From 4829f8a1dabf833b8b11fa707280bf5b1b707ab2 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Fri, 16 Feb 2024 14:32:03 +0100 Subject: [PATCH] drop *:wikipedia tags when selecting a NSI-based, fixes #9103 --- CHANGELOG.md | 2 ++ modules/presets/preset.js | 3 +++ modules/services/nsi.js | 15 +++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c27256faf..257447b55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,8 +58,10 @@ _Breaking developer changes, which may affect downstream projects or sites that #### :rocket: Presets * Don't consider traffic_calming features as areas ([id-tagging-schema#1076]) * Add rendering style for roller coaster tracks and supports ([#9891], thanks [@mangerlahn]) +* Drop `*:wikipedia` tags when switching to a new NSI-based preset which specifies a corresponding `*:wikidata` tag ([#9103]) #### :hammer: Development +[#9103]: https://github.com/openstreetmap/iD/issues/9103 [#9424]: https://github.com/openstreetmap/iD/pull/9424 [#9422]: https://github.com/openstreetmap/iD/issues/9422 [#9876]: https://github.com/openstreetmap/iD/issues/9876 diff --git a/modules/presets/preset.js b/modules/presets/preset.js index 13c1f487c..27c6d0ff5 100644 --- a/modules/presets/preset.js +++ b/modules/presets/preset.js @@ -248,6 +248,9 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) { if (_this.tags[k] || !tags[k]) { tags[k] = 'yes'; } + } else if (addTags[k] === '') { + // empty string equates to a tag which should be removed + delete tags[k]; } else { tags[k] = addTags[k]; } diff --git a/modules/services/nsi.js b/modules/services/nsi.js index 8664a364b..81b0c9351 100644 --- a/modules/services/nsi.js +++ b/modules/services/nsi.js @@ -82,6 +82,21 @@ function loadNsiPresets() { // The preset json schema doesn't include it, but the iD code still uses it Object.values(vals[0].presets).forEach(preset => preset.suggestion = true); + // nsi does not specify *:wikipedia (anymore): + // clean up previous values to prevent that the wikidata/wikipedia information + // is going to be out of sync, see #9103 + Object.values(vals[0].presets).forEach(preset => { + if (preset.tags['brand:wikidata']) { + preset.addTags['brand:wikipedia'] = ''; + } + if (preset.tags['operator:wikidata']) { + preset.addTags['operator:wikipedia'] = ''; + } + if (preset.tags['network:wikidata']) { + preset.addTags['network:wikipedia'] = ''; + } + }); + presetManager.merge({ presets: vals[0].presets, featureCollection: vals[1]