Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch brand suggestion preset generation over to inherit fields #5716

Merged
merged 2 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions build_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading