From 1bfb9ac0c01fd0c57724c9057c26b306c5e56cf7 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 16 Jan 2019 10:02:05 -0500 Subject: [PATCH] Updated almost junction issue message and tooltip to be better aligned with other issues Added a quick fix for setting the almost junction node as noexit --- data/core.yaml | 7 ++- dist/locales/en.json | 8 +++- .../validations/highway_almost_junction.js | 45 +++++++++++++++---- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index d6c9025b6..249312621 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -1195,8 +1195,8 @@ en: message: Crossing ways without connection tooltip: "Roads are crossing other roads, buildings, railroads, or waterways without connection nodes or a bridge tag." highway_almost_junction: - message: Almost junction - tooltip: "This node is very close but not connected to way {wid}." + message: "{highway} is very close but not connected to {highway2}." + tooltip: "Intersecting highways must share a junction vertex." fix: delete_feature: title: Delete this feature @@ -1207,6 +1207,9 @@ en: add_connection_vertex: title: Connect the features undo_redo: Connected crossing features. + tag_as_disconnected: + title: Tag as disconnected + undo_redo: Tagged nearby features as disconnected. intro: done: done ok: OK diff --git a/dist/locales/en.json b/dist/locales/en.json index 5e07077ae..2f5f4dca2 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -1456,8 +1456,8 @@ "tooltip": "Roads are crossing other roads, buildings, railroads, or waterways without connection nodes or a bridge tag." }, "highway_almost_junction": { - "message": "Almost junction", - "tooltip": "This node is very close but not connected to way {wid}." + "message": "{highway} is very close but not connected to {highway2}.", + "tooltip": "Intersecting highways must share a junction vertex." }, "fix": { "delete_feature": { @@ -1472,6 +1472,10 @@ "add_connection_vertex": { "title": "Connect the features", "undo_redo": "Connected crossing features." + }, + "tag_as_disconnected": { + "title": "Tag as disconnected", + "undo_redo": "Tagged nearby features as disconnected." } } }, diff --git a/modules/validations/highway_almost_junction.js b/modules/validations/highway_almost_junction.js index d6a0bab6a..6e8836d05 100644 --- a/modules/validations/highway_almost_junction.js +++ b/modules/validations/highway_almost_junction.js @@ -6,22 +6,29 @@ import { geoSphericalDistance, geoVecInterp, } from '../geo'; -import { set as d3_set } from 'd3-collection'; +import { + utilDisplayLabel +} from '../util'; +import { actionChangeTags } from '../actions'; import { t } from '../util/locale'; import { ValidationIssueType, ValidationIssueSeverity, validationIssue, + validationIssueFix } from './validation_issue'; /** * Look for roads that can be connected to other roads with a short extension */ -export function validationHighwayAlmostJunction() { +export function validationHighwayAlmostJunction(context) { function isHighway(entity) { - return entity.type === 'way' && entity.tags.highway; + return entity.type === 'way' && entity.tags.highway && entity.tags.highway !== 'no'; + } + function isNoexit(node) { + return node.tags.noexit && node.tags.noexit === 'yes'; } function findConnectableEndNodesByExtension(way, graph, tree) { @@ -32,7 +39,7 @@ export function validationHighwayAlmostJunction() { nodeLast = graph.entity(nidLast); if (nidFirst === nidLast) return results; - if (!nodeFirst.tags.noexit && graph.parentWays(nodeFirst).length === 1) { + if (!isNoexit(nodeFirst) && graph.parentWays(nodeFirst).length === 1) { var widNearFirst = canConnectByExtend(way, 0, graph, tree); if (widNearFirst !== null) { results.push({ @@ -41,7 +48,7 @@ export function validationHighwayAlmostJunction() { }); } } - if (!nodeLast.tags.noexit && graph.parentWays(nodeLast).length === 1) { + if (!isNoexit(nodeLast) && graph.parentWays(nodeLast).length === 1) { var widNearLast = canConnectByExtend(way, way.nodes.length - 1, graph, tree); if (widNearLast !== null) { results.push({ @@ -96,13 +103,35 @@ export function validationHighwayAlmostJunction() { if (!isHighway(edited[i])) continue; var extendableNodes = findConnectableEndNodesByExtension(edited[i], graph, tree); for (var j = 0; j < extendableNodes.length; j++) { + var endHighway = edited[i]; + var node = extendableNodes[j].node; + var edgeHighway = graph.entity(extendableNodes[j].wid); + + var fixes = []; + if (Object.keys(node.tags).length === 0) { + // node has no tags, suggest noexit fix + fixes.push(new validationIssueFix({ + title: t('issues.fix.tag_as_disconnected.title'), + action: function() { + var nodeID = this.issue.entities[1].id; + context.perform( + actionChangeTags(nodeID, {noexit: 'yes'}), + t('issues.fix.tag_as_disconnected.undo_redo') + ); + } + })); + } issues.push(new validationIssue({ type: ValidationIssueType.highway_almost_junction, severity: ValidationIssueSeverity.warning, - message: t('issues.highway_almost_junction.message'), - tooltip: t('issues.highway_almost_junction.tooltip', {wid: extendableNodes[j].wid}), - entities: [extendableNodes[j].node, graph.entity(extendableNodes[j].wid)], + message: t('issues.highway_almost_junction.message', { + highway: utilDisplayLabel(endHighway, context), + highway2: utilDisplayLabel(edgeHighway, context) + }), + tooltip: t('issues.highway_almost_junction.tooltip'), + entities: [endHighway, node, edgeHighway], coordinates: extendableNodes[j].node.loc, + fixes: fixes })); } }