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

Use partially evaluated ux_language_text_source functions #212

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
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
73 changes: 48 additions & 25 deletions bubble-wrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,56 @@ global:
#ux/ui
ux_language: false # l10n language code, trusting OSM in v0.10 tiles, fixed in v1.0 tiles
ux_language_fallback: false # l10n language code, trusting OSM in v0.10 tiles, fixed in v1.0 tiles
ux_language_text_source_fn: |
function(f) {
var language = global.ux_language ? 'name:'+global.ux_language : '';
var fallback = global.ux_language_fallback ? 'name:'+global.ux_language_fallback : '';
// replace self with evaluated global options
var func = global.ux_language_text_source_fn =
global.ux_language && global.ux_language_fallback ?
function(f) { return f[language] || f[fallback] || f['name']; } :
global.ux_language ?
function(f) { return f[language] || f['name']; } :
global.ux_language_fallback ?
function(f) { return f[fallback] || f['name']; } :
function(f) { return f['name']; };
return func(f);
}
ux_language_text_source: |
function() {
// if a ux_langauge has been defined use that, else if there is feature name in the fallback_ux_language then use that, else use the feature's default name in the local language
return (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature.name;
function() { return global.ux_language_text_source_fn(feature); }
ux_language_text_source_short_fn: |
function(f) {
var language = global.ux_language ? 'name:short:'+global.ux_language : '';
var fallback = global.ux_language_fallback ? 'name:short:'+global.ux_language_fallback : '';
var func = global.ux_language_text_source_short_fn =
global.ux_language && global.ux_language_fallback ?
function(f) { return f[language] || f[fallback] || f['name:short']; } :
global.ux_language ?
function(f) { return f[language] || f['name:short']; } :
global.ux_language_fallback ?
function(f) { return f[fallback] || f['name:short']; } :
function(f) { return f['name:short']; };
return func(f);
}
ux_language_text_source_short: |
function() {
return (global.ux_language && feature['name:short:'+global.ux_language]) || (global.ux_language_fallback && feature['name:short:'+global.ux_language_fallback]) || feature['name:short'];
}
function() { return global.ux_language_text_source_short_fn(feature); }
ux_language_text_source_short_proxy_name: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
var short = (global.ux_language && feature['name:short:'+global.ux_language]) || (global.ux_language_fallback && feature['name:short:'+global.ux_language_fallback]) || feature['name:short'];
var name = global.ux_language_text_source_fn(feature);
var short = global.ux_language_text_source_short_fn(feature);
return short ? name : '';
}
ux_language_text_source_abbreviation: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
var abbrev = (global.ux_language && feature['name:abbreviation:'+global.ux_language]) || (global.ux_language_fallback && feature['name:abbreviation:'+global.ux_language_fallback]) || feature['name:abbreviation'];
return abbrev || name;
var abbrev = (global.ux_language && feature['name:abbreviation:'+global.ux_language]) ||
(global.ux_language_fallback && feature['name:abbreviation:'+global.ux_language_fallback]) ||
feature['name:abbreviation'];
return abbrev || global.ux_language_text_source_fn(feature);
}
ux_language_text_source_iata: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
if(feature.iata) {
var name = global.ux_language_text_source_fn(feature);
if (feature.iata) {
if (name) {
return name + ' (' + feature.iata + ')';
}
Expand All @@ -41,26 +66,25 @@ global:
}
ux_language_text_source_ocean: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
var name = global.ux_language_text_source_fn(feature);
return name.split('').join(' ');
}
ux_language_text_source_sea: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
var name = global.ux_language_text_source_fn(feature);
return name.split('').join(' ');
}
ux_language_text_source_continent: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
var name = global.ux_language_text_source_fn(feature);
return name.split('').join(' ');
}
ux_language_text_source_road_ref_and_name: |
function() {
// if a ux_langauge has been defined use that, else if there is feature name in the fallback_ux_language then use that, else use the feature's default name in the local language
return (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature.name;
return global.ux_language_text_source_fn(feature);
/*
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
var name = global.ux_language_text_source_fn(feature);
if(feature.ref && name) {
return (feature.ref + ' ' + name);
} else {
Expand All @@ -70,11 +94,10 @@ global:
}
ux_language_text_source_road_ref_and_name_short: |
function() {
// if a ux_langauge has been defined use that, else if there is feature name in the fallback_ux_language then use that, else use the feature's default name in the local language
return (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature.name;
return global.ux_language_text_source_fn(feature);
/*
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
var name = global.ux_language_text_source_fn(feature);
if (feature.ref && (feature.ref.length < 6) && name) {
return feature.ref + ' ' + name;
} else {
Expand All @@ -84,17 +107,17 @@ global:
}
ux_language_text_source_piste_advanced: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
var name = global.ux_language_text_source_fn(feature);
return name ? ('◆ ' + name) : '◆';
}
ux_language_text_source_piste_expert: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
var name = global.ux_language_text_source_fn(feature);
return name ? ('◆◆ ' + name) : '◆◆';
}
ux_language_text_source_building_and_address: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
var name = global.ux_language_text_source_fn(feature);
if (name && feature.addr_housenumber) {
return name + '\n' + feature.addr_housenumber;
} else {
Expand Down