You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2023/10/05 19:49:51 UTC
[incubator-baremaps] 01/01: Add colorfull building extrusions
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
commit 310c19da73da35e37d37e51825c0b9b21100304b
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Thu Oct 5 21:49:01 2023 +0200
Add colorfull building extrusions
---
.run/basemap-dev.run.xml | 5 +++
basemap/layers/building/extrusion.js | 64 ++++++++++++++++++++++++++++++++++++
basemap/layers/building/tileset.js | 42 ++++++++++++++++++++---
basemap/style.js | 2 ++
4 files changed, 109 insertions(+), 4 deletions(-)
diff --git a/.run/basemap-dev.run.xml b/.run/basemap-dev.run.xml
index 9b68be2a..3287415e 100644
--- a/.run/basemap-dev.run.xml
+++ b/.run/basemap-dev.run.xml
@@ -10,6 +10,11 @@
<option name="ENABLED" value="true" />
</pattern>
</extension>
+ <extension name="software.aws.toolkits.jetbrains.core.execution.JavaAwsConnectionExtension">
+ <option name="credential" />
+ <option name="region" />
+ <option name="useCurrentConnection" value="false" />
+ </extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
diff --git a/basemap/layers/building/extrusion.js b/basemap/layers/building/extrusion.js
new file mode 100644
index 00000000..2c28e5ed
--- /dev/null
+++ b/basemap/layers/building/extrusion.js
@@ -0,0 +1,64 @@
+/**
+ 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.
+ **/
+import theme from "../../theme.js";
+
+export default {
+ id: 'building-extrusion',
+ type: 'fill-extrusion',
+ source: 'baremaps',
+ 'source-layer': 'building',
+ filter: ['!=', ['get', 'building'], 'no'],
+ layout: {
+ visibility: 'visible',
+ },
+ minzoom: 16,
+ paint: {
+ "fill-extrusion-color": [
+ "case",
+ ["has", "building:colour"],
+ ["get", "building:colour"],
+ theme.buildingShapeFillColor,
+ ],
+ "fill-extrusion-base": [
+ 'interpolate',
+ ['linear'],
+ ['zoom'],
+ 16,
+ 0,
+ 17,
+ ['get', "extrusion:base"]
+ ],
+ "fill-extrusion-height": [
+ 'interpolate',
+ ['linear'],
+ ['zoom'],
+ 16,
+ 0,
+ 17,
+ ['get', "extrusion:height"]
+ ],
+ "fill-extrusion-opacity": [
+ 'interpolate',
+ ['linear'],
+ ['zoom'],
+ 16,
+ 0,
+ 17,
+ 0.8
+ ]
+ },
+}
diff --git a/basemap/layers/building/tileset.js b/basemap/layers/building/tileset.js
index 66c9bf1f..47c962e1 100644
--- a/basemap/layers/building/tileset.js
+++ b/basemap/layers/building/tileset.js
@@ -21,14 +21,48 @@ export default {
{
minzoom: 13,
maxzoom: 20,
- sql:
- "SELECT id, tags, geom FROM osm_ways WHERE tags ? 'building'",
+ sql: `
+ 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)
+ || 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),
+ geom
+ FROM osm_ways
+ WHERE tags ? 'building'`,
},
{
minzoom: 13,
maxzoom: 20,
- sql:
- "SELECT id, tags, geom FROM osm_relations WHERE tags ? 'building'",
+ sql: `
+ 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)
+ || 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),
+ geom
+ FROM osm_relations
+ WHERE tags ? 'building'`,
},
],
}
diff --git a/basemap/style.js b/basemap/style.js
index 48ff2fc0..8baf8d28 100644
--- a/basemap/style.js
+++ b/basemap/style.js
@@ -53,6 +53,7 @@ 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";
+import building_extrusion from "./layers/building/extrusion.js";
import building_number from "./layers/building/number.js";
import man_made_bridge from "./layers/man_made/bridge.js";
import man_made_pier_line from "./layers/man_made/pier_line.js";
@@ -121,6 +122,7 @@ export default {
natural_trunk,
boundary_line,
waterway_label,
+ building_extrusion,
icon,
point_label,
country_label,