kopia lustrzana https://github.com/openmaptiles/openmaptiles
Revamp water label display logic (#1457)
* At zooms 9-13, water labels will now be rendered for water features that are at least 0.25 tiles in size. This means that water features that are the same size as a 128x128 pixel square will get a point label. * Labels for large water features are now shown at the lowest zoom at which it's appropriate to show a label. * Bay and strait names (`natural=bay` and `natural=strait`) are included. * Large seas modeled as areas (e.g. Caspian Sea) render as `class=sea` rather than `class=lake`pull/1465/head^2
rodzic
cd77b07e46
commit
af8c6883dd
|
@ -66,6 +66,9 @@ tables:
|
||||||
type: string
|
type: string
|
||||||
- name: tags
|
- name: tags
|
||||||
type: hstore_tags
|
type: hstore_tags
|
||||||
|
- name: place
|
||||||
|
key: place
|
||||||
|
type: string
|
||||||
- name: natural
|
- name: natural
|
||||||
key: natural
|
key: natural
|
||||||
type: string
|
type: string
|
||||||
|
|
Plik binarny nie jest wyświetlany.
Przed Szerokość: | Wysokość: | Rozmiar: 100 KiB Po Szerokość: | Wysokość: | Rozmiar: 109 KiB |
|
@ -21,6 +21,9 @@ tables:
|
||||||
- name: place
|
- name: place
|
||||||
key: place
|
key: place
|
||||||
type: string
|
type: string
|
||||||
|
- name: natural
|
||||||
|
key: natural
|
||||||
|
type: string
|
||||||
- name: rank
|
- name: rank
|
||||||
key: rank
|
key: rank
|
||||||
type: integer
|
type: integer
|
||||||
|
@ -34,3 +37,6 @@ tables:
|
||||||
place:
|
place:
|
||||||
- ocean
|
- ocean
|
||||||
- sea
|
- sea
|
||||||
|
natural:
|
||||||
|
- bay
|
||||||
|
- strait
|
||||||
|
|
Plik binarny nie jest wyświetlany.
Przed Szerokość: | Wysokość: | Rozmiar: 45 KiB Po Szerokość: | Wysokość: | Rozmiar: 52 KiB |
|
@ -2,14 +2,22 @@ DROP TRIGGER IF EXISTS trigger_delete_point ON osm_water_polygon;
|
||||||
DROP TRIGGER IF EXISTS trigger_update_point ON osm_water_polygon;
|
DROP TRIGGER IF EXISTS trigger_update_point ON osm_water_polygon;
|
||||||
DROP TRIGGER IF EXISTS trigger_insert_point ON osm_water_polygon;
|
DROP TRIGGER IF EXISTS trigger_insert_point ON osm_water_polygon;
|
||||||
|
|
||||||
|
-- etldoc: osm_water_polygon -> osm_water_point_view
|
||||||
|
-- etldoc: lake_centerline -> osm_water_point_view
|
||||||
CREATE OR REPLACE VIEW osm_water_point_view AS
|
CREATE OR REPLACE VIEW osm_water_point_view AS
|
||||||
SELECT wp.osm_id,
|
SELECT wp.osm_id,
|
||||||
ST_PointOnSurface(wp.geometry) AS geometry,
|
ST_PointOnSurface(wp.geometry) AS geometry,
|
||||||
wp.name,
|
wp.name,
|
||||||
wp.name_en,
|
wp.name_en,
|
||||||
wp.name_de,
|
wp.name_de,
|
||||||
|
CASE
|
||||||
|
WHEN "natural" = 'bay' THEN 'bay'
|
||||||
|
WHEN place = 'sea' THEN 'sea'
|
||||||
|
ELSE 'lake'
|
||||||
|
END AS class,
|
||||||
update_tags(wp.tags, ST_PointOnSurface(wp.geometry)) AS tags,
|
update_tags(wp.tags, ST_PointOnSurface(wp.geometry)) AS tags,
|
||||||
ST_Area(wp.geometry) AS area,
|
-- Area of the feature in square meters
|
||||||
|
ST_Area(wp.geometry) as area,
|
||||||
wp.is_intermittent
|
wp.is_intermittent
|
||||||
FROM osm_water_polygon AS wp
|
FROM osm_water_polygon AS wp
|
||||||
LEFT JOIN lake_centerline ll ON wp.osm_id = ll.osm_id
|
LEFT JOIN lake_centerline ll ON wp.osm_id = ll.osm_id
|
||||||
|
@ -17,11 +25,25 @@ WHERE ll.osm_id IS NULL
|
||||||
AND wp.name <> ''
|
AND wp.name <> ''
|
||||||
AND ST_IsValid(wp.geometry);
|
AND ST_IsValid(wp.geometry);
|
||||||
|
|
||||||
-- etldoc: osm_water_polygon -> osm_water_point
|
-- etldoc: osm_water_point_view -> osm_water_point_earth_view
|
||||||
-- etldoc: lake_centerline -> osm_water_point
|
CREATE OR REPLACE VIEW osm_water_point_earth_view AS
|
||||||
|
SELECT osm_id,
|
||||||
|
geometry,
|
||||||
|
name,
|
||||||
|
name_en,
|
||||||
|
name_de,
|
||||||
|
class,
|
||||||
|
tags,
|
||||||
|
-- Percentage of the earth's surface covered by this feature (approximately)
|
||||||
|
-- The constant below is 111,842^2 * 180 * 180, where 111,842 is the length of one degree of latitude at the equator in meters.
|
||||||
|
area / (405279708033600 * COS(ST_Y(ST_Transform(geometry,4326))*PI()/180)) as earth_area,
|
||||||
|
is_intermittent
|
||||||
|
FROM osm_water_point_view;
|
||||||
|
|
||||||
|
-- etldoc: osm_water_point_earth_view -> osm_water_point
|
||||||
CREATE TABLE IF NOT EXISTS osm_water_point AS
|
CREATE TABLE IF NOT EXISTS osm_water_point AS
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM osm_water_point_view;
|
FROM osm_water_point_earth_view;
|
||||||
DO
|
DO
|
||||||
$$
|
$$
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -46,12 +46,14 @@ SELECT
|
||||||
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
||||||
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
||||||
tags,
|
tags,
|
||||||
'lake'::text AS class,
|
class,
|
||||||
is_intermittent::int AS intermittent
|
is_intermittent::int AS intermittent
|
||||||
FROM osm_water_point
|
FROM osm_water_point
|
||||||
WHERE geometry && bbox
|
WHERE geometry && bbox
|
||||||
AND (
|
AND (
|
||||||
(zoom_level BETWEEN 9 AND 13 AND area > 70000 * 2 ^ (20 - zoom_level))
|
-- Show a label if a water feature covers at least 1/4 of a tile or z14+
|
||||||
|
(tags->'place' IN ('sea', 'ocean') AND POWER(4,zoom_level) * earth_area > 0.25)
|
||||||
|
OR (zoom_level BETWEEN 3 AND 13 AND POWER(4,zoom_level) * earth_area > 0.25)
|
||||||
OR (zoom_level >= 14)
|
OR (zoom_level >= 14)
|
||||||
)
|
)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -65,15 +67,15 @@ SELECT
|
||||||
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
||||||
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
||||||
tags,
|
tags,
|
||||||
place::text AS class,
|
COALESCE(NULLIF("natural",''), "place") AS class,
|
||||||
is_intermittent::int AS intermittent
|
is_intermittent::int AS intermittent
|
||||||
FROM osm_marine_point
|
FROM osm_marine_point
|
||||||
WHERE geometry && bbox
|
WHERE geometry && bbox
|
||||||
AND (
|
AND CASE
|
||||||
place = 'ocean'
|
WHEN place = 'ocean' THEN TRUE
|
||||||
OR (zoom_level >= "rank" AND "rank" IS NOT NULL)
|
WHEN zoom_level >= "rank" AND "rank" IS NOT NULL THEN TRUE
|
||||||
OR (zoom_level >= 8)
|
WHEN "natural" = 'bay' THEN zoom_level >= 13
|
||||||
);
|
ELSE zoom_level >= 8 END;
|
||||||
$$ LANGUAGE SQL STABLE
|
$$ LANGUAGE SQL STABLE
|
||||||
-- STRICT
|
-- STRICT
|
||||||
PARALLEL SAFE;
|
PARALLEL SAFE;
|
||||||
|
|
|
@ -14,9 +14,11 @@ layer:
|
||||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||||
class:
|
class:
|
||||||
description: |
|
description: |
|
||||||
Distinguish between `lake`, `ocean` and `sea`.
|
Distinguish between `lake`, `ocean`, `bay`, `strait`, and `sea`.
|
||||||
values:
|
values:
|
||||||
- lake
|
- lake
|
||||||
|
- bay
|
||||||
|
- strait
|
||||||
- sea
|
- sea
|
||||||
- ocean
|
- ocean
|
||||||
intermittent:
|
intermittent:
|
||||||
|
|
Ładowanie…
Reference in New Issue