#18949 closed enhancement (fixed)
[TaggingPreset] Make templates available for formatting key values, like for item names
Reported by: | KorneySan | Owned by: | simon04 |
---|---|---|---|
Priority: | normal | Milestone: | 21.03 |
Component: | Core | Version: | |
Keywords: | preset, template_for_key_value, name_template | Cc: |
Description (last modified by )
Proposal is to make formatting by template available for key values like it done for item names.
This is especially usable for public transport routes naming.
In TaggingPresets there is an example for item naming:
<?xml version="1.0" encoding="UTF-8"?> <presets> <item name="Public transportation" type="relation" name_template="Bus({operator} {ref} ?{'{from} - {via} - {to}' | '{from} - {to}' | '{from}' | '{to}'})" name_template_filter="type=route route=bus"> </item> </presets>
which set JOSM to DISPLAY a route relation name by that template. But the same is suitable for the route name by default:
<text key="name" text="Name" default_template="Bus {ref}?{: '{from} → {to}'}" default_template_filter="type=route route=bus"> />
The value set event should happen for example on route creation dialogue OK button press.
Attachments (1)
Change History (23)
comment:1 by , 5 years ago
Description: | modified (diff) |
---|
comment:2 by , 5 years ago
Component: | Core → Internal preset |
---|
comment:3 by , 5 years ago
Component: | Internal preset → Core |
---|---|
Keywords: | name_template added |
comment:4 by , 5 years ago
I'm confused: the title says "formatting key values", the description says "formatting by template" (meaning for display purposes?), the description says "value set event" (change something?). Please provide the following details.
Having default_template="Bus {ref}?{: '{from} → {to}'}"
in place, when creating a new relation (using the preset dialog only) without providing a name
, the template should be evaluated based on the other values (which in turn might trigger a default_template
as well??) and the result be set as name
?
follow-up: 6 comment:5 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → needinfo |
follow-up: 20 comment:6 by , 5 years ago
Replying to Don-vip:
Having
default_template="Bus {ref}?{: '{from} → {to}'}"
in place, when creating a new relation (using the preset dialog only) without providing aname
, the template should be evaluated based on the other values (which in turn might trigger adefault_template
as well??) and the result be set asname
?
Exactly!
On preset dialog closing by OK button the engine should check the name
value and if it is empty AND default_template
is set, it should evaluate default_template
and set the result to the name
.
comment:7 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | needinfo → new |
comment:8 by , 4 years ago
Ticket #20049 has been marked as a duplicate of this ticket.
Use case: in a multilingual region we have to fill in the attributes
name
,name:de
, andname:it
.name
is a string concatenation ofname:de
andname:it
. It would save a lot of keystrokes ifname
could be calculated fromname:de
andname:it
.
Another use case:
osmc:symbol
could be calculated fromoperator
andref
.
comment:9 by , 4 years ago
Milestone: | → 21.03 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
by , 4 years ago
Attachment: | Screenshot 2021-03-20 at 23.07.24.png added |
---|
comment:12 by , 4 years ago
-
resources/data/defaultpresets.xml
diff --git a/resources/data/defaultpresets.xml b/resources/data/defaultpresets.xml index 51be7b0ce..309de2e6b 100644
a b 2834 2834 </item> <!-- Public Transport Route (Rail) --> 2835 2835 <item name="Public Transport Route (Bus)" icon="presets/misc/route.svg" type="relation" preset_name_label="true"> 2836 2836 <link wiki="Public_transport#Service_routes" /> 2837 2837 <space /> 2838 2838 <key key="type" value="route" /> 2839 2839 <combo key="route" text="Route type" values="bus,share_taxi,trolleybus" values_searchable="true" match="keyvalue!" /> 2840 2840 <key key="public_transport:version" value="2" /> <!-- only validate marked relations in order to avoid false positives --> 2841 <reference ref="name_ref" /> 2841 <text key="name" text="Name" value_template="Bus {ref}: {from} → {to}" /> 2842 <text key="ref" text="Reference" /> 2842 2843 <optional> 2843 2844 <reference ref="public_transport_route_optionals" /> 2844 2845 <combo key="reservation" text="Reservation" values="yes,no,required,recommended" /> 2845 2846 </optional> 2846 2847 <roles> 2847 2848 <role key="stop" text="stop position" requisite="optional" type="node" member_expression="public_transport=stop_position (bus=yes OR share_taxi=yes OR trolleybus=yes)" /> 2848 2849 <role key="stop_exit_only" text="stop position (exit only)" requisite="optional" type="node" member_expression="public_transport=stop_position (bus=yes OR share_taxi=yes OR trolleybus=yes)" />
comment:15 by , 4 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Documentation: TaggingPresets?action=diff&version=179
follow-up: 17 comment:16 by , 4 years ago
Thanks for this feature but sadly it does not work that nicely with defaultpresets.
- We have lots of route relations' presets with a combo for
route=*
. How can I get the value ofroute=*
with a capital, first letter or even in local language? - I often have more than one value for
via
. How can I split the string at the semicolon and add some chars in between?
follow-up: 18 comment:17 by , 4 years ago
comment:18 by , 4 years ago
Replying to skyper:
Replying to skyper:
- We have lots of route relations' presets with a combo for
route=*
. How can I get the value ofroute=*
with a capital, first letter or even in local language?Tried to solve this with the syntax of
name_template=""
but it does not work: #20842.
Thanks, now it works with r17860.
Replying to simon04:
Documentation: TaggingPresets?action=diff&version=179
As far as I understand it, the syntax of name_template=""
is used which means it is not limited to values of <text />
and not even to only the object tags as e.g. parent relations and their tags could be used. Am I right?
name_template
is only defined for<item>
, atm. E.g., this is a an enhancement for core.