diff --git a/README.md b/README.md index f4ccb461..6031cc72 100644 --- a/README.md +++ b/README.md @@ -78,9 +78,10 @@ docker-compose run import-osm ### Work on Vector Tile Schema -Run the `db-schema` container each time you modify SQL code inside `./schema`. +Build and run the `db-schema` container each time you modify SQL code inside `./schema`. ```bash +docker-compose build db-schema docker-compose run db-schema ``` diff --git a/data.yml b/data.yml index adab45d6..5773808a 100644 --- a/data.yml +++ b/data.yml @@ -51,6 +51,43 @@ 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: building + Datasource: + dbname: osm + extent: -20037508.34,-20037508.34,20037508.34,20037508.34 + geometry_field: way + geometry_table: '' + host: db + key_field: '' + key_field_as_attribute: '' + max_size: 512 + password: osm + port: 5432 + srid: '' + table: |- + ( SELECT + osm_id, + way, + least(greatest(3, COALESCE(height, levels*3.66,5)),400)^.7 AS render_height + FROM ( + SELECT osm_id, ST_Simplify(way, 10) AS way, height, levels FROM building_z13 + WHERE z(!scale_denominator!) = 13 + UNION ALL + SELECT * FROM building_z14 + WHERE z(!scale_denominator!) >= 14 + ) AS water + WHERE way && !bbox! + ORDER BY render_height, ST_YMin(way) DESC + ) AS data + type: postgis + user: osm + description: Buildings + fields: + osm_id: Number + render_height: Number + 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 maxzoom: 14 minzoom: 0 name: OSM2VectorTiles v3.0 diff --git a/schema/create_schema.sh b/schema/create_schema.sh index 47420cfc..12cc35fe 100755 --- a/schema/create_schema.sh +++ b/schema/create_schema.sh @@ -17,6 +17,7 @@ function exec_psql_file() { function main() { exec_psql_file "$VT_UTIL_DIR/postgis-vt-util.sql" exec_psql_file "layers/water.sql" + exec_psql_file "layers/building.sql" } main diff --git a/schema/layers/building.sql b/schema/layers/building.sql new file mode 100644 index 00000000..ccdc5c93 --- /dev/null +++ b/schema/layers/building.sql @@ -0,0 +1,7 @@ +CREATE OR REPLACE VIEW building_z13 AS ( + SELECT osm_id, way, height, levels FROM buildings WHERE way_area > 1400 +); + +CREATE OR REPLACE VIEW building_z14 AS ( + SELECT osm_id, way, height, levels FROM buildings +);