From b2fc4a43c03c96b111d121ed75840fb2c1b2c41d Mon Sep 17 00:00:00 2001 From: Dimitar <19364673+Dimitar5555@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:47:19 +0300 Subject: [PATCH] Consider lifecycle prefixed tags in Future/Past features (#10228) and sharpen landuse filter --- CHANGELOG.md | 3 +++ modules/renderer/features.js | 18 ++++++++++++------ test/spec/renderer/features.js | 5 +++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13f1ca900..87c99f6cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ _Breaking developer changes, which may affect downstream projects or sites that * Fix bug which required a second button click when resolving/reopening of OSM notes ([#8994], thanks [@laigyu]) * Fix API URLs for ImproveOSM QA service ([#9993], thanks [@k-yle]) * Fix icons with inline css styles not properly being displayed on osm.org +* Properly sort map features with lifecycle prefixes in the _Past/Futures_ features ([#7582]) +* Only consider features with either `landuse`, `natural`, `amentiy` or `leisure` tag to be classified as _Landuse_ areas #### :earth_asia: Localization #### :hourglass: Performance #### :mortar_board: Walkthrough / Help @@ -60,6 +62,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Update dependencies, including `osm-community-index` to v5.7, `osm-auth` to v2.5 [#3595]: https://github.com/openstreetmap/iD/issues/3595 +[#7582]: https://github.com/openstreetmap/iD/issues/7582 [#8994]: https://github.com/openstreetmap/iD/issues/8994 [#9993]: https://github.com/openstreetmap/iD/issues/9993 [#10181]: https://github.com/openstreetmap/iD/pull/10181 diff --git a/modules/renderer/features.js b/modules/renderer/features.js index 58a65ed5b..232e4a5ce 100644 --- a/modules/renderer/features.js +++ b/modules/renderer/features.js @@ -132,7 +132,12 @@ export function rendererFeatures(context) { }); defineRule('landuse', function isLanduse(tags, geometry) { - return geometry === 'area' && + return geometry === 'area' && ( + !!tags.landuse || + !!tags.natural || + !!tags.leisure || + !!tags.amenity + ) && !_rules.buildings.filter(tags) && !_rules.building_parts.filter(tags) && !_rules.indoor.filter(tags) && @@ -188,7 +193,7 @@ export function rendererFeatures(context) { return tags['piste:type']; }); - defineRule('aerialways', function isPiste(tags) { + defineRule('aerialways', function isAerialways(tags) { return tags.aerialway && tags.aerialway !== 'yes' && tags.aerialway !== 'station'; @@ -206,11 +211,12 @@ export function rendererFeatures(context) { paths[tags.highway] ) { return false; } - var strings = Object.keys(tags); + const keys = Object.keys(tags); - for (var i = 0; i < strings.length; i++) { - var s = strings[i]; - if (osmLifecyclePrefixes[s] || osmLifecyclePrefixes[tags[s]]) return true; + 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; } return false; }); diff --git a/test/spec/renderer/features.js b/test/spec/renderer/features.js index 76752ea28..addbe2e7c 100644 --- a/test/spec/renderer/features.js +++ b/test/spec/renderer/features.js @@ -152,6 +152,7 @@ describe('iD.rendererFeatures', function() { iD.osmWay({id: 'scrub', tags: {area: 'yes', natural: 'scrub'}, version: 1}), iD.osmWay({id: 'industrial', tags: {area: 'yes', landuse: 'industrial'}, version: 1}), iD.osmWay({id: 'parkinglot', tags: {area: 'yes', amenity: 'parking', parking: 'surface'}, version: 1}), + iD.osmWay({id: 'park', tags: {area: 'yes', leisure: 'park', parking: 'surface'}, version: 1}), // Landuse Multipolygon iD.osmWay({id: 'outer', version: 1}), @@ -550,13 +551,13 @@ describe('iD.rendererFeatures', function() { }); it('hides uninteresting (e.g. untagged or "other") member ways on a hidden multipolygon relation', function() { - var outer = iD.osmWay({id: 'outer', tags: {area: 'yes', natural: 'wood'}, version: 1}); + var outer = iD.osmWay({id: 'outer', tags: {}, version: 1}); var inner1 = iD.osmWay({id: 'inner1', tags: {barrier: 'fence'}, version: 1}); var inner2 = iD.osmWay({id: 'inner2', version: 1}); var inner3 = iD.osmWay({id: 'inner3', tags: {highway: 'residential'}, version: 1}); var r = iD.osmRelation({ id: 'r', - tags: {type: 'multipolygon'}, + tags: {type: 'multipolygon', natural: 'wood'}, members: [ {id: outer.id, role: 'outer', type: 'way'}, {id: inner1.id, role: 'inner', type: 'way'},