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 56114e66 Display icons, country names, and boundaries on the basemap
(#674)
56114e66 is described below
commit 56114e66550b1d1936156be57c352e46098a5dd8
Author: Bertil Chapuis <[email protected]>
AuthorDate: Sat May 27 14:22:40 2023 +0200
Display icons, country names, and boundaries on the basemap (#674)
---
basemap/layers/boundary/tileset.js | 4 +--
basemap/layers/point/country_label.js | 42 +++++++++++++++++++++++
basemap/layers/point/{label.js => point_label.js} | 13 ++-----
basemap/layers/point/tileset.js | 2 +-
basemap/style.js | 6 ++--
basemap/tileset.js | 2 +-
6 files changed, 53 insertions(+), 16 deletions(-)
diff --git a/basemap/layers/boundary/tileset.js
b/basemap/layers/boundary/tileset.js
index 09111907..34cb9fc6 100644
--- a/basemap/layers/boundary/tileset.js
+++ b/basemap/layers/boundary/tileset.js
@@ -20,12 +20,12 @@ export default {
},
{
minzoom: 6,
- maxzoom: 14,
+ maxzoom: 10,
sql:
"SELECT fid as id, jsonb_build_object('boundary',
'administrative', 'admin_level', '1') as tags, geom FROM globaladm1_z$zoom",
},
{
- minzoom: 14,
+ minzoom: 10,
maxzoom: 20,
sql:
"SELECT id, tags, geom FROM osm_ways WHERE tags ? 'boundary'",
diff --git a/basemap/layers/point/country_label.js
b/basemap/layers/point/country_label.js
new file mode 100644
index 00000000..c9358a79
--- /dev/null
+++ b/basemap/layers/point/country_label.js
@@ -0,0 +1,42 @@
+/**
+ 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, withSymbolSortKeys} from "../../utils/utils.js";
+
+let directives = [
+ {
+ filter: [
+ 'all',
+ ['==', ['get', 'place'], 'country']
+ ],
+ 'text-size': 18,
+ 'text-color': 'rgb(25, 25, 25)',
+ 'symbol-sort-key': ["-", ["to-number", ['get', 'population'], 0]],
+ },
+];
+
+export default asLayerObject(withSymbolSortKeys(directives), {
+ id: 'country_label',
+ type: 'symbol',
+ source: 'baremaps',
+ 'source-layer': 'point',
+ 'minzoom': 1,
+ 'maxzoom': 4,
+ layout: {
+ visibility: 'visible',
+ 'text-font': ['Noto Sans Regular'],
+ 'text-field': ['get', 'name'],
+ },
+ paint: {
+ 'text-halo-color': 'rgba(255, 255, 255, 0.8)',
+ 'text-halo-width': 1,
+ },
+});
diff --git a/basemap/layers/point/label.js b/basemap/layers/point/point_label.js
similarity index 90%
rename from basemap/layers/point/label.js
rename to basemap/layers/point/point_label.js
index 0515b31f..5cce37ea 100644
--- a/basemap/layers/point/label.js
+++ b/basemap/layers/point/point_label.js
@@ -12,15 +12,6 @@
import {asLayerObject, withSymbolSortKeys} from "../../utils/utils.js";
let directives = [
- {
- filter: [
- 'all',
- ['==', ['get', 'place'], 'country']
- ],
- 'text-size': 18,
- 'text-color': 'rgb(25, 25, 25)',
- 'symbol-sort-key': ["-", ["to-number", ['get', 'population'], 0]],
- },
{
filter: [
'all',
@@ -77,10 +68,12 @@ let directives = [
];
export default asLayerObject(withSymbolSortKeys(directives), {
- id: 'label',
+ id: 'point_label',
type: 'symbol',
source: 'baremaps',
'source-layer': 'point',
+ 'minzoom': 4,
+ 'maxzoom': 24,
layout: {
visibility: 'visible',
'text-font': ['Noto Sans Regular'],
diff --git a/basemap/layers/point/tileset.js b/basemap/layers/point/tileset.js
index 24f08b64..68d665eb 100644
--- a/basemap/layers/point/tileset.js
+++ b/basemap/layers/point/tileset.js
@@ -20,7 +20,7 @@ export default {
{
"minzoom": 4,
"maxzoom": 20,
- "sql": "SELECT id, tags, geom FROM osm_point_z$zoom WHERE tags !=
'{}' AND (tags ->> 'place' != 'country')"
+ "sql": "SELECT id, tags, geom FROM osm_point_z$zoom WHERE tags !=
'{}'"
}
]
}
diff --git a/basemap/style.js b/basemap/style.js
index c57251d7..e2a10571 100644
--- a/basemap/style.js
+++ b/basemap/style.js
@@ -52,7 +52,8 @@ import waterway_label from "./layers/waterway/label.js"
import waterway_tunnel_line from "./layers/waterway/tunnel_line.js"
import waterway_tunnel_casing from "./layers/waterway/tunnel_casing.js"
import icon from "./layers/point/icon.js";
-import label from './layers/point/label.js';
+import country_label from './layers/point/country_label.js';
+import point_label from './layers/point/point_label.js';
export default {
"version": 8,
@@ -109,6 +110,7 @@ export default {
boundary_line,
waterway_label,
icon,
- label,
+ country_label,
+ point_label,
],
};
\ No newline at end of file
diff --git a/basemap/tileset.js b/basemap/tileset.js
index b7bbc919..c92d6326 100644
--- a/basemap/tileset.js
+++ b/basemap/tileset.js
@@ -46,7 +46,7 @@ export default {
amenity,
attraction,
barrier,
- // boundary,
+ boundary,
building,
highway,
landuse,