Repository navigation
Multi-map improvements - #1582
Conversation
… datasets in the sequence that support a tile, up to the one that contains data for the entire tile (usually a world map). In other words, once a dataset fills the entire tile, the remaining datasets are not processed for that tile.
|
@Sublimis Can you show screenshots with the difference?
Note that world map supports all tiles BUT does not have all or detailed data. At least until someone provides a world map with more data: So the small maps with detailed data are more important in rendering. |
Note, when map files are added by priority, world map will be the last to be processed, and only if none of the previous maps provided an entire tile: |
|
@Sublimis I edited your post with the screenshots to put them together for easy reading. <img src="..." width="...%"/> |
Zoom in a bit more (twice) on the edge of the map, until scale shows "5 km". Our map was taken from here, but the exact map shouldn't matter much: https://www.openandromaps.org/en/downloads/europe |
|
@Sublimis Is is about the rectangle at OAM map edges? Note: it is easier to test with a small map (with sea) like Azores. |
|
Map source doesn't matter, as long as you find zoom level >10 and an edge with incomplete tile. Ok, we can try Azores or anything else. |
|
@Sublimis Try to also reproduce it with Mapsforge maps. |
The second image just shows the zoom center! (You must pan around a bit to find the map edge) |
|
@Sublimis Thanks, I understand now, I was looking at different things! 🙂 |
|
|
@Sublimis What happens with adjacent maps where each map has a part of the data of their shared tile? |
Yes, maps should be inserted in order of precedence for this to function as advertised. Or at the very least, the world map (if used) should be inserted last. Anyone using the RETURN_FIRST is already doing this. If a user who consciously chooses to use the RETURN_AUTOFILL flag sees artifacts like the above, they will simply change the order of the inserted maps. (This should be put as a note in the description of the flag, if not already clear enough).
This is incorrect. Anyone who uses the RETURN_FIRST flag already pays attention to the order of the maps inserted if there is a chance that more than one map can serve a particular tile, which is often the case. Especially if they are using the world map, which overlaps all the other maps.
Since the library decides ("automatically") when a tile is "filled", the name seems appropriate. We don't have a better name, if anyone can think of a better name, please suggest it!
Yes |
It is working exactly as advertised. Note, this flag is not a replacement for RETURN_ALL! |
|
@Sublimis Indeed Also this new flag seems to have a very specific use, like world map + 1 country on top? Please let's revert the samples to |
|
For your example above to work "correctly" with the AUTOFILL flag (i.e. to return data from both maps), neither map should claim to have data for an entire tile that it doesn't actually have. But that then becomes "just" a question of implementation details, i.e. how to get the exact map boundaries (currently this is a rough rectangle). That's why this flag is currently most useful with a world map. |
|
@Sublimis We also need to think about the performance of the map. |
It seems you should think this through some more. Do take your time. RETURN_FIRST is useful when the user knows the maps they throw into the |
|
Also note that no one is forcing anyone to use the new flag. It has its own benefit that no other flag covers. They all have artifacts in a common useful scenario as shown above. The new flag is in addition to the current flags and does not change their current behavior in any way. The sample application can be reverted to RETURN_ALL, no problem. |
This doesn't really have anything to do with the new flag, does it? It may only be faster than RETURN_ALL, or exactly the same. The new flag can never be slower than RETURN_ALL. |
|
@Sublimis I meant that users usually open maps of neighboring countries. |
|
By the way, we first tried to implement such functionality at the "layer level", i.e. use RETURN_ALL (without limiting the zoom level of the world map), but somehow force the sea layer of the more important map to be drawn on top of the less important (world) map, to prevent coastline artifacts. However, we learned that ALL sea layers are hard-coded as layer zero, so no go. Maybe this is a part of the library that could also be improved in the future, but we will almost certainly not deal with it. We also first used the name RETURN_SEQUENTIAL for the new flag, but this name doesn't really say much. That's why there are some The RETURN_AUTOFILL flag is perhaps best described as a "fixed" version of RETURN_FIRST; it behaves the same unless the tile is incomplete (partially drawn), in which case it will try to load more data (unlike RETURN_FIRST). Also, our opinion is that no one should ever look at a map that doesn't have a world background when zoomed out, especially considering that the current world map is so lightweight. But that's just us 🙂 |
|
Let's recap and propose a slightly different, more universal approach. Here we are solving the following multi-map artifacts:
Now we also want to satisfy this useful condition:
The proposal is to provide the ability to assign priority to the inserted map. By default, this can be 0 for all maps (so that no code changes are required from the user). Then return all data (just like RETURN_ALL would do), but sorted by priority. If a map has priority <0, return its data only if the tile is not yet filled by other maps. We can call this a background map priority. Such functionality can even be implemented without introducing a new flag. By default it will behave just like the RETURN_ALL is behaving right now. However, we could also introduce a small auxiliary functionality so that users of the RETURN_ALL + world map can immediately benefit from removing the "peeking coastline" artifact: The library could detect when a map is called "world.map" and automatically assign it a negative priority. What do you think? |
|
@Sublimis Thanks for the detailed description. A universal solution seems better, so opening azores + austria + switzerland + world
|
|
@Sublimis It is also important if we manage not to break how the public API works. |
1. Fix: Low-res map coastline peeks out from behind high-res map (RETURN_ALL issue) 2. Fix. Incomplete tile returned on map edge (RETURN_FIRST issue; RETURN_ALL has this issue only when zoom levels are limited as in the sample app) 3. (RETURN_ALL) Return data from all maps that overlap on a tile while respecting the two points above: Map priorities via MapDataStore.setPriority()
|
@Sublimis Can you change the title and the description of the pull request? |
|
@Sublimis It does not work if we don't set priority. java.lang.IllegalArgumentException: Duplicate map database
at org.mapsforge.map.datastore.MultiMapDataStore.addMapDataStore(MultiMapDataStore.java:70)
at org.mapsforge.samples.android.MultiMapLowResWorld.onCreate(MultiMapLowResWorld.java:86) |
1. Fix: Low-res map coastline peeks out from behind high-res map (RETURN_ALL issue) 2. Fix. Incomplete tile returned on map edge (RETURN_FIRST issue; RETURN_ALL has this issue only when zoom levels are limited as in the sample app) 3. (RETURN_ALL) Return data from all maps that overlap on a tile while respecting the two points above: Map priorities via MapDataStore.setPriority(). MapFile named "world.map" is automatically assigned some very negative priority.
Fixed that, please try now with the latest code. |
| if ("world.map".equalsIgnoreCase(mapFile.getName())) { | ||
| // Some random (very) negative value no one will use | ||
| setPriority(Integer.MIN_VALUE + 374); | ||
| } |
There was a problem hiding this comment.
So let's put this in the sample apps? They do assume particular map names, so it seems appropriate, especially for the Android sample app that has "world.map" hardcoded right there in plain sight.
There was a problem hiding this comment.
@Sublimis Let's put it only in the sample apps.
Android has it, we can also put it in desktop samples.
There was a problem hiding this comment.
To be clear, only AWT sample app should need such auxiliary functionality, since Android app sets the priority manually.
There was a problem hiding this comment.
@Sublimis We can set it manually on desktop samples as well, just like on Android.
They are just examples.
There was a problem hiding this comment.
It's actually better like this, without assuming that the world.map file should be present, so the user decides which files to use. Because desktop sample has no startup menu like the Android app, it's just a single app.
1. Fix: Low-res map coastline peeks out from behind high-res map (RETURN_ALL issue) 2. Fix. Incomplete tile returned on map edge (RETURN_FIRST issue; RETURN_ALL has this issue only when zoom levels are limited as in the sample app) 3. (RETURN_ALL) Return data from all maps that overlap on a tile while respecting the two points above: Map priorities via MapDataStore.setPriority().
|
@Sublimis Now it seems to work ok in all cases. |
Yes, nothing more to add 👍 |
|
Wait, maybe to clarify comments a bit. |
1. Fix: Low-res map coastline peeks out from behind high-res map (RETURN_ALL issue) 2. Fix. Incomplete tile returned on map edge (RETURN_FIRST issue; RETURN_ALL has this issue only when zoom levels are limited as in the sample app) 3. (RETURN_ALL) Return data from all maps that overlap on a tile while respecting the two points above: Map priorities via MapDataStore.setPriority().
|
Done. |
|
@Sublimis Thanks! |











* MultiMapDataStore.DataPolicy.RETURN_AUTOFILL: Return data from all datasets in the sequence that support a tile, up to the one that contains data for the entire tile (usually a world map). In other words, once a dataset fills the entire tile, the remaining datasets are not processed for that tile.Here we are solving the following multi-map artifacts:
Low-res map coastline peeks out from behind high-res map (RETURN_ALL issue)
Incomplete tile returned on map edge (RETURN_FIRST issue; RETURN_ALL has this issue only when zoom levels are limited as in the sample app)
Return data from all maps that overlap on a tile
Motivation: Prevent ugly gaps at the edges of the map when the map does not cover the tile completely, and we have a background world map that should easily cover this gap. Additionally, prevent the land areas of the (low-res) world map from "peeking" behind the land areas of a (hi-res) main map, when the main map can provide the entire tile itself.
These problems can be easily seen in the Android application sample MultiMapLowResWorld.