From 3be7eb6fcae6d79b3e95507c50af50b216193e6f Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Wed, 4 Dec 2024 13:33:33 +0100 Subject: [PATCH] restrict direction cones to matching parent ways, fixes #9013 for certain vertex features, only look at matching parent ways when determining where to draw direction cones: * highway related points (e.g. highway=stop/yield/etc., traffic calming, cycleway=asl, traffic signs, barriers): only look at parent ways with highway=* * railway related points (e.g. railway=milestone): only look at parent ways with railway=* * waterway related points (e.g. waterway=milestone): only look at parent ways with waterway=* see also #5634 --- CHANGELOG.md | 2 ++ modules/osm/node.js | 26 +++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da0c2a49c..c036640b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ _Breaking developer changes, which may affect downstream projects or sites that #### :white_check_mark: Validation #### :bug: Bugfixes * Fix unsolvable validator error triggered by regional presets ([#10459]) +* Render highway direction cones only on matching parent ways ([#9013]) #### :earth_asia: Localization * Update Sinitic languages in the Multilingual Names field ([#10488], thanks [@winstonsung]) * Update the list of languages in the Wikipedia field ([#10489]) @@ -54,6 +55,7 @@ _Breaking developer changes, which may affect downstream projects or sites that #### :hammer: Development * Migrate unit tests from karma to vitest ([#10452]) +[#9013]: https://github.com/openstreetmap/iD/issues/9013 [#10452]: https://github.com/openstreetmap/iD/pull/10452 [#10459]: https://github.com/openstreetmap/iD/pull/10459 [#10488]: https://github.com/openstreetmap/iD/pull/10488 diff --git a/modules/osm/node.js b/modules/osm/node.js index b1b73e434..a6f07e808 100644 --- a/modules/osm/node.js +++ b/modules/osm/node.js @@ -114,19 +114,23 @@ Object.assign(osmNode.prototype, { if (!lookForward && !lookBackward) return; var nodeIds = {}; - resolver.parentWays(this).forEach(function(parent) { - var nodes = parent.nodes; - for (i = 0; i < nodes.length; i++) { - if (nodes[i] === this.id) { // match current entity - if (lookForward && i > 0) { - nodeIds[nodes[i - 1]] = true; // look back to prev node - } - if (lookBackward && i < nodes.length - 1) { - nodeIds[nodes[i + 1]] = true; // look ahead to next node + resolver.parentWays(this) + .filter(p => (this.tags.highway || this.tags.traffic_sign || this.tags.traffic_calming || this.tags.barrier || this.tags.cycleway) ? p.tags.highway : true) + .filter(p => (this.tags.railway) ? p.tags.railway : true) + .filter(p => (this.tags.waterway) ? p.tags.waterway : true) + .forEach(function(parent) { + var nodes = parent.nodes; + for (i = 0; i < nodes.length; i++) { + if (nodes[i] === this.id) { // match current entity + if (lookForward && i > 0) { + nodeIds[nodes[i - 1]] = true; // look back to prev node + } + if (lookBackward && i < nodes.length - 1) { + nodeIds[nodes[i + 1]] = true; // look ahead to next node + } } } - } - }, this); + }, this); Object.keys(nodeIds).forEach(function(nodeId) { // +90 because geoAngle returns angle from X axis, not Y (north)