I am wondering is there a bug with setting layer coordinate system with WKT file?
When I set coordinate system by code (CoordSystemCode.PCS_MGIBalkans_7) I get good results with overlay .shp layer above GoogleMap satellite layer.
When I set the same coordinate system by WKT file http://spatialreference.org/ref/epsg/31277/ogcwkt/, overlay layer is always (I tried changing many parameters) about 20km southern then it should be.
I'm asking because I need to make custom projection in form of WKT so I need to be sure that there is no bug.
Thank you,Djordje Novakovic
The WKT has the TOWGS84 transformation tag. AspMap currently has no data for such transformation(for PCS_MGIBalkans_7 to WGS84), thereby your WKT and the resulting map image should be more correct.
I made some experiments in GoogleMaps sample application:
I created custom coordinate system: CoordSystem cs1 = new CoordSystem(); string wkt = @"PROJCS[…. some wkt data …. "; cs1.SetWKT(wkt);
I created one point in the center of Belgrade in local coordinate system:AspMap.Point point1 = new AspMap.Point(7458211, 4962126);
Created the other point in Google maps coordinate system and put a marker on it:AspMap.Point googlePoint1 = map.CoordinateSystem.TransformPoint(cs1, point1);map.Markers.Add(new Marker(googlePoint1, "CS set by WKT"));
Marker is about 20km southern from Belgrade center.
But, when I first transform point1 in WGS84 and then in Google maps coordinate system, marker gets perfect position!AspMap.Point googlePoint1 = map.CoordinateSystem.TransformPoint (CoordSystem.WGS1984, cs1.ToWgs84(point1));map.Markers.Add(new Marker(googlePoint1, "CS set by WKT"));
Problem is when I want to put layer in custom coordinate system (based on WKT) above Google maps. Layer data is always about 20km southern from its correct position.
It looks like you forget to include some “to WGS84” and “from WGS84” steps when making WKT coordinate system transformation? Or I’m missing something?
You have to add a TOWGS84 tag to your custom coordinate system.
But I'm always using WKT with TOWGS tag. That's something I assume.
If you click the link in the first post you will see "TOWGS84[577.326,90.129,463.919,5.137,1.474,5.297,2.4232]"
I'm using some other parameters, more suitable for Sebia but that's not important.
Conversion to WGS84 works perfectly. Problem is conversion to GoogleMap coordinate system.
This thing with coordinates conversion is major problem to us. Everything else in using AspMap control is (almost) excellent.
Thank you for responses,Djordje
In this case conversion should work correctly.
If it is not, try to put the WKT into a .prj file with the file name the same as for the .shp.
It this does not help too, please send us the shapefile and source code.