Skip to content

Commit

Permalink
Fix #23290: Validate the regions a tag is expected to be in (patch by…
Browse files Browse the repository at this point in the history
… Sarabjeet108, modified)

Modifications are as follows:
* Allow the use of the new `region` attributes for keys inside a preset
* Basic tests

`regions` comes from Vespucci's extensions: https://vespucci.io/tutorials/presets/#extensions

git-svn-id: https://josm.openstreetmap.de/svn/trunk@18918 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
taylor.smock committed Dec 19, 2023
1 parent e9ad3a9 commit d9bb236
Show file tree
Hide file tree
Showing 33 changed files with 665 additions and 205 deletions.
32 changes: 16 additions & 16 deletions resources/data/defaultpresets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@
<list_entry value="unmarked" icon="presets/vehicle/crossing_unmarked.svg" />
<list_entry value="no" />
</combo>
<combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" />
<combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" regions="GB" />
<combo key="kerb" text="Kerb" values="flush,lowered,no,raised,rolled,yes" values_context="kerb" />
<combo key="supervised" text="Crossing attendant" delimiter="|" values="yes|no|06:00-20:00|Mo-Fr 09:00-18:00,Sa 08:00-14:00|May-Sep 09:30-12:30,14:15-19:30" values_i18n="false" values_sort="false" />
<check key="crossing:island" text="With island" />
Expand Down Expand Up @@ -1516,7 +1516,7 @@
<list_entry value="unmarked" icon="presets/vehicle/crossing_unmarked.svg" />
</combo>
<reference ref="crossing_markings" />
<combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" values_searchable="true" />
<combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" values_searchable="true" regions="GB" />
<combo key="kerb" text="Kerb" values="flush,lowered,no,raised,rolled,yes" values_context="kerb" />
<combo key="supervised" text="Crossing attendant" delimiter="|" values="yes|no|06:00-20:00|Mo-Fr 09:00-18:00,Sa 08:00-14:00|May-Sep 09:30-12:30,14:15-19:30" values_i18n="false" values_sort="false" />
<combo key="tactile_paving" text="Tactile Paving" values="yes,no,incorrect" />
Expand Down Expand Up @@ -7308,10 +7308,10 @@
<list_entry value="war_memorial" short_description="A building, monument, statue or other edifice celebrating a victory or commemorating those who died or were injured in a war." />
<list_entry value="sculpture" short_description="A non figurative sculpture which does not match any of the other categories." />
<list_entry value="cross" short_description="A cross-shaped memorial." />
<list_entry value="blue_plaque" short_description="A blue plaque commemorating a historical link to that location. (UK)" />
<list_entry value="blue_plaque" short_description="A blue plaque commemorating a historical link to that location. (UK)" regions="GB" />
<list_entry value="obelisk" short_description="An obelisk." />
<list_entry value="ghost_bike" short_description="A bicycle painted white permanently placed as memorial for a victim of a road accident (usually cyclists)." />
<list_entry value="stolperstein" short_description="10cm × 10cm brass plaque commemorating victims of Nazi persecution. (EU,RU)" />
<list_entry value="stolperstein" short_description="10cm × 10cm brass plaque commemorating victims of Nazi persecution. (EU,RU)" regions="EU,RU" />
<list_entry value="bench" short_description="A bench placed in memory of someone or something; usually has a plaque, and sometimes a statue sitting on (part of) it." />
</combo>
<optional>
Expand Down Expand Up @@ -8261,7 +8261,7 @@
<check key="payment:girocard" text="Girocard" match="keyvalue" />
<check key="payment:laser" text="Laser" match="keyvalue" />
<check key="payment:maestro" text="Maestro" match="keyvalue" />
<check key="payment:postfinance_card" text="PostFinance Card (ch)" match="keyvalue" />
<check key="payment:postfinance_card" text="PostFinance Card (ch)" match="keyvalue" region="CH" />
<check key="payment:visa_debit" text="Visa Debit" match="keyvalue" />
<check key="payment:visa_electron" text="Visa Electron" match="keyvalue" />
</checkgroup>
Expand All @@ -8280,12 +8280,12 @@
<space />
<combo key="payment:electronic_purses" text="Electronic purses and Charge cards" values="yes,no" match="keyvalue" />
<checkgroup columns="4">
<check key="payment:ep_avant" text="Avant (fi)" match="keyvalue" />
<check key="payment:ep_geldkarte" text="Geldkarte (de)" match="keyvalue" />
<check key="payment:ep_mep" text="Mep (pt)" match="keyvalue" />
<check key="payment:ep_minicash" text="Minicash (lu)" match="keyvalue" />
<check key="payment:ep_minipay" text="Minipay (it)" match="keyvalue" />
<check key="payment:ep_monedero4b" text="Mondero 4b (es)" match="keyvalue" />
<check key="payment:ep_avant" text="Avant (fi)" match="keyvalue" regions="FI" />
<check key="payment:ep_geldkarte" text="Geldkarte (de)" match="keyvalue" regions="DE" />
<check key="payment:ep_mep" text="Mep (pt)" match="keyvalue" regions="PT" />
<check key="payment:ep_minicash" text="Minicash (lu)" match="keyvalue" regions="LU" />
<check key="payment:ep_minipay" text="Minipay (it)" match="keyvalue" regions="IT" />
<check key="payment:ep_monedero4b" text="Mondero 4b (es)" match="keyvalue" regions="ES" />
</checkgroup>
<space />
<combo key="payment:cryptocurrencies" text="Cryptocurrencies" values="yes,no" match="keyvalue" />
Expand Down Expand Up @@ -9968,11 +9968,11 @@
<optional>
<text key="destination" text="Name of river/lake/sea/ocean it runs into" />
<text key="ref" text="Reference" />
<text key="ref:sandre" text="Reference Sandre (FR)" />
<text key="ref:fgkz" text="Reference FGKZ (DE)" />
<text key="ref:regine" text="Reference REGINE (NO)" />
<text key="ref:gnis" text="Reference GNIS (USA)" />
<text key="ref:gnbc" text="Reference GNBC (CA)" />
<text key="ref:sandre" text="Reference Sandre (FR)" regions="FR" />
<text key="ref:fgkz" text="Reference FGKZ (DE)" regions="DE" />
<text key="ref:regine" text="Reference REGINE (NO)" regions="NO" />
<text key="ref:gnis" text="Reference GNIS (USA)" regions="US" />
<text key="ref:gnbc" text="Reference GNBC (CA)" regions="CA" />
<reference ref="wikipedia_wikidata" />
</optional>
<roles>
Expand Down
28 changes: 25 additions & 3 deletions resources/data/tagging-preset.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<complexContent>
<extension base="tns:group-parent">
<attributeGroup ref="tns:attributes.name" />
<attributeGroup ref="tns:attributes.regions"/>
</extension>
</complexContent>
</complexType>
Expand All @@ -121,7 +122,7 @@
<complexType name="item">
<annotation>
<documentation>
Every item is one annotation set to select from. name is required, type and preset_name_label are recommended, icon and name_template are optional attributes.
Every item is one annotation set to select from. name is required, type and preset_name_label are recommended and icon, name_template, regions and exclude_regions are optional attributes.
</documentation>
</annotation>
<sequence>
Expand All @@ -134,6 +135,7 @@
</sequence>
<attributeGroup ref="tns:attributes.name" />
<attributeGroup ref="tns:attributes.icon" />
<attributeGroup ref="tns:attributes.regions"/>
<attribute name="type" type="string">
<annotation>
<documentation><![CDATA[
Expand Down Expand Up @@ -364,7 +366,7 @@
<complexType name="list_entry">
<annotation>
<documentation><![CDATA[
Used in <combo/> and <multiselect/>. More information see short_descriptions below. The attributes are value, display_value, short_description, icon and icon_size.
Used in <combo/> and <multiselect/>. More information see short_descriptions below. The attributes are value, display_value, short_description, icon, icon_size, regions, and exclude_regions.
]]></documentation>
</annotation>
<attribute name="value" type="string" use="required" />
Expand All @@ -378,6 +380,7 @@
</annotation>
</attribute>
<attributeGroup ref="tns:attributes.icon" />
<attributeGroup ref="tns:attributes.regions"/>
<anyAttribute processContents="skip" />
</complexType>

Expand Down Expand Up @@ -489,6 +492,7 @@
</attribute>
<attribute name="match" type="tns:match" />
<attributeGroup ref="tns:attributes.icon" />
<attributeGroup ref="tns:attributes.regions"/>

<attribute name="name" use="prohibited" />
<attribute name="type" use="prohibited" />
Expand Down Expand Up @@ -558,7 +562,7 @@
<complexType name="role">
<annotation>
<documentation>
To specify possible roles of members in relations. The key attribute is required, text, requisite, count, type and member_expression are optional.
To specify possible roles of members in relations. The key attribute is required, text, requisite, count, type, member_expression, regions, and exclude_regions are optional.
</documentation>
</annotation>
<attribute name="key" type="string">
Expand All @@ -574,6 +578,7 @@
<attribute name="count" type="integer" />
<attribute name="member_expression" type="string" />
<attribute name="regexp" type="boolean" />
<attributeGroup ref="tns:attributes.regions"/>
<anyAttribute processContents="skip" />
</complexType>

Expand Down Expand Up @@ -729,4 +734,21 @@
</attribute>
</attributeGroup>

<attributeGroup name="attributes.regions">
<attribute name="regions" type="string">
<annotation>
<documentation>
Comma separated list of countries this preset group or item is applicable for. If not specified, the preset is applicable for all countries.
</documentation>
</annotation>
</attribute>
<attribute name="exclude_regions" type="boolean">
<annotation>
<documentation>
If true, invert the meaning of regions.
</documentation>
</annotation>
</attribute>
</attributeGroup>

</schema>
6 changes: 3 additions & 3 deletions src/org/openstreetmap/josm/data/osm/OsmUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ public final class OsmUtils {

/**
* Discouraged synonym for {@link #TRUE_VALUE}
* @deprecated since xxx, use {@link #TRUE_VALUE} instead.
* @deprecated since 18801, use {@link #TRUE_VALUE} instead.
*/
@Deprecated
public static final String trueval = TRUE_VALUE;
/**
* Discouraged synonym for {@link #FALSE_VALUE}
* @deprecated since xxx, use {@link #FALSE_VALUE} instead.
* @deprecated since 18801, use {@link #FALSE_VALUE} instead.
*/
@Deprecated
public static final String falseval = FALSE_VALUE;
/**
* Discouraged synonym for {@link #REVERSE_VALUE}
* @deprecated since xxx, use {@link #REVERSE_VALUE} instead.
* @deprecated since 18801, use {@link #REVERSE_VALUE} instead.
*/
@Deprecated
public static final String reverseval = REVERSE_VALUE;
Expand Down
Loading

0 comments on commit d9bb236

Please sign in to comment.