Add some IDs and validation on IDS

This commit is contained in:
pietervdvn 2021-09-26 18:15:21 +02:00
parent 4cb09ba8e7
commit 699e609fd7
6 changed files with 20 additions and 285 deletions

View file

@ -8,7 +8,7 @@ export interface TagRenderingConfigJson {
/**
* The id of the tagrendering, should be an unique string.
* Used to keep the translations in sync
* Used to keep the translations in sync. Only used in the tagRenderings-array of a layerConfig, not requered otherwise
*/
id?: string,

View file

@ -275,7 +275,14 @@ export default class LayerConfig {
}
this.tagRenderings = trs(json.tagRenderings, false);
const missingIds = json.tagRenderings.filter(tr => typeof tr !== "string" && tr["builtin"] === undefined && tr["id"] === undefined);
if(missingIds.length > 0){
console.error("Some tagRenderings of", this.id, "are missing an id:", missingIds)
throw "Missing ids in tagrenderings"
}
this.filters = (json.filter ?? []).map((option, i) => {
return new FilterConfig(option, `${context}.filter-[${i}]`)
});

View file

@ -13,7 +13,7 @@ import {Utils} from "../../Utils";
*/
export default class TagRenderingConfig {
readonly id?: string;
readonly id: string;
readonly render?: Translation;
readonly question?: Translation;
readonly condition?: TagsFilter;
@ -57,6 +57,7 @@ export default class TagRenderingConfig {
return;
}
this.id = json.id ?? "";
this.render = Translations.T(json.render, context + ".render");
this.question = Translations.T(json.question, context + ".question");

View file

@ -63,6 +63,7 @@
},
"tagRenderings": [
{
"id": "turbine-output",
"render": {
"en": "The power output of this wind turbine is {generator:output:electricity}.",
"fr": "La puissance générée par cette éolienne est de {generator:output:electricity}."
@ -77,6 +78,7 @@
}
},
{
"id": "turbine-operator",
"render": {
"en": "This wind turbine is operated by {operator}.",
"fr": "Cette éolienne est opérée par {operator}."
@ -90,6 +92,7 @@
}
},
{
"id": "turbine-height",
"render": {
"en": "The total height (including rotor radius) of this wind turbine is {height} metres.",
"fr": "La hauteur totale, incluant les pales, est de {height} mètres."
@ -104,6 +107,7 @@
}
},
{
"id": "turbine-diameter",
"render": {
"en": "The rotor diameter of this wind turbine is {rotor:diameter} metres.",
"fr": "Le diamètre du rotor est de {rotor:diameter} mètres."
@ -118,6 +122,7 @@
}
},
{
"id": "turbine-start-date",
"render": {
"en": "This wind turbine went into operation on/in {start_date}.",
"fr": "Léolienne est active depuis {start_date}."

View file

@ -166,11 +166,13 @@
},
"tagRenderings": [
{
"id": "walk-length",
"render": {
"nl": "Deze wandeling is <b>{_length:km}km</b> lang"
}
},
{
"id":"walk-type",
"mappings": [
{
"if": "route=iwn",
@ -199,6 +201,7 @@
]
},
{
"id": "walk-description",
"render": {
"nl": "<h3>Korte beschrijving:</h3>{description}"
},
@ -209,6 +212,7 @@
}
},
{
"id": "walk-operator",
"question": {
"nl": "Wie beheert deze wandeling en plaatst dus de signalisatiebordjes?"
},
@ -218,6 +222,7 @@
}
},
{
"id": "walk-operator-email",
"question": {
"nl": "Naar wie kan men emailen bij problemen rond signalisatie?"
},

View file

@ -1,283 +0,0 @@
{
"id": "speelplekken_temp",
"title": {
"nl": "Speelplekken in de Antwerpse Zuidrand"
},
"shortDescription": {
"nl": "Speelplekken in de Antwerpse Zuidrand"
},
"description": {
"nl": "Speelplekken in de Antwerpse Zuidrand. Een project van Provincie Antwerpen, in samenwerking met Createlli, Sportpret en OpenStreetMap België"
},
"language": [
"nl"
],
"maintainer": "MapComplete",
"icon": "./assets/themes/speelplekken/logo.svg",
"hideFromOverview": true,
"lockLocation": true,
"version": "0",
"startLat": 51.17174,
"startLon": 4.449462,
"startZoom": 12,
"widenFactor": 0.05,
"socialImage": "",
"defaultBackgroundId": "CartoDB.Positron",
"layers": [
{
"builtin": "play_forest",
"override": {
"source": {
"geoJson": "https://pietervdvn.github.io/speelplekken_cache/speelplekken_{z}_{x}_{y}.geojson",
"geoJsonZoomLevel": 14,
"isOsmCache": true
},
"icon": "./assets/themes/speelplekken/speelbos.svg",
"minzoom": 12
},
"calculatedTags": [
"_is_shadowed=feat.overlapWith('shadow').length > 0 ? 'yes': ''"
]
},
{
"builtin": "playground",
"override": {
"icon": "./assets/themes/speelplekken/speeltuin.svg",
"minzoom": 14,
"source": {
"geoJsonLocal": "http://127.0.0.1:8080/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJson": "https://pietervdvn.github.io/speelplekken_cache/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJsonZoomLevel": 14,
"isOsmCache": true
},
"calculatedTags": [
"_is_shadowed=feat.overlapWith('shadow').length > 0 ? 'yes': ''"
]
}
},
{
"builtin": "village_green",
"override": {
"icon": "./assets/themes/speelplekken/speelweide.svg",
"minzoom": 14,
"source": {
"geoJsonLocal": "http://127.0.0.1:8080/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJson": "https://pietervdvn.github.io/speelplekken_cache/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJsonZoomLevel": 14,
"isOsmCache": true
},
"calculatedTags": [
"_is_shadowed=feat.overlapWith('shadow').length > 0 ? 'yes': ''"
]
}
},
{
"builtin": "grass_in_parks",
"override": {
"icon": "./assets/themes/speelplekken/speelweide.svg",
"minzoom": 14,
"source": {
"geoJsonLocal": "http://127.0.0.1:8080/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJson": "https://pietervdvn.github.io/speelplekken_cache/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJsonZoomLevel": 14,
"isOsmCache": true
},
"calculatedTags": [
"_is_shadowed=feat.overlapWith('shadow').length > 0 ? 'yes': ''"
]
}
},
{
"builtin": "sport_pitch",
"override": {
"minzoom": 15,
"source": {
"geoJsonLocal": "http://127.0.0.1:8080/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJson": "https://pietervdvn.github.io/speelplekken_cache/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJsonZoomLevel": 14,
"isOsmCache": true
},
"calculatedTags": [
"_is_shadowed=feat.overlapWith('shadow').length > 0 ? 'yes': ''"
]
}
},
{
"builtin": "slow_roads",
"override": {
"+tagRenderings": [
{
"question": "Is dit een publiek toegankelijk pad?",
"mappings": [
{
"if": "access=private",
"then": "Dit is een privaat pad"
},
{
"if": "access=no",
"then": "Dit is een privaat pad",
"hideInAnswer": true
},
{
"if": "access=permissive",
"then": "Dit pad is duidelijk in private eigendom, maar er hangen geen verbodsborden dus mag men erover"
}
]
}
],
"calculatedTags": [
"_part_of_walking_routes=Array.from(new Set(feat.memberships().map(r => \"<a href='#relation/\"+r.relation.id+\"'>\" + r.relation.tags.name + \"</a>\"))).join(', ')",
"_is_shadowed=feat.overlapWith('shadow').length > 0 ? 'yes': ''"
],
"minzoom": 18,
"source": {
"geoJsonLocal": "http://127.0.0.1:8080/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJson": "https://pietervdvn.github.io/speelplekken_cache/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJsonZoomLevel": 14,
"isOsmCache": true
}
}
},
{
"id": "walking_routes",
"name": {
"nl": "Wandelroutes van provincie Antwerpen"
},
"description": "Walking routes by 'provincie Antwerpen'",
"source": {
"osmTags": {
"and": [
"type=route",
"route=foot",
"operator~[pP]rovincie Antwerpen"
]
},
"geoJson": "https://pietervdvn.github.io/speelplekken_cache/speelplekken_{layer}_{z}_{x}_{y}.geojson",
"geoJsonZoomLevel": 14,
"isOsmCache": true
},
"title": {
"render": "Wandeling <i>{name}</i>",
"mappings": [
{
"if": "name~.*wandeling.*",
"then": "{name}"
}
]
},
"tagRenderings": [
{
"render": {
"nl": "Deze wandeling is <b>{_length:km}km</b> lang"
}
},
{
"mappings": [
{
"if": "route=iwn",
"then": {
"nl": "Dit is een internationale wandelroute"
}
},
{
"if": "route=nwn",
"then": {
"nl": "Dit is een nationale wandelroute"
}
},
{
"if": "route=rwn",
"then": {
"nl": "Dit is een regionale wandelroute"
}
},
{
"if": "route=lwn",
"then": {
"nl": "Dit is een lokale wandelroute"
}
}
]
},
{
"render": {
"nl": "<h3>Korte beschrijving:</h3>{description}"
},
"question": "Geef een korte beschrijving van de wandeling (max 255 tekens)",
"freeform": {
"key": "description",
"type": "text"
}
},
{
"question": {
"nl": "Wie beheert deze wandeling en plaatst dus de signalisatiebordjes?"
},
"render": "Signalisatie geplaatst door {operator}",
"freeform": {
"key": "operator"
}
},
{
"question": {
"nl": "Naar wie kan men emailen bij problemen rond signalisatie?"
},
"render": {
"nl": "Bij problemen met signalisatie kan men emailen naar <a href='mailto:{operator:email}'>{operator:email}</a>"
},
"freeform": {
"key": "operator:email",
"type": "email"
}
},
"questions",
"reviews"
],
"color": {
"render": "#6d6",
"mappings": [
{
"if": "color~*",
"then": "{color}"
},
{
"if": "colour~*",
"then": "{colour}"
}
]
},
"width": {
"render": "9"
}
}
],
"clustering": {
"maxZoom": 16,
"minNeededElements": 100
},
"roamingRenderings": [
{
"render": "Maakt deel uit van {_part_of_walking_routes}",
"condition": "_part_of_walking_routes~*"
},
{
"render": "<a href='{video}' target='blank'>Een kinder-reportage vinden jullie hier<a/>",
"freeform": {
"key": "video",
"type": "url"
},
"question": "Wat is de link naar de video-reportage?"
}
],
"overrideAll": {
"isShown": {
"render": "yes",
"mappings": [
{
"if": "_is_shadowed=yes",
"then": "no"
}
]
}
}
}