This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
The following commit(s) were added to refs/heads/main by this push:
new 88f35b8c Add leisure and improve low level zooms (#800)
88f35b8c is described below
commit 88f35b8c2ffa32b9af9c0058cd96829c28636a03
Author: Bertil Chapuis <[email protected]>
AuthorDate: Thu Nov 9 22:38:55 2023 +0100
Add leisure and improve low level zooms (#800)
---
basemap/layers/landuse/prepare.sql | 2 +-
basemap/layers/landuse/tileset.js | 8 +-
basemap/layers/leisure/clean.sql | 71 +++++++++++
basemap/layers/leisure/index.sql | 26 ++++
basemap/layers/leisure/prepare.sql | 232 ++++++++++++++++++++++++++++++++++++
basemap/layers/leisure/simplify.sql | 98 +++++++++++++++
basemap/layers/leisure/tileset.js | 6 +
basemap/layers/railway/prepare.sql | 5 +-
basemap/workflow.js | 30 +++++
daylight/workflow.js | 30 +++++
10 files changed, 497 insertions(+), 11 deletions(-)
diff --git a/basemap/layers/landuse/prepare.sql
b/basemap/layers/landuse/prepare.sql
index f6684151..520c2fc8 100644
--- a/basemap/layers/landuse/prepare.sql
+++ b/basemap/layers/landuse/prepare.sql
@@ -19,7 +19,7 @@ SELECT
FROM osm_polygon
WHERE geom IS NOT NULL
AND st_area(geom) > 78270 / power(2, 12) * 100
- AND tags ->> 'landuse' IN ('residential', 'farmland', 'forest', 'meadow',
'orchard', 'vineyard', 'salt_pond', 'water');
+ AND tags ->> 'landuse' IN ('commercial', 'construction', 'industrial',
'residential', 'retail', 'farmland', 'forest', 'meadow',
'greenhouse_horticulture', 'meadow', 'orchard', 'plant_nursery','vineyard',
'basin', 'salt_pond', 'brownfield', 'cemetery', 'grass', 'greenfield',
'landfill', 'military', 'quarry', 'railway');
CREATE INDEX IF NOT EXISTS osm_landuse_filtered_geom_idx ON
osm_landuse_filtered USING GIST (geom);
CREATE INDEX IF NOT EXISTS osm_landuse_filtered_tags_idx ON
osm_landuse_filtered (landuse);
diff --git a/basemap/layers/landuse/tileset.js
b/basemap/layers/landuse/tileset.js
index 1f1bdb56..d39132da 100644
--- a/basemap/layers/landuse/tileset.js
+++ b/basemap/layers/landuse/tileset.js
@@ -20,15 +20,9 @@ export default {
queries: [
{
minzoom: 1,
- maxzoom: 8,
- sql:
- "SELECT id, tags, geom FROM osm_landuse_z$zoom WHERE tags ->>
'landuse' IN ('farmland', 'forest', 'meadow')",
- },
- {
- minzoom: 8,
maxzoom: 13,
sql:
- "SELECT id, tags, geom FROM osm_landuse_z$zoom WHERE tags ->>
'landuse' IN ('farmland', 'forest', 'meadow', 'residential', 'vineyard')",
+ "SELECT id, tags, geom FROM osm_landuse_z$zoom WHERE tags ?
'landuse'",
},
{
minzoom: 13,
diff --git a/basemap/layers/leisure/clean.sql b/basemap/layers/leisure/clean.sql
new file mode 100644
index 00000000..9b97c9dc
--- /dev/null
+++ b/basemap/layers/leisure/clean.sql
@@ -0,0 +1,71 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to you under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_filtered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_clustered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_grouped CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_buffered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_exploded CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure CASCADE;
+
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_xl_filtered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_xl_clustered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_xl_grouped CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_xl_buffered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_xl_exploded CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_xl CASCADE;
+
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_l_filtered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_l_clustered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_l_grouped CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_l_buffered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_l_exploded CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_l CASCADE;
+
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_m_filtered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_m_clustered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_m_grouped CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_m_buffered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_m_exploded CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_m CASCADE;
+
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_s_filtered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_s_clustered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_s_grouped CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_s_buffered CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_s_exploded CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_s CASCADE;
+
+DROP VIEW IF EXISTS osm_leisure_z20 CASCADE;
+DROP VIEW IF EXISTS osm_leisure_z19 CASCADE;
+DROP VIEW IF EXISTS osm_leisure_z18 CASCADE;
+DROP VIEW IF EXISTS osm_leisure_z17 CASCADE;
+DROP VIEW IF EXISTS osm_leisure_z16 CASCADE;
+DROP VIEW IF EXISTS osm_leisure_z15 CASCADE;
+DROP VIEW IF EXISTS osm_leisure_z14 CASCADE;
+DROP VIEW IF EXISTS osm_leisure_z13 CASCADE;
+
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z12 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z11 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z10 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z9 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z8 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z7 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z6 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z5 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z4 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z3 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z2 CASCADE;
+DROP MATERIALIZED VIEW IF EXISTS osm_leisure_z1 CASCADE;
+
diff --git a/basemap/layers/leisure/index.sql b/basemap/layers/leisure/index.sql
new file mode 100644
index 00000000..5efaf447
--- /dev/null
+++ b/basemap/layers/leisure/index.sql
@@ -0,0 +1,26 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to you under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z1_index ON osm_leisure_z1 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z2_index ON osm_leisure_z2 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z3_index ON osm_leisure_z3 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z4_index ON osm_leisure_z4 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z5_index ON osm_leisure_z5 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z6_index ON osm_leisure_z6 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z7_index ON osm_leisure_z7 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z8_index ON osm_leisure_z8 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z9_index ON osm_leisure_z9 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z10_index ON osm_leisure_z10 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z11_index ON osm_leisure_z11 USING
SPGIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_geom_z12_index ON osm_leisure_z12 USING
SPGIST (geom);
diff --git a/basemap/layers/leisure/prepare.sql
b/basemap/layers/leisure/prepare.sql
new file mode 100644
index 00000000..75b99c3f
--- /dev/null
+++ b/basemap/layers/leisure/prepare.sql
@@ -0,0 +1,232 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to you under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+CREATE MATERIALIZED VIEW osm_leisure_filtered AS
+SELECT
+ tags -> 'leisure' AS leisure,
+ st_simplifypreservetopology(geom, 78270 / power(2, 12)) AS geom
+FROM osm_polygon
+WHERE geom IS NOT NULL
+ AND st_area(geom) > 78270 / power(2, 12) * 100
+ AND tags ->> 'leisure' IN ('garden', 'golf_course', 'marina',
'nature_reserve', 'park', 'pitch', 'sport_center', 'stadium', 'swimming_pool',
'track');
+CREATE INDEX IF NOT EXISTS osm_leisure_filtered_geom_idx ON
osm_leisure_filtered USING GIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_filtered_tags_idx ON
osm_leisure_filtered (leisure);
+
+CREATE MATERIALIZED VIEW osm_leisure_clustered AS
+SELECT
+ leisure,
+ geom,
+ st_clusterdbscan(geom, 0, 0) OVER(PARTITION BY leisure) AS cluster
+FROM osm_leisure_filtered
+WHERE geom IS NOT NULL;
+CREATE INDEX IF NOT EXISTS osm_leisure_clustered_geom_idx ON
osm_leisure_clustered USING GIST (geom);
+CREATE INDEX IF NOT EXISTS osm_leisure_clustered_tags_idx ON
osm_leisure_clustered (leisure);
+
+CREATE MATERIALIZED VIEW osm_leisure_grouped AS
+SELECT
+ leisure,
+ st_collect(geom) AS geom
+FROM osm_leisure_clustered
+GROUP BY leisure, cluster;
+
+CREATE MATERIALIZED VIEW osm_leisure_buffered AS
+SELECT
+ leisure,
+ st_buffer(geom, 0, 'join=mitre') AS geom
+FROM osm_leisure_grouped;
+
+CREATE MATERIALIZED VIEW osm_leisure_exploded AS
+SELECT
+ leisure,
+ (st_dump(geom)).geom AS geom
+FROM osm_leisure_buffered;
+
+CREATE MATERIALIZED VIEW osm_leisure AS
+SELECT
+ row_number() OVER () AS id,
+ jsonb_build_object('leisure', leisure) AS tags,
+ geom
+FROM osm_leisure_exploded;
+
+-- XTRA LARGE
+CREATE MATERIALIZED VIEW osm_leisure_xl_filtered AS
+SELECT
+ id,
+ tags -> 'leisure' as leisure,
+ st_buffer(st_simplifypreservetopology(geom, 78270 / power(2, 8)), 78270 /
power(2, 8), 'join=mitre') AS geom
+FROM osm_leisure
+WHERE st_area(st_envelope(geom)) > 25 * power(78270 / power(2, 8), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_xl_clustered AS
+SELECT
+ leisure,
+ geom,
+ st_clusterdbscan(geom, 0, 0) OVER(PARTITION BY leisure) AS cluster
+FROM osm_leisure_xl_filtered;
+
+CREATE MATERIALIZED VIEW osm_leisure_xl_grouped AS
+SELECT
+ leisure,
+ cluster,
+ st_collect(geom) AS geom
+FROM osm_leisure_xl_clustered
+GROUP BY leisure, cluster;
+
+CREATE MATERIALIZED VIEW osm_leisure_xl_buffered AS
+SELECT
+ leisure,
+ st_buffer(geom, -78270 / power(2, 8), 'join=mitre') AS geom
+FROM osm_leisure_xl_grouped;
+
+CREATE MATERIALIZED VIEW osm_leisure_xl_exploded AS
+SELECT
+ leisure,
+ (st_dump(geom)).geom AS geom
+FROM osm_leisure_xl_buffered;
+
+CREATE MATERIALIZED VIEW osm_leisure_xl AS
+SELECT
+ row_number() OVER () AS id,
+ jsonb_build_object('leisure', leisure) AS tags,
+ geom AS geom
+FROM osm_leisure_xl_buffered;
+
+-- LARGE
+CREATE MATERIALIZED VIEW osm_leisure_l_filtered AS
+SELECT
+ id,
+ tags -> 'leisure' as leisure,
+ st_buffer(st_simplifypreservetopology(geom, 78270 / power(2, 6)), 78270 /
power(2, 7), 'join=mitre') AS geom
+FROM osm_leisure
+WHERE st_area(st_envelope(geom)) > 5 * power(78270 / power(2, 7), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_l_clustered AS
+SELECT
+ leisure,
+ geom,
+ st_clusterdbscan(geom, 0, 0) OVER(PARTITION BY leisure) AS cluster
+FROM osm_leisure_l_filtered;
+
+CREATE MATERIALIZED VIEW osm_leisure_l_grouped AS
+SELECT
+ leisure,
+ cluster,
+ st_collect(geom) AS geom
+FROM osm_leisure_l_clustered
+GROUP BY leisure, cluster;
+
+CREATE MATERIALIZED VIEW osm_leisure_l_buffered AS
+SELECT
+ leisure,
+ st_buffer(geom, 0.5 * -78270 / power(2, 7), 'join=mitre') AS geom
+FROM osm_leisure_l_grouped;
+
+CREATE MATERIALIZED VIEW osm_leisure_l_exploded AS
+SELECT
+ leisure,
+ (st_dump(geom)).geom AS geom
+FROM osm_leisure_l_buffered;
+
+CREATE MATERIALIZED VIEW osm_leisure_l AS
+SELECT
+ row_number() OVER () AS id,
+ jsonb_build_object('leisure', leisure) AS tags,
+ geom AS geom
+FROM osm_leisure_l_buffered;
+
+-- MEDIUM
+CREATE MATERIALIZED VIEW osm_leisure_m_filtered AS
+SELECT
+ id,
+ tags -> 'leisure' as leisure,
+ st_buffer(st_simplifypreservetopology(geom, 78270 / power(2, 5)), 78270 /
power(2, 6), 'join=mitre') AS geom
+FROM osm_leisure
+WHERE st_area(st_envelope(geom)) > 10 * power(78270 / power(2, 6), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_m_clustered AS
+SELECT
+ leisure,
+ geom,
+ st_clusterdbscan(geom, 0, 0) OVER(PARTITION BY leisure) AS cluster
+FROM osm_leisure_m_filtered;
+
+CREATE MATERIALIZED VIEW osm_leisure_m_grouped AS
+SELECT
+ leisure,
+ cluster,
+ st_collect(geom) AS geom
+FROM osm_leisure_m_clustered
+GROUP BY leisure, cluster;
+
+CREATE MATERIALIZED VIEW osm_leisure_m_buffered AS
+SELECT
+ leisure,
+ st_buffer(geom, 0.1 * -78270 / power(2, 6), 'join=mitre') AS geom
+FROM osm_leisure_m_grouped;
+
+CREATE MATERIALIZED VIEW osm_leisure_m_exploded AS
+SELECT
+ leisure,
+ (st_dump(geom)).geom AS geom
+FROM osm_leisure_m_buffered;
+
+CREATE MATERIALIZED VIEW osm_leisure_m AS
+SELECT
+ row_number() OVER () AS id,
+ jsonb_build_object('leisure', leisure) AS tags,
+ geom AS geom
+FROM osm_leisure_m_buffered;
+
+-- SMALL
+CREATE MATERIALIZED VIEW osm_leisure_s_filtered AS
+SELECT
+ id,
+ tags -> 'leisure' as leisure,
+ st_buffer(st_simplifypreservetopology(geom, 78270 / power(2, 4)), 78270 /
power(2, 5), 'join=mitre') AS geom
+FROM osm_leisure
+WHERE st_area(st_envelope(geom)) > 15 * power(78270 / power(2, 5), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_s_clustered AS
+SELECT
+ leisure,
+ geom,
+ st_clusterdbscan(geom, 0, 0) OVER(PARTITION BY leisure) AS cluster
+FROM osm_leisure_s_filtered;
+
+CREATE MATERIALIZED VIEW osm_leisure_s_grouped AS
+SELECT
+ leisure,
+ cluster,
+ st_collect(geom) AS geom
+FROM osm_leisure_s_clustered
+GROUP BY leisure, cluster;
+
+CREATE MATERIALIZED VIEW osm_leisure_s_buffered AS
+SELECT
+ leisure,
+ st_buffer(geom, 0, 'join=mitre') AS geom
+FROM osm_leisure_s_grouped;
+
+CREATE MATERIALIZED VIEW osm_leisure_s_exploded AS
+SELECT
+ leisure,
+ (st_dump(geom)).geom AS geom
+FROM osm_leisure_s_buffered;
+
+CREATE MATERIALIZED VIEW osm_leisure_s AS
+SELECT
+ row_number() OVER () AS id,
+ jsonb_build_object('leisure', leisure) AS tags,
+ geom AS geom
+FROM osm_leisure_s_buffered;
diff --git a/basemap/layers/leisure/simplify.sql
b/basemap/layers/leisure/simplify.sql
new file mode 100644
index 00000000..cdd6756c
--- /dev/null
+++ b/basemap/layers/leisure/simplify.sql
@@ -0,0 +1,98 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to you under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+CREATE VIEW osm_leisure_z20 AS
+SELECT id, tags, geom FROM osm_leisure;
+
+CREATE VIEW osm_leisure_z19 AS
+SELECT id, tags, geom FROM osm_leisure;
+
+CREATE VIEW osm_leisure_z18 AS
+SELECT id, tags, geom FROM osm_leisure;
+
+CREATE VIEW osm_leisure_z17 AS
+SELECT id, tags, geom FROM osm_leisure;
+
+CREATE VIEW osm_leisure_z16 AS
+SELECT id, tags, geom FROM osm_leisure;
+
+CREATE VIEW osm_leisure_z15 AS
+SELECT id, tags, geom FROM osm_leisure;
+
+CREATE VIEW osm_leisure_z14 AS
+SELECT id, tags, geom FROM osm_leisure;
+
+CREATE VIEW osm_leisure_z13 AS
+SELECT id, tags, geom FROM osm_leisure;
+
+CREATE MATERIALIZED VIEW osm_leisure_z12 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 12)) AS
geom
+FROM osm_leisure
+WHERE st_area(st_envelope(geom)) > 25 * power(78270 / power(2, 12), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z11 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 11)) AS
geom
+FROM osm_leisure
+WHERE st_area(st_envelope(geom)) > 25 * power(78270 / power(2, 11), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z10 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 10)) AS
geom
+FROM osm_leisure
+WHERE st_area(st_envelope(geom)) > 25 * power(78270 / power(2, 10), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z9 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 9)) AS geom
+FROM osm_leisure
+WHERE st_area(st_envelope(geom)) > 25 * power(78270 / power(2, 9), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z8 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 8)) AS geom
+FROM osm_leisure_xl
+WHERE st_area(st_envelope(geom)) > 25 * power(78270 / power(2, 8), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z7 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 7)) AS geom
+FROM osm_leisure_l
+WHERE st_area(st_envelope(geom)) > 150 * power(78270 / power(2, 7), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z6 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 6)) AS geom
+FROM osm_leisure_m
+WHERE st_area(st_envelope(geom)) > 150 * power(78270 / power(2, 6), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z5 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 5)) AS geom
+FROM osm_leisure_s
+WHERE st_area(st_envelope(geom)) > 150 * power(78270 / power(2, 5), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z4 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 4)) AS geom
+FROM osm_leisure_s
+WHERE st_area(st_envelope(geom)) > 150 * power(78270 / power(2, 4), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z3 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 3)) AS geom
+FROM osm_leisure_s
+WHERE st_area(st_envelope(geom)) > 150 * power(78270 / power(2, 3), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z2 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 2)) AS geom
+FROM osm_leisure_s
+WHERE st_area(st_envelope(geom)) > 150 * power(78270 / power(2, 2), 2);
+
+CREATE MATERIALIZED VIEW osm_leisure_z1 AS
+SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 1)) AS geom
+FROM osm_leisure_s
+WHERE st_area(st_envelope(geom)) > 250 * power(78270 / power(2, 1), 2);
diff --git a/basemap/layers/leisure/tileset.js
b/basemap/layers/leisure/tileset.js
index 858fe98f..bef2910c 100644
--- a/basemap/layers/leisure/tileset.js
+++ b/basemap/layers/leisure/tileset.js
@@ -18,6 +18,12 @@
export default {
id: 'leisure',
queries: [
+ {
+ minzoom: 1,
+ maxzoom: 13,
+ sql:
+ "SELECT id, tags, geom FROM osm_leisure_z$zoom WHERE tags ?
'leisure'",
+ },
{
minzoom: 13,
maxzoom: 20,
diff --git a/basemap/layers/railway/prepare.sql
b/basemap/layers/railway/prepare.sql
index f83c0483..c9222865 100644
--- a/basemap/layers/railway/prepare.sql
+++ b/basemap/layers/railway/prepare.sql
@@ -18,10 +18,9 @@ SELECT id, tags, geom
FROM (
SELECT
min(id) as id,
- jsonb_build_object('railway', tags -> 'railway') as tags,
+ jsonb_build_object('railway', tags -> 'railway', 'service', tags ->
'service') as tags,
(st_dump(st_linemerge(st_collect(geom)))).geom as geom
FROM osm_ways
WHERE tags ->> 'railway' IN ('light_rail', 'monorail', 'rail', 'subway',
'tram')
- AND NOT tags ? 'service'
- GROUP BY tags -> 'railway'
+ GROUP BY tags -> 'railway', tags -> 'service'
) AS merge;
diff --git a/basemap/workflow.js b/basemap/workflow.js
index 47ae09a7..bf2f3c2d 100644
--- a/basemap/workflow.js
+++ b/basemap/workflow.js
@@ -405,6 +405,36 @@ export default {
},
]
},
+ {
+ "id": "openstreetmap-leisure",
+ "needs": [
+ "openstreetmap-polygon"
+ ],
+ "tasks": [
+ {
+ "type": "ExecuteSql",
+ "file": "layers/leisure/clean.sql",
+ "database": config.database,
+ },
+ {
+ "type": "ExecuteSql",
+ "file": "layers/leisure/prepare.sql",
+ "database": config.database,
+ },
+ {
+ "type": "ExecuteSql",
+ "file": "layers/leisure/simplify.sql",
+ "database": config.database,
+ "parallel": true,
+ },
+ {
+ "type": "ExecuteSql",
+ "file": "layers/leisure/index.sql",
+ "database": config.database,
+ "parallel": true
+ },
+ ]
+ },
{
"id": "openstreetmap-waterway",
"needs": [
diff --git a/daylight/workflow.js b/daylight/workflow.js
index 3c387b64..c256c87b 100644
--- a/daylight/workflow.js
+++ b/daylight/workflow.js
@@ -398,6 +398,36 @@ export default {
},
]
},
+ {
+ "id": "openstreetmap-leisure",
+ "needs": [
+ "openstreetmap-polygon"
+ ],
+ "tasks": [
+ {
+ "type": "ExecuteSql",
+ "file": "layers/leisure/clean.sql",
+ "database": config.database,
+ },
+ {
+ "type": "ExecuteSql",
+ "file": "layers/leisure/prepare.sql",
+ "database": config.database,
+ },
+ {
+ "type": "ExecuteSql",
+ "file": "layers/leisure/simplify.sql",
+ "database": config.database,
+ "parallel": true,
+ },
+ {
+ "type": "ExecuteSql",
+ "file": "layers/leisure/index.sql",
+ "database": config.database,
+ "parallel": true
+ },
+ ]
+ },
{
"id": "daylight-waterway",
"needs": ["daylight-linestring"],