diff --git a/Customizations/AllKnownLayers.ts b/Customizations/AllKnownLayers.ts index 0925714af..c526eb3b5 100644 --- a/Customizations/AllKnownLayers.ts +++ b/Customizations/AllKnownLayers.ts @@ -22,6 +22,7 @@ import * as tree_nodes from "../assets/layers/trees/tree_nodes.json" import * as benches from "../assets/layers/benches/benches.json" import * as benches_at_pt from "../assets/layers/benches/benches_at_pt.json" import * as picnic_tables from "../assets/layers/benches/picnic_tables.json" +import * as play_forest from "../assets/layers/play_forest/play_forest.json" import LayerConfig from "./JSON/LayerConfig"; import {LayerConfigJson} from "./JSON/LayerConfigJson"; @@ -52,7 +53,8 @@ export default class AllKnownLayers { tree_nodes, benches, benches_at_pt, - picnic_tables + picnic_tables, + play_forest ]; // Must be below the list... diff --git a/Customizations/AllKnownLayouts.ts b/Customizations/AllKnownLayouts.ts index 29a269470..fb8f7cd72 100644 --- a/Customizations/AllKnownLayouts.ts +++ b/Customizations/AllKnownLayouts.ts @@ -21,6 +21,7 @@ import * as trees from "../assets/themes/trees/trees.json" import * as personal from "../assets/themes/personalLayout/personalLayout.json" import * as playgrounds from "../assets/themes/playgrounds/playgrounds.json" import * as bicycle_lib from "../assets/themes/bicycle_library/bicycle_library.json" +import * as play_forests from "../assets/themes/play_forests/play_forests.json" import LayerConfig from "./JSON/LayerConfig"; import LayoutConfig from "./JSON/LayoutConfig"; import AllKnownLayers from "./AllKnownLayers"; @@ -70,6 +71,7 @@ export class AllKnownLayouts { new LayoutConfig(climbing), new LayoutConfig(playgrounds), new LayoutConfig(trees), + new LayoutConfig(play_forests) ]; diff --git a/Customizations/JSON/LayerConfig.ts b/Customizations/JSON/LayerConfig.ts index 58f7cf823..e0d6a2452 100644 --- a/Customizations/JSON/LayerConfig.ts +++ b/Customizations/JSON/LayerConfig.ts @@ -54,19 +54,19 @@ export default class LayerConfig { context = context + "." + json.id; const self = this; this.id = json.id; - this.name = Translations.T(json.name); - this.description = Translations.T(json.description); + this.name = Translations.T(json.name, context+".name"); + this.description = Translations.T(json.description, context+".description"); this.overpassTags = FromJSON.Tag(json.overpassTags, context + ".overpasstags"); this.doNotDownload = json.doNotDownload ?? false, this.passAllFeatures = json.passAllFeatures ?? false; this.minzoom = json.minzoom; this.wayHandling = json.wayHandling ?? 0; this.hideUnderlayingFeaturesMinPercentage = json.hideUnderlayingFeaturesMinPercentage ?? 0; - this.presets = (json.presets ?? []).map(pr => + this.presets = (json.presets ?? []).map((pr, i) => ({ - title: Translations.T(pr.title), + title: Translations.T(pr.title, `${context}.presets[${i}].title`), tags: pr.tags.map(t => FromJSON.SimpleTag(t)), - description: Translations.T(pr.description) + description: Translations.T(pr.description, `${context}.presets[${i}].description`) })) diff --git a/Customizations/JSON/LayoutConfig.ts b/Customizations/JSON/LayoutConfig.ts index bf36cf0c9..d1424bcb9 100644 --- a/Customizations/JSON/LayoutConfig.ts +++ b/Customizations/JSON/LayoutConfig.ts @@ -53,6 +53,9 @@ export default class LayoutConfig { } else { this.language = json.language; } + if(this.language.length == 0){ + throw "No languages defined. Define at least one language" + } if (json.title === undefined) { throw "Title not defined in " + this.id; } @@ -62,7 +65,7 @@ export default class LayoutConfig { this.title = new Translation(json.title, context + ".title"); this.description = new Translation(json.description, context + ".description"); this.shortDescription = json.shortDescription === undefined ? this.description.FirstSentence() : new Translation(json.shortDescription, context + ".shortdescription"); - this.descriptionTail = json.descriptionTail === undefined ? new Translation({"*": ""}, context) : new Translation(json.descriptionTail, context + ".descriptionTail"); + this.descriptionTail = json.descriptionTail === undefined ? new Translation({"*": ""}, context+".descriptionTail") : new Translation(json.descriptionTail, context + ".descriptionTail"); this.icon = json.icon; this.socialImage = json.socialImage; this.startZoom = json.startZoom; diff --git a/Customizations/JSON/TagRenderingConfig.ts b/Customizations/JSON/TagRenderingConfig.ts index 830921fa4..20ee771d5 100644 --- a/Customizations/JSON/TagRenderingConfig.ts +++ b/Customizations/JSON/TagRenderingConfig.ts @@ -45,13 +45,13 @@ export default class TagRenderingConfig { throw "Initing a TagRenderingConfig with undefined in " + context; } if (typeof json === "string") { - this.render = Translations.T(json); + this.render = Translations.T(json, context+".render"); this.multiAnswer = false; return; } - this.render = Translations.T(json.render); - this.question = Translations.T(json.question); + this.render = Translations.T(json.render, context+".render"); + this.question = Translations.T(json.question, context+".question"); this.roaming = json.roaming ?? false; const condition = FromJSON.Tag(json.condition ?? {"and": []}, `${context}.condition`); if (this.roaming && conditionIfRoaming !== undefined) { @@ -96,10 +96,11 @@ export default class TagRenderingConfig { } else if (mapping.hideInAnswer !== undefined) { hideInAnswer = FromJSON.Tag(mapping.hideInAnswer, `${context}.mapping[${i}].hideInAnswer`); } + const mappingContext = `${context}.mapping[${i}]` const mp = { - if: FromJSON.Tag(mapping.if, `${context}.mapping[${i}].if`), - ifnot: (mapping.ifnot !== undefined ? FromJSON.Tag(mapping.ifnot, `${context}.mapping[${i}].ifnot`) : undefined), - then: Translations.T(mapping.then), + if: FromJSON.Tag(mapping.if, `${mappingContext}.if`), + ifnot: (mapping.ifnot !== undefined ? FromJSON.Tag(mapping.ifnot, `${mappingContext}.ifnot`) : undefined), + then: Translations.T(mapping.then, `{mappingContext}.then`), hideInAnswer: hideInAnswer }; if (this.question) { diff --git a/assets/layers/play_forest/icon.jpg b/assets/layers/play_forest/icon.jpg new file mode 100644 index 000000000..5a0b42bf7 Binary files /dev/null and b/assets/layers/play_forest/icon.jpg differ diff --git a/assets/layers/play_forest/play_forest.json b/assets/layers/play_forest/play_forest.json new file mode 100644 index 000000000..e83f16463 --- /dev/null +++ b/assets/layers/play_forest/play_forest.json @@ -0,0 +1,108 @@ +{ + "id": "play_forest", + "name": { + "nl": "Speelbossen" + }, + "minzoom": 12, + "overpassTags": { + "and": [ + "playground=forest" + ] + }, + "title": { + "render": { + "nl": "Speelbos" + }, + "mappings": [ + { + "if": "name~*", + "then": { + "nl": "Speelbos {name}" + } + } + ] + }, + "description": { + "nl": "Een speelbos is een vrij toegankelijke zone in een bos" + }, + "tagRenderings": [ + "images", + { + "question": "Wie beheert dit gebied?", + "render": "Dit gebied wordt beheerd door {operator}", + "freeform": { + "key": "operator" + }, + "mappings": [ + { + "if": "operator~[aA][nN][bB]", + "then": "Dit gebied wordt beheerd door het Agentschap Natuur en Bos", + "hideInAnswer": true + }, + { + "if": "operator=Agenstchap Natuur en Bos", + "then": "Dit gebied wordt beheerd door het Agentschap Natuur en Bos" + } + ] + }, + { + "question": "Wanneer is deze speelzone toegankelijk?", + "mappings": [ + { + "if": "opening_hours=08:00-22:00", + "then": "Het hele jaar door overdag toegankelijk (van 08:00 tot 22:00)" + }, + { + "if": "opening_hours=Jul-Aug 08:00-22:00", + "then": "Enkel in de zomervakantie en overdag toegankelijk (van 1 juli tot 31 augustus, van 08:00 tot 22:00" + } + ] + }, + { + "question": "Naar waar kan men emailen indien er problemen zijn met de speelzone?", + "render": "De bevoegde dienst kan bereikt worden via {email}", + "freeform": { + "key": "email", + "type": "email" + } + }, + { + "question": "Naar waar kan men bellen indien er problemen zijn met de speelzone?", + "render": "De bevoegde dienst kan getelefoneerd worden via {phone}", + "freeform": { + "key": "phone", + "type": "phone" + } + }, + "questions", + { + "render": "{reviews(name, play_forest)}" + } + ], + "hideUnderlayingFeaturesMinPercentage": 0, + "hideFromOverview": false, + "icon": { + "render": "./assets/layers/play_forest/icon.jpg" + }, + "width": { + "render": "8" + }, + "iconSize": { + "render": "40,40,center" + }, + "color": { + "render": "#2d2" + }, + "presets": [ + { + "title": "Speelbos", + "tags": [ + "leisure=playground", + "playground=forest", + "fixme=Toegevoegd met MapComplete, geometry nog uit te tekenen" + ], + "description": "Een zone in het bos, duidelijk gemarkeerd als speelzone met de betreffende borden
" + } + ], + "wayHandling": 2 +} \ No newline at end of file diff --git a/assets/themes/play_forests/play_forests.json b/assets/themes/play_forests/play_forests.json new file mode 100644 index 000000000..1f7c090c9 --- /dev/null +++ b/assets/themes/play_forests/play_forests.json @@ -0,0 +1,27 @@ +{ + "id": "play_forests", + "title": { + "nl": "Speelbossen" + }, + "shortDescription": { + "nl": "Deze kaart toont speelbossen" + }, + "description": { + "nl": "Een speelbos is een zone in een bos die vrij toegankelijk is voor spelende kinderen. Deze wordt in bossen van het Agentschap Natuur en bos altijd aangeduid met het overeenkomstige bord." + }, + "language": [ + "nl" + ], + "maintainer": "", + "icon": "./assets/layers/play_forest/icon.jpg", + "version": "0", + "startLat": 0, + "startLon": 0, + "startZoom": 1, + "widenFactor": 0.05, + "socialImage": "", + "layers": [ + "play_forest" + ], + "roamingRenderings": [] +} \ No newline at end of file