name-suggestion-index
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -240,13 +240,19 @@ const colors = require('colors/safe'); | ||
let warnMissingWikipedia = []; | ||
let warnMissingTag = []; | ||
let seen = {}; | ||
Object.keys(canonical).forEach(k => { | ||
let obj = canonical[k]; | ||
let parts = k.split('|', 2); | ||
let tag = parts[0]; | ||
let name = parts[1]; | ||
// Warn if the item is uncommon (i.e. not found in keepNames) | ||
if (!keep[k]) { | ||
delete canonical[k].count; | ||
if (!canonical[k].nocount) { // suppress warning? | ||
delete obj.count; | ||
if (!obj.nocount) { // suppress warning? | ||
warnUncommon.push(k); | ||
} | ||
} else { | ||
delete canonical[k].nocount; | ||
delete obj.nocount; | ||
} | ||
@@ -260,3 +266,3 @@ | ||
// Warn if the name appears to be a duplicate | ||
let stem = stemmer(k.split('|', 2)[1]); | ||
let stem = stemmer(name); | ||
let other = seen[stem]; | ||
@@ -268,3 +274,3 @@ if (other) { | ||
suppress = true; | ||
} else if (canonical[k].nomatch && canonical[k].nomatch.indexOf(other) !== -1) { | ||
} else if (obj.nomatch && obj.nomatch.indexOf(other) !== -1) { | ||
suppress = true; | ||
@@ -280,3 +286,3 @@ } | ||
// Warn if `brand:wikidata` or `brand:wikipedia` tags are missing or look wrong.. | ||
let wd = canonical[k].tags['brand:wikidata']; | ||
let wd = obj.tags['brand:wikidata']; | ||
if (!wd) { | ||
@@ -287,3 +293,3 @@ warnMissingWikidata.push(k); | ||
} | ||
let wp = canonical[k].tags['brand:wikipedia']; | ||
let wp = obj.tags['brand:wikipedia']; | ||
if (!wp) { | ||
@@ -294,2 +300,17 @@ warnMissingWikipedia.push(k); | ||
} | ||
// Warn on other missing tags | ||
switch (tag) { | ||
case 'amenity/fast_food': | ||
case 'amenity/restaurant': | ||
if (!obj.tags.cuisine) { | ||
warnMissingTag.push([k, 'cuisine']); | ||
} | ||
break; | ||
case 'amenity/vending_machine': | ||
if (!obj.tags.vending) { | ||
warnMissingTag.push([k, 'vending']); | ||
} | ||
break; | ||
} | ||
}); | ||
@@ -306,2 +327,11 @@ | ||
if (warnMissingTag.length) { | ||
console.warn(colors.yellow('\nWarning - Missing tags for entries in `canonical.json`:')); | ||
console.warn('To resolve these, add the missing tag.'); | ||
warnMissingTag.forEach(w => console.warn( | ||
colors.yellow(' "' + w[0] + '"') + ' -> missing tag? -> ' + colors.yellow('"' + w[1] + '"') | ||
)); | ||
console.warn('total ' + warnMissingTag.length); | ||
} | ||
if (warnDuplicate.length) { | ||
@@ -363,3 +393,2 @@ console.warn(colors.yellow('\nWarning - Potential duplicate names in `canonical.json`:')); | ||
let total = Object.keys(canonical).length; | ||
@@ -366,0 +395,0 @@ let hasWd = total - warnMissingWikidata.length; |
@@ -19,6 +19,7 @@ const colors = require('colors/safe'); | ||
// Start clean | ||
shell.rm('-f', ['dist/name-suggestions.*']); | ||
shell.rm('-f', ['dist/name-suggestions.*', 'dist/taginfo.json']); | ||
buildJSON(); | ||
buildXML(); | ||
buildTaginfo(); | ||
@@ -99,1 +100,45 @@ console.timeEnd(colors.green('data built')); | ||
} | ||
function buildTaginfo() { | ||
var taginfo = { | ||
'data_format': 1, | ||
'data_url': 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/master/dist/taginfo.json', | ||
'project': { | ||
'name': 'name-suggestion-index', | ||
'description': 'Canonical common brand names for OpenStreetMap', | ||
'project_url': 'https://github.com/osmlab/name-suggestion-index', | ||
'doc_url': 'https://github.com/osmlab/name-suggestion-index/blob/master/README.md', | ||
'icon_url': 'https://raw.githubusercontent.com/mapbox/maki/master/icons/fast-food-15.svg?sanitize=true', | ||
'contact_name': 'Bryan Housel', | ||
'contact_email': 'bryan@mapbox.com' | ||
} | ||
}; | ||
let items = {}; | ||
for (let key in out) { | ||
for (let value in out[key]) { | ||
for (let name in out[key][value]) { | ||
let tags = out[key][value][name].tags; | ||
for (let k in tags) { | ||
let v = tags[k]; | ||
// skip value for most tags this project uses | ||
if (/name|brand|operator/.test(k)) { | ||
v = '*'; | ||
} | ||
let id = k + '/' + v; | ||
items[id] = { key: k } | ||
if (v !== '*') { | ||
items[id].value = v; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
taginfo.tags = Object.keys(items).sort().map(k => items[k]); | ||
fs.writeFileSync('dist/taginfo.json', stringify(taginfo, { maxLength: 100 })); | ||
} |
@@ -41,4 +41,5 @@ { | ||
"^tourism/hotel\\|(belvedere|krone|victoria)", | ||
"^shop/bakery\\|(Bäckerei\\s)?Müller", | ||
"^shop/(convenience|kiosk)\\|(bp|esso|exxon|mobil|shell)$", | ||
"^shop/pawnbroker\\|Ломбард" | ||
"^shop/frame\\|rumah\\spenduduk$" | ||
], | ||
@@ -138,3 +139,3 @@ "discardNames": [ | ||
"^indipend\\.$", | ||
"^(independent\\s)?(cng|filling|fuel|gas|lpg|petrol)(\\s(station|pump))?$", | ||
"^((drummed|independent)\\s)?(cng|filling|fuel|gas|lpg|petrol)(\\s(station|pump))?$", | ||
"^istanbul(\\skebab)?$", | ||
@@ -161,6 +162,7 @@ "^imbiss$", | ||
"^mailbox$", | ||
"^magazin", | ||
"^market$", | ||
"^mécanique$", | ||
"^mercado$", | ||
"^mini(\\s)?(abc|market|mart|mercado)", | ||
"^mini(\\s)?(abc|market|mart|mercado|pump)", | ||
"municipal", | ||
@@ -208,3 +210,3 @@ "^nails$", | ||
"^steak house$", | ||
"^store$", | ||
"^stores?$", | ||
"^(beer|convenience|corner|general|liquor|variety)(\\sstore)?$", | ||
@@ -257,3 +259,5 @@ "^stromtankstelle$", | ||
"^детский дом$", | ||
"^ломбард$", | ||
"^закусочная$", | ||
"замена масла", | ||
"^золото(й)?$", | ||
@@ -267,2 +271,4 @@ "^зоо(магазин|товары)$", | ||
"^киоск$", | ||
"^мебель$", | ||
"^меблі$", | ||
"^мороженое$", | ||
@@ -269,0 +275,0 @@ "^оптика$", |
@@ -11,2 +11,3 @@ ## Contributing | ||
* Add `brand:wikidata` and `brand:wikipedia` tags - [show me](#female_detective--add-wiki-tags) | ||
* Add missing brands - [show me](#convenience_store--add-missing-brands) | ||
@@ -452,2 +453,23 @@ ##### :no_entry_sign: Don't edit the files in `dist/` - they are generated: | ||
### :convenience_store: Add missing brands | ||
If it exists, we want to know about it! | ||
Some brands aren't mapped enough (50+ times) to automatically be added to the index so this | ||
is a valuable way to get ahead of incorrect tagging. | ||
1. Before adding a new brand, the minimum information you should know is the correct tagging required for instances of the brand (`name`, `brand` and what it is - e.g. `shop=food`). Ideally you also have `brand:wikidata` and `brand:wikipedia` tags for the brand and any other appropriate tags - e.g. `cuisine`. | ||
2. Add your new entry anywhere in `config/canonical.json` (it will be sorted alphabetically later) and using the `"tags"` key add all appropriate OSM tags. Refer to [here](#card_file_box--about-configcanonicaljson) if you're not familiar with the syntax. | ||
3. Add the `"nocount": true` key to your new entry as this will suppress the warnings that it doesn't appear often in OSM. | ||
4. If the brand only has locations in a known set of countries add the `"countryCodes": []` key to your new entry. This takes an array of [ISO 3166-1 alpha-2 country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) in lowercase (e.g. `["de", "at", "nl"]`). | ||
5. If instances of this brand are commonly mistagged add the `"match": []` key to list these. Again, refer to [here](#card_file_box--about-configcanonicaljson) for syntax. | ||
6. Run `npm run build` and resolve any [duplicate name warnings](#thinking--resolve-warnings). | ||
| ||
#### Using Overpass Turbo | ||
@@ -454,0 +476,0 @@ |
{ | ||
"name": "name-suggestion-index", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"license": "BSD-3-Clause", | ||
@@ -33,9 +33,11 @@ "repository": "osmlab/name-suggestion-index", | ||
"node-fetch": "^2.2.0", | ||
"osmium": "^0.5.7", | ||
"rollup": "^0.66.0", | ||
"rollup-plugin-json": "^3.0.0", | ||
"shelljs": "^0.8.0", | ||
"wikidata-sdk": "^5.15.0", | ||
"xmlbuilder": "^10.0.0" | ||
}, | ||
"optionalDependencies": { | ||
"osmium": "^0.5.7", | ||
"wikidata-sdk": "^5.15.0" | ||
}, | ||
"engines": { | ||
@@ -42,0 +44,0 @@ "node": ">=6.4.0" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
8915381
11
34
79127
2