diff --git a/assets/themes/bag/bag.json b/assets/themes/bag/bag.json
index 1aa324bc3..05ddd4e4a 100644
--- a/assets/themes/bag/bag.json
+++ b/assets/themes/bag/bag.json
@@ -45,7 +45,7 @@
"hideFromOverview": true,
"layers": [
{
- "id": "osm:buildings",
+ "id": "osm_buildings",
"name": "OSM Buildings",
"title": "OSM Building",
"description": "Layer showing buildings that are in OpenStreetMap",
@@ -147,7 +147,7 @@
]
},
{
- "id": "osm:adresses",
+ "id": "osm_adresses",
"name": "OSM Adresses",
"title": "OSM Adress",
"description": "Layer showing adresses that are in OpenStreetMap",
@@ -185,7 +185,7 @@
]
},
{
- "id": "bag:pand",
+ "id": "bag_pand",
"name": "BAG Buildings",
"title": "BAG Building",
"description": {
@@ -207,7 +207,7 @@
},
"minzoom": 18,
"calculatedTags": [
- "_overlaps_with_buildings=overlapWith(feat)('osm:buildings').filter(f => f.feat.properties.id.indexOf('-') < 0)",
+ "_overlaps_with_buildings=overlapWith(feat)('osm_buildings').filter(f => f.feat.properties.id.indexOf('-') < 0)",
"_overlaps_with=feat(get)('_overlaps_with_buildings').find(f => f.overlap > 1 /* square meter */ )",
"_overlaps_with_properties=feat(get)('_overlaps_with')?.feat?.properties",
"_overlap_percentage=Math.round(100 * (feat(get)('_overlaps_with')?.overlap / feat(get)('_overlaps_with_properties')['_surface:strict']))",
@@ -228,7 +228,7 @@
"render": {
"special": {
"type": "import_way_button",
- "targetLayer": "osm:buildings",
+ "targetLayer": "osm_buildings",
"tags": "building=$_bag_obj:building; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date; start_date=$_bag_obj:start_date",
"text": {
"*": "Upload this building to OpenStreetMap"
@@ -258,7 +258,7 @@
},
{
"if": "_overlaps_with!=",
- "then": "{conflate_button(osm:buildings, building=$_bag_obj:building; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date; start_date=$_bag_obj:start_date, Replace the geometry in OpenStreetMap, , _osm_obj:id)}"
+ "then": "{conflate_button(osm_buildings, building=$_bag_obj:building; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date; start_date=$_bag_obj:start_date, Replace the geometry in OpenStreetMap, , _osm_obj:id)}"
},
{
"if": {
@@ -268,7 +268,7 @@
"_bag_obj:in_construction=true"
]
},
- "then": "{import_way_button(osm:buildings, building=$_bag_obj:building; construction=$_bag_obj:construction; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date; start_date=$_bag_obj:start_date, Upload this building to OpenStreetMap)}"
+ "then": "{import_way_button(osm_buildings, building=$_bag_obj:building; construction=$_bag_obj:construction; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date; start_date=$_bag_obj:start_date, Upload this building to OpenStreetMap)}"
}
]
},
@@ -348,7 +348,7 @@
},
{
"id": "Overlapping building",
- "render": "
The overlapping
osm:buildings is a
{_osm_obj:building} and covers
{_overlap_percentage}% of the BAG building.
The BAG-building covers
{_reverse_overlap_percentage}% of the OSM building
BAG geometry:
{minimap(21, id):height:10rem;border-radius:1rem;overflow:hidden}OSM geometry:
{minimap(21,_osm_obj:id):height:10rem;border-radius:1rem;overflow:hidden} ",
+ "render": "The overlapping
osm_buildings is a
{_osm_obj:building} and covers
{_overlap_percentage}% of the BAG building.
The BAG-building covers
{_reverse_overlap_percentage}% of the OSM building
BAG geometry:
{minimap(21, id):height:10rem;border-radius:1rem;overflow:hidden}OSM geometry:
{minimap(21,_osm_obj:id):height:10rem;border-radius:1rem;overflow:hidden} ",
"condition": "_overlaps_with!="
},
{
@@ -386,7 +386,7 @@
]
},
{
- "id": "bag:verblijfsobject",
+ "id": "bag_verblijfsobject",
"name": "BAG Addresses",
"title": "BAG Address",
"description": "Address information from the BAG register",
@@ -398,7 +398,7 @@
},
"minzoom": 18,
"calculatedTags": [
- "_closed_osm_addr:=closest(feat)('osm:adresses').properties",
+ "_closed_osm_addr:=closest(feat)('osm_adresses').properties",
"_bag_obj:addr:housenumber=`${feat.properties.huisnummer}${feat.properties.huisletter}${(feat.properties.toevoeging != '') ? '-' : ''}${feat.properties.toevoeging}`",
"_bag_obj:ref:bag=Number(feat.properties.identificatie)",
"_bag_obj:source:date=new Date().toISOString().split('T')[0]",
@@ -411,7 +411,7 @@
"tagRenderings": [
{
"id": "Import button",
- "render": "{import_button(osm:adresses, addr:city=$woonplaats; addr:housenumber=$_bag_obj:addr:housenumber; addr:postcode=$postcode; addr:street=$openbare_ruimte; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date, Upload this adress to OpenStreetMap)}",
+ "render": "{import_button(osm_adresses, addr:city=$woonplaats; addr:housenumber=$_bag_obj:addr:housenumber; addr:postcode=$postcode; addr:street=$openbare_ruimte; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date, Upload this adress to OpenStreetMap)}",
"condition": "_imported_osm_object_found=false"
},
{
diff --git a/assets/themes/cyclenodes/cyclenodes.json b/assets/themes/cyclenodes/cyclenodes.json
index 9e2d3ba35..8fdd4cab1 100644
--- a/assets/themes/cyclenodes/cyclenodes.json
+++ b/assets/themes/cyclenodes/cyclenodes.json
@@ -32,7 +32,7 @@
"hideFromOverview": true,
"layers": [
{
- "id": "node2node",
+ "id": "node2node_bicycle",
"name": {
"en": "Node to node links",
"de": "Knotenpunktverbindungen",
@@ -126,7 +126,7 @@
"pointRendering": null
},
{
- "id": "node",
+ "id": "node_bicycle",
"name": {
"en": "Nodes",
"de": "Knotenpunkte",
@@ -321,6 +321,7 @@
],
"override": {
"minzoom": 16,
+ "id": "bicycle_guidepost",
"source": {
"osmTags": {
"and": [
diff --git a/assets/themes/cyclestreets/cyclestreets.json b/assets/themes/cyclestreets/cyclestreets.json
index 7b8ce2fc8..affd01ce7 100644
--- a/assets/themes/cyclestreets/cyclestreets.json
+++ b/assets/themes/cyclestreets/cyclestreets.json
@@ -290,7 +290,7 @@
]
},
{
- "id": "all_streets",
+ "id": "not_cyclestreets",
"name": {
"nl": "Alle straten",
"en": "All streets",
diff --git a/assets/themes/grb/grb.json b/assets/themes/grb/grb.json
index c4c955660..c2b64f77c 100644
--- a/assets/themes/grb/grb.json
+++ b/assets/themes/grb/grb.json
@@ -29,7 +29,7 @@
"hideFromOverview": true,
"layers": [
{
- "id": "osm-buildings",
+ "id": "osm_buildings_no_points",
"name": "All OSM-buildings",
"source": {
"osmTags": {
@@ -296,7 +296,7 @@
"name": "GRB geometries",
"title": "GRB outline",
"calculatedTags": [
- "_overlaps_with_buildings=overlapWith(feat)('osm-buildings').filter(f => f.feat.properties.id.indexOf('-') < 0) ?? []",
+ "_overlaps_with_buildings=overlapWith(feat)('osm_buildings_no_points').filter(f => f.feat.properties.id.indexOf('-') < 0) ?? []",
"_overlaps_with=get(feat)('_overlaps_with_buildings').find(f => f.overlap > 1 /* square meter */ )",
"_osm_obj:source:ref=get(feat)('_overlaps_with')?.feat?.properties['source:geometry:ref']",
"_osm_obj:id=get(feat)('_overlaps_with')?.feat?.properties?.id",
@@ -319,7 +319,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_no_points,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": [
{
"#": "Failsafe",
@@ -371,7 +371,7 @@
"addr:housenumber!:={_osm_obj: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_no_points,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": {
@@ -380,7 +380,7 @@
"_reverse_overlap_percentage>50"
]
},
- "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_no_points,building=$_target_building_type; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref, Replace the geometry in OpenStreetMap,,_osm_obj:id)}"
}
]
},
@@ -612,7 +612,7 @@
"builtin": "crab_address",
"override": {
"calculatedTags+": [
- "_embedded_in=overlapWith(feat)('osm-buildings').filter(b => /* Do not match newly created objects */ b.feat.properties.id.indexOf('-') < 0)[0]?.feat?.properties ?? {}",
+ "_embedded_in=overlapWith(feat)('osm_buildings_no_points').filter(b => /* Do not match newly created objects */ b.feat.properties.id.indexOf('-') < 0)[0]?.feat?.properties ?? {}",
"_embedding_nr=get(feat)('_embedded_in')['addr:housenumber']+(get(feat)('_embedded_in')['addr:unit'] ?? '')",
"_embedding_street=get(feat)('_embedded_in')['addr:street']",
"_embedding_id=get(feat)('_embedded_in').id",
@@ -709,7 +709,7 @@
"text": {
"nl": "Voeg dit adres als een nieuw adrespunt toe"
},
- "snap_onto_layers": "osm-buildings"
+ "snap_onto_layers": "osm_buildings_no_points"
}
},
"mappings": [
diff --git a/assets/themes/healthcare/healthcare.json b/assets/themes/healthcare/healthcare.json
index 51c577f0c..e06e7f305 100644
--- a/assets/themes/healthcare/healthcare.json
+++ b/assets/themes/healthcare/healthcare.json
@@ -39,7 +39,7 @@
{
"builtin": "shops",
"override": {
- "id": "medical-shops",
+ "id": "medical_shops",
"minzoom": 13,
"=filter": [
"open_now",
diff --git a/assets/themes/kerbs_and_crossings/kerbs_and_crossings.json b/assets/themes/kerbs_and_crossings/kerbs_and_crossings.json
index 108cfd410..ce049f837 100644
--- a/assets/themes/kerbs_and_crossings/kerbs_and_crossings.json
+++ b/assets/themes/kerbs_and_crossings/kerbs_and_crossings.json
@@ -46,6 +46,7 @@
{
"builtin": "crossings",
"override": {
+ "id": "crossings_no_traffic_lights",
"=presets": [
{
"title": {
@@ -87,4 +88,4 @@
},
"kerbs"
]
-}
\ No newline at end of file
+}
diff --git a/assets/themes/onwheels/onwheels.json b/assets/themes/onwheels/onwheels.json
index 116f0a487..8577f595f 100644
--- a/assets/themes/onwheels/onwheels.json
+++ b/assets/themes/onwheels/onwheels.json
@@ -258,6 +258,7 @@
{
"builtin": "parking_spaces",
"override": {
+ "id": "parking_spaces_disabled",
"source": {
"osmTags": "parking_space=disabled"
},
diff --git a/assets/themes/openlovemap/openlovemap.json b/assets/themes/openlovemap/openlovemap.json
index 2fd24944b..1c9bf94c1 100644
--- a/assets/themes/openlovemap/openlovemap.json
+++ b/assets/themes/openlovemap/openlovemap.json
@@ -14,7 +14,7 @@
{
"builtin": "shops",
"override": {
- "id": "erotic-shop",
+ "id": "erotic_shop",
"source": {
"osmTags": "shop=erotic"
},
diff --git a/assets/themes/transit/transit.json b/assets/themes/transit/transit.json
index 84c4a6abb..5676d6802 100644
--- a/assets/themes/transit/transit.json
+++ b/assets/themes/transit/transit.json
@@ -53,6 +53,7 @@
"builtin": "shelter",
"override": {
"minzoom": 18,
+ "id": "pt_shelter",
"source": {
"osmTags": {
"and": [
diff --git a/assets/themes/uk_addresses/uk_addresses.json b/assets/themes/uk_addresses/uk_addresses.json
index 0a05b9665..97bf12a81 100644
--- a/assets/themes/uk_addresses/uk_addresses.json
+++ b/assets/themes/uk_addresses/uk_addresses.json
@@ -185,7 +185,7 @@
]
},
{
- "id": "address",
+ "id": "uk_address",
"name": {
"en": "Known addresses in OSM"
},
diff --git a/assets/themes/walkingnodes/walkingnodes.json b/assets/themes/walkingnodes/walkingnodes.json
index e20ffb727..78c89216c 100644
--- a/assets/themes/walkingnodes/walkingnodes.json
+++ b/assets/themes/walkingnodes/walkingnodes.json
@@ -21,7 +21,7 @@
"hideFromOverview": true,
"layers": [
{
- "id": "node2node",
+ "id": "node2node_hiking",
"name": {
"en": "Node to node links",
"de": "Knotenpunktverbindungen",
@@ -120,7 +120,7 @@
]
},
{
- "id": "node",
+ "id": "node_hiking",
"name": {
"en": "Nodes",
"de": "Knotenpunkte",
@@ -279,6 +279,7 @@
],
"override": {
"minzoom": 16,
+ "id": "guidepost_hiking",
"source": {
"osmTags": {
"and": [
diff --git a/scripts/osm2pgsql/generateLayerFile.ts b/scripts/osm2pgsql/generateBuildDbScript.ts
similarity index 70%
rename from scripts/osm2pgsql/generateLayerFile.ts
rename to scripts/osm2pgsql/generateBuildDbScript.ts
index 5867b8d9f..a2c9363f2 100644
--- a/scripts/osm2pgsql/generateLayerFile.ts
+++ b/scripts/osm2pgsql/generateBuildDbScript.ts
@@ -9,7 +9,7 @@ import { Or } from "../../src/Logic/Tags/Or"
import { RegexTag } from "../../src/Logic/Tags/RegexTag"
import { Utils } from "../../src/Utils"
-class LuaSnippets{
+class LuaSnippets {
/**
* The main piece of code that calls `process_poi`
*/
@@ -25,23 +25,25 @@ class LuaSnippets{
"end",
""].join("\n")
- public static combine(calls: string[]): string{
+ public static combine(calls: string[]): string {
return [
`function process_poi(object, geom)`,
- ...calls.map(c => " "+c+"(object, geom)"),
+ ...calls.map(c => " " + c + "(object, geom)"),
`end`,
].join("\n")
}
}
+
class GenerateLayerLua {
private readonly _layer: LayerConfig
constructor(layer: LayerConfig) {
this._layer = layer
}
- public functionName(){
+
+ public functionName() {
const l = this._layer
- if(!l.source?.osmTags){
+ if (!l.source?.osmTags) {
return undefined
}
return `process_poi_${l.id}`
@@ -49,7 +51,7 @@ class GenerateLayerLua {
public generateFunction(): string {
const l = this._layer
- if(!l.source?.osmTags){
+ if (!l.source?.osmTags) {
return undefined
}
return [
@@ -75,10 +77,38 @@ class GenerateLayerLua {
" ",
` pois_${l.id}:insert(a)`,
"end",
- ""
+ "",
].join("\n")
}
+ private regexTagToLua(tag: RegexTag) {
+ if (typeof tag.value === "string" && tag.invert) {
+ return `object.tags["${tag.key}"] ~= "${tag.value}"`
+ }
+
+ if ("" + tag.value === "/.+/is" && !tag.invert) {
+ return `object.tags["${tag.key}"] ~= nil`
+ }
+
+ if ("" + tag.value === "/.+/is" && tag.invert) {
+ return `object.tags["${tag.key}"] == nil`
+ }
+
+ if (tag.matchesEmpty && !tag.invert) {
+ return `object.tags["${tag.key}"] == nil or object.tags["${tag.key}"] == ""`
+ }
+
+
+ if (tag.matchesEmpty && tag.invert) {
+ return `object.tags["${tag.key}"] ~= nil or object.tags["${tag.key}"] ~= ""`
+ }
+
+ if (tag.invert) {
+ return `object.tags["${tag.key}"] == nil or not string.find(object.tags["${tag.key}"], "${tag.value}")`
+ }
+
+ return `(object.tags["${tag.key}"] ~= nil and string.find(object.tags["${tag.key}"], "${tag.value}"))`
+ }
private toLuaFilter(tag: TagsFilter, useParens: boolean = false): string {
if (tag instanceof Tag) {
@@ -99,14 +129,7 @@ class GenerateLayerLua {
return expr
}
if (tag instanceof RegexTag) {
- if(typeof tag.value === "string" && tag.invert){
- return `object.tags["${tag.key}"] ~= "${tag.value}"`
- }
-
- let expr = `not string.find(object.tags["${tag.key}"], "${tag.value}")`
- if (!tag.invert) {
- expr = "not " + expr
- }
+ let expr = this.regexTagToLua(tag)
if (useParens) {
expr = "(" + expr + ")"
}
@@ -124,17 +147,17 @@ class GenerateLayerFile extends Script {
}
async main(args: string[]) {
- const layerNames = Array.from(AllSharedLayers.sharedLayers.values())
+ const layers = Array.from(AllSharedLayers.sharedLayers.values())
- const generators = layerNames.map(l => new GenerateLayerLua(l))
+ const generators = layers.filter(l => l.source.geojsonSource === undefined).map(l => new GenerateLayerLua(l))
const script = [
...generators.map(g => g.generateFunction()),
LuaSnippets.combine(Utils.NoNull(generators.map(g => g.functionName()))),
- LuaSnippets.tail
+ LuaSnippets.tail,
].join("\n\n\n")
const path = "build_db.lua"
- fs.writeFileSync(path,script, "utf-8")
+ fs.writeFileSync(path, script, "utf-8")
console.log("Written", path)
}
}