meta
{
  title: "MapThisWay";
  version: "0.131";
  description: "Map This Way";
  author: "Francesco Ansanelli";
  watch-modified: true;
}

/* mtw missingdispensing */

*[amenity=pharmacy][!dispensing][inside("IT")] {
	throwWarning: tr("{0} without {1}", "{0.value}", "{1.key}");
	group: "MapThisWay";
}

/* mtw missingoven */

*[cuisine ~= "pizza"][!oven][inside("IT")] {
	throwWarning: tr("{0} without {1}", "{0.value}", "{1.key}");
	group: "MapThisWay";
}

/* mtw unknownoven */

*[oven][oven !~ /^(no|electric|wood_fired|gas_fired)$/] {
	throwWarning: tr("unusual value of {0}", "{0.key}");
	group: "MapThisWay";
}

/* mtw restaurantkebab */

*[amenity!=fast_food][cuisine ~= "kebab"][inside("IT")] {
	throwWarning: tr("{0} without {1}", "{1.value}", "{0.value}");
	group: "MapThisWay";
}

/* mtw addressonbuilding */

way[building][tag_regex("^addr:*")][inside("IT")] {
	throwWarning: tr("building with addr:*");
	group: "MapThisWay";
}

/* mtw buildingnoroof */

way[building][roof:levels=0][roof:shape!=flat] {
	throwWarning: tr("{0} with {1} {2} not {3} {4}", "{0.key}", "{1.key}", "{1.value}", "{2.key}", "{2.value}");
	group: "MapThisWay";
}

/* mtw namenotcapitalized */

*[addr:street =~ /^[a-z]/],
*[name =~ /^[a-z]/] {
	throwWarning: tr("{0} not capitalized", "{0.key}");
	group: "MapThisWay";
}

/* mtw missingauthorization */

*[shop=tobacco][!authorization][inside("IT")] {
	throwWarning: tr("{0} without {1}", "{0.value}", "{1.key}");
	group: "MapThisWay";
}

/* mtw wrongbuildingtype TOO MANY ERRORS

*[office][office!=government] ∈
*[building][building!~/^(apartments|commercial|office|industrial|retail|supermarket|warehouse|kiosk)$/]{
	throwWarning: tr("office inside wrong building type");
	group: "MapThisWay";
}
*/
/* mtw wrongbuildingtype */

*[office=government] ∈
*[building][building!=government]{
	throwWarning: tr("office inside wrong building type");
	group: "MapThisWay";
}

/* mtw wrongbuildingtype TOO MANY ERRORS

*[shop] ∈
*[building][building!~/^(apartments|commercial|office|industrial|retail|supermarket|warehouse|kiosk)$/] {
	throwWarning: tr("shop inside wrong building type");
	group: "MapThisWay";
}
 */

/* mtw amenitywithname */

*[amenity=~/^(drinking_water|bbq|charging_station|grit_bin|parking_entrance|ticket_validator|atm|bureau_de_change|baking_oven|bench|clock|photo_booth|post_box|table|telephone|vending_machine|waste_basket|waste_disposal|watering_place|water_point)$/][name] {
	throwWarning: tr("{0} with {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* mtw nodewithbuilding */

node[building] {
	throwWarning: tr("node with {0}", "{0.key}");
	group: "MapThisWay";
}

/* mtw citylimitwithoutdirection */

node[traffic_sign=city_limit][!direction] {
	throwWarning: tr("{0} without {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* mtw numerocivicoerrato */
*[addr:housenumber][addr:housenumber !~ /^(0|[1-9][0-9]*)([a-z]{0,1}|(\/[1-9][0-9]*[a-z]{0,1})|bis|((qua)?ter))(\b rosso\b)?$/][inside("IT")] {
	throwWarning: tr("Numero Civico");
	group: "MapThisWay";
	assertMatch: "00";
	assertMatch: "01";
	assertMatch: "a";
	assertMatch: "1A";
	assertMatch: "1 a";
	assertMatch: "1/BIS";
	assertMatch: "0/0";
	assertMatch: "1 nero";
	assertNoMatch: "1";
	assertNoMatch: "1a";
	assertNoMatch: "1bis";
	assertNoMatch: "1ter";
	assertNoMatch: "1quater";
	assertNoMatch: "1/1";
	assertNoMatch: "95/1a";
	assertNoMatch: "1 rosso";
	assertNoMatch: "0";
	assertNoMatch: "0a";
}

/* ENABLE AFTER MY PATCH GET MERGED:
 * https://josm.openstreetmap.de/ticket/18166
 *
*["addr:housenumber"][replace(tag("addr:housenumber"),",",";") != join_list(";",filter("^(0|[1-9][0-9]*)([a-z]{0,1}|(\\/[1-9][0-9]*[a-z]{0,1})|bis|((qua)?ter))(\\b rosso\\b)?$",split(";",replace(tag("addr:housenumber"),",",";"))))][inside("IT")] {
	throwWarning: tr("Numero Civico");
	group: "MapThisWay";
	assertMatch: "00";
	assertMatch: "01";
	assertMatch: "a";
	assertMatch: "1A";
	assertMatch: "1 a";
	assertMatch: "1/BIS";
	assertMatch: "0/0";
	assertMatch: "1 nero";
	assertNoMatch: "1";
	assertNoMatch: "1a";
	assertNoMatch: "1bis";
	assertNoMatch: "1ter";
	assertNoMatch: "1quater";
	assertNoMatch: "1/1";
	assertNoMatch: "95/1a";
	assertNoMatch: "1 rosso";
	assertNoMatch: "0";
	assertNoMatch: "0a";
	assertNoMatch: "1;3";
	assertNoMatch: "1,3";
}*/

/* mtw unusualvending
 * https://josm.openstreetmap.de/ticket/17751
 *
*[amenity=vending_machine][vending][tag("vending") != join_list(";",filter("^(admission_tickets|animal_feed|art|bicycle_tube|books|bottle_return|bread|candles|chemist|chewing_gums|cigarettes|coffee|condoms|drinks|electronics|elongated_coin|excrement_bags|feminine_hygiene|first_aid|fishing_bait|fishing_tackle|flowers|food|fuel|ice_cream|ice_cubes|ink_cartridges|laundry_detergent|lottery|milk|newspapers|parcel_mail_in|parcel_pickup|parking_tickets|public_transport_plans|public_transport_tickets|sex_toys|SIM_cards|stamps|sweets|syringes|telephone_vouchers|toll|toys|umbrellas|water)$",split(";",tag("vending"))))] {
	throwWarning: tr("unusual value of {0}", "{1.key}");
	group: "MapThisWay";
}*/

/* mtw roundaboutwithname */

way[junction=roundabout][name] {
	throwWarning: tr("Roundabout with name");
	group: "MapThisWay";
}

/* mtw wifiyes */

*[wifi=yes] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "internet_access=wlan";
	group: "MapThisWay";
	fixRemove: "wifi";
	fixAdd: "internet_access=wlan";
}

/* mtw wifino */

*[wifi=no] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "internet_access";
	group: "MapThisWay";
	fixChangeKey: "wifi => internet_access";
}

/* mtw wififree */

*[wifi=free] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "internet_access=wlan";
	group: "MapThisWay";
	fixRemove: "wifi";
	fixAdd: "internet_access=wlan";
	fixAdd: "internet_access:fee=no";
}

/* mtw officetravelagent */

*[office=travel_agent] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "shop=travel_agency";
	group: "MapThisWay";
	fixRemove: "office";
	fixAdd: "shop=travel_agency";
}

/* mtw refwithspace - suggested by Andrea Musuruane */

way[highway][ref =~ /(\s+)|[;]/] {
	throwWarning: tr("unusual value of {0}", "{1.key}");
	group: "MapThisWay";
}


/* mtw landusewithname - suggested by Andrea Musuruane
SHOULD BE INVESTIGATED MORE BEFORE ENABILING...
way[landuse][name] {
	throwWarning: tr("{0} with {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}
*/

/* mtw onlychristian - suggested by Andrea Musuruane */

*[amenity=place_of_worship][religion=christian][!denomination] {
	throwWarning: tr("{0} without {1}", "{0.value}", "{2.key}");
	group: "MapThisWay";
}

/* mtw trafficsingunconnected - suggested by Andrea Musuruane */

node:unconnected[traffic_sign][traffic_sign=city_limit] {
	throwWarning: tr("{0}", "{2.tag}");
	group: "MapThisWay";
}

/* mtw facebookaswebsite */

*[website =~ /facebook/] {
	throwWarning: tr("{0}", "{0.tag}");
	group: "MapThisWay";
}

/* mtw invalidphone */
/* VALIDI
+39 0171 123456
+39-0171-123456
+39 0171 123 4567
+39 0171 12345
+39-0171-12345
+39 0171 12345
+39 02 12345
+39 0171 12345678
NON VALIDI
+39-0171-123 4567
+39 0171-123456
+39-0171 123456
+45 0171 123 4567
+39 0171-123 4567
*/

*["contact:phone"]["contact:phone" !~ /^(?:(?:\+39-0[0-9]{1,3}-[0-9]+)|(?:\+39 0[0-9]{1,3} [0-9]{3,}(?: [0-9]{4,})?))$/][inside("IT")],
*[phone][phone !~ /^(?:(?:\+39-0[0-9]{1,3}-[0-9]+)|(?:\+39 0[0-9]{1,3} [0-9]{3,}(?: [0-9]{4,})?))$/][inside("IT")] {
	throwWarning: tr("{0}", "{0.key}");
	group: "MapThisWay";
}

/* mtw invalidmobilephone */
/*VALIDI
+39 349 123456
+39-349-123456
+39 349 123 4567
+39 349 123 456
+39 349 123456
+39-349-123456
+39 349 123456
NON VALIDI
+39 349 1234 567
+39 349 12345
+39-349-12345
+39 39 123456
+39 444 12345
+39-349-123 4567
+39 349-123456
+39-349 123456
+45 349 123 4567
+39 349-123 4567
+39 349 12345678
*/

*["contact:mobile"]["contact:mobile" !~ /^(?:(?:\+39-3[0-9]{2}-[0-9]{6,7})|(?:\+39 3[0-9]{2} [0-9]{6,7})|(?:\+39 3[0-9]{2} [0-9]{3} [0-9]{3,4}))$/][inside("IT")],
*["phone:mobile"]["phone:mobile" !~ /^(?:(?:\+39-3[0-9]{2}-[0-9]{6,7})|(?:\+39 3[0-9]{2} [0-9]{6,7})|(?:\+39 3[0-9]{2} [0-9]{3} [0-9]{3,4}))$/][inside("IT")] {
	throwWarning: tr("{0}", "{0.key}");
	group: "MapThisWay";
}

/* mtw invalidtollfree */

*["contact:phone:IT"]["contact:phone:IT" !~ /^8[0-9]{2}[- ][0-9]+$/],
*["phone:IT"]["phone:IT" !~ /^8[0-9]{2}[- ][0-9]+$/] {
	throwWarning: tr("{0}", "{0.key}");
	group: "MapThisWay";
}

/* mtw busonwrongelement */
node[public_transport != "stop_position"][bus="yes"] {
	throwWarning: tr("{0} on suspicious object", "{1.tag}");
	group: "MapThisWay";
	fixRemove: "bus";
}

/* mtw shoplamps */

*[shop=lamps] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "shop=lighting";
	group: "MapThisWay";
	fixRemove: "shop";
	fixAdd: "shop=lighting";
}

/* mtw naturaltreenotmonumental - suggested by canfe */

node[natural=tree][!tag_regex("^(name|genus|species)")] {
	throwWarning: tr("{0} without name, genus or species", "{0.tag}");
	group: "MapThisWay";
}

/* mtw invaliddug - suggested by canfe */

way[highway][highway != "cycleway"][highway != "path"][highway != "via_ferrata"][name][name !~ /^(?i)(arco|autostrada|belvedere|calata|calle|cavalcavia|circonvallazione|corso|corte|cortile|discesa|galleria|gradinata|larghetto|largo|litoranea|lungargine|lungo[a-z]+|molo|parcheggio|passaggio|passeggiata|percorso ciclabile|percorso ciclopedonale|percorso pedonale|piazza|piazzale|piazzetta|pista ciclabile|ponte|raccordo|rampa|ronco|rotatoria|rotonda|salita|scalinata|scesa|sentiero|slargo|sottopasso|sovrappasso|spiazzo|strada|strada antica|strada comunale|strada consortile|strada nuova|strada panoramica|strada poderale|strada privata|strada provinciale|strada regionale|strada statale|strada vecchia|strada vicinale|stradella|stradello|stradone|tangenziale|traversa|traversa privata|via|via antica|via comunale|via nazionale|via nuova|via panoramica|via privata|via provinciale|via vecchia|viale|vialetto|vico|vico chiuso|vico cieco|vico privato|vicoletto|vicolo|vicolo chiuso|vicolo cieco|vicolo privato|viottolo)[ ]/][inside("IT")] {
	throwWarning: tr("unusual value of {0}", "{3.key}");
	group: "MapThisWay";
}

/* mtw invalidstartdate */

*["start_date"]["start_date" !~ /^(?:(?:mid|before|after|late) )?(?:(?:[0-9]{1,4}(?:-[0-9]{2}){0,2})|(?:[~C]*[0-9]+[s]?))(?: BC)?$/] {
	throwWarning: tr("{0}", "{0.key}");
	group: "MapThisWay";
}

/* mtw fblink */

*[facebook] {
	throwWarning: tr("{0} is deprecated", "{0.key}");
	suggestAlternative: "contact:facebook";
	group: "MapThisWay";
	fixChangeKey: "facebook => contact:facebook";
}

*["contact:facebook"]["contact:facebook" !~ /^https:\/\/www\.facebook\.com\//] {
	throwWarning: tr("{0}", "{0.tag}");
	group: "MapThisWay";
}

/* mtw iglink */

*["contact:instagram"]["contact:instagram" !~ /^(https:\/\/www\.instagram\.com\/)|@/] {
	throwWarning: tr("{0}", "{0.tag}");
	group: "MapThisWay";
}

/* mtw ischedit */

*["isced:level"]["isced:level" !~ /^[0-3]$/][inside("IT")] {
	throwWarning: tr("{0}", "{0.tag}");
	group: "MapThisWay";
}

/* mtw scuolainfanzia */

*[!highway][amenity!=kindergarten]["name" =~ /(?i)(scuola (materna|dell'infanzia))|asilo/] {
	throwWarning: tr("Asilo senza {0}", "{1.tag}");
	group: "MapThisWay";
	fixAdd: "amenity=kindergarten";
}

/* mtw nidonotnursery */

*[amenity=kindergarten]["name" =~ /(?i)nido/][nursery!=yes] {
	throwWarning: tr("{0} without {1}", "{0.value}", "{2.tag}");
	group: "MapThisWay";
	fixAdd: "nursery=yes";
}

/* mtw scuolainfanzianoisced */

*[amenity=kindergarten]["isced:level" != "0"] {
	throwWarning: tr("{0} without {1}", "{0.value}", "{1.key}");
	group: "MapThisWay";
	fixRemove: "isced:level";
	fixAdd: "isced:level=0";
}

/* mtw scuolaelementare */

*["name" =~ /(?i)scuola (primaria|elementare)/] {
	set scuola_elementare;
}

*[amenity!=school].scuola_elementare {
	throwWarning: tr("scuola elementare senza amenity=school");
	group: "MapThisWay";
}

*["isced:level" != "1"][amenity=school].scuola_elementare {
	throwWarning: tr("scuola elementare senza isced:level o isced:level non valido");
	group: "MapThisWay";
	fixRemove: "isced:level";
	fixAdd: "isced:level=1";
}

/* mtw scuolemedie */

*["name" =~ /(?i)scuola (media( inferiore)?)|(secondaria)/] {
	set scuola_media;
}

*["isced:level" != "2"][amenity=school].scuola_media {
	throwWarning: tr("scuola media senza isced:level o isced:level non valido");
	group: "MapThisWay";
	fixRemove: "isced:level";
	fixAdd: "isced:level=2";
}

/* mtw scuolesuperiori */

*["name" =~ /(?i)(istituto (magistrale|(di istruzione superiore)|tecnico|commerciale))|liceo/] {
	set scuola_superiore;
}

*["isced:level" != "3"][amenity=school].scuola_superiore {
	throwWarning: tr("scuola superiore senza isced:level o isced:level non valido");
	group: "MapThisWay";
	fixRemove: "isced:level";
	fixAdd: "isced:level=3";
}

/* mtw unkwnownschool */

*[amenity=school]!.scuola_superiore!.scuola_media!.scuola_elementare {
	throwWarning: tr("scuola non riconosciuta");
	group: "MapThisWay";
}

/* mtw schoolnoref */

*[amenity=kindergarten][!ref], *[amenity=school][!ref] {
	group: "MapThisWay";
	throwWarning: tr("scuola senza ref (cercare su cercalatuascuola.istruzione.it)");
}

/* mtw crossing */

way[highway] > node[highway=crossing],
way[highway=footway][footway=crossing],
way[highway=cycleway][cycleway=crossing] {
	set attraversamento_pedonale;
}

/* mtw crossingunknown */

*[crossing][crossing!=no]!.attraversamento_pedonale,
*[highway=crossing]!.attraversamento_pedonale {
	throwWarning: tr("Attraversamento pedonale non riconosciuto");
	group: "MapThisWay";
}

/* mtw crossingzebranouk */

*[crossing=zebra][outside("GB")].attraversamento_pedonale {
	throwWarning: tr("{0} outside of UK", "{0.tag}");
	suggestAlternative: "crossing=uncontrolled";
	group: "MapThisWay";
	fixRemove: "crossing";
	fixAdd: "crossing=uncontrolled";
	fixAdd: "crossing_ref=zebra";
}

/* mtw crossingmarked */

*[crossing=marked].attraversamento_pedonale {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "crossing=uncontrolled";
	group: "MapThisWay";
	fixRemove: "crossing";
	fixAdd: "crossing=uncontrolled";
}

/* mtw crossingcalming */

*[traffic_calming][traffic_calming!=table][traffic_calming!=hump].attraversamento_pedonale {
	throwWarning: tr("Attraversamento su {0}", "{0.tag}");
	group: "MapThisWay";
}

/* mtw tracktypenottrack */

way[tracktype][highway!=track] {
	throwWarning: tr("{0} not {1}", "{0.key}", "{1.tag}");
	group: "MapThisWay";
}

/* mtw comma */

*[cuisine =~ /,/] {
	throwWarning: tr("{0} with comma", "{0.key}");
	group: "MapThisWay";
}

/* mtw randomhighwayservice */

way[highway!=service][service] {
	throwWarning: tr("{0} not {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* mtw towervsmast

node["tower:type"=communication][man_made != mast] {
	throwWarning: tr("{0} not {1}", "{0.key}", "{1.value}");
	group: "MapThisWay";
	fixRemove: "man_made";
	fixAdd: "man_made=mast";
}
*/

/* mtw coinsinstadofcash */

*[amenity!="vending_machine"]["payment:coins"] {
	throwWarning: tr("{0}", "{1.key}");
	group: "MapThisWay";
	suggestAlternative: "payment:cash";
	fixChangeKey: "payment:coins => payment:cash";
}

/* mtw inknotprinter */

*[shop=ink] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "shop=printer_ink";
	group: "MapThisWay";
	fixRemove: "shop";
	fixAdd: "shop=printer_ink";
}

/* mtw farmyardwithoutfarm - Suggested by Andrea Musuruane */

*[place=farm] ⊈ area:closed2[landuse=farmyard] {
	throwWarning: tr("{0} without place=farm", "{1.tag}");
	group: "MapThisWay";
}

/* mtw farmnotinsidefarmyard - Suggested by Andrea Musuruane */

area[landuse=farmyard] ⊉ *[place=farm] {
	throwWarning: tr("{0} not inside landuse=farmyard", "{0.tag}");
	group: "MapThisWay";
}


/* mtw onelanenooneway - Suggested by Volker */

way[highway][lanes<2][!oneway][!junction] {
	throwWarning: tr("{0} {1}<{2} without {3}", "{0.key}", "{1.key}", "{1.value}", "{2.key}");
	group: "MapThisWay";
}

/* mtw onelanenopassingplaces - Suggested by Andrea Musuruane */

way[highway][lanes<2][oneway=no][passing_places!=yes] {
	throwWarning: tr("{0} {1}<{2} with {3} without {4}", "{0.key}", "{1.key}", "{1.value}", "{2.tag}", "{3.tag}");
	group: "MapThisWay";
	fixAdd: "passing_places=yes";
}

/* mtw passingplacesmanylanes */

way[highway][lanes>=2][passing_places] {
	throwWarning: tr("{0} {1}>={2} with {3}", "{0.key}", "{1.key}", "{1.value}", "{2.key}");
	group: "MapThisWay";
	fixAdd: "lane_markings=no";
	fixRemove: "passing_places";
}

/* mtw onelanelanemarkings */

way[highway][lanes<2][lane_markings] {
	throwWarning: tr("{0} {1}<{2} with {3}", "{0.key}", "{1.key}", "{1.value}", "{2.key}");
	group: "MapThisWay";
	fixRemove: "lane_markings";
}

/* mtw clinicnothealthcare */

*[social_facility][social_facility=healthcare] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "amenity=clinic";
	group: "MapThisWay";
	fixRemove: "social_facility";
	fixAdd: "amenity=clinic";
}

/* mtw milestone */
*[addr:milestone][addr:milestone !~ /^(?:km|mi)\. [0-9]*[.+]?[0-9]+$/] {
	throwWarning: tr("Invalid milestone");
	group: "MapThisWay";
}

/* mtw milestoneswithhousenumber */
*[addr:milestone][addr:housenumber] {
	throwWarning: tr("{0} with {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* mtw accessyes */
way[highway][access=permissive],
way[highway][access=yes] {
	throwWarning: tr("{0} with {1} is harmful", "{0.key}", "{1.tag}");
	group: "MapThisWay";
	fixRemove: "access";
}

/* mtw pathwithfootyes */
way[highway=path][foot=yes][!horse] {
	throwWarning: tr("{0} with {1} is redundant", "{0.value}", "{1.tag}");
	group: "MapThisWay";
	suggestAlternative: "foot=designated";
	fixAdd: "foot=designated";
}

/* mtw pathwithbicycleyes */
way[highway=path][bicycle=yes][!horse] {
	throwWarning: tr("{0} with {1} is redundant", "{0.value}", "{1.tag}");
	group: "MapThisWay";
	suggestAlternative: "bicycle=designated";
	fixAdd: "bicycle=designated";
}

/* mtw segregatednofoot */
way[segregated][!foot] {
	throwWarning: tr("{0} without {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* mtw segregatednobicicle */
way[segregated][!bicycle] {
	throwWarning: tr("{0} without {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* mtw segregatedwronghighway */
*[segregated][highway != path][highway != cycleway][highway != footway][highway != crossing] {
	throwWarning: tr("{0} without {1}, {2}, {3}", "{0.key}", "{1.tag}", "{2.tag}", "{3.tag}");
	group: "MapThisWay";
}

/* mtw caiscaleonway */
way[cai_scale] {
	throwWarning: tr("{0} on a way", "{0.key}");
	group: "MapThisWay";
	fixRemove: "cai_scale";
}

/* mtw rnsacscale */
relation[sac_scale],
node[sac_scale] {
	throwWarning: tr("{0} not on way", "{0.key}");
	group: "MapThisWay";
	fixRemove: "sac_scale";
}

/* mtw rntrailvisibility */
relation[trail_visibility],
node[trail_visibility] {
	throwWarning: tr("{0} not on way", "{0.key}");
	group: "MapThisWay";
	fixRemove: "trail_visibility";
}

/* mtw highwayonrelation */
relation[highway] {
	throwWarning: tr("{0} on a relation", "{0.key}");
	group: "MapThisWay";
	fixRemove: "highway";
}

/* mtw biketrack */
way[highway!=path][highway!=footway][bicycle=yes] {
	throwWarning: tr("{0} is redundant", "{2.tag}");
	group: "MapThisWay";
	fixRemove: "bicycle";
}

/* mtw foottrack */
way[highway!=path][highway!=cycleway][foot=yes] {
	throwWarning: tr("{0} is redundant", "{2.tag}");
	group: "MapThisWay";
	fixRemove: "foot";
}

/* mtw busstopconnected */
way[highway] > node[highway=bus_stop] {
	throwWarning: tr("{0} collegato alla way", "{0.tag}");
	group: "MapThisWay";
}

/* mtw sentierocai */
/* FIXME identificare elenco tag per capire che è CAI */

relation["ref:REI"] {
	set sentiero_cai;
}

/* mtw refrei */

relation["ref:REI"]["ref:REI" !~ /^((?:E(?:AL|AT|BI|CN|NO|TO|VB|VC)[A-Z][A-Z0-9]{3}[A-Z0-9])|(?:[A-DF-Z][A-Z]{2}[A-Z][A-Z0-9]{3}[A-Z0-9]))$/] {
	throwWarning: tr("unusual value of {0}", "{1.key}");
	group: "MapThisWay";
	set invalid_ref_rei;
}

/* mtw missingcairef */

relation.sentiero_cai[!ref] {
	throwWarning: tr("{0} without {1}", "Sentiero CAI", "{1.key}");
	group: "MapThisWay";
}

/* mtw invalidcairef */

relation["ref:REI"]!.invalid_ref_rei[tag(ref)!=concat(substring(tag("ref:REI"), 4, 7), replace(substring(tag("ref:REI"), 7, 8), "0", ""))] {
	throwWarning: tr("ref non compatibile con ref:REI");
	fixAdd: concat("ref=", substring(tag("ref:REI"), 4, 7), replace(substring(tag("ref:REI"), 7, 8), "0", ""));
	group: "MapThisWay";
}

/* mtw wrnname */

relation.sentiero_cai[!"rwn:name"] {
	throwWarning: tr("{0} without {1}", "Sentiero CAI", "{1.key}");
	group: "MapThisWay";
}

/* mtw cairpe */

relation["rwn:name"]["ref:REI" =~ /^E/]["rwn:name"!="Rete Patrimonio Escursionistico Piemonte (RPE)"] {
	throwWarning: tr("unusual value of {0}", "{2.key}");
	fixAdd: "rwn:name=Rete Patrimonio Escursionistico Piemonte (RPE)";
	group: "MapThisWay";
}

/* mtw caitagblacklist */

relation.sentiero_cai[tag_regex("^(?!(type|route|network|name|ref|cai_scale|roundtrip|source|source:ref|survey:date|osmc:symbol|symbol(?::it)*|operator|old_ref|ascent|descent|distance|duration:forward|duration:backward|from|to|rwn:name|reg_ref|ref:REI|maintenance(?::it)*|state|note(?::it)*|note:project_page|website|wikimedia_commons|description(?::it)*)$)(\\w*)")] {
	throwWarning: tr("tag non nello schema CAI");
	group: "MapThisWay";
}

/* mtw unknowncaiscale */

relation[cai_scale][cai_scale !~ /^(T|E|EE|EEA|EAI)$/] { 
	throwWarning: tr("unusual value of {0}", "{0.tag}");
	group: "MapThisWay";
}

/* mtw nosacscale */

relation[cai_scale] > way[!sac_scale] { 
	throwWarning: tr("strada senza {0} parte di un sentiero CAI", "{0.key}");
	group: "MapThisWay";
}

/* mtw sacscalet */

relation[cai_scale="T"] > way[sac_scale][sac_scale!="hiking"] { 
	throwWarning: tr("strada con {0} parte di un sentiero con cai_scale=T", "{0.tag}");
	group: "MapThisWay";
}

/* mtw sacscalee */
relation[cai_scale="E"] > way[sac_scale][sac_scale!="hiking"] { 
	throwWarning: tr("strada con {0} parte di un sentiero con cai_scale=E", "{0.tag}");
	group: "MapThisWay";
}

/* mtw sacscaleee */

relation[cai_scale="EE"] > way[sac_scale][sac_scale!="hiking"][sac_scale!="mountain_hiking"][sac_scale!="demanding_mountain_hiking"] { 
	throwWarning: tr("strada con {0} parte di un sentiero con cai_scale=EE", "{0.tag}");
	group: "MapThisWay";
}

/* mtw sacscaleeai */

relation[cai_scale="EAI"] > way[sac_scale][sac_scale!="hiking"][sac_scale!="mountain_hiking"][sac_scale!="demanding_mountain_hiking"][sac_scale!="alpine_hiking"] { 
	throwWarning: tr("strada con {0} parte di un sentiero con cai_scale=EAI", "{0.tag}");
	group: "MapThisWay";
}

/* mtw survey:date */

*["survey:date"]["survey:date" !~ /^(?:[0-9]{1,4}(?:-[0-9]{2}){0,2})$/] {
	throwWarning: tr("{0}", "{0.key}");
	group: "MapThisWay";
}

/* mtw refalreadyonrel */

relation[type=route][ref] way[tag("ref")=parent_tag("ref")] {
	throwWarning: tr("Ref già sulla relazione");
	fixRemove: "ref";
	group: "MapThisWay";
}

/* mtw unknowncaisourceref */

relation.sentiero_cai["source:ref"]["source:ref" !~ /^9[1-2][0-9]{5}$/] {
	throwWarning: tr("source:ref non riconosciuto");
	group: "MapThisWay";
}

/* addr:unit senza addr:housenumber */

*[addr:unit][!addr:housenumber] {
	throwWarning: tr("{0} without {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* place con addr:postcode */

*[place]["addr:postcode"] {
	throwWarning: tr("{0} with {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* name che contiene le virgolette */

*["name" =~ /"/] {
	throwWarning: tr("{0} with quotation mark(s)", "{0.key}");
	group: "MapThisWay";
}

/* mtw refvatin */
*[ref:vatin][ref:vatin !~ /^IT[0-9]{11}$/][inside("IT")] {
	throwWarning: tr("ref:vatin deve essere IT seguito da 11 cifre");
	group: "MapThisWay";
}

/* mtw guidepostontheway - suggested by Ivo Reano */
way[highway] > node[information=guidepost] {
	throwWarning: tr("scollegare il segnavia");
	group: "MapThisWay";
}

/* mtw historicamenity */
*[historic][amenity] {	
	throwWarning: tr("{0} together with {1}", "{0.key}", "{1.key}");
	group: "MapThisWay";
}

/* mtw churchnobuilding */
way[amenity=place_of_worship][!building] {	
	throwWarning: tr("{0} without {1}", "{0.tag}", "{1.key}");
	group: "MapThisWay";
}

/* mtw oldparkingschema */
way[tag_regex("^parking:lane:(both|left|right)")] {
	throwWarning: tr("{0} is deprecated", "parking:lane:side");
	group: "MapThisWay";
}

/* mtw oldparkingconditionschema */
way[tag_regex("^parking:condition:(both|left|right)")] {
	throwWarning: tr("{0} is deprecated", "parking:condition:side");
	group: "MapThisWay";
}

/* mtw oldparkingleftno */
way["parking:lane:left"=no] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:left => parking:left";
}

/* mtw oldparkingrightno */
way["parking:lane:right"=no] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:right => parking:right";
}

/* mtw oldparkingbothno */
way["parking:lane:both"=no] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:both";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:both => parking:both";
}

/* mtw oldparkingrightparallel */
way["parking:lane:right:parallel"]["parking:lane:right:parallel" =~ /(half_on_kerb|on_kerb|street_side|shoulder)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:right:parallel => parking:right";
	fixAdd: "parking:right:orientation=parallel";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingrightparallelonstreet */
way["parking:lane:right:parallel"]["parking:lane:right:parallel" =on_street] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixAdd: "parking:right=lane";
	fixAdd: "parking:right:orientation=parallel";
	fixRemove: "parking:lane:right:parallel";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingrightparallelunknown */
way["parking:lane:right"=parallel][!"parking:lane:right:parallel"] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixAdd: "parking:right=yes";
	fixAdd: "parking:right:orientation=parallel";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftparallel */
way["parking:lane:left:parallel"]["parking:lane:left:parallel" =~ /(half_on_kerb|on_kerb|street_side|shoulder)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:left:parallel => parking:left";
	fixAdd: "parking:left:orientation=parallel";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftparallelonstreet */
way["parking:lane:left:parallel"]["parking:lane:left:parallel" =on_street] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixAdd: "parking:left=lane";
	fixAdd: "parking:left:orientation=parallel";
	fixRemove: "parking:lane:left:parallel";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftparallelunknown */
way["parking:lane:left"=parallel][!"parking:lane:left:parallel"] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixAdd: "parking:left=yes";
	fixAdd: "parking:left:orientation=parallel";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingrightperpendicular */
way["parking:lane:right:perpendicular"]["parking:lane:right:perpendicular" =~ /(half_on_kerb|on_kerb|street_side|shoulder)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:right:perpendicular => parking:right";
	fixAdd: "parking:right:orientation=perpendicular";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingrightperpendicularonstreet */
way["parking:lane:right:perpendicular"]["parking:lane:right:perpendicular" =on_street] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixAdd: "parking:right=lane";
	fixAdd: "parking:right:orientation=perpendicular";
	fixRemove: "parking:lane:right:perpendicular";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingrightperpendicularunknown */
way["parking:lane:right"=perpendicular][!"parking:lane:right:perpendicular"] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixAdd: "parking:right=yes";
	fixAdd: "parking:right:orientation=perpendicular";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftperpendicular */
way["parking:lane:left:perpendicular"]["parking:lane:left:perpendicular" =~ /(half_on_kerb|on_kerb|street_side|shoulder)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:left:perpendicular => parking:left";
	fixAdd: "parking:left:orientation=perpendicular";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftperpendicularonstreet */
way["parking:lane:left:perpendicular"]["parking:lane:left:perpendicular" =on_street] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixAdd: "parking:left=lane";
	fixAdd: "parking:left:orientation=perpendicular";
	fixRemove: "parking:lane:left:perpendicular";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftperpendicularunknown */
way["parking:lane:left"=perpendicular][!"parking:lane:left:perpendicular"] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixAdd: "parking:left=yes";
	fixAdd: "parking:left:orientation=perpendicular";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingrightdiagonal */
way["parking:lane:right:diagonal"]["parking:lane:right:diagonal" =~ /(half_on_kerb|on_kerb|street_side|shoulder)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:right:diagonal => parking:right";
	fixAdd: "parking:right:orientation=diagonal";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingrightdiagonalonstreet */
way["parking:lane:right:diagonal"]["parking:lane:right:diagonal" =on_street] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixAdd: "parking:right=lane";
	fixAdd: "parking:right:orientation=diagonal";
	fixRemove: "parking:lane:right:diagonal";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingrightdiagonalunknown */
way["parking:lane:right"=diagonal][!"parking:lane:right:diagonal"] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right";
	group: "MapThisWay";
	fixAdd: "parking:right=yes";
	fixAdd: "parking:right:orientation=diagonal";
	fixRemove: "parking:lane:right";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftdiagonal */
way["parking:lane:left:diagonal"]["parking:lane:left:diagonal" =~ /(half_on_kerb|on_kerb|street_side|shoulder)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:left:diagonal => parking:left";
	fixAdd: "parking:left:orientation=diagonal";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftdiagonalonstreet */
way["parking:lane:left:diagonal"]["parking:lane:left:diagonal" =on_street] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixAdd: "parking:left=lane";
	fixAdd: "parking:left:orientation=diagonal";
	fixRemove: "parking:lane:left:diagonal";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftdiagonalunknown */
way["parking:lane:left"=diagonal][!"parking:lane:left:diagonal"] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left";
	group: "MapThisWay";
	fixAdd: "parking:left=yes";
	fixAdd: "parking:left:orientation=diagonal";
	fixRemove: "parking:lane:left";
	fixRemove: "parking:lane:both";
}

/* mtw oldparkingleftdeprecatedtwice */
way["parking:lane:left" =~ /(no_parking|no_stopping|no_standing)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left:restriction";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:left => parking:left:restriction";
}

/* mtw oldparkingrightdeprecatedtwice */
way["parking:lane:right" =~ /(no_parking|no_stopping|no_standing)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right:restriction";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:right => parking:right:restriction";
}

/* mtw oldparkingbothdeprecatedtwice */
way["parking:lane:both" =~ /(no_parking|no_stopping|no_standing)/] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:both:restriction";
	group: "MapThisWay";
	fixChangeKey: "parking:lane:both => parking:both:restriction";
}

/* mtw oldparkingleftticket */
way["parking:condition:left" = ticket] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left:fee=yes";
	group: "MapThisWay";
	fixAdd: "parking:left:fee=yes";
	fixRemove: "parking:condition:left";
}

/* mtw oldparkingrightticket */
way["parking:condition:right" = ticket] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right:fee=yes";
	group: "MapThisWay";
	fixAdd: "parking:right:fee=yes";
	fixRemove: "parking:condition:right";
}

/* mtw oldparkingbothticket */
way["parking:condition:both" = ticket] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:both:fee=yes";
	group: "MapThisWay";
	fixAdd: "parking:both:fee=yes";
	fixRemove: "parking:condition:both";
}

/* mtw oldparkingleftfree */
way["parking:condition:left" = free] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:left:fee=no";
	group: "MapThisWay";
	fixAdd: "parking:left:fee=no";
	fixRemove: "parking:condition:left";
}

/* mtw oldparkingrightfree */
way["parking:condition:right" = free] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:right:fee=no";
	group: "MapThisWay";
	fixAdd: "parking:right:fee=no";
	fixRemove: "parking:condition:right";
}

/* mtw oldparkingbothfree */
way["parking:condition:both" = free] {
	throwWarning: tr("{0} is deprecated", "{0.tag}");
	suggestAlternative: "parking:both:fee=no";
	group: "MapThisWay";
	fixAdd: "parking:both:fee=no";
	fixRemove: "parking:condition:both";
}

/* mtw wrongroleguidepost - Suggested by Ivo Reano */
relation[type=route] >[role != "guidepost"] node[information=guidepost] {
  throwWarning: tr("Segnavia senza ruolo guidepost");
	group: "MapThisWay";
}

/* mtw unusualmaxspeed */
way[maxspeed][maxspeed =~ /^(?!5$|10$|15$|20$|30$|40$|50$|60$|70$|80$|90$|100$|110$|120$|130$).*/][inside("IT")] {
	throwWarning: tr("unusual value of {0}", "{0.tag}");
	group: "MapThisWay";
}

/* mtw unusualmaxspeedp */
way[highway=primary][maxspeed][maxspeed > 110][inside("IT")] {
	throwWarning: tr("highway=secondary with maxspeed > 110", "{0.tag}");
	group: "MapThisWay";
}

/* mtw unusualmaxspeeds */
way[highway=secondary][maxspeed][maxspeed > 90][inside("IT")] {
	throwWarning: tr("highway=secondary with maxspeed > 90", "{0.tag}");
	group: "MapThisWay";
}

/* mtw unusualmaxspeedt */
way[highway=tertiary][maxspeed][maxspeed > 90][inside("IT")] {
	throwWarning: tr("highway=tertiary with maxspeed > 90", "{0.tag}");
	group: "MapThisWay";
}

/* mtw unusualmaxspeedr */
way[highway=residential][maxspeed][maxspeed > 50][inside("IT")] {
	throwWarning: tr("highway=residential with maxspeed > 50", "{0.tag}");
	group: "MapThisWay";
}