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

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


The following commit(s) were added to refs/heads/colorfull-extrusions by this 
push:
     new 5d0aaa78 Disable colors due to z-fighting
5d0aaa78 is described below

commit 5d0aaa78bdb61749c0bc46f5247a691486a59b22
Author: Bertil Chapuis <[email protected]>
AuthorDate: Sat Nov 11 00:15:22 2023 +0100

    Disable colors due to z-fighting
---
 basemap/layers/building/extrusion.js | 16 +++++----
 basemap/layers/building/tileset.js   | 66 +++++++++++++++++++-----------------
 2 files changed, 45 insertions(+), 37 deletions(-)

diff --git a/basemap/layers/building/extrusion.js 
b/basemap/layers/building/extrusion.js
index 0c0dca5c..03d8c0d6 100644
--- a/basemap/layers/building/extrusion.js
+++ b/basemap/layers/building/extrusion.js
@@ -27,12 +27,16 @@ export default {
     },
     minzoom: 15,
     paint: {
-        "fill-extrusion-color": [
-            "case",
-            ["has", "building:colour"],
-            ["get", "building:colour"],
-            theme.buildingShapeFillColor,
-        ],
+        "fill-extrusion-color": theme.buildingShapeFillColor,
+        // Having muliple colors for building parts results in z-fighting
+        // https://github.com/maplibre/maplibre-gl-js/issues/3157
+        // https://github.com/maplibre/maplibre-gl-js/issues/3187
+        // "fill-extrusion-color": [
+        //     "case",
+        //     ["has", "building:colour"],
+        //     ["get", "building:colour"],
+        //     theme.buildingShapeFillColor,
+        // ],
         "fill-extrusion-base": [
             'interpolate',
             ['linear'],
diff --git a/basemap/layers/building/tileset.js 
b/basemap/layers/building/tileset.js
index fab6f347..e7fabd2f 100644
--- a/basemap/layers/building/tileset.js
+++ b/basemap/layers/building/tileset.js
@@ -22,47 +22,51 @@ export default {
             minzoom: 13,
             maxzoom: 20,
             sql: `
-                SELECT 
-                    id, 
+                SELECT
+                    id,
                     tags
                         || jsonb_build_object('extrusion:base', (CASE
-                                                                     WHEN tags 
? 'building:min_height'
-                                                                         THEN 
tags ->> 'building:min_height'
-                                                                     WHEN tags 
->> 'building:min_level' ~ '^[0-9\\\\\\\\.]+$'
-                                                                         THEN 
tags ->> 'building:min_level'
-                                                                     ELSE '0' 
END)::real * 3)
+                            WHEN tags ? 'building:min_height'
+                                THEN (tags ->> 'building:min_height')::real
+                            WHEN tags ->> 'building:min_level' ~ '^[0-9.]+$'
+                                THEN (tags ->> 'building:min_level')::real * 3
+                            ELSE 0 END))
                         || jsonb_build_object('extrusion:height', (CASE
-                                                                   WHEN tags ? 
'building:height'
-                                                                       THEN 
tags ->> 'building:height'
-                                                                   WHEN tags 
->> 'building:levels' ~ '^[0-9\\\\\\\\.]+$'
-                                                                       THEN 
tags ->> 'building:levels'
-                                                                   ELSE '2' 
END)::real * 3) as tags,
-                    geom 
-                FROM osm_ways 
-                WHERE tags ? 'building'`,
+                            WHEN tags ? 'height'
+                               THEN (SUBSTRING(tags ->> 'height' FROM 
'^[0-9]+'))::real
+                            WHEN tags ? 'building:height'
+                               THEN (tags ->> 'building:height')::real
+                            WHEN tags ->> 'building:levels' ~ '^[0-9.]+$'
+                               THEN (tags ->> 'building:levels')::real * 3
+                            ELSE 6 END)) as tags,
+                    geom
+                FROM osm_ways
+                WHERE (tags ? 'building' OR tags ? 'building:part') AND ((NOT 
tags ? 'layer') OR (tags ->> 'layer')::real >= 0)`,
         },
         {
             minzoom: 13,
             maxzoom: 20,
             sql: `
-                SELECT 
-                    id, 
-                    tags 
+                SELECT
+                    id,
+                    tags
                         || jsonb_build_object('extrusion:base', (CASE
-                                                                      WHEN 
tags ? 'building:min_height'
-                                                                          THEN 
tags ->> 'building:min_height'
-                                                                      WHEN 
tags ->> 'building:min_level' ~ '^[0-9\\\\\\\\.]+$'
-                                                                          THEN 
tags ->> 'building:min_level'
-                                                                      ELSE '0' 
END)::real * 3)
+                            WHEN tags ? 'building:min_height'
+                                THEN (tags ->> 'building:min_height')::real
+                            WHEN tags ->> 'building:min_level' ~ '^[0-9.]+$'
+                                THEN (tags ->> 'building:min_level')::real * 3
+                            ELSE 0 END))
                         || jsonb_build_object('extrusion:height', (CASE
-                                                                   WHEN tags ? 
'building:height'
-                                                                       THEN 
tags ->> 'building:height'
-                                                                   WHEN tags 
->> 'building:levels' ~ '^[0-9\\\\\\\\.]+$'
-                                                                       THEN 
tags ->> 'building:levels'
-                                                                   ELSE '2' 
END)::real * 3) as tags,
-                    geom 
-                FROM osm_relations 
-                WHERE tags ? 'building'`,
+                            WHEN tags ? 'height'
+                                THEN (SUBSTRING(tags ->> 'height' FROM 
'^[0-9]+'))::real
+                            WHEN tags ? 'building:height'
+                                THEN (tags ->> 'building:height')::real
+                            WHEN tags ->> 'building:levels' ~ '^[0-9.]+$'
+                                THEN (tags ->> 'building:levels')::real * 3
+                            ELSE 6 END)) as tags,
+                    geom
+                FROM osm_relations
+                WHERE (tags ? 'building' OR tags ? 'building:part') AND ((NOT 
tags ? 'layer') OR (tags ->> 'layer')::real >= 0)`,
         },
     ],
 }

Reply via email to