Refactor ice into table function

pull/24/head
lukasmartinelli 2016-10-08 16:42:16 +02:00
rodzic 7cb3b4a43a
commit f8ddbfd1b0
2 zmienionych plików z 19 dodań i 16 usunięć

Wyświetl plik

@ -90,26 +90,13 @@ Layer:
max_size: 512
password: osm
port: 5432
srid: ''
table: |-
( SELECT geom, type
FROM (
SELECT ST_Simplify(geom, 80000) AS geom, type FROM ice_z0
WHERE z(!scale_denominator!) BETWEEN 0 AND 1
UNION ALL
SELECT * FROM ice_z2
WHERE z(!scale_denominator!) BETWEEN 2 AND 4
UNION ALL
SELECT * FROM ice_z5
WHERE z(!scale_denominator!) BETWEEN 5 AND 8
) AS ice
WHERE geom && !bbox!
) AS t
srid: 900913
table: (SELECT * FROM layer_ice(!bbox!, z(!scale_denominator!))) AS t
type: postgis
user: osm
description: Ice shelves
fields:
type: String
class: String
properties:
"buffer-size": 4
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

Wyświetl plik

@ -15,3 +15,19 @@ CREATE OR REPLACE VIEW ice_z5 AS (
UNION ALL
SELECT geom, 'ice_shelf' AS type FROM ne_10m_antarctic_ice_shelves_polys
);
CREATE OR REPLACE FUNCTION layer_ice(bbox geometry, zoom_level int)
RETURNS TABLE(geom geometry, class text) AS $$
WITH zoom_levels AS (
SELECT ST_Simplify(geom, 80000) AS geom, type FROM ice_z0
WHERE zoom_level BETWEEN 0 AND 1
UNION ALL
SELECT * FROM ice_z2
WHERE zoom_level BETWEEN 2 AND 4
UNION ALL
SELECT * FROM ice_z5
WHERE zoom_level BETWEEN 5 AND 8
)
SELECT geom, type::text AS class FROM zoom_levels
WHERE geom && bbox;
$$ LANGUAGE SQL IMMUTABLE;