I am facing the following issue when the zoomlevel is set to Level 3 which is custom =>147647947.5
System.InvalidOperationException: latitude or longitude exceeded limits
at ThinkGeo.Core.Overlay.<DrawAsync>d__77.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.MapViewBase.<DrawOverlayAsync>d__369.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.MapViewBase.<DrawOverlaysAsync>d__364.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.MapViewBase.<DrawAsyncCore>d__302.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.MapViewBase.<DrawAsync>d__301.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.MapViewBase.<RefreshAsync>d__288.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.MapViewBase.<RefreshAsync>d__287.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ThinkGeo.Core.MapViewBase.<ZoomStoryboard_Completed>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
The exception is from the reprojection. Can you check your code and make sure the projection is consistent with your data? Can you send over your code snippet regarding the layer/projection configuration?
I cannot recreate your issue. I tried the following code with your data and they all return correctly.
var converted1 = ProjectionConverter.Convert(27700, 3857, new PointShape(-724626.700055006, 863325.948658728));
var converted2 = ProjectionConverter.Convert(27700, 3857, new PointShape(1347611.70005501, -189425.948658728));
var vertices1 = new Vertex[] { new Vertex(-724626.700055006, 863325.948658728), new Vertex(1347611.70005501, -189425.948658728) };
var converted3 = ProjectionConverter.Convert(27700, 3857, new Feature(new LineShape(vertices1)));
var converted4 = ProjectionConverter.Convert(27700, 3857, new PointShape(0, 673900));
var converted5 = ProjectionConverter.Convert(27700, 3857, new PointShape(622985, 0));
var vertices2 = new Vertex[] { new Vertex(0, 673900), new Vertex(622985, 0) };
var converted6 = ProjectionConverter.Convert(27700, 3857, new Feature(new LineShape(vertices2)));
Here is a trick for you to debug, you can replace your ProjectionConverter with your own custom class:
var projectionConverter = new ProjectionConverter(internalProjection, externalProjection);
projectionConverter.Open();
projectionConverter.ConvertToExternalProjection(shape) <== this is the line which is causing error
The x value -24579533.175198 lies outside the “valid zone” supported by the built-in ProjectionConverter , so it cannot handle that coordinate. For a more robust transformation you can use GDAL’s converter:
Install the ThinkGeo.Gdal Nuget package
Use this code:
var projectionConverter = new GdalProjectionConverter(3857, 27700);
projectionConverter.Open();
var projected = projectionConverter.ConvertToExternalProjection(new PointShape(-24579533.175198, 13840383.2507416));
Note: EPSG 27700 is defined only for Great Britain. Converting coordinates far outside that region may produce inaccurate or misleading results.