ThinkGeo.com    |     Documentation    |     Premium Support

MapUtil.ToWorldCoordinate get Decimal Degrees

Is there a way to always get Decimal Degrees with MapUtil.ToWorldCoordinate?
When map Units are set to decimal degree SRID 4326 I can get decimal degrees from this function as desired.
But when in mercator projection SRID 3395 in Meter, I always get meter values from this function. But they do not appear to be Northing, Easting Values, so I am not sure how to convert to Degrees.
To make my solution work I either need an option for decimal degrees always from this function or a way to use mercator with Degrees and not meters which does not appear to be a valid choice with Proj.

I tried to use Proj convert string as per: https://proj.org/operations/conversions/unitconvert.html
But it does not seem to be supported with the wrapped version of the library in thinkGeo dependencies.

Thanks Chris,
You can use the projection converter to convert it to 4326.

ProjectionConverter projectionConverter = new ProjectionConverter(3395, 4326);
projectionConverter.Open();
PointShape newCenterPoint = projectionConverter.ConvertToInternalProjection(centerPoint) as PointShape;

Thanks

Frank

I tried the code snippet you sent, but I got the following exception:
“latitude or longitude exceeded limits”
My map is in Meters (Mercator). Here is the rest of my code in this section:
Point currentPoint = e.GetPosition(GlobalObjects.Instance.Map);
PointShape worldPoint = MapUtil.ToWorldCoordinate(GlobalObjects.Instance.Map.CurrentExtent, (float)currentPoint.X, (float)currentPoint.Y, (float)GlobalObjects.Instance.xMap.ActualWidth, (float)GlobalObjects.Instance.Map.ActualHeight);

Here is an example value of my centerPoint that fails conversion.
{-2490404.26965435,-1591905.47432807,0}

Nevermind, I needed to use .ConvertToExternalProjection.
Now it works fine, thanks.

Thanks Chris,
Good to know it works. Let us know if you have any more question.

Thanks

Frank