Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Clarify that commented code is for local testing #128

Merged
merged 2 commits into from
Jun 11, 2022
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
308 changes: 155 additions & 153 deletions global.yaml
Original file line number Diff line number Diff line change
@@ -1,153 +1,155 @@
global:
api_key: false # intended to be overwritten by StreetComplete
language: false # intended to be overwritten by StreetComplete
text_font_family: 'Roboto'
text_stroke_color: 'white'
text_water_color: '#fff'
text_stroke: { color: global.text_stroke_color, width: 2.5px }
text_places_stroke: { color: global.text_stroke_color, width: 2.5px }
text_countries_stroke: { color: global.text_stroke_color, width: 2.5px }
text_water_stroke: { color: global.water_color, width: 2.5px }
text_fill_color: '#124'
text_size_scaling: 1 # intended to be overwritten by StreetComplete
text_size: |
function() {
var size = 13;
if ($zoom >= 18 && $zoom < 19) {
size = 15;
} else if ($zoom >= 19) {
size = 17;
}
return (size * global.text_size_scaling) + "px";
}

# The following colors are in most cases overwritten
# ones that are used are defined in streetcomplete-light-style.yaml
# and streetcomplete-dark-style.yaml files
railway_color: '#99a'
road_color: '#fff'
highway_color: '#fa8'
highway_outline_color: global.road_outline_color
road_outline_color: '#a88'
path_color: global.road_color
path_outline_color: '#ca9'
square_color: global.road_color
square_outline_color: global.path_outline_color

earth_color: '#f3eacc'
water_color: '#68d'
green_color: '#c6ddaa'
forest_color: '#a8c884'
town_color: '#f3dacd'

building_color: rgb(204,214,238)
building_outline_color: rgb(185,195,217)

boundary_color: '#e39'

oneway_arrow_color: '#888'
barrier_color: '#888'
roundabout_color: global.road_outline_color

tunnel_color: [1., 1., 1., 0.2]

name_source: |
function() {
var userLang = global.language;
if (userLang) {
// Preference #1: Take name in own language (e.g. name:en used in Egypt a lot)
var nameInUserLang = feature['name_'+userLang];
if (nameInUserLang) return nameInUserLang;

// find language of name of element
var elementLang;
var name = feature["name"];
var localizedNameRegex = /^name_([a-z]{2,3})$/;
var keys = Object.keys(feature);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
if (key == "name") continue;
if (name == feature[key]) {
var match = key.match(localizedNameRegex);
if (match && match.length == 2) {
elementLang = match[1];
break;
}
}
}

if (elementLang && elementLang != userLang) {
var userScript = global.language_script;

// Preference #2 and #3 are not available in JawgMaps

// Preference #2: Take international name (e.g. used in Greece a lot)
//var internationalName = feature["int_name"];
//if (internationalName) return internationalName;

// Preference #3: Take name that is readable in user's script, usually romanized name. Used in Japan a lot
//var nameInUserScript = feature["name_" + elementLang + "-" + userScript];
//if (nameInUserScript) return nameInUserScript;
// NOTE: more correct would be to check elementScript != userScript but the elementScript is hard to find out in pure JavaScript

// Preference #4: Take name in English (cause it's kind of the "international") language
if (userLang != "en") {
var nameInEnglish = feature["name_en"];
if (nameInEnglish) return nameInEnglish;
}

// Preference #5: Take name that is readable in Latin (cause it's kind of "international") script
if (userScript != "Latn") {
var nameInLatinScript = feature["name_ltn"];
if (nameInLatinScript) return nameInLatinScript;
}

// Preference #6: Take name of any other language whose script is the same as the user's script (e.g. French signs in Laos)
// ... not implementable without a mapping of language code to script

// Preference #7: Take name of any other language whose script is in Latin (cause it's kind of "international") script (e.g. French signs in Laos)
// ... not implementable without a mapping of language code to script
}
}

return feature["name"];
}

suggested_min_zoom: |
function() {
return feature.min_zoom <= $zoom
}

sort_rank: function() { return feature.sort_rank; }

scene:
animated: false
background:
color: global.earth_color

camera:
type: perspective
max_tilt: 40
fov: 80

lights:
cameralight:
type: point
diffuse: 0.3
origin: camera
ambient: 0.7

sources:
jawg:
type: MVT
url: https://tile.jawg.io/streets-v2/{z}/{x}/{y}.pbf
max_zoom: 16
url_params:
access-token: global.api_key

textures:
oneway-arrow:
# url: images/[email protected]
url: https://raw.githubusercontent.com/streetcomplete/streetcomplete-mapstyle/jawg/images/[email protected]
filtering: mipmap
density: 5
global:
api_key: false # intended to be overwritten by StreetComplete
language: false # intended to be overwritten by StreetComplete
text_font_family: 'Roboto'
text_stroke_color: 'white'
text_water_color: '#fff'
text_stroke: { color: global.text_stroke_color, width: 2.5px }
text_places_stroke: { color: global.text_stroke_color, width: 2.5px }
text_countries_stroke: { color: global.text_stroke_color, width: 2.5px }
text_water_stroke: { color: global.water_color, width: 2.5px }
text_fill_color: '#124'
text_size_scaling: 1 # intended to be overwritten by StreetComplete
text_size: |
function() {
var size = 13;
if ($zoom >= 18 && $zoom < 19) {
size = 15;
} else if ($zoom >= 19) {
size = 17;
}
return (size * global.text_size_scaling) + "px";
}

# The following colors are in most cases overwritten
# ones that are used are defined in streetcomplete-light-style.yaml
# and streetcomplete-dark-style.yaml files
railway_color: '#99a'
road_color: '#fff'
highway_color: '#fa8'
highway_outline_color: global.road_outline_color
road_outline_color: '#a88'
path_color: global.road_color
path_outline_color: '#ca9'
square_color: global.road_color
square_outline_color: global.path_outline_color

earth_color: '#f3eacc'
water_color: '#68d'
green_color: '#c6ddaa'
forest_color: '#a8c884'
town_color: '#f3dacd'

building_color: rgb(204,214,238)
building_outline_color: rgb(185,195,217)

boundary_color: '#e39'

oneway_arrow_color: '#888'
barrier_color: '#888'
roundabout_color: global.road_outline_color

tunnel_color: [1., 1., 1., 0.2]

name_source: |
function() {
var userLang = global.language;
if (userLang) {
// Preference #1: Take name in own language (e.g. name:en used in Egypt a lot)
var nameInUserLang = feature['name_'+userLang];
if (nameInUserLang) return nameInUserLang;

// find language of name of element
var elementLang;
var name = feature["name"];
var localizedNameRegex = /^name_([a-z]{2,3})$/;
var keys = Object.keys(feature);
for (var i = 0; i < keys.length; ++i) {
var key = keys[i];
if (key == "name") continue;
if (name == feature[key]) {
var match = key.match(localizedNameRegex);
if (match && match.length == 2) {
elementLang = match[1];
break;
}
}
}

if (elementLang && elementLang != userLang) {
var userScript = global.language_script;

// Preference #2 and #3 are not available in JawgMaps

// Preference #2: Take international name (e.g. used in Greece a lot)
//var internationalName = feature["int_name"];
//if (internationalName) return internationalName;

// Preference #3: Take name that is readable in user's script, usually romanized name. Used in Japan a lot
//var nameInUserScript = feature["name_" + elementLang + "-" + userScript];
//if (nameInUserScript) return nameInUserScript;
// NOTE: more correct would be to check elementScript != userScript but the elementScript is hard to find out in pure JavaScript

// Preference #4: Take name in English (cause it's kind of the "international") language
if (userLang != "en") {
var nameInEnglish = feature["name_en"];
if (nameInEnglish) return nameInEnglish;
}

// Preference #5: Take name that is readable in Latin (cause it's kind of "international") script
if (userScript != "Latn") {
var nameInLatinScript = feature["name_ltn"];
if (nameInLatinScript) return nameInLatinScript;
}

// Preference #6: Take name of any other language whose script is the same as the user's script (e.g. French signs in Laos)
// ... not implementable without a mapping of language code to script

// Preference #7: Take name of any other language whose script is in Latin (cause it's kind of "international") script (e.g. French signs in Laos)
// ... not implementable without a mapping of language code to script
}
}

return feature["name"];
}

suggested_min_zoom: |
function() {
return feature.min_zoom <= $zoom
}

sort_rank: function() { return feature.sort_rank; }

scene:
animated: false
background:
color: global.earth_color

camera:
type: perspective
max_tilt: 40
fov: 80

lights:
cameralight:
type: point
diffuse: 0.3
origin: camera
ambient: 0.7

sources:
jawg:
type: MVT
url: https://tile.jawg.io/streets-v2/{z}/{x}/{y}.pbf
max_zoom: 16
url_params:
access-token: global.api_key

textures:
oneway-arrow:
# for online testing (e.g. Tangram Play):
url: https://raw.githubusercontent.com/streetcomplete/streetcomplete-mapstyle/jawg/images/[email protected]
# for local testing and the final release (e.g. using an emulator):
#url: images/[email protected]
filtering: mipmap
density: 5
Loading