2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								import  { readFileSync ,  writeFileSync }  from  "fs" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  { Utils }  from  "../../../Utils" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// SMall script to output the properties of the types.csv as json to add in the tagRenderingGroup. Should be copied manually
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 02:17:28 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function  run ( file ,  protojson )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  entries : string [ ]  =  Utils . NoNull ( readFileSync ( file ,  "utf8" ) . split ( "\n" ) . map ( str  = >  str . trim ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    entries . shift ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  overview_question_answers  =  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    const  questions  =  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 21:56:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  filterOptions :  {  question : string ,  osmTags? : string  }  [ ]  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            question :  "All connectors" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( const  entry  of  entries )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  [ key ,  image ,  description ,  whitelist ]  =  entry . split ( "," ) . map ( str  = >  str . trim ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( key  ===  "" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  txt  =  ` <img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/ ${ image } '/>  ${ description } ` 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        const  json  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            if :  ` ${ key } =1 ` , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ifnot :  ` ${ key } = ` , 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            then : txt , 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( whitelist )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            const  countries  =  whitelist . replace ( /"/g ,  '' ) . split ( "," ) . map ( country  = >  "_country!="  +  country )  //HideInAnswer if it is in the wrong country
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 21:56:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            json [ "hideInAnswer" ]  =  { or : countries } 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        overview_question_answers . push ( json ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // We add a second time for any amount to trigger a visualisation; but this is not an answer option
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  no_ask_json  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            if :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                and :  [ ` ${ key } ~* ` ,  ` ${ key } !=1 ` ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            then : txt , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            hideInAnswer : true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        overview_question_answers . push ( no_ask_json ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        const  indivQ  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            question :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                en :  ` How much plugs of type  ${ description }  <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/ ${ image } '/> are available here? ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            render :  ` There are <b>{ ${ key } }</b>  <img style='width:1rem' src='./assets/layers/charging_station/ ${ image } '/> plugs of type  ${ description }  available here ` , 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								            freeform :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                key : key , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                type :  "pnat" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            condition :  ` ${ key } ~* ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        questions . push ( indivQ ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 21:56:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        filterOptions . push ( { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            question :  ` Has a  ${ description }  <img style='width:1rem' src='./assets/layers/charging_station/ ${ image } '/> connector ` , 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 21:56:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            osmTags :  ` ${ key } ~* ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  toggles  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "question" :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            "en" :  "Which charging stations are available here?" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "multiAnswer" :  true , 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-07 21:03:29 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        "mappings" :  overview_question_answers 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    questions . unshift ( toggles ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  stringified  =  questions . map ( q  = >  JSON . stringify ( q ,  null ,  "  " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 02:17:28 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    let  proto  =  readFileSync ( protojson ,  "utf8" ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    proto  =  proto . replace ( "$$$" ,  stringified . join ( ",\n" )  +  "," ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 21:56:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    proto  =  JSON . parse ( proto ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    proto [ "filter" ] . push ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        options : filterOptions 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    writeFileSync ( "charging_station.json" ,  JSON . stringify ( proto ,  undefined ,  "  " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								try  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 21:56:48 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    run ( "types.csv" ,  "charging_station.protojson" ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-06 01:35:08 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}  catch  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    console . error ( e ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}