ThinkGeo.com    |     Documentation    |     Premium Support

ZoomLevel issue

Hi Team,

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)

I am using ThinkGeo version 14.2.6

Can some one please help here?

Thanks,
Jayshree

Hi Jayshree,

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?

Thanks,
Ben

Hi Ben,

I am using the following projection,

InternalProjection => 27700
ExternalProjection => 3857

Shape => -724626.700055006,863325.948658728,1347611.70005501,-189425.948658728
Shape => {0,673900,622985,0}

Thanks,
Jayshree

More information,

shape => -29618123.0525023,16173294.2177723,0

Hi Jayshree,

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:

class MyProjectionConverter : ProjectionConverter
{
    protected override Collection<Vertex> ConvertToExternalProjectionCore(IEnumerable<Vertex> verticies)
    {
        return base.ConvertToExternalProjectionCore(verticies);
    }
}

Then whenever it throws an exception, you can get the vertices which causes the exception. Send over those vertices to us and we can dig in.

Thanks,
Ben

shape => -29618123.0525023,16173294.2177723,0

Have u tried with this vertices??

Yes, did you try it on your side?

Hi Ben,

Sorry for the confusion, I am using following

var projectionConverter = new ProjectionConverter(internalProjection, externalProjection);
projectionConverter.Open();
projectionConverter.ConvertToExternalProjection(shape) <== this is the line which is causing error

inputs :
shape => -24579533.175198,13840383.2507416,0
internalProjection =>3857
externalProjection => 27700

Could you please help here?

Thanks,
Jayshree

Hi Jayshree,

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:

  1. Install the ThinkGeo.Gdal Nuget package

  2. 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.

Thanks,
Ben

Thanks Ben!!!
Appreciate your help on this.

My Pleasure, Jayshree!