ThinkGeo.com    |     Documentation    |     Premium Support

Centerpoint+Currentscale problem

Hi Ben, here are my logs.

I use DevExpress with all sorts of panels, so I can imagine the size changes a lot.

This is my log right after mapview_loaded:
ThinkGeo Message - 10:36:11.3506194: Resizing: ResizeMode: PreserveScale, Width: 2552, Height: 1082, Center: (600000, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0
ThinkGeo Message - 10:36:11.4161243: Resizing: ResizeMode: PreserveScale, Width: 2552, Height: 1114, Center: (600000, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0
ThinkGeo Message - 10:36:12.6167937: Resize_Tick Before Updating: ResizeMode: PreserveScale, Width: 2552, Height: 1114, Center: (600000, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0
ThinkGeo Message - 10:36:24.6221892: Resize_Tick After Updated: ResizeMode: PreserveScale, Width: 2552, Height: 1114, Center: (-40461177,001401, 19742762,5572991), CurrentScale: 2000000, Unit: Meter, Rotation: 0

Then I press ZoomNederlandAsync (the aerial photo becomes visible, but no log information).

After that I change the size of the map and then this is the log:
ThinkGeo Message - 10:40:27.8934297: Resizing: ResizeMode: PreserveScale, Width: 2314, Height: 1114, Center: (600000, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0
ThinkGeo Message - 10:40:28.3978460: Resize_Tick Before Updating: ResizeMode: PreserveScale, Width: 2314, Height: 1114, Center: (600000, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0
ThinkGeo Message - 10:40:28.4067456: Resize_Tick After Updated: ResizeMode: PreserveScale, Width: 2314, Height: 1114, Center: (709802,02404024, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0

Hi @G_Vandenboom and @Julian_Thoms,

Thank you guys for the log! They are really helpful!

I fixed the issue in the latest beta (14.4.0-beta011), please have a try.

Also just remind you guys the map has different Resizing mode; there’s a sample in the HowDoI where you can see the difference between the 3 Resizing Mode. You might want to try PreserveScaleAndCenter.

Thanks,
Ben

Hi Ben, thanks, that Beta fixed it!
Also that Resizing Mode is way better than the other one - why isn’t it the default? :smiley:

Thanks!

Hi Ben,

I’m sorry to inform you that this is not the solution for me :frowning:
I upgraded to beta012, but nothing changed.

This is my log from beta012:
ThinkGeo Message - 09:14:46.9347380: Resizing: ResizeMode: PreserveScale, Width: 2552, Height: 1113, Center: (600000, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0
ThinkGeo Message - 09:14:46.9821957: Resizing: ResizeMode: PreserveScale, Width: 2552, Height: 1114, Center: (600000, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0
ThinkGeo Message - 09:14:48.2782744: Resize_Tick Before Updating: ResizeMode: PreserveScale, Width: 2552, Height: 1114, Center: (600000, 6820000), CurrentScale: 2000000, Unit: Meter, Rotation: 0
ThinkGeo Message - 09:14:48.2896954: Resize_Tick After Updated: ResizeMode: PreserveScale, Width: 2552, Height: 1114, Center: (-40139547,6557915, 19051259,4642388), CurrentScale: 2000000, Unit: Meter, Rotation: 0

And changing the mapresize setting crashes my application with a System.NullReferenceException

Regards,
Guido van den Boom

Yeah, sadly the same issue also still happens to me, I don’t know why it didnt happen when I tried it yesterday…

ThinkGeo Message - 12:01:54.9678034: Resizing: ResizeMode: PreserveScale, Width: 832, Height: 603, Center: (0, 0), CurrentScale: 243121526,391922, Unit: Meter, Rotation: 0
ThinkGeo Message - 12:01:59.8119627: Resizing: ResizeMode: PreserveScale, Width: 812, Height: 603, Center: (638480,75, 5357773), CurrentScale: 150441,574559204, Unit: Meter, Rotation: 0
ThinkGeo Message - 12:02:04.6693234: Resize_Tick Before Updating: ResizeMode: PreserveScale, Width: 812, Height: 603, Center: (638480,75, 5357773), CurrentScale: 150441,574559204, Unit: Meter, Rotation: 0
ThinkGeo Message - 12:02:04.6820554: Resize_Tick After Updated: ResizeMode: PreserveScale, Width: 812, Height: 603, Center: (-26743401,0041272, 20025507,2314698), CurrentScale: 150441,574559204, Unit: Meter, Rotation: 0

Actually I have a pointer for you @Ben, I know why it worked yesterday, I changed the ResizeMode.
On PreserveScale this bug appears, changing it to MapResizeMode.PreserveScaleAndCenter fixes it.

@G_Vandenboom can you test if this fixes the issue on your end as well?

@Julian_Thoms, @Ben,
I tried that this morning, but setting the MapResizeMode to any value (PreserveExtent or PreserveScaleAndCenter) results in a System.NullReferenceException error and crashes my application.

This is the CallStack if it helps:

@G_Vandenboom @Julian_Thoms

I recreated that exception and figured it out. Please pull the latest beta013 and give it a try.

I was able to reproduce the exception when resizing the map in PreserveScaleAndCenter or PreserveExtent mode before the map is refreshed. The issue occurs because overlays are only initialized when the map is drawn (e.g., via map.RefreshAsync() ), if the map is resized before any refresh, it triggers a call to Overlay.Transform(RectangleShape targetExtent) , but the overlay hasn’t been initialized yet, which causes the exception.

In fact, I’m not very sure it will fix the other issue that the map will disappear after initialization in PreserveScale mode. Can you guys let me know if it still exists on your side?

@Julian_Thoms, I think you are right, it should be better to default it to PreserveScaleAndCenter :slight_smile: . we’ll make it happen after making sure there’s no issues around resizing.

FYI: there’s another user asking the similar question here: ThinkGeo 14.3.0 Map Initialization Exception - ThinkGeo UI for Desktop / WPF - ThinkGeo Discussion Forums

Thanks,
Ben

@Ben

I can confirm I can set the MapResizeMode now in mapview_loaded without exceptions !
When I set the MapResizeMode to PreserveScaleAndCenter or PreserveExtent the map does not disappear anymore. I get to see the aerial photo perfectly :wink:

When I set the MapResizeMode to PreserveScale or I do not set the MapResizeMode (default setting) then the map still disappears.

For me the PreserveScale is the prefered option, but I can live with PreserveScaleAndCenter for now.
Thank you !!

Update: I don’t know if it is the MapResizeMode or something else, but zooming in and out is not smooth anymore. The screen flashes white with every zoom step. Before the aerial photo zoomed in or out and then became sharper.

Regards,
Guido

That’s great, Guido! Can you make sure you’ve removed the following code? The log slows everything down. Let me know if the performance is still bad without the logs.

ThinkGeoDebugger.LogType = ThinkGeoLogType.Interaction;
ThinkGeoDebugger.LogLevel = ThinkGeoLogLevel.All;

We’ll keep working on PreserveScale.

Hi Ben,
I removed the ThinkGeoDebugger code lines, but still te flashes exist.
I create a short movie with the two versions. Version 25.5.125.0 of my application uses Thinkgeo 14.3.0.
The second part of the video uses the latest Beta013.

Link to the video flashing.mp4

Hi Guido,

Can you pull the latest beta015 and see if it fixed the PreserveScale and the flashing issue for you?

Thanks,
Ben

Hi Ben,
At first everything seems to be working fine.
PreserveScale shows the aerial map after mapview_loaded and the map is very smooth without flashing.

But with beta015 all my Zoom functions crash, like ZoomNederlandAsync and also the code below.
It seems like the values become out of range.

Public Sub ZoomToOverlay(ByVal Name As String)
    For Each OVL In ContentOverlays
        If OVL.Name = Name Then
            Try
                Me.CurrentExtent = OVL.GetBoundingBox
                Me.RefreshAsync()
            Catch
                MsgBox("Zoomen naar kaartlaag mislukt!", vbCritical)
            End Try
        End If
    Next
End Sub

What can I check for you to understand what’s creating this crash?

Hi Guido,

I couldn’t recreate your issue. Can you send me the error/exception you see? If possible can you enable the log as following, and send me all the logs in output window?

ThinkGeoDebugger.LogType = ThinkGeoLogType.All;
ThinkGeoDebugger.LogLevel = ThinkGeoLogLevel.All;

  1. Ideally you need to make the method async and refresh the map with await:
    await Me.RefreshAsync()
    Otherwise multiple Me.RefreshAsync() might be running concurrently.

Thanks,
Ben

Hi Ben,

This is the error/exception:
“An unhandled exception of type System.ArgumentOutOfRangeException occurred in PresentationFramework.dll
The specified argument is outside the range of valid values.”

I have included the Thinkgeo log with the ‘All’ settings and also the Call Stack.
I executed ‘ZoomNederlandAsync’ to recreate the crash.

Call Stack beta015.txt (3.3 KB)
Thinkgeo log beta015.txt (54.9 KB)

It doens’t matter if I use the aerial photo or OpenStreetMap, the same issue occurs.

I have existing tilecaches, which seem to be out of sync with the new scales ??
When I deleted the existing caches I execute ZoomNederlandAsync, it doesn’t crash but the map is empty (no aerial photo).
Zooming In and Out recreates the cache.

Deleting the cache for another overlay does not work by the way.

Seems to me like there is a mismatch between the tilecache scale and the zoomscale ?
When I empty the cache for some overlays it works untill I zoom with SHIFT/Mouse select.
After that the exception occurs.

Hi Guido,

The exception was thrown because multiple mapview.RefreshAsync() was executing concurrently. Please pull the latest beta016, where we added more check and should prevent the exception. But a better way is in your code, always await the async method; or cancel the previous drawing when the 2nd drawing kicks off.

About the tilecache, can you let me know which version worked correctly and since which version started to have issues? Can you share more of your code?

Just FYI, the map’s zoomscales and TileOverlay can be different. it will show correctly even if they are different, and the following code would sync the two:
MapView.ZoomScales = tileOverlay.TileMatrixSet.GetScales();

Thanks,
Ben

Hi Ben,

The latest beta016 is working perfectly. No exceptions and the map is showing pretty smooth.
This beta016 also works while I have not changed the RefreshAsync to be awaited yet.
(Off course I will listen to your tip and change the calls to be awaited).

Beta013 was working just fine, the first time the error occurs is in beta014.

Sharing my code is difficult, but I’m happy to inform that I easily managed to reproduce the error in de HowDoI WPF samples. Although beta016 is working, maybe this helps to optimize the code.

  1. Set the ThinkGeo version to beta014.
  2. Go to the OpenStreetMap.xaml.cs
  3. Add layerOverlay.TileCache = new FileRasterTileCache(@".\cache", “Error”); to mapview_loaded
  4. Add this function to the file:
    private void BtnTest_Click(object sender, RoutedEventArgs e)
    {
    MapView.CenterPoint = new PointShape(600000, 6820000);
    MapView.CurrentScale = 2000000;
    MapView.RotationAngle = 0;
    _ = MapView.RefreshAsync();
    }
  5. Start the application and go to OpenStreetMap. After some panning around and zooming in and out, click on the button.

I tried also with beta016 en no problem then.

I hope this helps !

Regards,
Guido

HI Guido,

I recreated the flashing issue using your demo code with beta014, and verified it’s been fixed in beta016, thanks for sharing!

Thanks,
Ben

Also Guido, I’m going to default MapResizeMode to PreserveScaleAndCenter. Please set it to PreserveScale if that’s what you prefer.

@Julian_Thoms so In the future versions (beta017 and newer) it will default to PreserveScaleAndCenter.

Thanks,
Ben