You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you just load the world.map from mapsforge maps and zoom to level 22-24, then it isn't displayed anymore correctly. The problem seems to be the calculation of the insideArea in the DatabaseRenderer and the call to renderContext.canvasRasterer.fillOutsideAreas(Color.TRANSPARENT, insideArea);. In the method fillOutsideAreas there is a cast to int, which may give wrong result if the map has the bounding box of the whole world.
So obviously nobody will just visualize the world map and go to this zoom level, but with nice feature of the MultiMapDataStore it make sense to have the world map and e.g. the germany.map from openandromaps loaded. If you zoom to 22 or larger, then the visualization of the germany.map doesn't work anymore due to this problem.
Thanks for the fast reply. I've just integrated and tested and ... surprisingly the problem still exists. I wonder whether the native code is doing some cast to integer too.
I know that I can easily limit the zoom level - but in rare cases (problems with my routing) it was very useful to zoom in and see each single microdegree of the way objects, so I rather would like to keep this in.
I wonder what is the use case for this clip operation. A map like germany anyway does not fill a rectangular bouning box, where I can clip it in a way that make sense. And with a MultiMapDataStore which contains also the world.map there isn't anything to clip. So what's the rationale to do this operation?
There was floating point overflow, at least on Android whose methods work with float.
MultiMapLowResWorld shows 2 ways to limit the zoom levels of the map files.
We could perhaps improve it further, so that the world map does not affect the render calls of other maps.
I would like to rise again the question about the added value of this clip operation:
I wonder what is the use case for this clip operation. A map like germany anyway does not fill a rectangular bouning box, where I can clip it in a way that make sense. And with a MultiMapDataStore which contains also the world.map there isn't anything to clip. So what's the rationale to do this operation?
From my perspective this clip operation can be skipped - then it cannot cause any problem.
So the reason seems simple. Canvas.clipOutRect() / Canvas.clipRect() probably shouldn't be fed with map-space coordinates, values be like 1.4E10, but with its local coordinates instead, as the javadoc on clipOutRect() says.
Yes, I've commented out these lines and at least in my default use case this works fine, including zoom levels 22..24.
Yup, confirmed. Couldn't get past 22 for whatever reason, but it also occured at levels around 20-21 in the end. The most probable reason is written above, if you want to tackle it without removing the fillOutsideAreas lines.
It can help to do first the intersection of the bounding boxes and then convert this to the relative location. For this purpose add a method to BoundingBox:
/**
* @param boundingBox the BoundingBox which should be checked for intersection with this BoundingBox.
* @return BoundingBox that intersects with the given BoundingBox.
*/
public BoundingBox intersect(BoundingBox boundingBox) {
if (this == boundingBox) {
return this;
}
double maxLatitude = Math.min(this.maxLatitude, boundingBox.maxLatitude);
double minLatitude = Math.max(this.minLatitude, boundingBox.minLatitude);
double maxLongitude = Math.min(this.maxLongitude, boundingBox.maxLongitude);
double minLongitude = Math.max(this.minLongitude, boundingBox.minLongitude);
return new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude);
}
Activity
Canvas.setClipDifference use float values, fix #1659
Canvas.setClipDifference use float values, fix #1659 (#1660)
devemux86 commentedon Feb 25, 2025
@mg4gh Thanks for the report and also for checking the code. 👍
This should be fixed now with #1660.
Unless using indoor maps, there is no reason to use such high zoom levels above 20-22.
You can control the zoom level limits with:
Zoom level 20 has 0.1 m / pixel: https://wiki.openstreetmap.org/wiki/Zoom_levels
mg4gh commentedon Feb 25, 2025
Thanks for the fast reply. I've just integrated and tested and ... surprisingly the problem still exists. I wonder whether the native code is doing some cast to integer too.
I know that I can easily limit the zoom level - but in rare cases (problems with my routing) it was very useful to zoom in and see each single microdegree of the way objects, so I rather would like to keep this in.
I wonder what is the use case for this clip operation. A map like germany anyway does not fill a rectangular bouning box, where I can clip it in a way that make sense. And with a MultiMapDataStore which contains also the world.map there isn't anything to clip. So what's the rationale to do this operation?
devemux86 commentedon Feb 25, 2025
@mg4gh What Android version?
Do you see it on a device or Android emulator?
mg4gh commentedon Feb 25, 2025
Android 15 on an emulator.
Do you expect a different behaviour with a real device?
Canvas.setClipDifference clamp float values, fix #1659
Canvas.setClipDifference clamp float values, fix #1659 (#1661)
devemux86 commentedon Feb 26, 2025
There was floating point overflow, at least on Android whose methods work with
float.MultiMapLowResWorld shows 2 ways to limit the zoom levels of the map files.
We could perhaps improve it further, so that the world map does not affect the render calls of other maps.
Sublimis commentedon Feb 26, 2025
@devemux86 Please undo #1661 and let's be reasonable about it.
if (value < Float.MIN_VALUE) return Float.MIN_VALUE?? Come on, we can do better.6 remaining items
devemux86 commentedon Feb 26, 2025
No problem, as these large zoom levels are not usable anyway.
devemux86 commentedon Feb 26, 2025
Anyway, it seems to work on desktop.
mg4gh commentedon Feb 26, 2025
I would like to rise again the question about the added value of this clip operation:
From my perspective this clip operation can be skipped - then it cannot cause any problem.
devemux86 commentedon Feb 26, 2025
@mg4gh
About where it is used, see the documentation in the CanvasRasterer.fillOutsideAreas methods.
Load a country map without world map and zoom out,
we should see theme's
map-background-outsidecolor outside the map (not white tiles).Sublimis commentedon Feb 26, 2025
Have you tried without it? Are you 100% sure the problem doesn't occur when lines 120-128 of
DatabaseRendererare commented out?Sublimis commentedon Feb 26, 2025
So the reason seems simple.
Canvas.clipOutRect()/Canvas.clipRect()probably shouldn't be fed with map-space coordinates, values be like1.4E10, but with its local coordinates instead, as the javadoc onclipOutRect()says.mg4gh commentedon Feb 26, 2025
Yes, I've commented out these lines and at least in my default use case this works fine, including zoom levels 22..24.
Sublimis commentedon Feb 26, 2025
Yup, confirmed. Couldn't get past 22 for whatever reason, but it also occured at levels around 20-21 in the end. The most probable reason is written above, if you want to tackle it without removing the
fillOutsideAreaslines.mg4gh commentedon Feb 26, 2025
It can help to do first the intersection of the bounding boxes and then convert this to the relative location. For this purpose add a method to BoundingBox:
and then change DatabaseRenderer line 122:
This provides the clipping as today and it works well with zoom level 22..24
Sublimis commentedon Feb 26, 2025
#1664
devemux86 commentedon Feb 27, 2025
This should be solved by #1664.