diff --git a/CHANGELOG.md b/CHANGELOG.md index d13eea7c1..7ba7286ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Fix rendering of KeepRight issues ([#8963]) * Fix KeepRight warnings showing up as "Unknown" issues ([#8925]) * Fix W keyboard shortcut not working on MacOS in certain system languages / keyboard layouts (e.g. Spanish) ([#8905]) +* Render closed ways tagged as `public_transport=platform`, `waterway=dam` or `highway=elevator` as areas ([#8985]) #### :rocket: Presets * Optimize order of values in dropdowns of `access` fields ([#8945]) * Use value of `vehicle` tag as placeholder value of `access` fields for `motor_vehicle` and `bicycle` @@ -69,6 +70,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#8945]: https://github.com/openstreetmap/iD/issues/8945 [#8963]: https://github.com/openstreetmap/iD/issues/8963 [#8976]: https://github.com/openstreetmap/iD/issues/8976 +[#8985]: https://github.com/openstreetmap/iD/issues/8985 # 2.20.4 diff --git a/modules/osm/tags.js b/modules/osm/tags.js index db981db65..48e9dcffa 100644 --- a/modules/osm/tags.js +++ b/modules/osm/tags.js @@ -13,34 +13,43 @@ export function osmSetAreaKeys(value) { osmAreaKeys = value; } +// `highway` and `railway` are typically linear features, but there +// are a few exceptions that should be treated as areas, even in the +// absence of a proper `area=yes` or `areaKeys` tag.. see #4194 +export var osmAreaKeysExceptions = { + highway: { + elevator: true, + rest_area: true, + services: true + }, + public_transport: { + platform: true + }, + railway: { + platform: true, + roundhouse: true, + station: true, + traverser: true, + turntable: true, + wash: true + }, + waterway: { + dam: true + } +}; + // returns an object with the tag from `tags` that implies an area geometry, if any export function osmTagSuggestingArea(tags) { if (tags.area === 'yes') return { area: 'yes' }; if (tags.area === 'no') return null; - // `highway` and `railway` are typically linear features, but there - // are a few exceptions that should be treated as areas, even in the - // absence of a proper `area=yes` or `areaKeys` tag.. see #4194 - var lineKeys = { - highway: { - rest_area: true, - services: true - }, - railway: { - roundhouse: true, - station: true, - traverser: true, - turntable: true, - wash: true - } - }; var returnTags = {}; for (var key in tags) { if (key in osmAreaKeys && !(tags[key] in osmAreaKeys[key])) { returnTags[key] = tags[key]; return returnTags; } - if (key in lineKeys && tags[key] in lineKeys[key]) { + if (key in osmAreaKeysExceptions && tags[key] in osmAreaKeysExceptions[key]) { returnTags[key] = tags[key]; return returnTags; } diff --git a/modules/presets/index.js b/modules/presets/index.js index f57058ede..4a13a0ce7 100644 --- a/modules/presets/index.js +++ b/modules/presets/index.js @@ -298,7 +298,14 @@ export function presetIndex() { // and the subkeys form the discardlist. _this.areaKeys = () => { // The ignore list is for keys that imply lines. (We always add `area=yes` for exceptions) - const ignore = ['barrier', 'highway', 'footway', 'railway', 'junction', 'type']; + const ignore = { + barrier: true, + highway: true, + footway: true, + railway: true, + junction: true, + type: true + }; let areaKeys = {}; // ignore name-suggestion-index and deprecated presets @@ -309,7 +316,7 @@ export function presetIndex() { const keys = p.tags && Object.keys(p.tags); const key = keys && keys.length && keys[0]; // pick the first tag if (!key) return; - if (ignore.indexOf(key) !== -1) return; + if (ignore[key]) return; if (p.geometry.indexOf('area') !== -1) { // probably an area.. areaKeys[key] = areaKeys[key] || {}; diff --git a/modules/presets/preset.js b/modules/presets/preset.js index 42339e526..3f9dd1513 100644 --- a/modules/presets/preset.js +++ b/modules/presets/preset.js @@ -1,5 +1,5 @@ import { t } from '../core/localizer'; -import { osmAreaKeys } from '../osm/tags'; +import { osmAreaKeys, osmAreaKeysExceptions } from '../osm/tags'; import { utilArrayUniq, utilObjectOmit } from '../util'; import { utilSafeClassName } from '../util/util'; @@ -218,17 +218,17 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) { // Add area=yes if necessary. // This is necessary if the geometry is already an area (e.g. user drew an area) AND any of: // 1. chosen preset could be either an area or a line (`barrier=city_wall`) - // 2. chosen preset doesn't have a key in osmAreaKeys (`railway=station`) + // 2. chosen preset doesn't have a key in osmAreaKeys (`railway=station`), + // and is not an "exceptional area" tag (e.g. `waterway=dam`) if (!addTags.hasOwnProperty('area')) { delete tags.area; if (geometry === 'area') { let needsAreaTag = true; - if (_this.geometry.indexOf('line') === -1) { - for (let k in addTags) { - if (k in osmAreaKeys) { - needsAreaTag = false; - break; - } + for (let k in addTags) { + if (_this.geometry.indexOf('line') === -1 && k in osmAreaKeys + || k in osmAreaKeysExceptions && addTags[k] in osmAreaKeysExceptions[k]) { + needsAreaTag = false; + break; } } if (needsAreaTag) {