From 16f1187c04b4ee99dc73e482de1825a0e5f85658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=E2=84=93e=20Hensel?= Date: Sat, 8 Mar 2025 04:22:51 +1100 Subject: [PATCH] fix some direction cones not appearing on railway tracks (#10843) also refactored the logic for readability --- CHANGELOG.md | 2 ++ modules/osm/node.js | 5 ++--- modules/osm/tags.js | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 163edc9a4..203bacbb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,11 +42,13 @@ _Breaking developer changes, which may affect downstream projects or sites that #### :camera: Street-Level #### :white_check_mark: Validation #### :bug: Bugfixes +* fix some direction cones not appearing on railway tracks ([#10843], thanks [@k-yle]) #### :earth_asia: Localization #### :hourglass: Performance #### :mortar_board: Walkthrough / Help #### :hammer: Development +[#10843]: https://github.com/openstreetmap/iD/pull/10843 # 2.32.0 ##### 2025-03-05 diff --git a/modules/osm/node.js b/modules/osm/node.js index 5cfe01554..b8c333e59 100644 --- a/modules/osm/node.js +++ b/modules/osm/node.js @@ -1,6 +1,7 @@ import { osmEntity } from './entity'; import { geoAngle, geoExtent } from '../geo'; import { utilArrayUniq } from '../util'; +import { osmShouldRenderDirection } from './tags'; export const cardinal = { north: 0, n: 0, @@ -119,9 +120,7 @@ const prototype = { var nodeIds = {}; 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) + .filter(way => osmShouldRenderDirection(this.tags, way.tags)) .forEach(function(parent) { var nodes = parent.nodes; for (i = 0; i < nodes.length; i++) { diff --git a/modules/osm/tags.js b/modules/osm/tags.js index 4a4dadc44..a5fa59e80 100644 --- a/modules/osm/tags.js +++ b/modules/osm/tags.js @@ -306,3 +306,19 @@ export var osmMutuallyExclusiveTagPairs = [ ['addr:nostreet', 'addr:street'] ]; + +/** + * @param {Tags} vertexTags @param {Tags} wayTags + * returns true if iD should render the `direction` tag for + * this vertex+way combination. + */ +export function osmShouldRenderDirection(vertexTags, wayTags) { + if (vertexTags.highway || vertexTags.traffic_sign || vertexTags.traffic_calming || vertexTags.barrier) { + // allowed on roads and tramways + return !!(wayTags.highway || wayTags.railway); + } + if (vertexTags.railway) return !!wayTags.railway; + if (vertexTags.waterway) return !!wayTags.waterway; + if (vertexTags.cycleway === 'asl') return !!wayTags.highway; + return true; +}