Integer overlow issues when using large area map files and zooming in

7 views
Skip to first unread message

b3nn0

unread,
Apr 29, 2021, 7:31:05 AMApr 29
to Mapsforge & VTM

Hi,
I noticed that the map vanishes when zooming in a lot while using a larger map file (e.g. Germany, or even a MultiMapFile with multiple countries).
Similar issues had been discussed/fixed here: https://github.com/mapsforge/mapsforge/issues/572
but this is a different one.

While rendering itself seems to work just fine, the issue happens afterwards when trying to fill the background.

Relevant code:
DatabaseRenderer uses canvasRasterer.fillOutsideAreas() and passes it the MapFile's bounding box (coordinates relative to the tile boundary).
When zooming in a lot, this can easily become -1E9/1E9.
CanvasRasterer then uses setClipDifference and casts all parameters to int (as the canvas wants it). However, these ints will then overflow.

If I can see it correctly, AwtCanvas could work with double based clipping just fine, but Android's canvas can not? I guess a custom workaround would be needed for this? Any idea for a fix?

Emux

unread,
Apr 29, 2021, 7:37:22 AMApr 29
to mapsfo...@googlegroups.com
What large zoom?

Because all map libraries have a max zoom limit.

--
Emux

b3nn0

unread,
Apr 29, 2021, 7:40:37 AMApr 29
to Mapsforge & VTM
Well, depends on the size of the map file of course.
For germany.map, it happens at zoom 28, so not that bad. For the large MultiMapFile I'm using in practice (pretty much whole world), it happens at zoom 23 IIRC. Which is not terrible, but also not optimal for high precision applications (RTK GPS and stuff like that)

Emux

unread,
Apr 29, 2021, 7:57:21 AMApr 29
to mapsfo...@googlegroups.com
Mapsforge maps though not designed for indoor mapping,
they store coordinates in microdegrees (degrees × 1E6).

This is a precision of (around) 11 cm:
https://wiki.openstreetmap.org/wiki/Precision_of_coordinates

Usually a max zoom 20-22 should be enough for most cases.
(like most other map engines, Google Maps, Mapbox, etc)

--
Emux
Reply all
Reply to author
Forward
0 new messages