forked from MapComplete/MapComplete
Stricter layer checking
This commit is contained in:
parent
18c53af27f
commit
3334e0d384
5 changed files with 42 additions and 258 deletions
|
@ -37,6 +37,8 @@ export default class SharedTagRenderings {
|
|||
for (const key in icons) {
|
||||
dict.set(key, <TagRenderingConfigJson>icons[key])
|
||||
}
|
||||
|
||||
dict.forEach((value, key) => value.id = key)
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import {Utils} from "../Utils";
|
|||
|
||||
export default class Constants {
|
||||
|
||||
public static vNumber = "0.12.1";
|
||||
public static vNumber = "0.12.2";
|
||||
public static ImgurApiKey = '7070e7167f0a25a'
|
||||
public static readonly mapillary_client_token_v3 = 'TXhLaWthQ1d4RUg0czVxaTVoRjFJZzowNDczNjUzNmIyNTQyYzI2'
|
||||
public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
|
||||
|
|
|
@ -21,6 +21,7 @@ import Combine from "../../UI/Base/Combine";
|
|||
import Title from "../../UI/Base/Title";
|
||||
import List from "../../UI/Base/List";
|
||||
import Link from "../../UI/Base/Link";
|
||||
import {Utils} from "../../Utils";
|
||||
|
||||
export default class LayerConfig extends WithContextLoader {
|
||||
|
||||
|
@ -203,19 +204,38 @@ export default class LayerConfig extends WithContextLoader {
|
|||
.filter(r => r["location"] === undefined)
|
||||
.map((r, i) => new LineRenderingConfig(<LineRenderingConfigJson>r, context + ".mapRendering[" + i + "]"))
|
||||
|
||||
|
||||
this.tagRenderings = this.ExtractLayerTagRenderings(json)
|
||||
const missingIds = json.tagRenderings?.filter(tr => typeof tr !== "string" && tr["builtin"] === undefined && tr["id"] === undefined && tr["rewrite"] === undefined) ?? [];
|
||||
|
||||
if (missingIds.length > 0 && official) {
|
||||
if (missingIds?.length > 0 && official) {
|
||||
console.error("Some tagRenderings of", this.id, "are missing an id:", missingIds)
|
||||
throw "Missing ids in tagrenderings"
|
||||
}
|
||||
|
||||
this.tagRenderings = this.ExtractLayerTagRenderings(json)
|
||||
{
|
||||
|
||||
|
||||
const emptyIds = this.tagRenderings.filter(tr => tr.id === "");
|
||||
if (emptyIds.length > 0) {
|
||||
throw `Some tagrendering-ids are empty or have an emtpy string; this is not allowed (at ${context})`
|
||||
}
|
||||
|
||||
const duplicateIds = Utils.Dupicates(this.tagRenderings.map(f => f.id).filter(id => id !== "questions"))
|
||||
if (duplicateIds.length > 0) {
|
||||
throw `Some tagRenderings have a duplicate id: ${duplicateIds} (at ${context}.tagRenderings)`
|
||||
}
|
||||
}
|
||||
|
||||
this.filters = (json.filter ?? []).map((option, i) => {
|
||||
return new FilterConfig(option, `${context}.filter-[${i}]`)
|
||||
});
|
||||
|
||||
{
|
||||
const duplicateIds = Utils.Dupicates(this.filters.map(f => f.id))
|
||||
if (duplicateIds.length > 0) {
|
||||
throw `Some filters have a duplicate id: ${duplicateIds} (at ${context}.filters)`
|
||||
}
|
||||
}
|
||||
|
||||
if (json["filters"] !== undefined) {
|
||||
throw "Error in " + context + ": use 'filter' instead of 'filters'"
|
||||
}
|
||||
|
|
15
Utils.ts
15
Utils.ts
|
@ -144,6 +144,21 @@ Note that these values can be prepare with javascript in the theme by using a [c
|
|||
return newArr;
|
||||
}
|
||||
|
||||
public static Dupicates(arr: string[]): string[] {
|
||||
if (arr === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const newArr = [];
|
||||
const seen = new Set<string>();
|
||||
for (const string of arr) {
|
||||
if(seen.has(string)){
|
||||
newArr.push(string)
|
||||
}
|
||||
seen.add(string)
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
|
||||
public static Identical<T>(t1: T[], t2: T[], eq?: (t: T, t0: T) => boolean): boolean {
|
||||
if (t1.length !== t2.length) {
|
||||
return false
|
||||
|
|
|
@ -148,246 +148,6 @@
|
|||
],
|
||||
"id": "toilet-access"
|
||||
},
|
||||
{
|
||||
"question": {
|
||||
"en": "Are these toilets publicly accessible?",
|
||||
"de": "Sind diese Toiletten öffentlich zugänglich?",
|
||||
"fr": "Ces toilettes sont-elles accessibles au public ?",
|
||||
"nl": "Zijn deze toiletten publiek toegankelijk?",
|
||||
"it": "Questi servizi igienici sono aperti al pubblico?",
|
||||
"ru": "Есть ли свободный доступ к этим туалетам?"
|
||||
},
|
||||
"render": {
|
||||
"en": "Access is {access}",
|
||||
"de": "Zugang ist {access}",
|
||||
"fr": "L'accès est {access}",
|
||||
"nl": "Toegankelijkheid is {access}",
|
||||
"it": "L'accesso è {access}"
|
||||
},
|
||||
"freeform": {
|
||||
"key": "access",
|
||||
"addExtraTags": [
|
||||
"fixme=the tag access was filled out by the user and might need refinement"
|
||||
]
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"if": "access=yes",
|
||||
"then": {
|
||||
"en": "Public access",
|
||||
"de": "Öffentlicher Zugang",
|
||||
"fr": "Accès publique",
|
||||
"nl": "Publiek toegankelijk",
|
||||
"it": "Accesso pubblico",
|
||||
"ru": "Свободный доступ"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=customers",
|
||||
"then": {
|
||||
"en": "Only access to customers",
|
||||
"de": "Nur Zugang für Kunden",
|
||||
"fr": "Accès réservé aux clients",
|
||||
"nl": "Enkel toegang voor klanten",
|
||||
"it": "Accesso riservato ai clienti e alle clienti"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=no",
|
||||
"then": {
|
||||
"en": "Not accessible",
|
||||
"de": "Nicht zugänglich",
|
||||
"fr": "Toilettes privées",
|
||||
"nl": "Niet toegankelijk",
|
||||
"ru": "Недоступно",
|
||||
"it": "Non accessibile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=key",
|
||||
"then": {
|
||||
"en": "Accessible, but one has to ask a key to enter",
|
||||
"de": "Zugänglich, aber man muss einen Schlüssel für die Eingabe verlangen",
|
||||
"fr": "Accessible, mais vous devez demander la clé",
|
||||
"nl": "Toegankelijk na het vragen van de sleutel",
|
||||
"it": "Accessibile, ma occorre chiedere una chiave per accedere"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=public",
|
||||
"then": {
|
||||
"en": "Public access",
|
||||
"de": "Öffentlicher Zugang",
|
||||
"fr": "Accès publique",
|
||||
"nl": "Publiek toegankelijk",
|
||||
"it": "Accesso pubblico",
|
||||
"ru": "Свободный доступ"
|
||||
},
|
||||
"hideInAnswer": true
|
||||
}
|
||||
],
|
||||
"id": "toilet-access"
|
||||
},
|
||||
{
|
||||
"question": {
|
||||
"en": "Are these toilets publicly accessible?",
|
||||
"de": "Sind diese Toiletten öffentlich zugänglich?",
|
||||
"fr": "Ces toilettes sont-elles accessibles au public ?",
|
||||
"nl": "Zijn deze toiletten publiek toegankelijk?",
|
||||
"it": "Questi servizi igienici sono aperti al pubblico?",
|
||||
"ru": "Есть ли свободный доступ к этим туалетам?"
|
||||
},
|
||||
"render": {
|
||||
"en": "Access is {access}",
|
||||
"de": "Zugang ist {access}",
|
||||
"fr": "L'accès est {access}",
|
||||
"nl": "Toegankelijkheid is {access}",
|
||||
"it": "L'accesso è {access}"
|
||||
},
|
||||
"freeform": {
|
||||
"key": "access",
|
||||
"addExtraTags": [
|
||||
"fixme=the tag access was filled out by the user and might need refinement"
|
||||
]
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"if": "access=yes",
|
||||
"then": {
|
||||
"en": "Public access",
|
||||
"de": "Öffentlicher Zugang",
|
||||
"fr": "Accès publique",
|
||||
"nl": "Publiek toegankelijk",
|
||||
"it": "Accesso pubblico",
|
||||
"ru": "Свободный доступ"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=customers",
|
||||
"then": {
|
||||
"en": "Only access to customers",
|
||||
"de": "Nur Zugang für Kunden",
|
||||
"fr": "Accès réservé aux clients",
|
||||
"nl": "Enkel toegang voor klanten",
|
||||
"it": "Accesso riservato ai clienti e alle clienti"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=no",
|
||||
"then": {
|
||||
"en": "Not accessible",
|
||||
"de": "Nicht zugänglich",
|
||||
"fr": "Toilettes privées",
|
||||
"nl": "Niet toegankelijk",
|
||||
"ru": "Недоступно",
|
||||
"it": "Non accessibile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=key",
|
||||
"then": {
|
||||
"en": "Accessible, but one has to ask a key to enter",
|
||||
"de": "Zugänglich, aber man muss einen Schlüssel für die Eingabe verlangen",
|
||||
"fr": "Accessible, mais vous devez demander la clé",
|
||||
"nl": "Toegankelijk na het vragen van de sleutel",
|
||||
"it": "Accessibile, ma occorre chiedere una chiave per accedere"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=public",
|
||||
"then": {
|
||||
"en": "Public access",
|
||||
"de": "Öffentlicher Zugang",
|
||||
"fr": "Accès publique",
|
||||
"nl": "Publiek toegankelijk",
|
||||
"it": "Accesso pubblico",
|
||||
"ru": "Свободный доступ"
|
||||
},
|
||||
"hideInAnswer": true
|
||||
}
|
||||
],
|
||||
"id": "toilet-access"
|
||||
},
|
||||
{
|
||||
"question": {
|
||||
"en": "Are these toilets publicly accessible?",
|
||||
"de": "Sind diese Toiletten öffentlich zugänglich?",
|
||||
"fr": "Ces toilettes sont-elles accessibles au public ?",
|
||||
"nl": "Zijn deze toiletten publiek toegankelijk?",
|
||||
"it": "Questi servizi igienici sono aperti al pubblico?",
|
||||
"ru": "Есть ли свободный доступ к этим туалетам?"
|
||||
},
|
||||
"render": {
|
||||
"en": "Access is {access}",
|
||||
"de": "Zugang ist {access}",
|
||||
"fr": "L'accès est {access}",
|
||||
"nl": "Toegankelijkheid is {access}",
|
||||
"it": "L'accesso è {access}"
|
||||
},
|
||||
"freeform": {
|
||||
"key": "access",
|
||||
"addExtraTags": [
|
||||
"fixme=the tag access was filled out by the user and might need refinement"
|
||||
]
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"if": "access=yes",
|
||||
"then": {
|
||||
"en": "Public access",
|
||||
"de": "Öffentlicher Zugang",
|
||||
"fr": "Accès publique",
|
||||
"nl": "Publiek toegankelijk",
|
||||
"it": "Accesso pubblico",
|
||||
"ru": "Свободный доступ"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=customers",
|
||||
"then": {
|
||||
"en": "Only access to customers",
|
||||
"de": "Nur Zugang für Kunden",
|
||||
"fr": "Accès réservé aux clients",
|
||||
"nl": "Enkel toegang voor klanten",
|
||||
"it": "Accesso riservato ai clienti e alle clienti"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=no",
|
||||
"then": {
|
||||
"en": "Not accessible",
|
||||
"de": "Nicht zugänglich",
|
||||
"fr": "Toilettes privées",
|
||||
"nl": "Niet toegankelijk",
|
||||
"ru": "Недоступно",
|
||||
"it": "Non accessibile"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=key",
|
||||
"then": {
|
||||
"en": "Accessible, but one has to ask a key to enter",
|
||||
"de": "Zugänglich, aber man muss einen Schlüssel für die Eingabe verlangen",
|
||||
"fr": "Accessible, mais vous devez demander la clé",
|
||||
"nl": "Toegankelijk na het vragen van de sleutel",
|
||||
"it": "Accessibile, ma occorre chiedere una chiave per accedere"
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": "access=public",
|
||||
"then": {
|
||||
"en": "Public access",
|
||||
"de": "Öffentlicher Zugang",
|
||||
"fr": "Accès publique",
|
||||
"nl": "Publiek toegankelijk",
|
||||
"it": "Accesso pubblico",
|
||||
"ru": "Свободный доступ"
|
||||
},
|
||||
"hideInAnswer": true
|
||||
}
|
||||
],
|
||||
"id": "toilet-access"
|
||||
},
|
||||
{
|
||||
"id": "toilets-fee",
|
||||
"question": {
|
||||
|
@ -679,19 +439,6 @@
|
|||
}
|
||||
],
|
||||
"filter": [
|
||||
{
|
||||
"id": "wheelchair",
|
||||
"options": [
|
||||
{
|
||||
"question": {
|
||||
"en": "Wheelchair accessible",
|
||||
"nl": "Rolstoel toegankelijk",
|
||||
"de": "Rollstuhlgerecht"
|
||||
},
|
||||
"osmTags": "wheelchair=yes"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "wheelchair",
|
||||
"options": [
|
||||
|
|
Loading…
Reference in a new issue