Skip to content

world.map doesn't work on zoom level 22-24 #1659

Description

@mg4gh

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.

A user of my app has this problem reported.

Activity

  1. added this to the 0.24.0 milestone on Feb 25, 2025
  2. added a commit that references this issue on Feb 25, 2025
    93ec9a6
  3. added a commit that references this issue on Feb 25, 2025
    b283174
  4. devemux86 commented on Feb 25, 2025

    @devemux86
    Collaborator

    @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:

    mapView.getModel().mapViewPosition.setZoomLevelMin(2);
    mapView.getModel().mapViewPosition.setZoomLevelMax(20);

    Zoom level 20 has 0.1 m / pixel: https://wiki.openstreetmap.org/wiki/Zoom_levels

  5. mg4gh commented on Feb 25, 2025

    @mg4gh
    ContributorAuthor

    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?

  6. devemux86 commented on Feb 25, 2025

    @devemux86
    Collaborator

    @mg4gh What Android version?
    Do you see it on a device or Android emulator?

  7. mg4gh commented on Feb 25, 2025

    @mg4gh
    ContributorAuthor

    Android 15 on an emulator.

    Do you expect a different behaviour with a real device?

  8. added 2 commits that reference this issue on Feb 26, 2025
    8b1c1f4
    9ee923e
  9. devemux86 commented on Feb 26, 2025

    @devemux86
    Collaborator

    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.

  10. Sublimis commented on Feb 26, 2025

    @Sublimis
    Contributor

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

  11. 6 remaining items

  12. devemux86 commented on Feb 26, 2025

    @devemux86
    Collaborator

    No problem, as these large zoom levels are not usable anyway.

  13. devemux86 commented on Feb 26, 2025

    @devemux86
    Collaborator

    Anyway, it seems to work on desktop.

  14. mg4gh commented on Feb 26, 2025

    @mg4gh
    ContributorAuthor

    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.

  15. devemux86 commented on Feb 26, 2025

    @devemux86
    Collaborator

    @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-outside color outside the map (not white tiles).

  16. Sublimis commented on Feb 26, 2025

    @Sublimis
    Contributor

    From my perspective this clip operation can be skipped - then it cannot cause any problem.

    Have you tried without it? Are you 100% sure the problem doesn't occur when lines 120-128 of DatabaseRenderer are commented out?

  17. Sublimis commented on Feb 26, 2025

    @Sublimis
    Contributor

    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.

  18. mg4gh commented on Feb 26, 2025

    @mg4gh
    ContributorAuthor

    From my perspective this clip operation can be skipped - then it cannot cause any problem.

    Have you tried without it? Are you 100% sure the problem doesn't occur when lines 120-128 of DatabaseRenderer are commented out?

    Yes, I've commented out these lines and at least in my default use case this works fine, including zoom levels 22..24.

  19. Sublimis commented on Feb 26, 2025

    @Sublimis
    Contributor

    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.

  20. mg4gh commented on Feb 26, 2025

    @mg4gh
    ContributorAuthor

    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);
        }
    

    and then change DatabaseRenderer line 122:

    Rectangle insideArea = this.mapDataStore.boundingBox().intersect(rendererJob.tile.getBoundingBox()).getPositionRelativeToTile(rendererJob.tile);
    

    This provides the clipping as today and it works well with zoom level 22..24

  21. Sublimis commented on Feb 26, 2025

    @Sublimis
    Contributor
  22. added this to the 0.24.0 milestone on Feb 27, 2025
  23. devemux86 commented on Feb 27, 2025

    @devemux86
    Collaborator

    This should be solved by #1664.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions