diff --git a/data.yml b/data.yml index 1133be8..95a68b6 100644 --- a/data.yml +++ b/data.yml @@ -78,6 +78,29 @@ Layer: 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 + - id: rail + Datasource: + dbname: osm + extent: -20037508.34,-20037508.34,20037508.34,20037508.34 + geometry_field: geom + geometry_table: '' + host: db + key_field: '' + key_field_as_attribute: '' + max_size: 512 + password: osm + port: 5432 + srid: 900913 + table: (SELECT * FROM layer_rail(!bbox!, z(!scale_denominator!))) AS t + type: postgis + user: osm + description: Buildings + fields: + brunnel: 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 - id: ice Datasource: dbname: osm diff --git a/schema/create_schema.sh b/schema/create_schema.sh index f98136a..ba749f9 100755 --- a/schema/create_schema.sh +++ b/schema/create_schema.sh @@ -25,6 +25,7 @@ function main() { exec_psql_file "layers/place.sql" exec_psql_file "layers/country.sql" exec_psql_file "layers/state.sql" + exec_psql_file "layers/rail.sql" } main diff --git a/schema/layers/rail.sql b/schema/layers/rail.sql new file mode 100644 index 0000000..290e72e --- /dev/null +++ b/schema/layers/rail.sql @@ -0,0 +1,18 @@ +CREATE OR REPLACE VIEW rail_z13 AS ( + SELECT * FROM rail + WHERE class='rail' +); + +CREATE OR REPLACE VIEW rail_z14 AS ( + SELECT * FROM rail +); + +CREATE OR REPLACE FUNCTION layer_rail(bbox geometry, zoom_level int) +RETURNS TABLE(geom geometry, class text, brunnel text) AS $$ + SELECT way AS geom, class::text, brunnel::text FROM ( + SELECT * FROM rail_z13 WHERE zoom_level = 13 + UNION ALL + SELECT * FROM rail_z14 WHERE zoom_level >= 14 + ) AS zoom_levels + WHERE way && bbox; +$$ LANGUAGE SQL IMMUTABLE;