From 43b4b4f02b1f7389ab53da2a634375bdc5379324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=E2=84=93e=20Hensel?= Date: Sat, 4 Mar 2023 06:53:10 +1300 Subject: [PATCH] render right-sided arrows for features with lifecycle prefixes (#9493) --- modules/osm/way.js | 7 ++++--- test/spec/osm/way.js | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/osm/way.js b/modules/osm/way.js index 881ad5d84..25f9f700d 100644 --- a/modules/osm/way.js +++ b/modules/osm/way.js @@ -3,7 +3,7 @@ import { geoArea as d3_geoArea } from 'd3-geo'; import { geoExtent, geoVecCross } from '../geo'; import { osmEntity } from './entity'; import { osmLanes } from './lanes'; -import { osmTagSuggestingArea, osmOneWayTags, osmRightSideIsInsideTags } from './tags'; +import { osmTagSuggestingArea, osmOneWayTags, osmRightSideIsInsideTags, osmRemoveLifecyclePrefix } from './tags'; import { utilArrayUniq } from '../util'; @@ -167,8 +167,9 @@ Object.assign(osmWay.prototype, { // i.e. the right side is the 'inside' (e.g. the right side of a // natural=cliff is lower). sidednessIdentifier: function() { - for (var key in this.tags) { - var value = this.tags[key]; + for (const realKey in this.tags) { + const value = this.tags[realKey]; + const key = osmRemoveLifecyclePrefix(realKey); if (key in osmRightSideIsInsideTags && (value in osmRightSideIsInsideTags[key])) { if (osmRightSideIsInsideTags[key][value] === true) { return key; diff --git a/test/spec/osm/way.js b/test/spec/osm/way.js index 177387d63..eb43f9deb 100644 --- a/test/spec/osm/way.js +++ b/test/spec/osm/way.js @@ -359,6 +359,7 @@ describe('iD.osmWay', function() { expect(iD.osmWay({tags: { barrier: 'guard_rail' }}).sidednessIdentifier()).to.eql('barrier'); expect(iD.osmWay({tags: { barrier: 'city_wall' }}).sidednessIdentifier()).to.eql('barrier'); expect(iD.osmWay({tags: { man_made: 'embankment' }}).sidednessIdentifier()).to.eql('man_made'); + expect(iD.osmWay({tags: { 'abandoned:barrier': 'guard_rail' }}).sidednessIdentifier()).to.eql('barrier'); }); it('returns null when tag does not have implied sidedness', function() { @@ -366,6 +367,8 @@ describe('iD.osmWay', function() { expect(iD.osmWay({tags: { barrier: 'fence' }}).sidednessIdentifier()).to.be.null; expect(iD.osmWay({tags: { man_made: 'dyke' }}).sidednessIdentifier()).to.be.null; expect(iD.osmWay({tags: { highway: 'motorway' }}).sidednessIdentifier()).to.be.null; + expect(iD.osmWay({tags: { 'demolished:highway': 'motorway' }}).sidednessIdentifier()).to.be.null; + expect(iD.osmWay({tags: { 'not:natural': 'cliff' }}).sidednessIdentifier()).to.be.null; }); });