Handle more "hybrid" area+line tags as area-by-default, fixes #8985

This commit is contained in:
Martin Raifer
2022-02-16 15:38:27 +01:00
parent 5b905bec1a
commit 04a07092d2
4 changed files with 45 additions and 27 deletions
+2
View File
@@ -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 <kbd>⌥</kbd><kbd>W</kbd> 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
+26 -17
View File
@@ -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;
}
+9 -2
View File
@@ -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] || {};
+8 -8
View File
@@ -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) {