Skip to content

Commit

Permalink
render aeroway=runway in real width
Browse files Browse the repository at this point in the history
  • Loading branch information
imagico committed Oct 2, 2015
1 parent 454c236 commit 52dd755
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 14 deletions.
4 changes: 2 additions & 2 deletions project.mml
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -860,7 +860,7 @@
85.05112877980659
],
"properties": {
"minzoom": 14
"minzoom": 11
},
"advanced": {}
},
Expand Down
68 changes: 56 additions & 12 deletions project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 52dd755

Please sign in to comment.