Add check: a preset for a newly created point should match the layer + fix bugs in themes
This commit is contained in:
parent
3398c9f405
commit
c874afc745
5 changed files with 32 additions and 22 deletions
|
@ -10,6 +10,7 @@ import {TagRenderingConfigJson} from "../Json/TagRenderingConfigJson";
|
||||||
import {TagUtils} from "../../../Logic/Tags/TagUtils";
|
import {TagUtils} from "../../../Logic/Tags/TagUtils";
|
||||||
import {ExtractImages} from "./FixImages";
|
import {ExtractImages} from "./FixImages";
|
||||||
import ScriptUtils from "../../../scripts/ScriptUtils";
|
import ScriptUtils from "../../../scripts/ScriptUtils";
|
||||||
|
import {And} from "../../../Logic/Tags/And";
|
||||||
|
|
||||||
|
|
||||||
class ValidateLanguageCompleteness extends DesugaringStep<any> {
|
class ValidateLanguageCompleteness extends DesugaringStep<any> {
|
||||||
|
@ -339,6 +340,24 @@ export class ValidateLayer extends DesugaringStep<LayerConfigJson> {
|
||||||
new DetectShadowedMappings().convertAll(<TagRenderingConfigJson[]>json.tagRenderings, context + ".tagRenderings")
|
new DetectShadowedMappings().convertAll(<TagRenderingConfigJson[]>json.tagRenderings, context + ".tagRenderings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(json.presets !== undefined){
|
||||||
|
|
||||||
|
// Check that a preset will be picked up by the layer itself
|
||||||
|
const baseTags = TagUtils.Tag( json.source.osmTags)
|
||||||
|
for (let i = 0; i < json.presets.length; i++){
|
||||||
|
const preset = json.presets[i];
|
||||||
|
const tags : {k: string,v: string}[]= new And(preset.tags.map(t => TagUtils.Tag(t))).asChange({id:"node/-1"})
|
||||||
|
const properties = {}
|
||||||
|
for (const tag of tags) {
|
||||||
|
properties[tag.k] = tag.v
|
||||||
|
}
|
||||||
|
const doMatch = baseTags.matchesProperties(properties)
|
||||||
|
if(!doMatch){
|
||||||
|
errors.push(context+".presets["+i+"]: This preset does not match the required tags of this layer. This implies that a newly added point will not show up.\n A newly created point will have properties: "+JSON.stringify(properties)+"\n The required tags are: "+baseTags.asHumanString(false, false, {}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errors.push(e)
|
errors.push(e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,25 +127,6 @@
|
||||||
"de": "Knotenpunkt <strong>{rcn_ref}</strong>"
|
"de": "Knotenpunkt <strong>{rcn_ref}</strong>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"presets": [
|
|
||||||
{
|
|
||||||
"title": {
|
|
||||||
"de": "Knotenpunkt"
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"network:type=node_network"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": {
|
|
||||||
"de": "Knotenpunkt im Netzwerk Spree-Neiße"
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"network:type=node_network",
|
|
||||||
"cycle_network=Knotenpunktwegweisung Spree-Neiße"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tagRenderings": [
|
"tagRenderings": [
|
||||||
{
|
{
|
||||||
"question": {
|
"question": {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
"it": "Friggitoria",
|
"it": "Friggitoria",
|
||||||
"hu": "Sültkrumplievő-hely"
|
"hu": "Sültkrumplievő-hely"
|
||||||
},
|
},
|
||||||
|
"=presets": [],
|
||||||
"source": {
|
"source": {
|
||||||
"=osmTags": {
|
"=osmTags": {
|
||||||
"and": [
|
"and": [
|
||||||
|
@ -47,7 +48,8 @@
|
||||||
"builtin": "food",
|
"builtin": "food",
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 19,
|
"minzoom": 19,
|
||||||
"filter": null
|
"filter": null,
|
||||||
|
"name": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -77,7 +77,8 @@
|
||||||
],
|
],
|
||||||
"=filter": {
|
"=filter": {
|
||||||
"sameAs": "nature_reserve_centerpoints"
|
"sameAs": "nature_reserve_centerpoints"
|
||||||
}
|
},
|
||||||
|
"=presets": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -103,6 +104,9 @@
|
||||||
},
|
},
|
||||||
"presets": []
|
"presets": []
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"presets": [
|
||||||
|
{"tags+": "operator=Natuurpunt"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -193,6 +197,10 @@
|
||||||
"builtin": "birdhide",
|
"builtin": "birdhide",
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 14,
|
"minzoom": 14,
|
||||||
|
"presets": [
|
||||||
|
{"tags+": "operator=Natuurpunt"},
|
||||||
|
{"tags+": "operator=Natuurpunt"}
|
||||||
|
],
|
||||||
"source": {
|
"source": {
|
||||||
"geoJson": "https://raw.githubusercontent.com/pietervdvn/MapComplete-data/main/natuurpunt_cache/natuurpunt_{layer}_{z}_{x}_{y}.geojson",
|
"geoJson": "https://raw.githubusercontent.com/pietervdvn/MapComplete-data/main/natuurpunt_cache/natuurpunt_{layer}_{z}_{x}_{y}.geojson",
|
||||||
"geoJsonZoomLevel": 12,
|
"geoJsonZoomLevel": 12,
|
||||||
|
|
|
@ -139,8 +139,8 @@
|
||||||
"id": "to_handle",
|
"id": "to_handle",
|
||||||
"options": [
|
"options": [
|
||||||
{
|
{
|
||||||
"question": "Only show non-matched objects",
|
|
||||||
"default": true,
|
"default": true,
|
||||||
|
"question": "Only show non-matched objects",
|
||||||
"osmTags": {
|
"osmTags": {
|
||||||
"and": [
|
"and": [
|
||||||
"_imported=",
|
"_imported=",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue