Skip to content

Being able to render tile by tile #1085

Closed

Description

@monsieurtanuki

Regarding DatabaseRenderer:

  • the purpose is to render tiles
  • in the context of a visible map
  • being called by an instance of MapWorkerPool

But that doesn't match a slightly different way of seeing things: a simple "give me that tile".
Because DatabaseRenderer:

  • interacts with MapWorkerPool so that it forces a display refresh (MapWorkerPool.this.layer.requestRedraw();), that we don't want here
  • includes some optimizations, like not writing twice the same label (cf. Set<MapElementContainer> undrawableElements), that provokes side-effects (cf. Bug with MapForge in OpenStreetMapViewer osmdroid/osmdroid#1145)
  • in this last case, potentially because of a bug - as elements are never removed from tileDependencies except in MapWorkerPool, that we don't want to use because of the display refresh

My suggestion is to create a dedicated class that extends StandardRenderer.
The purpose is to have the same level of quality as DatabaseRenderer, but in a simpler context where we will avoid side-effects.
The name will be something like DirectRenderer.

Activity

  1. devemux86 commented on Sep 8, 2018

    @devemux86
    Collaborator

    Mapsforge is not meant to be a raster tile generator, there are specific tools for that, like the ones used by all online raster tile providers.

    Also Mapsforge offers more advanced real-time rendering of labels + symbols in separate layer, which cannot be written in the raster tiles of the map.

    BTW Mapsforge has not any rendering problems via its engine. So cannot know how any external implementations use its low level API correctly or not.

    However if someone wants to provide pull request which:

    • Doesn't break library's current working behavior
    • Can work as extension to help such workflows

    We can certainly review it.

  2. devemux86 commented on Sep 8, 2018

    @devemux86
    Collaborator

    There is the SaveTiles sample demonstrating similar workflow.

  3. monsieurtanuki commented on Sep 8, 2018

    @monsieurtanuki
    ContributorAuthor

    @devemux86 Oh of course I didn't mean to imply that rasters are better than vectors or that the only point of Mapsforge is to build rasters. Different technology, different usages.

    Thanks for your SaveTiles sample. It's more or less what we used to do, and we may encounter the side-effects I described: if we repeatedly ask for the same neighboring tiles, sometimes the labels are not consistent anymore.

    Btw I don't seem able to push, I get an error 403. Any idea why? (I'm not a git expert)

  4. devemux86 commented on Sep 8, 2018

    @devemux86
    Collaborator

    Can check this forum discussion for more details.

    Btw I don't seem able to push, I get an error 403. Any idea why?

    Push where?

  5. monsieurtanuki commented on Sep 8, 2018

    @monsieurtanuki
    ContributorAuthor

    Push my commit to mapsforge, in order to create a pull request.

  6. devemux86 commented on Sep 8, 2018

    @devemux86
    Collaborator

    Only administrators can push commits in Mapsforge repositories. 🙂
    Perhaps you can check GitHub documentation about pull requests.

  7. monsieurtanuki commented on Sep 9, 2018

    @monsieurtanuki
    ContributorAuthor

    Looks like I was doing the right thing, but not from the right place.
    I've just create the PR #1086.

  8. added this to the 0.11.0 milestone on Sep 9, 2018
  9. devemux86 commented on Sep 9, 2018

    @devemux86
    Collaborator

    Closed via #1086.

  10. devemux86 commented on Sep 9, 2018

    @devemux86
    Collaborator

    You can use it via snapshot builds published in Sonatype.

  11. monsieurtanuki commented on Sep 9, 2018

    @monsieurtanuki
    ContributorAuthor

    @devemux86 Thank you, it works perfectly with the SNAPSHOT version!

    Obviously I cannot keep master-SNAPSHOT as a version number for our app (osmdroid) in production.
    How does it work from now: when do you plan to create a new version with a real version number?
    On our side there's no big hurry on the subject, but I'd like to know when I'm able to merge my fix on osmdroid.

  12. devemux86 commented on Sep 9, 2018

    @devemux86
    Collaborator

    Very nice to hear that, please make extensive tests to verify it! 🙂

    I can publish a 0.10.1 release, but since we just had 0.10.0, prefer to wait a bit to see if something critical comes up.

  13. monsieurtanuki commented on Sep 9, 2018

    @monsieurtanuki
    ContributorAuthor

    @devemux86 That's fine by me. Just tell me when you're ready, and on our side we keep testing it.

  14. 3 remaining items

  15. monsieurtanuki commented on Sep 11, 2018

    @monsieurtanuki
    ContributorAuthor

    @ludwigb Thank you for your comment.

    That's what appears in the code but was not part of my initial assumptions: there's no such thing as a unique tile for zoom,x,y in mapsforge.

    What you display depends on what you displayed before.
    First, display whatever label that overlaps from neighboring tiles and that has been displayed.
    Second, display all the labels of the current tile, ordered by priority, and that don't collide with the neighbors' labels.

    I guess it can be marginally flawed, e.g. when you already displayed in neighboring tiles unimportant labels that prevent you from displaying an important label on the current tile (because of collision).

    Regardless, I guess the whole process is OK if you display maps.

    But I display tiles, and here's the additional issue I need to address: taking into account overlapping labels from neighboring tiles that have not been processed yet.
    I think that means a third step in my case:

    • adding all the labels from neighboring tiles that haven't been processed yet
    • if those labels overlap with the current tile

    Or something like that.

  16. applantation commented on Sep 12, 2018

    @applantation
    Collaborator
  17. monsieurtanuki commented on Sep 12, 2018

    @monsieurtanuki
    ContributorAuthor

    @ludwigb Here is how my problem is different:

    • I render tile (z,x,y) on the bottom of the screen - I save it as a 256x256 bitmap and put it in my memory cache
    • I pan downwards and have to display tile (z,x,y+1), that happens to have an overlapping label with the previous tile - I save it as a 256x256 bitmap, including the part of the overlapping label that fits into this tile, and put it in my memory cache
    • I now have a broken label in my memory cache, partly displayed in tile (z,x,y+1) but not at all displayed in tile (z,x,y) - and that's not good because I display what is in the memory cache - a broken label
    • I assume that in mapsforge it's not that bad - I assume that first you display tile (z,x,y) without the label, but as soon as you display tile (z,x,y+1) you display fully the label in both tiles. I'm not sure about that, but obviously you don't have this problem in the standard use of mapsforge.
    • Of course if for some reasons my tiles are not stored in my memory cache anymore, then they will be recomputed and with the tileDependencies mechanism used by mapsforge, the label will appear in both tiles
    • A solution for me could be to say - if when rendering tile (z,x,y+1) I notice that there's a label that should fit into tile (z,x,y) but was not previously taken into account, then I must "deprecate" the (z,x,y) bitmap and remove it from the memory cache. It will then be recomputed and include the label
    • Another solution would be to assume that labels don't span over more than 2 neighboring tiles (or that we can live with marginal beyond 2 tiles) and that checking the 8 neighboring tiles' labels is enough
  18. devemux86 commented on Sep 12, 2018

    @devemux86
    Collaborator

    I assume that in mapsforge it's not that bad - I assume that first you display tile (z,x,y) without the label, but as soon as you display tile (z,x,y+1) you display fully the label in both tiles.

    No, that doesn't work that way in Mapsforge, the aforementioned forum discussion describes the mechanism.

  19. ludwigb commented on Sep 12, 2018

    @ludwigb
    Collaborator
  20. monsieurtanuki commented on Sep 12, 2018

    @monsieurtanuki
    ContributorAuthor

    @ludwigb I'm more optimistic than you for 2 reasons:

    • sure there might be some recursion, but the tiles will be deprecated only if needed (e.g. overlapping label not being taken into account before)
    • the limit is not the world, but my memory cache - I won't deprecate tiles I don't currently display

    I'll let you know how things evolve.

  21. monsieurtanuki commented on Sep 19, 2018

    @monsieurtanuki
    ContributorAuthor

    Could be somehow solved by osmdroid/osmdroid#1156.

  22. devemux86 commented on Sep 19, 2018

    @devemux86
    Collaborator

    Vector maps on mobile devices certainly should have variable tile size (like Mapsforge and VTM provide), but the extra tile space does not remove the need for special handling of labels at tile borders.

  23. monsieurtanuki commented on Sep 19, 2018

    @monsieurtanuki
    ContributorAuthor

    @devemux86 I agree with you, but in order to implement what I originally had in mind I would have needed to introduce some kind of callbacks into DatabaseRenderer, and I want to have zero impact on it.
    Perhaps I will have to add those callbacks anyway (on a copy of DatabaseRenderer?), perhaps I won't have to do it because of the way I manage the cache, so far I don't know.

  24. devemux86 commented on Sep 19, 2018

    @devemux86
    Collaborator

    New DirectRenderer is meant for changes and external use, being in same package with similar access.

    DatabaseRenderer in not used externally, remains for library purposes and should avoid changes.

  25. monsieurtanuki commented on Sep 24, 2018

    @monsieurtanuki
    ContributorAuthor

    Just PR'ed #1089
    The solution I implemented is a refresh of all neighboring tiles whenever there are new overlapping labels.

  26. added a commit that references this issue on Oct 11, 2018
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