RenderTheme: append a fixed string to value

110 views
Skip to first unread message

Deyan Vasilev

unread,
Jul 19, 2019, 4:21:34 PM7/19/19
to mapsforge-dev
Hi everyone,

is there a way to append a fixed string to a value in e.g. a caption?
For example:  append a " m" to the value of the "ele" key, so to get "1505 m" in the caption?

Best regards,
Dido

Emux

unread,
Jul 20, 2019, 4:12:04 AM7/20/19
to mapsfo...@googlegroups.com
Mean in map labels when render Mapsforge map files with render themes?

The values come from the input osm/pbf file and the theme just renders them.

Can influence values in map (e.g. add units in 'ele' tags) by using TagTransform Osmosis plugin as an intermediate step in map-writer input.

--
Emux

Deyan Vasilev

unread,
Jul 22, 2019, 9:31:23 AM7/22/19
to mapsforge-dev
Exactly.
I get used with this option in the Mapnik rendering xml control file. In the text symbolizer you can append/prepend arbitrary text to the field value.

E.g. you can build a language translation table for the resources in a mine that are usually given in English, add a " (closed)"
 string to the name of a building that is usually not accessible, etc.

On Saturday, July 20, 2019 at 11:12:04 AM UTC+3, Emux wrote:
Mean in map labels when render Mapsforge map files with render themes?

--
Emux

xarly89

unread,
Nov 29, 2019, 1:12:55 PM11/29/19
to Mapsforge & VTM
This feature would be really nice, since it's possible to apply a TagTransform while generating your own maps, but it's not possible to do this if we are talking about an online vector source.

Is it possible to display another Text / Caption element, right next to another one? Perhaps this way we could achieve the same effect.

Deyan Vasilev

unread,
May 20, 2021, 3:37:36 PM5/20/21
to mapsfo...@googlegroups.com
Emux,

is TagTransform capable of appending two key/value pairs into a new one, e.g:
name=abc
height=2

--> name=abc (2)

I tried building a translation to do this kind of stuff but I cannot
figure out how to reference {1} and {2} coming out from two different
match_ids into a single output key.
> --
> 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-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/7ac9ab54-709d-e997-8f22-e2032fe93e27%40gmail.com.

Emux

unread,
May 21, 2021, 4:25:03 AM5/21/21
to mapsfo...@googlegroups.com
Probably you could do it with multiple matches {1}, {2}, ...

You can read more details in TagTransform documentation.

And see the OpenAndroMaps TagTransform xml for more examples.

--
Emux

Deyan Vasilev

unread,
May 21, 2021, 5:11:29 AM5/21/21
to mapsfo...@googlegroups.com
Hi Emux, I did it, not working.
Here's my match script:

<translation>
<name>Rock name</name>
<description>
</description>
<match mode="and">
<tag k="height" v="([0-9]+)" match_id="ht_nm"/>
<tag k="name" v="(.+)" match_id="ht_nm"/>
</match>
<output>
<copy-all/>
<tag from_match="ht_nm" k="name_corrected" v="{1}{2}"/>
</output>
</translation>

End result is: I get a field "name_corrected". There I get
'somename{2}'. It seems that the {2} match group is just missing. My
suggestion is that finally match_id="ht_nm" comes from the <tag
k="name" v="(.+)" match_id="ht_nm"/> only and the first tag match for
height is simply overwritten.

I tried also to put both tags into separate match_ids, e.g.

<match mode="and">
<tag k="height" v="([0-9]+)" match_id="ht"/>
<tag k="name" v="(.+)" match_id="nm"/>
</match>

but I don't know how to combine them in the output, e.g. in a similar
(here illegal) way:

<output>
<copy-all/>
<tag from_match="ht from_match="nm" k="name_corrected" v="{1}{2}"/>
</output>
> --
> You received this message because you are subscribed to the Google Groups "Mapsforge & VTM" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/21e4265d-f8c4-96f4-a5ff-45cd51915e2c%40gmail.com.

Deyan Vasilev

unread,
May 26, 2021, 8:39:19 AM5/26/21
to mapsfo...@googlegroups.com
Hi Emux,

in case you've missed my answer, do you have any suggestions?

Emux

unread,
May 26, 2021, 8:41:33 AM5/26/21
to mapsfo...@googlegroups.com
If TagTrasform cannot work for you,
you need to edit your input osm in another way and modify its values.

--
Emux

Deyan Vasilev

unread,
Jun 2, 2021, 11:43:16 AM6/2/21
to mapsfo...@googlegroups.com
Just for the record if anyone needs to resolve a similar issue:

I finally managed to transform name tags using ogr2osm with osm format
on both input and the output.
ogr2osm allows any kind of tag transformations using simple python scripting.
> --
> You received this message because you are subscribed to the Google Groups "Mapsforge & VTM" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/bebabc3e-2c90-474e-6379-85c98fd4d8db%40gmail.com.
Reply all
Reply to author
Forward
0 new messages