[VTM] render-theme file creation tutorial

936 views
Skip to first unread message

Adi Barda

unread,
Jul 1, 2018, 7:52:36 AM7/1/18
to mapsforge-dev
Hi Everyone,
My App (AdvRider WD) now has full support for MapsForge maps using VTM library. Thank you very much for a great lib and I'll be glad if you put it the applications list. 
Now, I need to create a render-theme file for off-road usage. I understand that best is to use OpenAndroMaps with Elevate4 render-theme as a basis?
On top of that I need to make some modifications to the rendering and I would like to know if there is any documentation for understanding / creating render-theme files?

Thanks a lot!

Emux

unread,
Jul 1, 2018, 9:00:39 AM7/1/18
to mapsfo...@googlegroups.com
Thanks for the info, I added it in VTM applications list.


Regarding render themes:

You can study VTM render themes documentation, (adapted from community from similar Mapsforge docs).

VTM default render theme is recommended to be used as basis, since VTM has differences with Mapsforge themes.


Elevate can be used for ideas, but it's a Mapsforge theme, and though VTM can read Mapsforge themes, they often aren't perfect inside VTM.

--
Emux

Adi Barda

unread,
Jul 1, 2018, 9:37:11 AM7/1/18
to mapsforge-dev
Thanks!
My application is mostly for off-road usages so one important requirement is to render contour lines so given that I have an OpenAndroMap which has the contour lines data, is it possible to add to the default render-theme the contour instructions? something like that:

<!-- contour lines -->
<rule e="any" k="*" v="*" cat="contour">
<rule e="way" k="contour_ext" v="*" zoom-max="9">
<rule e="way" k="contour_ext" v="elevation_major">
<line stroke="#8E8072" stroke-width="0.9" />
</rule>
</rule>
<rule e="way" k="contour_ext" v="*" zoom-min="10" zoom-max="12">
<rule e="way" k="contour_ext" v="elevation_medium">
<line stroke="#8E8072" stroke-width="0.6" />
</rule>
<rule e="way" k="contour_ext" v="elevation_major">
<line stroke="#8E8072" stroke-width="1.5" />
</rule>
</rule>
<rule e="way" k="contour_ext" v="*" zoom-min="13" zoom-max="13">
<rule e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" stroke-width="0.6" />
</rule>
<rule e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" stroke-width="1.5" />
</rule>
</rule>
<rule e="way" k="contour_ext" v="*" zoom-min="14" zoom-max="14">
<rule e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" stroke-width="0.45" />
</rule>
<rule e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" stroke-width="1.2" />
<pathText k="ele" font-style="bold" font-size="10" fill="#6E5A46" stroke="#E5FFFFFF" stroke-width="1" />
</rule>
</rule>
<rule e="way" k="contour_ext" v="*" zoom-min="15" zoom-max="15">
<rule e="way" k="contour_ext" v="elevation_minor" zoom-max="15">
<line stroke="#8E8072" stroke-width="0.36" />
</rule>
<rule e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" stroke-width="0.9" />
<pathText k="ele" font-style="bold" font-size="11" fill="#6E5A46" stroke="#E5FFFFFF" stroke-width="1" />
</rule>
</rule>
<rule e="way" k="contour_ext" v="*" zoom-min="16" zoom-max="16">
<rule e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" stroke-width="0.24" />
</rule>
<rule e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" stroke-width="0.6" />
<pathText k="ele" font-style="bold" font-size="12" fill="#6E5A46" stroke="#E5FFFFFF" stroke-width="2" />
</rule>
</rule>
<rule e="way" k="contour_ext" v="*" zoom-min="17">
<rule e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" stroke-width="0.18" />
</rule>
<rule e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" stroke-width="0.45" />
<pathText k="ele" font-style="bold" font-size="12" fill="#6E5A46" stroke="#E5FFFFFF" stroke-width="2" />
</rule>
</rule>
</rule>

Emux

unread,
Jul 1, 2018, 9:39:15 AM7/1/18
to mapsfo...@googlegroups.com
Could work, but if use a VTM theme as base then should convert the rules to VTM theme schema.

--
Emux

Adi Barda

unread,
Jul 1, 2018, 10:33:55 AM7/1/18
to mapsforge-dev
I did this straight forward conversion to the contour rules and put it in the default.xml and it's not working.. I'm sure I have a lots of things to learn - is there any kind of compiler to check for possible errors in the render-theme?


    <m e="any" k="*" v="*" cat="contour">
<m e="way" k="contour_ext" v="*" zoom-max="9">
<m e="way" k="contour_ext" v="elevation_major">
<line stroke="#8E8072" width="0.9" />
</m>
</m>
<m e="way" k="contour_ext" v="*" zoom-min="10" zoom-max="12">
<m e="way" k="contour_ext" v="elevation_medium">
<line stroke="#8E8072" width="0.6" />
</m>
<m e="way" k="contour_ext" v="elevation_major">
<line stroke="#8E8072" width="1.5" />
</m>
</m>
<m e="way" k="contour_ext" v="*" zoom-min="13" zoom-max="13">
<m e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" width="0.6" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="1.5" />
</m>
</m>
<m e="way" k="contour_ext" v="*" zoom-min="14" zoom-max="14">
<m e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" width="0.45" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="1.2" />
                                
                <caption k="ele" font-style="bold" size="10" fill="#6E5A46" stroke="#E5FFFFFF" width="1" />
<!--<pathText k="ele" font-style="bold" font-size="10" fill="#6E5A46" stroke="#E5FFFFFF" width="1" /> -->
</m>
</m>
<m e="way" k="contour_ext" v="*" zoom-min="15" zoom-max="15">
<m e="way" k="contour_ext" v="elevation_minor" zoom-max="15">
<line stroke="#8E8072" width="0.36" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="0.9" />
                
                <caption k="ele" font-style="bold" size="11" fill="#6E5A46" stroke="#E5FFFFFF" width="1" />
<!--<pathText k="ele" font-style="bold" font-size="11" fill="#6E5A46" stroke="#E5FFFFFF" width="1" /> -->
</m>
</m>
<m e="way" k="contour_ext" v="*" zoom-min="16" zoom-max="16">
<m e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" width="0.24" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="0.6" />
                
                <caption k="ele" font-style="bold" size="12" fill="#6E5A46" stroke="#E5FFFFFF" width="2" />
<!--<pathText k="ele" font-style="bold" font-size="12" fill="#6E5A46" stroke="#E5FFFFFF" width="2" />-->
</m>
</m>
<m e="way" k="contour_ext" v="*" zoom-min="17">
<m e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" width="0.18" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="0.45" />
                
                <caption k="ele" font-style="bold" size="12" fill="#6E5A46" stroke="#E5FFFFFF" width="2" />
<!--<pathText k="ele" font-style="bold" font-size="12" fill="#6E5A46" stroke="#E5FFFFFF" width="2" />-->
</m>
</m>
</m>

Emux

unread,
Jul 1, 2018, 10:39:44 AM7/1/18
to mapsfo...@googlegroups.com
> is there any kind of compiler to check for possible errors in the render-theme?

If work the xml theme files inside an IDE (like IDEA, Eclipse, etc) or advanced Editor, they can use the online xml schema (declared in themes) and validate the rules.

--
Emux

Adi Barda

unread,
Jul 2, 2018, 9:09:01 AM7/2/18
to mapsforge-dev
Emux, can you assist?
I followed the XSD and it looks fine. I have added the contour lines rules block (below) and refreshed Cruiser GL  application (F5) and nothing happened...
I'm using OpenAndroMap so the info exists.
Also, is there any other known active forums / groups to consult with developers about VTM / Render-theme ?

Thanks a lot!


<m e="way" k="*" v="*" cat="contour">
<m e="way" k="contour_ext" v="~" zoom-max="9">
<m e="way" k="contour_ext" v="elevation_major">
<line stroke="#8E8072" width="0.9" />
</m>
</m>
<m e="way" k="contour_ext" v="~" zoom-min="10" zoom-max="12">
<m e="way" k="contour_ext" v="elevation_medium">
<line stroke="#8E8072" width="0.6" />
</m>
<m e="way" k="contour_ext" v="elevation_major">
<line stroke="#8E8072" width="1.5" />
</m>
</m>
<m e="way" k="contour_ext" v="~" zoom-min="13" zoom-max="13">
<m e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" width="0.6" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="1.5" />
</m>
</m>
<m e="way" k="contour_ext" v="~" zoom-min="14" zoom-max="14">
<m e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" width="0.45" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="1.2" />
                                
                <caption k="ele" font-style="bold" size="10" fill="#6E5A46" stroke="#E5FFFFFF" width="1" />
<!--<pathText k="ele" font-style="bold" font-size="10" fill="#6E5A46" stroke="#E5FFFFFF" width="1" /> -->
</m>
</m>
<m e="way" k="contour_ext" v="~" zoom-min="15" zoom-max="15">
<m e="way" k="contour_ext" v="elevation_minor" zoom-max="15">
<line stroke="#8E8072" width="0.36" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="0.9" />
                
                <caption k="ele" font-style="bold" size="11" fill="#6E5A46" stroke="#E5FFFFFF" width="1" />
<!--<pathText k="ele" font-style="bold" font-size="11" fill="#6E5A46" stroke="#E5FFFFFF" width="1" /> -->
</m>
</m>
<m e="way" k="contour_ext" v="~" zoom-min="16" zoom-max="16">
<m e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" width="0.24" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="0.6" />
                
                <caption k="ele" font-style="bold" size="12" fill="#6E5A46" stroke="#E5FFFFFF" width="2" />
<!--<pathText k="ele" font-style="bold" font-size="12" fill="#6E5A46" stroke="#E5FFFFFF" width="2" />-->
</m>
</m>
<m e="way" k="contour_ext" v="~" zoom-min="17">
<m e="way" k="contour_ext" v="elevation_minor">
<line stroke="#8E8072" width="0.18" />
</m>
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">
<line stroke="#8E8072" width="0.45" />
                
                <caption k="ele" font-style="bold" size="12" fill="#6E5A46" stroke="#E5FFFFFF" width="2" />
<!--<pathText k="ele" font-style="bold" font-size="12" fill="#6E5A46" stroke="#E5FFFFFF" width="2" />-->
</m>
</m>
</m>

Adi Barda

unread,
Jul 2, 2018, 9:58:06 AM7/2/18
to mapsforge-dev
I also tried to change "*" to "any" in the "k" and "v" attributes, played with "priority" attr and tried using layers. non of this made it work. I'm missing something basic...
Message has been deleted

Gustl22

unread,
Jul 2, 2018, 11:27:58 AM7/2/18
to mapsforge-dev
Vtm does not provide "*" or "any" for e, k or v parameters. Simply ignore them if you want to pass all elements to subsections. It's like a filter. All params in VTM themes are optional, so you don't have to specify them in every section <m/>.

Have a look at vtm theme, to understand better:
https://github.com/mapsforge/vtm/blob/master/vtm-themes/resources/assets/vtm/default.xml

Emux

unread,
Jul 2, 2018, 12:27:58 PM7/2/18
to mapsfo...@googlegroups.com
> Also, is there any other known active forums / groups to consult with developers about VTM / Render-theme ?

This is the official forum of Mapsforge and VTM vector map libraries.


It's recommended to play with a plain theme (copy of default.xml) with the minimum new elements in it, so can debug them easily.

Also it's important to check in what order in theme the new elements are placed, i.e. to not be hidden by other elements.

Here is an old test with contours in VTM, don't know if still works (can try thicker strokes):

 <m cat="contour" closed="no" e="way" k="contour_ext">
     
<m e="way" k="contour_ext" zoom-max="9">

         
<m e="way" k="contour_ext" v="elevation_major">

             
<line fix="true" stroke="#8E8072" width="0.3"/>
         
</m>
     
</m>
     
<m e="way" k="contour_ext" zoom-max="12" zoom-min="10">

         
<m e="way" k="contour_ext" v="elevation_medium">

             
<line fix="true" stroke="#8E8072" width="0.2"/>

         
</m>
         
<m e="way" k="contour_ext" v="elevation_major">

             
<line fix="true" stroke="#8E8072" width="0.5"/>
         
</m>
     
</m>
     
<m e="way" k="contour_ext" zoom-max="13" zoom-min="13">

         
<m e="way" k="contour_ext" v="elevation_minor">

             
<line fix="true" stroke="#8E8072" width="0.2"/>

         
</m>
         
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">

             
<line fix="true" stroke="#8E8072" width="0.5"/>
         
</m>
     
</m>
     
<m e="way" k="contour_ext" zoom-max="14" zoom-min="14">

         
<m e="way" k="contour_ext" v="elevation_minor">

             
<line fix="true" stroke="#8E8072" width="0.15"/>

         
</m>
         
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">

             
<line fix="true" stroke="#8E8072" width="0.4"/>
             
<text style="bold" fill="#6E5A46" k="ele" size="7" stroke="#E5FFFFFF"
                   
stroke-width="1"/>
         
</m>
     
</m>
     
<m e="way" k="contour_ext" zoom-max="15" zoom-min="15">

         
<m e="way" k="contour_ext" v="elevation_minor">

             
<line fix="true" stroke="#8E8072" width="0.12"/>

         
</m>
         
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">

             
<line fix="true" stroke="#8E8072" width="0.3"/>
             
<text style="bold" fill="#6E5A46" k="ele" size="8" stroke="#E5FFFFFF"
                   
stroke-width="1"/>
         
</m>
     
</m>
     
<m e="way" k="contour_ext" zoom-max="16" zoom-min="16">

         
<m e="way" k="contour_ext" v="elevation_minor">

             
<line fix="true" stroke="#8E8072" width="0.08"/>

         
</m>
         
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">

             
<line fix="true" stroke="#8E8072" width="0.2"/>
             
<text style="bold" fill="#6E5A46" k="ele" size="9" stroke="#E5FFFFFF"
                   
stroke-width="2"/>
         
</m>
     
</m>
     
<m e="way" k="contour_ext" zoom-min="17">

         
<m e="way" k="contour_ext" v="elevation_minor">

             
<line fix="true" stroke="#8E8072" width="0.06"/>

         
</m>
         
<m e="way" k="contour_ext" v="elevation_medium|elevation_major">

             
<line fix="true" stroke="#8E8072" width="0.15"/>
             
<text style="bold" fill="#6E5A46" k="ele" size="9" stroke="#E5FFFFFF"
                   
stroke-width="2"/>
         
</m>
     
</m>
 
</m>

--
Emux

Adi Barda

unread,
Jul 3, 2018, 11:15:43 AM7/3/18
to mapsforge-dev

Thanks everyone, I have a good progress with the contour lines.
If I understand correctly then Elevate4 render-theme is not good for use with VTM (I wonder why?)
So now I need to kind of translate it to VTM's format.
Any idea where to start from or I just need to trial and error on every aspect? It looks like it will take a lot of time..

I'm thinking of getting the VTM's OSM render-theme as a base theme and add all the hiking stuff
 

Emux

unread,
Jul 3, 2018, 11:31:16 AM7/3/18
to mapsfo...@googlegroups.com
Elevate theme is developed with Mapsforge map engine, so naturally plays very well there.

VTM detects and reads Mapsforge themes automatically, so can parse them nicely.

But there are theme rules which exist in VTM and don't exist in Mapsforge and vice versa.
Also some rule sizes / widths may need adjustments in each, since they're different map engines.


Can open simultaneously in Cruiser (Mapsforge) and Cruiser GL (VTM) an OpenAndroMaps map + Elevate theme and compare their rendering.

And also vtm-theme-comparator can help in such procedures.

--
Emux

Adi Barda

unread,
Jul 3, 2018, 11:48:00 AM7/3/18
to mapsforge-dev
So Emux, given that MapsForge themes are officially supported, maybe it will be best to start with Elevate4 as a basis and to adjust it to my needs instead of building everything from scratch?
The only reason I see not to do so is if MapsForge themes support is deprecated and will not be further maintained then It makes sense to invest only in theme that is planned to be supported in the future

Emux

unread,
Jul 3, 2018, 11:58:23 AM7/3/18
to mapsfo...@googlegroups.com
VTM (like all map engines) has its own theme rules often more advanced for OpenGL rendering.

Afterwards community added support for Mapsforge themes, but obviously can expect differences.
(and some unimplemented rules for a theme to work 'as is' without adjustments)

Better compare both, study the differences and proceed accordingly. :)

--
Emux

Adi Barda

unread,
Jul 3, 2018, 3:25:41 PM7/3/18
to mapsforge-dev
I guess I'm going to try the VTM theme route first :)
Reply all
Reply to author
Forward
0 new messages