From 52dd7559484f35227d4adb443d924ba7de40ea04 Mon Sep 17 00:00:00 2001 From: imagico Date: Sat, 19 Sep 2015 22:00:54 +0200 Subject: [PATCH] render aeroway=runway in real width --- project.mml | 4 ++-- project.yaml | 68 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/project.mml b/project.mml index 4366638b1c..4e73f3c3ea 100644 --- a/project.mml +++ b/project.mml @@ -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, feature\n FROM (\n SELECT -- features mapped as polygons\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 ('taxiway', 'helipad') THEN aeroway ELSE NULL END))\n ) AS feature,\n z_order, way_area 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 ('taxiway', 'helipad'))\n AND way && !bbox!\n UNION ALL\n SELECT -- aeroway lines, converted to areas\n way, feature, z_order, ST_Area(way) AS way_area\n FROM\n (SELECT \n ST_Transform(\n ST_Buffer(\n ST_Transform( -- Use a projection that allows accurate buffering\n way,\n _ST_BestSRID(ST_Transform(way, 4326)::geography) -- Find the SRID to use\n ),\n 0.5 * CASE -- Buffer by the half-width\n WHEN width ~ '^\\d{1,3}(\\.\\d+)?$' -- Validate the width tag\n THEN LEAST(width::real, 150) -- Place a maximum on the width\n WHEN aeroway = 'runway' -- No valid width, so estimate from length if a runway\n THEN LEAST(GREATEST(ST_Length(ST_Transform(way,4326)::geography)/50,12.0),75.0)\n ELSE --taxiway\n 6\n END,\n 'endcap=flat join=round'\n ),\n ST_SRID(way)\n ) AS way,\n 'aeroway_' || aeroway AS feature,\n z_order FROM planet_osm_line\n WHERE aeroway IN ('runway', 'taxiway')\n AND way && -- extend bounding box by maximum buffer width\n CASE \n -- handle large bounding boxes that do not transform to 4326 or geography\n WHEN ST_Perimeter(!bbox!) > 3e+38 THEN !bbox!\n ELSE ST_Transform(\n ST_Expand(\n ST_Transform(\n !bbox!,\n _ST_BestSRID(ST_Transform(!bbox!,4326)::geography)),\n 150),\n ST_SRID(!bbox!))\n END\n ) AS p\n ) AS features\n ORDER BY z_order, way_area desc\n) AS highway_area_fill", "geometry_field": "way", "type": "postgis", "key_field": "", @@ -860,7 +860,7 @@ 85.05112877980659 ], "properties": { - "minzoom": 14 + "minzoom": 11 }, "advanced": {} }, diff --git a/project.yaml b/project.yaml index 6881924561..50420a4d86 100644 --- a/project.yaml +++ b/project.yaml @@ -913,21 +913,65 @@ Layer: <<: *osm2pgsql table: |- (SELECT - way, - COALESCE( - ('highway_' || (CASE WHEN highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'cycleway', 'living_street', - 'track', 'path', 'platform', 'services') THEN highway ELSE NULL END)), - ('railway_' || (CASE WHEN railway IN ('platform') THEN railway ELSE NULL END)), - (('aeroway_' || CASE WHEN aeroway IN ('runway', 'taxiway', 'helipad') THEN aeroway ELSE NULL END)) - ) AS feature - FROM planet_osm_polygon - WHERE highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'living_street', 'track', 'path', 'platform', 'services') - OR railway IN ('platform') - OR aeroway IN ('runway', 'taxiway', 'helipad') + way, feature + FROM ( + SELECT -- features mapped as polygons + way, + COALESCE( + ('highway_' || (CASE WHEN highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'cycleway', 'living_street', + 'track', 'path', 'platform', 'services') THEN highway ELSE NULL END)), + ('railway_' || (CASE WHEN railway IN ('platform') THEN railway ELSE NULL END)), + ('aeroway_' || (CASE WHEN aeroway IN ('taxiway', 'helipad') THEN aeroway ELSE NULL END)) + ) AS feature, + z_order, way_area FROM planet_osm_polygon + WHERE (highway IN ('residential', 'unclassified', 'pedestrian', 'service', 'footway', 'living_street', 'track', 'path', 'platform', 'services') + OR railway IN ('platform') + OR aeroway IN ('taxiway', 'helipad')) + AND way && !bbox! + UNION ALL + SELECT -- aeroway lines, converted to areas + way, feature, z_order, ST_Area(way) AS way_area + FROM + (SELECT + ST_Transform( + ST_Buffer( + ST_Transform( -- Use a projection that allows accurate buffering + way, + _ST_BestSRID(ST_Transform(way, 4326)::geography) -- Find the SRID to use + ), + 0.5 * CASE -- Buffer by the half-width + WHEN width ~ '^\d{1,3}(\.\d+)?$' -- Validate the width tag + THEN LEAST(width::real, 150) -- Place a maximum on the width + WHEN aeroway = 'runway' -- No valid width, so estimate from length if a runway + THEN LEAST(GREATEST(ST_Length(ST_Transform(way,4326)::geography)/50,12.0),75.0) + ELSE --taxiway + 6 + END, + 'endcap=flat join=round' + ), + ST_SRID(way) + ) AS way, + 'aeroway_' || aeroway AS feature, + z_order FROM planet_osm_line + WHERE aeroway IN ('runway', 'taxiway') + AND way && -- extend bounding box by maximum buffer width + CASE + -- handle large bounding boxes that do not transform to 4326 or geography + WHEN ST_Perimeter(!bbox!) > 3e+38 THEN !bbox! + ELSE ST_Transform( + ST_Expand( + ST_Transform( + !bbox!, + _ST_BestSRID(ST_Transform(!bbox!,4326)::geography)), + 150), + ST_SRID(!bbox!)) + END + ) AS p + ) AS features ORDER BY z_order, way_area desc ) AS highway_area_fill properties: - minzoom: 14 + minzoom: 11 advanced: {} - id: "roads-fill" name: "roads-fill"