2020-06-24 00:35:19 +02:00
import { LayerDefinition } from "../LayerDefinition" ;
2020-07-05 18:59:47 +02:00
import { Or , Tag } from "../../Logic/TagsFilter" ;
import { TagRenderingOptions } from "../TagRendering" ;
import { AccessTag } from "../Questions/AccessTag" ;
import { OperatorTag } from "../Questions/OperatorTag" ;
import { NameQuestion } from "../Questions/NameQuestion" ;
import { NameInline } from "../Questions/NameInline" ;
2020-07-13 12:10:43 +02:00
import { DescriptionQuestion } from "../Questions/DescriptionQuestion" ;
2020-07-14 20:18:44 +02:00
import { ImageCarouselWithUploadConstructor } from "../../UI/Image/ImageCarouselWithUpload" ;
2020-06-24 00:35:19 +02:00
export class NatureReserves extends LayerDefinition {
2020-07-18 20:40:51 +02:00
constructor ( moreQuests : boolean = false ) {
2020-06-24 00:35:19 +02:00
super ( ) ;
2020-07-24 14:46:25 +02:00
this . name = "Natuurgebied" ;
this . icon = "" ;
2020-06-27 03:06:51 +02:00
this . overpassFilter =
2020-07-18 20:40:51 +02:00
new Or ( [ new Tag ( "leisure" , "nature_reserve" ) , new Tag ( "boundary" , "protected_area" ) ] ) ;
2020-06-28 23:33:48 +02:00
this . maxAllowedOverlapPercentage = 10 ;
2020-06-24 00:35:19 +02:00
this . newElementTags = [ new Tag ( "leisure" , "nature_reserve" ) ,
new Tag ( "fixme" , "Toegevoegd met MapComplete, geometry nog uit te tekenen" ) ]
this . minzoom = 13 ;
2020-07-18 20:40:51 +02:00
this . title = new NameInline ( "natuurreservaat" ) ;
2020-06-24 00:35:19 +02:00
this . style = this . generateStyleFunction ( ) ;
this . elementsToShow = [
2020-07-14 20:18:44 +02:00
new ImageCarouselWithUploadConstructor ( ) ,
2020-07-24 15:59:41 +02:00
/ * n e w T a g R e n d e r i n g O p t i o n s ( {
2020-07-22 01:07:32 +02:00
freeform : {
key : "_surface" ,
renderTemplate : "{_surface}m²" ,
template : "$$$"
}
2020-07-24 15:59:41 +02:00
} ) , * /
2020-07-05 18:59:47 +02:00
new NameQuestion ( ) ,
new AccessTag ( ) ,
new OperatorTag ( ) ,
2020-07-13 12:10:43 +02:00
new DescriptionQuestion ( "natuurgebied" )
2020-06-24 00:35:19 +02:00
] ;
2020-07-18 20:40:51 +02:00
const extraRenderings = [
new TagRenderingOptions ( {
question : "Mogen honden in dit natuurgebied?" ,
mappings : [
{ k : new Tag ( "dog" , "leashed" ) , txt : "Honden moeten aan de leiband" } ,
{ k : new Tag ( "dog" , "no" ) , txt : "Honden zijn niet toegestaan" } ,
{ k : new Tag ( "dog" , "yes" ) , txt : "Honden zijn welkom" } ,
]
} ) . OnlyShowIf ( new Tag ( "access" , "yes" ) ) ,
new TagRenderingOptions ( {
question : "Op welke website kunnen we meer informatie vinden over dit natuurgebied?" ,
freeform : {
key : "website" ,
renderTemplate : "<a href='{website}' target='_blank'>Meer informatie</a>" ,
template : "$$$"
}
} ) ,
new TagRenderingOptions ( {
question : "Wie is de conservator van dit gebied?<br>" +
"<span class='question-subtext'>Geef de naam van de conservator énkel als die duidelijk online staat gepubliceerd.</span>" ,
freeform : {
renderTemplate : "De conservator van dit gebied is {curator}" ,
template : "$$$" ,
key : "curator"
}
} ) ,
new TagRenderingOptions (
{
question : "Wat is het email-adres van de beheerder?<br>" +
"<span class='question-subtext'>Geef bij voorkeur het emailadres van de Natuurpunt-afdeling; geef enkel een email-adres van de conservator als dit duidelijk is gepubliceerd</span>" ,
freeform : {
2020-07-19 00:13:45 +02:00
renderTemplate : "Bij problemen of vragen, de conservator kan bereikt worden via " +
2020-07-18 20:40:51 +02:00
"<a href='mailto:{email}'>{email}</a>" ,
2020-07-26 02:01:34 +02:00
template : "$email$" ,
2020-07-18 20:40:51 +02:00
key : "email"
}
} ) ,
new TagRenderingOptions (
{
question : "Wat is het telefoonnummer van de beheerder?<br>" +
"<span class='question-subtext'>Geef bij voorkeur het telefoonnummer van de Natuurpunt-afdeling; geef enkel een email-adres van de conservator als dit duidelijk is gepubliceerd</span>" ,
freeform : {
renderTemplate : "Bij problemen of vragen, de {conservator} kan bereikt worden via " +
"<a href='tel:{phone}'>{phone}</a>" ,
2020-07-26 02:01:34 +02:00
template : "$phone$" ,
2020-07-18 20:40:51 +02:00
key : "phone"
}
} ) ,
] ;
if ( moreQuests ) {
this . elementsToShow =
this . elementsToShow . concat ( extraRenderings ) ;
}
2020-06-24 00:35:19 +02:00
}
private generateStyleFunction() {
const self = this ;
return function ( properties : any ) {
let questionSeverity = 0 ;
2020-07-05 18:59:47 +02:00
for ( const qd of self . elementsToShow ) {
2020-07-13 13:17:03 +02:00
if ( qd instanceof DescriptionQuestion ) {
continue ;
}
2020-07-05 18:59:47 +02:00
if ( qd . IsQuestioning ( properties ) ) {
2020-07-13 13:17:03 +02:00
questionSeverity = Math . max ( questionSeverity , qd . Priority ( ) ? ? 0 ) ;
2020-06-24 00:35:19 +02:00
}
}
let colormapping = {
0 : "#00bb00" ,
1 : "#00ff00" ,
10 : "#dddd00" ,
20 : "#ff0000"
} ;
let colour = colormapping [ questionSeverity ] ;
while ( colour == undefined ) {
questionSeverity -- ;
2020-07-05 18:59:47 +02:00
colour = colormapping [ questionSeverity ] ;
2020-06-24 00:35:19 +02:00
}
return {
color : colour ,
2020-07-01 17:38:48 +02:00
icon : undefined
2020-06-24 00:35:19 +02:00
} ;
} ;
}
}