From afce723b74465ee8b188bb7f6c4f99aa898782a9 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Thu, 17 Apr 2025 12:47:10 +0200 Subject: [PATCH] only consider proper lifecycle tagging in "past/futures" layer (#10943) fixes #10186, where features with e.g. `intermittent=yes` were incorrectly sorted into the past/futures layer now only features with correct tagging are included in the "past/futures" layer: * either the "legacy" lifecycle tagging (e.g. `highway=construction`) * or proper lifecycle prefix tags (e.g. `disused:shop=convenience`) --- CHANGELOG.md | 2 ++ modules/renderer/features.js | 10 ++++++---- test/spec/renderer/features.js | 10 +++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1bff6662..0421b75b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Show unchanged tags of a [deprecation rule](https://github.com/ideditor/schema-builder?tab=readme-ov-file#deprecations) explicitly in the validation warning ([#10104]) #### :bug: Bugfixes * Fix removed tooltips from re-appearing when using keyboard navigation ([#9873]) +* Only consider feature with proper lifecycle tags in "past/futures" layer ([#10943]) #### :earth_asia: Localization #### :hourglass: Performance #### :mortar_board: Walkthrough / Help @@ -55,6 +56,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#9873]: https://github.com/openstreetmap/iD/issues/9873 [#10104]: https://github.com/openstreetmap/iD/issues/10104 +[#10943]: https://github.com/openstreetmap/iD/pull/10943 [#10946]: https://github.com/openstreetmap/iD/issues/10946 [#10959]: https://github.com/openstreetmap/iD/issues/10959 [#10966]: https://github.com/openstreetmap/iD/issues/10966 diff --git a/modules/renderer/features.js b/modules/renderer/features.js index baa069edc..0263f3ad2 100644 --- a/modules/renderer/features.js +++ b/modules/renderer/features.js @@ -223,10 +223,12 @@ export function rendererFeatures(context) { const keys = Object.keys(tags); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const s = key.split(':')[0]; - if (osmLifecyclePrefixes[s] || osmLifecyclePrefixes[tags[key]]) return true; + for (const key of keys) { + if (osmLifecyclePrefixes[tags[key]]) return true; // legacy tagging, e.g. `highway=construction` + const parts = key.split(':'); + if (parts.length === 1) continue; + const prefix = parts[0]; + if (osmLifecyclePrefixes[prefix]) return true; // lifecycle tagging, e.g. `demolished:building=yes` } return false; }); diff --git a/test/spec/renderer/features.js b/test/spec/renderer/features.js index addbe2e7c..7ee85a739 100644 --- a/test/spec/renderer/features.js +++ b/test/spec/renderer/features.js @@ -58,7 +58,7 @@ describe('iD.rendererFeatures', function() { iD.osmNode({id: 'point_dock', tags: {waterway: 'dock'}, version: 1}), iD.osmNode({id: 'point_rail_station', tags: {railway: 'station'}, version: 1}), iD.osmNode({id: 'point_generator', tags: {power: 'generator'}, version: 1}), - iD.osmNode({id: 'point_old_rail_station', tags: {railway: 'station', disused: 'yes'}, version: 1}), + iD.osmNode({id: 'point_old_rail_station', tags: {'disused:railway': 'station'}, version: 1}), iD.osmWay({id: 'motorway', tags: {highway: 'motorway'}, version: 1}), iD.osmWay({id: 'building_yes', tags: {area: 'yes', amenity: 'school', building: 'yes'}, version: 1}), iD.osmWay({id: 'boundary', tags: {boundary: 'administrative'}, version: 1}), @@ -80,7 +80,7 @@ describe('iD.rendererFeatures', function() { expect(stats.paths).to.eql(0); expect(stats.points).to.eql(5); expect(stats.power).to.eql(1); - expect(stats.rail).to.eql(2); + expect(stats.rail).to.eql(1); expect(stats.water).to.eql(1); }); }); @@ -92,7 +92,7 @@ describe('iD.rendererFeatures', function() { iD.osmNode({id: 'point_dock', tags: {waterway: 'dock'}, version: 1}), iD.osmNode({id: 'point_rail_station', tags: {railway: 'station'}, version: 1}), iD.osmNode({id: 'point_generator', tags: {power: 'generator'}, version: 1}), - iD.osmNode({id: 'point_old_rail_station', tags: {railway: 'station', disused: 'yes'}, version: 1}), + iD.osmNode({id: 'point_old_rail_station', tags: {'disused:railway': 'station'}, version: 1}), // Traffic Roads iD.osmWay({id: 'motorway', tags: {highway: 'motorway'}, version: 1}), @@ -472,12 +472,12 @@ describe('iD.rendererFeatures', function() { features.gatherStats(all, graph, dimensions); doMatch('rail', [ - 'point_rail_station', 'point_old_rail_station', - 'railway', 'rail_landuse', 'rail_disused' + 'point_rail_station', 'railway', 'rail_landuse', 'rail_disused' ]); dontMatch('rail', [ 'rail_streetcar', 'rail_trail', // because rail also used as highway + 'point_old_rail_station', 'point_bar', 'motorway', 'service', 'path', 'building_yes', 'forest', 'boundary', 'boundary_member', 'water', 'power_line', 'motorway_construction', 'fence'