Mar 6, 2010 at 9:37 AM
Edited Mar 6, 2010 at 9:40 AM
Hi Raghu, first you need to decide on the spatial reference system you want for the map. Lets assume WGS84.
We can look the wkt up on http://spatialreference.org
which gives us:
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],
(note I have added random line breaks so that it displays ok on codeplex)
Because the data in the database is also in WGS84 we do not need to transform the database layers at all so the data can be added without change.
For the Shapefile layers we will need to transform them into the same spatial reference system we do this by creating an instance of an ICoordinateTransformation.
Basically we reference ProjNet from the External References folder.
Then we create an ICoordinateSystem by parsing the wkt for WGS84 (see link above).
Shapefile provider already has a CoordinateSystem property which is fed by the .prj file associated with the .shp file - we do not need to do anything special here.
We then create the ICoordinateTransform which converts geometries from the the source projection (i.e the one from the shapefile) to the target (i.e the one from the WGS84 wkt) also detailed in the link above.
Then we set the CoordinateTransformation property on the Layer that the Shapefile feeds.
That should fix up your projections.
The main issue that you may come across is if there is no .prj file accompanying the .shp file. In this case the CoordinateSystem property on the Shapefile provider will be null and you will have to find out what spatial reference system the data actually
belongs in, locate and parse the wkt for the srs into a suitable ICoordinateSystem before creating the transform.