Switch brand suggestion preset generation over to inherit fields

This also attempts to use `cuisine` and `vending` tags in the
presetID - in case a more specific preset exists for those things.

This fixes a minor annoyance where only matching `key/value`
would find the "fast food" preset instead of the "chicken fast food"
or "pizza fast food" preset.

So now Chick-fil-a has a chicken icon and Sbarro has a pizza icon. 🍕
This commit is contained in:
Bryan Housel
2019-01-15 16:02:57 -05:00
parent 20553dc977
commit 7c26816a7e
2 changed files with 1239 additions and 1221 deletions
+24 -6
View File
@@ -199,22 +199,40 @@ function suggestionsToPresets(presets) {
function addSuggestion(key, value, name) {
var presetID = key + '/' + value;
var preset = presets[presetID];
var suggestion = suggestions[key][value][name];
var presetID, preset;
// sometimes we can find a more specific preset then key/value..
if (suggestion.tags.cuisine) {
presetID = key + '/' + value + '/' + suggestion.tags.cuisine;
preset = presets[presetID];
} else if (suggestion.tags.vending) {
if (suggestion.tags.vending === 'parcel_pickup;parcel_mail_in') {
presetID = key + '/' + value + '/parcel_pickup_dropoff';
} else {
presetID = key + '/' + value + '/' + suggestion.tags.vending;
}
preset = presets[presetID];
}
// fallback to key/value
if (!preset) {
presetID = key + '/' + value;
preset = presets[presetID];
}
// still no match?
if (!preset) {
console.log('Warning: No preset "' + presetID + '" for name-suggestion "' + name + '"');
return;
}
var suggestionID = key + '/' + value + '/' + name;
var suggestion = suggestions[key][value][name];
var wikidataTag = { 'brand:wikidata': suggestion.tags['brand:wikidata'] };
var suggestionID = presetID + '/' + name;
presets[suggestionID] = {
name: name,
icon: preset.icon,
fields: preset.fields,
moreFields: preset.moreFields,
geometry: preset.geometry,
tags: _merge({}, preset.tags, wikidataTag),
addTags: suggestion.tags,
+1215 -1215
View File
File diff suppressed because it is too large Load Diff