Add opening hours to playgrounds and pitches

This commit is contained in:
pietervdvn 2021-03-26 00:14:17 +01:00
parent 1b1ec9f15d
commit fa238092bc
4 changed files with 157 additions and 69 deletions

View file

@ -133,7 +133,7 @@ export default class TagRenderingConfig {
} }
if(this.render && this.question && this.freeform === undefined){ if(this.render && this.question && this.freeform === undefined){
throw `${context}: Detected a tagrendering which takes input without freeform key in ${context}` throw `${context}: Detected a tagrendering which takes input without freeform key in ${context}; the question is ${this.question.txt}`
} }
if(!json.multiAnswer && this.mappings !== undefined && this.question !== undefined){ if(!json.multiAnswer && this.mappings !== undefined && this.question !== undefined){

View file

@ -42,7 +42,6 @@ export default class FilteringFeatureSource implements FeatureSource {
const isShown = layer.layerDef.isShown const isShown = layer.layerDef.isShown
const tags = f.feature.properties; const tags = f.feature.properties;
console.log("Is shown: ", isShown," known? ", isShown.IsKnown(tags), " result: ", isShown.GetRenderValue(tags).txt)
if(isShown.IsKnown(tags)){ if(isShown.IsKnown(tags)){
const result = layer.layerDef.isShown.GetRenderValue(f.feature.properties).txt; const result = layer.layerDef.isShown.GetRenderValue(f.feature.properties).txt;
if(result !== "yes"){ if(result !== "yes"){

View file

@ -288,6 +288,21 @@
"nl": "Van zonsopgang tot zonsondergang", "nl": "Van zonsopgang tot zonsondergang",
"en": "Accessible from sunrise till sunset" "en": "Accessible from sunrise till sunset"
} }
},
{
"if": "opening_hours=24/7",
"then": {
"nl": "Dag en nacht toegankelijk",
"en": "Always accessible"
}
},
{
"if": "opening_hours=",
"then": {
"nl": "Dag en nacht toegankelijk",
"en": "Always accessible"
},
"hideInAnswer": true
} }
] ]
}, },
@ -300,6 +315,18 @@
"icon": { "icon": {
"render": "https://upload.wikimedia.org/wikipedia/commons/0/00/Map_icons_by_Scott_de_Jonge_-_playground.svg" "render": "https://upload.wikimedia.org/wikipedia/commons/0/00/Map_icons_by_Scott_de_Jonge_-_playground.svg"
}, },
"iconOverlays": [
{
"if": {
"and": [
"opening_hours!=24/7",
"opening_hours~*"
]
},
"then": "isOpen",
"badge": true
}
],
"width": { "width": {
"render": "1" "render": "1"
}, },

View file

@ -1,34 +1,42 @@
{ {
"id": "sport_pitch", "id": "sport_pitch",
"name": { "name": {
"nl": "Sportterrein" "nl": "Sportterrein",
"en": "Sport pitches"
}, },
"wayHandling": 2, "wayHandling": 2,
"minzoom": 12, "minzoom": 12,
"source": { "source": {
"osmTags": { "osmTags": {
"and": [ "and": [
"leisure=pitch" "leisure=pitch"
]} ]
}
}, },
"title": { "title": {
"render": { "render": {
"nl": "Sportterrein" "nl": "Sportterrein",
"en": "Sport pitch"
} }
}, },
"description": { "description": {
"nl": "Een sportterrein" "nl": "Een sportterrein",
"en": "A sport pitch"
}, },
"tagRenderings": [ "tagRenderings": [
"images", "images",
{ {
"render": { "render": {
"nl": "Hier kan men {sport} beoefenen" "nl": "Hier kan men {sport} beoefenen",
"en": "{sport} is played here"
}, },
"freeform": { "freeform": {
"key": "sport" "key": "sport"
}, },
"question": "Welke sporten kan men hier beoefenen?", "question": {
"nl": "Welke sporten kan men hier beoefenen?",
"en": "Which sport can be played here?"
},
"multiAnswer": true, "multiAnswer": true,
"mappings": [ "mappings": [
{ {
@ -38,7 +46,8 @@
] ]
}, },
"then": { "then": {
"nl": "Hier kan men basketbal spelen" "nl": "Hier kan men basketbal spelen",
"en": "Basketball is played here"
} }
}, },
{ {
@ -48,7 +57,8 @@
] ]
}, },
"then": { "then": {
"nl": "Hier kan men voetbal spelen" "nl": "Hier kan men voetbal spelen",
"en": "Soccer is played here"
} }
}, },
{ {
@ -58,7 +68,8 @@
] ]
}, },
"then": { "then": {
"nl": "Dit is een pingpongtafel" "nl": "Dit is een pingpongtafel",
"en": "This is a pingpong table"
} }
}, },
{ {
@ -68,7 +79,8 @@
] ]
}, },
"then": { "then": {
"nl": "Hier kan men tennis spelen" "nl": "Hier kan men tennis spelen",
"en": "Tennis is played here"
} }
}, },
{ {
@ -78,7 +90,8 @@
] ]
}, },
"then": { "then": {
"nl": "Hier kan men korfbal spelen" "nl": "Hier kan men korfbal spelen",
"en": "Korfball is played here"
} }
}, },
{ {
@ -88,59 +101,62 @@
] ]
}, },
"then": { "then": {
"nl": "Hier kan men basketbal beoefenen" "nl": "Hier kan men basketbal beoefenen",
"en": "Basketball is played here"
},
"hideInAnswer": true
}
]
},
{
"question": {
"nl": "Wat is de ondergrond van dit sportveld?",
"en": "Which is the surface of this sport pitch?"
},
"render": {
"nl": "De ondergrond is <b>{surface}</b>",
"en": "The surface is <b>{surface}</b>"
},
"freeform": {
"key": "surface"
},
"mappings": [
{
"if": "surface=grass",
"then": {
"nl": "De ondergrond is <b>gras</b>",
"en": "The surface is <b>grass</b>"
}
},
{
"if": "surface=sand",
"then": {
"nl": "De ondergrond is <b>zand</b>",
"en": "The surface is <b>sand</b>"
}
},
{
"if": "surface=paving_stones",
"then": {
"nl": "De ondergrond bestaat uit <b>stoeptegels</b>",
"en": "The surface is <b>paving stones</b>"
}
},
{
"if": "surface=asphalt",
"then": {
"nl": "De ondergrond is <b>asfalt</b>",
"en": "The surface is <b>asphalt</b>"
}
},
{
"if": "surface=concrete",
"then": {
"nl": "De ondergrond is <b>beton</b>",
"en": "The surface is <b>concrete</b>"
} }
} }
] ]
},{
"question": {
"nl": "Wat is de ondergrond van dit sportveld?",
"en": "Which is the surface of this sport pitch?"
},
"render": {
"nl": "De ondergrond is <b>{surface}</b>",
"en": "The surface is <b>{surface}</b>"
},
"freeform": {
"key": "surface"
},
"mappings": [
{
"if": "surface=grass",
"then": {
"nl": "De ondergrond is <b>gras</b>",
"en": "The surface is <b>grass</b>"
}
},
{
"if": "surface=sand",
"then": {
"nl": "De ondergrond is <b>zand</b>",
"en": "The surface is <b>sand</b>"
}
},
{
"if": "surface=paving_stones",
"then": {
"nl": "De ondergrond bestaat uit <b>stoeptegels</b>",
"en": "The surface is <b>paving stones</b>"
}
},
{
"if": "surface=asphalt",
"then": {
"nl": "De ondergrond is <b>asfalt</b>",
"en": "The surface is <b>asphalt</b>"
}
},
{
"if": "surface=concrete",
"then": {
"nl": "De ondergrond is <b>beton</b>",
"en": "The surface is <b>concrete</b>"
}
}
]
}, },
{ {
"question": { "question": {
@ -151,7 +167,8 @@
"if": "access=public", "if": "access=public",
"then": "Publiek toegankelijk" "then": "Publiek toegankelijk"
}, },
{"if": "access=limited", {
"if": "access=limited",
"then": "Beperkt toegankelijk (enkel na reservatie, tijdens bepaalde uren, ...)" "then": "Beperkt toegankelijk (enkel na reservatie, tijdens bepaalde uren, ...)"
}, },
{ {
@ -169,7 +186,12 @@
"nl": "Moet men reserveren om gebruik te maken van dit sportveld?" "nl": "Moet men reserveren om gebruik te maken van dit sportveld?"
}, },
"condition": { "condition": {
"and": [ "access!=public", "access!=private", "access!=members"]}, "and": [
"access!=public",
"access!=private",
"access!=members"
]
},
"mappings": [ "mappings": [
{ {
"if": "reservation=required", "if": "reservation=required",
@ -179,7 +201,8 @@
"if": "reservation=recommended", "if": "reservation=recommended",
"then": "Reserveren is sterk aangeraden om gebruik te maken van dit sportterrein" "then": "Reserveren is sterk aangeraden om gebruik te maken van dit sportterrein"
}, },
{"if": "reservation=yes", {
"if": "reservation=yes",
"then": "Reserveren is mogelijk, maar geen voorwaarde" "then": "Reserveren is mogelijk, maar geen voorwaarde"
}, },
{ {
@ -204,13 +227,52 @@
}, },
"render": "<a href='mailto:{email}' target='_blank'>{email}</a>" "render": "<a href='mailto:{email}' target='_blank'>{email}</a>"
}, },
{
"question": {
"nl": "Wanneer is dit sportveld toegankelijk?",
"en": "When is this pitch accessible?"
},
"render": "{opening_hours()}",
"freeform": {
"key": "opening_hours",
"type": "opening_hours"
},
"mappings": [
{
"if": "opening_hours=",
"then": "24/7 toegankelijk",
"hideInAnswer": true
},
{
"if": "opening_hours=24/7",
"then": {
"nl": "24/7 toegankelijk",
"en": "Always accessible"
}
}
]
},
"questions", "questions",
{"render":"{reviews(name, sportpitch)}"} {
"render": "{reviews(name, sportpitch)}"
}
], ],
"hideUnderlayingFeaturesMinPercentage": 0, "hideUnderlayingFeaturesMinPercentage": 0,
"icon": { "icon": {
"render": "circle:white;./assets/layers/sport_pitch/tabletennis.svg" "render": "circle:white;./assets/layers/sport_pitch/tabletennis.svg"
}, },
"iconOverlays": [
{
"if": {
"and": [
"opening_hours!=24/7",
"opening_hours~*"
]
},
"then": "isOpen",
"badge": true
}
],
"width": { "width": {
"render": "1" "render": "1"
}, },