From d48106ed502ec02806513f96f8f88343dabf583e Mon Sep 17 00:00:00 2001 From: math1985 Date: Mon, 16 May 2016 02:31:48 +0200 Subject: [PATCH 01/25] Database reload **This is a pull-request against the lua branch** This PR proposes a database-reload. It changes the documentation on the use of osm2pgsql, and adds a .lua file for preprocessing. This database import aims to be backwards compatible with older versions of the style. This resolves (at least part of) #1504. #Hstore Adding the hstore option to osm2pgsql allows the database to use all keys. This PR proposes using hstore for new keys, and using traditional columns for old keys. This allows us to stay compatible with old versions of the style. According to [@pnorman's benchmarks](http://www.paulnorman.ca/blog/2014/03/osm2pgsql-and-hstore/), using hstore without dropping columns would lead to a 9% size increase and a 0.38% speed decrease. Given the benefits of having all columns available, I would consider this acceptable. # Make polygon/linestring decision based on value This is based on the following unmerged PR to osm2pgsql: https://github.com/openstreetmap/osm2pgsql/pull/346 It makes the polygon/linestring decision based on the tag value, in addition to the tag key. In particular, highway=services and junction=yes are now treated as polygon, while leisure=track, man_made=embankment, man_made=breakwater, man_made=groyne, natural=cliff, natural=tree_row, historic=citywalls, waterway=derelict_canal, waterway=ditch, waterway=drain, waterway=river, waterway=stream, waterway=wadi, waterway=weir, power=line, and power=minor_line are now treated as linestring. This resolves #1362, resolves #137, resolves #268, and resolves #892. # Rendering order The new .lua file creates a osmcarto_z_order value in the database, which stores the rendering order we use. This will allow us to simplify the road queries. # Recommend -G flag for multipolygons This resolves #59. # Import ele on buildings This resolves #101. # Delete more meta-tags from imports The .lua file drops some more meta-information from imports that is of no need for rendering. This is based on the following unmerged PR to osm2pgsql: * https://github.com/openstreetmap/osm2pgsql/pull/532 --- INSTALL.md | 2 +- openstreetmap-carto.lua | 447 ++++++++++++++++++++++++++++++++++++++ openstreetmap-carto.style | 111 +--------- 3 files changed, 459 insertions(+), 101 deletions(-) create mode 100644 openstreetmap-carto.lua diff --git a/INSTALL.md b/INSTALL.md index 2930a5487e..4d0dce613b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,7 +5,7 @@ You need OpenStreetMap data loaded into a PostGIS database (see below for [depen It's probably easiest to grab an PBF of OSM data from [Mapzen](https://mapzen.com/metro-extracts/) or [geofabrik](http://download.geofabrik.de/). Once you've set up your PostGIS database, import with osm2pgsql: ``` -osm2pgsql -d gis ~/path/to/data.osm.pbf --style openstreetmap-carto.style +osm2pgsql -G --hstore -d gis ~/path/to/data.osm.pbf --style openstreetmap-carto.style --tag-transform-script ~/osm/openstreetmap-carto.lua ``` You can find a more detailed guide to setting up a database and loading data with osm2pgsql at [switch2osm.org](http://switch2osm.org/loading-osm-data/). diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua new file mode 100644 index 0000000000..5ddfd9bd57 --- /dev/null +++ b/openstreetmap-carto.lua @@ -0,0 +1,447 @@ +-- For documentation of Lua tag transformations, see: +-- https://github.com/openstreetmap/osm2pgsql/blob/master/docs/lua.md + +-- Custom keys that are defined by this file +custom_keys = { 'z_order', 'osmcarto_z_order' } + +-- Objects with any of the following keys will be treated as polygon +polygon_keys = { 'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisure', + 'man_made', 'military', 'natural', 'office', 'place', 'power', + 'public_transport', 'shop', 'sport', 'tourism', 'waterway', + 'wetland', 'water', 'aeroway', 'abandoned:aeroway', 'abandoned:amenity', + 'abandoned:building', 'abandoned:landuse', 'abandoned:power', 'area:highway' } + +-- Objects with any of the following key/value combinations will be treated as polygon +polygon_values = { + {'highway', 'services'}, + {'junction', 'yes'} + } + +-- Objects with any of the following key/value combinations will be treated as linestring +linestring_values = { + {'leisure', 'track'}, + {'man_made', 'embankment'}, + {'man_made', 'breakwater'}, + {'man_made', 'groyne'}, + {'natural', 'cliff'}, + {'natural', 'tree_row'}, + {'historic', 'citywalls'}, + {'waterway', 'canal'}, + {'waterway', 'derelict_canal'}, + {'waterway', 'ditch'}, + {'waterway', 'drain'}, + {'waterway', 'river'}, + {'waterway', 'stream'}, + {'waterway', 'wadi'}, + {'waterway', 'weir'}, + {'power', 'line'}, + {'power', 'minor_line'} + } + +-- The following keys will be deleted +delete_tags = { + 'note', + 'note:.*', + 'source', + 'source_ref', + 'source:.*', + 'attribution', + 'comment', + 'fixme', + -- Tags generally dropped by editors, not otherwise covered + 'created_by', + 'odbl', + 'odbl:note', + -- Lots of import tags + -- EUROSHA (Various countries) + 'project:eurosha_2012', + -- Corine (CLC) (Europe) + 'CLC:.*', + + -- UrbIS (Brussels, BE) + 'ref:UrbIS', + + -- Geobase (CA) + 'geobase:.*', + -- NHN (CA) + 'accuracy:meters', + 'sub_sea:type', + 'waterway:type', + -- CanVec (CA) + 'canvec:.*', + -- StatsCan (CA) + 'statscan:rbuid', + -- Geobase (CA) + 'geobase:.*', + + -- RUIAN (CZ) + 'ref:ruian:addr', + 'ref:ruian', + 'building:ruian:type', + -- DIBAVOD (CZ) + 'dibavod:id', + -- UIR-ADR (CZ) + 'uir_adr:ADRESA_KOD', + + -- osak (DK) + 'osak:.*', + -- kms (DK) + 'kms:.*', + -- GST (DK) + 'gst:feat_id', + + -- Maa-amet (EE) + 'maaamet:ETAK', + + -- ngbe (ES) + -- See also note:es and source:file above + 'ngbe:.*', + + -- FANTOIR (FR) + 'ref:FR:FANTOIR', + + -- Friuli Venezia Giulia (IT) + 'it:fvg:.*', + + -- KSJ2 (JA) + -- See also note:ja and source_ref above + 'KSJ2:.*', + -- Yahoo/ALPS (JA) + 'yh:.*', + + -- 3dshapes (NL) + '3dshapes:ggmodelk', + -- AND (NL) + 'AND_nosr_r', + + -- OPPDATERIN (NO) + 'OPPDATERIN', + + -- LINZ (NZ) + 'LINZ2OSM:.*', + 'linz2osm:.*', + 'LINZ:.*', + + -- Various imports (PL) + 'addr:city:simc', + 'addr:street:sym_ul', + 'building:usage:pl', + 'building:use:pl', + -- WroclawGIS (PL) + 'WroclawGIS:.*', + -- TERYT (PL) + 'teryt:simc', + + -- RABA (SK) + 'raba:id', + + -- Naptan (UK) + 'naptan:.*', + + -- TIGER (US) + 'tiger:.*', + -- GNIS (US) + 'gnis:.*', + -- DCGIS (Washington DC, US) + 'dcgis:gis_id', + -- National Hydrography Dataset (US) + 'NHD:.*', + 'nhd:.*', + -- Building Identification Number (New York, US) + 'nycdoitt:bin', + -- Chicago Building Inport (US) + 'chicago:building_id', + -- Louisville, Kentucky/Building Outlines Import (US) + 'lojic:bgnum', + -- MassGIS (Massachusetts, US) + 'massgis:way_id', + + -- mvdgis (Montevideo, UY) + 'mvdgis:.*', + + -- misc + 'import', + 'import_uuid', + 'OBJTYPE', + 'SK53_bulk:load' +} + + +-- Array used to specify z_order and osmcarto_z_order per key/value combination. +-- The former is used for backwards compatibility and for uses that use a single +-- database for multiple rendering styles. +-- Each element has the form {key, value, z_order, osmcarto_z_order, is_road}. +-- If is_road=1, the object will be added to planet_osm_roads. +zordering_tags = { + { 'railway', nil, 5, 0, 1}, + { 'boundary', 'administrative', 0, 0, 1}, + { 'bridge', 'yes', 10, 0, 0 }, + { 'bridge', 'true', 10, 0, 0 }, + { 'bridge', 1, 10, 0, 0 }, + { 'tunnel', 'yes', -10, 0, 0}, + { 'tunnel', 'true', -10, 0, 0}, + { 'tunnel', 1, -10, 0, 0}, + {'railway', 'rail', 0, 440, 1}, + {'railway', 'subway', 0, 420, 1}, + {'railway', 'narrow_gauge', 0, 420, 1}, + {'railway', 'light_rail', 0, 420, 1}, + {'railway', 'preserved', 0, 420, 1}, + {'railway', 'funicular', 0, 420, 1}, + {'railway', 'monorail', 0, 420, 1}, + {'railway', 'miniature', 0, 420, 1}, + {'railway', 'turntable', 0, 420, 1}, + {'railway', 'tram', 0, 410, 1}, + {'railway', 'tram-service', 0, 405, 1}, + {'railway', 'disused', 0, 400, 1}, + {'railway', 'construction', 0, 400, 1}, + {'highway', 'motorway', 9, 380, 1}, + {'highway', 'trunk', 8, 370, 1}, + {'highway', 'primary', 7, 360, 1}, + {'highway', 'secondary', 6, 350, 1}, + {'highway', 'tertiary', 4, 340, 0}, + {'highway', 'residential', 3, 330, 0}, + {'highway', 'unclassified', 3, 330, 0}, + {'highway', 'road', 3, 330, 0}, + {'highway', 'living_street', 0, 320, 0}, + {'highway', 'pedestrian', 0, 310, 0}, + {'highway', 'raceway', 0, 300, 0}, + {'highway', 'motorway_link', 9, 240, 1}, + {'highway', 'trunk_link', 6, 230, 1}, + {'highway', 'primary_link', 5, 220, 1}, + {'highway', 'secondary_link', 4, 210, 1}, + {'highway', 'tertiary_link', 3, 200, 0}, + {'highway', 'service', 0, 150, 0}, + {'highway', 'track', 0, 110, 0}, + {'highway', 'path', 0, 100, 0}, + {'highway', 'footway', 0, 100, 0}, + {'highway', 'bridleway', 0, 100, 0}, + {'highway', 'cycleway', 0, 100, 0}, + {'highway', 'steps', 0, 100, 0}, + {'highway', 'platform', 0, 90, 0}, + {'highway', 'minor', 3, 0, 0}, + {'railway', 'platform', 0, 90, 0}, + {'aeroway', 'runway', 0, 60, 0}, + {'aeroway', 'taxiway', 0, 50, 0}, + {'highway', 'construction', 0, 10, 0} +} + +function add_z_order(keyvalues) + -- The default z_order is 0 + z_order = 0 + osmcarto_z_order = 0 + + -- Increase or decrease z_order based on the specific key/value combination as specified in zordering_tags + for i,k in ipairs(zordering_tags) do + -- If the value in zordering_tags is specified, match key and value. Otherwise, match key only. + if ((k[2] and keyvalues[k[1]] == k[2]) or (k[2] == nil and keyvalues[k[1]] ~= nil)) then + -- If the fifth component of the element of zordering_tags is 1, add the object to planet_osm_roads + if (k[5] == 1) then + roads = 1 + end + z_order = z_order + k[3] + osmcarto_z_order = math.max(osmcarto_z_order, k[4]) + end + end + + -- Add z_order as key/value combination + keyvalues["osmcarto_z_order"] = osmcarto_z_order + keyvalues["z_order"] = z_order + + return keyvalues, roads +end + +-- Filtering on nodes, ways, and relations +function filter_tags_generic(keyvalues, numberofkeys) + filter = 0 -- Will object be filtered out? + + -- Delete tags listed in delete_tags + for k, v in pairs (keyvalues) do + match = false + for _, d in ipairs(delete_tags) do + match = match or string.find(k, d) + end + if match then + keyvalues[k] = nil + numberofkeys = numberofkeys - 1 + end + end + + -- Filter out objects with 0 tags + if numberofkeys == 0 then + filter = 1 + return filter, keyvalues + end + + return filter, keyvalues +end + +-- Filtering on nodes +function filter_tags_node (keyvalues, numberofkeys) + return filter_tags_generic(keyvalues, numberofkeys) +end + +-- Filtering on relations +function filter_basic_tags_rel (keyvalues, numberofkeys) + -- Filter out objects that are filtered out by filter_tags_generic + filter, keyvalues = filter_tags_generic(keyvalues, numberofkeys) + if filter == 1 then + return filter, keyvalues + end + + -- Filter out all relations except route, multipolygon and boundary relations + if ((keyvalues["type"] ~= "route") and (keyvalues["type"] ~= "multipolygon") and (keyvalues["type"] ~= "boundary")) then + filter = 1 + return filter, keyvalues + end + + return filter, keyvalues +end + +-- Filtering on ways +function filter_tags_way (keyvalues, numberofkeys) + filter = 0 -- Will object be filtered out? + polygon = 0 -- Will object be treated as polygon? + roads = 0 -- Will object be added to planet_osm_roads? + + -- Filter out objects that are filtered out by filter_tags_generic + filter, keyvalues = filter_tags_generic(keyvalues, numberofkeys) + if filter == 1 then + return filter, keyvalues, polygon, roads + end + + -- Treat objects with a key in polygon_keys as polygon + for i,k in ipairs(polygon_keys) do + if keyvalues[k] then + polygontag = 1 + -- However, if the key/value combination occurs in linestring_values, do not treat the object as polygon + for index,tag in pairs(linestring_values) do + if k == tag[1] and keyvalues[k] == tag[2] then + polygontag = 0 + break + end + end + if polygontag == 1 then + polygon = 1 + break + end + end + end + + -- Treat objects with a key/value combination in polygon_values as polygon + if polygon == 0 then + for index,tag in pairs(polygon_values) do + if keyvalues[tag[1]] == tag[2] then + polygon=1 + break + end + end + end + + -- Treat objects tagged as area=yes, area=1, or area=true as polygon, + -- and treat objects tagged as area=no, area=0, or area=false not as polygon + if ((keyvalues["area"] == "yes") or (keyvalues["area"] == "1") or (keyvalues["area"] == "true")) then + polygon = 1; + elseif ((keyvalues["area"] == "no") or (keyvalues["area"] == "0") or (keyvalues["area"] == "false")) then + polygon = 0; + end + + -- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads + keyvalues, roads = add_z_order(keyvalues) + + return filter, keyvalues, polygon, roads +end + +function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, membercount) + filter = 0 -- Will object be filtered out? + linestring = 0 -- Will object be treated as linestring? + polygon = 0 -- Will object be treated as polygon? + roads = 0 -- Will object be added to planet_osm_roads? + membersuperseded = {} + for i = 1, membercount do + membersuperseded[i] = 0 -- Will member be ignored when handling areas? + end + + type = keyvalues["type"] + + -- Remove type key + keyvalues["type"] = nil + + -- Relations with type=boundary are treated as linestring + if (type == "boundary") then + linestring = 1 + end + -- Relations with type=multipolygon and boundary=* are treated as linestring + if ((type == "multipolygon") and keyvalues["boundary"]) then + linestring = 1 + -- For multipolygons... + elseif (type == "multipolygon") then + -- Treat as polygon + polygon = 1 + haspolygontags = false + -- Count the number of polygon tags + -- First count keys in polygon_keys + for i,k in ipairs(polygon_keys) do + if keyvalues[k] then + polygontag = 1 + -- However, if the key/value combination occurs in linestring_values, do not count the object as polygon + for index,tag in pairs(linestring_values) do + if k == tag[1] and keyvalues[k] == tag[2] then + polygontag = 0 + break + end + end + if polygontag == 1 then + haspolygontags = true + break + end + end + end + -- Treat objects with a key/value combination in polygon_values as polygon + if not haspolygontags then + for index,tag in pairs(polygon_values) do + if keyvalues[tag[1]] == tag[2] then + haspolygontags = true + break + end + end + end + -- Support for old-style multipolygons (1/2): + -- If there are no polygon tags, add tags from all outer elements to the multipolygon itself + if not haspolygontags then + for i = 1,membercount do + if (roles[i] == "outer") then + for k,v in pairs(keyvaluemembers[i]) do + keyvalues[k] = v + end + end + end + end + -- Support for old-style multipolygons (2/2): + -- For any member of the multipolygon, set membersuperseded to 1 (i.e. don't deal with it as area as well), + -- except when the member has a (non-custom) key/value combination that is not also a key/value combination of the multipolygon itself + for i = 1,membercount do + superseded = 1 + for k,v in pairs(keyvaluemembers[i]) do + if ((keyvalues[k] == nil or keyvalues[k] ~= v) and not is_in(k,custom_keys)) then + superseded = 0; + break + end + end + membersuperseded[i] = superseded + end + end + + -- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads + keyvalues, roads = add_z_order(keyvalues) + + return filter, keyvalues, membersuperseded, linestring, polygon, roads +end + +function is_in (needle, haystack) + for index, value in ipairs (haystack) do + if value == needle then + return true + end + end + return false +end diff --git a/openstreetmap-carto.style b/openstreetmap-carto.style index f2322cf322..ad69fc74a1 100644 --- a/openstreetmap-carto.style +++ b/openstreetmap-carto.style @@ -1,5 +1,6 @@ -# This is the .style file for OpenStreetMap Carto, which is currently -# the same as the upstream osm2pgsql style +# This is the osm2pgsql .style file for openstreetmap-carto. +# phstore is used instead of polygon,nocolumn to preserve compatibility +# with older osm2pgsql versions # OsmType Tag DataType Flags node,way access text linear @@ -10,25 +11,19 @@ node,way admin_level text linear node,way aerialway text linear node,way aeroway text polygon node,way amenity text polygon -node,way area text # hard coded support for area=1/yes => polygon is in osm2pgsql +node,way area text polygon # hard coded support for area=1/yes => polygon is in osm2pgsql node,way barrier text linear -node,way bicycle text -node,way brand text linear +node,way bicycle text linear node,way bridge text linear node,way boundary text linear node,way building text polygon node capital text linear node,way construction text linear node,way covered text linear -node,way culvert text linear -node,way cutting text linear node,way denomination text linear -node,way disused text linear -node ele text linear -node,way embankment text linear +node,way ele text linear node,way foot text linear node,way generator:source text linear -node,way harbour text polygon node,way highway text linear node,way historic text polygon node,way horse text linear @@ -40,114 +35,30 @@ node,way leisure text polygon node,way lock text linear node,way man_made text polygon node,way military text polygon -node,way motorcar text linear node,way name text linear node,way natural text polygon # natural=coastline tags are discarded by a hard coded rule in osm2pgsql -node,way office text polygon node,way oneway text linear node,way operator text linear node,way place text polygon -node poi text node,way population text linear node,way power text polygon node,way power_source text linear -node,way public_transport text polygon node,way railway text linear node,way ref text linear -node,way religion text nocache +node,way religion text linear node,way route text linear node,way service text linear node,way shop text polygon -node,way sport text polygon node,way surface text linear -node,way toll text linear node,way tourism text polygon -node,way tower:type text linear way tracktype text linear node,way tunnel text linear node,way water text polygon node,way waterway text polygon node,way wetland text polygon node,way width text linear -node,way wood text linear -node,way z_order int4 linear # This is calculated during import -way way_area real # This is calculated during import +way way_area real linear # This is calculated during import -# Area tags -# We don't make columns for these tags, but objects with them are areas. -way abandoned:aeroway text phstore -way abandoned:amenity text phstore -way abandoned:building text phstore -way abandoned:landuse text phstore -way abandoned:power text phstore -way area:highway text phstore - -# Deleted tags -# These are tags that are generally regarded as useless for most rendering. -# Most of them are from imports or intended as internal information for mappers -# Some of them are automatically deleted by editors. -# If you want some of them, perhaps for a debugging layer, just delete the lines. - -# These tags are used by mappers to keep track of data. -# They aren't very useful for rendering. -node,way note text delete -node,way note:* text delete -node,way source text delete -node,way source_ref text delete -node,way source:* text delete -node,way attribution text delete -node,way comment text delete -node,way fixme text delete - -# Tags generally dropped by editors, not otherwise covered -node,way created_by text delete -node,way odbl text delete -node,way odbl:note text delete -node,way SK53_bulk:load text delete - -# Lots of import tags -# TIGER (US) -node,way tiger:* text delete - -# NHD (US) -# NHD has been converted every way imaginable -node,way NHD:* text delete -node,way nhd:* text delete - -# GNIS (US) -node,way gnis:* text delete - -# Geobase (CA) -node,way geobase:* text delete -# NHN (CA) -node,way accuracy:meters text delete -node,way sub_sea:type text delete -node,way waterway:type text delete - -# KSJ2 (JA) -# See also note:ja and source_ref above -node,way KSJ2:* text delete -# Yahoo/ALPS (JA) -node,way yh:* text delete - -# osak (DK) -node,way osak:* text delete - -# kms (DK) -node,way kms:* text delete - -# ngbe (ES) -# See also note:es and source:file above -node,way ngbe:* text delete - -# naptan (UK) -node,way naptan:* text delete - -# Corine (CLC) (Europe) -node,way CLC:* text delete - -# misc -node,way 3dshapes:ggmodelk text delete -node,way AND_nosr_r text delete -node,way import text delete -node,way it:fvg:* text delete +# Columns defined in openstreetmap-carto.lua file +way z_order int4 linear +way osmcarto_z_order int4 linear From e0aa01d40211d9df083bf27d0a73f1d47b54bae0 Mon Sep 17 00:00:00 2001 From: math1985 Date: Tue, 17 May 2016 20:06:37 +0200 Subject: [PATCH 02/25] Add highway=rest_area to list of tags treated as polygon --- openstreetmap-carto.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 5ddfd9bd57..c8b8a7b960 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -14,6 +14,7 @@ polygon_keys = { 'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisu -- Objects with any of the following key/value combinations will be treated as polygon polygon_values = { {'highway', 'services'}, + {'highway', 'rest_area'}, {'junction', 'yes'} } From 1ec1cfc5f29c34fe456fe2337e0930c61084e78c Mon Sep 17 00:00:00 2001 From: math1985 Date: Tue, 17 May 2016 23:01:28 +0200 Subject: [PATCH 03/25] Merge duplicate code to determine if object is polygon --- openstreetmap-carto.lua | 110 +++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 64 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index c8b8a7b960..cab83e615d 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -310,41 +310,7 @@ function filter_tags_way (keyvalues, numberofkeys) return filter, keyvalues, polygon, roads end - -- Treat objects with a key in polygon_keys as polygon - for i,k in ipairs(polygon_keys) do - if keyvalues[k] then - polygontag = 1 - -- However, if the key/value combination occurs in linestring_values, do not treat the object as polygon - for index,tag in pairs(linestring_values) do - if k == tag[1] and keyvalues[k] == tag[2] then - polygontag = 0 - break - end - end - if polygontag == 1 then - polygon = 1 - break - end - end - end - - -- Treat objects with a key/value combination in polygon_values as polygon - if polygon == 0 then - for index,tag in pairs(polygon_values) do - if keyvalues[tag[1]] == tag[2] then - polygon=1 - break - end - end - end - - -- Treat objects tagged as area=yes, area=1, or area=true as polygon, - -- and treat objects tagged as area=no, area=0, or area=false not as polygon - if ((keyvalues["area"] == "yes") or (keyvalues["area"] == "1") or (keyvalues["area"] == "true")) then - polygon = 1; - elseif ((keyvalues["area"] == "no") or (keyvalues["area"] == "0") or (keyvalues["area"] == "false")) then - polygon = 0; - end + polygon = haspolygontags(keyvalues) -- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads keyvalues, roads = add_z_order(keyvalues) @@ -378,37 +344,11 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc elseif (type == "multipolygon") then -- Treat as polygon polygon = 1 - haspolygontags = false - -- Count the number of polygon tags - -- First count keys in polygon_keys - for i,k in ipairs(polygon_keys) do - if keyvalues[k] then - polygontag = 1 - -- However, if the key/value combination occurs in linestring_values, do not count the object as polygon - for index,tag in pairs(linestring_values) do - if k == tag[1] and keyvalues[k] == tag[2] then - polygontag = 0 - break - end - end - if polygontag == 1 then - haspolygontags = true - break - end - end - end - -- Treat objects with a key/value combination in polygon_values as polygon - if not haspolygontags then - for index,tag in pairs(polygon_values) do - if keyvalues[tag[1]] == tag[2] then - haspolygontags = true - break - end - end - end + -- Support for old-style multipolygons (1/2): -- If there are no polygon tags, add tags from all outer elements to the multipolygon itself - if not haspolygontags then + haspolytags = haspolygontags(keyvalues) + if (haspolytags == 0) then for i = 1,membercount do if (roles[i] == "outer") then for k,v in pairs(keyvaluemembers[i]) do @@ -438,6 +378,48 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc return filter, keyvalues, membersuperseded, linestring, polygon, roads end +-- Check if an object with given tags should be treated as polygon +function haspolygontags (tags) + -- Treat objects tagged as area=yes, area=1, or area=true as polygon, + -- and treat objects tagged as area=no, area=0, or area=false not as polygon + if ((tags["area"] == "yes") or (tags["area"] == "1") or (tags["area"] == "true")) then + return 1 + elseif ((tags["area"] == "no") or (tags["area"] == "0") or (tags["area"] == "false")) then + return 0 + end + + -- Treat objects with a key in polygon_keys as polygon + haspolytags = 0 + for i,k in ipairs(polygon_keys) do + if tags[k] then + polygontag = 1 + -- However, if the key/value combination occurs in linestring_values, do not treat the object as polygon + for index,tag in pairs(linestring_values) do + if k == tag[1] and tags[k] == tag[2] then + polygontag = 0 + break + end + end + if polygontag == 1 then + haspolytags = 1 + break + end + end + end + + -- Treat objects with a key/value combination in polygon_values as polygon + if polygon == 0 then + for index,tag in pairs(polygon_values) do + if tags[tag[1]] == tag[2] then + haspolytags = 1 + break + end + end + end + + return haspolytags +end + function is_in (needle, haystack) for index, value in ipairs (haystack) do if value == needle then From 02edb0ab97a09bda3a4fab0ef060c40db0ad54d2 Mon Sep 17 00:00:00 2001 From: math1985 Date: Tue, 17 May 2016 23:39:23 +0200 Subject: [PATCH 04/25] Explicitly make variables in .lua script local --- openstreetmap-carto.lua | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index cab83e615d..e0eb110a90 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -228,8 +228,8 @@ zordering_tags = { function add_z_order(keyvalues) -- The default z_order is 0 - z_order = 0 - osmcarto_z_order = 0 + local z_order = 0 + local osmcarto_z_order = 0 -- Increase or decrease z_order based on the specific key/value combination as specified in zordering_tags for i,k in ipairs(zordering_tags) do @@ -253,7 +253,7 @@ end -- Filtering on nodes, ways, and relations function filter_tags_generic(keyvalues, numberofkeys) - filter = 0 -- Will object be filtered out? + local filter = 0 -- Will object be filtered out? -- Delete tags listed in delete_tags for k, v in pairs (keyvalues) do @@ -284,7 +284,7 @@ end -- Filtering on relations function filter_basic_tags_rel (keyvalues, numberofkeys) -- Filter out objects that are filtered out by filter_tags_generic - filter, keyvalues = filter_tags_generic(keyvalues, numberofkeys) + local filter, keyvalues = filter_tags_generic(keyvalues, numberofkeys) if filter == 1 then return filter, keyvalues end @@ -300,9 +300,9 @@ end -- Filtering on ways function filter_tags_way (keyvalues, numberofkeys) - filter = 0 -- Will object be filtered out? - polygon = 0 -- Will object be treated as polygon? - roads = 0 -- Will object be added to planet_osm_roads? + local filter = 0 -- Will object be filtered out? + local polygon = 0 -- Will object be treated as polygon? + local roads = 0 -- Will object be added to planet_osm_roads? -- Filter out objects that are filtered out by filter_tags_generic filter, keyvalues = filter_tags_generic(keyvalues, numberofkeys) @@ -319,16 +319,16 @@ function filter_tags_way (keyvalues, numberofkeys) end function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, membercount) - filter = 0 -- Will object be filtered out? - linestring = 0 -- Will object be treated as linestring? - polygon = 0 -- Will object be treated as polygon? - roads = 0 -- Will object be added to planet_osm_roads? - membersuperseded = {} + local filter = 0 -- Will object be filtered out? + local linestring = 0 -- Will object be treated as linestring? + local polygon = 0 -- Will object be treated as polygon? + local roads = 0 -- Will object be added to planet_osm_roads? + local membersuperseded = {} for i = 1, membercount do membersuperseded[i] = 0 -- Will member be ignored when handling areas? end - type = keyvalues["type"] + local type = keyvalues["type"] -- Remove type key keyvalues["type"] = nil @@ -373,7 +373,7 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc end -- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads - keyvalues, roads = add_z_order(keyvalues) + local keyvalues, roads = add_z_order(keyvalues) return filter, keyvalues, membersuperseded, linestring, polygon, roads end @@ -389,10 +389,10 @@ function haspolygontags (tags) end -- Treat objects with a key in polygon_keys as polygon - haspolytags = 0 + local haspolytags = 0 for i,k in ipairs(polygon_keys) do if tags[k] then - polygontag = 1 + local polygontag = 1 -- However, if the key/value combination occurs in linestring_values, do not treat the object as polygon for index,tag in pairs(linestring_values) do if k == tag[1] and tags[k] == tag[2] then From e5660e6a431bd733887b527c22a15c381548ca5d Mon Sep 17 00:00:00 2001 From: math1985 Date: Tue, 17 May 2016 23:43:28 +0200 Subject: [PATCH 05/25] Whitespace in .lua file --- openstreetmap-carto.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index e0eb110a90..c22e55072f 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -2,14 +2,14 @@ -- https://github.com/openstreetmap/osm2pgsql/blob/master/docs/lua.md -- Custom keys that are defined by this file -custom_keys = { 'z_order', 'osmcarto_z_order' } +custom_keys = {'z_order', 'osmcarto_z_order'} -- Objects with any of the following keys will be treated as polygon -polygon_keys = { 'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisure', +polygon_keys = {'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisure', 'man_made', 'military', 'natural', 'office', 'place', 'power', 'public_transport', 'shop', 'sport', 'tourism', 'waterway', 'wetland', 'water', 'aeroway', 'abandoned:aeroway', 'abandoned:amenity', - 'abandoned:building', 'abandoned:landuse', 'abandoned:power', 'area:highway' } + 'abandoned:building', 'abandoned:landuse', 'abandoned:power', 'area:highway'} -- Objects with any of the following key/value combinations will be treated as polygon polygon_values = { @@ -174,14 +174,14 @@ delete_tags = { -- Each element has the form {key, value, z_order, osmcarto_z_order, is_road}. -- If is_road=1, the object will be added to planet_osm_roads. zordering_tags = { - { 'railway', nil, 5, 0, 1}, - { 'boundary', 'administrative', 0, 0, 1}, - { 'bridge', 'yes', 10, 0, 0 }, - { 'bridge', 'true', 10, 0, 0 }, - { 'bridge', 1, 10, 0, 0 }, - { 'tunnel', 'yes', -10, 0, 0}, - { 'tunnel', 'true', -10, 0, 0}, - { 'tunnel', 1, -10, 0, 0}, + {'railway', nil, 5, 0, 1}, + {'boundary', 'administrative', 0, 0, 1}, + {'bridge', 'yes', 10, 0, 0}, + {'bridge', 'true', 10, 0, 0}, + {'bridge', 1, 10, 0, 0}, + {'tunnel', 'yes', -10, 0, 0}, + {'tunnel', 'true', -10, 0, 0}, + {'tunnel', 1, -10, 0, 0}, {'railway', 'rail', 0, 440, 1}, {'railway', 'subway', 0, 420, 1}, {'railway', 'narrow_gauge', 0, 420, 1}, From d524487148e82ee22a32865f81ca453f7d17649a Mon Sep 17 00:00:00 2001 From: math1985 Date: Tue, 17 May 2016 23:46:35 +0200 Subject: [PATCH 06/25] Move filtering out objects with 0 tags to beginning of function in .lua file --- openstreetmap-carto.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index c22e55072f..3809f5a249 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -255,6 +255,12 @@ end function filter_tags_generic(keyvalues, numberofkeys) local filter = 0 -- Will object be filtered out? + -- Filter out objects with 0 tags + if numberofkeys == 0 then + filter = 1 + return filter, keyvalues + end + -- Delete tags listed in delete_tags for k, v in pairs (keyvalues) do match = false @@ -267,10 +273,9 @@ function filter_tags_generic(keyvalues, numberofkeys) end end - -- Filter out objects with 0 tags + -- Filter out objects that have 0 tags after deleting tags if numberofkeys == 0 then filter = 1 - return filter, keyvalues end return filter, keyvalues From d276c903777e27d0754479d342a44780805203fd Mon Sep 17 00:00:00 2001 From: math1985 Date: Tue, 17 May 2016 23:47:43 +0200 Subject: [PATCH 07/25] Code simplification --- openstreetmap-carto.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 3809f5a249..9845d9df22 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -258,7 +258,7 @@ function filter_tags_generic(keyvalues, numberofkeys) -- Filter out objects with 0 tags if numberofkeys == 0 then filter = 1 - return filter, keyvalues + return 1, {} end -- Delete tags listed in delete_tags From 1b82cb6227ce77c905bd1ad24080fa5af354f97e Mon Sep 17 00:00:00 2001 From: math1985 Date: Sun, 22 May 2016 21:23:46 +0200 Subject: [PATCH 08/25] Typo --- openstreetmap-carto.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 9845d9df22..f007638d0e 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -413,7 +413,7 @@ function haspolygontags (tags) end -- Treat objects with a key/value combination in polygon_values as polygon - if polygon == 0 then + if haspolytags == 0 then for index,tag in pairs(polygon_values) do if tags[tag[1]] == tag[2] then haspolytags = 1 From 343d1c9c613b1e27f4f758fe164da922a4a964c7 Mon Sep 17 00:00:00 2001 From: math1985 Date: Sun, 22 May 2016 21:59:25 +0200 Subject: [PATCH 09/25] Small performance optimization --- openstreetmap-carto.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index f007638d0e..98524f64f5 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -263,14 +263,13 @@ function filter_tags_generic(keyvalues, numberofkeys) -- Delete tags listed in delete_tags for k, v in pairs (keyvalues) do - match = false - for _, d in ipairs(delete_tags) do - match = match or string.find(k, d) - end - if match then - keyvalues[k] = nil - numberofkeys = numberofkeys - 1 - end + for _, d in ipairs(delete_tags) do + if string.find(k, d) then + keyvalues[k] = nil + numberofkeys = numberofkeys - 1 + break + end + end end -- Filter out objects that have 0 tags after deleting tags From 8d0489e3d95f65e140d1e02bed67b5b5a07bb711 Mon Sep 17 00:00:00 2001 From: math1985 Date: Mon, 30 May 2016 15:21:27 +0200 Subject: [PATCH 10/25] Small code optimization --- openstreetmap-carto.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 98524f64f5..0d05adb204 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -253,14 +253,13 @@ end -- Filtering on nodes, ways, and relations function filter_tags_generic(keyvalues, numberofkeys) - local filter = 0 -- Will object be filtered out? - -- Filter out objects with 0 tags if numberofkeys == 0 then - filter = 1 return 1, {} end + local filter = 0 -- Will object be filtered out? + -- Delete tags listed in delete_tags for k, v in pairs (keyvalues) do for _, d in ipairs(delete_tags) do From d34bebcd94dec4aa5e15bc9d854ad4f012e4bc81 Mon Sep 17 00:00:00 2001 From: math1985 Date: Mon, 30 May 2016 15:23:24 +0200 Subject: [PATCH 11/25] Small code optimization --- openstreetmap-carto.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 0d05adb204..51d2989040 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -273,10 +273,10 @@ function filter_tags_generic(keyvalues, numberofkeys) -- Filter out objects that have 0 tags after deleting tags if numberofkeys == 0 then - filter = 1 + return 1, {} end - return filter, keyvalues + return 0, keyvalues end -- Filtering on nodes @@ -289,16 +289,15 @@ function filter_basic_tags_rel (keyvalues, numberofkeys) -- Filter out objects that are filtered out by filter_tags_generic local filter, keyvalues = filter_tags_generic(keyvalues, numberofkeys) if filter == 1 then - return filter, keyvalues + return 1, keyvalues end -- Filter out all relations except route, multipolygon and boundary relations if ((keyvalues["type"] ~= "route") and (keyvalues["type"] ~= "multipolygon") and (keyvalues["type"] ~= "boundary")) then - filter = 1 - return filter, keyvalues + return 1, keyvalues end - return filter, keyvalues + return 0, keyvalues end -- Filtering on ways From 21d9b803d0038c228c66fc803b784aa250017538 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Mon, 30 May 2016 06:59:29 -0700 Subject: [PATCH 12/25] Combine boundary relation checks --- openstreetmap-carto.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 51d2989040..0394879f40 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -335,12 +335,8 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc -- Remove type key keyvalues["type"] = nil - -- Relations with type=boundary are treated as linestring - if (type == "boundary") then - linestring = 1 - end - -- Relations with type=multipolygon and boundary=* are treated as linestring - if ((type == "multipolygon") and keyvalues["boundary"]) then + -- Boundary relations are treated as linestring + if type == "boundary" or (type == "multipolygon" and keyvalues["boundary"]) then linestring = 1 -- For multipolygons... elseif (type == "multipolygon") then From 118c5cfc2b45fe47b89acfaa2c14be9ef1d4b328 Mon Sep 17 00:00:00 2001 From: math1985 Date: Mon, 30 May 2016 16:28:45 +0200 Subject: [PATCH 13/25] Move columns that are not used in WHERE statements to osm2pgsql --- openstreetmap-carto.style | 9 -------- project.mml | 28 ++++++++++++------------ project.yaml | 46 +++++++++++++++++++-------------------- 3 files changed, 37 insertions(+), 46 deletions(-) diff --git a/openstreetmap-carto.style b/openstreetmap-carto.style index ad69fc74a1..cd8c961763 100644 --- a/openstreetmap-carto.style +++ b/openstreetmap-carto.style @@ -20,14 +20,10 @@ node,way building text polygon node capital text linear node,way construction text linear node,way covered text linear -node,way denomination text linear -node,way ele text linear node,way foot text linear -node,way generator:source text linear node,way highway text linear node,way historic text polygon node,way horse text linear -node,way intermittent text linear node,way junction text linear node,way landuse text polygon node,way layer text linear @@ -38,11 +34,8 @@ node,way military text polygon node,way name text linear node,way natural text polygon # natural=coastline tags are discarded by a hard coded rule in osm2pgsql node,way oneway text linear -node,way operator text linear node,way place text polygon -node,way population text linear node,way power text polygon -node,way power_source text linear node,way railway text linear node,way ref text linear node,way religion text linear @@ -55,8 +48,6 @@ way tracktype text linear node,way tunnel text linear node,way water text polygon node,way waterway text polygon -node,way wetland text polygon -node,way width text linear way way_area real linear # This is calculated during import # Columns defined in openstreetmap-carto.lua file diff --git a/project.mml b/project.mml index aac77f8532..90818c191d 100644 --- a/project.mml +++ b/project.mml @@ -100,7 +100,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, name, way_pixels,\n COALESCE(wetland, landuse, \"natural\") AS feature\n FROM (SELECT\n way, COALESCE(name, '') AS name,\n ('landuse_' || (CASE WHEN landuse IN ('forest', 'military') THEN landuse ELSE NULL END)) AS landuse,\n ('natural_' || (CASE WHEN \"natural\" IN ('wood', 'sand', 'scree', 'shingle', 'bare_rock') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('wetland_' || (CASE WHEN \"natural\" IN ('wetland', 'mud') THEN (CASE WHEN \"natural\" IN ('mud') THEN \"natural\" ELSE wetland END) ELSE NULL END)) AS wetland,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE (landuse IN ('forest', 'military')\n OR \"natural\" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock'))\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n AND building IS NULL\n ORDER BY CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END, way_area DESC\n ) AS features\n) AS landcover_low_zoom", + "table": "(SELECT\n way, name, way_pixels,\n COALESCE(wetland, landuse, \"natural\") AS feature\n FROM (SELECT\n way, COALESCE(name, '') AS name,\n ('landuse_' || (CASE WHEN landuse IN ('forest', 'military') THEN landuse ELSE NULL END)) AS landuse,\n ('natural_' || (CASE WHEN \"natural\" IN ('wood', 'sand', 'scree', 'shingle', 'bare_rock') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('wetland_' || (CASE WHEN \"natural\" IN ('wetland', 'mud') THEN (CASE WHEN \"natural\" IN ('mud') THEN \"natural\" ELSE tags->'wetland' END) ELSE NULL END)) AS wetland,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE (landuse IN ('forest', 'military')\n OR \"natural\" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock'))\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n AND building IS NULL\n ORDER BY CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END, way_area DESC\n ) AS features\n) AS landcover_low_zoom", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -126,7 +126,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, name, religion, way_pixels,\n COALESCE(aeroway, amenity, wetland, power, landuse, leisure, military, \"natural\", tourism, highway, railway) AS feature\n FROM (SELECT\n way, COALESCE(name, '') AS name,\n ('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway ELSE NULL END)) AS aeroway,\n ('amenity_' || (CASE WHEN amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', \n 'hospital', 'kindergarten', 'grave_yard', 'prison', 'place_of_worship', 'clinic') \n THEN amenity ELSE NULL END)) AS amenity,\n ('landuse_' || (CASE WHEN landuse IN ('quarry', 'vineyard', 'orchard', 'cemetery', 'residential', 'garages', 'meadow', 'grass', \n 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'greenhouse_horticulture', \n 'recreation_ground', 'village_green', 'retail', 'industrial', 'railway', 'commercial', \n 'brownfield', 'landfill', 'construction') THEN landuse ELSE NULL END)) AS landuse,\n ('leisure_' || (CASE WHEN leisure IN ('swimming_pool', 'playground', 'park', 'recreation_ground', 'common', 'garden', \n 'golf_course', 'miniature_golf', 'picnic_table', 'sports_centre', 'stadium', 'pitch', \n 'track') THEN leisure ELSE NULL END)) AS leisure,\n ('military_' || (CASE WHEN military IN ('danger_area') THEN military ELSE NULL END)) AS military,\n ('natural_' || (CASE WHEN \"natural\" IN ('beach', 'shoal', 'heath', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('wetland_' || (CASE WHEN \"natural\" IN ('wetland', 'marsh', 'mud') THEN (CASE WHEN \"natural\" IN ('marsh', 'mud') THEN \"natural\" ELSE wetland END) ELSE NULL END)) AS wetland,\n ('power_' || (CASE WHEN power IN ('station', 'sub_station', 'substation', 'generator') THEN power ELSE NULL END)) AS power,\n ('tourism_' || (CASE WHEN tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site') THEN tourism ELSE NULL END)) AS tourism,\n ('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway ELSE NULL END)) AS highway,\n ('railway_' || (CASE WHEN railway = 'station' THEN railway ELSE NULL END)) AS railway,\n CASE WHEN religion IN ('christian', 'jewish') THEN religion ELSE 'INT-generic'::text END AS religion,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE (landuse IS NOT NULL\n OR leisure IS NOT NULL\n OR aeroway IN ('apron', 'aerodrome')\n OR amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', 'hospital', 'kindergarten', \n 'grave_yard', 'place_of_worship', 'prison', 'clinic')\n OR military IN ('danger_area')\n OR \"natural\" IN ('beach', 'shoal', 'heath', 'mud', 'marsh', 'wetland', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub')\n OR power IN ('station', 'sub_station', 'substation', 'generator')\n OR tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site')\n OR highway IN ('services', 'rest_area')\n OR railway = 'station')\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END, way_area DESC\n ) AS landcover\n) AS features", + "table": "(SELECT\n way, name, religion, way_pixels,\n COALESCE(aeroway, amenity, wetland, power, landuse, leisure, military, \"natural\", tourism, highway, railway) AS feature\n FROM (SELECT\n way, COALESCE(name, '') AS name,\n ('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway ELSE NULL END)) AS aeroway,\n ('amenity_' || (CASE WHEN amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', \n 'hospital', 'kindergarten', 'grave_yard', 'prison', 'place_of_worship', 'clinic') \n THEN amenity ELSE NULL END)) AS amenity,\n ('landuse_' || (CASE WHEN landuse IN ('quarry', 'vineyard', 'orchard', 'cemetery', 'residential', 'garages', 'meadow', 'grass', \n 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'greenhouse_horticulture', \n 'recreation_ground', 'village_green', 'retail', 'industrial', 'railway', 'commercial', \n 'brownfield', 'landfill', 'construction') THEN landuse ELSE NULL END)) AS landuse,\n ('leisure_' || (CASE WHEN leisure IN ('swimming_pool', 'playground', 'park', 'recreation_ground', 'common', 'garden', \n 'golf_course', 'miniature_golf', 'picnic_table', 'sports_centre', 'stadium', 'pitch', \n 'track') THEN leisure ELSE NULL END)) AS leisure,\n ('military_' || (CASE WHEN military IN ('danger_area') THEN military ELSE NULL END)) AS military,\n ('natural_' || (CASE WHEN \"natural\" IN ('beach', 'shoal', 'heath', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('wetland_' || (CASE WHEN \"natural\" IN ('wetland', 'marsh', 'mud') THEN (CASE WHEN \"natural\" IN ('marsh', 'mud') THEN \"natural\" ELSE tags->'wetland' END) ELSE NULL END)) AS wetland,\n ('power_' || (CASE WHEN power IN ('station', 'sub_station', 'substation', 'generator') THEN power ELSE NULL END)) AS power,\n ('tourism_' || (CASE WHEN tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site') THEN tourism ELSE NULL END)) AS tourism,\n ('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway ELSE NULL END)) AS highway,\n ('railway_' || (CASE WHEN railway = 'station' THEN railway ELSE NULL END)) AS railway,\n CASE WHEN religion IN ('christian', 'jewish') THEN religion ELSE 'INT-generic'::text END AS religion,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE (landuse IS NOT NULL\n OR leisure IS NOT NULL\n OR aeroway IN ('apron', 'aerodrome')\n OR amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', 'hospital', 'kindergarten', \n 'grave_yard', 'place_of_worship', 'prison', 'clinic')\n OR military IN ('danger_area')\n OR \"natural\" IN ('beach', 'shoal', 'heath', 'mud', 'marsh', 'wetland', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub')\n OR power IN ('station', 'sub_station', 'substation', 'generator')\n OR tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site')\n OR highway IN ('services', 'rest_area')\n OR railway = 'station')\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END, way_area DESC\n ) AS landcover\n) AS features", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -178,7 +178,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, waterway, intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel\n FROM planet_osm_line\n WHERE waterway IN ('stream', 'drain', 'ditch')\n) AS water_lines_casing", + "table": "(SELECT\n way, waterway, tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel\n FROM planet_osm_line\n WHERE waterway IN ('stream', 'drain', 'ditch')\n) AS water_lines_casing", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -204,7 +204,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT way, waterway, intermittent\n FROM planet_osm_line\n WHERE waterway = 'river'\n) AS water_lines_low_zoom", + "table": "(SELECT way, waterway, tags->'intermittent' as intermittent\n FROM planet_osm_line\n WHERE waterway = 'river'\n) AS water_lines_low_zoom", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -279,7 +279,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, surface, \n COALESCE(\"natural\", CASE WHEN landuse = 'forest' THEN 'wood' ELSE NULL END) AS \"natural\",\n CASE WHEN \"natural\" IN ('marsh', 'mud') \n THEN \"natural\" \n ELSE CASE WHEN (\"natural\" = 'wetland' AND wetland IS NULL) \n THEN 'wetland' \n ELSE CASE WHEN (\"natural\" = 'wetland')\n THEN wetland\n ELSE NULL\n END \n END\n END AS int_wetland\n FROM planet_osm_polygon\n WHERE (\"natural\" IN ('marsh', 'mud', 'wetland', 'wood', 'beach', 'shoal', 'reef') OR landuse = 'forest')\n AND building IS NULL\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY z_order, way_area DESC\n) AS landcover_area_symbols", + "table": "(SELECT\n way, surface, \n COALESCE(\"natural\", CASE WHEN landuse = 'forest' THEN 'wood' ELSE NULL END) AS \"natural\",\n CASE WHEN \"natural\" IN ('marsh', 'mud') \n THEN \"natural\" \n ELSE CASE WHEN (\"natural\" = 'wetland' AND NOT tags ? 'wetland') \n THEN 'wetland' \n ELSE CASE WHEN (\"natural\" = 'wetland')\n THEN tags->'wetland'\n ELSE NULL\n END \n END\n END AS int_wetland\n FROM planet_osm_polygon\n WHERE (\"natural\" IN ('marsh', 'mud', 'wetland', 'wood', 'beach', 'shoal', 'reef') OR landuse = 'forest')\n AND building IS NULL\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY z_order, way_area DESC\n) AS landcover_area_symbols", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -327,7 +327,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, waterway, name, intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel,\n 'no' AS bridge\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND (bridge IS NULL OR bridge NOT IN ('yes', 'aqueduct'))\n ORDER BY z_order\n) AS water_lines", + "table": "(SELECT\n way, waterway, name, tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel,\n 'no' AS bridge\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND (bridge IS NULL OR bridge NOT IN ('yes', 'aqueduct'))\n ORDER BY z_order\n) AS water_lines", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -978,7 +978,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n waterway,\n name,\n intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel,\n 'yes' AS bridge\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND bridge IN ('yes', 'aqueduct')\n ORDER BY z_order\n) AS waterway_bridges", + "table": "(SELECT\n way,\n waterway,\n name,\n tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel,\n 'yes' AS bridge\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND bridge IN ('yes', 'aqueduct')\n ORDER BY z_order\n) AS waterway_bridges", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1292,7 +1292,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n name,\n score,\n CASE\n WHEN (place = 'city' OR (capital = 'yes' AND score >= 100000)) THEN 1\n ELSE 2\n END as category\n FROM \n (SELECT\n way,\n place,\n name,\n capital,\n (\n (CASE\n WHEN (population ~ '^[0-9]{1,8}$') THEN population::INTEGER\n WHEN (place = 'city') THEN 100000\n WHEN (place = 'town') THEN 1000\n ELSE 1\n END)\n *\n (CASE\n WHEN (capital = 'yes') THEN 3\n WHEN (capital = '4') THEN 2\n ELSE 1\n END)\n ) AS score\n FROM planet_osm_point\n WHERE place IN ('city', 'town')\n ) as p\n ORDER BY score DESC\n) AS placenames_medium", + "table": "(SELECT\n way,\n name,\n score,\n CASE\n WHEN (place = 'city' OR (capital = 'yes' AND score >= 100000)) THEN 1\n ELSE 2\n END as category\n FROM \n (SELECT\n way,\n place,\n name,\n capital,\n (\n (CASE\n WHEN (tags->'population' ~ '^[0-9]{1,8}$') THEN (tags->'population')::INTEGER\n WHEN (place = 'city') THEN 100000\n WHEN (place = 'town') THEN 1000\n ELSE 1\n END)\n *\n (CASE\n WHEN (capital = 'yes') THEN 3\n WHEN (capital = '4') THEN 2\n ELSE 1\n END)\n ) AS score\n FROM planet_osm_point\n WHERE place IN ('city', 'town')\n ) as p\n ORDER BY score DESC\n) AS placenames_medium", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1397,7 +1397,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n COALESCE(\n 'aeroway_' || CASE WHEN aeroway IN ('helipad', 'aerodrome') THEN aeroway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'guest_house', \n 'hostel', 'hotel', 'motel', 'information', 'museum', 'picnic_site') THEN tourism ELSE NULL END,\n 'amenity_' || CASE WHEN amenity IN ('shelter', 'atm', 'bank', 'bar', 'bicycle_rental', 'bus_station', 'cafe', \n 'car_rental', 'car_wash', 'cinema', 'clinic', 'community_centre', 'fire_station', 'fountain',\n 'fuel', 'hospital', 'ice_cream', 'embassy', 'library', 'courthouse', 'townhall', 'parking', \n 'bicycle_parking', 'motorcycle_parking', 'pharmacy', 'doctors', 'dentist', 'place_of_worship', \n 'police', 'post_box', 'post_office', 'pub', 'biergarten', 'recycling', 'restaurant', 'food_court', \n 'fast_food', 'telephone', 'emergency_phone', 'taxi', 'theatre', 'toilets', 'drinking_water', \n 'prison', 'hunting_stand', 'nightclub', 'veterinary', 'social_facility') THEN amenity ELSE NULL END, \n 'shop_' || CASE WHEN shop IN ('supermarket', 'bag', 'bakery', 'beauty', 'books', 'butcher', 'clothes', 'computer', \n 'confectionery', 'fashion', 'convenience', 'department_store', 'doityourself', 'hardware', 'florist', \n 'garden_centre', 'hairdresser', 'hifi', 'ice_cream', 'car', 'car_repair', 'bicycle', 'mall', 'pet', \n 'photo', 'photo_studio', 'photography', 'seafood', 'shoes', 'alcohol', 'gift', 'furniture', 'kiosk', \n 'mobile_phone', 'motorcycle', 'musical_instrument', 'newsagent', 'optician', 'jewelry', 'jewellery', \n 'electronics', 'chemist', 'toys', 'travel_agency', 'car_parts', 'greengrocer', 'farm', 'stationery', \n 'laundry', 'dry_cleaning', 'beverages', 'perfumery', 'cosmetics', 'variety_store', 'wine', 'outdoor', \n 'copyshop', 'sports') THEN shop \n WHEN shop IN ('accessories', 'antiques', 'appliance', 'art', 'baby_goods', 'bathroom_furnishing', \n 'bed', 'boat', 'bookmaker', 'boutique', 'builder', 'building_materials', 'camera', 'car_service', \n 'carpet', 'charity', 'cheese', 'chocolate', 'coffee', 'communication', 'craft', 'curtain', 'dairy', \n 'deli', 'discount', 'e-cigarette', 'electrical', 'energy', 'erotic', 'estate_agent', \n 'fabric', 'fishing', 'flooring', 'food', 'frame', 'frozen_food', 'funeral_directors', 'furnace', \n 'gallery', 'games', 'gas', 'general', 'glaziery', 'grocery', 'health', 'health_food', 'hearing_aids', \n 'herbalist', 'hobby', 'household', 'houseware', 'hunting', 'interior_decoration', 'kitchen', \n 'leather', 'lighting', 'locksmith', 'lottery', 'market', 'massage', 'medical', 'medical_supply', 'money_lender', \n 'motorcycle_repair', 'music', 'office_supplies', 'organic', 'paint', 'pastry', 'pawnbroker', \n 'phone', 'pottery', 'printing', 'radiotechnics', 'real_estate', 'religion', 'rental', 'salon', \n 'scuba_diving', 'second_hand', 'sewing', 'shoe_repair', 'shopping_centre', 'solarium', 'souvenir', \n 'tailor', 'tanning', 'tattoo', 'tea', 'ticket', 'tiles', 'tobacco', 'trade', 'tyres', 'vacuum_cleaner', 'video', \n 'video_games', 'watches', 'wholesale', 'yes') THEN 'other' ELSE NULL END,\n 'leisure_' || CASE WHEN leisure IN ('water_park', 'playground', 'miniature_golf', 'golf_course', 'picnic_table') THEN leisure ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('mast', 'water_tower', 'lighthouse', 'windmill') THEN man_made ELSE NULL END,\n 'natural_' || CASE WHEN \"natural\" IN ('spring') THEN \"natural\" ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site') THEN historic ELSE NULL END,\n 'highway_'|| CASE WHEN highway IN ('bus_stop', 'elevator', 'traffic_signals') THEN highway ELSE NULL END,\n 'power_' || CASE WHEN power IN ('generator') THEN power ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('viewpoint') THEN tourism ELSE NULL END\n ) AS feature,\n access,\n religion,\n denomination,\n \"generator:source\",\n power_source,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering\n WHERE aeroway IN ('helipad', 'aerodrome')\n OR tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'guest_house', 'hostel', \n 'hotel', 'motel', 'information', 'museum', 'viewpoint', 'picnic_site')\n OR amenity IN ('shelter', 'atm', 'bank', 'bar', 'bicycle_rental', 'bus_station', 'cafe', \n 'car_rental', 'car_wash', 'cinema', 'clinic', 'community_centre',\n 'fire_station', 'fountain', 'fuel', 'hospital', 'ice_cream', 'embassy', 'library', 'courthouse', \n 'townhall', 'parking', 'bicycle_parking', 'motorcycle_parking', 'pharmacy', 'doctors', \n 'dentist', 'place_of_worship', 'police', 'post_box', 'post_office', 'pub', 'biergarten', \n 'recycling', 'restaurant', 'food_court', 'fast_food', 'telephone', 'emergency_phone', 'taxi', \n 'theatre', 'toilets', 'drinking_water', 'prison', 'hunting_stand', 'nightclub', 'veterinary',\n 'social_facility')\n OR shop IS NOT NULL -- skip checking a huge list and use a null check\n OR leisure IN ('water_park', 'playground', 'miniature_golf', 'golf_course', 'picnic_table')\n OR man_made IN ('mast', 'water_tower', 'lighthouse', 'windmill')\n OR \"natural\" IN ('spring')\n OR historic IN ('memorial', 'monument', 'archaeological_site')\n OR highway IN ('bus_stop', 'elevator', 'traffic_signals')\n OR (power = 'generator' AND (\"generator:source\" = 'wind' OR power_source = 'wind'))\n ORDER BY way_area desc\n) AS amenity_points_poly", + "table": "(SELECT\n way,\n COALESCE(\n 'aeroway_' || CASE WHEN aeroway IN ('helipad', 'aerodrome') THEN aeroway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'guest_house', \n 'hostel', 'hotel', 'motel', 'information', 'museum', 'picnic_site') THEN tourism ELSE NULL END,\n 'amenity_' || CASE WHEN amenity IN ('shelter', 'atm', 'bank', 'bar', 'bicycle_rental', 'bus_station', 'cafe', \n 'car_rental', 'car_wash', 'cinema', 'clinic', 'community_centre', 'fire_station', 'fountain',\n 'fuel', 'hospital', 'ice_cream', 'embassy', 'library', 'courthouse', 'townhall', 'parking', \n 'bicycle_parking', 'motorcycle_parking', 'pharmacy', 'doctors', 'dentist', 'place_of_worship', \n 'police', 'post_box', 'post_office', 'pub', 'biergarten', 'recycling', 'restaurant', 'food_court', \n 'fast_food', 'telephone', 'emergency_phone', 'taxi', 'theatre', 'toilets', 'drinking_water', \n 'prison', 'hunting_stand', 'nightclub', 'veterinary', 'social_facility') THEN amenity ELSE NULL END, \n 'shop_' || CASE WHEN shop IN ('supermarket', 'bag', 'bakery', 'beauty', 'books', 'butcher', 'clothes', 'computer', \n 'confectionery', 'fashion', 'convenience', 'department_store', 'doityourself', 'hardware', 'florist', \n 'garden_centre', 'hairdresser', 'hifi', 'ice_cream', 'car', 'car_repair', 'bicycle', 'mall', 'pet', \n 'photo', 'photo_studio', 'photography', 'seafood', 'shoes', 'alcohol', 'gift', 'furniture', 'kiosk', \n 'mobile_phone', 'motorcycle', 'musical_instrument', 'newsagent', 'optician', 'jewelry', 'jewellery', \n 'electronics', 'chemist', 'toys', 'travel_agency', 'car_parts', 'greengrocer', 'farm', 'stationery', \n 'laundry', 'dry_cleaning', 'beverages', 'perfumery', 'cosmetics', 'variety_store', 'wine', 'outdoor', \n 'copyshop', 'sports') THEN shop \n WHEN shop IN ('accessories', 'antiques', 'appliance', 'art', 'baby_goods', 'bathroom_furnishing', \n 'bed', 'boat', 'bookmaker', 'boutique', 'builder', 'building_materials', 'camera', 'car_service', \n 'carpet', 'charity', 'cheese', 'chocolate', 'coffee', 'communication', 'craft', 'curtain', 'dairy', \n 'deli', 'discount', 'e-cigarette', 'electrical', 'energy', 'erotic', 'estate_agent', \n 'fabric', 'fishing', 'flooring', 'food', 'frame', 'frozen_food', 'funeral_directors', 'furnace', \n 'gallery', 'games', 'gas', 'general', 'glaziery', 'grocery', 'health', 'health_food', 'hearing_aids', \n 'herbalist', 'hobby', 'household', 'houseware', 'hunting', 'interior_decoration', 'kitchen', \n 'leather', 'lighting', 'locksmith', 'lottery', 'market', 'massage', 'medical', 'medical_supply', 'money_lender', \n 'motorcycle_repair', 'music', 'office_supplies', 'organic', 'paint', 'pastry', 'pawnbroker', \n 'phone', 'pottery', 'printing', 'radiotechnics', 'real_estate', 'religion', 'rental', 'salon', \n 'scuba_diving', 'second_hand', 'sewing', 'shoe_repair', 'shopping_centre', 'solarium', 'souvenir', \n 'tailor', 'tanning', 'tattoo', 'tea', 'ticket', 'tiles', 'tobacco', 'trade', 'tyres', 'vacuum_cleaner', 'video', \n 'video_games', 'watches', 'wholesale', 'yes') THEN 'other' ELSE NULL END,\n 'leisure_' || CASE WHEN leisure IN ('water_park', 'playground', 'miniature_golf', 'golf_course', 'picnic_table') THEN leisure ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('mast', 'water_tower', 'lighthouse', 'windmill') THEN man_made ELSE NULL END,\n 'natural_' || CASE WHEN \"natural\" IN ('spring') THEN \"natural\" ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site') THEN historic ELSE NULL END,\n 'highway_'|| CASE WHEN highway IN ('bus_stop', 'elevator', 'traffic_signals') THEN highway ELSE NULL END,\n 'power_' || CASE WHEN power IN ('generator') THEN power ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('viewpoint') THEN tourism ELSE NULL END\n ) AS feature,\n access,\n religion,\n tags->'denomination' as denomination,\n tags->'generator:source' as \"generator:source\",\n tags->'power_source' as power_source,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering\n WHERE aeroway IN ('helipad', 'aerodrome')\n OR tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'guest_house', 'hostel', \n 'hotel', 'motel', 'information', 'museum', 'viewpoint', 'picnic_site')\n OR amenity IN ('shelter', 'atm', 'bank', 'bar', 'bicycle_rental', 'bus_station', 'cafe', \n 'car_rental', 'car_wash', 'cinema', 'clinic', 'community_centre',\n 'fire_station', 'fountain', 'fuel', 'hospital', 'ice_cream', 'embassy', 'library', 'courthouse', \n 'townhall', 'parking', 'bicycle_parking', 'motorcycle_parking', 'pharmacy', 'doctors', \n 'dentist', 'place_of_worship', 'police', 'post_box', 'post_office', 'pub', 'biergarten', \n 'recycling', 'restaurant', 'food_court', 'fast_food', 'telephone', 'emergency_phone', 'taxi', \n 'theatre', 'toilets', 'drinking_water', 'prison', 'hunting_stand', 'nightclub', 'veterinary',\n 'social_facility')\n OR shop IS NOT NULL -- skip checking a huge list and use a null check\n OR leisure IN ('water_park', 'playground', 'miniature_golf', 'golf_course', 'picnic_table')\n OR man_made IN ('mast', 'water_tower', 'lighthouse', 'windmill')\n OR \"natural\" IN ('spring')\n OR historic IN ('memorial', 'monument', 'archaeological_site')\n OR highway IN ('bus_stop', 'elevator', 'traffic_signals')\n OR (power = 'generator' AND (tags @> '\"generator:source\"=>wind' OR tags @> 'power_source=>wind'))\n ORDER BY way_area desc\n) AS amenity_points_poly", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1423,7 +1423,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n COALESCE(\n 'aeroway_' || CASE WHEN aeroway IN ('helipad', 'aerodrome') THEN aeroway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'guest_house', 'hostel', \n 'hotel', 'motel', 'information', 'museum', 'picnic_site') THEN tourism ELSE NULL END,\n 'amenity_' || CASE WHEN amenity IN ('shelter', 'atm', 'bank', 'bar', 'bicycle_rental', 'bus_station', 'cafe', \n 'car_rental', 'car_wash', 'cinema', 'clinic', 'community_centre', 'fire_station', 'fountain',\n 'fuel', 'hospital', 'ice_cream', 'embassy', 'library', 'courthouse', 'townhall', 'parking', \n 'bicycle_parking', 'motorcycle_parking', 'pharmacy', 'doctors', 'dentist', 'place_of_worship', \n 'police', 'post_box', 'post_office', 'pub', 'biergarten', 'recycling', 'restaurant', 'food_court', \n 'fast_food', 'telephone', 'emergency_phone', 'taxi', 'theatre', 'toilets', 'drinking_water', \n 'prison', 'hunting_stand', 'nightclub', 'veterinary', 'social_facility') THEN amenity ELSE NULL END,\n 'shop_' || CASE WHEN shop IN ('supermarket', 'bag', 'bakery', 'beauty', 'books', 'butcher', 'clothes', 'computer', 'confectionery', \n 'fashion', 'convenience', 'department_store', 'doityourself', 'hardware', 'florist', 'garden_centre', \n 'hairdresser', 'hifi', 'ice_cream', 'car', 'car_repair', 'bicycle', 'mall', 'pet', 'photo', 'photo_studio', \n 'photography', 'seafood', 'shoes', 'alcohol', 'gift', 'furniture', 'kiosk', 'mobile_phone', 'motorcycle', \n 'musical_instrument', 'newsagent', 'optician', 'jewelry', 'jewellery', 'electronics', 'chemist', 'toys', \n 'travel_agency', 'car_parts', 'greengrocer', 'farm', 'stationery', 'laundry', 'dry_cleaning', 'beverages', \n 'perfumery', 'cosmetics', 'variety_store', 'wine', 'outdoor', 'copyshop', 'sports') THEN shop \n WHEN shop IN ('accessories', 'antiques', 'appliance', 'art', 'baby_goods', 'bathroom_furnishing', 'bed', \n 'boat', 'bookmaker', 'boutique', 'builder', 'building_materials', 'camera', 'car_service', 'carpet', 'charity', \n 'cheese', 'chocolate', 'coffee', 'communication', 'craft', 'curtain', 'dairy', 'deli', \n 'discount', 'e-cigarette', 'electrical', 'energy', 'erotic', 'estate_agent', 'fabric', 'fishing', \n 'flooring', 'food', 'frame', 'frozen_food', 'funeral_directors', 'furnace', 'gallery', 'games', 'gas', \n 'general', 'glaziery', 'grocery', 'health', 'health_food', 'hearing_aids', 'herbalist', 'hobby', 'household', \n 'houseware', 'hunting', 'interior_decoration', 'kitchen', 'leather', 'lighting', 'locksmith', 'lottery', \n 'market', 'massage', 'medical', 'medical_supply', 'money_lender', 'motorcycle_repair', 'music', 'office_supplies', \n 'organic', 'paint', 'pastry', 'pawnbroker', 'phone', 'pottery', 'printing', 'radiotechnics', \n 'real_estate', 'religion', 'rental', 'salon', 'scuba_diving', 'second_hand', 'sewing', 'shoe_repair', 'shopping_centre', \n 'solarium', 'souvenir', 'tailor', 'tanning', 'tattoo', 'tea', 'ticket', 'tiles', 'tobacco', 'trade', 'tyres', \n 'vacuum_cleaner', 'video', 'video_games', 'watches', 'wholesale', 'yes') THEN 'other' ELSE NULL END,\n 'leisure_' || CASE WHEN leisure IN ('water_park', 'playground', 'miniature_golf', 'golf_course', 'picnic_table', 'slipway') THEN leisure ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('mast', 'water_tower', 'lighthouse', 'windmill') THEN man_made ELSE NULL END,\n 'natural_' || CASE WHEN \"natural\" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance') THEN \"natural\" ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site') THEN historic ELSE NULL END,\n 'highway_'|| CASE WHEN highway IN ('bus_stop', 'elevator', 'traffic_signals', 'ford') THEN highway ELSE NULL END,\n 'power_' || CASE WHEN power IN ('generator') THEN power ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('viewpoint') THEN tourism ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('cross') THEN man_made ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('wayside_cross') THEN historic ELSE NULL END\n ) AS feature,\n access,\n CASE\n WHEN \"natural\" IN ('peak', 'volcano', 'saddle') THEN\n CASE\n WHEN ele ~ '^-?\\d{1,4}(\\.\\d+)?$' THEN ele::NUMERIC\n ELSE NULL\n END\n ELSE NULL\n END AS score,\n religion,\n denomination,\n \"generator:source\",\n power_source,\n NULL AS way_pixels\n FROM planet_osm_point\n -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering\n WHERE aeroway IN ('helipad', 'aerodrome')\n OR tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'guest_house', 'hostel', \n 'hotel', 'motel', 'information', 'museum', 'viewpoint', 'picnic_site')\n OR amenity IN ('shelter', 'atm', 'bank', 'bar', 'bicycle_rental', 'bus_station', 'cafe', \n 'car_rental', 'car_wash', 'cinema', 'clinic', 'community_centre',\n 'fire_station', 'fountain', 'fuel', 'hospital', 'ice_cream', 'embassy', 'library', 'courthouse', \n 'townhall', 'parking', 'bicycle_parking', 'motorcycle_parking', 'pharmacy', 'doctors', \n 'dentist', 'place_of_worship', 'police', 'post_box', 'post_office', 'pub', 'biergarten', \n 'recycling', 'restaurant', 'food_court', 'fast_food', 'telephone', 'emergency_phone', \n 'taxi', 'theatre', 'toilets', 'drinking_water', 'prison', 'hunting_stand', 'nightclub', \n 'veterinary', 'social_facility')\n OR shop IS NOT NULL -- skip checking a huge list and use a null check\n OR leisure IN ('water_park', 'playground', 'miniature_golf', 'golf_course', 'picnic_table', 'slipway')\n OR man_made IN ('mast', 'water_tower', 'lighthouse', 'windmill', 'cross')\n OR \"natural\" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance')\n OR historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross')\n OR highway IN ('bus_stop', 'elevator', 'traffic_signals', 'ford')\n OR (power = 'generator' AND (\"generator:source\" = 'wind' OR power_source = 'wind'))\n ORDER BY score DESC NULLS LAST\n ) AS amenity_points", + "table": "(SELECT\n way,\n COALESCE(\n 'aeroway_' || CASE WHEN aeroway IN ('helipad', 'aerodrome') THEN aeroway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'guest_house', 'hostel', \n 'hotel', 'motel', 'information', 'museum', 'picnic_site') THEN tourism ELSE NULL END,\n 'amenity_' || CASE WHEN amenity IN ('shelter', 'atm', 'bank', 'bar', 'bicycle_rental', 'bus_station', 'cafe', \n 'car_rental', 'car_wash', 'cinema', 'clinic', 'community_centre', 'fire_station', 'fountain',\n 'fuel', 'hospital', 'ice_cream', 'embassy', 'library', 'courthouse', 'townhall', 'parking', \n 'bicycle_parking', 'motorcycle_parking', 'pharmacy', 'doctors', 'dentist', 'place_of_worship', \n 'police', 'post_box', 'post_office', 'pub', 'biergarten', 'recycling', 'restaurant', 'food_court', \n 'fast_food', 'telephone', 'emergency_phone', 'taxi', 'theatre', 'toilets', 'drinking_water', \n 'prison', 'hunting_stand', 'nightclub', 'veterinary', 'social_facility') THEN amenity ELSE NULL END,\n 'shop_' || CASE WHEN shop IN ('supermarket', 'bag', 'bakery', 'beauty', 'books', 'butcher', 'clothes', 'computer', 'confectionery', \n 'fashion', 'convenience', 'department_store', 'doityourself', 'hardware', 'florist', 'garden_centre', \n 'hairdresser', 'hifi', 'ice_cream', 'car', 'car_repair', 'bicycle', 'mall', 'pet', 'photo', 'photo_studio', \n 'photography', 'seafood', 'shoes', 'alcohol', 'gift', 'furniture', 'kiosk', 'mobile_phone', 'motorcycle', \n 'musical_instrument', 'newsagent', 'optician', 'jewelry', 'jewellery', 'electronics', 'chemist', 'toys', \n 'travel_agency', 'car_parts', 'greengrocer', 'farm', 'stationery', 'laundry', 'dry_cleaning', 'beverages', \n 'perfumery', 'cosmetics', 'variety_store', 'wine', 'outdoor', 'copyshop', 'sports') THEN shop \n WHEN shop IN ('accessories', 'antiques', 'appliance', 'art', 'baby_goods', 'bathroom_furnishing', 'bed', \n 'boat', 'bookmaker', 'boutique', 'builder', 'building_materials', 'camera', 'car_service', 'carpet', 'charity', \n 'cheese', 'chocolate', 'coffee', 'communication', 'craft', 'curtain', 'dairy', 'deli', \n 'discount', 'e-cigarette', 'electrical', 'energy', 'erotic', 'estate_agent', 'fabric', 'fishing', \n 'flooring', 'food', 'frame', 'frozen_food', 'funeral_directors', 'furnace', 'gallery', 'games', 'gas', \n 'general', 'glaziery', 'grocery', 'health', 'health_food', 'hearing_aids', 'herbalist', 'hobby', 'household', \n 'houseware', 'hunting', 'interior_decoration', 'kitchen', 'leather', 'lighting', 'locksmith', 'lottery', \n 'market', 'massage', 'medical', 'medical_supply', 'money_lender', 'motorcycle_repair', 'music', 'office_supplies', \n 'organic', 'paint', 'pastry', 'pawnbroker', 'phone', 'pottery', 'printing', 'radiotechnics', \n 'real_estate', 'religion', 'rental', 'salon', 'scuba_diving', 'second_hand', 'sewing', 'shoe_repair', 'shopping_centre', \n 'solarium', 'souvenir', 'tailor', 'tanning', 'tattoo', 'tea', 'ticket', 'tiles', 'tobacco', 'trade', 'tyres', \n 'vacuum_cleaner', 'video', 'video_games', 'watches', 'wholesale', 'yes') THEN 'other' ELSE NULL END,\n 'leisure_' || CASE WHEN leisure IN ('water_park', 'playground', 'miniature_golf', 'golf_course', 'picnic_table', 'slipway') THEN leisure ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('mast', 'water_tower', 'lighthouse', 'windmill') THEN man_made ELSE NULL END,\n 'natural_' || CASE WHEN \"natural\" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance') THEN \"natural\" ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site') THEN historic ELSE NULL END,\n 'highway_'|| CASE WHEN highway IN ('bus_stop', 'elevator', 'traffic_signals', 'ford') THEN highway ELSE NULL END,\n 'power_' || CASE WHEN power IN ('generator') THEN power ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('viewpoint') THEN tourism ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('cross') THEN man_made ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('wayside_cross') THEN historic ELSE NULL END\n ) AS feature,\n access,\n CASE\n WHEN \"natural\" IN ('peak', 'volcano', 'saddle') THEN\n CASE\n WHEN tags->'ele' ~ '^-?\\d{1,4}(\\.\\d+)?$' THEN (tags->'ele')::NUMERIC\n ELSE NULL\n END\n ELSE NULL\n END AS score,\n religion,\n tags->'denomination' as denomination,\n tags->'generator:source' as \"generator:source\",\n tags->'power_source' as power_source,\n NULL AS way_pixels\n FROM planet_osm_point\n -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering\n WHERE aeroway IN ('helipad', 'aerodrome')\n OR tourism IN ('alpine_hut', 'camp_site', 'caravan_site', 'chalet', 'guest_house', 'hostel', \n 'hotel', 'motel', 'information', 'museum', 'viewpoint', 'picnic_site')\n OR amenity IN ('shelter', 'atm', 'bank', 'bar', 'bicycle_rental', 'bus_station', 'cafe', \n 'car_rental', 'car_wash', 'cinema', 'clinic', 'community_centre',\n 'fire_station', 'fountain', 'fuel', 'hospital', 'ice_cream', 'embassy', 'library', 'courthouse', \n 'townhall', 'parking', 'bicycle_parking', 'motorcycle_parking', 'pharmacy', 'doctors', \n 'dentist', 'place_of_worship', 'police', 'post_box', 'post_office', 'pub', 'biergarten', \n 'recycling', 'restaurant', 'food_court', 'fast_food', 'telephone', 'emergency_phone', \n 'taxi', 'theatre', 'toilets', 'drinking_water', 'prison', 'hunting_stand', 'nightclub', \n 'veterinary', 'social_facility')\n OR shop IS NOT NULL -- skip checking a huge list and use a null check\n OR leisure IN ('water_park', 'playground', 'miniature_golf', 'golf_course', 'picnic_table', 'slipway')\n OR man_made IN ('mast', 'water_tower', 'lighthouse', 'windmill', 'cross')\n OR \"natural\" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance')\n OR historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross')\n OR highway IN ('bus_stop', 'elevator', 'traffic_signals', 'ford')\n OR (power = 'generator' AND (tags @> '\"generator:source\"=>wind' OR tags @> 'power_source=>wind'))\n ORDER BY score DESC NULLS LAST\n ) AS amenity_points", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1711,7 +1711,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels,\n COALESCE(\n 'aeroway_' || CASE WHEN aeroway IN ('gate', 'apron', 'helipad', 'aerodrome') THEN aeroway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'hotel', 'motel', 'hostel', 'chalet', 'guest_house', 'camp_site', 'caravan_site', \n 'theme_park', 'museum', 'zoo', 'information', 'picnic_site') THEN tourism ELSE NULL END,\n 'amenity_' || CASE WHEN amenity IN ('pub', 'restaurant', 'food_court', 'cafe', 'fast_food', 'biergarten', 'bar', 'library', \n 'theatre', 'courthouse', 'townhall', 'cinema', 'clinic', 'community_centre', 'parking', \n 'bicycle_parking', 'motorcycle_parking', 'police', 'fire_station', 'fountain', 'place_of_worship', \n 'grave_yard', 'shelter', 'bank', 'embassy', 'fuel', 'bus_station', 'prison', 'university', \n 'school', 'college', 'kindergarten', 'hospital', 'ice_cream', 'pharmacy', 'doctors', 'dentist', \n 'atm', 'bicycle_rental', 'car_rental', 'car_wash', 'post_box', 'post_office',\n 'recycling', 'telephone', 'emergency_phone', 'toilets', 'taxi', 'drinking_water', 'hunting_stand', \n 'nightclub', 'veterinary', 'social_facility') THEN amenity ELSE NULL END,\n 'shop_' || CASE WHEN shop IN ('supermarket', 'bag', 'bakery', 'beauty', 'books', 'butcher', 'clothes', 'computer', 'confectionery', \n 'fashion', 'convenience', 'department_store', 'doityourself', 'hardware', 'florist', 'garden_centre', \n 'hairdresser', 'hifi', 'ice_cream', 'car', 'car_repair', 'bicycle', 'mall', 'pet', 'photo', 'photo_studio', \n 'photography', 'seafood', 'shoes', 'alcohol', 'gift', 'furniture', 'kiosk', 'mobile_phone', 'motorcycle', \n 'musical_instrument', 'newsagent', 'optician', 'jewelry', 'jewellery', 'electronics', 'chemist', 'toys', \n 'travel_agency', 'car_parts', 'greengrocer', 'farm', 'stationery', 'laundry', 'dry_cleaning', 'beverages', \n 'perfumery', 'cosmetics', 'variety_store', 'wine', 'outdoor', 'copyshop', 'sports') THEN shop \n WHEN shop IN ('accessories', 'antiques', 'appliance', 'art', 'baby_goods', 'bathroom_furnishing', 'bed', \n 'boat', 'bookmaker', 'boutique', 'builder', 'building_materials', 'camera', 'car_service', 'carpet', 'charity', \n 'cheese', 'chocolate', 'coffee', 'communication', 'craft', 'curtain', 'dairy', 'deli', \n 'discount', 'e-cigarette', 'electrical', 'energy', 'erotic', 'estate_agent', 'fabric', 'fishing', \n 'flooring', 'food', 'frame', 'frozen_food', 'funeral_directors', 'furnace', 'gallery', 'games', 'gas', \n 'general', 'glaziery', 'grocery', 'health', 'health_food', 'hearing_aids', 'herbalist', 'hobby', 'household', \n 'houseware', 'hunting', 'interior_decoration', 'kitchen', 'leather', 'lighting', 'locksmith', \n 'lottery', 'market', 'massage', 'medical', 'medical_supply', 'money_lender', 'motorcycle_repair', 'music', \n 'office_supplies', 'organic', 'paint', 'pastry', 'pawnbroker', 'phone', 'pottery', \n 'printing', 'radiotechnics', 'real_estate', 'religion', 'rental', 'salon', 'scuba_diving', 'second_hand', \n 'sewing', 'shoe_repair', 'shopping_centre', 'solarium', 'souvenir', 'tailor', 'tanning', 'tattoo', 'tea', \n 'ticket', 'tiles', 'tobacco', 'trade', 'tyres', 'vacuum_cleaner', 'video', 'video_games', 'watches', 'wholesale', \n 'yes') THEN 'other' ELSE NULL END,\n 'leisure_' || CASE WHEN leisure IN ('swimming_pool', 'water_park', 'miniature_golf', 'golf_course', 'sports_centre', 'stadium', 'track', \n 'pitch', 'playground', 'park', 'recreation_ground', 'common', 'garden', 'nature_reserve', 'marina', \n 'picnic_table') THEN leisure ELSE NULL END,\n 'power_' || CASE WHEN power IN ('plant', 'station', 'generator', 'sub_station', 'substation') THEN power ELSE NULL END,\n 'landuse_' || CASE WHEN landuse IN ('reservoir', 'basin', 'recreation_ground', 'village_green', 'quarry', 'vineyard', 'orchard', 'cemetery', \n 'residential', 'garages', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', \n 'greenhouse_horticulture', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', \n 'construction', 'military') THEN landuse ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('lighthouse', 'windmill', 'mast', 'water_tower', 'pier', 'breakwater', 'groyne') THEN man_made ELSE NULL END,\n 'natural_' || CASE WHEN \"natural\" IN ('wood', 'water', 'mud', 'wetland', 'marsh', 'bay', 'spring', 'scree', 'shingle', 'bare_rock', 'sand', 'heath', \n 'grassland', 'scrub', 'beach', 'shoal', 'reef', 'glacier') THEN \"natural\" ELSE NULL END,\n 'place_' || CASE WHEN place IN ('island', 'islet') THEN place ELSE NULL END,\n 'military_' || CASE WHEN military IN ('danger_area') THEN military ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site') THEN historic ELSE NULL END,\n 'highway_' || CASE WHEN highway IN ('services', 'rest_area', 'bus_stop', 'elevator', 'ford') THEN highway ELSE NULL END,\n 'boundary_' || CASE WHEN boundary IN ('national_park') THEN boundary ELSE NULL END,\n 'waterway_' || CASE WHEN waterway IN ('dam') THEN waterway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('attraction') THEN tourism ELSE NULL END\n ) AS feature,\n access,\n name,\n operator,\n ref,\n way_area,\n CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building\n FROM planet_osm_polygon\n -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering\n WHERE (aeroway IN ('gate', 'apron', 'helipad', 'aerodrome')\n OR tourism IN ('alpine_hut', 'hotel', 'motel', 'hostel', 'chalet', 'guest_house', 'camp_site', 'caravan_site', 'theme_park', \n 'museum', 'attraction', 'zoo', 'information', 'picnic_site')\n OR amenity IS NOT NULL -- skip checking a huge list and use a null check\n OR shop IS NOT NULL\n OR leisure IS NOT NULL\n OR landuse IS NOT NULL\n OR man_made IN ('lighthouse', 'windmill', 'mast', 'water_tower', 'pier', 'breakwater', 'groyne')\n OR \"natural\" IS NOT NULL\n OR place IN ('island', 'islet')\n OR military IN ('danger_area')\n OR historic IN ('memorial', 'monument', 'archaeological_site')\n OR highway IN ('services', 'rest_area', 'bus_stop', 'elevator', 'ford')\n OR power IN ('plant', 'station', 'generator', 'sub_station', 'substation')\n OR boundary IN ('national_park')\n OR waterway = 'dam')\n AND name IS NOT NULL\n ORDER BY way_area DESC\n) AS text_poly", + "table": "(SELECT\n way,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels,\n COALESCE(\n 'aeroway_' || CASE WHEN aeroway IN ('gate', 'apron', 'helipad', 'aerodrome') THEN aeroway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'hotel', 'motel', 'hostel', 'chalet', 'guest_house', 'camp_site', 'caravan_site', \n 'theme_park', 'museum', 'zoo', 'information', 'picnic_site') THEN tourism ELSE NULL END,\n 'amenity_' || CASE WHEN amenity IN ('pub', 'restaurant', 'food_court', 'cafe', 'fast_food', 'biergarten', 'bar', 'library', \n 'theatre', 'courthouse', 'townhall', 'cinema', 'clinic', 'community_centre', 'parking', \n 'bicycle_parking', 'motorcycle_parking', 'police', 'fire_station', 'fountain', 'place_of_worship', \n 'grave_yard', 'shelter', 'bank', 'embassy', 'fuel', 'bus_station', 'prison', 'university', \n 'school', 'college', 'kindergarten', 'hospital', 'ice_cream', 'pharmacy', 'doctors', 'dentist', \n 'atm', 'bicycle_rental', 'car_rental', 'car_wash', 'post_box', 'post_office',\n 'recycling', 'telephone', 'emergency_phone', 'toilets', 'taxi', 'drinking_water', 'hunting_stand', \n 'nightclub', 'veterinary', 'social_facility') THEN amenity ELSE NULL END,\n 'shop_' || CASE WHEN shop IN ('supermarket', 'bag', 'bakery', 'beauty', 'books', 'butcher', 'clothes', 'computer', 'confectionery', \n 'fashion', 'convenience', 'department_store', 'doityourself', 'hardware', 'florist', 'garden_centre', \n 'hairdresser', 'hifi', 'ice_cream', 'car', 'car_repair', 'bicycle', 'mall', 'pet', 'photo', 'photo_studio', \n 'photography', 'seafood', 'shoes', 'alcohol', 'gift', 'furniture', 'kiosk', 'mobile_phone', 'motorcycle', \n 'musical_instrument', 'newsagent', 'optician', 'jewelry', 'jewellery', 'electronics', 'chemist', 'toys', \n 'travel_agency', 'car_parts', 'greengrocer', 'farm', 'stationery', 'laundry', 'dry_cleaning', 'beverages', \n 'perfumery', 'cosmetics', 'variety_store', 'wine', 'outdoor', 'copyshop', 'sports') THEN shop \n WHEN shop IN ('accessories', 'antiques', 'appliance', 'art', 'baby_goods', 'bathroom_furnishing', 'bed', \n 'boat', 'bookmaker', 'boutique', 'builder', 'building_materials', 'camera', 'car_service', 'carpet', 'charity', \n 'cheese', 'chocolate', 'coffee', 'communication', 'craft', 'curtain', 'dairy', 'deli', \n 'discount', 'e-cigarette', 'electrical', 'energy', 'erotic', 'estate_agent', 'fabric', 'fishing', \n 'flooring', 'food', 'frame', 'frozen_food', 'funeral_directors', 'furnace', 'gallery', 'games', 'gas', \n 'general', 'glaziery', 'grocery', 'health', 'health_food', 'hearing_aids', 'herbalist', 'hobby', 'household', \n 'houseware', 'hunting', 'interior_decoration', 'kitchen', 'leather', 'lighting', 'locksmith', \n 'lottery', 'market', 'massage', 'medical', 'medical_supply', 'money_lender', 'motorcycle_repair', 'music', \n 'office_supplies', 'organic', 'paint', 'pastry', 'pawnbroker', 'phone', 'pottery', \n 'printing', 'radiotechnics', 'real_estate', 'religion', 'rental', 'salon', 'scuba_diving', 'second_hand', \n 'sewing', 'shoe_repair', 'shopping_centre', 'solarium', 'souvenir', 'tailor', 'tanning', 'tattoo', 'tea', \n 'ticket', 'tiles', 'tobacco', 'trade', 'tyres', 'vacuum_cleaner', 'video', 'video_games', 'watches', 'wholesale', \n 'yes') THEN 'other' ELSE NULL END,\n 'leisure_' || CASE WHEN leisure IN ('swimming_pool', 'water_park', 'miniature_golf', 'golf_course', 'sports_centre', 'stadium', 'track', \n 'pitch', 'playground', 'park', 'recreation_ground', 'common', 'garden', 'nature_reserve', 'marina', \n 'picnic_table') THEN leisure ELSE NULL END,\n 'power_' || CASE WHEN power IN ('plant', 'station', 'generator', 'sub_station', 'substation') THEN power ELSE NULL END,\n 'landuse_' || CASE WHEN landuse IN ('reservoir', 'basin', 'recreation_ground', 'village_green', 'quarry', 'vineyard', 'orchard', 'cemetery', \n 'residential', 'garages', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', \n 'greenhouse_horticulture', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', \n 'construction', 'military') THEN landuse ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('lighthouse', 'windmill', 'mast', 'water_tower', 'pier', 'breakwater', 'groyne') THEN man_made ELSE NULL END,\n 'natural_' || CASE WHEN \"natural\" IN ('wood', 'water', 'mud', 'wetland', 'marsh', 'bay', 'spring', 'scree', 'shingle', 'bare_rock', 'sand', 'heath', \n 'grassland', 'scrub', 'beach', 'shoal', 'reef', 'glacier') THEN \"natural\" ELSE NULL END,\n 'place_' || CASE WHEN place IN ('island', 'islet') THEN place ELSE NULL END,\n 'military_' || CASE WHEN military IN ('danger_area') THEN military ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site') THEN historic ELSE NULL END,\n 'highway_' || CASE WHEN highway IN ('services', 'rest_area', 'bus_stop', 'elevator', 'ford') THEN highway ELSE NULL END,\n 'boundary_' || CASE WHEN boundary IN ('national_park') THEN boundary ELSE NULL END,\n 'waterway_' || CASE WHEN waterway IN ('dam') THEN waterway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('attraction') THEN tourism ELSE NULL END\n ) AS feature,\n access,\n name,\n tags->'operator' as operator,\n ref,\n way_area,\n CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building\n FROM planet_osm_polygon\n -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering\n WHERE (aeroway IN ('gate', 'apron', 'helipad', 'aerodrome')\n OR tourism IN ('alpine_hut', 'hotel', 'motel', 'hostel', 'chalet', 'guest_house', 'camp_site', 'caravan_site', 'theme_park', \n 'museum', 'attraction', 'zoo', 'information', 'picnic_site')\n OR amenity IS NOT NULL -- skip checking a huge list and use a null check\n OR shop IS NOT NULL\n OR leisure IS NOT NULL\n OR landuse IS NOT NULL\n OR man_made IN ('lighthouse', 'windmill', 'mast', 'water_tower', 'pier', 'breakwater', 'groyne')\n OR \"natural\" IS NOT NULL\n OR place IN ('island', 'islet')\n OR military IN ('danger_area')\n OR historic IN ('memorial', 'monument', 'archaeological_site')\n OR highway IN ('services', 'rest_area', 'bus_stop', 'elevator', 'ford')\n OR power IN ('plant', 'station', 'generator', 'sub_station', 'substation')\n OR boundary IN ('national_park')\n OR waterway = 'dam')\n AND name IS NOT NULL\n ORDER BY way_area DESC\n) AS text_poly", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1737,7 +1737,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n NULL as way_pixels,\n COALESCE('man_made_' || man_made, 'waterway_' || waterway, 'natural_' || \"natural\") AS feature,\n access,\n name,\n operator,\n ref,\n NULL AS way_area,\n CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building\n FROM planet_osm_line\n WHERE (man_made IN ('pier', 'breakwater', 'groyne', 'embankment')\n OR waterway IN ('dam', 'weir')\n OR \"natural\" IN ('cliff'))\n AND name IS NOT NULL\n) AS text_line", + "table": "(SELECT\n way,\n NULL as way_pixels,\n COALESCE('man_made_' || man_made, 'waterway_' || waterway, 'natural_' || \"natural\") AS feature,\n access,\n name,\n tags->'operator' as operator,\n ref,\n NULL AS way_area,\n CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building\n FROM planet_osm_line\n WHERE (man_made IN ('pier', 'breakwater', 'groyne', 'embankment')\n OR waterway IN ('dam', 'weir')\n OR \"natural\" IN ('cliff'))\n AND name IS NOT NULL\n) AS text_line", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1763,7 +1763,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n way_pixels,\n feature,\n access,\n CONCAT(\n name,\n CASE WHEN name IS NOT NULL AND elevation IS NOT NULL THEN E'\\n' ELSE NULL END,\n CASE WHEN elevation IS NOT NULL THEN CONCAT(REPLACE(ROUND(elevation)::TEXT, '-', U&'\\2212'), U&'\\00A0', 'm') ELSE NULL END\n ) AS name,\n CASE\n WHEN \"natural\" IN ('peak', 'volcano', 'saddle') THEN elevation\n ELSE NULL\n END AS score,\n operator,\n ref,\n way_area,\n is_building\n FROM\n (SELECT\n way,\n NULL AS way_pixels,\n COALESCE(\n 'aeroway_' || CASE WHEN aeroway IN ('gate', 'apron', 'helipad', 'aerodrome') THEN aeroway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'hotel', 'motel', 'hostel', 'chalet', 'guest_house', 'camp_site', 'caravan_site', \n 'theme_park', 'museum', 'zoo', 'information', 'picnic_site') THEN tourism ELSE NULL END,\n 'amenity_' || CASE WHEN amenity IN ('pub', 'restaurant', 'food_court', 'cafe', 'fast_food', 'biergarten', 'bar', 'library', 'theatre', \n 'courthouse', 'townhall', 'cinema', 'clinic', 'community_centre', 'parking', 'bicycle_parking', \n 'motorcycle_parking', 'police', 'fire_station', 'fountain', 'place_of_worship', 'grave_yard', 'shelter', 'bank', \n 'embassy', 'fuel', 'bus_station', 'prison', 'university', 'school', 'college', 'kindergarten', 'hospital', \n 'ice_cream', 'pharmacy', 'doctors', 'dentist', 'atm', 'bicycle_rental', 'car_rental',\n 'car_wash', 'post_box', 'post_office', 'recycling', 'telephone', 'emergency_phone', 'toilets', 'taxi', \n 'drinking_water', 'hunting_stand', 'nightclub', 'veterinary', 'social_facility') THEN amenity ELSE NULL END,\n 'shop_' || CASE WHEN shop IN ('supermarket', 'bag','bakery', 'beauty', 'books', 'butcher', 'clothes', 'computer', 'confectionery', 'fashion', \n 'convenience', 'department_store', 'doityourself', 'hardware', 'florist', 'garden_centre', 'hairdresser', \n 'hifi', 'ice_cream', 'car', 'car_repair', 'bicycle', 'mall', 'pet', 'photo', 'photo_studio', 'photography', \n 'seafood', 'shoes', 'alcohol', 'gift', 'furniture', 'kiosk', 'mobile_phone', 'motorcycle', 'musical_instrument', \n 'newsagent', 'optician', 'jewelry', 'jewellery', 'electronics', 'chemist', 'toys', 'travel_agency', 'car_parts', \n 'greengrocer', 'farm', 'stationery', 'laundry', 'dry_cleaning', 'beverages', 'perfumery', 'cosmetics', \n 'variety_store', 'wine', 'outdoor', 'copyshop', 'sports') THEN shop \n WHEN shop IN ('accessories', 'antiques', 'appliance', 'art', \n 'baby_goods', 'bathroom_furnishing', 'bed', 'boat', 'bookmaker', 'boutique', 'builder', \n 'building_materials', 'camera', 'car_service', 'carpet', 'charity', 'cheese', 'chocolate', 'coffee', \n 'communication', 'craft', 'curtain', 'dairy', 'deli', 'discount', \n 'e-cigarette', 'electrical', 'energy', 'erotic', 'estate_agent', 'fabric', 'fishing', 'flooring', \n 'food', 'frame', 'frozen_food', 'funeral_directors', 'furnace', 'gallery', 'games', 'gas', \n 'general', 'glaziery', 'grocery', 'health', 'health_food', 'hearing_aids', 'herbalist', 'hobby', 'household', \n 'houseware', 'hunting', 'interior_decoration', 'kitchen', 'leather', 'lighting', 'locksmith', \n 'lottery', 'market', 'massage', 'medical', 'medical_supply', 'money_lender', 'motorcycle_repair', 'music', \n 'office_supplies', 'organic', 'paint', 'pastry', 'pawnbroker', 'phone', 'pottery', \n 'printing', 'radiotechnics', 'real_estate', 'religion', 'rental', 'salon', 'scuba_diving', 'second_hand', \n 'sewing', 'shoe_repair', 'shopping_centre', 'solarium', 'souvenir', 'tailor', 'tanning', 'tattoo', \n 'tea', 'ticket', 'tiles', 'tobacco', 'trade', 'tyres', 'vacuum_cleaner', 'video', 'video_games', 'watches', \n 'wholesale', 'yes') THEN 'other' ELSE NULL END,\n 'leisure_' || CASE WHEN leisure IN ('swimming_pool', 'water_park', 'miniature_golf', 'golf_course', 'sports_centre', 'stadium', 'track', \n 'pitch','playground', 'park', 'recreation_ground', 'common', 'garden', 'nature_reserve', 'marina', \n 'slipway', 'picnic_table') THEN leisure ELSE NULL END,\n 'power_' || CASE WHEN power IN ('plant', 'station', 'generator', 'sub_station', 'substation') THEN power ELSE NULL END,\n 'landuse_' || CASE WHEN landuse IN ('reservoir', 'basin', 'recreation_ground', 'village_green', 'quarry', 'vineyard', 'orchard', 'cemetery', \n 'residential', 'garages', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', \n 'greenhouse_horticulture', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', \n 'construction', 'military') THEN landuse ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('lighthouse', 'windmill', 'mast', 'water_tower') THEN man_made ELSE NULL END,\n 'natural_' || CASE WHEN \"natural\" IN ('wood', 'peak', 'volcano', 'saddle', 'cave_entrance', 'water', 'mud', 'wetland', 'marsh', 'bay', 'spring', \n 'scree', 'shingle', 'bare_rock', 'sand', 'heath', 'grassland', 'scrub', 'beach', 'glacier', 'tree') \n THEN \"natural\" ELSE NULL END,\n 'place_' || CASE WHEN place IN ('island', 'islet') THEN place ELSE NULL END,\n 'military_' || CASE WHEN military IN ('danger_area') THEN military ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site') THEN historic ELSE NULL END,\n 'highway_' || CASE WHEN highway IN ('services', 'rest_area', 'bus_stop', 'elevator', 'ford') THEN highway ELSE NULL END,\n 'boundary_' || CASE WHEN boundary IN ('national_park') THEN boundary ELSE NULL END,\n 'waterway_' || CASE WHEN waterway IN ('dam', 'weir') THEN waterway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('attraction', 'viewpoint') THEN tourism ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('cross') THEN man_made ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('wayside_cross') THEN historic ELSE NULL END\n ) AS feature,\n access,\n name,\n CASE\n WHEN \"natural\" IN ('peak', 'volcano', 'saddle') OR tourism = 'alpine_hut' OR amenity = 'shelter' THEN\n CASE\n WHEN ele ~ '^-?\\d{1,4}(\\.\\d+)?$' THEN ele::NUMERIC\n ELSE NULL\n END\n ELSE NULL\n END AS elevation,\n \"natural\",\n operator,\n ref,\n NULL AS way_area,\n CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building\n FROM planet_osm_point\n -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering\n WHERE (aeroway IN ('gate', 'apron', 'helipad', 'aerodrome')\n OR tourism IN ('alpine_hut', 'hotel', 'motel', 'hostel', 'chalet', 'guest_house', 'camp_site', 'caravan_site', 'theme_park', \n 'museum', 'attraction', 'zoo', 'information', 'viewpoint', 'picnic_site')\n OR amenity IS NOT NULL -- skip checking a huge list and use a null check\n OR shop IS NOT NULL\n OR leisure IS NOT NULL\n OR landuse IN ('reservoir', 'basin', 'recreation_ground', 'village_green', 'quarry', 'vineyard', 'orchard', 'cemetery', 'residential', \n 'garages', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'greenhouse_horticulture', \n 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'construction', 'military')\n OR man_made IN ('lighthouse', 'windmill', 'mast', 'water_tower', 'cross')\n OR \"natural\" IS NOT NULL\n OR place IN ('island', 'islet')\n OR military IN ('danger_area')\n OR historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross')\n OR highway IN ('bus_stop', 'services', 'rest_area', 'elevator', 'ford')\n OR power IN ('plant', 'station', 'generator', 'sub_station', 'substation')\n OR boundary IN ('national_park')\n OR waterway IN ('dam', 'weir'))\n AND name IS NOT NULL\n ) AS p\n ORDER BY score DESC NULLS LAST\n ) AS text", + "table": "(SELECT\n way,\n way_pixels,\n feature,\n access,\n CONCAT(\n name,\n CASE WHEN name IS NOT NULL AND elevation IS NOT NULL THEN E'\\n' ELSE NULL END,\n CASE WHEN elevation IS NOT NULL THEN CONCAT(REPLACE(ROUND(elevation)::TEXT, '-', U&'\\2212'), U&'\\00A0', 'm') ELSE NULL END\n ) AS name,\n CASE\n WHEN \"natural\" IN ('peak', 'volcano', 'saddle') THEN elevation\n ELSE NULL\n END AS score,\n operator,\n ref,\n way_area,\n is_building\n FROM\n (SELECT\n way,\n NULL AS way_pixels,\n COALESCE(\n 'aeroway_' || CASE WHEN aeroway IN ('gate', 'apron', 'helipad', 'aerodrome') THEN aeroway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('alpine_hut', 'hotel', 'motel', 'hostel', 'chalet', 'guest_house', 'camp_site', 'caravan_site', \n 'theme_park', 'museum', 'zoo', 'information', 'picnic_site') THEN tourism ELSE NULL END,\n 'amenity_' || CASE WHEN amenity IN ('pub', 'restaurant', 'food_court', 'cafe', 'fast_food', 'biergarten', 'bar', 'library', 'theatre', \n 'courthouse', 'townhall', 'cinema', 'clinic', 'community_centre', 'parking', 'bicycle_parking', \n 'motorcycle_parking', 'police', 'fire_station', 'fountain', 'place_of_worship', 'grave_yard', 'shelter', 'bank', \n 'embassy', 'fuel', 'bus_station', 'prison', 'university', 'school', 'college', 'kindergarten', 'hospital', \n 'ice_cream', 'pharmacy', 'doctors', 'dentist', 'atm', 'bicycle_rental', 'car_rental',\n 'car_wash', 'post_box', 'post_office', 'recycling', 'telephone', 'emergency_phone', 'toilets', 'taxi', \n 'drinking_water', 'hunting_stand', 'nightclub', 'veterinary', 'social_facility') THEN amenity ELSE NULL END,\n 'shop_' || CASE WHEN shop IN ('supermarket', 'bag','bakery', 'beauty', 'books', 'butcher', 'clothes', 'computer', 'confectionery', 'fashion', \n 'convenience', 'department_store', 'doityourself', 'hardware', 'florist', 'garden_centre', 'hairdresser', \n 'hifi', 'ice_cream', 'car', 'car_repair', 'bicycle', 'mall', 'pet', 'photo', 'photo_studio', 'photography', \n 'seafood', 'shoes', 'alcohol', 'gift', 'furniture', 'kiosk', 'mobile_phone', 'motorcycle', 'musical_instrument', \n 'newsagent', 'optician', 'jewelry', 'jewellery', 'electronics', 'chemist', 'toys', 'travel_agency', 'car_parts', \n 'greengrocer', 'farm', 'stationery', 'laundry', 'dry_cleaning', 'beverages', 'perfumery', 'cosmetics', \n 'variety_store', 'wine', 'outdoor', 'copyshop', 'sports') THEN shop \n WHEN shop IN ('accessories', 'antiques', 'appliance', 'art', \n 'baby_goods', 'bathroom_furnishing', 'bed', 'boat', 'bookmaker', 'boutique', 'builder', \n 'building_materials', 'camera', 'car_service', 'carpet', 'charity', 'cheese', 'chocolate', 'coffee', \n 'communication', 'craft', 'curtain', 'dairy', 'deli', 'discount', \n 'e-cigarette', 'electrical', 'energy', 'erotic', 'estate_agent', 'fabric', 'fishing', 'flooring', \n 'food', 'frame', 'frozen_food', 'funeral_directors', 'furnace', 'gallery', 'games', 'gas', \n 'general', 'glaziery', 'grocery', 'health', 'health_food', 'hearing_aids', 'herbalist', 'hobby', 'household', \n 'houseware', 'hunting', 'interior_decoration', 'kitchen', 'leather', 'lighting', 'locksmith', \n 'lottery', 'market', 'massage', 'medical', 'medical_supply', 'money_lender', 'motorcycle_repair', 'music', \n 'office_supplies', 'organic', 'paint', 'pastry', 'pawnbroker', 'phone', 'pottery', \n 'printing', 'radiotechnics', 'real_estate', 'religion', 'rental', 'salon', 'scuba_diving', 'second_hand', \n 'sewing', 'shoe_repair', 'shopping_centre', 'solarium', 'souvenir', 'tailor', 'tanning', 'tattoo', \n 'tea', 'ticket', 'tiles', 'tobacco', 'trade', 'tyres', 'vacuum_cleaner', 'video', 'video_games', 'watches', \n 'wholesale', 'yes') THEN 'other' ELSE NULL END,\n 'leisure_' || CASE WHEN leisure IN ('swimming_pool', 'water_park', 'miniature_golf', 'golf_course', 'sports_centre', 'stadium', 'track', \n 'pitch','playground', 'park', 'recreation_ground', 'common', 'garden', 'nature_reserve', 'marina', \n 'slipway', 'picnic_table') THEN leisure ELSE NULL END,\n 'power_' || CASE WHEN power IN ('plant', 'station', 'generator', 'sub_station', 'substation') THEN power ELSE NULL END,\n 'landuse_' || CASE WHEN landuse IN ('reservoir', 'basin', 'recreation_ground', 'village_green', 'quarry', 'vineyard', 'orchard', 'cemetery', \n 'residential', 'garages', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', \n 'greenhouse_horticulture', 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', \n 'construction', 'military') THEN landuse ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('lighthouse', 'windmill', 'mast', 'water_tower') THEN man_made ELSE NULL END,\n 'natural_' || CASE WHEN \"natural\" IN ('wood', 'peak', 'volcano', 'saddle', 'cave_entrance', 'water', 'mud', 'wetland', 'marsh', 'bay', 'spring', \n 'scree', 'shingle', 'bare_rock', 'sand', 'heath', 'grassland', 'scrub', 'beach', 'glacier', 'tree') \n THEN \"natural\" ELSE NULL END,\n 'place_' || CASE WHEN place IN ('island', 'islet') THEN place ELSE NULL END,\n 'military_' || CASE WHEN military IN ('danger_area') THEN military ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('memorial', 'monument', 'archaeological_site') THEN historic ELSE NULL END,\n 'highway_' || CASE WHEN highway IN ('services', 'rest_area', 'bus_stop', 'elevator', 'ford') THEN highway ELSE NULL END,\n 'boundary_' || CASE WHEN boundary IN ('national_park') THEN boundary ELSE NULL END,\n 'waterway_' || CASE WHEN waterway IN ('dam', 'weir') THEN waterway ELSE NULL END,\n 'tourism_' || CASE WHEN tourism IN ('attraction', 'viewpoint') THEN tourism ELSE NULL END,\n 'man_made_' || CASE WHEN man_made IN ('cross') THEN man_made ELSE NULL END,\n 'historic_' || CASE WHEN historic IN ('wayside_cross') THEN historic ELSE NULL END\n ) AS feature,\n access,\n name,\n CASE\n WHEN \"natural\" IN ('peak', 'volcano', 'saddle') OR tourism = 'alpine_hut' OR amenity = 'shelter' THEN\n CASE\n WHEN tags->'ele' ~ '^-?\\d{1,4}(\\.\\d+)?$' THEN (tags->'ele')::NUMERIC\n ELSE NULL\n END\n ELSE NULL\n END AS elevation,\n \"natural\",\n tags->'operator' as operator,\n ref,\n NULL AS way_area,\n CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building\n FROM planet_osm_point\n -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering\n WHERE (aeroway IN ('gate', 'apron', 'helipad', 'aerodrome')\n OR tourism IN ('alpine_hut', 'hotel', 'motel', 'hostel', 'chalet', 'guest_house', 'camp_site', 'caravan_site', 'theme_park', \n 'museum', 'attraction', 'zoo', 'information', 'viewpoint', 'picnic_site')\n OR amenity IS NOT NULL -- skip checking a huge list and use a null check\n OR shop IS NOT NULL\n OR leisure IS NOT NULL\n OR landuse IN ('reservoir', 'basin', 'recreation_ground', 'village_green', 'quarry', 'vineyard', 'orchard', 'cemetery', 'residential', \n 'garages', 'meadow', 'grass', 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'greenhouse_horticulture', \n 'retail', 'industrial', 'railway', 'commercial', 'brownfield', 'landfill', 'construction', 'military')\n OR man_made IN ('lighthouse', 'windmill', 'mast', 'water_tower', 'cross')\n OR \"natural\" IS NOT NULL\n OR place IN ('island', 'islet')\n OR military IN ('danger_area')\n OR historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross')\n OR highway IN ('bus_stop', 'services', 'rest_area', 'elevator', 'ford')\n OR power IN ('plant', 'station', 'generator', 'sub_station', 'substation')\n OR boundary IN ('national_park')\n OR waterway IN ('dam', 'weir'))\n AND name IS NOT NULL\n ) AS p\n ORDER BY score DESC NULLS LAST\n ) AS text", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1893,7 +1893,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n waterway,\n lock,\n name,\n intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND (tunnel IS NULL or tunnel != 'culvert')\n AND name IS NOT NULL\n ORDER BY z_order\n) AS water_lines_text", + "table": "(SELECT\n way,\n waterway,\n lock,\n name,\n tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND (tunnel IS NULL or tunnel != 'culvert')\n AND name IS NOT NULL\n ORDER BY z_order\n) AS water_lines_text", "geometry_field": "way", "type": "postgis", "key_field": "", diff --git a/project.yaml b/project.yaml index d4f8984ae3..6108186c03 100644 --- a/project.yaml +++ b/project.yaml @@ -116,7 +116,7 @@ Layer: way, COALESCE(name, '') AS name, ('landuse_' || (CASE WHEN landuse IN ('forest', 'military') THEN landuse ELSE NULL END)) AS landuse, ('natural_' || (CASE WHEN "natural" IN ('wood', 'sand', 'scree', 'shingle', 'bare_rock') THEN "natural" ELSE NULL END)) AS "natural", - ('wetland_' || (CASE WHEN "natural" IN ('wetland', 'mud') THEN (CASE WHEN "natural" IN ('mud') THEN "natural" ELSE wetland END) ELSE NULL END)) AS wetland, + ('wetland_' || (CASE WHEN "natural" IN ('wetland', 'mud') THEN (CASE WHEN "natural" IN ('mud') THEN "natural" ELSE tags->'wetland' END) ELSE NULL END)) AS wetland, way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels FROM planet_osm_polygon WHERE (landuse IN ('forest', 'military') @@ -155,7 +155,7 @@ Layer: 'track') THEN leisure ELSE NULL END)) AS leisure, ('military_' || (CASE WHEN military IN ('danger_area') THEN military ELSE NULL END)) AS military, ('natural_' || (CASE WHEN "natural" IN ('beach', 'shoal', 'heath', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub') THEN "natural" ELSE NULL END)) AS "natural", - ('wetland_' || (CASE WHEN "natural" IN ('wetland', 'marsh', 'mud') THEN (CASE WHEN "natural" IN ('marsh', 'mud') THEN "natural" ELSE wetland END) ELSE NULL END)) AS wetland, + ('wetland_' || (CASE WHEN "natural" IN ('wetland', 'marsh', 'mud') THEN (CASE WHEN "natural" IN ('marsh', 'mud') THEN "natural" ELSE tags->'wetland' END) ELSE NULL END)) AS wetland, ('power_' || (CASE WHEN power IN ('station', 'sub_station', 'substation', 'generator') THEN power ELSE NULL END)) AS power, ('tourism_' || (CASE WHEN tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site') THEN tourism ELSE NULL END)) AS tourism, ('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway ELSE NULL END)) AS highway, @@ -206,7 +206,7 @@ Layer: <<: *osm2pgsql table: |- (SELECT - way, waterway, intermittent, + way, waterway, tags->'intermittent' as intermittent, CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel FROM planet_osm_line WHERE waterway IN ('stream', 'drain', 'ditch') @@ -222,7 +222,7 @@ Layer: Datasource: <<: *osm2pgsql table: |- - (SELECT way, waterway, intermittent + (SELECT way, waterway, tags->'intermittent' as intermittent FROM planet_osm_line WHERE waterway = 'river' ) AS water_lines_low_zoom @@ -281,10 +281,10 @@ Layer: COALESCE("natural", CASE WHEN landuse = 'forest' THEN 'wood' ELSE NULL END) AS "natural", CASE WHEN "natural" IN ('marsh', 'mud') THEN "natural" - ELSE CASE WHEN ("natural" = 'wetland' AND wetland IS NULL) + ELSE CASE WHEN ("natural" = 'wetland' AND NOT tags ? 'wetland') THEN 'wetland' ELSE CASE WHEN ("natural" = 'wetland') - THEN wetland + THEN tags->'wetland' ELSE NULL END END @@ -318,7 +318,7 @@ Layer: <<: *osm2pgsql table: |- (SELECT - way, waterway, name, intermittent, + way, waterway, name, tags->'intermittent' as intermittent, CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel, 'no' AS bridge FROM planet_osm_line @@ -1156,7 +1156,7 @@ Layer: way, waterway, name, - intermittent, + tags->'intermittent' as intermittent, CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel, 'yes' AS bridge FROM planet_osm_line @@ -1515,7 +1515,7 @@ Layer: capital, ( (CASE - WHEN (population ~ '^[0-9]{1,8}$') THEN population::INTEGER + WHEN (tags->'population' ~ '^[0-9]{1,8}$') THEN (tags->'population')::INTEGER WHEN (place = 'city') THEN 100000 WHEN (place = 'town') THEN 1000 ELSE 1 @@ -1663,9 +1663,9 @@ Layer: ) AS feature, access, religion, - denomination, - "generator:source", - power_source, + tags->'denomination' as denomination, + tags->'generator:source' as "generator:source", + tags->'power_source' as power_source, way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels FROM planet_osm_polygon -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering @@ -1686,7 +1686,7 @@ Layer: OR "natural" IN ('spring') OR historic IN ('memorial', 'monument', 'archaeological_site') OR highway IN ('bus_stop', 'elevator', 'traffic_signals') - OR (power = 'generator' AND ("generator:source" = 'wind' OR power_source = 'wind')) + OR (power = 'generator' AND (tags @> '"generator:source"=>wind' OR tags @> 'power_source=>wind')) ORDER BY way_area desc ) AS amenity_points_poly properties: @@ -1746,15 +1746,15 @@ Layer: CASE WHEN "natural" IN ('peak', 'volcano', 'saddle') THEN CASE - WHEN ele ~ '^-?\d{1,4}(\.\d+)?$' THEN ele::NUMERIC + WHEN tags->'ele' ~ '^-?\d{1,4}(\.\d+)?$' THEN (tags->'ele')::NUMERIC ELSE NULL END ELSE NULL END AS score, religion, - denomination, - "generator:source", - power_source, + tags->'denomination' as denomination, + tags->'generator:source' as "generator:source", + tags->'power_source' as power_source, NULL AS way_pixels FROM planet_osm_point -- The upcoming where clause is needed for performance only, as the CASE statements would end up doing the equivalent filtering @@ -1775,7 +1775,7 @@ Layer: OR "natural" IN ('peak', 'volcano', 'saddle', 'spring', 'cave_entrance') OR historic IN ('memorial', 'monument', 'archaeological_site', 'wayside_cross') OR highway IN ('bus_stop', 'elevator', 'traffic_signals', 'ford') - OR (power = 'generator' AND ("generator:source" = 'wind' OR power_source = 'wind')) + OR (power = 'generator' AND (tags @> '"generator:source"=>wind' OR tags @> 'power_source=>wind')) ORDER BY score DESC NULLS LAST ) AS amenity_points properties: @@ -2071,7 +2071,7 @@ Layer: ) AS feature, access, name, - operator, + tags->'operator' as operator, ref, way_area, CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building @@ -2113,7 +2113,7 @@ Layer: COALESCE('man_made_' || man_made, 'waterway_' || waterway, 'natural_' || "natural") AS feature, access, name, - operator, + tags->'operator' as operator, ref, NULL AS way_area, CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building @@ -2217,13 +2217,13 @@ Layer: CASE WHEN "natural" IN ('peak', 'volcano', 'saddle') OR tourism = 'alpine_hut' OR amenity = 'shelter' THEN CASE - WHEN ele ~ '^-?\d{1,4}(\.\d+)?$' THEN ele::NUMERIC + WHEN tags->'ele' ~ '^-?\d{1,4}(\.\d+)?$' THEN (tags->'ele')::NUMERIC ELSE NULL END ELSE NULL END AS elevation, "natural", - operator, + tags->'operator' as operator, ref, NULL AS way_area, CASE WHEN building = 'no' OR building IS NULL THEN 'no' ELSE 'yes' END AS is_building @@ -2357,7 +2357,7 @@ Layer: waterway, lock, name, - intermittent, + tags->'intermittent' as intermittent, CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel FROM planet_osm_line WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi') From ae3f38ebc171453c67688e76cdb67c1c7f390abc Mon Sep 17 00:00:00 2001 From: math1985 Date: Mon, 30 May 2016 17:27:53 +0200 Subject: [PATCH 14/25] Convet layer to integer and user layer instead of z_order * Convert layer to integer and use it in queries * Use layer instead of z_order in queries where possible --- openstreetmap-carto.lua | 9 +++++++++ openstreetmap-carto.style | 2 +- project.yaml | 40 +++++++++++++++++++-------------------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 0394879f40..67d55df383 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -271,6 +271,8 @@ function filter_tags_generic(keyvalues, numberofkeys) end end + keyvalues['layer'] = layer(keyvalues['layer']) + -- Filter out objects that have 0 tags after deleting tags if numberofkeys == 0 then return 1, {} @@ -426,3 +428,10 @@ function is_in (needle, haystack) end return false end + +--- Normalizes layer tags +-- @param v The layer tag value +-- @return An integer for the layer tag +function layer (v) + return v and string.find(v, "^-?%d+$") and tonumber(v) < 100 and tonumber(v) > -100 and v or nil +end diff --git a/openstreetmap-carto.style b/openstreetmap-carto.style index cd8c961763..9bec4cc3a6 100644 --- a/openstreetmap-carto.style +++ b/openstreetmap-carto.style @@ -26,7 +26,7 @@ node,way historic text polygon node,way horse text linear node,way junction text linear node,way landuse text polygon -node,way layer text linear +node,way layer int4 linear node,way leisure text polygon node,way lock text linear node,way man_made text polygon diff --git a/project.yaml b/project.yaml index 6108186c03..a6c256a561 100644 --- a/project.yaml +++ b/project.yaml @@ -123,7 +123,7 @@ Layer: OR "natural" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock')) AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real AND building IS NULL - ORDER BY CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END, way_area DESC + ORDER BY COALESCE(layer,0), way_area DESC ) AS features ) AS landcover_low_zoom properties: @@ -175,7 +175,7 @@ Layer: OR highway IN ('services', 'rest_area') OR railway = 'station') AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real - ORDER BY CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END, way_area DESC + ORDER BY COALESCE(layer,0), way_area DESC ) AS landcover ) AS features properties: @@ -263,7 +263,7 @@ Layer: OR "natural" IN ('water', 'glacier')) AND building IS NULL AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real - ORDER BY z_order, way_area DESC + ORDER BY COALESCE(layer,0), way_area DESC ) AS water_areas properties: minzoom: 4 @@ -293,7 +293,7 @@ Layer: WHERE ("natural" IN ('marsh', 'mud', 'wetland', 'wood', 'beach', 'shoal', 'reef') OR landuse = 'forest') AND building IS NULL AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real - ORDER BY z_order, way_area DESC + ORDER BY COALESCE(layer,0), way_area DESC ) AS landcover_area_symbols properties: minzoom: 10 @@ -324,7 +324,7 @@ Layer: FROM planet_osm_line WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi') AND (bridge IS NULL OR bridge NOT IN ('yes', 'aqueduct')) - ORDER BY z_order + ORDER BY COALESCE(layer,0) ) AS water_lines properties: minzoom: 12 @@ -457,7 +457,7 @@ Layer: WHERE building IS NOT NULL AND building != 'no' AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real - ORDER BY z_order, way_area DESC + ORDER BY COALESCE(layer,0), way_area DESC ) AS buildings properties: minzoom: 12 @@ -480,7 +480,7 @@ Layer: AND building != 'no' AND (aeroway = 'terminal' OR amenity = 'place_of_worship') AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real - ORDER BY z_order, way_area DESC) + ORDER BY COALESCE(layer,0), way_area DESC) AS buildings_major properties: minzoom: 12 @@ -531,7 +531,7 @@ Layer: WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, - CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull + COALESCE(layer,0) AS layernotnull FROM planet_osm_line WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') AND highway IS NOT NULL -- end of road select @@ -558,7 +558,7 @@ Layer: CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, NULL AS oneway, 'no' AS link, - CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull + COALESCE(layer,0) AS layernotnull FROM planet_osm_line WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes') AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select @@ -768,7 +768,7 @@ Layer: FROM planet_osm_polygon WHERE highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'track', 'path', 'platform') OR railway IN ('platform') - ORDER BY z_order, way_area DESC + ORDER BY COALESCE(layer,0), way_area DESC ) AS highway_area_casing properties: minzoom: 14 @@ -815,7 +815,7 @@ Layer: WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, - CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull + COALESCE(layer,0) AS layernotnull FROM planet_osm_line WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage')) AND (covered IS NULL OR NOT covered = 'yes') @@ -844,7 +844,7 @@ Layer: CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, NULL AS oneway, 'no' AS link, - CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull + COALESCE(layer,0) AS layernotnull FROM planet_osm_line WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage')) AND (covered IS NULL OR NOT covered = 'yes') @@ -926,7 +926,7 @@ Layer: WHERE highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'living_street', 'track', 'path', 'platform', 'services') OR railway IN ('platform') OR aeroway IN ('runway', 'taxiway', 'helipad') - ORDER BY z_order, way_area desc + ORDER BY COALESCE(layer,0), way_area desc ) AS highway_area_fill properties: minzoom: 14 @@ -973,7 +973,7 @@ Layer: WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, - CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull + COALESCE(layer,0) AS layernotnull FROM planet_osm_line WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage')) AND (covered IS NULL OR NOT covered = 'yes') @@ -1002,7 +1002,7 @@ Layer: CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, NULL AS oneway, 'no' AS link, - CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull + COALESCE(layer,0) AS layernotnull FROM planet_osm_line WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage')) AND (covered IS NULL OR NOT covered = 'yes') @@ -1138,7 +1138,7 @@ Layer: WHERE highway IS NOT NULL OR (railway IS NOT NULL AND railway != 'preserved' AND (service IS NULL OR service NOT IN ('spur', 'siding', 'yard'))) - ORDER BY z_order + ORDER BY COALESCE(layer,0) ) AS roads_low_zoom properties: minzoom: 5 @@ -1162,7 +1162,7 @@ Layer: FROM planet_osm_line WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi') AND bridge IN ('yes', 'aqueduct') - ORDER BY z_order + ORDER BY COALESCE(layer,0) ) AS waterway_bridges properties: minzoom: 15 @@ -1209,7 +1209,7 @@ Layer: WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link, - CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull + COALESCE(layer,0) AS layernotnull FROM planet_osm_line WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct') AND highway IS NOT NULL -- end of road select @@ -1236,7 +1236,7 @@ Layer: CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service, NULL AS oneway, 'no' AS link, - CASE WHEN layer~E'^-?\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull + COALESCE(layer,0) AS layernotnull FROM planet_osm_line WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct') AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select @@ -2363,7 +2363,7 @@ Layer: WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi') AND (tunnel IS NULL or tunnel != 'culvert') AND name IS NOT NULL - ORDER BY z_order + ORDER BY COALESCE(layer,0) ) AS water_lines_text properties: minzoom: 13 From 04956b4bbd27232604ae36da8310bf9bdb84ac93 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Thu, 2 Jun 2016 00:26:32 -0700 Subject: [PATCH 15/25] Clean up and speed up filter_tags_generic --- openstreetmap-carto.lua | 133 +++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 64 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 67d55df383..66c066b41f 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -42,10 +42,8 @@ linestring_values = { -- The following keys will be deleted delete_tags = { 'note', - 'note:.*', 'source', 'source_ref', - 'source:.*', 'attribution', 'comment', 'fixme', @@ -56,24 +54,16 @@ delete_tags = { -- Lots of import tags -- EUROSHA (Various countries) 'project:eurosha_2012', - -- Corine (CLC) (Europe) - 'CLC:.*', -- UrbIS (Brussels, BE) 'ref:UrbIS', - -- Geobase (CA) - 'geobase:.*', -- NHN (CA) 'accuracy:meters', 'sub_sea:type', 'waterway:type', - -- CanVec (CA) - 'canvec:.*', -- StatsCan (CA) 'statscan:rbuid', - -- Geobase (CA) - 'geobase:.*', -- RUIAN (CZ) 'ref:ruian:addr', @@ -84,32 +74,14 @@ delete_tags = { -- UIR-ADR (CZ) 'uir_adr:ADRESA_KOD', - -- osak (DK) - 'osak:.*', - -- kms (DK) - 'kms:.*', -- GST (DK) 'gst:feat_id', -- Maa-amet (EE) 'maaamet:ETAK', - - -- ngbe (ES) - -- See also note:es and source:file above - 'ngbe:.*', - -- FANTOIR (FR) 'ref:FR:FANTOIR', - -- Friuli Venezia Giulia (IT) - 'it:fvg:.*', - - -- KSJ2 (JA) - -- See also note:ja and source_ref above - 'KSJ2:.*', - -- Yahoo/ALPS (JA) - 'yh:.*', - -- 3dshapes (NL) '3dshapes:ggmodelk', -- AND (NL) @@ -117,37 +89,18 @@ delete_tags = { -- OPPDATERIN (NO) 'OPPDATERIN', - - -- LINZ (NZ) - 'LINZ2OSM:.*', - 'linz2osm:.*', - 'LINZ:.*', - -- Various imports (PL) 'addr:city:simc', 'addr:street:sym_ul', 'building:usage:pl', 'building:use:pl', - -- WroclawGIS (PL) - 'WroclawGIS:.*', -- TERYT (PL) 'teryt:simc', -- RABA (SK) 'raba:id', - - -- Naptan (UK) - 'naptan:.*', - - -- TIGER (US) - 'tiger:.*', - -- GNIS (US) - 'gnis:.*', -- DCGIS (Washington DC, US) 'dcgis:gis_id', - -- National Hydrography Dataset (US) - 'NHD:.*', - 'nhd:.*', -- Building Identification Number (New York, US) 'nycdoitt:bin', -- Chicago Building Inport (US) @@ -166,7 +119,58 @@ delete_tags = { 'OBJTYPE', 'SK53_bulk:load' } +delete_wildcards = { + 'note:.*', + 'source:.*', + -- Corine (CLC) (Europe) + 'CLC:.*', + -- Geobase (CA) + 'geobase:.*', + -- CanVec (CA) + 'canvec:.*', + -- Geobase (CA) + 'geobase:.*', + + -- osak (DK) + 'osak:.*', + -- kms (DK) + 'kms:.*', + + -- ngbe (ES) + -- See also note:es and source:file above + 'ngbe:.*', + + -- Friuli Venezia Giulia (IT) + 'it:fvg:.*', + + -- KSJ2 (JA) + -- See also note:ja and source_ref above + 'KSJ2:.*', + -- Yahoo/ALPS (JA) + 'yh:.*', + + -- LINZ (NZ) + 'LINZ2OSM:.*', + 'linz2osm:.*', + 'LINZ:.*', + + -- WroclawGIS (PL) + 'WroclawGIS:.*', + -- Naptan (UK) + 'naptan:.*', + + -- TIGER (US) + 'tiger:.*', + -- GNIS (US) + 'gnis:.*', + -- National Hydrography Dataset (US) + 'NHD:.*', + 'nhd:.*', + -- mvdgis (Montevideo, UY) + 'mvdgis:.*' + +} -- Array used to specify z_order and osmcarto_z_order per key/value combination. -- The former is used for backwards compatibility and for uses that use a single @@ -252,33 +256,34 @@ function add_z_order(keyvalues) end -- Filtering on nodes, ways, and relations -function filter_tags_generic(keyvalues, numberofkeys) - -- Filter out objects with 0 tags - if numberofkeys == 0 then - return 1, {} - end - - local filter = 0 -- Will object be filtered out? - +function filter_tags_generic(tags, n) -- Delete tags listed in delete_tags - for k, v in pairs (keyvalues) do + for tag, _ in pairs (tags) do for _, d in ipairs(delete_tags) do - if string.find(k, d) then - keyvalues[k] = nil - numberofkeys = numberofkeys - 1 + if tag == d then + tags[tag] = nil + break -- Skip this tag from further checks since it's deleted + end + end + end + -- By using a second loop for wildcards we avoid checking already deleted tags + for tag, _ in pairs (tags) do + for _, d in ipairs(delete_wildcards) do + if string.find(tag, d) then + tags[tag] = nil break end end end - keyvalues['layer'] = layer(keyvalues['layer']) - - -- Filter out objects that have 0 tags after deleting tags - if numberofkeys == 0 then + -- Filter out objects that have no tags after deleting + if next(tags) == nil then return 1, {} end - return 0, keyvalues + -- Convert layer to an integer + tags['layer'] = layer(tags['layer']) + return 0, tags end -- Filtering on nodes From d0b1f533ba3f835e8db41976a57a398ddea1217f Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Thu, 2 Jun 2016 01:24:03 -0700 Subject: [PATCH 16/25] Use luadoc strings --- openstreetmap-carto.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 67d55df383..ba85723c72 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -378,7 +378,9 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc return filter, keyvalues, membersuperseded, linestring, polygon, roads end --- Check if an object with given tags should be treated as polygon +--- Check if an object with given tags should be treated as polygon +-- @param tags OSM tags +-- @return 1 if area, 0 if linear function haspolygontags (tags) -- Treat objects tagged as area=yes, area=1, or area=true as polygon, -- and treat objects tagged as area=no, area=0, or area=false not as polygon From 73496d8b3a55163e12bc8b8fbeac6ac1c46376c1 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Thu, 2 Jun 2016 01:24:26 -0700 Subject: [PATCH 17/25] Only handle area=yes --- openstreetmap-carto.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index ba85723c72..51d2e24130 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -382,12 +382,9 @@ end -- @param tags OSM tags -- @return 1 if area, 0 if linear function haspolygontags (tags) - -- Treat objects tagged as area=yes, area=1, or area=true as polygon, - -- and treat objects tagged as area=no, area=0, or area=false not as polygon - if ((tags["area"] == "yes") or (tags["area"] == "1") or (tags["area"] == "true")) then - return 1 - elseif ((tags["area"] == "no") or (tags["area"] == "0") or (tags["area"] == "false")) then - return 0 + -- Treat objects tagged as area=yes polygon, other area as no + if tags["area"] then + return tags["area"] == "yes" end -- Treat objects with a key in polygon_keys as polygon From a43cb7a129d7a648cc525af5eb20574d6ded703b Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Thu, 2 Jun 2016 01:47:35 -0700 Subject: [PATCH 18/25] Refactor polygon special case lists for simpler code --- openstreetmap-carto.lua | 86 ++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 58 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 51d2e24130..a9d3a135da 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -5,39 +5,30 @@ custom_keys = {'z_order', 'osmcarto_z_order'} -- Objects with any of the following keys will be treated as polygon -polygon_keys = {'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisure', - 'man_made', 'military', 'natural', 'office', 'place', 'power', - 'public_transport', 'shop', 'sport', 'tourism', 'waterway', - 'wetland', 'water', 'aeroway', 'abandoned:aeroway', 'abandoned:amenity', - 'abandoned:building', 'abandoned:landuse', 'abandoned:power', 'area:highway'} +polygon_keys = { + 'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisure', + 'man_made', 'military', 'natural', 'office', 'place', 'power', + 'public_transport', 'shop', 'sport', 'tourism', 'waterway', + 'wetland', 'water', 'aeroway', 'abandoned:aeroway', 'abandoned:amenity', + 'abandoned:building', 'abandoned:landuse', 'abandoned:power', 'area:highway' +} --- Objects with any of the following key/value combinations will be treated as polygon -polygon_values = { - {'highway', 'services'}, - {'highway', 'rest_area'}, - {'junction', 'yes'} - } -- Objects with any of the following key/value combinations will be treated as linestring linestring_values = { - {'leisure', 'track'}, - {'man_made', 'embankment'}, - {'man_made', 'breakwater'}, - {'man_made', 'groyne'}, - {'natural', 'cliff'}, - {'natural', 'tree_row'}, - {'historic', 'citywalls'}, - {'waterway', 'canal'}, - {'waterway', 'derelict_canal'}, - {'waterway', 'ditch'}, - {'waterway', 'drain'}, - {'waterway', 'river'}, - {'waterway', 'stream'}, - {'waterway', 'wadi'}, - {'waterway', 'weir'}, - {'power', 'line'}, - {'power', 'minor_line'} - } + leisure = {track = true}, + man_made = {embankment = true, breakwater = true, groyne = true}, + natural = {cliff = true, tree_row = true}, + historic = {citywalls = true}, + waterway = {canal = true, derelict_canal = true, ditch = true, drain = true, river = true, stream = true, wadi = true, weir = true}, + power = {line = true, minor_line = true} +} + +-- Objects with any of the following key/value combinations will be treated as polygon +polygon_values = { + highway = {services = true, rest_area = true}, + junction = {yes = true} +} -- The following keys will be deleted delete_tags = { @@ -384,39 +375,18 @@ end function haspolygontags (tags) -- Treat objects tagged as area=yes polygon, other area as no if tags["area"] then - return tags["area"] == "yes" - end - - -- Treat objects with a key in polygon_keys as polygon - local haspolytags = 0 - for i,k in ipairs(polygon_keys) do - if tags[k] then - local polygontag = 1 - -- However, if the key/value combination occurs in linestring_values, do not treat the object as polygon - for index,tag in pairs(linestring_values) do - if k == tag[1] and tags[k] == tag[2] then - polygontag = 0 - break - end - end - if polygontag == 1 then - haspolytags = 1 - break - end - end + return tags["area"] == "yes" and 1 or 0 end - -- Treat objects with a key/value combination in polygon_values as polygon - if haspolytags == 0 then - for index,tag in pairs(polygon_values) do - if tags[tag[1]] == tag[2] then - haspolytags = 1 - break - end + -- Search through object's tags + for k, v in pairs(tags) do + -- Check if it has a polygon key and not a linestring override, or a polygon k=v + if (polygon_keys[k] and not (linestring_values[k] and linestring_values[k][v])) or + (polygon_values[k] and polygon_values[k][v]) then + return 1 end end - - return haspolytags + return 0 end function is_in (needle, haystack) From 659840cabf2b889dcd79205839ae4ab279a4bbc1 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Thu, 2 Jun 2016 01:48:48 -0700 Subject: [PATCH 19/25] Name polygon function isarea --- openstreetmap-carto.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index a9d3a135da..3d37c3957a 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -305,7 +305,7 @@ function filter_tags_way (keyvalues, numberofkeys) return filter, keyvalues, polygon, roads end - polygon = haspolygontags(keyvalues) + polygon = isarea(keyvalues) -- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads keyvalues, roads = add_z_order(keyvalues) @@ -338,7 +338,7 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc -- Support for old-style multipolygons (1/2): -- If there are no polygon tags, add tags from all outer elements to the multipolygon itself - haspolytags = haspolygontags(keyvalues) + haspolytags = isarea(keyvalues) if (haspolytags == 0) then for i = 1,membercount do if (roles[i] == "outer") then @@ -372,7 +372,7 @@ end --- Check if an object with given tags should be treated as polygon -- @param tags OSM tags -- @return 1 if area, 0 if linear -function haspolygontags (tags) +function isarea (tags) -- Treat objects tagged as area=yes polygon, other area as no if tags["area"] then return tags["area"] == "yes" and 1 or 0 From 10bff06c71f4707f1c312e4f98cd41e9d4d3e0cb Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Thu, 2 Jun 2016 02:01:17 -0700 Subject: [PATCH 20/25] Use local vars for polygon stuff --- openstreetmap-carto.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 3d37c3957a..6e3946f51c 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -5,7 +5,7 @@ custom_keys = {'z_order', 'osmcarto_z_order'} -- Objects with any of the following keys will be treated as polygon -polygon_keys = { +local polygon_keys = { 'building', 'landuse', 'amenity', 'harbour', 'historic', 'leisure', 'man_made', 'military', 'natural', 'office', 'place', 'power', 'public_transport', 'shop', 'sport', 'tourism', 'waterway', @@ -15,7 +15,7 @@ polygon_keys = { -- Objects with any of the following key/value combinations will be treated as linestring -linestring_values = { +local linestring_values = { leisure = {track = true}, man_made = {embankment = true, breakwater = true, groyne = true}, natural = {cliff = true, tree_row = true}, @@ -25,7 +25,7 @@ linestring_values = { } -- Objects with any of the following key/value combinations will be treated as polygon -polygon_values = { +local polygon_values = { highway = {services = true, rest_area = true}, junction = {yes = true} } From 5175195b817d31a737242da5ce8524acbf7cce79 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Wed, 15 Jun 2016 02:15:28 -0700 Subject: [PATCH 21/25] Search through possible polygon tags --- openstreetmap-carto.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 6e3946f51c..fd255eae5c 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -381,8 +381,13 @@ function isarea (tags) -- Search through object's tags for k, v in pairs(tags) do -- Check if it has a polygon key and not a linestring override, or a polygon k=v - if (polygon_keys[k] and not (linestring_values[k] and linestring_values[k][v])) or - (polygon_values[k] and polygon_values[k][v]) then + for _, ptag in ipairs(polygon_keys) do + if k == ptag and not (linestring_values[k] and linestring_values[k][v]) then + return 1 + end + end + + if (polygon_values[k] and polygon_values[k][v]) then return 1 end end From be2eb577b8804d5b0bfc22d41e8f8ec25a87a498 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Wed, 15 Jun 2016 18:04:36 -0700 Subject: [PATCH 22/25] Refactor lua z_order and roads code --- openstreetmap-carto.lua | 166 +++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 86 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index 66c066b41f..8eae5afc43 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -172,87 +172,83 @@ delete_wildcards = { } --- Array used to specify z_order and osmcarto_z_order per key/value combination. --- The former is used for backwards compatibility and for uses that use a single --- database for multiple rendering styles. --- Each element has the form {key, value, z_order, osmcarto_z_order, is_road}. --- If is_road=1, the object will be added to planet_osm_roads. -zordering_tags = { - {'railway', nil, 5, 0, 1}, - {'boundary', 'administrative', 0, 0, 1}, - {'bridge', 'yes', 10, 0, 0}, - {'bridge', 'true', 10, 0, 0}, - {'bridge', 1, 10, 0, 0}, - {'tunnel', 'yes', -10, 0, 0}, - {'tunnel', 'true', -10, 0, 0}, - {'tunnel', 1, -10, 0, 0}, - {'railway', 'rail', 0, 440, 1}, - {'railway', 'subway', 0, 420, 1}, - {'railway', 'narrow_gauge', 0, 420, 1}, - {'railway', 'light_rail', 0, 420, 1}, - {'railway', 'preserved', 0, 420, 1}, - {'railway', 'funicular', 0, 420, 1}, - {'railway', 'monorail', 0, 420, 1}, - {'railway', 'miniature', 0, 420, 1}, - {'railway', 'turntable', 0, 420, 1}, - {'railway', 'tram', 0, 410, 1}, - {'railway', 'tram-service', 0, 405, 1}, - {'railway', 'disused', 0, 400, 1}, - {'railway', 'construction', 0, 400, 1}, - {'highway', 'motorway', 9, 380, 1}, - {'highway', 'trunk', 8, 370, 1}, - {'highway', 'primary', 7, 360, 1}, - {'highway', 'secondary', 6, 350, 1}, - {'highway', 'tertiary', 4, 340, 0}, - {'highway', 'residential', 3, 330, 0}, - {'highway', 'unclassified', 3, 330, 0}, - {'highway', 'road', 3, 330, 0}, - {'highway', 'living_street', 0, 320, 0}, - {'highway', 'pedestrian', 0, 310, 0}, - {'highway', 'raceway', 0, 300, 0}, - {'highway', 'motorway_link', 9, 240, 1}, - {'highway', 'trunk_link', 6, 230, 1}, - {'highway', 'primary_link', 5, 220, 1}, - {'highway', 'secondary_link', 4, 210, 1}, - {'highway', 'tertiary_link', 3, 200, 0}, - {'highway', 'service', 0, 150, 0}, - {'highway', 'track', 0, 110, 0}, - {'highway', 'path', 0, 100, 0}, - {'highway', 'footway', 0, 100, 0}, - {'highway', 'bridleway', 0, 100, 0}, - {'highway', 'cycleway', 0, 100, 0}, - {'highway', 'steps', 0, 100, 0}, - {'highway', 'platform', 0, 90, 0}, - {'highway', 'minor', 3, 0, 0}, - {'railway', 'platform', 0, 90, 0}, - {'aeroway', 'runway', 0, 60, 0}, - {'aeroway', 'taxiway', 0, 50, 0}, - {'highway', 'construction', 0, 10, 0} +-- Big table for z_order and roads status for certain tags. z=0 is turned into +-- nil by the z_order function +local roads_info = { + highway = { + motorway = {z = 380, roads = true}, + trunk = {z = 370, roads = true}, + primary = {z = 360, roads = true}, + secondary = {z = 350, roads = true}, + tertiary = {z = 340, roads = false}, + residential = {z = 330, roads = false}, + unclassified = {z = 330, roads = false}, + road = {z = 330, roads = false}, + living_street = {z = 320, roads = false}, + pedestrian = {z = 310, roads = false}, + raceway = {z = 300, roads = false}, + motorway_link = {z = 240, roads = true}, + trunk_link = {z = 230, roads = true}, + primary_link = {z = 220, roads = true}, + secondary_link = {z = 210, roads = true}, + tertiary_link = {z = 200, roads = false}, + service = {z = 150, roads = false}, + track = {z = 110, roads = false}, + path = {z = 100, roads = false}, + footway = {z = 100, roads = false}, + bridleway = {z = 100, roads = false}, + cycleway = {z = 100, roads = false}, + steps = {z = 90, roads = false}, + platform = {z = 90, roads = false}, + construction = {z = 10, roads = false} + }, + railway = { + rail = {z = 440, roads = true}, + subway = {z = 420, roads = true}, + narrow_gauge = {z = 420, roads = true}, + light_rail = {z = 420, roads = true}, + preserved = {z = 420, roads = true}, + funicular = {z = 420, roads = true}, + monorail = {z = 420, roads = true}, + miniature = {z = 420, roads = true}, + turntable = {z = 420, roads = true}, + tram = {z = 410, roads = true}, + disused = {z = 400, roads = true}, + construction = {z = 400, roads = true}, + platform = {z = 90, roads = true}, + }, + aeroway = { + runway = {z = 60, roads = false}, + taxiway = {z = 50, roads = false}, + }, + boundary = { + administrative = {z = 0, roads = true} + }, } -function add_z_order(keyvalues) - -- The default z_order is 0 - local z_order = 0 - local osmcarto_z_order = 0 - - -- Increase or decrease z_order based on the specific key/value combination as specified in zordering_tags - for i,k in ipairs(zordering_tags) do - -- If the value in zordering_tags is specified, match key and value. Otherwise, match key only. - if ((k[2] and keyvalues[k[1]] == k[2]) or (k[2] == nil and keyvalues[k[1]] ~= nil)) then - -- If the fifth component of the element of zordering_tags is 1, add the object to planet_osm_roads - if (k[5] == 1) then - roads = 1 - end - z_order = z_order + k[3] - osmcarto_z_order = math.max(osmcarto_z_order, k[4]) - end - end - - -- Add z_order as key/value combination - keyvalues["osmcarto_z_order"] = osmcarto_z_order - keyvalues["z_order"] = z_order +--- Gets the z_order for a set of tags +-- @param tags OSM tags +-- @return z_order if an object with z_order, otherwise nil +function z_order(tags) + local z = 0 + for k, v in pairs(tags) do + if roads_info[k] and roads_info[k][v] then + z = math.max(z, roads_info[k][v].z) + end + end + return z ~= 0 and z or nil +end - return keyvalues, roads +--- Gets the roads table status for a set of tags +-- @param tags OSM tags +-- @return 1 if it belongs in the roads table, 0 otherwise +function roads(tags) + for k, v in pairs(tags) do + if roads_info[k] and roads_info[k][v] and roads_info[k][v].roads then + return 1 + end + end + return 0 end -- Filtering on nodes, ways, and relations @@ -311,7 +307,6 @@ end function filter_tags_way (keyvalues, numberofkeys) local filter = 0 -- Will object be filtered out? local polygon = 0 -- Will object be treated as polygon? - local roads = 0 -- Will object be added to planet_osm_roads? -- Filter out objects that are filtered out by filter_tags_generic filter, keyvalues = filter_tags_generic(keyvalues, numberofkeys) @@ -321,17 +316,16 @@ function filter_tags_way (keyvalues, numberofkeys) polygon = haspolygontags(keyvalues) - -- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads - keyvalues, roads = add_z_order(keyvalues) + -- Add z_order column + keyvalues.z_order = z_order(keyvalues) - return filter, keyvalues, polygon, roads + return filter, keyvalues, polygon, roads(keyvalues) end function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, membercount) local filter = 0 -- Will object be filtered out? local linestring = 0 -- Will object be treated as linestring? local polygon = 0 -- Will object be treated as polygon? - local roads = 0 -- Will object be added to planet_osm_roads? local membersuperseded = {} for i = 1, membercount do membersuperseded[i] = 0 -- Will member be ignored when handling areas? @@ -377,10 +371,10 @@ function filter_tags_relation_member (keyvalues, keyvaluemembers, roles, memberc end end - -- Add z_order key/value combination and determine if the object should also be added to planet_osm_roads - local keyvalues, roads = add_z_order(keyvalues) + -- Add z_order column + keyvalues.z_order = z_order(keyvalues) - return filter, keyvalues, membersuperseded, linestring, polygon, roads + return filter, keyvalues, membersuperseded, linestring, polygon, roads(keyvalues) end -- Check if an object with given tags should be treated as polygon From 4499350d2673770abf7e16a3a1a5dd6cdf440264 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Wed, 15 Jun 2016 18:05:44 -0700 Subject: [PATCH 23/25] Add testing framework --- scripts/lua/README.md | 5 +++++ scripts/lua/openstreetmap-carto.lua | 1 + scripts/lua/test.lua | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 scripts/lua/README.md create mode 120000 scripts/lua/openstreetmap-carto.lua create mode 100644 scripts/lua/test.lua diff --git a/scripts/lua/README.md b/scripts/lua/README.md new file mode 100644 index 0000000000..b5c3a4ef4e --- /dev/null +++ b/scripts/lua/README.md @@ -0,0 +1,5 @@ +# Lua helper scripts # + +These scripts are for developing, testing, and profiling the [Lua tag transform](../../openstreetmap-carto.lua). There is a symlink to the transform in this directory so it can be `require`d by other files. + +They are not necessary for map rendering or most development. diff --git a/scripts/lua/openstreetmap-carto.lua b/scripts/lua/openstreetmap-carto.lua new file mode 120000 index 0000000000..ba19fbe902 --- /dev/null +++ b/scripts/lua/openstreetmap-carto.lua @@ -0,0 +1 @@ +../../openstreetmap-carto.lua \ No newline at end of file diff --git a/scripts/lua/test.lua b/scripts/lua/test.lua new file mode 100644 index 0000000000..a38808b479 --- /dev/null +++ b/scripts/lua/test.lua @@ -0,0 +1,21 @@ +--[[ +This file is part of OpenStreetMap Carto and used for validating the Lua tag transforms. + +Run it with lua test.lua +]] + +require ("openstreetmap-carto") + +print("TESTING: z_order") + +assert(z_order({}) == nil, "test failed: no tags") +assert(z_order({foo="bar"}) == nil, "test failed: other tags") +assert(z_order({highway="motorway"}) == 380 , "test failed: motorway") +assert(z_order({highway="motorway", railway="rail"}) == 440 , "test failed: motorway + rail") + +print("TESTING: roads") +assert(roads({}) == 0, "test failed: no tags") +assert(roads({foo="bar"}) == 0, "test failed: other tags") +assert(roads({highway="motorway"}) == 1, "test failed: motorway") +assert(roads({railway="rail"}) == 1, "test failed: rail") +assert(roads({highway="residential", railway="rail"}) == 1, "test failed: rail") From f2030f25f7979aa4e90c4c82925e0e9e44ebe2e0 Mon Sep 17 00:00:00 2001 From: math1985 Date: Sun, 19 Jun 2016 00:28:14 +0200 Subject: [PATCH 24/25] Use spaces, not tabs --- openstreetmap-carto.lua | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/openstreetmap-carto.lua b/openstreetmap-carto.lua index df1d51606f..1ee1d4b36f 100644 --- a/openstreetmap-carto.lua +++ b/openstreetmap-carto.lua @@ -184,29 +184,29 @@ local roads_info = { secondary_link = {z = 210, roads = true}, tertiary_link = {z = 200, roads = false}, service = {z = 150, roads = false}, - track = {z = 110, roads = false}, - path = {z = 100, roads = false}, - footway = {z = 100, roads = false}, - bridleway = {z = 100, roads = false}, - cycleway = {z = 100, roads = false}, - steps = {z = 90, roads = false}, - platform = {z = 90, roads = false}, + track = {z = 110, roads = false}, + path = {z = 100, roads = false}, + footway = {z = 100, roads = false}, + bridleway = {z = 100, roads = false}, + cycleway = {z = 100, roads = false}, + steps = {z = 90, roads = false}, + platform = {z = 90, roads = false}, construction = {z = 10, roads = false} }, railway = { - rail = {z = 440, roads = true}, - subway = {z = 420, roads = true}, - narrow_gauge = {z = 420, roads = true}, - light_rail = {z = 420, roads = true}, - preserved = {z = 420, roads = true}, - funicular = {z = 420, roads = true}, - monorail = {z = 420, roads = true}, - miniature = {z = 420, roads = true}, - turntable = {z = 420, roads = true}, - tram = {z = 410, roads = true}, - disused = {z = 400, roads = true}, - construction = {z = 400, roads = true}, - platform = {z = 90, roads = true}, + rail = {z = 440, roads = true}, + subway = {z = 420, roads = true}, + narrow_gauge = {z = 420, roads = true}, + light_rail = {z = 420, roads = true}, + preserved = {z = 420, roads = true}, + funicular = {z = 420, roads = true}, + monorail = {z = 420, roads = true}, + miniature = {z = 420, roads = true}, + turntable = {z = 420, roads = true}, + tram = {z = 410, roads = true}, + disused = {z = 400, roads = true}, + construction = {z = 400, roads = true}, + platform = {z = 90, roads = true}, }, aeroway = { runway = {z = 60, roads = false}, From 2ec88f33a9b5822d77430e1ac6a7827f5edbba90 Mon Sep 17 00:00:00 2001 From: math1985 Date: Mon, 27 Jun 2016 01:09:19 +0200 Subject: [PATCH 25/25] Regenerate .mml --- project.mml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/project.mml b/project.mml index 90818c191d..9ea9e051a2 100644 --- a/project.mml +++ b/project.mml @@ -100,7 +100,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, name, way_pixels,\n COALESCE(wetland, landuse, \"natural\") AS feature\n FROM (SELECT\n way, COALESCE(name, '') AS name,\n ('landuse_' || (CASE WHEN landuse IN ('forest', 'military') THEN landuse ELSE NULL END)) AS landuse,\n ('natural_' || (CASE WHEN \"natural\" IN ('wood', 'sand', 'scree', 'shingle', 'bare_rock') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('wetland_' || (CASE WHEN \"natural\" IN ('wetland', 'mud') THEN (CASE WHEN \"natural\" IN ('mud') THEN \"natural\" ELSE tags->'wetland' END) ELSE NULL END)) AS wetland,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE (landuse IN ('forest', 'military')\n OR \"natural\" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock'))\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n AND building IS NULL\n ORDER BY CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END, way_area DESC\n ) AS features\n) AS landcover_low_zoom", + "table": "(SELECT\n way, name, way_pixels,\n COALESCE(wetland, landuse, \"natural\") AS feature\n FROM (SELECT\n way, COALESCE(name, '') AS name,\n ('landuse_' || (CASE WHEN landuse IN ('forest', 'military') THEN landuse ELSE NULL END)) AS landuse,\n ('natural_' || (CASE WHEN \"natural\" IN ('wood', 'sand', 'scree', 'shingle', 'bare_rock') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('wetland_' || (CASE WHEN \"natural\" IN ('wetland', 'mud') THEN (CASE WHEN \"natural\" IN ('mud') THEN \"natural\" ELSE tags->'wetland' END) ELSE NULL END)) AS wetland,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE (landuse IN ('forest', 'military')\n OR \"natural\" IN ('wood', 'wetland', 'mud', 'sand', 'scree', 'shingle', 'bare_rock'))\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n AND building IS NULL\n ORDER BY COALESCE(layer,0), way_area DESC\n ) AS features\n) AS landcover_low_zoom", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -126,7 +126,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, name, religion, way_pixels,\n COALESCE(aeroway, amenity, wetland, power, landuse, leisure, military, \"natural\", tourism, highway, railway) AS feature\n FROM (SELECT\n way, COALESCE(name, '') AS name,\n ('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway ELSE NULL END)) AS aeroway,\n ('amenity_' || (CASE WHEN amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', \n 'hospital', 'kindergarten', 'grave_yard', 'prison', 'place_of_worship', 'clinic') \n THEN amenity ELSE NULL END)) AS amenity,\n ('landuse_' || (CASE WHEN landuse IN ('quarry', 'vineyard', 'orchard', 'cemetery', 'residential', 'garages', 'meadow', 'grass', \n 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'greenhouse_horticulture', \n 'recreation_ground', 'village_green', 'retail', 'industrial', 'railway', 'commercial', \n 'brownfield', 'landfill', 'construction') THEN landuse ELSE NULL END)) AS landuse,\n ('leisure_' || (CASE WHEN leisure IN ('swimming_pool', 'playground', 'park', 'recreation_ground', 'common', 'garden', \n 'golf_course', 'miniature_golf', 'picnic_table', 'sports_centre', 'stadium', 'pitch', \n 'track') THEN leisure ELSE NULL END)) AS leisure,\n ('military_' || (CASE WHEN military IN ('danger_area') THEN military ELSE NULL END)) AS military,\n ('natural_' || (CASE WHEN \"natural\" IN ('beach', 'shoal', 'heath', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('wetland_' || (CASE WHEN \"natural\" IN ('wetland', 'marsh', 'mud') THEN (CASE WHEN \"natural\" IN ('marsh', 'mud') THEN \"natural\" ELSE tags->'wetland' END) ELSE NULL END)) AS wetland,\n ('power_' || (CASE WHEN power IN ('station', 'sub_station', 'substation', 'generator') THEN power ELSE NULL END)) AS power,\n ('tourism_' || (CASE WHEN tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site') THEN tourism ELSE NULL END)) AS tourism,\n ('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway ELSE NULL END)) AS highway,\n ('railway_' || (CASE WHEN railway = 'station' THEN railway ELSE NULL END)) AS railway,\n CASE WHEN religion IN ('christian', 'jewish') THEN religion ELSE 'INT-generic'::text END AS religion,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE (landuse IS NOT NULL\n OR leisure IS NOT NULL\n OR aeroway IN ('apron', 'aerodrome')\n OR amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', 'hospital', 'kindergarten', \n 'grave_yard', 'place_of_worship', 'prison', 'clinic')\n OR military IN ('danger_area')\n OR \"natural\" IN ('beach', 'shoal', 'heath', 'mud', 'marsh', 'wetland', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub')\n OR power IN ('station', 'sub_station', 'substation', 'generator')\n OR tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site')\n OR highway IN ('services', 'rest_area')\n OR railway = 'station')\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END, way_area DESC\n ) AS landcover\n) AS features", + "table": "(SELECT\n way, name, religion, way_pixels,\n COALESCE(aeroway, amenity, wetland, power, landuse, leisure, military, \"natural\", tourism, highway, railway) AS feature\n FROM (SELECT\n way, COALESCE(name, '') AS name,\n ('aeroway_' || (CASE WHEN aeroway IN ('apron', 'aerodrome') THEN aeroway ELSE NULL END)) AS aeroway,\n ('amenity_' || (CASE WHEN amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', \n 'hospital', 'kindergarten', 'grave_yard', 'prison', 'place_of_worship', 'clinic') \n THEN amenity ELSE NULL END)) AS amenity,\n ('landuse_' || (CASE WHEN landuse IN ('quarry', 'vineyard', 'orchard', 'cemetery', 'residential', 'garages', 'meadow', 'grass', \n 'allotments', 'forest', 'farmyard', 'farm', 'farmland', 'greenhouse_horticulture', \n 'recreation_ground', 'village_green', 'retail', 'industrial', 'railway', 'commercial', \n 'brownfield', 'landfill', 'construction') THEN landuse ELSE NULL END)) AS landuse,\n ('leisure_' || (CASE WHEN leisure IN ('swimming_pool', 'playground', 'park', 'recreation_ground', 'common', 'garden', \n 'golf_course', 'miniature_golf', 'picnic_table', 'sports_centre', 'stadium', 'pitch', \n 'track') THEN leisure ELSE NULL END)) AS leisure,\n ('military_' || (CASE WHEN military IN ('danger_area') THEN military ELSE NULL END)) AS military,\n ('natural_' || (CASE WHEN \"natural\" IN ('beach', 'shoal', 'heath', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub') THEN \"natural\" ELSE NULL END)) AS \"natural\",\n ('wetland_' || (CASE WHEN \"natural\" IN ('wetland', 'marsh', 'mud') THEN (CASE WHEN \"natural\" IN ('marsh', 'mud') THEN \"natural\" ELSE tags->'wetland' END) ELSE NULL END)) AS wetland,\n ('power_' || (CASE WHEN power IN ('station', 'sub_station', 'substation', 'generator') THEN power ELSE NULL END)) AS power,\n ('tourism_' || (CASE WHEN tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site') THEN tourism ELSE NULL END)) AS tourism,\n ('highway_' || (CASE WHEN highway IN ('services', 'rest_area') THEN highway ELSE NULL END)) AS highway,\n ('railway_' || (CASE WHEN railway = 'station' THEN railway ELSE NULL END)) AS railway,\n CASE WHEN religion IN ('christian', 'jewish') THEN religion ELSE 'INT-generic'::text END AS religion,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE (landuse IS NOT NULL\n OR leisure IS NOT NULL\n OR aeroway IN ('apron', 'aerodrome')\n OR amenity IN ('parking', 'bicycle_parking', 'motorcycle_parking', 'university', 'college', 'school', 'hospital', 'kindergarten', \n 'grave_yard', 'place_of_worship', 'prison', 'clinic')\n OR military IN ('danger_area')\n OR \"natural\" IN ('beach', 'shoal', 'heath', 'mud', 'marsh', 'wetland', 'grassland', 'wood', 'sand', 'scree', 'shingle', 'bare_rock', 'scrub')\n OR power IN ('station', 'sub_station', 'substation', 'generator')\n OR tourism IN ('attraction', 'camp_site', 'caravan_site', 'picnic_site')\n OR highway IN ('services', 'rest_area')\n OR railway = 'station')\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY COALESCE(layer,0), way_area DESC\n ) AS landcover\n) AS features", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -253,7 +253,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n \"natural\",\n waterway,\n landuse,\n name,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE\n (waterway IN ('dock', 'riverbank', 'canal')\n OR landuse IN ('reservoir', 'basin')\n OR \"natural\" IN ('water', 'glacier'))\n AND building IS NULL\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY z_order, way_area DESC\n) AS water_areas", + "table": "(SELECT\n way,\n \"natural\",\n waterway,\n landuse,\n name,\n way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels\n FROM planet_osm_polygon\n WHERE\n (waterway IN ('dock', 'riverbank', 'canal')\n OR landuse IN ('reservoir', 'basin')\n OR \"natural\" IN ('water', 'glacier'))\n AND building IS NULL\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY COALESCE(layer,0), way_area DESC\n) AS water_areas", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -279,7 +279,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, surface, \n COALESCE(\"natural\", CASE WHEN landuse = 'forest' THEN 'wood' ELSE NULL END) AS \"natural\",\n CASE WHEN \"natural\" IN ('marsh', 'mud') \n THEN \"natural\" \n ELSE CASE WHEN (\"natural\" = 'wetland' AND NOT tags ? 'wetland') \n THEN 'wetland' \n ELSE CASE WHEN (\"natural\" = 'wetland')\n THEN tags->'wetland'\n ELSE NULL\n END \n END\n END AS int_wetland\n FROM planet_osm_polygon\n WHERE (\"natural\" IN ('marsh', 'mud', 'wetland', 'wood', 'beach', 'shoal', 'reef') OR landuse = 'forest')\n AND building IS NULL\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY z_order, way_area DESC\n) AS landcover_area_symbols", + "table": "(SELECT\n way, surface, \n COALESCE(\"natural\", CASE WHEN landuse = 'forest' THEN 'wood' ELSE NULL END) AS \"natural\",\n CASE WHEN \"natural\" IN ('marsh', 'mud') \n THEN \"natural\" \n ELSE CASE WHEN (\"natural\" = 'wetland' AND NOT tags ? 'wetland') \n THEN 'wetland' \n ELSE CASE WHEN (\"natural\" = 'wetland')\n THEN tags->'wetland'\n ELSE NULL\n END \n END\n END AS int_wetland\n FROM planet_osm_polygon\n WHERE (\"natural\" IN ('marsh', 'mud', 'wetland', 'wood', 'beach', 'shoal', 'reef') OR landuse = 'forest')\n AND building IS NULL\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY COALESCE(layer,0), way_area DESC\n) AS landcover_area_symbols", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -327,7 +327,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way, waterway, name, tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel,\n 'no' AS bridge\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND (bridge IS NULL OR bridge NOT IN ('yes', 'aqueduct'))\n ORDER BY z_order\n) AS water_lines", + "table": "(SELECT\n way, waterway, name, tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel,\n 'no' AS bridge\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND (bridge IS NULL OR bridge NOT IN ('yes', 'aqueduct'))\n ORDER BY COALESCE(layer,0)\n) AS water_lines", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -535,7 +535,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n building\n FROM planet_osm_polygon\n WHERE building IS NOT NULL\n AND building != 'no'\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY z_order, way_area DESC\n) AS buildings", + "table": "(SELECT\n way,\n building\n FROM planet_osm_polygon\n WHERE building IS NOT NULL\n AND building != 'no'\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY COALESCE(layer,0), way_area DESC\n) AS buildings", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -561,7 +561,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n building,\n amenity,\n aeroway\n FROM planet_osm_polygon\n WHERE building IS NOT NULL\n AND building != 'no'\n AND (aeroway = 'terminal' OR amenity = 'place_of_worship')\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY z_order, way_area DESC)\nAS buildings_major", + "table": "(SELECT\n way,\n building,\n amenity,\n aeroway\n FROM planet_osm_polygon\n WHERE building IS NOT NULL\n AND building != 'no'\n AND (aeroway = 'terminal' OR amenity = 'place_of_worship')\n AND way_area > 0.01*!pixel_width!::real*!pixel_height!::real\n ORDER BY COALESCE(layer,0), way_area DESC)\nAS buildings_major", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -587,7 +587,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT way, (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,\n horse, foot, bicycle, tracktype, int_surface, access, construction,\n service, oneway, link, layernotnull\n FROM ( -- subselect that contains both roads and rail/aero\n SELECT\n way,\n ('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on\n horse,\n foot,\n bicycle,\n tracktype,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', \n 'grass_paver', 'gravel', 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', \n 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface,\n CASE WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE\n WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text\n ELSE 'INT-normal'::text\n END AS service,\n CASE\n WHEN oneway IN ('yes', '-1') THEN oneway\n WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'\n ELSE NULL\n END AS oneway,\n CASE\n WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes'\n ELSE 'no'\n END AS link,\n CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes')\n AND highway IS NOT NULL -- end of road select\n UNION ALL\n SELECT\n way,\n COALESCE(\n ('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text \n WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END)),\n ('aeroway_' || aeroway)\n ) AS feature,\n horse,\n foot,\n bicycle,\n tracktype,\n 'null',\n CASE\n WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,\n NULL AS oneway,\n 'no' AS link,\n CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes')\n AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select\n ) AS features\n JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.\n ('railway_rail', 440),\n ('railway_INT-preserved-ssy', 430),\n ('railway_INT-spur-siding-yard', 430),\n ('railway_subway', 420),\n ('railway_narrow_gauge', 420),\n ('railway_light_rail', 420),\n ('railway_preserved', 420),\n ('railway_funicular', 420),\n ('railway_monorail', 420),\n ('railway_miniature', 420),\n ('railway_turntable', 420),\n ('railway_tram', 410),\n ('railway_tram-service', 405),\n ('railway_disused', 400),\n ('railway_construction', 400),\n ('highway_motorway', 380),\n ('highway_trunk', 370),\n ('highway_primary', 360),\n ('highway_secondary', 350),\n ('highway_tertiary', 340),\n ('highway_residential', 330),\n ('highway_unclassified', 330),\n ('highway_road', 330),\n ('highway_living_street', 320),\n ('highway_pedestrian', 310),\n ('highway_raceway', 300),\n ('highway_motorway_link', 240),\n ('highway_trunk_link', 230),\n ('highway_primary_link', 220),\n ('highway_secondary_link', 210),\n ('highway_tertiary_link', 200),\n ('highway_service', 150),\n ('highway_track', 110),\n ('highway_path', 100),\n ('highway_footway', 100),\n ('highway_bridleway', 100),\n ('highway_cycleway', 100),\n ('highway_steps', 100),\n ('highway_platform', 90),\n ('railway_platform', 90),\n ('aeroway_runway', 60),\n ('aeroway_taxiway', 50),\n ('highway_construction', 10)\n ) AS ordertable (feature, prio)\n USING (feature)\n ORDER BY\n layernotnull,\n prio,\n CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,\n CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END\n) AS tunnels", + "table": "(SELECT way, (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,\n horse, foot, bicycle, tracktype, int_surface, access, construction,\n service, oneway, link, layernotnull\n FROM ( -- subselect that contains both roads and rail/aero\n SELECT\n way,\n ('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on\n horse,\n foot,\n bicycle,\n tracktype,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', \n 'grass_paver', 'gravel', 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', \n 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface,\n CASE WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE\n WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text\n ELSE 'INT-normal'::text\n END AS service,\n CASE\n WHEN oneway IN ('yes', '-1') THEN oneway\n WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'\n ELSE NULL\n END AS oneway,\n CASE\n WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes'\n ELSE 'no'\n END AS link,\n COALESCE(layer,0) AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes')\n AND highway IS NOT NULL -- end of road select\n UNION ALL\n SELECT\n way,\n COALESCE(\n ('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text \n WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END)),\n ('aeroway_' || aeroway)\n ) AS feature,\n horse,\n foot,\n bicycle,\n tracktype,\n 'null',\n CASE\n WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,\n NULL AS oneway,\n 'no' AS link,\n COALESCE(layer,0) AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes')\n AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select\n ) AS features\n JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.\n ('railway_rail', 440),\n ('railway_INT-preserved-ssy', 430),\n ('railway_INT-spur-siding-yard', 430),\n ('railway_subway', 420),\n ('railway_narrow_gauge', 420),\n ('railway_light_rail', 420),\n ('railway_preserved', 420),\n ('railway_funicular', 420),\n ('railway_monorail', 420),\n ('railway_miniature', 420),\n ('railway_turntable', 420),\n ('railway_tram', 410),\n ('railway_tram-service', 405),\n ('railway_disused', 400),\n ('railway_construction', 400),\n ('highway_motorway', 380),\n ('highway_trunk', 370),\n ('highway_primary', 360),\n ('highway_secondary', 350),\n ('highway_tertiary', 340),\n ('highway_residential', 330),\n ('highway_unclassified', 330),\n ('highway_road', 330),\n ('highway_living_street', 320),\n ('highway_pedestrian', 310),\n ('highway_raceway', 300),\n ('highway_motorway_link', 240),\n ('highway_trunk_link', 230),\n ('highway_primary_link', 220),\n ('highway_secondary_link', 210),\n ('highway_tertiary_link', 200),\n ('highway_service', 150),\n ('highway_track', 110),\n ('highway_path', 100),\n ('highway_footway', 100),\n ('highway_bridleway', 100),\n ('highway_cycleway', 100),\n ('highway_steps', 100),\n ('highway_platform', 90),\n ('railway_platform', 90),\n ('aeroway_runway', 60),\n ('aeroway_taxiway', 50),\n ('highway_construction', 10)\n ) AS ordertable (feature, prio)\n USING (feature)\n ORDER BY\n layernotnull,\n prio,\n CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,\n CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END\n) AS tunnels", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -796,7 +796,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n COALESCE((\n 'highway_' || (CASE WHEN highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'cycleway', 'track', 'path', 'platform') THEN highway ELSE NULL END)),\n ('railway_' || (CASE WHEN railway IN ('platform') THEN railway ELSE NULL END))\n ) AS feature\n FROM planet_osm_polygon\n WHERE highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'track', 'path', 'platform')\n OR railway IN ('platform')\n ORDER BY z_order, way_area DESC\n) AS highway_area_casing", + "table": "(SELECT\n way,\n COALESCE((\n 'highway_' || (CASE WHEN highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'cycleway', 'track', 'path', 'platform') THEN highway ELSE NULL END)),\n ('railway_' || (CASE WHEN railway IN ('platform') THEN railway ELSE NULL END))\n ) AS feature\n FROM planet_osm_polygon\n WHERE highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'track', 'path', 'platform')\n OR railway IN ('platform')\n ORDER BY COALESCE(layer,0), way_area DESC\n) AS highway_area_casing", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -821,7 +821,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT way, (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,\n horse, foot, bicycle, tracktype, int_surface, access, construction,\n service, oneway, link, layernotnull\n FROM ( -- subselect that contains both roads and rail/aero\n SELECT\n way,\n ('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on\n horse,\n foot,\n bicycle,\n tracktype,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', \n 'grass_paver', 'gravel', 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', \n 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface,\n CASE WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE\n WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text\n ELSE 'INT-normal'::text\n END AS service,\n CASE\n WHEN oneway IN ('yes', '-1') THEN oneway\n WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'\n ELSE NULL\n END AS oneway,\n CASE\n WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes'\n ELSE 'no'\n END AS link,\n CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))\n AND (covered IS NULL OR NOT covered = 'yes')\n AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))\n AND highway IS NOT NULL -- end of road select\n UNION ALL\n SELECT\n way,\n COALESCE(\n ('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text \n WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END)),\n ('aeroway_' || aeroway)\n ) AS feature,\n horse,\n foot,\n bicycle,\n tracktype,\n 'null',\n CASE\n WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,\n NULL AS oneway,\n 'no' AS link,\n CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))\n AND (covered IS NULL OR NOT covered = 'yes')\n AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))\n AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select\n ) AS features\n JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.\n ('railway_rail', 440),\n ('railway_INT-preserved-ssy', 430),\n ('railway_INT-spur-siding-yard', 430),\n ('railway_subway', 420),\n ('railway_narrow_gauge', 420),\n ('railway_light_rail', 420),\n ('railway_preserved', 420),\n ('railway_funicular', 420),\n ('railway_monorail', 420),\n ('railway_miniature', 420),\n ('railway_turntable', 420),\n ('railway_tram', 410),\n ('railway_tram-service', 405),\n ('railway_disused', 400),\n ('railway_construction', 400),\n ('highway_motorway', 380),\n ('highway_trunk', 370),\n ('highway_primary', 360),\n ('highway_secondary', 350),\n ('highway_tertiary', 340),\n ('highway_residential', 330),\n ('highway_unclassified', 330),\n ('highway_road', 330),\n ('highway_living_street', 320),\n ('highway_pedestrian', 310),\n ('highway_raceway', 300),\n ('highway_motorway_link', 240),\n ('highway_trunk_link', 230),\n ('highway_primary_link', 220),\n ('highway_secondary_link', 210),\n ('highway_tertiary_link', 200),\n ('highway_service', 150),\n ('highway_track', 110),\n ('highway_path', 100),\n ('highway_footway', 100),\n ('highway_bridleway', 100),\n ('highway_cycleway', 100),\n ('highway_steps', 100),\n ('highway_platform', 90),\n ('railway_platform', 90),\n ('aeroway_runway', 60),\n ('aeroway_taxiway', 50),\n ('highway_construction', 10)\n ) AS ordertable (feature, prio)\n USING (feature)\n ORDER BY\n layernotnull,\n prio,\n CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,\n CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END\n) AS roads_casing", + "table": "(SELECT way, (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,\n horse, foot, bicycle, tracktype, int_surface, access, construction,\n service, oneway, link, layernotnull\n FROM ( -- subselect that contains both roads and rail/aero\n SELECT\n way,\n ('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on\n horse,\n foot,\n bicycle,\n tracktype,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', \n 'grass_paver', 'gravel', 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', \n 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface,\n CASE WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE\n WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text\n ELSE 'INT-normal'::text\n END AS service,\n CASE\n WHEN oneway IN ('yes', '-1') THEN oneway\n WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'\n ELSE NULL\n END AS oneway,\n CASE\n WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes'\n ELSE 'no'\n END AS link,\n COALESCE(layer,0) AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))\n AND (covered IS NULL OR NOT covered = 'yes')\n AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))\n AND highway IS NOT NULL -- end of road select\n UNION ALL\n SELECT\n way,\n COALESCE(\n ('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text \n WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END)),\n ('aeroway_' || aeroway)\n ) AS feature,\n horse,\n foot,\n bicycle,\n tracktype,\n 'null',\n CASE\n WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,\n NULL AS oneway,\n 'no' AS link,\n COALESCE(layer,0) AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))\n AND (covered IS NULL OR NOT covered = 'yes')\n AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))\n AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select\n ) AS features\n JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.\n ('railway_rail', 440),\n ('railway_INT-preserved-ssy', 430),\n ('railway_INT-spur-siding-yard', 430),\n ('railway_subway', 420),\n ('railway_narrow_gauge', 420),\n ('railway_light_rail', 420),\n ('railway_preserved', 420),\n ('railway_funicular', 420),\n ('railway_monorail', 420),\n ('railway_miniature', 420),\n ('railway_turntable', 420),\n ('railway_tram', 410),\n ('railway_tram-service', 405),\n ('railway_disused', 400),\n ('railway_construction', 400),\n ('highway_motorway', 380),\n ('highway_trunk', 370),\n ('highway_primary', 360),\n ('highway_secondary', 350),\n ('highway_tertiary', 340),\n ('highway_residential', 330),\n ('highway_unclassified', 330),\n ('highway_road', 330),\n ('highway_living_street', 320),\n ('highway_pedestrian', 310),\n ('highway_raceway', 300),\n ('highway_motorway_link', 240),\n ('highway_trunk_link', 230),\n ('highway_primary_link', 220),\n ('highway_secondary_link', 210),\n ('highway_tertiary_link', 200),\n ('highway_service', 150),\n ('highway_track', 110),\n ('highway_path', 100),\n ('highway_footway', 100),\n ('highway_bridleway', 100),\n ('highway_cycleway', 100),\n ('highway_steps', 100),\n ('highway_platform', 90),\n ('railway_platform', 90),\n ('aeroway_runway', 60),\n ('aeroway_taxiway', 50),\n ('highway_construction', 10)\n ) AS ordertable (feature, prio)\n USING (feature)\n ORDER BY\n layernotnull,\n prio,\n CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,\n CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END\n) AS roads_casing", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -847,7 +847,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n COALESCE(\n ('highway_' || (CASE WHEN highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'cycleway', 'living_street', \n 'track', 'path', 'platform', 'services') THEN highway ELSE NULL END)),\n ('railway_' || (CASE WHEN railway IN ('platform') THEN railway ELSE NULL END)),\n (('aeroway_' || CASE WHEN aeroway IN ('runway', 'taxiway', 'helipad') THEN aeroway ELSE NULL END))\n ) AS feature\n FROM planet_osm_polygon\n WHERE highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'living_street', 'track', 'path', 'platform', 'services')\n OR railway IN ('platform')\n OR aeroway IN ('runway', 'taxiway', 'helipad')\n ORDER BY z_order, way_area desc\n) AS highway_area_fill", + "table": "(SELECT\n way,\n COALESCE(\n ('highway_' || (CASE WHEN highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'cycleway', 'living_street', \n 'track', 'path', 'platform', 'services') THEN highway ELSE NULL END)),\n ('railway_' || (CASE WHEN railway IN ('platform') THEN railway ELSE NULL END)),\n (('aeroway_' || CASE WHEN aeroway IN ('runway', 'taxiway', 'helipad') THEN aeroway ELSE NULL END))\n ) AS feature\n FROM planet_osm_polygon\n WHERE highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'living_street', 'track', 'path', 'platform', 'services')\n OR railway IN ('platform')\n OR aeroway IN ('runway', 'taxiway', 'helipad')\n ORDER BY COALESCE(layer,0), way_area desc\n) AS highway_area_fill", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -873,7 +873,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT way, (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,\n horse, foot, bicycle, tracktype, int_surface, access, construction,\n service, oneway, link, layernotnull\n FROM ( -- subselect that contains both roads and rail/aero\n SELECT\n way,\n ('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on\n horse,\n foot,\n bicycle,\n tracktype,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', \n 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', \n 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface,\n CASE WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE\n WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text\n ELSE 'INT-normal'::text\n END AS service,\n CASE\n WHEN oneway IN ('yes', '-1') THEN oneway\n WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'\n ELSE NULL\n END AS oneway,\n CASE\n WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes'\n ELSE 'no'\n END AS link,\n CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))\n AND (covered IS NULL OR NOT covered = 'yes')\n AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))\n AND highway IS NOT NULL -- end of road select\n UNION ALL\n SELECT\n way,\n COALESCE(\n ('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text \n WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END)),\n ('aeroway_' || aeroway)\n ) AS feature,\n horse,\n foot,\n bicycle,\n tracktype,\n 'null',\n CASE\n WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,\n NULL AS oneway,\n 'no' AS link,\n CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))\n AND (covered IS NULL OR NOT covered = 'yes')\n AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))\n AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select\n ) AS features\n JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.\n ('railway_rail', 440),\n ('railway_INT-preserved-ssy', 430),\n ('railway_INT-spur-siding-yard', 430),\n ('railway_subway', 420),\n ('railway_narrow_gauge', 420),\n ('railway_light_rail', 420),\n ('railway_preserved', 420),\n ('railway_funicular', 420),\n ('railway_monorail', 420),\n ('railway_miniature', 420),\n ('railway_turntable', 420),\n ('railway_tram', 410),\n ('railway_tram-service', 405),\n ('railway_disused', 400),\n ('railway_construction', 400),\n ('highway_motorway', 380),\n ('highway_trunk', 370),\n ('highway_primary', 360),\n ('highway_secondary', 350),\n ('highway_tertiary', 340),\n ('highway_residential', 330),\n ('highway_unclassified', 330),\n ('highway_road', 330),\n ('highway_living_street', 320),\n ('highway_pedestrian', 310),\n ('highway_raceway', 300),\n ('highway_motorway_link', 240),\n ('highway_trunk_link', 230),\n ('highway_primary_link', 220),\n ('highway_secondary_link', 210),\n ('highway_tertiary_link', 200),\n ('highway_service', 150),\n ('highway_track', 110),\n ('highway_path', 100),\n ('highway_footway', 100),\n ('highway_bridleway', 100),\n ('highway_cycleway', 100),\n ('highway_steps', 100),\n ('highway_platform', 90),\n ('railway_platform', 90),\n ('aeroway_runway', 60),\n ('aeroway_taxiway', 50),\n ('highway_construction', 10)\n ) AS ordertable (feature, prio)\n USING (feature)\n ORDER BY\n layernotnull,\n prio,\n CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,\n CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END\n) AS roads_fill", + "table": "(SELECT way, (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,\n horse, foot, bicycle, tracktype, int_surface, access, construction,\n service, oneway, link, layernotnull\n FROM ( -- subselect that contains both roads and rail/aero\n SELECT\n way,\n ('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on\n horse,\n foot,\n bicycle,\n tracktype,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', \n 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', \n 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface,\n CASE WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE\n WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text\n ELSE 'INT-normal'::text\n END AS service,\n CASE\n WHEN oneway IN ('yes', '-1') THEN oneway\n WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'\n ELSE NULL\n END AS oneway,\n CASE\n WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes'\n ELSE 'no'\n END AS link,\n COALESCE(layer,0) AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))\n AND (covered IS NULL OR NOT covered = 'yes')\n AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))\n AND highway IS NOT NULL -- end of road select\n UNION ALL\n SELECT\n way,\n COALESCE(\n ('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text \n WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END)),\n ('aeroway_' || aeroway)\n ) AS feature,\n horse,\n foot,\n bicycle,\n tracktype,\n 'null',\n CASE\n WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,\n NULL AS oneway,\n 'no' AS link,\n COALESCE(layer,0) AS layernotnull\n FROM planet_osm_line\n WHERE (tunnel IS NULL OR NOT tunnel IN ('yes', 'building_passage'))\n AND (covered IS NULL OR NOT covered = 'yes')\n AND (bridge IS NULL OR NOT bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct'))\n AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select\n ) AS features\n JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.\n ('railway_rail', 440),\n ('railway_INT-preserved-ssy', 430),\n ('railway_INT-spur-siding-yard', 430),\n ('railway_subway', 420),\n ('railway_narrow_gauge', 420),\n ('railway_light_rail', 420),\n ('railway_preserved', 420),\n ('railway_funicular', 420),\n ('railway_monorail', 420),\n ('railway_miniature', 420),\n ('railway_turntable', 420),\n ('railway_tram', 410),\n ('railway_tram-service', 405),\n ('railway_disused', 400),\n ('railway_construction', 400),\n ('highway_motorway', 380),\n ('highway_trunk', 370),\n ('highway_primary', 360),\n ('highway_secondary', 350),\n ('highway_tertiary', 340),\n ('highway_residential', 330),\n ('highway_unclassified', 330),\n ('highway_road', 330),\n ('highway_living_street', 320),\n ('highway_pedestrian', 310),\n ('highway_raceway', 300),\n ('highway_motorway_link', 240),\n ('highway_trunk_link', 230),\n ('highway_primary_link', 220),\n ('highway_secondary_link', 210),\n ('highway_tertiary_link', 200),\n ('highway_service', 150),\n ('highway_track', 110),\n ('highway_path', 100),\n ('highway_footway', 100),\n ('highway_bridleway', 100),\n ('highway_cycleway', 100),\n ('highway_steps', 100),\n ('highway_platform', 90),\n ('railway_platform', 90),\n ('aeroway_runway', 60),\n ('aeroway_taxiway', 50),\n ('highway_construction', 10)\n ) AS ordertable (feature, prio)\n USING (feature)\n ORDER BY\n layernotnull,\n prio,\n CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,\n CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END\n) AS roads_fill", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -951,7 +951,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n COALESCE(\n ('highway_' || (CASE WHEN substr(highway, length(highway)-3, 4) = 'link' THEN substr(highway, 0, length(highway)-4) ELSE highway end)),\n ('railway_' || (CASE WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN railway IN ('rail', 'tram', 'light_rail', 'funicular', 'narrow_gauge') THEN railway ELSE NULL END))\n ) AS feature,\n CASE WHEN tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes' THEN 'yes' ELSE 'no' END AS int_tunnel,\n CASE WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', \n 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', \n 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface\n FROM planet_osm_roads\n WHERE highway IS NOT NULL\n OR (railway IS NOT NULL AND railway != 'preserved'\n AND (service IS NULL OR service NOT IN ('spur', 'siding', 'yard')))\n ORDER BY z_order\n) AS roads_low_zoom", + "table": "(SELECT\n way,\n COALESCE(\n ('highway_' || (CASE WHEN substr(highway, length(highway)-3, 4) = 'link' THEN substr(highway, 0, length(highway)-4) ELSE highway end)),\n ('railway_' || (CASE WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN railway IN ('rail', 'tram', 'light_rail', 'funicular', 'narrow_gauge') THEN railway ELSE NULL END))\n ) AS feature,\n CASE WHEN tunnel = 'yes' OR tunnel = 'building_passage' OR covered = 'yes' THEN 'yes' ELSE 'no' END AS int_tunnel,\n CASE WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes' ELSE 'no' END AS link,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'ground', \n 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', 'concrete:lanes', \n 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface\n FROM planet_osm_roads\n WHERE highway IS NOT NULL\n OR (railway IS NOT NULL AND railway != 'preserved'\n AND (service IS NULL OR service NOT IN ('spur', 'siding', 'yard')))\n ORDER BY COALESCE(layer,0)\n) AS roads_low_zoom", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -978,7 +978,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n waterway,\n name,\n tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel,\n 'yes' AS bridge\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND bridge IN ('yes', 'aqueduct')\n ORDER BY z_order\n) AS waterway_bridges", + "table": "(SELECT\n way,\n waterway,\n name,\n tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel,\n 'yes' AS bridge\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND bridge IN ('yes', 'aqueduct')\n ORDER BY COALESCE(layer,0)\n) AS waterway_bridges", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1004,7 +1004,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT way, (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,\n horse, foot, bicycle, tracktype, int_surface, access, construction,\n service, oneway, link, layernotnull\n FROM ( -- subselect that contains both roads and rail/aero\n SELECT\n way,\n ('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on\n horse,\n foot,\n bicycle,\n tracktype,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', \n 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', \n 'concrete:lanes', 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface,\n CASE WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE\n WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text\n ELSE 'INT-normal'::text\n END AS service,\n CASE\n WHEN oneway IN ('yes', '-1') THEN oneway\n WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'\n ELSE NULL\n END AS oneway,\n CASE\n WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes'\n ELSE 'no'\n END AS link,\n CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull\n FROM planet_osm_line\n WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct')\n AND highway IS NOT NULL -- end of road select\n UNION ALL\n SELECT\n way,\n COALESCE(\n ('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text \n WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END)),\n ('aeroway_' || aeroway)\n ) AS feature,\n horse,\n foot,\n bicycle,\n tracktype,\n 'null',\n CASE\n WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,\n NULL AS oneway,\n 'no' AS link,\n CASE WHEN layer~E'^-?\\\\d+$' AND length(layer)<10 THEN layer::integer ELSE 0 END AS layernotnull\n FROM planet_osm_line\n WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct')\n AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select\n ) AS features\n JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.\n ('railway_rail', 440),\n ('railway_INT-preserved-ssy', 430),\n ('railway_INT-spur-siding-yard', 430),\n ('railway_subway', 420),\n ('railway_narrow_gauge', 420),\n ('railway_light_rail', 420),\n ('railway_preserved', 420),\n ('railway_funicular', 420),\n ('railway_monorail', 420),\n ('railway_miniature', 420),\n ('railway_turntable', 420),\n ('railway_tram', 410),\n ('railway_tram-service', 405),\n ('railway_disused', 400),\n ('railway_construction', 400),\n ('highway_motorway', 380),\n ('highway_trunk', 370),\n ('highway_primary', 360),\n ('highway_secondary', 350),\n ('highway_tertiary', 340),\n ('highway_residential', 330),\n ('highway_unclassified', 330),\n ('highway_road', 330),\n ('highway_living_street', 320),\n ('highway_pedestrian', 310),\n ('highway_raceway', 300),\n ('highway_motorway_link', 240),\n ('highway_trunk_link', 230),\n ('highway_primary_link', 220),\n ('highway_secondary_link', 210),\n ('highway_tertiary_link', 200),\n ('highway_service', 150),\n ('highway_track', 110),\n ('highway_path', 100),\n ('highway_footway', 100),\n ('highway_bridleway', 100),\n ('highway_cycleway', 100),\n ('highway_steps', 100),\n ('highway_platform', 90),\n ('railway_platform', 90),\n ('aeroway_runway', 60),\n ('aeroway_taxiway', 50),\n ('highway_construction', 10)\n ) AS ordertable (feature, prio)\n USING (feature)\n ORDER BY\n layernotnull,\n prio,\n CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,\n CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END\n) AS bridges", + "table": "(SELECT way, (CASE WHEN substr(feature, length(feature)-3, 4) = 'link' THEN substr(feature, 0, length(feature)-4) ELSE feature END) AS feature,\n horse, foot, bicycle, tracktype, int_surface, access, construction,\n service, oneway, link, layernotnull\n FROM ( -- subselect that contains both roads and rail/aero\n SELECT\n way,\n ('highway_' || highway) AS feature, --only motorway to tertiary links are accepted later on\n horse,\n foot,\n bicycle,\n tracktype,\n CASE WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', \n 'ground', 'mud', 'pebblestone', 'salt', 'sand', 'woodchips', 'clay') THEN 'unpaved' ELSE \n CASE WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'cobblestone:flattened', 'sett', 'concrete', \n 'concrete:lanes', 'concrete:plates', 'paving_stones', 'metal', 'wood') THEN 'paved' \n ELSE null END END AS int_surface,\n CASE WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE\n WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text\n ELSE 'INT-normal'::text\n END AS service,\n CASE\n WHEN oneway IN ('yes', '-1') THEN oneway\n WHEN junction IN ('roundabout') AND (oneway IS NULL OR NOT oneway IN ('no', 'reversible')) THEN 'yes'\n ELSE NULL\n END AS oneway,\n CASE\n WHEN substr(highway, length(highway)-3, 4) = 'link' THEN 'yes'\n ELSE 'no'\n END AS link,\n COALESCE(layer,0) AS layernotnull\n FROM planet_osm_line\n WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct')\n AND highway IS NOT NULL -- end of road select\n UNION ALL\n SELECT\n way,\n COALESCE(\n ('railway_' || (CASE WHEN railway = 'preserved' AND service IN ('spur', 'siding', 'yard') THEN 'INT-preserved-ssy'::text \n WHEN (railway = 'rail' AND service IN ('spur', 'siding', 'yard')) THEN 'INT-spur-siding-yard' \n WHEN (railway = 'tram' AND service IN ('spur', 'siding', 'yard')) THEN 'tram-service' ELSE railway END)),\n ('aeroway_' || aeroway)\n ) AS feature,\n horse,\n foot,\n bicycle,\n tracktype,\n 'null',\n CASE\n WHEN access IN ('destination') THEN 'destination'::text\n WHEN access IN ('no', 'private') THEN 'no'::text\n ELSE NULL\n END AS access,\n construction,\n CASE WHEN service IN ('parking_aisle', 'drive-through', 'driveway') THEN 'INT-minor'::text ELSE 'INT-normal'::text END AS service,\n NULL AS oneway,\n 'no' AS link,\n COALESCE(layer,0) AS layernotnull\n FROM planet_osm_line\n WHERE bridge IN ('yes', 'boardwalk', 'cantilever', 'covered', 'low_water_crossing', 'movable', 'trestle', 'viaduct')\n AND (railway IS NOT NULL OR aeroway IS NOT NULL) -- end of rail/aero select\n ) AS features\n JOIN (VALUES -- this join is also putting a condition on what is selected. features not matching it do not make it into the results.\n ('railway_rail', 440),\n ('railway_INT-preserved-ssy', 430),\n ('railway_INT-spur-siding-yard', 430),\n ('railway_subway', 420),\n ('railway_narrow_gauge', 420),\n ('railway_light_rail', 420),\n ('railway_preserved', 420),\n ('railway_funicular', 420),\n ('railway_monorail', 420),\n ('railway_miniature', 420),\n ('railway_turntable', 420),\n ('railway_tram', 410),\n ('railway_tram-service', 405),\n ('railway_disused', 400),\n ('railway_construction', 400),\n ('highway_motorway', 380),\n ('highway_trunk', 370),\n ('highway_primary', 360),\n ('highway_secondary', 350),\n ('highway_tertiary', 340),\n ('highway_residential', 330),\n ('highway_unclassified', 330),\n ('highway_road', 330),\n ('highway_living_street', 320),\n ('highway_pedestrian', 310),\n ('highway_raceway', 300),\n ('highway_motorway_link', 240),\n ('highway_trunk_link', 230),\n ('highway_primary_link', 220),\n ('highway_secondary_link', 210),\n ('highway_tertiary_link', 200),\n ('highway_service', 150),\n ('highway_track', 110),\n ('highway_path', 100),\n ('highway_footway', 100),\n ('highway_bridleway', 100),\n ('highway_cycleway', 100),\n ('highway_steps', 100),\n ('highway_platform', 90),\n ('railway_platform', 90),\n ('aeroway_runway', 60),\n ('aeroway_taxiway', 50),\n ('highway_construction', 10)\n ) AS ordertable (feature, prio)\n USING (feature)\n ORDER BY\n layernotnull,\n prio,\n CASE WHEN access IN ('no', 'private') THEN 0 WHEN access IN ('destination') THEN 1 ELSE 2 END,\n CASE WHEN int_surface IN ('unpaved') THEN 0 ELSE 2 END\n) AS bridges", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -1893,7 +1893,7 @@ "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", "Datasource": { "extent": "-20037508,-20037508,20037508,20037508", - "table": "(SELECT\n way,\n waterway,\n lock,\n name,\n tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND (tunnel IS NULL or tunnel != 'culvert')\n AND name IS NOT NULL\n ORDER BY z_order\n) AS water_lines_text", + "table": "(SELECT\n way,\n waterway,\n lock,\n name,\n tags->'intermittent' as intermittent,\n CASE WHEN tunnel IN ('yes', 'culvert') THEN 'yes' ELSE 'no' END AS int_tunnel\n FROM planet_osm_line\n WHERE waterway IN ('river', 'canal', 'derelict_canal', 'stream', 'drain', 'ditch', 'wadi')\n AND (tunnel IS NULL or tunnel != 'culvert')\n AND name IS NOT NULL\n ORDER BY COALESCE(layer,0)\n) AS water_lines_text", "geometry_field": "way", "type": "postgis", "key_field": "",