/* {0} on a node, should be a way */
node[oneway],
node[bridge],
node[sidewalk],
node[footway],
node[man_made=embankment],
node[man_made=groyne],
node[man_made=cutline],
node[power=line],
node[cutline],
node[aerialway=cable_car],
node[aerialway=gondola],
node[aerialway=chair_lift],
node[aerialway=mixed_lift],
node[aerialway=drag_lift],
node[aerialway=t-bar],
node[aerialway=j-bar],
node[aerialway=platter],
node[aerialway=magic_carpet],
node[aerialway=rope_tow],
node[aerialway=goods],
node[aeroway=taxiway],
node[aeroway=runway],
node[railway=rail],
node[railway=narrow_gauge],
node[railway=monorail],
node[railway=preserved],
node[railway=light_rail],
node[railway=subway],
node[railway=tram],
node[railway=disused],
node[railway=abandoned],
node[waterway=river],
node[waterway=canal],
node[waterway=stream],
node[waterway=ditch],
node[waterway=drain],
node[natural=coastline],
node[natural=ridge],
node[natural=valley],
node[natural=tree_row] {
  throwWarning: tr("{0} on a node. Should be used on a way.", "{0.tag}");
  assertMatch: "node oneway=-1";
  assertNoMatch: "way oneway=-1";
  assertMatch: "node bridge=yes";
  assertMatch: "node bridge=viaduct";
}

/* {0} on a node, should be an area; see ticket #10679 */
node[landuse],
node[natural=scree],
node[natural=scrub],
node[natural=fell],
node[natural=heath],
node[natural=wood],
node[natural=grassland],
node[natural=wetland],
node[natural=water],
node[natural=mud],
node[natural=beach],
node[natural=sand],
node[natural=wood],
node[natural=bare_rock],
node[natural=glacier],
node[waterway=riverbank],
node[man_made=bridge],
node[man_made=breakwater],
node[aeroway=apron],
node[power=plant],
node[building:part],
node[source:outline] {
  throwWarning: tr("{0} on a node. Should be drawn as an area.", "{0.tag}");
}

/* {0} on a node, should be a relation; see #10252, #10769 */
node[route],
node[restriction] {
  throwWarning: tr("{0}=* on a node. Should be used in a relation", "{0.key}"); 
}

/* {0} on a way, should be a node */
way[entrance],
way[railway=subway_entrance],
way[man_made=survey_point],
way[power=transformer],
way[power=pole],
way[power=tower]!:closed,
way[amenity=vending_machine],
way[natural=peak],
way[natural=saddle],
way[natural=volcano],
way[natural=tree] {
  throwWarning: tr("{0} on a way. Should be used on a node.", "{0.tag}"); 
}

/* {0} on a way, should be a relation; see #10252 */
way[route=bus] {
  throwWarning: tr("{0} on a way. Should be used in a relation", "{0.tag}"); 
}

/* #12502 */
node[leisure=park][natural=tree] {
  throwWarning: tr("{0} together with {1} on a node. Remove {0}.", "{0.tag}", "{1.tag}");
  fixRemove: "leisure";
}
node[leisure=park][natural!=tree] {
  throwWarning: tr("{0} on a node. Should be drawn as an area.", "{0.tag}");
}

/* see ticket:#10125 */
node[source:geometry] {
  throwWarning: tr("{0} on a node", "{0.key}");
  fixChangeKey: "source:geometry => source:position";
}

/* Building inside building (spatial test) */
*[building][building!~/no|entrance/][any(tag("layer"),"0") = any(parent_tag("layer"),"0")] ∈
*[building][building!~/no|entrance/] {
  throwWarning: tr("Building inside building");
}

/* Overlapping areas (spatial test) */
area[natural =~ /^(water|wetland|coastline)$/], area[landuse=reservoir] {
  set water_area;
}

/* area:closed:areaStyle.water_area ⧉ area:closed:areaStyle.water_area -- does not work for now -- see ticket#10215 */
area:closed:areaStyle[natural =~ /^(water|wetland|coastline)$/] ⧉ area:closed:areaStyle.water_area,
area:closed:areaStyle[landuse=reservoir]                        ⧉ area:closed:areaStyle.water_area {
  throwWarning: tr("Overlapping Water Areas");
}

area:closed:areaStyle ⧉ area:closed:areaStyle {
  throwOther: tr("Overlapping Areas");
}

/* see ticket #9311 */
node[amenity=parking]["capacity:disabled" !~ /^(yes|[0-9]+)$/] ∈ *[amenity=parking] {
  throwWarning: tr("{0} inside {1}", "amenity=parking", "amenity=parking");
}

/* see ticket #9556 */
area:closed:areaStyle[tag("natural") = parent_tag("natural")] ⧉ area:closed:areaStyle[natural] {
  throwWarning: tr("Overlapping Identical Natural Areas");
}

area:closed:areaStyle[tag("landuse") = parent_tag("landuse")] ⧉ area:closed:areaStyle[landuse] {
  throwWarning: tr("Overlapping Identical Landuses");
}

/* see ticket:#9522 */
node[tag("amenity") = parent_tag("amenity")] ∈ *[amenity][amenity != parking] {
  throwWarning: tr("{0} inside {1}", concat("amenity=", tag("amenity")), concat("amenity=", tag("amenity")));
  group: tr("{0} inside {1}", "amenity", "amenity");
}
node[tag("leisure") = parent_tag("leisure")] ∈ *[leisure] {
  throwWarning: tr("{0} inside {1}", concat("leisure=", tag("leisure")), concat("leisure=", tag("leisure")));
  group: tr("{0} inside {1}", "leisure", "leisure");
}
node[tag("tourism") = parent_tag("tourism")] ∈ *[tourism] {
  throwWarning: tr("{0} inside {1}", concat("tourism=", tag("tourism")), concat("tourism=", tag("tourism")));
  group: tr("{0} inside {1}", "tourism", "tourism");
}
node[tag("shop") = parent_tag("shop")] ∈ *[shop] {
  throwWarning: tr("{0} inside {1}", concat("shop=", tag("shop")), concat("shop=", tag("shop")));
  group: tr("{0} inside {1}", "shop", "shop");
}
node[tag("power") = parent_tag("power")] ∈ *[power] {
  throwWarning: tr("{0} inside {1}", concat("power=", tag("power")), concat("power=", tag("power")));
  group: tr("{0} inside {1}", "power", "power");
}

/* isolated nodes which should be part of a way, see #10825 */
node:unconnected:in-downloaded-area[entrance],
node:unconnected:in-downloaded-area[traffic_calming],
node:unconnected:in-downloaded-area[highway=passing_place],
node:unconnected:in-downloaded-area[highway=mini_roundabout],
node:unconnected:in-downloaded-area[highway=motorway_junction],
node:unconnected:in-downloaded-area[highway=turning_loop],
node:unconnected:in-downloaded-area[highway=turning_circle],
node:unconnected:in-downloaded-area[highway=stop],
node:unconnected:in-downloaded-area[highway=give_way],
node:unconnected:in-downloaded-area[highway=traffic_signals],
node:unconnected:in-downloaded-area[highway=crossing],
node:unconnected:in-downloaded-area[crossing],
node:unconnected:in-downloaded-area[railway=crossing],
node:unconnected:in-downloaded-area[railway=level_crossing],
node:unconnected:in-downloaded-area[railway=buffer_stop],
node:unconnected:in-downloaded-area[public_transport=stop_position],
node:unconnected:in-downloaded-area[noexit],
node:unconnected:in-downloaded-area[waterway=dam],
node:unconnected:in-downloaded-area[waterway=weir],
node:unconnected:in-downloaded-area[waterway=waterfall],
node:unconnected:in-downloaded-area[amenity=ferry_terminal],
node:unconnected:in-downloaded-area[mountain_pass=yes],
node:unconnected:in-downloaded-area[barrier=gate],
node:unconnected:in-downloaded-area[barrier=lift_gate],
node:unconnected:in-downloaded-area[barrier=swing_gate],
node:unconnected:in-downloaded-area[barrier=toll_booth],
node:unconnected:in-downloaded-area[barrier=turnstile],
node:unconnected:in-downloaded-area[barrier=full-height_turnstile],
node:unconnected:in-downloaded-area[barrier=motorcycle_barrier],
node:unconnected:in-downloaded-area[barrier=rope],
node:unconnected:in-downloaded-area[barrier=sally_port],
node:unconnected:in-downloaded-area[barrier=spikes],
node:unconnected:in-downloaded-area[barrier=stile],
node:unconnected:in-downloaded-area[barrier=sump_buster],
node:unconnected:in-downloaded-area[barrier=kerb],
node:unconnected:in-downloaded-area[barrier=border_control],
node:unconnected:in-downloaded-area[barrier=bump_gate],
node:unconnected:in-downloaded-area[barrier=bus_trap],
node:unconnected:in-downloaded-area[barrier=cattle_grid],
node:unconnected:in-downloaded-area[barrier=chain],
node:unconnected:in-downloaded-area[barrier=cycle_barrier],
node:unconnected:in-downloaded-area[barrier=hampshire_gate],
node:unconnected:in-downloaded-area[barrier=height_restrictor],
node:unconnected:in-downloaded-area[barrier=debris] {
  throwWarning: tr("{0} must be connected to a way", "{2.tag}");
}

/*see #11127*/
way[railway][bridge] > node,
way[highway][bridge] > node {
  set node_in_bridge;
}
way[waterway] > node.node_in_bridge {
  throwWarning: tr("node connects waterway and bridge");
}

/*see #11128*/
way[highway] > node[tourism=information][information=guidepost] {
  set guidepost;
  throwOther: tr("{0} node connected to a highway", "{1.tag}");
}
way[highway] > node[amenity][!entrance][amenity!~/^(parking|parking_space|parking_entrance|motorcycle_parking|bicycle_parking|bus_station|car_wash|ferry_terminal)$/],
way[highway] > node[building][!entrance],
way[highway] > node[leisure][!entrance][leisure!=slipway],
way[highway] > node[office][!entrance],
way[highway] > node[shop][!entrance],
way[highway] > node[tourism][!entrance][tourism!=viewpoint]!.guidepost {
  throwWarning: tr("{0} node connected to a highway", "{0.key}");
}

way[junction=roundabout]:righthandtraffic:clockwise,
way[junction=roundabout]!:righthandtraffic:anticlockwise {
  throwWarning: tr("suspicious roundabout direction");
}

/* #12496 */
area:closed[place=islet][eval(areasize()) > 1500000] {
  throwWarning: tr("{0} on a large area", "{1.tag}");
  suggestAlternative: "place=island";
  fixAdd: "place=island";
}

area:closed[place=island][eval(areasize()) < 500000] {
  throwWarning: tr("{0} on a small area", "{1.tag}");
  suggestAlternative: "place=islet";
  fixAdd: "place=islet";
}

/* 12561 - building larger than Aalsmeer Flower Auction */
area:closed[building][eval(areasize()) > 500000] {
  throwWarning: tr("Too large building");
}

/* #12577 */
way[power=line] > node,
way[power=minor_line] > node,
way[power=cable] > node {
  set node_in_power_way;
}
way[!power][!building] > node.node_in_power_way {
  throwWarning: tr("Node connects a power line or cable with an object which is not related to the power infrastructure.");
}

/* #12646, #12992 */
way[waterway=~/^(stream|ditch|river|drain)$/]!:closed >[index=-1] node[natural!=sinkhole][natural!=cave_entrance]!:connection:in-downloaded-area { 
  throwWarning: tr("Waterway ends without a connection to another waterway or the direction of the waterway is wrong.");
}

/* #10717 */
way[natural=coastline] ∈ area[natural=water],
way[natural=coastline] ∈ area[waterway=riverbank] {
  throwError: tr("Coastline inside {1}", "{0.tag}");
}