How to develop MapsForge themes for VTM?

1,235 views
Skip to first unread message

Zsolt Ero

unread,
Jan 3, 2018, 7:29:49 AM1/3/18
to mapsforge-dev
Hello,

I'd like to develop some MapsForge themes to be used with OpenAndroMaps offline maps. I'd like to base my theme on VTM's default theme (vtm-themes/resources/assets/vtm/default.xml).

What is the most efficient way to edit and preview this theme on a desktop? I'm using OS X.

Here is what I tried:
- Downloaded the Cruiser desktop app, but it couldn't open the XML theme file from the VTM project.
- Tried ./gradlew :vtm-web-app:farmRun, but I didn't understand how can I make it render mapsForge maps and not just serve online tiles
- I'd like to run vtm-playground/src/org/oscim/test/MapsforgeTest.java but I don't have experience with Java development / Gradle and I don't know how to start an example in this project.

Can you help me? I feel the right direction would be to run MapsforgeTest, and reload frequently? Will that work for me?

Zsolt

Emux

unread,
Jan 3, 2018, 7:52:43 AM1/3/18
to mapsfo...@googlegroups.com
Indeed a way is to use MapsforgeTest, but that requires to have Android Studio running and changing the parameters for map files and themes.

Or as you mentioned just run Cruiser GL, load a map file and a theme, make changes in the theme xml and simply press F5 to reload and all changes appear on screen.
But you need cruiser-gl executable for VTM themes.

Cruiser uses Mapsforge engine, while Cruiser GL uses VTM engine.

Important: in any method to easily handle the themes as external files would need:
- Copy in a folder the theme xml file (e.g. default.xml) and the 3 resource folders (patterns, symbols, textures).
- Do a "replace all" in xml file of "assets:" prefix to "file:" (without quotes), for the theme to find its resources.
Then you'll have a self-contained folder of a theme with its local resources, ready to modify.

--
Emux

Zsolt Ero

unread,
Jan 3, 2018, 8:29:20 AM1/3/18
to mapsforge-dev
Thanks a lot, it works in both programs now.

Just one small question, how can I change the display scale / retina dpi setting?

In Cruiser I set it, it tells me that restart is required, but then it forgets everything after restart. I'm using ./cruiser-gl.sh to start the program.

In MapsForgeExample I guess I need to add a line, but I cannot find out what can it possibly be?

Zsolt
Message has been deleted

Emux

unread,
Jan 3, 2018, 8:46:17 AM1/3/18
to mapsfo...@googlegroups.com
To change map labels size, can find the option in Settings > Text size.

To change all map scale (symbols, labels, tile size), can find the option in Settings > Display scale.

cruiser.sh starts Cruiser and cruiser-gl.sh starts Cruiser GL.
They're two different apps, could change their settings separately.


In MapsforgeTest can play with:
CanvasAdapter.userScale = 1.2f;

--
Emux

I_G

unread,
Jan 3, 2018, 9:39:25 AM1/3/18
to mapsforge-dev
I just upload the theme file to my Android phone from Brackets with the SFTP plugin then reselect it in Locus/Orux etc. These themes will be used mostly on mobile clients anyways.

Zsolt Ero

unread,
Jan 3, 2018, 10:18:23 AM1/3/18
to mapsforge-dev
My problem is that in Cruiser and Cruiser GL the settings are not remembered. After every restart the app starts in the default state.

Now, a question about styling. No matter what I try, I cannot make some elements be visible on low zoom levels. For example, if I'd like to show an overview map of railway lines, this is the most minimal example I could come up with.

<?xml version="1.0" encoding="UTF-8"?>
    <m e="way">
        <m k="railway">
            <line cap="butt" fix="true" stroke="#ddaa9988" width="10.0"/>
        </m>
    </m>
</rendertheme>

Yet, on my maps this only display from zoom 10.

Am I doing something wrong, or this is happening because the data is only present in the .map file from zoom 10?

Zsolt

I_G

unread,
Jan 3, 2018, 10:27:57 AM1/3/18
to mapsforge-dev
If you use OpenAndroMaps then yes, a lot of objects enter at higher zoom levels, so you can't do anything about it. You can check the tagmapping here: https://www.openandromaps.org/en/map-basics-2/tag-mapping

Emux

unread,
Jan 3, 2018, 11:14:51 AM1/3/18
to mapsfo...@googlegroups.com
Cannot do serious theme development on mobile devices. Desktop convenience is unmatchable all these years we make themes.
An alternative is to use Android emulator or Genymotion on desktop, though still transfers should be made for every and each tiny xml or resource change.

Zoom levels indeed firstly are managed from tag-mapping during map creation, that is from what zoom level each element to be included in map file.
Then can micro-manage further the min zoom inside the themes, for the available zoom ranges.

Regarding Cruiser settings, please create a topic in Cruiser forum mentioning platform details. Could be something specific, as last time checked on Windows, macOS and Linux worked fine.

--
Emux

Emux

unread,
Jan 3, 2018, 11:39:47 AM1/3/18
to mapsfo...@googlegroups.com
> An alternative is to use Android emulator or Genymotion on desktop

See OpenAndroMaps FAQ here with instructions.

--
Emux

Zsolt Ero

unread,
Jan 4, 2018, 8:28:20 AM1/4/18
to mapsfo...@googlegroups.com
Hi,

I'm progressing, but cannot figure out how to make wind turbines
visible. I'm trying on OAM maps, but on every other source they just
do not appear.

Here is what I'm trying:
<m e="node" k="generator:source" v="wind">
<symbol src="file:symbols/peak.svg"/>
</m>

The official Elements theme also contains this part, but it's also not visible:
<rule e="any" k="generator:source" v="wind">
<symbol id="s_power_wind" src="file:ele_res/s_power_wind.svg"
symbol-height="16" symbol-scaling="size" symbol-width="16"/>
<rule e="any" k="*" v="*">
<caption fill="#734A08" font-size="10" font-style="bold"
k="name" position="above" stroke="#E5FFFFFF" stroke-width="2"
symbol-id="s_power_wind"/>
</rule>
</rule>

I'm trying to make these ones visible:
http://overpass-turbo.eu/s/ucE

Is there any developer / x-ray theme which would allow displaying
_everything_ present in a map (MapBox / OpenMapTiles have an X-Ray
view for visualizing vector tiles).

Zsolt
> --
> 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/GjLnEPlerV4/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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mapsforge-dev/e2a17e59-a6a3-b407-6384-543f583554b1%40gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.

I_G

unread,
Jan 4, 2018, 8:34:18 AM1/4/18
to mapsforge-dev
I think you should go to the OpenAndroMaps forum with OAM-specific questions, straight from the horse's mouth :) I asked exactly this question there, seems like it's some glitch, maybe these objects will be back in the January release.

Zsolt Ero

unread,
Jan 4, 2018, 8:37:51 AM1/4/18
to mapsfo...@googlegroups.com
I've also asked it there (unfortunately it's in the german forum, I
didn't realise there are two separate forums), but from the reply I
thought probably I'm doing something wrong.

OK, a general question about Mapsforge format: what is this <rule> vs.
<m> thing? I see v1 for the m theme and v4 in the rule theme. Is it
possible to convert m -> rule in a simple way?

Zsolt
> https://groups.google.com/d/msgid/mapsforge-dev/350fdd9a-abc5-4802-ac4d-e8aa301174f9%40googlegroups.com.

Zsolt Ero

unread,
Jan 4, 2018, 8:41:56 AM1/4/18
to mapsfo...@googlegroups.com
I did a find and replace from <m> to <rule> tags as well as replaced
the top part. It works, but is it as simple as this? Anything else I need
to take care about?

Are there any performance benefits of each?

Emux

unread,
Jan 4, 2018, 8:49:47 AM1/4/18
to mapsfo...@googlegroups.com
Indeed when creating a theme from a map file, it's useful to know how it was created, i.e. its tag-mapping, like Christian and Tobias have linked in OpenAndroMaps forum.


> what is this <rule> vs. <m> thing?

There are 2 map engines which can read Mapsforge map files:

- Mapsforge with HA software rendering (<rule> notation)
- VTM with OpenGL rendering (<m> notation)

VTM themes have extra features like styles and advanced rules specifically for OpenGL.

Mapsforge cannot read VTM themes.
VTM can read both Mapsforge and VTM themes.

So depends on what apps want to run a theme.
Can see applications using Mapsforge here and VTM here.

--
Emux

Zsolt Ero

unread,
Jan 4, 2018, 8:55:39 AM1/4/18
to mapsfo...@googlegroups.com
OK, I see. So <rule> themes, like Elevate are compatible with both
Cruiser and Cruiser-GL for example, but VTM's default XML is only
compatible with VTM based apps.
The v1 vs. v4 confused me, so actually v1 here is the newer concept?

Zsolt
> --
> 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/GjLnEPlerV4/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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mapsforge-dev/00e252b8-ed1c-9f45-7f2b-3aab34870863%40gmail.com.

Emux

unread,
Jan 4, 2018, 8:59:21 AM1/4/18
to mapsfo...@googlegroups.com
> The v1 vs. v4 confused me, so actually v1 here is the newer concept?

They are versions of themes for each map library.

Not to be mixed as they progress in parallel.
There is no newer concept, just "different" implementations.

--
Emux

Zsolt Ero

unread,
Jan 4, 2018, 12:44:34 PM1/4/18
to mapsfo...@googlegroups.com
OK, thanks, it's clear that I'm targeting a VTM based mobile client,
so I'll base mine on the VTM's default theme.

So what is the best way to debug Mapsforge files? Is there any way to
see everything in there, like in an X-Ray like view? For example this
is the view of OpenMapTIles vector tile mode.



On 4 January 2018 at 14:59, Emux <deve...@gmail.com> wrote:
>> The v1 vs. v4 confused me, so actually v1 here is the newer concept?
>
> They're are versions of themes for each map library.
>
> Not to be mixed as they progress in parallel.
> There is no newer concept, just "different" implementations.
>
> --
> 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/GjLnEPlerV4/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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mapsforge-dev/b55d43e7-68f9-b8e0-92ab-6b416e4e7b3a%40gmail.com.
TileServer - Maps rendered from vector tiles 2018-01-04 18-40-42.png

Emux

unread,
Jan 5, 2018, 4:21:29 AM1/5/18
to mapsfo...@googlegroups.com
I know their feature, it's nice.
Though don't know if it's working on the actual vector tiles or a DB.

Mapsforge map files store the data with special optimizations designed for fast + efficient map retrieval / rendering on devices with limited resources.
So (unfortunately) there isn't available any random access search, only retrieval per tiles in zoom intervals.

There are available examples in Mapsforge + VTM repositories of such reverse geocoding, i.e. query map elements at an area.
I can include it in next Cruiser version if there is interest (screenshot).

--
Emux
Cruiser GL.png

Zsolt Ero

unread,
Jan 5, 2018, 8:36:25 AM1/5/18
to mapsfo...@googlegroups.com
Their X-Ray view works out of vector tiles data.

Your feature looks nice, but would it be possible to make the theme
see-through / outline-only? I think people would like it a lot!

The great thing would be to visualise if there is _anything_ on a
given place, so that I know if something is not displaying because of
a wrong query, or because it's actually missing from the data. But I
don't know enough about XML themes to know how to show everything.

Here is my first try:

<?xml version="1.0" encoding="UTF-8"?>
<rendertheme map-background="#000000" version="1"
<m e="node">
<circle fill="#ffffff" radius="10" scale-radius="true"/>
<caption dy="-20" fill="#ffffff" k="name" size="14"/>
</m>
<m e="way">
<m k="highway">
<line stroke="#00ff00" stroke-width="2.0"/>
<caption dy="-20" fill="#00ff00" k="name" size="14" zoom-min="14"/>
</m>
<m k="contour_ext">
<line stroke="#ffffff" stroke-width="2.0"/>
</m>
<m k="highway" v="~|no|false">
<line stroke="#5a68f6" stroke-width="2.0"/>
<caption dy="-20" fill="#5a68f6" k="name" size="14" zoom-min="14"/>
</m>
</m>
</rendertheme>

Obviously some things are not clear to me:
- is there a general way to do if-else? For example I'd like to query
all elements which have not been colored so far, but all I could do is
select non-highway. Thus it's overriding my contour lines part.
- How can I do zoom-min on a caption? It doesn't work the way I wrote.

Zsolt
> --
> 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/GjLnEPlerV4/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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mapsforge-dev/a40bd8f6-5d14-efc4-0f86-f60ee2e13230%40gmail.com.
Cruiser GL - Hungary.map | debug.xml 2018-01-05 14-33-11.png

Emux

unread,
Jan 5, 2018, 8:59:07 AM1/5/18
to mapsfo...@googlegroups.com
It's always recommended to study existing themes like default.xml for ideas and understanding the concept.


> is there a general way to do if-else? For example I'd like to query all elements which have not been colored so far, but all I could do is select non-highway. Thus it's overriding my contour lines part.

The matching is based on tags, there is no "so far", need to always declare the tag/values in rules, either directly or using special characters.

e.g. the tunnels have some rules for match, no match values and not present.


> How can I do zoom-min on a caption? It doesn't work the way I wrote.

e.g. the house numbers are just captions rendered from zoom 17.

--
Emux

Gustl22

unread,
Jan 20, 2018, 2:20:48 PM1/20/18
to mapsforge-dev
Hi,

I don't really get the principle of the select.

What does select="first" exactly mean?

Is there a selector for select="when-missed", that selects elements that weren't matched in a m-block? Or should it be implemented?
One example: if you have amenities and want to add a text style to a bunch of selected elements with select="when-matched". How can I style the left elements? Especially in default_atlas.xml via web you can't simply add an extra <text>some style</text> add the end to "fill" missed elements. All were overridden with this text style then.

Thanks!

Emux

unread,
Jan 20, 2018, 3:12:00 PM1/20/18
to mapsfo...@googlegroups.com
What means "selects elements that weren't matched in a m-block"?
Like select all (thousands) map elements which aren't matched by a single rule?

A rule doesn't or cannot search the map to find additional elements, it expects specific declarations to perform matches.

So can use special characters like:
- wildcard "*" (matches every value or key and is equivalent to their absence)
- negation "~" (matches if the map element doesn't have a tag with the specified key)
- exclude "-" (matches if the map element has tag without the specified values)

Example of their use is in tunnels declaration and implementation in RuleBuilder class.

Regarding selectors can check their comments / implementation in Rule class.

Hope that helps, I understand the lack of documentation, any contributions here are welcome. :)

Mapsforge has a render theme guide.
VTM extends that (e.g. Mapsforge doesn't support the exclude "-").

--
Emux

I_G

unread,
Jan 20, 2018, 3:38:55 PM1/20/18
to mapsforge-dev
Hi,

A NOT operator for tag values in Mapsforge would be nice, ie.
<rule e="*" k="shop" v="!cheese">
to select all but cheese shops :)

Best regards,
IG

Emux

unread,
Jan 20, 2018, 3:52:25 PM1/20/18
to mapsfo...@googlegroups.com
> A NOT operator for tag values in Mapsforge would be nice

That's what above VTM "-" exclude rule handles.

I created #1030 in Mapsforge repository.

--
Emux

Gustl22

unread,
Jan 21, 2018, 5:05:38 AM1/21/18
to mapsforge-dev
Example:

<m k="amenity">
<m select="first" zoom-min="15">
<m v="hospital">
<symbol src="hospital" />
<text priority="9" use="health" />
</m>
<m v="library">
<symbol src="library" />
<text priority="9" use="caption-small-blue" />
</m>
<m select="when-matched" zoom-min="17">
<text priority="9" use="poi" />
</m>
<m select="when-missed" zoom-min="17"> <!--equivalent to--> <m k="amenity" v="-|hospital|library">
<text priority="9" use="caption-small-blue" />
</m>
</m>
</m>

1) what effect has the select="first" operator? Select only the first rule? That wouldn't make sense.

2) "selects elements that weren't matched in a m-block": the when-missed operator should do the same as the "-|hospital|library" without specifying the values again (e.g. consider more than 20 values). Is there such an operator?

Emux

unread,
Jan 21, 2018, 8:53:48 AM1/21/18
to mapsfo...@googlegroups.com
1) That should select the 1st match of all enclosing sub-rules in a rule section (not any 1st sub-rule).
Could be useful with symbols to avoid overlap. Need to test with a simple theme xml to understand better.

2) The when-matched in a sub-rule is related to the matched results of a rule section.
So (unimplemented) when-missed should know what to miss, and those can be retrieved as the enclosing rule matches.

For all these we should study / test very carefully the code, there isn't currently a better guide.

--
Emux
Reply all
Reply to author
Forward
0 new messages