Add check: layer and theme ids must be lowercase and match [a-z_-]*
This commit is contained in:
parent
9916371122
commit
444f0bc47c
7 changed files with 27 additions and 15 deletions
|
@ -73,7 +73,13 @@ export default class LayerConfig extends WithContextLoader {
|
|||
|
||||
if (json.source.osmTags === undefined) {
|
||||
throw "Layer " + this.id + " does not define a osmTags in the source section - these should always be present, even for geojson layers (" + context + ")"
|
||||
}
|
||||
|
||||
if(json.id.toLowerCase() !== json.id){
|
||||
throw `${context}: The id of a layer should be lowercase: ${json.id}`
|
||||
}
|
||||
if(json.id.match(/[a-z0-9-_]/) == null){
|
||||
throw `${context}: The id of a layer should match [a-z0-9-_]*: ${json.id}`
|
||||
}
|
||||
|
||||
this.maxAgeOfCache = json.source.maxCacheAge ?? 24 * 60 * 60 * 30
|
||||
|
|
|
@ -58,6 +58,12 @@ export default class LayoutConfig {
|
|||
constructor(json: LayoutConfigJson, official = true, context?: string) {
|
||||
this.official = official;
|
||||
this.id = json.id;
|
||||
if(json.id.toLowerCase() !== json.id){
|
||||
throw "The id of a theme should be lowercase: "+json.id
|
||||
}
|
||||
if(json.id.match(/[a-z0-9-_]/) == null){
|
||||
throw "The id of a theme should match [a-z0-9-_]*: "+json.id
|
||||
}
|
||||
context = (context ?? "") + "." + this.id;
|
||||
this.maintainer = json.maintainer;
|
||||
this.credits = json.credits;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"layers": [
|
||||
"defibrillator",
|
||||
{
|
||||
"id": "Brugge",
|
||||
"id": "brugge",
|
||||
"name": "Brugse dataset",
|
||||
"source": {
|
||||
"osmTags": "Brugs volgnummer~*",
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"id": "OSM-buildings",
|
||||
"id": "osm-buildings",
|
||||
"name": "All OSM-buildings",
|
||||
"source": {
|
||||
"osmTags": "building~*",
|
||||
|
@ -372,13 +372,13 @@
|
|||
"builtin": "crab_address",
|
||||
"override": {
|
||||
"calculatedTags+": [
|
||||
"_embedded_in=feat.overlapWith('OSM-buildings').filter(b => /* Do not match newly created objects */ b.feat.properties.id.indexOf('-') < 0)[0]?.feat?.properties ?? {}",
|
||||
"_embedded_in=feat.overlapWith('osm-buildings').filter(b => /* Do not match newly created objects */ b.feat.properties.id.indexOf('-') < 0)[0]?.feat?.properties ?? {}",
|
||||
"_embedding_nr=feat.get('_embedded_in')['addr:housenumber']+(feat.get('_embedded_in')['addr:unit'] ?? '')",
|
||||
"_embedding_street=feat.get('_embedded_in')['addr:street']",
|
||||
"_embedding_id=feat.get('_embedded_in').id",
|
||||
"_closeby_addresses=feat.closestn('address',10,undefined,50).map(f => f.feat).filter(addr => addr.properties['addr:street'] == feat.properties['STRAATNM'] && feat.properties['HNRLABEL'] == addr.properties['addr:housenumber'] + (addr.properties['addr:unit']??'') ).length",
|
||||
"_has_identical_closeby_address=feat.get('_closeby_addresses') >= 1 ? 'yes' : 'no'",
|
||||
"_embedded_in_grb=feat.overlapWith('GRB')[0]?.feat?.properties ?? {}",
|
||||
"_embedded_in_grb=feat.overlapWith('grb')[0]?.feat?.properties ?? {}",
|
||||
"_embedding_nr_grb=feat.get('_embedded_in_grb')['addr:housenumber']",
|
||||
"_embedding_street_grb=feat.get('_embedded_in_grb')['addr:street']"
|
||||
],
|
||||
|
@ -452,7 +452,7 @@
|
|||
},
|
||||
{
|
||||
"id": "import-button",
|
||||
"render": "{import_button(address, addr:street=$STRAATNM; addr:housenumber=$_HNRLABEL,Voeg dit adres als een nieuw adrespunt toe,,OSM-buildings,5)}",
|
||||
"render": "{import_button(address, addr:street=$STRAATNM; addr:housenumber=$_HNRLABEL,Voeg dit adres als een nieuw adrespunt toe,,osm-buildings,5)}",
|
||||
"condition": {
|
||||
"and": [
|
||||
"_embedding_id!=",
|
||||
|
@ -469,7 +469,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"id": "GRB",
|
||||
"id": "grb",
|
||||
"description": "Geometry which comes from GRB with tools to import them",
|
||||
"source": {
|
||||
"osmTags": {
|
||||
|
@ -486,7 +486,7 @@
|
|||
"name": "GRB geometries",
|
||||
"title": "GRB outline",
|
||||
"calculatedTags": [
|
||||
"_overlaps_with_buildings=feat.overlapWith('OSM-buildings').filter(f => f.feat.properties.id.indexOf('-') < 0)",
|
||||
"_overlaps_with_buildings=feat.overlapWith('osm-buildings').filter(f => f.feat.properties.id.indexOf('-') < 0)",
|
||||
"_overlaps_with=feat.get('_overlaps_with_buildings').filter(f => f.overlap > 1 /* square meter */ )[0] ?? ''",
|
||||
"_overlap_absolute=feat.get('_overlaps_with')?.overlap",
|
||||
"_overlap_percentage=Math.round(100 * feat.get('_overlap_absolute') / feat.get('_surface')) ",
|
||||
|
@ -507,7 +507,7 @@
|
|||
"tagRenderings": [
|
||||
{
|
||||
"id": "Import-button",
|
||||
"render": "{import_way_button(OSM-buildings,building=$building;man_made=$man_made; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref; addr:street=$addr:street; addr:housenumber=$addr:housenumber; building:min_level=$_building:min_level, Upload this building to OpenStreetMap,,_is_part_of_building=true,1,_moveable=true)}",
|
||||
"render": "{import_way_button(osm-buildings,building=$building;man_made=$man_made; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref; addr:street=$addr:street; addr:housenumber=$addr:housenumber; building:min_level=$_building:min_level, Upload this building to OpenStreetMap,,_is_part_of_building=true,1,_moveable=true)}",
|
||||
"mappings": [
|
||||
{
|
||||
"#": "Hide import button if intersection with other objects are detected",
|
||||
|
@ -524,11 +524,11 @@
|
|||
"addr:housenumber~*"
|
||||
]
|
||||
},
|
||||
"then": "{conflate_button(OSM-buildings,building=$_target_building_type; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref; addr:street=$addr:street; addr:housenumber=$addr:housenumber, Replace the geometry in OpenStreetMap and add the address,,_osm_obj:id)}"
|
||||
"then": "{conflate_button(osm-buildings,building=$_target_building_type; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref; addr:street=$addr:street; addr:housenumber=$addr:housenumber, Replace the geometry in OpenStreetMap and add the address,,_osm_obj:id)}"
|
||||
},
|
||||
{
|
||||
"if": "_overlaps_with!=",
|
||||
"then": "{conflate_button(OSM-buildings,building=$_target_building_type; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref, Replace the geometry in OpenStreetMap,,_osm_obj:id)}"
|
||||
"then": "{conflate_button(osm-buildings,building=$_target_building_type; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref, Replace the geometry in OpenStreetMap,,_osm_obj:id)}"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
},
|
||||
"layers": [
|
||||
{
|
||||
"id": "OSM-buildings-fixme",
|
||||
"id": "osm-buildings-fixme",
|
||||
"name": "OSM-buildings with a fixme",
|
||||
"source": {
|
||||
"osmTags": {
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
}
|
||||
],
|
||||
"calculatedTags": [
|
||||
"_overlapping=Number(feat.properties.zoom) >= 14 ? feat.overlapWith('OSM-buildings').map(ff => ff.feat.properties) : undefined",
|
||||
"_overlapping=Number(feat.properties.zoom) >= 14 ? feat.overlapWith('osm-buildings').map(ff => ff.feat.properties) : undefined",
|
||||
"_applicable=feat.get('_overlapping').filter(p => (p._spelling_is_correct === 'true') && (p._singular_import === 'true')).map(p => p.id)",
|
||||
"_applicable_count=feat.get('_applicable')?.length"
|
||||
],
|
||||
|
@ -67,7 +67,7 @@
|
|||
},
|
||||
{
|
||||
"id": "autoapply",
|
||||
"render": "{auto_apply(OSM-buildings, _applicable, apply_streetname, Automatically add all missing streetnames on buildings in view)}"
|
||||
"render": "{auto_apply(osm-buildings, _applicable, apply_streetname, Automatically add all missing streetnames on buildings in view)}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -89,7 +89,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"id": "OSM-buildings",
|
||||
"id": "osm-buildings",
|
||||
"name": "Alle OSM-gebouwen met een huisnummer en zonder straat",
|
||||
"source": {
|
||||
"osmTags": {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"layers": [
|
||||
"street_lamps",
|
||||
{
|
||||
"id": "Assen",
|
||||
"id": "assen",
|
||||
"name": "Dataset Assen",
|
||||
"source": {
|
||||
"osmTags": "Lichtmastnummer~*",
|
||||
|
|
Loading…
Reference in a new issue