From 742147c62b11b72b8b0668aa791d1ec20a91125d Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Tue, 29 Jan 2019 13:31:02 -0500 Subject: [PATCH] Don't validate water areas or specific highway, waterway, or railway features --- data/core.yaml | 12 +++++----- dist/locales/en.json | 12 +++++----- modules/validations/crossing_ways.js | 35 +++++++++++++++++----------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index b8e9fa945..713908a55 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -1176,19 +1176,19 @@ en: tip: Highways crossing buildings should use bridges, tunnels, coverings, or entrances. building-railway: tip: Railways crossing buildings should use bridges or tunnels. - building-water: + building-waterway: tip: Waterways crossing buildings should use tunnels or different layers. highway-highway: tip: Crossing highways should use bridges, tunnels, or intersections. highway-railway: tip: Highways crossing railways should use bridges, tunnels, or level crossings. - highway-water: - tip: Highways crossing water should use bridges, tunnels, or fords. + highway-waterway: + tip: Highways crossing waterways should use bridges, tunnels, or fords. railway-railway: tip: Crossing railways should be connected or use bridges or tunnels. - railway-water: - tip: Railways crossing water should use bridges or tunnels. - water-water: + railway-waterway: + tip: Railways crossing waterways should use bridges or tunnels. + waterway-waterway: tip: Crossing waterways should be connected or use tunnels. tunnel-tunnel: tip: Crossing tunnels should use different layers. diff --git a/dist/locales/en.json b/dist/locales/en.json index 5734d28c9..1cf509a98 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -1430,7 +1430,7 @@ "building-railway": { "tip": "Railways crossing buildings should use bridges or tunnels." }, - "building-water": { + "building-waterway": { "tip": "Waterways crossing buildings should use tunnels or different layers." }, "highway-highway": { @@ -1439,16 +1439,16 @@ "highway-railway": { "tip": "Highways crossing railways should use bridges, tunnels, or level crossings." }, - "highway-water": { - "tip": "Highways crossing water should use bridges, tunnels, or fords." + "highway-waterway": { + "tip": "Highways crossing waterways should use bridges, tunnels, or fords." }, "railway-railway": { "tip": "Crossing railways should be connected or use bridges or tunnels." }, - "railway-water": { - "tip": "Railways crossing water should use bridges or tunnels." + "railway-waterway": { + "tip": "Railways crossing waterways should use bridges or tunnels." }, - "water-water": { + "waterway-waterway": { "tip": "Crossing waterways should be connected or use tunnels." }, "tunnel-tunnel": { diff --git a/modules/validations/crossing_ways.js b/modules/validations/crossing_ways.js index a83e7a307..139731de3 100644 --- a/modules/validations/crossing_ways.js +++ b/modules/validations/crossing_ways.js @@ -71,11 +71,17 @@ export function validationHighwayCrossingOtherWays(context) { return getFeatureTypeForTags(tags); } + // only validate certain waterway features + var waterways = new Set(['canal', 'ditch', 'drain', 'river', 'stream']); + // ignore certain highway and railway features + var ignoredHighways = new Set(['rest_area', 'services']); + var ignoredRailways = new Set(['train_wash']); + function getFeatureTypeForTags(tags) { - if (hasTag(tags, 'highway')) return 'highway'; if (hasTag(tags, 'building')) return 'building'; - if (hasTag(tags, 'railway')) return 'railway'; - if (hasTag(tags, 'waterway') || tags.natural === 'water') return 'water'; + if (hasTag(tags, 'highway') && !ignoredHighways.has(tags.highway)) return 'highway'; + if (hasTag(tags, 'railway') && !ignoredRailways.has(tags.railway)) return 'railway'; + if (hasTag(tags, 'waterway') && waterways.has(tags.waterway)) return 'waterway'; return null; } @@ -107,8 +113,8 @@ export function validationHighwayCrossingOtherWays(context) { if (hasTag(tags1, 'tunnel') && !hasTag(tags2, 'tunnel')) return true; if (!hasTag(tags1, 'tunnel') && hasTag(tags2, 'tunnel')) return true; } - if ((featureType1 === 'highway' && featureType2 === 'water') || - (featureType1 === 'railway' && featureType2 === 'water')) { + if ((featureType1 === 'highway' && featureType2 === 'waterway') || + (featureType1 === 'railway' && featureType2 === 'waterway')) { // Legit cases: // (1) highway/railway is on a bridge // (2) only one of the two ways is in a tunnel @@ -125,7 +131,7 @@ export function validationHighwayCrossingOtherWays(context) { // (2) highway/railway has a covered tag if (hasTag(tags1, 'bridge') || hasTag(tags1, 'tunnel') || hasTag(tags1, 'covered')) return true; } - if (featureType1 === 'water' && featureType2 === 'water') { + if (featureType1 === 'waterway' && featureType2 === 'waterway') { // Legit cases: // (1) only one of the water is in a tunnel // (2) both are in tunnels but on differnt layers @@ -133,7 +139,7 @@ export function validationHighwayCrossingOtherWays(context) { if (!hasTag(tags1, 'tunnel') && hasTag(tags2, 'tunnel')) return true; if (hasTag(tags1, 'tunnel') && hasTag(tags2, 'tunnel') && tags1.layer !== tags2.layer) return true; } - if (featureType1 === 'water' && featureType2 === 'building') { + if (featureType1 === 'waterway' && featureType2 === 'building') { // Legit cases: // (1) water is in a tunnel // (2) water has a covered tag @@ -151,13 +157,13 @@ export function validationHighwayCrossingOtherWays(context) { var featureType2 = getFeatureTypeForTags(entity2.tags); if (featureType1 === featureType2) { if (featureType1 === 'highway') return true; - if (featureType1 === 'water') return true; + if (featureType1 === 'waterway') return true; if (featureType1 === 'railway') return true; } else { var featureTypes = new Set([featureType1, featureType2]); if (featureTypes.has('highway')) { - if (featureTypes.has('water')) { - // do not allow adding fords on structures + if (featureTypes.has('waterway')) { + // do not allow fords on structures if (hasTag(entity1.tags, 'tunnel') && hasTag(entity2.tags, 'tunnel')) return false; if (hasTag(entity1.tags, 'bridge') && hasTag(entity2.tags, 'bridge')) return false; return true; @@ -226,7 +232,10 @@ export function validationHighwayCrossingOtherWays(context) { } if (entity.type === 'way') { return entity; - } else if (entity.type === 'relation' && entity.tags.type === 'multipolygon') { + } else if (entity.type === 'relation' && + entity.tags.type === 'multipolygon' && + // only check multipolygons if they are buildings + hasTag(entity.tags, 'building')) { return _map(entity.members, function(member) { if (context.hasEntity(member.id)) { var entity = context.entity(member.id); @@ -250,9 +259,9 @@ export function validationHighwayCrossingOtherWays(context) { var type2 = getFeatureTypeForCrossingCheck(entity2, graph); if (type1 === type2) { return utilDisplayLabel(entity1, context) > utilDisplayLabel(entity2, context); - } else if (type1 === 'water') { + } else if (type1 === 'waterway') { return true; - } else if (type2 === 'water') { + } else if (type2 === 'waterway') { return false; } return type1 < type2;