Move layers to canonical paths, rewrite some regexes as 'or' as to make the taginfo-information more accurate

This commit is contained in:
pietervdvn 2021-04-20 10:49:45 +02:00
parent 05b05a958c
commit ce9b0eabb1
42 changed files with 61 additions and 52 deletions

View file

@ -1,5 +1,5 @@
{ {
"id": "bike_cafes", "id": "bike_cafe",
"name": { "name": {
"en": "Bike cafe", "en": "Bike cafe",
"nl": "Fietscafé", "nl": "Fietscafé",
@ -11,7 +11,14 @@
"source": { "source": {
"osmTags": { "osmTags": {
"and": [ "and": [
"amenity~pub|bar|cafe|restaurant", {
"or": [
"amenity=pub",
"amenity=bar",
"amenity=cafe",
"amenity=restaurant"
]
},
{ {
"#": "Note the double tilde in 'service:bicycle' which interprets the key as regex too", "#": "Note the double tilde in 'service:bicycle' which interprets the key as regex too",
"or": [ "or": [

View file

@ -1,5 +1,5 @@
{ {
"id": "bike_shops", "id": "bike_shop",
"name": { "name": {
"en": "Bike repair/shop", "en": "Bike repair/shop",
"nl": "Fietszaak", "nl": "Fietszaak",

View file

@ -49,7 +49,7 @@
], ],
"hideUnderlayingFeaturesMinPercentage": 0, "hideUnderlayingFeaturesMinPercentage": 0,
"icon": { "icon": {
"render": "./assets/layers/cycling_themed_object/other_services.svg" "render": "./assets/layers/bike_themed_object/other_services.svg"
}, },
"width": { "width": {
"render": "2" "render": "2"

View file

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 995 B

View file

@ -1,5 +1,5 @@
{ {
"id": "birdhides", "id": "birdhide",
"name": { "name": {
"nl": "Vogelkijkhutten" "nl": "Vogelkijkhutten"
}, },
@ -178,7 +178,7 @@
], ],
"icon": { "icon": {
"render": { "render": {
"nl": "./assets/layers/bird_hide/birdhide.svg" "nl": "./assets/layers/birdhide/birdhide.svg"
}, },
"mappings": [ "mappings": [
{ {
@ -189,7 +189,7 @@
"amenity=shelter" "amenity=shelter"
] ]
}, },
"then": "./assets/layers/bird_hide/birdshelter.svg" "then": "./assets/layers/birdhide/birdshelter.svg"
} }
] ]
}, },

View file

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -1,5 +1,5 @@
{ {
"id": "information_boards", "id": "information_board",
"name": { "name": {
"nl": "Informatieborden", "nl": "Informatieborden",
"en": "Information boards" "en": "Information boards"

View file

Before

Width:  |  Height:  |  Size: 469 KiB

After

Width:  |  Height:  |  Size: 469 KiB

View file

@ -1,5 +1,5 @@
{ {
"id": "maps", "id": "map",
"name": { "name": {
"en": "Maps", "en": "Maps",
"nl": "Kaarten" "nl": "Kaarten"
@ -126,7 +126,7 @@
], ],
"hideUnderlayingFeaturesMinPercentage": 0, "hideUnderlayingFeaturesMinPercentage": 0,
"icon": { "icon": {
"render": "./assets/layers/maps/map.svg", "render": "./assets/layers/map/map.svg",
"mappings": [ "mappings": [
{ {
"if": { "if": {
@ -135,7 +135,7 @@
"map_source:attribution=sticker" "map_source:attribution=sticker"
] ]
}, },
"then": "./assets/layers/maps/map-stickered.svg" "then": "./assets/layers/map/map-stickered.svg"
}, },
{ {
"if": { "if": {
@ -144,7 +144,7 @@
"map_source:attribution=yes" "map_source:attribution=yes"
] ]
}, },
"then": "./assets/layers/maps/osm-logo-white-bg.svg" "then": "./assets/layers/map/osm-logo-white-bg.svg"
}, },
{ {
"if": { "if": {
@ -152,7 +152,7 @@
"map_source=OpenStreetMap" "map_source=OpenStreetMap"
] ]
}, },
"then": "./assets/layers/maps/osm-logo-buggy-attr.svg" "then": "./assets/layers/map/osm-logo-buggy-attr.svg"
} }
] ]
}, },

View file

Before

Width:  |  Height:  |  Size: 297 KiB

After

Width:  |  Height:  |  Size: 297 KiB

View file

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 159 KiB

View file

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 156 KiB

View file

@ -1,5 +1,5 @@
{ {
"id": "nature_reserves", "id": "nature_reserve",
"name": { "name": {
"nl": "Natuurgebied" "nl": "Natuurgebied"
}, },

View file

@ -1,5 +1,5 @@
{ {
"id": "picnic_tables", "id": "picnic_table",
"name": { "name": {
"en": "Picnic tables", "en": "Picnic tables",
"nl": "Picnictafels" "nl": "Picnictafels"
@ -51,7 +51,7 @@
], ],
"hideUnderlayingFeaturesMinPercentage": 0, "hideUnderlayingFeaturesMinPercentage": 0,
"icon": { "icon": {
"render": "circle:#e6cf39;./assets/layers/benches/picnic_table.svg" "render": "circle:#e6cf39;./assets/layers/picnic_table/picnic_table.svg"
}, },
"width": { "width": {
"render": "8" "render": "8"

View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -1,5 +1,5 @@
{ {
"id": "public_bookcases", "id": "public_bookcase",
"name": { "name": {
"en": "Bookcases", "en": "Bookcases",
"nl": "Boekenruilkastjes", "nl": "Boekenruilkastjes",

View file

@ -1,5 +1,5 @@
{ {
"id": "surveillance_cameras", "id": "surveillance_camera",
"name": { "name": {
"en": "Surveillance camera's", "en": "Surveillance camera's",
"nl": "Bewakingscamera's" "nl": "Bewakingscamera's"

View file

@ -1,5 +1,5 @@
{ {
"id": "toilets", "id": "toilet",
"name": { "name": {
"en": "Toilets", "en": "Toilets",
"de": "Toiletten", "de": "Toiletten",
@ -16,15 +16,15 @@
} }
}, },
"icon": { "icon": {
"render": "./assets/layers/toilets/toilets.svg", "render": "./assets/layers/toilet/toilets.svg",
"mappings": [ "mappings": [
{ {
"if": "wheelchair=yes", "if": "wheelchair=yes",
"then": "./assets/layers/toilets/wheelchair.svg" "then": "./assets/layers/toilet/wheelchair.svg"
}, },
{ {
"if": "toilets:position=urinals", "if": "toilets:position=urinals",
"then": "./assets/layers/toilets/urinal.svg" "then": "./assets/layers/toilet/urinal.svg"
} }
] ]
}, },

View file

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 700 B

View file

@ -1,5 +1,5 @@
{ {
"id": "tree_nodes", "id": "tree_node",
"name": { "name": {
"nl": "Boom", "nl": "Boom",
"en": "Tree" "en": "Tree"
@ -277,8 +277,8 @@
] ]
}, },
"then": { "then": {
"nl": "<img src=\"./assets/layers/trees/Onroerend_Erfgoed_logo_without_text.svg\" style=\"width:0.85em;height:1em;vertical-align:middle\" alt=\"\"/> Erkend als houtig erfgoed door Onroerend Erfgoed Vlaanderen", "nl": "<img src=\"./assets/layers/tree_node/Onroerend_Erfgoed_logo_without_text.svg\" style=\"width:0.85em;height:1em;vertical-align:middle\" alt=\"\"/> Erkend als houtig erfgoed door Onroerend Erfgoed Vlaanderen",
"en": "<img src=\"./assets/layers/trees/Onroerend_Erfgoed_logo_without_text.svg\" style=\"width:0.85em;height:1em;vertical-align:middle\" alt=\"\"/> Registered as heritage by <i>Onroerend Erfgoed</i> Flanders" "en": "<img src=\"./assets/layers/tree_node/Onroerend_Erfgoed_logo_without_text.svg\" style=\"width:0.85em;height:1em;vertical-align:middle\" alt=\"\"/> Registered as heritage by <i>Onroerend Erfgoed</i> Flanders"
} }
}, },
{ {
@ -339,8 +339,8 @@
}, },
{ {
"render": { "render": {
"nl": "<img src=\"./assets/layers/trees/Onroerend_Erfgoed_logo_without_text.svg\" style=\"width:0.85em;height:1em;vertical-align:middle\" alt=\"\"/> Onroerend Erfgoed-ID: <a href=\"https://id.erfgoed.net/erfgoedobjecten/{ref:OnroerendErfgoed}\">{ref:OnroerendErfgoed}</a>", "nl": "<img src=\"./assets/layers/tree_node/Onroerend_Erfgoed_logo_without_text.svg\" style=\"width:0.85em;height:1em;vertical-align:middle\" alt=\"\"/> Onroerend Erfgoed-ID: <a href=\"https://id.erfgoed.net/erfgoedobjecten/{ref:OnroerendErfgoed}\">{ref:OnroerendErfgoed}</a>",
"en": "<img src=\"./assets/layers/trees/Onroerend_Erfgoed_logo_without_text.svg\" style=\"width:0.85em;height:1em;vertical-align:middle\" alt=\"\"/> Onroerend Erfgoed ID: <a href=\"https://id.erfgoed.net/erfgoedobjecten/{ref:OnroerendErfgoed}\">{ref:OnroerendErfgoed}</a>" "en": "<img src=\"./assets/layers/tree_node/Onroerend_Erfgoed_logo_without_text.svg\" style=\"width:0.85em;height:1em;vertical-align:middle\" alt=\"\"/> Onroerend Erfgoed ID: <a href=\"https://id.erfgoed.net/erfgoedobjecten/{ref:OnroerendErfgoed}\">{ref:OnroerendErfgoed}</a>"
}, },
"question": { "question": {
"nl": "Wat is het ID uitgegeven door Onroerend Erfgoed Vlaanderen?", "nl": "Wat is het ID uitgegeven door Onroerend Erfgoed Vlaanderen?",

View file

@ -29,7 +29,7 @@
"widenFactor": 0.05, "widenFactor": 0.05,
"socialImage": "", "socialImage": "",
"layers": [ "layers": [
"bench","bench_at_pt","picnic_tables" "bench","bench_at_pt","picnic_table"
], ],
"roamingRenderings": [] "roamingRenderings": []
} }

View file

@ -28,6 +28,6 @@
"widenFactor": 0.05, "widenFactor": 0.05,
"roamingRenderings": [], "roamingRenderings": [],
"layers": [ "layers": [
"public_bookcases" "public_bookcase"
] ]
} }

View file

@ -32,8 +32,8 @@
"widenFactor": 0.05, "widenFactor": 0.05,
"socialImage": "assets/themes/cyclofix/logo.svg", "socialImage": "assets/themes/cyclofix/logo.svg",
"layers": [ "layers": [
"bike_cafes", "bike_cafe",
"bike_shops", "bike_shop",
{ {
"builtin": "bicycle_library", "builtin": "bicycle_library",
"override": { "override": {

View file

@ -29,7 +29,7 @@
"widenFactor": 0.05, "widenFactor": 0.05,
"socialImage": "", "socialImage": "",
"layers": [ "layers": [
"maps" "map"
], ],
"roamingRenderings": [] "roamingRenderings": []
} }

View file

@ -22,10 +22,10 @@
"socialImage": "", "socialImage": "",
"layers": [ "layers": [
"drinking_water", "drinking_water",
"birdhides", "birdhide",
"maps", "map",
"information_boards", "information_board",
"nature_reserves" "nature_reserve"
], ],
"roamingRenderings": [] "roamingRenderings": []
} }

View file

@ -27,7 +27,7 @@
"defaultBackgroundId": "osm", "defaultBackgroundId": "osm",
"layers": [ "layers": [
"direction", "direction",
"surveillance_cameras" "surveillance_camera"
], ],
"roamingRenderings": [] "roamingRenderings": []
} }

View file

@ -23,6 +23,6 @@
"widenFactor": 0.05, "widenFactor": 0.05,
"icon": "./assets/themes/toilets/toilets.svg", "icon": "./assets/themes/toilets/toilets.svg",
"layers": [ "layers": [
"toilets" "toilet"
] ]
} }

View file

@ -28,7 +28,7 @@
"maxZoom": 18 "maxZoom": 18
}, },
"layers": [ "layers": [
"tree_nodes" "tree_node"
], ],
"roamingRenderings": [], "roamingRenderings": [],
"defaultBackgroundId": "AGIV" "defaultBackgroundId": "AGIV"

View file

@ -25,9 +25,9 @@ const layerFiles = ScriptUtils.readDirRecSync("./assets/layers")
.map(path => { .map(path => {
try { try {
const parsed = JSON.parse(readFileSync(path, "UTF8")); const parsed = JSON.parse(readFileSync(path, "UTF8"));
return parsed return {parsed: parsed, path: path}
} catch (e) { } catch (e) {
console.error("Could not parse file ", path, "due to ", e) console.error("Could not parse file ", "./assets/layers/"+ path, "due to ", e)
} }
}) })
const themeFiles: any[] = ScriptUtils.readDirRecSync("./assets/themes") const themeFiles: any[] = ScriptUtils.readDirRecSync("./assets/themes")
@ -37,7 +37,7 @@ const themeFiles: any[] = ScriptUtils.readDirRecSync("./assets/themes")
return JSON.parse(readFileSync(path, "UTF8")); return JSON.parse(readFileSync(path, "UTF8"));
}) })
writeFileSync("./assets/generated/known_layers_and_themes.json", JSON.stringify({ writeFileSync("./assets/generated/known_layers_and_themes.json", JSON.stringify({
"layers": layerFiles, "layers": layerFiles.map(l => l.parsed),
"themes": themeFiles "themes": themeFiles
})) }))
@ -51,9 +51,7 @@ for (const i in licenses) {
} }
const knownPaths = new Set<string>(licensePaths) const knownPaths = new Set<string>(licensePaths)
const linuxHints = [] function validateLayer(layerJson: LayerConfigJson, path: string, context?: string): string[] {
function validateLayer(layerJson: LayerConfigJson, context?: string): string[] {
let errorCount = []; let errorCount = [];
if (layerJson["overpassTags"] !== undefined) { if (layerJson["overpassTags"] !== undefined) {
errorCount.push("Layer " + layerJson.id + "still uses the old 'overpassTags'-format. Please use \"source\": {\"osmTags\": <tags>}' instead of \"overpassTags\": <tags> (note: this isn't your fault, the custom theme generator still spits out the old format)") errorCount.push("Layer " + layerJson.id + "still uses the old 'overpassTags'-format. Please use \"source\": {\"osmTags\": <tags>}' instead of \"overpassTags\": <tags> (note: this isn't your fault, the custom theme generator still spits out the old format)")
@ -65,9 +63,13 @@ function validateLayer(layerJson: LayerConfigJson, context?: string): string[] {
for (const remoteImage of remoteImages) { for (const remoteImage of remoteImages) {
errorCount.push("Found a remote image: " + remoteImage + " in layer " + layer.id + ", please download it.") errorCount.push("Found a remote image: " + remoteImage + " in layer " + layer.id + ", please download it.")
const path = remoteImage.substring(remoteImage.lastIndexOf("/") + 1) const path = remoteImage.substring(remoteImage.lastIndexOf("/") + 1)
linuxHints.push("wget " + remoteImage)
linuxHints.push(`echo '{"path":"${path}", "license": "<insert license here>", "authors": [ "<insert author(s) here"], "sources": [${remoteImage}] > ${path}.license_info.json`)
} }
const expected : string = `assets/layers/${layer.id}/${layer.id}.json`
if(path!=undefined && path.indexOf(expected)< 0){
errorCount.push("Layer is in an incorrect place. The path is "+path+", but expected "+expected)
}
for (const image of images) { for (const image of images) {
if (!knownPaths.has(image)) { if (!knownPaths.has(image)) {
const ctx = context === undefined ? "" : ` in a layer defined in the theme ${context}` const ctx = context === undefined ? "" : ` in a layer defined in the theme ${context}`
@ -76,6 +78,7 @@ function validateLayer(layerJson: LayerConfigJson, context?: string): string[] {
} }
} catch (e) { } catch (e) {
console.error(e)
return [`Layer ${layerJson.id}` ?? JSON.stringify(layerJson).substring(0, 50) + " is invalid: " + e] return [`Layer ${layerJson.id}` ?? JSON.stringify(layerJson).substring(0, 50) + " is invalid: " + e]
} }
return errorCount return errorCount
@ -84,8 +87,8 @@ function validateLayer(layerJson: LayerConfigJson, context?: string): string[] {
let layerErrorCount = [] let layerErrorCount = []
const knownLayerIds = new Set<string>(); const knownLayerIds = new Set<string>();
for (const layerFile of layerFiles) { for (const layerFile of layerFiles) {
knownLayerIds.add(layerFile.id) knownLayerIds.add(layerFile.parsed.id)
layerErrorCount.push(...validateLayer(layerFile)) layerErrorCount.push(...validateLayer(layerFile.parsed, layerFile.path))
} }
let themeErrorCount = [] let themeErrorCount = []
@ -94,7 +97,7 @@ for (const themeFile of themeFiles) {
for (const layer of themeFile.layers) { for (const layer of themeFile.layers) {
if (typeof layer === "string") { if (typeof layer === "string") {
if (!knownLayerIds.has(layer)) { if (!knownLayerIds.has(layer)) {
themeErrorCount.push("Unknown layer id: " + layer) themeErrorCount.push(`Unknown layer id: ${layer} in theme ${themeFile.id}`)
} }
} else { } else {
if (layer.builtin !== undefined) { if (layer.builtin !== undefined) {
@ -103,7 +106,7 @@ for (const themeFile of themeFiles) {
} }
} else { } else {
// layer.builtin contains layer overrides - we can skip those // layer.builtin contains layer overrides - we can skip those
layerErrorCount.push(...validateLayer(layer, themeFile.id)) layerErrorCount.push(...validateLayer(layer,undefined, themeFile.id))
} }
} }
} }
@ -129,7 +132,6 @@ if (layerErrorCount.length + themeErrorCount.length == 0) {
console.log(errors) console.log(errors)
const msg = (`Found ${layerErrorCount.length} errors in the layers; ${themeErrorCount.length} errors in the themes`) const msg = (`Found ${layerErrorCount.length} errors in the layers; ${themeErrorCount.length} errors in the themes`)
console.log(msg) console.log(msg)
console.log(linuxHints.join("\n"))
if (process.argv.indexOf("--report") >= 0) { if (process.argv.indexOf("--report") >= 0) {
console.log("Writing report!") console.log("Writing report!")
writeFileSync("layer_report.txt", errors) writeFileSync("layer_report.txt", errors)