MapsForge Library delivers random label rendering

485 views
Skip to first unread message

Michael Bechtold

unread,
Nov 20, 2016, 11:54:00 AM11/20/16
to mapsforge-dev
MapsForge Library delivers random label rendering
=================================================

Problem statement:
- minimal custom theme, showing only level 2 capitals, display=always (similar effects occur with other towns e.g., too - I only restricted to captials for easier analysis)
- using OAM map Westafrica (similar effects occur all around the world, too, but here I see two nearby effects on one screen)
- at level 6, MOBAC (using the beta feature of mapsforge rendering) does not display Accra, while at level 7 it is visible (Cruiser 1.2.12+ in contrast shows Accra at both levels)
- this different behaviour occurs, even if I copy the mapsforge jar files that Cruiser uses into the folder in the MOBAC structure and then recompile.
- I restricted MOBAC to one thread only in addition
- looking into the MOBAC code dealing with MapsForge (MapsforgeMapSource.java), I do not see any tampering by MOBAC, but a pretty straight passing from MapsForge Renderer to Java's ImageIO file writing.

The objective that I have is to build OFFLINE world maps (you find them on OAM web site), to complement vector maps like OAM for lower zoom levels (10 and below). And I found the label rendering massively unpredictable (in particular a level 8, partly level 9 and 10), priority and "always" simply being randomly ignored. So I started to narrow it down. And captitals on level 2only guarantee zero overlap in zoom levels 6 and above, so I got to a clear test case. With a valid use case in addition: nearly all online maps that I use for levels 5 to 7 omit quite a number of capitals, which I consider a nogo for overview level maps (level 5-10). I am using customMultiLayerMapSource to overlay the capitals on top of those incomplete online maps. It works nice, except that again a number of captials are missing.
And as said earlier, "always" is screwed at levels 8-10, too, randonly. I suspect the same root cause, but maybe I am mistaken here.

How to set up test to reproduce:
1) get the material from https://www.dropbox.com/sh/t8sgg558gcihsh3/AAB5fneLw5-0bolXu51lKs3ma
2) unzip "Mobile Atlas Creator 2.0.0 beta 2 test case.zip"
3) get http://www.openandromaps.org/maps/africa/WestAfrica.zip und unzip it (it contains capitals flagged as such from level 6 upwards)
4) in OAM-mf-WestAfrica-capitals.xml in mapsources adapt the paths to the Elevate-captials.xml and to the downloaded map
5) start MOBAC and select WestAfrica-capital-test profile, as well as the OAM-mf-WestAfrica-capitals map source - then you should see something like 2016-11-20 16_49_21-MOBAC.png; Accra missing at ZL 6, while ZL 7 shows it (in other tools like Cruiser it shows correctly at ZL 6, too, hence it's in the file ...)
6) create the Atlas and view in some SQLITEDB viewer you have - should look like 2016-11-20 16_54_53-MapOutput.png - see also the WestAfricaCapitalsTestMBe.sqlitedb file in Dropbox

The damaged labels are sitting on a tile boundary, BTW.

Background:
The objective that I have is to build OFFLINE world maps (you find them on the OAM web site), to complement vector maps like OAM and others for lower zoom levels (10 and below). And I found the label rendering massively unpredictable (in particular at level 6-8, partly level 9 and 10); priority and "always" in the theme simply being randomly ignored. So I started to narrow it down. And captitals on level 2 only guarantee zero overlap in zoom levels 6 and above, so I got to a clear test case.
With a valid use case in addition: nearly all online maps that I use for levels 5 to 7 omit quite a number of capitals, which I consider a nogo for overview level maps (levels 5-10). I am using new MOBAC beta customMultiLayerMapSource to overlay the capitals on top of those incomplete online maps. It works nicely, except that again a number of capitals are missing.

Tobias

unread,
Nov 20, 2016, 1:54:06 PM11/20/16
to mapsforge-dev
The damaged labels are sitting on a tile boundary, BTW.

That's probably the culprit. As I wrote in OAM forums, labels on tile boundaries are not reliably drawn if the label layer isn't active. So probably MOBAC isn't using the label layer, maybe you should check with the MOBAC developer if this is the case.
More on the label layer here:
https://groups.google.com/forum/#!searchin/mapsforge-dev/label$20layer/mapsforge-dev/AedxgdAWnR0/KmY9TDvlLgoJ

Best regards,
Tobias

Emux

unread,
Nov 20, 2016, 3:22:53 PM11/20/16
to mapsfo...@googlegroups.com
Like Tobias mentions anything on tile edges needs extra handling.

Mapsforge supports two types of rendering:

- Normal: where everything is rendered in the tiles on screen, with an internal index to "try" keep references for already rendered tiles and draw their elements first in their adjacent tiles.
These calculations could fall under race conditions (FCFS) and collision detection, where a simple map refresh (F5) could alter some labels order, particularly on latest desktop Cruiser where multi-threading is enabled.

- Separate (aka w/ label layer): where the symbols / labels are not rendered on the tiles, but live on a separate layer on screen. So the tile cache does not contain them, only the below polygons / lines, i.e. everything where in a rotation stays fixed on map.

BTW nowadays desktop Cruiser advanced to 512px tile size for better visual experience.

I attach 2 screenshots:
- Normal rendering
- Separate rendering (more labels on tile edges)

BTW cut-off labels or icons is not a trivial task, see TileMill documentation for extra details.

Everything is not perfect in the library, we welcome any improvements. :)

--
Emux
normal.png
separate.png

Michael Bechtold

unread,
Nov 20, 2016, 3:55:23 PM11/20/16
to mapsforge-dev
From Cruiser thread:
==================================
Just tested in Cruiser: Accra disappears when "normal" rendering is being used. Only "Separate" does a correct job.
So I guess  the question for MOBAC translates into: how can MOBAC make use of the new label feature (https://github.com/mapsforge/mapsforge/blob/master/docs/LabelLayer.md) ?
Would it mean to have an additional RendererJob(Tile tile, MapDataStore mapFile, RenderThemeFuture renderThemeFuture, DisplayModel displayModel,
                       float textScale, boolean isTransparent, boolean labelsOnly)
run ? With labelsOnly set to true in the second run ?
On the other hand: in Cruiser, in "normal" mode, not only the label disappears, but also the (capital) icon ... ?
At least for me - more questions :-)
==================================

We are all in non-violent agreement here. Yet: what is the answer to my question above - how to introduce this LaberLayer best in MOBAC ?
Not asking you to do it, but give guidance, pls., as you HAVE done it :-)

TXs and cheers
Michael

Emux

unread,
Nov 21, 2016, 2:40:38 AM11/21/16
to mapsfo...@googlegroups.com
I don't know if it's feasible to introduce a vector library feature in an application working with raster bitmap tiles.

LabelLayer is not rendered on cached images, it's calculated live and draws the symbols / labels on the screen.

Perhaps you try to accomplish something with the wrong tools.
If you need to produce raster maps you can use Mapnik or TileMill or ..., as they were designed for that specific job.

--
Emux

Robert

unread,
Nov 21, 2016, 4:35:47 PM11/21/16
to mapsforge-dev
Hi Michael,

unfortunately the LabelLayer is only an option for the map viewer, but not for the "atlas download" (or better atlas rendering in the case of mapsforge). Most atlas formats use tiled images, hence I would have to cut the label layer into tiles. Additionally the areas to be rendered can be very very large - and LabelLayer requires a Canvas to draw upon. A Canvas is more or less an in-memory image that has to be as large as the map to be rendered. 
Just an example: Germany on zoom level 14 has a size of about 100000x130000 pixel. Considering 3 byte per pixel that would make an image of ~36 GB RAM - only for zoom 14! For each increasing zoom level the space needed multiplies by 4.
You see that this is not generally working solution.

From my perspective the mapsforge label rendering will stay a problem for all apps which have to use real map tiles with labels (or label only tiles) unless a deterministic label rendering algorithm (in the meaning of: "the rendered labels are always the same independently what tiles have been rendered before") is available. 

I would not try to integrate mapsforge into MOBAC if there would be an alternative. The tile renderer you mentioned (Mapnik or TileMill) are from my perspective "unusable" (in the meaning that someone with a master in computer science requires more than one hour to set it up). MOBAC is for end-users with little computer science knowledge - hence projects that rely on a PostGIS database are definitely out of scope. 


Robert

Michael Bechtold

unread,
Nov 21, 2016, 5:09:22 PM11/21/16
to mapsforge-dev
OK, understand, Robert. Thank you for the explanation.
I am thinking about creating limited maps for my purpose (levels 4 to 8 or 9) with only cities and towns, using osmosis. I failed so far as the writer plugin is not recognized under Windows. May try with the embedded Ubuntu tomorrow (my native Linux boxes are too weak).
Then I would see if the mapsforge rendering gets better, combining maps without cities/towns with the ones with the cities/towns. Trial and error, I know.

Emux

unread,
Nov 22, 2016, 3:39:02 AM11/22/16
to mapsfo...@googlegroups.com
Maybe a misinterpretation of Mapsforge engine and / or LabelLayer mechanics (which Ludwig explained in detail here)..

We certainly don't keep the whole world canvas in memory, that's why there are two caches: in memory (screen sized) and the arbitrary file cache.
LabelLayer may retrieve the data in tiles (due to map file format) but it draws them directly on the *viewable* canvas.
There are calculations taking place in it continuously, which CPU doesn't like. :)

Eventually software rendering has its limits, that's why..
..all these work much nicer in OpenGL (VTM) where the heavy tasks were transferred in GPU.

BTW I retested Osmosis alone in Windows and works with the "osmosis.bat" (not with the "osmosis") executable.
So putting the plugins either in "lib\\default\\" subfolder or in "C:\\Documents and Settings\\(Username)\\Application Data\\Openstreetmap\\Osmosis\\Plugins" as mentioned here does the job.

--
Emux

Michael Bechtold

unread,
Nov 22, 2016, 7:30:28 AM11/22/16
to mapsforge-dev
Thank you Emux.

Well, if something can be put on the screen, it can be delivered elsewhere, too, with some changes/additions, of course. MOBAC is able to combine multiple layers, different raster maps and mapsforge vector maps, so a LabelLayer would not at all break the concept on MOBAC side. It would just be another png to deal with.
How does the LabelLayer get objects correctly spread and aligned ? With right priority etc. ? When I move the map versus the screen - will labels that were on the screen border then be re-painted ? Or is the canvas always made large enough to prevent such ?

A tile aligned "snapshot" of the canvas would deliver the right overlay, regardless when this snapshot happens, I suppose, because today already the extra layer works properly ...

Or do I miss a point here, Emux and Robert?

Michael Bechtold

unread,
Nov 22, 2016, 8:13:30 AM11/22/16
to mapsforge-dev
Tried osmosis again, but now get below. The plugin seems recognized.
Adding a tag-mapping file does not prevent the error ...
TXs for your advise in advance.
Michael


"java"  -cp "N:\Geo-Maps\osmosis\lib\default\plexus-classworlds-2.5.2.jar" -Dapp.home="N:\Geo-Maps\osmosis" -Dclassworlds.conf="N:\Geo-Maps\osmosis\config\plexus.conf" org.codehaus.classworlds.Launcher   --read-pbf file=n:\downloads\antarctica-latest.osm.pbf --mw file=test.map
Nov 22, 2016 2:01:46 PM org.openstreetmap.osmosis.core.Osmosis run
INFORMATION: Osmosis Version 0.45
Nov 22, 2016 2:01:47 PM org.openstreetmap.osmosis.core.Osmosis run
INFORMATION: Preparing pipeline.
Nov 22, 2016 2:01:47 PM org.openstreetmap.osmosis.core.Osmosis main
SCHWERWIEGEND: Execution aborted.
java.lang.NoClassDefFoundError: gnu/trove/procedure/TShortIntProcedure
        at org.mapsforge.map.writer.model.MapWriterConfiguration.loadTagMappingFile(MapWriterConfiguration.java:324)
        at org.mapsforge.map.writer.osmosis.MapFileWriterFactory.createTaskManagerImpl(MapFileWriterFactory.java:52)
        at org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactory.createTaskManager(TaskManagerFactory.java:60)
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.buildTasks(Pipeline.java:50)
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.prepare(Pipeline.java:112)
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:86)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: java.lang.ClassNotFoundException: gnu.trove.procedure.TShortIntProcedure
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 16 more

Emux

unread,
Nov 22, 2016, 8:18:02 AM11/22/16
to mapsfo...@googlegroups.com
Get map-writer jar with dependencies, preferably the snapshot from snapshots repository.

--
Emux

Michael Bechtold

unread,
Nov 22, 2016, 8:44:20 AM11/22/16
to mapsforge-dev
BINGO - that's the trick :-) Thank you, Emux.

Robert

unread,
Nov 22, 2016, 2:40:19 PM11/22/16
to mapsfo...@googlegroups.com
Hi EMux.

Just to make sure there is no misunderstanding: MOBAC has a map view
which makes it look a bit similar to Cruiser, however the map view is
just "nice-to-have eye candy" - it is just for selecting the region.
The important part is the atlas creation engine which takes map tiles as
an input, arranges them, converts them and in the output is the user
selected output format (there are about 50 of them).
Hence all viewing parts are irrelevant to me, because if the basic
engine gets the correct tiles for building the atlas the map view will
be fine, too.

> Maybe a misinterpretation of Mapsforge engine and / or LabelLayer
> mechanics (which Ludwig explained in detail here
> <https://github.com/mapsforge/mapsforge/blob/master/docs/LabelLayer.md>)..
> We certainly don't keep the whole world canvas in memory,

I wasn't talking about how the LabelLayer works as used by mapsforge, I
tried to adapt the basic principle how LabelLayer works to MOBAC - which
is not possible as I outlined (if my assumptions on LabelLayer are
correct).

> that's why
> there are two caches: in memory (screen sized) and the arbitrary file cache.
> LabelLayer may retrieve the data in tiles (due to map file format) but
> it draws them directly on the *viewable* canvas.

That is the major difference between mapsforge an MOBAC. In MOBAC the
*viewable* area is the map region selected by the user (because it has
to be processed at once as the LabelLayer does not work on tile level).

Robert

PS - just a stupid question: If the label rendering process for a tiled
map is that complicated how does Mapnik does it? AFAIR the Mapnik
created maps look quite good regarding the label placement. Isn't there
a possibility to adapt the used algorithm/principle?

Michael Bechtold

unread,
Nov 22, 2016, 2:52:58 PM11/22/16
to mapsforge-dev
Experimenting with osmosis and the map writer, I get a WEIRD effect:

Using
osmosis.bat -v 1 --rb file=germany-latest.osm.pbf --bounding-box top=50.400000 left=8.800000 bottom=49.800000 right=8.400000 --mw file=RheinMain.map tag-conf-file=tag-mapping.xml map-start-zoom=4 map-start-position=50.1000000,8.600000
I get a map that has a white stripe top to bottom, where Frankfurt and some highways are supposed to be. Some labels go into the white strip, but no towns and no highways are there.

The map writer is from the snapshot from today.

How can such happen ?

TXs and cheers
Michael
RheinMain.map
tag-mapping.xml

Emux

unread,
Nov 22, 2016, 3:06:50 PM11/22/16
to mapsfo...@googlegroups.com
The fundamental difference between raster and vector map libs / apps is that raster libs expect as input pre-rendered bitmap tiles to show, while the vector libs read the vector data and perform the rendering live on screen.


On 22/11/2016 09:40 μμ, Robert wrote:
PS - just a stupid question: If the label rendering process for a tiled map is that complicated how does Mapnik does it? AFAIR the Mapnik created maps look quite good regarding the label placement. Isn't there a possibility to adapt the used algorithm/principle?

Engines like Mapnik or TileMill are destined to run on desktops (server side) and produce the bitmap tiles for the clients.

Vector renderers are meant to run directly at clients and render the content there, e.g. should run also on light mobile devices.

Not to mention the developers power behind each project. :)

--
Emux

Emux

unread,
Nov 22, 2016, 3:15:45 PM11/22/16
to mapsfo...@googlegroups.com
You have set left > right in coordinates?

A better way to debug such cases is to perform each step separately.
- First cut the bounds in a osm / pbf file and verify e.g. by opening in JOSM
- Then feed the result to map-writer

Even better map-writer already provides the bbox option for limiting the map area (take care the coordinates order).

--
Emux

Michael Bechtold

unread,
Nov 22, 2016, 3:43:44 PM11/22/16
to mapsforge-dev
Top > Bottom, Left > Right, as you can see in the command string.
And the stripe is in the middle of the map, hence not a boundary issue. Did you see the attachment ?
Same with Berlin area.
osmosis.bat -v 1 --rb file=germany-latest.osm.pbf --bounding-box top=52.800000 left=13.600000 bottom=52.200000 right=13.200000 --mw file=Berlin.map tag-conf-file=tag-mapping.xml map-start-zoom=4 map-start-position=52.5000000,13.400000
Berlin.map

Emux

unread,
Nov 23, 2016, 3:19:33 AM11/23/16
to mapsfo...@googlegroups.com
Right longitude should be > than left longitude.

--
Emux

Emux

unread,
Nov 23, 2016, 3:24:46 AM11/23/16
to mapsfo...@googlegroups.com
e.g. Berlin map has bounds:

minLat,minLon,maxLat,maxLon=52.234534,12.982901,52.778202,13.861297

That can be checked easily in Cruiser via the "Tools" - "Map info" menu.

--
Emux

Michael Bechtold

unread,
Nov 23, 2016, 12:24:41 PM11/23/16
to mapsforge-dev
OK, tested with restricted "town/city only maps" created with osmconvert -> osmfilter -> osmconvert -> osmosis", as input to MOBAC.
As feared, there is no way to escape the non-deterministic behavior of the mapsforge-writer.

Which brought back one memory of mine: in fact I have seen different map outputs from the writer with the same inputs (.map, theme, etc.). Only difference then can be timing. Question: does map-writer and its sub-processes have ANY multi-threading in it ?

Emux

unread,
Nov 23, 2016, 12:28:14 PM11/23/16
to mapsfo...@googlegroups.com
Do you mean map reader?

Because map writer just writes the map file, it has nothing to do with the rendering.

Map reader can have multi-threading, by default is disabled.

I have enabled it in Desktop Cruiser and mapsforge-awt-samples, since seems stable enough now (though more memory intensive).

--
Emux

Michael Bechtold

unread,
Nov 23, 2016, 1:25:52 PM11/23/16
to mapsforge-dev
You are right, the reader, plus the renderer, which is also called from MOBAC.
So it seems there is no workaround, no more screws to turn easily.

And I would like to come back to my older question:
========================================

Well, if something can be put on the screen, it can be delivered elsewhere, too, with some changes/additions, of course. MOBAC is able to combine multiple layers, different raster maps and mapsforge vector maps, so a LabelLayer would not at all break the concept on MOBAC side. It would just be another png to deal with.
How does the LabelLayer get objects correctly spread and aligned ? With right priority etc. ? When I move the map versus the screen - will labels that were on the screen border then be re-painted ? Or is the canvas always made large enough to prevent such ?

A tile aligned "snapshot" of the canvas would deliver the right overlay, regardless when this snapshot happens, I suppose, because today already the extra layer works properly ...
========================================

I have seen some discussions between you and Robert, but I did not feel they answered my question. I fully understand that mapsforge reader plsu renderer today cannot deliver a tile for the LabelLayer. But my question is: when exactly is the correct data available in mapsforge ? When it can be sent to screen oriented libraries, it can also be sent somewhere else (output parameter).

Ludwig

unread,
Nov 23, 2016, 8:33:19 PM11/23/16
to mapsfo...@googlegroups.com
I think the problem that underlies this discussion is not randomness of the label rendering, but that certain labels that you do want to see, like country capitals, do not reliably show. 

The problem IMHO is that the OSM data does not have an easy tag for capitals or the most important cities. The place category has only city-town-village-hamlet or so, resulting in quite an inconsistent use and moving all the complexity of rendering a useful and consistent world map into the renderer. 
I know there is a capital=yes tag but checking this is somewhat broken in our library, so it cannot be relied on.

I think to achieve what you want to do (consistently rendering capitals) you would be best advised to preprocess the OSM data to add another tag to capitals that you then use as a discriminator. 

HTH 
Ludwig


--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-dev+unsubscribe@googlegroups.com.
To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/80232d67-c3f6-4889-82c4-c92a00fbcc5a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Michael Bechtold

unread,
Nov 24, 2016, 1:20:12 AM11/24/16
to mapsforge-dev
TXs Ludwig for looking at that topic.

I can see what you describe when looking at filtered OSM data, but I can state this is not the real problem. Why ?
1) the osmfilter did find them, they are in the file
2) they are visible at some zoom levels (like the Accra thing), and not on others
3) PLUS: I used the captial filtering because
     - it is my real purpose to amend some OSM raster maps that are very inconsistent re. capitals with overlaps
     - but also because it gives a more handy test set for the broader underlying probelm around town labels in general
4) display=always is randonly ignored
5) priorities are randonly ignored
6) and as discussed earlier, this most probalby has to do with tile border issues. You can see that nicely in one of the attachments, where labels are cut ibnto pieces.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.

To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.

Emux

unread,
Nov 24, 2016, 2:41:19 AM11/24/16
to mapsfo...@googlegroups.com
Regarding the directives randomness we know they cannot function perfectly in "normal" rendering, due to tiles edges constraints.
e.g. trying to fill the map with symbols per 0.1 degrees shows this screenshot with voids at tile edges

That's why the solution with the "separate" rendering via the LabelLayer was implemented, effectively ignoring the below tiles (where above map fills perfectly).

Regarding the code, I cannot answer directly without rechecking the API, but the best procedure is start from the end at DatabaseRenderer.executeJob and go backwards, seeing what's called when, where the data are read and where the LabelLayer interferes.

Note: what Ludwig describes can be achieved easily with an intermediate Osmosis plugin like TagTransform.

--
Emux

Michael Bechtold

unread,
Nov 24, 2016, 4:15:37 AM11/24/16
to mapsforge-dev
TXs Emux.
The need for a function like TagTransform (which I just learned form you) I discussed with Christian for the purpose of classifying towns by population ranges.
To a certain extent I got what I wanted already yesterday by using osmfilter with conditions (--keep="place=city or ( place=town and population>=10000 )")
In the OSM/o5m/PBF/map file I have exactly all needed objects - it's "only" about getting their labels into MOBAC's "fingers".

And that will not work without amendments to the mapsforge API libray. It's hard for me to reverse engineer the secrets of the LabelLayer mechanics, because this is the thing to expose. Also I have no idea how this "canvas" could potentially be used to grab correct and complete "snapshots" from the LabelLayer, coincidentially exactly the size and position of the standard tiles.

I trust you, Emux and Ludwig will have a fireworks of ideas for such :-) ?

Emux

unread,
Nov 24, 2016, 4:33:19 AM11/24/16
to mapsfo...@googlegroups.com
What exactly do you want to do?

Integrate LabelLayer in MOBAC?
Then I'm afraid you have to study the code, as it was created with live drawing vector layers in mind, not for raster images.

Create raster maps?
Then a vector library is not probably the right tool, I'd go with e.g. TileMill.

--
Emux

Michael Bechtold

unread,
Nov 24, 2016, 4:43:34 AM11/24/16
to mapsforge-dev
Get a png (or alike) of the LabelLayer "handed over" by an extension of the mapsforge rendering APIs.
We can consider the tile borders to act like screen borders. I am aware this is all talking on the 10000 feet conceptual level, not code. Already currently the Labels are shown as raster in the end, being combined with the underlying map in an App like Cruiser. So, I suppose this is not a fundamentally different thing. Data flow is somewhat different, I suspect.

Once MOBAC gets those bytes into its fingers, it would be Robert (and me pot. assisting) to digest that in MOBAC and feed into maps.


On Thursday, 24 November 2016 10:33:19 UTC+1, Emux wrote:
What exactly to you want to do?

Integrate LabelLayer in MOBAC?
Then I'm afraid you have to study the code, as it was created with live drawing vector layers in mind, not with raster images.


Create raster maps?
Then a vector library is not probably the right tool, I'd go with e.g. TileMill.

--
Emux

Emux

unread,
Nov 24, 2016, 4:54:10 AM11/24/16
to mapsfo...@googlegroups.com
On 24/11/2016 11:43 πμ, Michael Bechtold wrote:
Already currently the Labels are shown as raster in the end, being combined with the underlying map in an App like Cruiser. So, I suppose this is not a fundamentally different thing.

No, that's definitely not right here.

LabelLayer does not show as raster in the end - it's never meant to behave like that - as we want it to be dynamic (e.g. if we rotate the map the labels shouldn't be cached but render continously with motion).

So when it's enabled (i.e. "Separate" rendering in Cruiser) then only the main map is rendered in tiles (i.e. only the below elements), the symbols and labels are rendered live on screen (not on any bitmaps), so the cached tiles don't actually contain them (check the tile cache files).

--
Emux

Michael Bechtold

unread,
Nov 24, 2016, 5:00:54 AM11/24/16
to mapsforge-dev
OK, got it.
But what does "are rendered live on screen" mean in detail ("who" does this rendering) ? When you can deliver the correct Labels to a given screen, they could be put somewhere else, too ? Or why not ?

Robert

unread,
Nov 24, 2016, 6:11:16 AM11/24/16
to mapsfo...@googlegroups.com
Hi Emux.

> What exactly to you want to do?
> Integrate LabelLayer in MOBAC?

I was searching for a way to provide correctly rendered labels for
mapsforge maps within MOBAC. Someone wrote here that LabelLAyer would be
the solution, therefore I checked it it can be adapted for MOBAC, which
is not the case.

My general aim is to provide a simple local map renderer for MOBAC.
There are three requirements:

1. All titles are rendered locally - therefore it does not matter if you
use 10 tiles or 10 million (no chance to abuse online resources).

2. It has to work out-of-the box, preferred platform-independent (or it
should work at least on Windows)

3. It should be simple to use.

> Create raster maps?
> Then a vector library is not probably the right tool, I'd go with e.g.
> TileMill <http://wiki.openstreetmap.org/wiki/TileMill>.

From my perspective mapsforge is the only project that comes close to
what is needed. It is relative small, handy, the pre-processed map data
is available for download and it is easily customizable through themes.
The only point left regarding mapsforge is the labels problem.

Simplified you can say:

".map file + [optional render theme] + mapsforge library = map tiles"

From my perspective this is a unique feature of mapsforge. All the
other projects are bloated, too complex, have thousands of dependencies
you have to provide manually or do not work on the three major platforms
(Win, Linux, OSX).

Unfortunately TileMill is big, relative complex and is no longer
supported. The Windows installer package even contains vulnerable
software (node.js 0.8.11).

Robert

Michael Bechtold

unread,
Nov 26, 2016, 4:15:45 AM11/26/16
to mapsforge-dev
Hello team,
I did some more digging and could clearly see that the ORDER of tile rendering calls changes the outcome. Maybe not news to you ...
One difference between the MOBAC screens and the rendered map is, that the MOBAC screens never cut Labels in the middle. The generated map has cut Labels, at least for the capital/admin_level 4 obejcts (Wuppertal/Solingen & Frankfurt).

I trust your combined brains will make sense of those effetcs, and hopefully get to an improvement.

TXs and cheers and have a nice weekend
Michael
2016-11-26 09_35_01-MOBAC run 1 generated map.png
2016-11-26 09_35_25-MOBAC-Screen-Run 1.png
Mapsforge Random Labeling-MOBAC Runs.csv
2016-11-26 09_38_09-MOBAC-Screen-Run 2.png
Elevate-Towns.xml

Ludwig

unread,
Nov 26, 2016, 5:01:10 AM11/26/16
to mapsfo...@googlegroups.com
I did some more digging and could clearly see that the ORDER of tile rendering calls changes the outcome. Maybe not news to you ...

No, and I think Emux explained this before on this thread. 

Maybe I quickly explain this again in my words: the renderer keeps state to draw labels across tile boundaries.
Starting with the first tile (when rendering for mapsforge on a device this will be a tile in the middle): at this stage none of the surrounding tiles have been drawn, so all labels can be drawn across boundaries. Which labels were drawn is remembered, so when it comes to draw the adjacent tiles, the remaining parts of a label are drawn. 

So when the next tile is drawn, first the parts of labels already drawn on the middle tile are drawn, disregarding any priorities etc. Otherwise we would have half-drawn labels. Only then is the rest drawn. As the first tile has already been drawn, no new labels can be drawn over this border, again regardless of priority. 

The rendering order is spiral, so with tile #4 being drawn, we have to adjacent tiles already drawn, so there are now more constraints. 

This continues and the process is synced with the tiles in the cache. So whenever a tile is purged from the cache, the label cache is also updated. So we can get the situation where a tile is surrounded by eight tiles that have already been drawn. So this tile can only draw the remaining parts of labels from the adjacent tiles, but cannot itself draw new labels across boundaries. 

So, of course it matters which tile you start with and so then results may seem random and disregarding priorities. As Emux explained the LabelLayer avoids this problem, but at the end of the day it is basically just laying out the labels for the whole of the screen, at one point you are bound to have a cut-off point. 

Ludwig

--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-dev+unsubscribe@googlegroups.com.

To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.

Michael Bechtold

unread,
Nov 26, 2016, 5:15:18 AM11/26/16
to mapsforge-dev
TXs, Ludwig, for the very detailed process description inside the mapsforge renderer.
Just to double check: below is working WITHOUT relying on the LabelLayer ?
So, if MOBAC would create renderer jobs in a spiral order, it could leverage the benfits of the spiral algorithm inside mapsforge ?
How huge (number of tiles) can such a spiral inside mapsforge renderer realistically get before memory blows up ?
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.

To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.

Michael Bechtold

unread,
Nov 26, 2016, 5:29:44 AM11/26/16
to mapsforge-dev
I'm well aware that without the LabelLayer, the result will dependent on the start of the spiral, but at least there would not be massacred tiles ...

And then of course I still hope you find a way to make the LabelLayer usable via an API that a tool like MOBAC could use. Any ideas how such would be doable ?

Ludwig

unread,
Nov 26, 2016, 5:56:31 AM11/26/16
to mapsfo...@googlegroups.com
Memory depends all on your setup and the amount of data to render (so this depends of scale) ...really no idea. 
The algorithm depends of only a part of the world being visible at any one point as the user pans around on a screen.

Now, you could try to emulate such a process by feeding a stream of adjacent tiles into the rendering queue, so kind of sweeping over the world. 

But I am afraid at one point you will arrive somewhere where the cached data will just get too big. And as I described it before, unfortunately even tile10000 somewhat depends on the first tile rendered, so there is no reliable way to reload the cache somehow. 

Ludwig






To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-dev+unsubscribe@googlegroups.com.

To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.

Michael Bechtold

unread,
Dec 1, 2016, 12:49:44 PM12/1/16
to mapsforge-dev
Hi team,
I put a spiral order tile retrieval (from mapsforge map files) into MOBAC, from center to the outside. But it does not make a big difference, if any. And also near the center of the spiral there are errors (so breaking up into continents will not help much, if at all).
This points back to the question how big these mapsforge caches currently are, how they can be increased (if that is the problem at all).
And of course the current housekeeping mechanics for the cache has an impact (FIFO, LRU, etc.). For above purpose FIFO would be best, I suppose, if the cache is large enough for 10000 tiles (Layer and map).
Can you pls. advise ?
TXs and cheers
Michael

Quote from Ludwig:
Yes, only the periphery is relevant.Â

Technically, additional calls could be added to drop those references from the cache that go towards the interior (so not just the interior tiles, but the references from the peripheral tiles that go towards each other and inside).

You could also break up the world into continents, assuming that at the end of the day there is nothing of interest on the oceans (Emux' opinion will differ), and just spiral from a center of each continent towards some defined border.

The cache is all configurable, somewhere.

Ludwig

unread,
Dec 1, 2016, 5:49:23 PM12/1/16
to mapsfo...@googlegroups.com
The size for the cache is set in the constructor for the InMemoryTileCache/FileSystemTileCache. Whatever TileCache you are using (multi-level or single-level) its size is taken by the TileRenderer to create an equally sized LabelStore. 



--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-dev+unsubscribe@googlegroups.com.
To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.

Emux

unread,
Dec 2, 2016, 2:21:51 AM12/2/16
to mapsfo...@googlegroups.com
e.g. see mapsforge-samples-awt for setting the two tile caches

Regarding the final approach, the best result will always be via a LabelLayer.

But right now I don't know if it's feasible - even without it - to have proper labels in "external of MapView" tiles with existing API.

--
Emux

Ludwig

unread,
Dec 2, 2016, 4:14:48 AM12/2/16
to mapsfo...@googlegroups.com
IIRC there is an interface for the LabelCache and in this case, as the cache is not really required, it might make sense to simply implement a dummy cache with a very large nominal capacity but that does not actually store any data.

As Emux said, not sure if this is going to work.

On 2 December 2016 at 15:21, Emux <deve...@gmail.com> wrote:
e.g. see mapsforge-samples-awt for setting the two tile caches

Regarding the final approach, the best result will always be via a LabelLayer.

But right now I don't known if it's feasible - even without it - to have proper labels in "external of MapView" tiles with existing API.

--
Emux

--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-dev+unsubscribe@googlegroups.com.
To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.

Emux

unread,
Jul 27, 2017, 8:40:35 AM7/27/17
to Michael Bechtold g, Ludwig, Robert, mapsforge-dev, Christian Kernbeis
This better continue discussed in public at relevant forum topic. :)

On 27/07/2017 03:27 μμ, Michael Bechtold g wrote:
Hello team,
I'd like to come back to a topic from last year - about the MOBAC use of Mapsforge libs. Which currently has a massive problem, because Labels are frequently either broken or missing.
Now, in an OAM discussion, Emux stated below.

Richard, is there a way to improve MOBAC based on that ?

TXs and cheers
Michael

(probably not the right topic to discuss these)

Mapsforge label rendering is handled by library itself, via its client module.
Cruiser is a platform using *unmodified* Mapsforge + VTM libs.

Any app using the Mapsforge libs can render the labels with same fine result.
We demonstrate the process in the Samples at repository.
Mapsforge applications can be seen here and AFAIK Orux uses the libs, while Locus has modified them?

LabelLayer can be an extra improvement, but not strictly necessary.
Mapsforge client has internal label cache at tile edges for normal rendering.

So if any app like to use Mapsforge in a different “possible” way, need to somehow extend its API, preferably contributing the improvements for all community to benefit.

Emux

You received this message because you are subscribed to a topic in the Google Groups "mapsforge-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mapsforge-dev/UA3EHDx9yDw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mapsforge-de...@googlegroups.com.

To post to this group, send email to mapsfo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mapsforge-dev.

For more options, visit https://groups.google.com/d/optout.




--
Emux

Emux

unread,
Jul 27, 2017, 9:08:11 AM7/27/17
to Michael Bechtold g, Ludwig, Robert, mapsforge-dev, Christian Kernbeis
BTW regarding the rendering & save tiles, can see a PR we merged lately in desktop samples.

--
Emux

Michael Bechtold g

unread,
Jul 30, 2017, 9:23:41 AM7/30/17
to Emux, Ludwig, Robert, mapsforge-dev, Christian Kernbeis
Thank you Emux.

I had a look at the PR example and compared it with the resp. parts of MOBAC. To me, this seems OK. The output, however, is definitely not OK (see attached).
Hence, some trick is missing.

Can you pls. advise ?

TXs and cheers
Michael
2017-07-28 13_31_39-Vectorial Map Viewer.png

Michael Bechtold

unread,
Jul 31, 2017, 7:12:45 AM7/31/17
to mapsforge-dev, deve...@gmail.com, ludwigbr...@gmail.com, rob...@mailueberfall.de, ad...@openandromaps.org
Update: setting LabelCache to false in MOBAC prevented labels from being cut - BUT it still leaves out some places completely, like Cologne or London or Frankfurt in some zoom levels. Any idea ?
Reply all
Reply to author
Forward
0 new messages