From d9c6bd1f3974c1e70e702af9ad40eb73b2765197 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Fri, 21 Dec 2018 14:45:20 -0500 Subject: [PATCH] Added specialized issue messages for the common types of way crossing issues Fixed several linting issues involving crossing way validations --- data/core.yaml | 36 ++++++++++++++++++-- dist/locales/en.json | 46 ++++++++++++++++++++++++-- modules/validations/crossing_ways.js | 26 +++++++++++---- test/spec/validations/crossing_ways.js | 2 +- 4 files changed, 97 insertions(+), 13 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index fa52fbb34..d9a405bd3 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -883,20 +883,50 @@ en: error: error warning: warning disconnected_highway: - message: "{highway} is disconnected from other highways" + message: "{highway} is disconnected from other highways." tooltip: "Roads should be connected to other roads or building entrances." old_multipolygon: message: Multipolygon tags on outer way tooltip: "This style of multipolygon is deprecated. Please assign the tags to the parent multipolygon instead of the outer way." untagged_feature: - message: "{feature} has no tags" + message: "{feature} has no tags." tooltip: "Select a feature type that describes what this is." many_deletions: message: "You're deleting {n} features: {p} nodes, {l} lines, {a} areas, {r} relations. Are you sure you want to do this? This will delete them from the map that everyone else sees on openstreetmap.org." tag_suggests_area: - message: "The tag {tag} suggests line should be area, but it is not an area" + message: "The tag {tag} suggests line should be area, but it is not an area." deprecated_tags: message: "Deprecated tags: {tags}" + building-building_crossing: + message: "{building} intersect {building1} on the same layer." + tooltip: "Buildings should not intersect except on separate layers." + building-highway_crossing: + message: "{highway} crosses {building} without a bridge, tunnel, or entrance." + tooltip: "Highways crossing buildings should be connected with an entrance or use separate layers." + building-railway_crossing: + message: "{railway} crosses {building} without a bridge or tunnel." + tooltip: "Railways crossing buildings should use separate layers." + building-water_crossing: + message: "{water} crosses {building} without a culvert." + tooltip: "Waterways crossing buildings should use separate layers." + highway-highway_crossing: + message: "{highway} crosses {highway2} without a bridge, tunnel, or intersection." + tooltip: "Crossing highways should be connected or use separate layers." + highway-railway_crossing: + message: "{highway} crosses {railway} without a bridge, tunnel, or level crossing." + tooltip: "Highways crossing railways should be connected or use separate layers." + highway-water_crossing: + message: "{highway} crosses {water} without a bridge, tunnel, or ford." + tooltip: "Highways crossing waterways should be connected with a ford or use separate layers." + railway-railway_crossing: + message: "{railway} crosses {railway2} without a bridge, tunnel, or connection." + tooltip: "Crossing railways should be connected or use separate layers." + railway-water_crossing: + message: "{railway} crosses {water} without a bridge or tunnel." + tooltip: "Railways crossing waterways should use separate layers." + water-water_crossing: + message: "{water} crosses {water2} without a culvert or connection." + tooltip: "Crossing waterways should be connected or use separate layers." crossing_ways: message: Crossing ways without connection tooltip: "Roads are crossing other roads, buildings, railroads, or waterways without connection nodes or a bridge tag." diff --git a/dist/locales/en.json b/dist/locales/en.json index 5e1739736..337180a74 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -1053,7 +1053,7 @@ "warning": "warning" }, "disconnected_highway": { - "message": "{highway} is disconnected from other highways", + "message": "{highway} is disconnected from other highways.", "tooltip": "Roads should be connected to other roads or building entrances." }, "old_multipolygon": { @@ -1061,18 +1061,58 @@ "tooltip": "This style of multipolygon is deprecated. Please assign the tags to the parent multipolygon instead of the outer way." }, "untagged_feature": { - "message": "{feature} has no tags", + "message": "{feature} has no tags.", "tooltip": "Select a feature type that describes what this is." }, "many_deletions": { "message": "You're deleting {n} features: {p} nodes, {l} lines, {a} areas, {r} relations. Are you sure you want to do this? This will delete them from the map that everyone else sees on openstreetmap.org." }, "tag_suggests_area": { - "message": "The tag {tag} suggests line should be area, but it is not an area" + "message": "The tag {tag} suggests line should be area, but it is not an area." }, "deprecated_tags": { "message": "Deprecated tags: {tags}" }, + "building-building_crossing": { + "message": "{building} intersect {building1} on the same layer.", + "tooltip": "Buildings should not intersect except on separate layers." + }, + "building-highway_crossing": { + "message": "{highway} crosses {building} without a bridge, tunnel, or entrance.", + "tooltip": "Highways crossing buildings should be connected with an entrance or use separate layers." + }, + "building-railway_crossing": { + "message": "{railway} crosses {building} without a bridge or tunnel.", + "tooltip": "Railways crossing buildings should use separate layers." + }, + "building-water_crossing": { + "message": "{water} crosses {building} without a culvert.", + "tooltip": "Waterways crossing buildings should use separate layers." + }, + "highway-highway_crossing": { + "message": "{highway} crosses {highway2} without a bridge, tunnel, or intersection.", + "tooltip": "Crossing highways should be connected or use separate layers." + }, + "highway-railway_crossing": { + "message": "{highway} crosses {railway} without a bridge, tunnel, or level crossing.", + "tooltip": "Highways crossing railways should be connected or use separate layers." + }, + "highway-water_crossing": { + "message": "{highway} crosses {water} without a bridge, tunnel, or ford.", + "tooltip": "Highways crossing waterways should be connected with a ford or use separate layers." + }, + "railway-railway_crossing": { + "message": "{railway} crosses {railway2} without a bridge, tunnel, or connection.", + "tooltip": "Crossing railways should be connected or use separate layers." + }, + "railway-water_crossing": { + "message": "{railway} crosses {water} without a bridge or tunnel.", + "tooltip": "Railways crossing waterways should use separate layers." + }, + "water-water_crossing": { + "message": "{water} crosses {water2} without a culvert or connection.", + "tooltip": "Crossing waterways should be connected or use separate layers." + }, "crossing_ways": { "message": "Crossing ways without connection", "tooltip": "Roads are crossing other roads, buildings, railroads, or waterways without connection nodes or a bridge tag." diff --git a/modules/validations/crossing_ways.js b/modules/validations/crossing_ways.js index 1b47bdf83..28e7b2da3 100644 --- a/modules/validations/crossing_ways.js +++ b/modules/validations/crossing_ways.js @@ -1,6 +1,7 @@ import _clone from 'lodash-es/clone'; import { geoExtent, geoLineIntersection } from '../geo'; import { set as d3_set } from 'd3-collection'; +import { utilDisplayLabel } from '../util'; import { t } from '../util/locale'; import { ValidationIssueType, @@ -9,7 +10,7 @@ import { } from './validation_issue'; -export function validationHighwayCrossingOtherWays() { +export function validationHighwayCrossingOtherWays(context) { // Check if the edge going from n1 to n2 crosses (without a connection node) // any edge on way. Return the corss point if so. function findEdgeToWayCrossCoords(n1, n2, way, graph, edgePairsVisited) { @@ -45,7 +46,7 @@ export function validationHighwayCrossingOtherWays() { var parentRels = graph.parentRelations(way); for (var i = 0; i < parentRels.length; i++) { var rel = parentRels[i]; - for (k in rel.tags) { + for (var k in rel.tags) { if (!tags[k]) tags[k] = rel.tags[k]; } } @@ -171,6 +172,7 @@ export function validationHighwayCrossingOtherWays() { for (var k = 0; k < crossCoords.length; k++) { edgeCrossInfos.push({ ways: [entity, way], + featureTypes: [entFeatureType, wayFeatureType], cross_point: crossCoords[k], }); } @@ -187,13 +189,25 @@ export function validationHighwayCrossingOtherWays() { for (var i = 0; i < edited.length; i++) { var crosses = findCrossingsByWay(edited[i], graph, tree, edgePairsVisited); for (var j = 0; j < crosses.length; j++) { + var crossing = crosses[j]; + + var crossingTypeID = crossing.featureTypes.sort().join('-') + '_crossing'; + + var messageDict = {}; + messageDict[crossing.featureTypes[0]] = utilDisplayLabel(crossing.ways[0], context); + var key2 = crossing.featureTypes[1]; + if (crossing.featureTypes[0] === crossing.featureTypes[1]) { + key2 += '2'; + } + messageDict[key2] = utilDisplayLabel(crossing.ways[1], context); + issues.push(new validationIssue({ type: ValidationIssueType.crossing_ways, severity: ValidationIssueSeverity.error, - message: t('issues.crossing_ways.message'), - tooltip: t('issues.crossing_ways.tooltip'), - entities: crosses[j].ways, - coordinates: crosses[j].cross_point, + message: t('issues.'+crossingTypeID+'.message', messageDict), + tooltip: t('issues.'+crossingTypeID+'.tooltip'), + entities: crossing.ways, + coordinates: crossing.cross_point, })); } } diff --git a/test/spec/validations/crossing_ways.js b/test/spec/validations/crossing_ways.js index 4b1985b15..abad3d0fd 100644 --- a/test/spec/validations/crossing_ways.js +++ b/test/spec/validations/crossing_ways.js @@ -262,7 +262,7 @@ describe('iD.validations.crossing_ways', function () { iD.actionAddEntity(n6), iD.actionAddEntity(w2), iD.actionAddEntity(w3), - iD.actionAddEntity(r1), + iD.actionAddEntity(r1) ); }