LayerServer: make all layer ids unique
This commit is contained in:
parent
ef2f1487c6
commit
1d6c9ec1ef
12 changed files with 74 additions and 46 deletions
|
@ -45,7 +45,7 @@
|
||||||
"hideFromOverview": true,
|
"hideFromOverview": true,
|
||||||
"layers": [
|
"layers": [
|
||||||
{
|
{
|
||||||
"id": "osm:buildings",
|
"id": "osm_buildings",
|
||||||
"name": "OSM Buildings",
|
"name": "OSM Buildings",
|
||||||
"title": "OSM Building",
|
"title": "OSM Building",
|
||||||
"description": "Layer showing buildings that are in OpenStreetMap",
|
"description": "Layer showing buildings that are in OpenStreetMap",
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "osm:adresses",
|
"id": "osm_adresses",
|
||||||
"name": "OSM Adresses",
|
"name": "OSM Adresses",
|
||||||
"title": "OSM Adress",
|
"title": "OSM Adress",
|
||||||
"description": "Layer showing adresses that are in OpenStreetMap",
|
"description": "Layer showing adresses that are in OpenStreetMap",
|
||||||
|
@ -185,7 +185,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bag:pand",
|
"id": "bag_pand",
|
||||||
"name": "BAG Buildings",
|
"name": "BAG Buildings",
|
||||||
"title": "BAG Building",
|
"title": "BAG Building",
|
||||||
"description": {
|
"description": {
|
||||||
|
@ -207,7 +207,7 @@
|
||||||
},
|
},
|
||||||
"minzoom": 18,
|
"minzoom": 18,
|
||||||
"calculatedTags": [
|
"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=feat(get)('_overlaps_with_buildings').find(f => f.overlap > 1 /* square meter */ )",
|
||||||
"_overlaps_with_properties=feat(get)('_overlaps_with')?.feat?.properties",
|
"_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']))",
|
"_overlap_percentage=Math.round(100 * (feat(get)('_overlaps_with')?.overlap / feat(get)('_overlaps_with_properties')['_surface:strict']))",
|
||||||
|
@ -228,7 +228,7 @@
|
||||||
"render": {
|
"render": {
|
||||||
"special": {
|
"special": {
|
||||||
"type": "import_way_button",
|
"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",
|
"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": {
|
"text": {
|
||||||
"*": "Upload this building to OpenStreetMap"
|
"*": "Upload this building to OpenStreetMap"
|
||||||
|
@ -258,7 +258,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"if": "_overlaps_with!=",
|
"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": {
|
"if": {
|
||||||
|
@ -268,7 +268,7 @@
|
||||||
"_bag_obj:in_construction=true"
|
"_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",
|
"id": "Overlapping building",
|
||||||
"render": "<div>The overlapping <a href=https://osm.org/{_osm_obj:id} target=_blank>osm:buildings</a> is a <b>{_osm_obj:building}</b> and covers <b>{_overlap_percentage}%</b> of the BAG building.<br>The BAG-building covers <b>{_reverse_overlap_percentage}%</b> of the OSM building<div><h3>BAG geometry:</h3>{minimap(21, id):height:10rem;border-radius:1rem;overflow:hidden}<h3>OSM geometry:</h3>{minimap(21,_osm_obj:id):height:10rem;border-radius:1rem;overflow:hidden}</div></div>",
|
"render": "<div>The overlapping <a href=https://osm.org/{_osm_obj:id} target=_blank>osm_buildings</a> is a <b>{_osm_obj:building}</b> and covers <b>{_overlap_percentage}%</b> of the BAG building.<br>The BAG-building covers <b>{_reverse_overlap_percentage}%</b> of the OSM building<div><h3>BAG geometry:</h3>{minimap(21, id):height:10rem;border-radius:1rem;overflow:hidden}<h3>OSM geometry:</h3>{minimap(21,_osm_obj:id):height:10rem;border-radius:1rem;overflow:hidden}</div></div>",
|
||||||
"condition": "_overlaps_with!="
|
"condition": "_overlaps_with!="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -386,7 +386,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bag:verblijfsobject",
|
"id": "bag_verblijfsobject",
|
||||||
"name": "BAG Addresses",
|
"name": "BAG Addresses",
|
||||||
"title": "BAG Address",
|
"title": "BAG Address",
|
||||||
"description": "Address information from the BAG register",
|
"description": "Address information from the BAG register",
|
||||||
|
@ -398,7 +398,7 @@
|
||||||
},
|
},
|
||||||
"minzoom": 18,
|
"minzoom": 18,
|
||||||
"calculatedTags": [
|
"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:addr:housenumber=`${feat.properties.huisnummer}${feat.properties.huisletter}${(feat.properties.toevoeging != '') ? '-' : ''}${feat.properties.toevoeging}`",
|
||||||
"_bag_obj:ref:bag=Number(feat.properties.identificatie)",
|
"_bag_obj:ref:bag=Number(feat.properties.identificatie)",
|
||||||
"_bag_obj:source:date=new Date().toISOString().split('T')[0]",
|
"_bag_obj:source:date=new Date().toISOString().split('T')[0]",
|
||||||
|
@ -411,7 +411,7 @@
|
||||||
"tagRenderings": [
|
"tagRenderings": [
|
||||||
{
|
{
|
||||||
"id": "Import button",
|
"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"
|
"condition": "_imported_osm_object_found=false"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
"hideFromOverview": true,
|
"hideFromOverview": true,
|
||||||
"layers": [
|
"layers": [
|
||||||
{
|
{
|
||||||
"id": "node2node",
|
"id": "node2node_bicycle",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Node to node links",
|
"en": "Node to node links",
|
||||||
"de": "Knotenpunktverbindungen",
|
"de": "Knotenpunktverbindungen",
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
"pointRendering": null
|
"pointRendering": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "node",
|
"id": "node_bicycle",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Nodes",
|
"en": "Nodes",
|
||||||
"de": "Knotenpunkte",
|
"de": "Knotenpunkte",
|
||||||
|
@ -321,6 +321,7 @@
|
||||||
],
|
],
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 16,
|
"minzoom": 16,
|
||||||
|
"id": "bicycle_guidepost",
|
||||||
"source": {
|
"source": {
|
||||||
"osmTags": {
|
"osmTags": {
|
||||||
"and": [
|
"and": [
|
||||||
|
|
|
@ -290,7 +290,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "all_streets",
|
"id": "not_cyclestreets",
|
||||||
"name": {
|
"name": {
|
||||||
"nl": "Alle straten",
|
"nl": "Alle straten",
|
||||||
"en": "All streets",
|
"en": "All streets",
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
"hideFromOverview": true,
|
"hideFromOverview": true,
|
||||||
"layers": [
|
"layers": [
|
||||||
{
|
{
|
||||||
"id": "osm-buildings",
|
"id": "osm_buildings_no_points",
|
||||||
"name": "All OSM-buildings",
|
"name": "All OSM-buildings",
|
||||||
"source": {
|
"source": {
|
||||||
"osmTags": {
|
"osmTags": {
|
||||||
|
@ -296,7 +296,7 @@
|
||||||
"name": "GRB geometries",
|
"name": "GRB geometries",
|
||||||
"title": "GRB outline",
|
"title": "GRB outline",
|
||||||
"calculatedTags": [
|
"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 */ )",
|
"_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:source:ref=get(feat)('_overlaps_with')?.feat?.properties['source:geometry:ref']",
|
||||||
"_osm_obj:id=get(feat)('_overlaps_with')?.feat?.properties?.id",
|
"_osm_obj:id=get(feat)('_overlaps_with')?.feat?.properties?.id",
|
||||||
|
@ -319,7 +319,7 @@
|
||||||
"tagRenderings": [
|
"tagRenderings": [
|
||||||
{
|
{
|
||||||
"id": "Import-button",
|
"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": [
|
"mappings": [
|
||||||
{
|
{
|
||||||
"#": "Failsafe",
|
"#": "Failsafe",
|
||||||
|
@ -371,7 +371,7 @@
|
||||||
"addr:housenumber!:={_osm_obj:addr:housenumber}"
|
"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": {
|
"if": {
|
||||||
|
@ -380,7 +380,7 @@
|
||||||
"_reverse_overlap_percentage>50"
|
"_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",
|
"builtin": "crab_address",
|
||||||
"override": {
|
"override": {
|
||||||
"calculatedTags+": [
|
"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_nr=get(feat)('_embedded_in')['addr:housenumber']+(get(feat)('_embedded_in')['addr:unit'] ?? '')",
|
||||||
"_embedding_street=get(feat)('_embedded_in')['addr:street']",
|
"_embedding_street=get(feat)('_embedded_in')['addr:street']",
|
||||||
"_embedding_id=get(feat)('_embedded_in').id",
|
"_embedding_id=get(feat)('_embedded_in').id",
|
||||||
|
@ -709,7 +709,7 @@
|
||||||
"text": {
|
"text": {
|
||||||
"nl": "Voeg dit adres als een nieuw adrespunt toe"
|
"nl": "Voeg dit adres als een nieuw adrespunt toe"
|
||||||
},
|
},
|
||||||
"snap_onto_layers": "osm-buildings"
|
"snap_onto_layers": "osm_buildings_no_points"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mappings": [
|
"mappings": [
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
{
|
{
|
||||||
"builtin": "shops",
|
"builtin": "shops",
|
||||||
"override": {
|
"override": {
|
||||||
"id": "medical-shops",
|
"id": "medical_shops",
|
||||||
"minzoom": 13,
|
"minzoom": 13,
|
||||||
"=filter": [
|
"=filter": [
|
||||||
"open_now",
|
"open_now",
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
{
|
{
|
||||||
"builtin": "crossings",
|
"builtin": "crossings",
|
||||||
"override": {
|
"override": {
|
||||||
|
"id": "crossings_no_traffic_lights",
|
||||||
"=presets": [
|
"=presets": [
|
||||||
{
|
{
|
||||||
"title": {
|
"title": {
|
||||||
|
|
|
@ -258,6 +258,7 @@
|
||||||
{
|
{
|
||||||
"builtin": "parking_spaces",
|
"builtin": "parking_spaces",
|
||||||
"override": {
|
"override": {
|
||||||
|
"id": "parking_spaces_disabled",
|
||||||
"source": {
|
"source": {
|
||||||
"osmTags": "parking_space=disabled"
|
"osmTags": "parking_space=disabled"
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
{
|
{
|
||||||
"builtin": "shops",
|
"builtin": "shops",
|
||||||
"override": {
|
"override": {
|
||||||
"id": "erotic-shop",
|
"id": "erotic_shop",
|
||||||
"source": {
|
"source": {
|
||||||
"osmTags": "shop=erotic"
|
"osmTags": "shop=erotic"
|
||||||
},
|
},
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
"builtin": "shelter",
|
"builtin": "shelter",
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 18,
|
"minzoom": 18,
|
||||||
|
"id": "pt_shelter",
|
||||||
"source": {
|
"source": {
|
||||||
"osmTags": {
|
"osmTags": {
|
||||||
"and": [
|
"and": [
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "address",
|
"id": "uk_address",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Known addresses in OSM"
|
"en": "Known addresses in OSM"
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
"hideFromOverview": true,
|
"hideFromOverview": true,
|
||||||
"layers": [
|
"layers": [
|
||||||
{
|
{
|
||||||
"id": "node2node",
|
"id": "node2node_hiking",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Node to node links",
|
"en": "Node to node links",
|
||||||
"de": "Knotenpunktverbindungen",
|
"de": "Knotenpunktverbindungen",
|
||||||
|
@ -120,7 +120,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "node",
|
"id": "node_hiking",
|
||||||
"name": {
|
"name": {
|
||||||
"en": "Nodes",
|
"en": "Nodes",
|
||||||
"de": "Knotenpunkte",
|
"de": "Knotenpunkte",
|
||||||
|
@ -279,6 +279,7 @@
|
||||||
],
|
],
|
||||||
"override": {
|
"override": {
|
||||||
"minzoom": 16,
|
"minzoom": 16,
|
||||||
|
"id": "guidepost_hiking",
|
||||||
"source": {
|
"source": {
|
||||||
"osmTags": {
|
"osmTags": {
|
||||||
"and": [
|
"and": [
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { Or } from "../../src/Logic/Tags/Or"
|
||||||
import { RegexTag } from "../../src/Logic/Tags/RegexTag"
|
import { RegexTag } from "../../src/Logic/Tags/RegexTag"
|
||||||
import { Utils } from "../../src/Utils"
|
import { Utils } from "../../src/Utils"
|
||||||
|
|
||||||
class LuaSnippets{
|
class LuaSnippets {
|
||||||
/**
|
/**
|
||||||
* The main piece of code that calls `process_poi`
|
* The main piece of code that calls `process_poi`
|
||||||
*/
|
*/
|
||||||
|
@ -25,23 +25,25 @@ class LuaSnippets{
|
||||||
"end",
|
"end",
|
||||||
""].join("\n")
|
""].join("\n")
|
||||||
|
|
||||||
public static combine(calls: string[]): string{
|
public static combine(calls: string[]): string {
|
||||||
return [
|
return [
|
||||||
`function process_poi(object, geom)`,
|
`function process_poi(object, geom)`,
|
||||||
...calls.map(c => " "+c+"(object, geom)"),
|
...calls.map(c => " " + c + "(object, geom)"),
|
||||||
`end`,
|
`end`,
|
||||||
].join("\n")
|
].join("\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GenerateLayerLua {
|
class GenerateLayerLua {
|
||||||
private readonly _layer: LayerConfig
|
private readonly _layer: LayerConfig
|
||||||
|
|
||||||
constructor(layer: LayerConfig) {
|
constructor(layer: LayerConfig) {
|
||||||
this._layer = layer
|
this._layer = layer
|
||||||
}
|
}
|
||||||
public functionName(){
|
|
||||||
|
public functionName() {
|
||||||
const l = this._layer
|
const l = this._layer
|
||||||
if(!l.source?.osmTags){
|
if (!l.source?.osmTags) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return `process_poi_${l.id}`
|
return `process_poi_${l.id}`
|
||||||
|
@ -49,7 +51,7 @@ class GenerateLayerLua {
|
||||||
|
|
||||||
public generateFunction(): string {
|
public generateFunction(): string {
|
||||||
const l = this._layer
|
const l = this._layer
|
||||||
if(!l.source?.osmTags){
|
if (!l.source?.osmTags) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
|
@ -75,10 +77,38 @@ class GenerateLayerLua {
|
||||||
" ",
|
" ",
|
||||||
` pois_${l.id}:insert(a)`,
|
` pois_${l.id}:insert(a)`,
|
||||||
"end",
|
"end",
|
||||||
""
|
"",
|
||||||
].join("\n")
|
].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 {
|
private toLuaFilter(tag: TagsFilter, useParens: boolean = false): string {
|
||||||
if (tag instanceof Tag) {
|
if (tag instanceof Tag) {
|
||||||
|
@ -99,14 +129,7 @@ class GenerateLayerLua {
|
||||||
return expr
|
return expr
|
||||||
}
|
}
|
||||||
if (tag instanceof RegexTag) {
|
if (tag instanceof RegexTag) {
|
||||||
if(typeof tag.value === "string" && tag.invert){
|
let expr = this.regexTagToLua(tag)
|
||||||
return `object.tags["${tag.key}"] ~= "${tag.value}"`
|
|
||||||
}
|
|
||||||
|
|
||||||
let expr = `not string.find(object.tags["${tag.key}"], "${tag.value}")`
|
|
||||||
if (!tag.invert) {
|
|
||||||
expr = "not " + expr
|
|
||||||
}
|
|
||||||
if (useParens) {
|
if (useParens) {
|
||||||
expr = "(" + expr + ")"
|
expr = "(" + expr + ")"
|
||||||
}
|
}
|
||||||
|
@ -124,17 +147,17 @@ class GenerateLayerFile extends Script {
|
||||||
}
|
}
|
||||||
|
|
||||||
async main(args: string[]) {
|
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 = [
|
const script = [
|
||||||
...generators.map(g => g.generateFunction()),
|
...generators.map(g => g.generateFunction()),
|
||||||
LuaSnippets.combine(Utils.NoNull(generators.map(g => g.functionName()))),
|
LuaSnippets.combine(Utils.NoNull(generators.map(g => g.functionName()))),
|
||||||
LuaSnippets.tail
|
LuaSnippets.tail,
|
||||||
].join("\n\n\n")
|
].join("\n\n\n")
|
||||||
const path = "build_db.lua"
|
const path = "build_db.lua"
|
||||||
fs.writeFileSync(path,script, "utf-8")
|
fs.writeFileSync(path, script, "utf-8")
|
||||||
console.log("Written", path)
|
console.log("Written", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue