I have some polygons in SQL Server 2008 database stored as Geometries. Now I would like to create a map with the following specs:
Layer 1 will be a VectorLayer with its DataSource set to a ShapeFile. The PRJ file for this shape file has the following WKT:
Layer 2 will also be a VectorLayer with its DataSource set to GeometryFeatureProvider. For legacy reasons I am not using the SqlServer2008 provider as the data source. The SRID of all the features in this layer would be 4326 (i.e., WGS 84)
Now, the map loads and then I can see the features from the Shape File in the Top Right corner of the screen, and features in the 2nd layer don't even show up. I believe that some kind of reprojection/transformation has to be done for this to work, but I
am totally lost on what exactly needs to be done.
Jun 20, 2010 at 2:55 PM
Edited Jun 20, 2010 at 6:52 PM
to do on the fly reprojection of your layer, you have to set up coordinate transformation (see
this). The steps you need to do are
- Add reference to GeoAPI.Net and Proj.Net.
- Get WKT for EPSG:4326 (www.spatial-reference.org) and use CoordinateSystemFactory.CreateFromWKT to parse it (-> CS1).
- Get Coordinate System from ShapeFile using ((Shapefile)Layer1.DataSource).CoordinateSystem (->CS2)
- Use CoordinateTransformationFactory to set up CoordinateTransformation.CreateFromCoordinateSystems(CS1, CS2) (-> CT)
- Apply CT to your ((VectorLayer)Layer2).CoordinateTransformation.