Modify

Opened 3 years ago

Last modified 3 years ago

#19190 new enhancement

Option to set and call variables in tagging presets and validator rules

Reported by: skyper Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: variable tagging preset rule Cc:

Description

I often find myself copy & pasting value strings which are identical in presets.
An option to define that string in a variable and call it later would make life much easier, especially, when updating values and in terms of consistency.

    <combo key="turn:lanes:forward" text="Turn lanes in way direction" values="left|left,left|through,left;through|through,left;through|through;right,left|through;right,left;through|right,through|through,through|through;right,through|right,right|right,none|right,left|none,left|through|right,left|through|through;right,left;through|through|right,left;through|through;right|right,left|left;through|through|right,left|through|through;right|right,left|through|through|right,merge_to_right|merge_to_left,none|merge_to_left,merge_to_right|none,reverse|sharp_left;left|slight_left|through|slight_right;right|sharp_right|none" values_searchable="true" values_sort="false" match="key" />
    <combo key="turn:lanes:backward" text="Turn lanes opposed to way direction" values="left|left,left|through,left;through|through,left;through|through;right,left|through;right,left;through|right,through|through,through|through;right,through|right,right|right,none|right,left|none,left|through|right,left|through|through;right,left;through|through|right,left;through|through;right|right,left|left;through|through|right,left|through|through;right|right,left|through|through|right,merge_to_right|merge_to_left,none|merge_to_left,merge_to_right|none,reverse|sharp_left;left|slight_left|through|slight_right;right|sharp_right|none" values_searchable="true" values_sort="false" match="key" />

Would change to:

<var name="turnlane" value="left|left,left|through,left;through|through,left;through|through;right,left|through;right,left;through|right,through|through,through|through;right,through|right,right|right,none|right,left|none,left|through|right,left|through|through;right,left;through|through|right,left;through|through;right|right,left|left;through|through|right,left|through|through;right|right,left|through|through|right,merge_to_right|merge_to_left,none|merge_to_left,merge_to_right|none,reverse|sharp_left;left|slight_left|through|slight_right;right|sharp_right|none" />

    <combo key="turn:lanes:forward" text="Turn lanes in way direction" values="match_var(turnlane)" values_searchable="true" values_sort="false" match="key" />
    <combo key="turn:lanes:backward" text="Turn lanes opposed to way direction" values="match_var(turnlane)" values_searchable="true" values_sort="false" match="key" />

Similar is true for, e.g., long regex in validator rules. Again, a variable could solve the problem.

Attachments (0)

Change History (1)

comment:1 Changed 3 years ago by skyper

Oh, according to wiki:Help/Styles/MapCSSImplementation#Userdefinedproperties it should work for validator rules but I did not understand it. What do I do wrong or does the feature not work?

/* #19095, TODO: exclude "source:lanes" and "change:lanes=no|no", properly */
-lanes_tags: "join_list(", ",tag_regex(":lanes$"))";
way[highway][length("lanes_tags")>0][oneway=no] {
  set lanes_oneway_no;
  throwWarning: tr("{0} with {1} and {2} and without postfix {3}", "{0.tag}", "{1.tag}", "{2.tag}", ":forward/backward/both_ways");
  group: tr("suspicious tag combination");
  assertMatch: "way highway=motorway oneway=no turn:lanes=left|right";
  assertNoMatch: "way highway=motorway oneway=no turn:lanes:forward=left|right";
  assertNoMatch: "way highway=motorway oneway=-1 turn:lanes=left|right";
}
way[highway][length("lanes_tags")>0][oneway!=yes][oneway!=-1][highway !~ /^(motorway|motorway_link|trunk|trunk_link)$/]!.lanes_oneway_no {
  throwWarning: tr("{0} with {1} but without {2} or postfix {3}", "{0.tag}", "{1.tag}", "{2.tag}", ":forward/backward/both_ways");
  group: tr("suspicious tag combination");
  assertMatch: "way highway=primary turn:lanes=left|right";
  assertMatch: "way highway=primary turn:lanes=left|right source:lanes=abc";
  assertNoMatch: "way highway=motorway turn:lanes=left|right";
  assertNoMatch: "way highway=primary turn:lanes:forward=left|right";
/*  assertNoMatch: "way highway=primary source:lanes=abc";*/
}

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set.
to The owner will be changed from team to the specified user.
The owner will change to skyper
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.