From 2b15affb77c1b7fe1f8db8b29e905d8eb014384a Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Mon, 30 Nov 2020 12:14:20 -0500 Subject: [PATCH] Remove name-suggestion-index integration --- README.md | 4 +- package.json | 3 +- scripts/dist.js | 104 ------------------------------------------------ 3 files changed, 3 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index 66606438..94cb1b97 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ The [westnordost/osmfeatures](https://github.com/westnordost/osmfeatures) projec a component of [StreetComplete](https://github.com/westnordost/StreetComplete), makes it easier to use this data with Android or other Java platforms. -## Integrations +## Related Projects -This schema incorporates data from the [name-suggestion-index](https://github.com/osmlab/name-suggestion-index). +iD also incorporates preset data from the [name-suggestion-index](https://github.com/osmlab/name-suggestion-index). ## Contributing diff --git a/package.json b/package.json index 6ed5db66..28aa7c4d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "translations": "node scripts/translations.js" }, "devDependencies": { - "@ideditor/schema-builder": "2.0.0", - "name-suggestion-index": "4.0.2" + "@ideditor/schema-builder": "2.0.0" } } diff --git a/scripts/dist.js b/scripts/dist.js index b322c7f8..843ba5b8 100644 --- a/scripts/dist.js +++ b/scripts/dist.js @@ -1,11 +1,6 @@ -/* eslint-disable no-console */ const schemaBuilder = require('@ideditor/schema-builder'); -const nsiBrands = require('name-suggestion-index/dist/brands.json').brands; -const nsiWikidata = require('name-suggestion-index/dist/wikidata.json').wikidata; - schemaBuilder.buildDist({ - processPresets: addNsiPresets, taginfoProjectInfo: { name: 'iD Editor', description: 'Online editor for OSM data.', @@ -15,102 +10,3 @@ schemaBuilder.buildDist({ contact_email: 'q@quincylvania.com' } }); - -function addNsiPresets(presets) { - Object.keys(nsiBrands).forEach(kvnd => { - const suggestion = nsiBrands[kvnd]; - const qid = suggestion.tags['brand:wikidata']; - if (!qid || !/^Q\d+$/.test(qid)) return; // wikidata tag missing or looks wrong.. - - const parts = kvnd.split('|', 2); - const kv = parts[0]; - const name = parts[1].replace('~', ' '); - - let presetID, preset; - - // sometimes we can choose a more specific preset then key/value.. - if (suggestion.tags.cuisine) { - // cuisine can contain multiple values, so try them all in order - let cuisines = suggestion.tags.cuisine.split(';'); - for (let i = 0; i < cuisines.length; i++) { - presetID = kv + '/' + cuisines[i].trim(); - preset = presets[presetID]; - if (preset) break; // we matched one - } - - } else if (suggestion.tags.vending) { - if (suggestion.tags.vending === 'parcel_pickup;parcel_mail_in') { - presetID = kv + '/parcel_pickup_dropoff'; - } else { - presetID = kv + '/' + suggestion.tags.vending; - } - preset = presets[presetID]; - } - - // A few exceptions where the NSI tagging doesn't exactly match iD tagging.. - if (kv === 'healthcare/clinic') { - presetID = 'amenity/clinic'; - preset = presets[presetID]; - } else if (kv === 'leisure/tanning_salon') { - presetID = 'shop/beauty/tanning'; - preset = presets[presetID]; - } - - // fallback to key/value - if (!preset) { - presetID = kv; - preset = presets[presetID]; - } - - // still no match? - if (!preset) { - console.log(`Warning: No preset "${presetID}" for name-suggestion "${name}"`); - return; - } - - let suggestionID = presetID + '/' + name.replace('/', ''); - - let tags = { 'brand:wikidata': qid }; - for (let k in preset.tags) { - // prioritize suggestion tags over preset tags (for `vending`,`cuisine`, etc) - tags[k] = suggestion.tags[k] || preset.tags[k]; - } - - // Prefer a wiki commons logo sometimes.. #6361 - const preferCommons = { - Q177054: true, // Burger King - Q524757: true, // KFC - Q779845: true, // CBA - Q1205312: true, // In-N-Out - Q10443115: true // Carlings - }; - - let logoURL; - let logoURLs = nsiWikidata[qid] && nsiWikidata[qid].logos; - if (logoURLs) { - if (logoURLs.wikidata && preferCommons[qid]) { - logoURL = logoURLs.wikidata; - } else if (logoURLs.facebook) { - logoURL = logoURLs.facebook; - } else if (logoURLs.twitter) { - logoURL = logoURLs.twitter; - } else { - logoURL = logoURLs.wikidata; - } - } - - presets[suggestionID] = { - name: name, - icon: preset.icon, - imageURL: logoURL, - geometry: preset.geometry, - tags: tags, - addTags: suggestion.tags, - reference: preset.reference, - countryCodes: suggestion.countryCodes, - terms: (suggestion.matchNames || []), - matchScore: 2, - suggestion: true - }; - }); -}