Hi,
In our software we have the following settings:
setting.ReprojectLayersOnAdding = true;
setting.AllowProjectionMismatch = true;
We set a map projection and so any shapefiles added are reprojected to the map projection on adding. This is working sometimes but not always and in those cases I get e.success of false in the layer reprojected event, as you’d expect (last error code is 0).
An example is reprojecting WGS 84 UTM_60S (EPSG Code 32760) → British National Grid (EPSG Code 27700). This fails. I’ve also tried it going the other way, which does not work either.
I’ve included an example (with data) that illustrates the problem. I am using an older version of MapWinGIS day to day at the moment, but I have tested this in 5.2 with the same outcome.
I’ve used gdalsrsinfo to check the .prj files are sound and you’ll see from running the code MapWindow can import the projection from them, so all seems good there.
A separate issue I noticed when building the example is that if I set the map projection from importing the wkt then the “base” (British National Grid) shapefile polygon is slightly offset and in the incorrect position. If I use GrabProjectionFromData then the polygon is in the right place. We don’t have GrabProjectionFromData set in our production application and it appears in the correct place there, so not sure what is going on here. If I export the geoprojection created from importing the wkt and also the map projection created by using GrabProjectionFromData, they are almost exactly the same, except the imported one has:
DATUM["D_OSGB_1936",
and the map one has
DATUM["OSGB_1936",
I think this is unrelated to my reprojection issue. Looking at my example should hopefully make what I’m trying to explain a bit clearer.
Regards,
Rob HReprojectionProblem.zip (1.5 MB)