More work on the charging stations theme

This commit is contained in:
pietervdvn 2021-09-07 21:03:29 +02:00
parent c9f2079501
commit 7e2744576c
10 changed files with 476 additions and 97 deletions

View file

@ -2,10 +2,10 @@ import {Tag} from "./Tag";
import {TagsFilter} from "./TagsFilter";
export class RegexTag extends TagsFilter {
private readonly key: RegExp | string;
private readonly value: RegExp | string;
private readonly invert: boolean;
private readonly matchesEmpty: boolean
public readonly key: RegExp | string;
public readonly value: RegExp | string;
public readonly invert: boolean;
public readonly matchesEmpty: boolean
constructor(key: string | RegExp, value: RegExp | string, invert: boolean = false) {
super();

View file

@ -7,6 +7,7 @@ import {RegexTag} from "./RegexTag";
import SubstitutingTag from "./SubstitutingTag";
import {Or} from "./Or";
import {AndOrTagConfigJson} from "../../Models/ThemeConfig/Json/TagConfigJson";
import {isRegExp} from "util";
export class TagUtils {
static ApplyTemplate(template: string, tags: any): string {
@ -47,16 +48,15 @@ export class TagUtils {
}
/***
* Creates a hash {key --> [values]}, with all the values present in the tagsfilter
* Creates a hash {key --> [values : string | Regex ]}, with all the values present in the tagsfilter
*
* @param tagsFilters
* @constructor
*/
static SplitKeys(tagsFilters: TagsFilter[]) {
static SplitKeys(tagsFilters: TagsFilter[], allowRegex = false) {
const keyValues = {} // Map string -> string[]
tagsFilters = [...tagsFilters] // copy all
tagsFilters = [...tagsFilters] // copy all, use as queue
while (tagsFilters.length > 0) {
// Queue
const tagsFilter = tagsFilters.shift();
if (tagsFilter === undefined) {
@ -75,6 +75,21 @@ export class TagUtils {
keyValues[tagsFilter.key].push(...tagsFilter.value.split(";"));
continue;
}
if(allowRegex && tagsFilter instanceof RegexTag) {
const key = tagsFilter.key
if(isRegExp(key)) {
console.error("Invalid type to flatten the multiAnswer: key is a regex too", tagsFilter);
throw "Invalid type to FlattenMultiAnswer"
}
const keystr = <string>key
if (keyValues[keystr] === undefined) {
keyValues[keystr ] = [];
}
keyValues[keystr].push(tagsFilter);
continue;
}
console.error("Invalid type to flatten the multiAnswer", tagsFilter);
throw "Invalid type to FlattenMultiAnswer"
@ -106,16 +121,30 @@ export class TagUtils {
return new And(and);
}
static MatchesMultiAnswer(tag: TagsFilter, tags: any): boolean {
const splitted = TagUtils.SplitKeys([tag]);
/**
* Returns true if the properties match the tagsFilter, interpreted as a multikey.
* Note that this might match a regex tag
* @param tag
* @param properties
* @constructor
*/
static MatchesMultiAnswer(tag: TagsFilter, properties: any): boolean {
const splitted = TagUtils.SplitKeys([tag], true);
for (const splitKey in splitted) {
const neededValues = splitted[splitKey];
if (tags[splitKey] === undefined) {
if (properties[splitKey] === undefined) {
return false;
}
const actualValue = tags[splitKey].split(";");
const actualValue = properties[splitKey].split(";");
for (const neededValue of neededValues) {
if(neededValue instanceof RegexTag) {
if(!neededValue.matchesProperties(properties)) {
return false
}
continue
}
if (actualValue.indexOf(neededValue) < 0) {
return false;
}

View file

@ -1 +0,0 @@
,pietervdvn,pietervdvn-Latitude-5591,07.09.2021 18:13,file:///home/pietervdvn/.config/libreoffice/4;

View file

@ -13,7 +13,9 @@
"osmTags": {
"or": [
"amenity=charging_station",
"disused:amenity=charging_station"
"disused:amenity=charging_station",
"planned:amenity=charging_station",
"construction:amenity=charging_station"
]
}
},
@ -153,45 +155,135 @@
]
}
},
{
"if": {
"and": [
"socket:schuko~*",
"socket:schuko!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/CEE7_4F.svg'/> <b>Schuko wall plug</b> without ground pin (CEE7/4 type F)",
"hideInAnswer": true
},
{
"if": "socket:typee=1",
"ifnot": "socket:typee=",
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/TypeE.svg'/> <b>European wall plug</b> with ground pin (CEE7/4 type E)"
},
{
"if": {
"and": [
"socket:typee~*",
"socket:typee!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/TypeE.svg'/> <b>European wall plug</b> with ground pin (CEE7/4 type E)",
"hideInAnswer": true
},
{
"if": "socket:chademo=1",
"ifnot": "socket:chademo=",
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Chademo_type4.svg'/> <b>Chademo</b>"
},
{
"if": {
"and": [
"socket:chademo~*",
"socket:chademo!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Chademo_type4.svg'/> <b>Chademo</b>",
"hideInAnswer": true
},
{
"if": "socket:type1_cable=1",
"ifnot": "socket:type1_cable=",
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> <b>Type 1 with cable</b> (J1772)"
},
{
"if": {
"and": [
"socket:type1_cable~*",
"socket:type1_cable!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> <b>Type 1 with cable</b> (J1772)",
"hideInAnswer": true
},
{
"if": "socket:type1=1",
"ifnot": "socket:type1=",
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> <b>Type 1 <i>without</i> cable</b> (J1772)"
},
{
"if": {
"and": [
"socket:type1~*",
"socket:type1!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> <b>Type 1 <i>without</i> cable</b> (J1772)",
"hideInAnswer": true
},
{
"if": "socket:type1_combo=1",
"ifnot": "socket:type1_combo=",
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1-ccs.svg'/> <b>Type 1 CCS</b> (aka Type 1 Combo)"
},
{
"if": {
"and": [
"socket:type1_combo~*",
"socket:type1_combo!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1-ccs.svg'/> <b>Type 1 CCS</b> (aka Type 1 Combo)",
"hideInAnswer": true
},
{
"if": "socket:tesla_supercharger=1",
"ifnot": "socket:tesla_supercharger=",
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> <b>Tesla Supercharger</b>"
},
{
"if": {
"and": [
"socket:tesla_supercharger~*",
"socket:tesla_supercharger!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> <b>Tesla Supercharger</b>",
"hideInAnswer": true
},
{
"if": "socket:type2=1",
"ifnot": "socket:type2=",
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_socket.svg'/> <b>Type 2</b> (mennekes)"
},
{
"if": {
"and": [
"socket:type2~*",
"socket:type2!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_socket.svg'/> <b>Type 2</b> (mennekes)",
"hideInAnswer": true
},
{
"if": "socket:type2_combo=1",
"ifnot": "socket:type2_combo=",
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_CCS.svg'/> <b>Type 2 CCS</b> (mennekes)"
},
{
"if": {
"and": [
"socket:type2_combo~*",
"socket:type2_combo!=1"
]
},
"then": "<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_CCS.svg'/> <b>Type 2 CCS</b> (mennekes)",
"hideInAnswer": true
}
]
},
@ -199,7 +291,7 @@
"question": {
"en": "How much plugs of type <b>Schuko wall plug</b> without ground pin (CEE7/4 type F) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/CEE7_4F.svg'/> are available here?"
},
"render": "There are <b>{socket:schuko}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/CEE7_4F.svg'/> plugs of type <b>Schuko wall plug</b> without ground pin (CEE7/4 type F) available here",
"render": "There are <b>{socket:schuko}</b> <img style='width:1rem' src='./assets/layers/charging_station/CEE7_4F.svg'/> plugs of type <b>Schuko wall plug</b> without ground pin (CEE7/4 type F) available here",
"freeform": {
"key": "socket:schuko",
"type": "pnat"
@ -210,7 +302,7 @@
"question": {
"en": "How much plugs of type <b>European wall plug</b> with ground pin (CEE7/4 type E) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/TypeE.svg'/> are available here?"
},
"render": "There are <b>{socket:typee}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/TypeE.svg'/> plugs of type <b>European wall plug</b> with ground pin (CEE7/4 type E) available here",
"render": "There are <b>{socket:typee}</b> <img style='width:1rem' src='./assets/layers/charging_station/TypeE.svg'/> plugs of type <b>European wall plug</b> with ground pin (CEE7/4 type E) available here",
"freeform": {
"key": "socket:typee",
"type": "pnat"
@ -221,7 +313,7 @@
"question": {
"en": "How much plugs of type <b>Chademo</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Chademo_type4.svg'/> are available here?"
},
"render": "There are <b>{socket:chademo}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Chademo_type4.svg'/> plugs of type <b>Chademo</b> available here",
"render": "There are <b>{socket:chademo}</b> <img style='width:1rem' src='./assets/layers/charging_station/Chademo_type4.svg'/> plugs of type <b>Chademo</b> available here",
"freeform": {
"key": "socket:chademo",
"type": "pnat"
@ -232,7 +324,7 @@
"question": {
"en": "How much plugs of type <b>Type 1 with cable</b> (J1772) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> are available here?"
},
"render": "There are <b>{socket:type1_cable}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> plugs of type <b>Type 1 with cable</b> (J1772) available here",
"render": "There are <b>{socket:type1_cable}</b> <img style='width:1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> plugs of type <b>Type 1 with cable</b> (J1772) available here",
"freeform": {
"key": "socket:type1_cable",
"type": "pnat"
@ -243,7 +335,7 @@
"question": {
"en": "How much plugs of type <b>Type 1 <i>without</i> cable</b> (J1772) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> are available here?"
},
"render": "There are <b>{socket:type1}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> plugs of type <b>Type 1 <i>without</i> cable</b> (J1772) available here",
"render": "There are <b>{socket:type1}</b> <img style='width:1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> plugs of type <b>Type 1 <i>without</i> cable</b> (J1772) available here",
"freeform": {
"key": "socket:type1",
"type": "pnat"
@ -254,7 +346,7 @@
"question": {
"en": "How much plugs of type <b>Type 1 CCS</b> (aka Type 1 Combo) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1-ccs.svg'/> are available here?"
},
"render": "There are <b>{socket:type1_combo}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1-ccs.svg'/> plugs of type <b>Type 1 CCS</b> (aka Type 1 Combo) available here",
"render": "There are <b>{socket:type1_combo}</b> <img style='width:1rem' src='./assets/layers/charging_station/Type1-ccs.svg'/> plugs of type <b>Type 1 CCS</b> (aka Type 1 Combo) available here",
"freeform": {
"key": "socket:type1_combo",
"type": "pnat"
@ -265,7 +357,7 @@
"question": {
"en": "How much plugs of type <b>Tesla Supercharger</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> are available here?"
},
"render": "There are <b>{socket:tesla_supercharger}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> plugs of type <b>Tesla Supercharger</b> available here",
"render": "There are <b>{socket:tesla_supercharger}</b> <img style='width:1rem' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> plugs of type <b>Tesla Supercharger</b> available here",
"freeform": {
"key": "socket:tesla_supercharger",
"type": "pnat"
@ -276,7 +368,7 @@
"question": {
"en": "How much plugs of type <b>Type 2</b> (mennekes) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_socket.svg'/> are available here?"
},
"render": "There are <b>{socket:type2}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_socket.svg'/> plugs of type <b>Type 2</b> (mennekes) available here",
"render": "There are <b>{socket:type2}</b> <img style='width:1rem' src='./assets/layers/charging_station/Type2_socket.svg'/> plugs of type <b>Type 2</b> (mennekes) available here",
"freeform": {
"key": "socket:type2",
"type": "pnat"
@ -287,7 +379,7 @@
"question": {
"en": "How much plugs of type <b>Type 2 CCS</b> (mennekes) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_CCS.svg'/> are available here?"
},
"render": "There are <b>{socket:type2_combo}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_CCS.svg'/> plugs of type <b>Type 2 CCS</b> (mennekes) available here",
"render": "There are <b>{socket:type2_combo}</b> <img style='width:1rem' src='./assets/layers/charging_station/Type2_CCS.svg'/> plugs of type <b>Type 2 CCS</b> (mennekes) available here",
"freeform": {
"key": "socket:type2_combo",
"type": "pnat"
@ -444,37 +536,28 @@
},
"mappings": [
{
"if": {
"and": [
"no:network=yes"
]
},
"if": "no:network=yes",
"then": {
"en": "Not part of a bigger network"
}
},
{
"if": {
"and": [
"network=AeroVironment"
]
"if": "network=none",
"then": {
"en": "Not part of a bigger network"
},
"hideInAnswer": true
},
{
"if": "network=AeroVironment",
"then": "AeroVironment"
},
{
"if": {
"and": [
"network=Blink"
]
},
"if": "network=Blink",
"then": "Blink"
},
{
"if": {
"and": [
"network=eVgo"
]
},
"if": "network=eVgo",
"then": "eVgo"
}
]
@ -501,6 +584,55 @@
}
]
},
{
"#": "phone",
"question": {
"en": "What number can one call if there is a problem with this charging station?"
},
"render": {
"en": "In case of problems, call <a href='tel:{phone}'>{phone}</a>"
},
"freeform": {
"key": "phone",
"type": "phone"
}
},
{
"#": "email",
"question": {
"en": "What is the email address of the operator?"
},
"render": {
"en": "In case of problems, send an email to <a href='mailto:{email}'>{email}</a>"
},
"freeform": {
"key": "email",
"type": "email"
}
},
{
"#": "website",
"question": {
"en": "What is the website of the operator?"
},
"render": {
"en": "More info on <a href='{website}'>{website}</a>"
},
"freeform": {
"key": "website",
"type": "url"
}
},
{
"#": "ref",
"question": {
"en": "What is the reference number of this charging station?"
},
"render": "Reference number is <b>{ref}</b>",
"freeform": {
"key": "ref"
}
},
{
"#": "Operational status",
"question": {
@ -508,13 +640,6 @@
"nl": "Is dit oplaadpunt operationeel?"
},
"mappings": [
{
"if": "operational_status=",
"then": {
"en": "This charging station works",
"nl": "Dit oplaadpunt werkt"
}
},
{
"if": "operational_status=broken",
"then": {
@ -522,6 +647,30 @@
"nl": "Dit oplaadpunt is kapot"
}
},
{
"if": {
"and": [
"planned:amenity=charging_station",
"amenity="
]
},
"then": {
"en": "A charging station is planned here",
"nl": "Hier zal binnenkort een oplaadpunt gebouwd worden"
}
},
{
"if": {
"and": [
"construction:amenity=charging_station",
"amenity="
]
},
"then": {
"en": "A charging station is constructed here",
"nl": "Hier wordt op dit moment een oplaadpunt gebouwd"
}
},
{
"if": {
"and": [
@ -533,6 +682,13 @@
"en": "This charging station has beed permanently disabled and is not in use anymore but is still visible",
"nl": "Dit oplaadpunt is niet meer in gebruik maar is wel nog aanwezig"
}
},
{
"if": "amenity=charging_station",
"then": {
"en": "This charging station works",
"nl": "Dit oplaadpunt werkt"
}
}
]
}
@ -565,6 +721,16 @@
},
"then": "cross_bottom_right:#c22;"
},
{
"if": {
"or": [
"proposed:amenity=charging_station",
"planned:amenity=charging_station"
]
},
"then": "./assets/layers/charging_station/under_construction.svg",
"badge": true
},
{
"if": {
"and": [
@ -631,45 +797,60 @@
}
]
},
{
"options": [
{
"question": {
"en": "Only working charging stations"
},
"osmTags": {
"and": [
"operational_status!=broken",
"amenity=charging_station"
]
}
}
]
},
{
"options": [
{
"question": "All connectors"
},
{
"question": "Has a <b>Schuko wall plug</b> without ground pin (CEE7/4 type F) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/CEE7_4F.svg'/> connector",
"question": "Has a <b>Schuko wall plug</b> without ground pin (CEE7/4 type F) <img style='width:1rem' src='./assets/layers/charging_station/CEE7_4F.svg'/> connector",
"osmTags": "socket:schuko~*"
},
{
"question": "Has a <b>European wall plug</b> with ground pin (CEE7/4 type E) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/TypeE.svg'/> connector",
"question": "Has a <b>European wall plug</b> with ground pin (CEE7/4 type E) <img style='width:1rem' src='./assets/layers/charging_station/TypeE.svg'/> connector",
"osmTags": "socket:typee~*"
},
{
"question": "Has a <b>Chademo</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Chademo_type4.svg'/> connector",
"question": "Has a <b>Chademo</b> <img style='width:1rem' src='./assets/layers/charging_station/Chademo_type4.svg'/> connector",
"osmTags": "socket:chademo~*"
},
{
"question": "Has a <b>Type 1 with cable</b> (J1772) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> connector",
"question": "Has a <b>Type 1 with cable</b> (J1772) <img style='width:1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> connector",
"osmTags": "socket:type1_cable~*"
},
{
"question": "Has a <b>Type 1 <i>without</i> cable</b> (J1772) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> connector",
"question": "Has a <b>Type 1 <i>without</i> cable</b> (J1772) <img style='width:1rem' src='./assets/layers/charging_station/Type1_J1772.svg'/> connector",
"osmTags": "socket:type1~*"
},
{
"question": "Has a <b>Type 1 CCS</b> (aka Type 1 Combo) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type1-ccs.svg'/> connector",
"question": "Has a <b>Type 1 CCS</b> (aka Type 1 Combo) <img style='width:1rem' src='./assets/layers/charging_station/Type1-ccs.svg'/> connector",
"osmTags": "socket:type1_combo~*"
},
{
"question": "Has a <b>Tesla Supercharger</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> connector",
"question": "Has a <b>Tesla Supercharger</b> <img style='width:1rem' src='./assets/layers/charging_station/Tesla-hpwc-model-s.svg'/> connector",
"osmTags": "socket:tesla_supercharger~*"
},
{
"question": "Has a <b>Type 2</b> (mennekes) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_socket.svg'/> connector",
"question": "Has a <b>Type 2</b> (mennekes) <img style='width:1rem' src='./assets/layers/charging_station/Type2_socket.svg'/> connector",
"osmTags": "socket:type2~*"
},
{
"question": "Has a <b>Type 2 CCS</b> (mennekes) <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/Type2_CCS.svg'/> connector",
"question": "Has a <b>Type 2 CCS</b> (mennekes) <img style='width:1rem' src='./assets/layers/charging_station/Type2_CCS.svg'/> connector",
"osmTags": "socket:type2_combo~*"
}
]

View file

@ -13,7 +13,9 @@
"osmTags": {
"or": [
"amenity=charging_station",
"disused:amenity=charging_station"
"disused:amenity=charging_station",
"planned:amenity=charging_station",
"construction:amenity=charging_station"
]
}
},
@ -288,37 +290,28 @@
},
"mappings": [
{
"if": {
"and": [
"no:network=yes"
]
},
"if": "no:network=yes",
"then": {
"en": "Not part of a bigger network"
}
},
{
"if": {
"and": [
"network=AeroVironment"
]
"if": "network=none",
"then": {
"en": "Not part of a bigger network"
},
"hideInAnswer": true
},
{
"if": "network=AeroVironment",
"then": "AeroVironment"
},
{
"if": {
"and": [
"network=Blink"
]
},
"if": "network=Blink",
"then": "Blink"
},
{
"if": {
"and": [
"network=eVgo"
]
},
"if": "network=eVgo",
"then": "eVgo"
}
]
@ -345,6 +338,52 @@
}
]
},
{"#": "phone",
"question": {
"en": "What number can one call if there is a problem with this charging station?"
},
"render": {
"en": "In case of problems, call <a href='tel:{phone}'>{phone}</a>"
},
"freeform": {
"key": "phone",
"type": "phone"
}
},
{"#": "email",
"question": {
"en": "What is the email address of the operator?"
},
"render": {
"en": "In case of problems, send an email to <a href='mailto:{email}'>{email}</a>"
},
"freeform": {
"key": "email",
"type": "email"
}
},
{"#": "website",
"question": {
"en": "What is the website of the operator?"
},
"render": {
"en": "More info on <a href='{website}'>{website}</a>"
},
"freeform": {
"key": "website",
"type": "url"
}
},
{
"#": "ref",
"question": {
"en": "What is the reference number of this charging station?"
},
"render": "Reference number is <b>{ref}</b>",
"freeform": {
"key": "ref"
}
},
{
"#": "Operational status",
"question": {
@ -352,13 +391,6 @@
"nl": "Is dit oplaadpunt operationeel?"
},
"mappings": [
{
"if": "operational_status=",
"then": {
"en": "This charging station works",
"nl": "Dit oplaadpunt werkt"
}
},
{
"if": "operational_status=broken",
"then": {
@ -366,6 +398,30 @@
"nl": "Dit oplaadpunt is kapot"
}
},
{
"if": {
"and": [
"planned:amenity=charging_station",
"amenity="
]
},
"then": {
"en": "A charging station is planned here",
"nl": "Hier zal binnenkort een oplaadpunt gebouwd worden"
}
},
{
"if": {
"and": [
"construction:amenity=charging_station",
"amenity="
]
},
"then": {
"en": "A charging station is constructed here",
"nl": "Hier wordt op dit moment een oplaadpunt gebouwd"
}
},
{
"if": {
"and": [
@ -377,6 +433,13 @@
"en": "This charging station has beed permanently disabled and is not in use anymore but is still visible",
"nl": "Dit oplaadpunt is niet meer in gebruik maar is wel nog aanwezig"
}
},
{
"if": "amenity=charging_station",
"then": {
"en": "This charging station works",
"nl": "Dit oplaadpunt werkt"
}
}
]
}
@ -402,10 +465,23 @@
"iconOverlays": [
{
"if": {
"or": ["disused:amenity=charging_station","operational_status=broken"]
"or": [
"disused:amenity=charging_station",
"operational_status=broken"
]
},
"then": "cross_bottom_right:#c22;"
},
{
"if": {
"or": [
"proposed:amenity=charging_station",
"planned:amenity=charging_station"
]
},
"then": "./assets/layers/charging_station/under_construction.svg",
"badge": true
},
{
"if": {
"and": [
@ -471,6 +547,21 @@
}
}
]
},
{
"options": [
{
"question": {
"en": "Only working charging stations"
},
"osmTags": {
"and": [
"operational_status!=broken",
"amenity=charging_station"
]
}
}
]
}
]
}

View file

@ -6,7 +6,7 @@ function run(file, protojson) {
const entries: string[] = Utils.NoNull(readFileSync(file, "utf8").split("\n").map(str => str.trim()))
entries.shift()
const result = []
const overview_question_answers = []
const questions = []
const filterOptions: { question: string, osmTags?: string } [] = [
{
@ -20,27 +20,35 @@ function run(file, protojson) {
continue;
}
const txt = `<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/${image}'/> ${description}`
const json = {
if: `${key}=1`,
ifnot: `${key}=`,
then: `<img style='width:3rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/${image}'/> ${description}`,
then: txt,
}
if (whitelist) {
const countries = whitelist.split(";").map(country => "_country!=" + country) //HideInAnswer if it is in the wrong country
const countries = whitelist.replace(/"/g, '').split(",").map(country => "_country!=" + country) //HideInAnswer if it is in the wrong country
json["hideInAnswer"] = {or: countries}
}
result.push(json)
overview_question_answers.push(json)
// We add a second time for any amount to trigger a visualisation; but this is not an answer option
const no_ask_json = {
if: {and: [`${key}~*`,`${key}!=1`]
},
then: txt,
hideInAnswer: true
}
overview_question_answers.push(no_ask_json)
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?`
},
render: `There are <b>{${key}}</b> <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/${image}'/> plugs of type ${description} available here`,
render: `There are <b>{${key}}</b> <img style='width:1rem' src='./assets/layers/charging_station/${image}'/> plugs of type ${description} available here`,
freeform: {
key: key,
type: "pnat"
@ -52,7 +60,7 @@ function run(file, protojson) {
questions.push(indivQ)
filterOptions.push({
question: `Has a ${description} <img style='width:1rem; margin-left: 1rem; margin-right: 1rem' src='./assets/layers/charging_station/${image}'/> connector`,
question: `Has a ${description} <img style='width:1rem' src='./assets/layers/charging_station/${image}'/> connector`,
osmTags: `${key}~*`
})
}
@ -62,7 +70,7 @@ function run(file, protojson) {
"en": "Which charging stations are available here?"
},
"multiAnswer": true,
"mappings": result
"mappings": overview_question_answers
}
questions.unshift(toggles)

View file

@ -98,5 +98,15 @@
"sources": [
"https://commons.wikimedia.org/wiki/File:Type3c.svg"
]
},
{
"path": "under_construction.svg",
"license": "Public domain",
"authors": [
"Sarang"
],
"sources": [
"https://upload.wikimedia.org/wikipedia/commons/2/20/UnderCon_icon.svg"
]
}
]

View file

@ -1,5 +1,5 @@
Key in OSM,image,Description,Country-whitelist,,,,,,,
socket:schuko,CEE7_4F.svg,<b>Schuko wall plug</b> without ground pin (CEE7/4 type F),be,fr,ma,tn,pl,cs,sk,mo
socket:schuko,CEE7_4F.svg,<b>Schuko wall plug</b> without ground pin (CEE7/4 type F),"be,fr,ma,tn,pl,cs,sk,mo"
socket:typee,TypeE.svg,<b>European wall plug</b> with ground pin (CEE7/4 type E),,,,,,,,
socket:chademo,Chademo_type4.svg,<b>Chademo</b>,,,,,,,,
socket:type1_cable,Type1_J1772.svg,<b>Type 1 with cable</b> (J1772),,,,,,,,

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="184.99873"
height="160.99916"
version="1.1"
id="svg8"
sodipodi:docname="under_construction.svg"
style="stroke-linejoin:round"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1043"
id="namedview10"
showgrid="false"
inkscape:zoom="3.7083822"
inkscape:cx="84.786789"
inkscape:cy="27.5718"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg8" />
<path
d="M 92.49937,8.4991633 8.4993703,152.49916 H 176.49937 Z"
id="path4"
inkscape:connector-curvature="0"
style="fill:#ffffff;stroke:#cc0000;stroke-width:17" />
<path
d="m 93.970423,112.12145 a 2.1244582,2.1244582 0 0 1 -3.186687,1.06223 l -2.124459,-3.18669 V 93.00133 l -6.373374,10.62229 -11.68452,-6.373373 9.560062,-19.120124 H 73.78807 L 65.290237,93.00133 62.10355,89.814643 v -3.186687 l 8.497833,-14.871207 h 21.244582 a 4.2489163,4.2489163 0 0 1 4.248916,4.248916 z m 16.995667,12.74675 -43.551394,-36.115786 1.062229,-3.186687 44.613625,37.178013 8.49783,-10.62229 a 5.3111454,5.3111454 0 0 1 9.56006,0 l 23.36904,30.80464 H 93.970423 L 107.7794,125.93043 Z m -29.742416,-19.12012 7.435603,10.62229 1.062229,26.55572 a 8.4978327,8.4978327 0 0 1 -6.373374,-4.24891 l -1.062229,-18.0579 -8.497833,-11.68452 -19.120123,32.92911 a 4.2489163,4.2489163 0 0 1 -2.124459,-2.12446 L 51.481259,133.36603 69.539154,99.374705 Z M 95.032652,67.507832 a 7.435604,7.435604 0 0 1 14.871208,0 7.435604,7.435604 0 0 1 -14.871208,0"
id="path6"
inkscape:connector-curvature="0"
style="stroke-width:1.06222904" />
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -33,7 +33,8 @@
"reset:layeroverview": "echo {\\\"layers\\\":[], \\\"themes\\\":[]} > ./assets/generated/known_layers_and_themes.json",
"generate": "mkdir -p ./assets/generated && npm run reset:layeroverview && npm run generate:images && npm run generate:translations && npm run generate:layeroverview",
"build": "rm -rf dist/ && npm run generate && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*",
"prepare-deploy": "npm run generate && npm run test && npm run generate:editor-layer-index && npm run generate:layeroverview && npm run generate:layouts && npm run build && rm -rf .cache",
"generate:charging-stations": "cd ./assets/layers/charging_station && ts-node csvToJson.ts && cd -",
"prepare-deploy": "npm run generate && npm run test && npm run generate:editor-layer-index && npm run generate:charging-stations && npm run generate:layeroverview && npm run generate:layouts && npm run build && rm -rf .cache",
"deploy:staging": "npm run prepare-deploy && rm -rf ~/git/pietervdvn.github.io/Staging/* && cp -r dist/* ~/git/pietervdvn.github.io/Staging/ && cd ~/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean",
"deploy:pietervdvn": "cd ~/git/pietervdvn.github.io/ && git pull && cd - && npm run prepare-deploy && rm -rf ~/git/pietervdvn.github.io/MapComplete/* && cp -r dist/* ~/git/pietervdvn.github.io/MapComplete/ && cd ~/git/pietervdvn.github.io/ && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean",
"deploy:production": "cd ~/git/mapcomplete.github.io/ && git pull && cd - && rm -rf ./assets/generated && npm run prepare-deploy && npm run optimize-images && rm -rf ~/git/mapcomplete.github.io/* && cp -r dist/* ~/git/mapcomplete.github.io/ && cd ~/git/mapcomplete.github.io/ && echo \"mapcomplete.osm.be\" > CNAME && git add * && git commit -m 'New MapComplete Version' && git push && cd - && npm run clean && npm run gittag",