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
|
||||
- name: tags
|
||||
type: hstore_tags
|
||||
- name: place
|
||||
key: place
|
||||
type: string
|
||||
- name: natural
|
||||
key: natural
|
||||
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
|
||||
key: place
|
||||
type: string
|
||||
- name: natural
|
||||
key: natural
|
||||
type: string
|
||||
- name: rank
|
||||
key: rank
|
||||
type: integer
|
||||
|
@ -34,3 +37,6 @@ tables:
|
|||
place:
|
||||
- ocean
|
||||
- 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_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
|
||||
SELECT wp.osm_id,
|
||||
ST_PointOnSurface(wp.geometry) AS geometry,
|
||||
wp.name,
|
||||
wp.name_en,
|
||||
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,
|
||||
ST_Area(wp.geometry) AS area,
|
||||
-- Area of the feature in square meters
|
||||
ST_Area(wp.geometry) as area,
|
||||
wp.is_intermittent
|
||||
FROM osm_water_polygon AS wp
|
||||
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 ST_IsValid(wp.geometry);
|
||||
|
||||
-- etldoc: osm_water_polygon -> osm_water_point
|
||||
-- etldoc: lake_centerline -> osm_water_point
|
||||
-- etldoc: osm_water_point_view -> osm_water_point_earth_view
|
||||
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
|
||||
SELECT *
|
||||
FROM osm_water_point_view;
|
||||
FROM osm_water_point_earth_view;
|
||||
DO
|
||||
$$
|
||||
BEGIN
|
||||
|
|
|
@ -46,12 +46,14 @@ SELECT
|
|||
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
||||
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
||||
tags,
|
||||
'lake'::text AS class,
|
||||
class,
|
||||
is_intermittent::int AS intermittent
|
||||
FROM osm_water_point
|
||||
WHERE geometry && bbox
|
||||
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)
|
||||
)
|
||||
UNION ALL
|
||||
|
@ -65,15 +67,15 @@ SELECT
|
|||
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
||||
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
||||
tags,
|
||||
place::text AS class,
|
||||
COALESCE(NULLIF("natural",''), "place") AS class,
|
||||
is_intermittent::int AS intermittent
|
||||
FROM osm_marine_point
|
||||
WHERE geometry && bbox
|
||||
AND (
|
||||
place = 'ocean'
|
||||
OR (zoom_level >= "rank" AND "rank" IS NOT NULL)
|
||||
OR (zoom_level >= 8)
|
||||
);
|
||||
AND CASE
|
||||
WHEN place = 'ocean' THEN TRUE
|
||||
WHEN zoom_level >= "rank" AND "rank" IS NOT NULL THEN TRUE
|
||||
WHEN "natural" = 'bay' THEN zoom_level >= 13
|
||||
ELSE zoom_level >= 8 END;
|
||||
$$ LANGUAGE SQL STABLE
|
||||
-- STRICT
|
||||
PARALLEL SAFE;
|
||||
|
|
|
@ -14,9 +14,11 @@ layer:
|
|||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||
class:
|
||||
description: |
|
||||
Distinguish between `lake`, `ocean` and `sea`.
|
||||
Distinguish between `lake`, `ocean`, `bay`, `strait`, and `sea`.
|
||||
values:
|
||||
- lake
|
||||
- bay
|
||||
- strait
|
||||
- sea
|
||||
- ocean
|
||||
intermittent:
|
||||
|
|
Ładowanie…
Reference in New Issue