This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a commit to branch 684-construction
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git

commit 81bed5489c1f2abe5c35fc4b044b1ee38ab7d2d6
Author: Bertil Chapuis <[email protected]>
AuthorDate: Wed May 31 00:44:48 2023 +0200

    Add highway=construction directives
---
 basemap/layers/highway/construction_dash.js    | 109 ++++++++++++++++++++
 basemap/layers/highway/construction_line.js    | 136 +++++++++++++++++++++++++
 basemap/layers/highway/highway_construction.js |  15 ---
 basemap/layers/highway/prepare.sql             |  10 +-
 basemap/layers/highway/simplify.sql            |   2 +-
 basemap/style.js                               |   9 +-
 6 files changed, 261 insertions(+), 20 deletions(-)

diff --git a/basemap/layers/highway/construction_dash.js 
b/basemap/layers/highway/construction_dash.js
new file mode 100644
index 00000000..4cf7a643
--- /dev/null
+++ b/basemap/layers/highway/construction_dash.js
@@ -0,0 +1,109 @@
+/**
+ Licensed 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.
+ **/
+ import {asLayerObject, withSortKeys} from "../../utils/utils.js";
+
+ let directives =[
+     {
+         filter: [
+             'all',
+             ['==', ['get', 'highway'], 'construction'],
+             ['==', ['get', 'construction'], 'motorway'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 16,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'trunk'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 12,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'primary'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 14,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'secondary'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 12,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'tertiary'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 12,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'unclassified'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 8,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'residential'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 8,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'living_street'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 8,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'service'],
+         ],
+         'line-color': 'rgb(254, 254, 254)',
+         'road-width': 8,
+     },
+ ]
+ 
+ export default asLayerObject(withSortKeys(directives), {
+     id: 'highway_construction_outline',
+     source: 'baremaps',
+     'source-layer': 'highway',
+     type: 'line',
+     layout: {
+         visibility: 'visible',
+         'line-cap': 'round',
+         'line-join': 'round',
+     },
+ });
+ 
\ No newline at end of file
diff --git a/basemap/layers/highway/construction_line.js 
b/basemap/layers/highway/construction_line.js
new file mode 100644
index 00000000..2d9f7b3b
--- /dev/null
+++ b/basemap/layers/highway/construction_line.js
@@ -0,0 +1,136 @@
+/**
+ Licensed 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.
+ **/
+ import {asLayerObject, withSortKeys} from "../../utils/utils.js";
+
+ let directives =[
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['any',
+                ['==', ['get', 'construction'], 'motorway'],
+                ['==', ['get', 'construction'], 'motorway_link'],
+            ]
+         ],
+         'line-color': 'rgb(233, 144, 161)',
+         'road-width': 16,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['any',
+                ['==', ['get', 'construction'], 'trunk'],
+                ['==', ['get', 'construction'], 'trunk_link'],
+            ]
+         ],
+         'line-color': 'rgb(250, 193, 172)',
+         'road-width': 12,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['any',
+                ['==', ['get', 'construction'], 'primary'],
+                ['==', ['get', 'construction'], 'primary_link'],
+            ]
+         ],
+         'line-color': 'rgb(253, 221, 179)',
+         'road-width': 14,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['any',
+                ['==', ['get', 'construction'], 'secondary'],
+                ['==', ['get', 'construction'], 'secondary_link'],
+            ]
+         ],
+         'line-color': 'rgb(248, 250, 202)',
+         'road-width': 12,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['any',
+                ['==', ['get', 'construction'], 'tertiary'],
+                ['==', ['get', 'construction'], 'tertiary_link'],
+            ]
+         ],
+         'line-color': 'rgb(190, 189, 188)',
+         'road-width': 12,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'unclassified'],
+         ],
+         'line-color': 'rgb(211, 207, 206)',
+         'road-width': 8,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'residential'],
+         ],
+         'line-color': 'rgb(211, 207, 206)',
+         'road-width': 8,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'living_street'],
+         ],
+         'line-color': 'rgb(207, 207, 207)',
+         'road-width': 8,
+     },
+     {
+         filter: [
+            'all',
+            ['==', ['get', 'highway'], 'construction'],
+            ['==', ['get', 'construction'], 'service'],
+         ],
+         'line-color': 'rgb(213, 211, 211)',
+         'road-width': 8,
+     },
+     {
+        filter: [
+           'all',
+           ['==', ['get', 'highway'], 'construction'],
+           ['==', ['get', 'construction'], 'raceway'],
+        ],
+        'line-color': 'rgb(213, 211, 211)',
+        'road-width': 8,
+    },
+ ]
+ 
+ export default asLayerObject(withSortKeys(directives), {
+     id: 'highway_construction_line',
+     source: 'baremaps',
+     'source-layer': 'highway',
+     type: 'line',
+     layout: {
+         visibility: 'visible',
+         'line-cap': 'butt',
+         'line-join': 'round',
+     },
+     paint: {
+        'line-dasharray': [1, 1],
+    },
+ });
+ 
\ No newline at end of file
diff --git a/basemap/layers/highway/highway_construction.js 
b/basemap/layers/highway/highway_construction.js
deleted file mode 100644
index bc949cfc..00000000
--- a/basemap/layers/highway/highway_construction.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- Licensed 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.
- **/
-// TODO:
-// recover construction styles.
-// 
https://raw.githubusercontent.com/baremaps/openstreetmap-vecto/7b7b9e8/layers/highway/style.js
-// https://wiki.openstreetmap.org/wiki/Key:construction
\ No newline at end of file
diff --git a/basemap/layers/highway/prepare.sql 
b/basemap/layers/highway/prepare.sql
index 8ec65b5f..3c8b994a 100644
--- a/basemap/layers/highway/prepare.sql
+++ b/basemap/layers/highway/prepare.sql
@@ -15,14 +15,16 @@ WITH
     filtered AS (
         SELECT
                 tags -> 'highway' AS highway,
+                tags -> 'construction' AS construction,
                 geom AS geom
         FROM osm_linestring
-        WHERE tags ->> 'highway' IN ('motorway', 'motorway_link', 'trunk', 
'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 
'tertiary',  'tertiary_link', 'unclassified', 'residential')
+        WHERE tags ->> 'highway' IN ('motorway', 'motorway_link', 'trunk', 
'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 
'tertiary',  'tertiary_link', 'unclassified', 'residential', 'construction')
     ),
     -- Cluster the linestrings by highway type
     clustered AS (
         SELECT
                 highway AS highway,
+                construction AS construction,
                 geom as geom,
                 ST_ClusterDBSCAN(geom, 0, 1) OVER (PARTITION BY highway) AS 
cluster
         FROM
@@ -32,23 +34,25 @@ WITH
     merged AS (
         SELECT
             highway AS highway,
+            construction AS construction,
             ST_LineMerge(ST_Collect(geom)) AS geom
         FROM
             clustered
         GROUP BY
-            highway, cluster
+            highway, construction, cluster
     ),
     -- Explode the merged linestrings into individual linestrings
     exploded AS (
         SELECT
             highway AS highway,
+            construction AS construction,
             (ST_Dump(geom)).geom AS geom
         FROM
             merged
     )
 SELECT
     row_number() OVER () AS id,
-    jsonb_build_object('highway', highway) AS tags,
+    jsonb_build_object('highway', highway, 'construction', construction) AS 
tags,
     geom AS geom
 FROM exploded;
 
diff --git a/basemap/layers/highway/simplify.sql 
b/basemap/layers/highway/simplify.sql
index be92cef7..9cf118bc 100644
--- a/basemap/layers/highway/simplify.sql
+++ b/basemap/layers/highway/simplify.sql
@@ -36,7 +36,7 @@ CREATE MATERIALIZED VIEW osm_highway_z12 AS
 SELECT id, tags, geom
 FROM (SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 12)) 
AS geom FROM osm_highway) AS osm_highway
 WHERE geom IS NOT NULL AND (st_area(st_envelope(geom)) > power((78270 / 
power(2, 12)), 2))
-  AND tags ->> 'highway' IN ( 'motorway', 'motorway_link',  'trunk', 
'trunk_link',  'primary', 'primary_link',  'secondary', 'secondary_link',  
'tertiary', 'tertiary_link', 'unclassified', 'residential');
+  AND tags ->> 'highway' IN ( 'motorway', 'motorway_link',  'trunk', 
'trunk_link',  'primary', 'primary_link',  'secondary', 'secondary_link',  
'tertiary', 'tertiary_link', 'unclassified', 'residential', 'construction');
 
 CREATE MATERIALIZED VIEW osm_highway_z11 AS
 SELECT id, tags, geom
diff --git a/basemap/style.js b/basemap/style.js
index e2a10571..dc40c4b6 100644
--- a/basemap/style.js
+++ b/basemap/style.js
@@ -17,7 +17,7 @@ import aeroway_polygon from "./layers/aeroway/polygon.js";
 import amenity_background from "./layers/amenity/background.js";
 import amenity_fountain from "./layers/amenity/fountain.js";
 import amenity_overlay from "./layers/amenity/overlay.js";
-import boundary_line from "./layers/boundary/line.js"
+import boundary_line from "./layers/boundary/line.js";
 import landuse_background from "./layers/landuse/background.js";
 import landuse_overlay from "./layers/landuse/overlay.js";
 import natural_background from "./layers/natural/background.js";
@@ -31,6 +31,8 @@ import leisure_background from 
"./layers/leisure/background.js";
 import leisure_overlay from "./layers/leisure/overlay.js";
 import railway_tunnel from "./layers/railway/tunnel.js";
 import railway_line from "./layers/railway/line.js";
+
+
 import highway_line from './layers/highway/highway_line.js';
 import highway_outline from './layers/highway/highway_outline.js';
 import highway_dash from './layers/highway/highway_dash.js';
@@ -39,7 +41,10 @@ import highway_tunnel_outline from 
'./layers/highway/tunnel_outline.js';
 import highway_pedestrian_area from './layers/highway/pedestrian_area.js';
 import highway_bridge_line from './layers/highway/bridge_line.js';
 import highway_bridge_outline from './layers/highway/bridge_outline.js';
+import highway_construction_line from "./layers/highway/construction_line.js";
+import highway_construction_dash from "./layers/highway/construction_dash.js";
 import highway_label from './layers/highway/highway_label.js';
+
 import ocean_overlay from './layers/ocean/overlay.js';
 import route_line from "./layers/route/style.js"
 import building_shape from "./layers/building/shape.js";
@@ -91,6 +96,8 @@ export default {
         railway_tunnel,
         building_shape,
         building_number,
+        highway_construction_dash,
+        highway_construction_line,
         highway_outline,
         highway_line,
         highway_dash,

Reply via email to