kopia lustrzana https://github.com/openmaptiles/openmaptiles
Add enhanced mountain features (#1202)
This PR adds support for several features in the `natural` key, including `saddle`, `ridge`, `arete`, and `cliff`. These features all currently render in openstreetmap-carto, so adding these features would advance OpenMapTiles towards its goal of parity with the standard renderer, as indicated in https://github.com/openstreetmap/operations/issues/565#issuecomment-907303115. This PR also adds the features requested in #274, with the exception of valleys, which I've left out of this PR because there are different complexities to mapping valleys that should be addressed as a separate (future) PR. ### Examples of mountain features in paper maps These features are regularly found in American-style maps and thus is of interest to the openstreetmap-americana map style. Below are examples of these mountain-related features found in general purpose maps: <img src="https://user-images.githubusercontent.com/3254090/131270340-af80c7bf-9416-40a3-9b64-56418abb2aef.png" width=400/> <img src="https://user-images.githubusercontent.com/3254090/131270375-b9eb2095-7708-443d-b7bc-22bf8adab721.png" width=400/> <img src="https://user-images.githubusercontent.com/3254090/131270423-64447ad3-d90a-4615-82e1-91175a8f8a6b.png" width=400/> <img src="https://user-images.githubusercontent.com/3254090/131270506-2248db9f-ded5-443f-82ed-b0e8d4d12a70.png" width=400/> ### Approach This PR extends the existing `mountain_peak` layer by adding other mountain features. We may want to consider renaming this layer in version 4.0 to be more inclusive of other mountain features including the potential future addition of valleys. However, the features added in this PR are associated with mountains and so their inclusion in this layer is the most appropriate location. A new `osm_mountain_linestring` mapping maps the new linear mountain features, with similar ranking logic as is used for the existing `peak`/`volcano` features. Additionally, `natural=saddle` is added to the `osm_peak_point` mapping and ranked using the formula for peaks. Since saddles will have lower elevations than peaks, important saddles will be preempted by important peaks. The new linestring features are rendered only at zoom 13-14, in order to match the zoom at which they appear in openstreetmap-carto. However, it may be appropriate in a future PR to extend the rendering of these features as generalized linestrings at lower zooms. ### Test Renderings Below is a test rendering showing aretes and peaks in Austria, just north of the Swiss border, followed by a screen shot of the [same location](https://www.openstreetmap.org/#map=14/46.8682/10.0863) in openstreetmap-carto: **OpenMapTiles, zoom 14** <img src="https://user-images.githubusercontent.com/3254090/131271258-5cd90bdb-cac2-41d8-887f-b4bf6be83673.png" width=400/> **openstreetmap-carto, zoom r14/v13:** <img src="https://user-images.githubusercontent.com/3254090/131271332-32d5bcfc-41c6-4625-829c-df063b7af523.png" width=400/>pull/1205/head^2
rodzic
910db7f60c
commit
f947cbffc3
Plik binarny nie jest wyświetlany.
Przed Szerokość: | Wysokość: | Rozmiar: 16 KiB Po Szerokość: | Wysokość: | Rozmiar: 28 KiB |
|
@ -29,3 +29,32 @@ tables:
|
|||
natural:
|
||||
- peak
|
||||
- volcano
|
||||
- saddle
|
||||
|
||||
# etldoc: imposm3 -> osm_mountain_linestring
|
||||
mountain_linestring:
|
||||
type: linestring
|
||||
columns:
|
||||
- name: osm_id
|
||||
type: id
|
||||
- name: geometry
|
||||
type: geometry
|
||||
- name: name
|
||||
key: name
|
||||
type: string
|
||||
- name: name_en
|
||||
key: name:en
|
||||
type: string
|
||||
- name: name_de
|
||||
key: name:de
|
||||
type: string
|
||||
- name: tags
|
||||
type: hstore_tags
|
||||
- name: wikipedia
|
||||
key: wikipedia
|
||||
type: string
|
||||
mapping:
|
||||
natural:
|
||||
- ridge
|
||||
- cliff
|
||||
- arete
|
||||
|
|
Plik binarny nie jest wyświetlany.
Przed Szerokość: | Wysokość: | Rozmiar: 4.7 KiB Po Szerokość: | Wysokość: | Rozmiar: 14 KiB |
|
@ -55,6 +55,39 @@ FROM (
|
|||
) AS ranked_peaks
|
||||
WHERE zoom_level >= 7
|
||||
AND (rank <= 5 OR zoom_level >= 14)
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
-- etldoc: osm_mountain_linestring -> layer_mountain_peak:z13_
|
||||
osm_id,
|
||||
geometry,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags->'natural' AS class,
|
||||
tags,
|
||||
NULL AS ele,
|
||||
NULL AS ele_ft,
|
||||
rank::int
|
||||
FROM (
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
name,
|
||||
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
||||
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
||||
tags,
|
||||
row_number() OVER (
|
||||
PARTITION BY LabelGrid(geometry, 100 * pixel_width)
|
||||
ORDER BY (
|
||||
(CASE WHEN NULLIF(wikipedia, '') IS NOT NULL THEN 10000 ELSE 0 END) +
|
||||
(CASE WHEN NULLIF(name, '') IS NOT NULL THEN 10000 ELSE 0 END)
|
||||
) DESC
|
||||
)::int AS "rank"
|
||||
FROM osm_mountain_linestring
|
||||
WHERE geometry && bbox
|
||||
) AS ranked_mountain_linestring
|
||||
WHERE zoom_level >= 13
|
||||
ORDER BY "rank" ASC;
|
||||
|
||||
$$ LANGUAGE SQL STABLE
|
||||
|
|
|
@ -14,6 +14,9 @@ layer:
|
|||
values:
|
||||
- peak
|
||||
- volcano
|
||||
- ridge
|
||||
- cliff
|
||||
- arete
|
||||
ele: Elevation (`ele`) in meters.
|
||||
ele_ft: Elevation (`ele`) in feet.
|
||||
rank: Rank of the peak within one tile (starting at 1 that is the most important peak).
|
||||
|
@ -25,6 +28,7 @@ layer:
|
|||
query: (SELECT osm_id, geometry, name, name_en, name_de, {name_languages}, class, ele, ele_ft, rank FROM layer_mountain_peak(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t
|
||||
schema:
|
||||
- ./update_peak_point.sql
|
||||
- ./update_mountain_linestring.sql
|
||||
- ./mountain_peak.sql
|
||||
datasources:
|
||||
- type: imposm3
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
DROP TRIGGER IF EXISTS trigger_flag ON osm_mountain_linestring;
|
||||
DROP TRIGGER IF EXISTS trigger_store ON osm_mountain_linestring;
|
||||
DROP TRIGGER IF EXISTS trigger_refresh ON mountain_linestring.updates;
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS mountain_linestring;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS mountain_linestring.osm_ids
|
||||
(
|
||||
osm_id bigint
|
||||
);
|
||||
|
||||
-- etldoc: osm_mountain_linestring -> osm_mountain_linestring
|
||||
CREATE OR REPLACE FUNCTION update_osm_mountain_linestring(full_update boolean) RETURNS void AS
|
||||
$$
|
||||
UPDATE osm_mountain_linestring
|
||||
SET tags = update_tags(tags, geometry)
|
||||
WHERE (full_update OR osm_id IN (SELECT osm_id FROM mountain_linestring.osm_ids))
|
||||
AND COALESCE(tags -> 'name:latin', tags -> 'name:nonlatin', tags -> 'name_int') IS NULL
|
||||
AND tags != update_tags(tags, geometry)
|
||||
$$ LANGUAGE SQL;
|
||||
|
||||
SELECT update_osm_mountain_linestring(true);
|
||||
|
||||
-- Handle updates
|
||||
|
||||
CREATE OR REPLACE FUNCTION mountain_linestring.store() RETURNS trigger AS
|
||||
$$
|
||||
BEGIN
|
||||
IF (tg_op = 'DELETE') THEN
|
||||
INSERT INTO mountain_linestring.osm_ids VALUES (OLD.osm_id);
|
||||
ELSE
|
||||
INSERT INTO mountain_linestring.osm_ids VALUES (NEW.osm_id);
|
||||
END IF;
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS mountain_linestring.updates
|
||||
(
|
||||
id serial PRIMARY KEY,
|
||||
t text,
|
||||
UNIQUE (t)
|
||||
);
|
||||
CREATE OR REPLACE FUNCTION mountain_linestring.flag() RETURNS trigger AS
|
||||
$$
|
||||
BEGIN
|
||||
INSERT INTO mountain_linestring.updates(t) VALUES ('y') ON CONFLICT(t) DO NOTHING;
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION mountain_linestring.refresh() RETURNS trigger AS
|
||||
$$
|
||||
DECLARE
|
||||
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
|
||||
BEGIN
|
||||
RAISE LOG 'Refresh mountain_linestring';
|
||||
PERFORM update_osm_mountain_linestring(false);
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM mountain_linestring.osm_ids;
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM mountain_linestring.updates;
|
||||
|
||||
RAISE LOG 'Refresh mountain_linestring done in %', age(clock_timestamp(), t);
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON osm_mountain_linestring
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE mountain_linestring.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON osm_mountain_linestring
|
||||
FOR EACH STATEMENT
|
||||
EXECUTE PROCEDURE mountain_linestring.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
AFTER INSERT
|
||||
ON mountain_linestring.updates
|
||||
INITIALLY DEFERRED
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE mountain_linestring.refresh();
|
Ładowanie…
Reference in New Issue