ThinkGeo.com    |     Documentation    |     Premium Support

Overlay and Layer DrawingExceptionMode

Hey,

I have a TIFF file with world file attached to it.

However image does not have projection information in it’s meta (I know it should be
ETRS-TM35FIN but it’s just not there) and no .PRJ file attached.

Now when I try to draw this image and project it to WebMercator, there’s “index was out of bounds” error drawn on the map.

This is expected behavior but I’d like to catch these errors and show some meaningful error message to the user. Unfortunately setting DrawingExceptionMode to DrawingExceptionMode.ThrowException still doesn’t throw the exception or at least it doesn’t bubble up to my application. Only thing that changes is that exception is not drawn on the map.

How could I go about with this?

Thanks Mikko,
During working on Exception gets thrown even with DrawException set
I found even we set
thinkGeoCloudVectorMapsOverlay.DrawingExceptionMode = DrawingExceptionMode.ThrowException;
The main threading may not get notification and threw an error. Because the exception is in the C# task method it is not observed. You need turn the option on.
More details is here

Basically just copy
< runtime>
< ThrowUnobservedTaskExceptions enabled=“true”/>
< /runtime>

to you app.config.

For your case you could set thinkGeoCloudVectorMapsOverlay.DrawingExceptionMode = DrawingExceptionMode.DrawException;
and hookup DrawingException event to notify the user. here is the full code.

  private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Set the map's unit of measurement to meters(Spherical Mercator)
            mapView.MapUnit = GeographyUnit.Meter;

            // Add Cloud Maps as a background overlay
            var thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light);
            thinkGeoCloudVectorMapsOverlay.DrawingExceptionMode = DrawingExceptionMode.DrawException;

            thinkGeoCloudVectorMapsOverlay.DrawingException += ThinkGeoCloudVectorMapsOverlay_DrawingException;

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            // Set the map extent
            mapView.CurrentExtent = new RectangleShape(-10786436, 3918518, -10769429, 3906002);
        }

        private void ThinkGeoCloudVectorMapsOverlay_DrawingException(object sender, DrawingExceptionTileOverlayEventArgs e)
        {
            MessageBox.Show(e.Exception.ToString());
        }

Thanks

Frank

1 Like