kopia lustrzana https://github.com/openmaptiles/openmaptiles
Add highway names
rodzic
9fa3d4b5a0
commit
8fb9c45fc1
|
@ -0,0 +1,19 @@
|
||||||
|
layer:
|
||||||
|
id: "highway_name"
|
||||||
|
description: |
|
||||||
|
[OpenStreetMap highway] which is used for roads, paths and cycletracks
|
||||||
|
and other recognised routes on land.
|
||||||
|
buffer_size: 8
|
||||||
|
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
|
||||||
|
fields:
|
||||||
|
class: String
|
||||||
|
datasource:
|
||||||
|
geometry_field: geometry
|
||||||
|
srid: 900913
|
||||||
|
query: (SELECT osm_id, geometry, name, class::text, subclass FROM layer_highway_name(!bbox!, z(!scale_denominator!))) AS t
|
||||||
|
schema:
|
||||||
|
- ./merge_highways.sql
|
||||||
|
- ./layer.sql
|
||||||
|
datasources:
|
||||||
|
- type: imposm3
|
||||||
|
mapping_file: ../highway/mapping.yaml
|
|
@ -0,0 +1,15 @@
|
||||||
|
CREATE OR REPLACE FUNCTION layer_highway_name(bbox geometry, zoom_level integer)
|
||||||
|
RETURNS TABLE(osm_id bigint, geometry geometry, name text, class highway_class, subclass text) AS $$
|
||||||
|
SELECT osm_id, geometry, name, to_highway_class(highway) AS class, highway AS subclass FROM (
|
||||||
|
SELECT * FROM osm_highway_name_linestring
|
||||||
|
WHERE zoom_level = 12 AND to_highway_class(highway) < 'minor_road'::highway_class AND NOT highway_is_link(highway)
|
||||||
|
UNION ALL
|
||||||
|
SELECT * FROM osm_highway_name_linestring
|
||||||
|
WHERE zoom_level = 13 AND to_highway_class(highway) < 'path'::highway_class
|
||||||
|
UNION ALL
|
||||||
|
SELECT * FROM osm_highway_name_linestring
|
||||||
|
WHERE zoom_level >= 14
|
||||||
|
) AS zoom_levels
|
||||||
|
WHERE geometry && bbox
|
||||||
|
ORDER BY z_order ASC;
|
||||||
|
$$ LANGUAGE SQL IMMUTABLE;
|
|
@ -0,0 +1,29 @@
|
||||||
|
-- Instead of using relations to find out the road names we
|
||||||
|
-- stitch together the touching ways with the same name
|
||||||
|
-- to allow for nice label rendering
|
||||||
|
-- Because this works well for roads that do not have relations as well
|
||||||
|
CREATE TABLE IF NOT EXISTS osm_highway_name_linestring AS (
|
||||||
|
SELECT
|
||||||
|
(ST_Dump(geometry)).geom AS geometry,
|
||||||
|
-- NOTE: The osm_id is no longer the original one which can make it difficult
|
||||||
|
-- to lookup road names by OSM ID
|
||||||
|
member_osm_ids[0] AS osm_id,
|
||||||
|
member_osm_ids,
|
||||||
|
name,
|
||||||
|
highway,
|
||||||
|
z_order
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
ST_LineMerge(ST_Union(geometry)) AS geometry,
|
||||||
|
name,
|
||||||
|
highway,
|
||||||
|
min(z_order) AS z_order,
|
||||||
|
array_agg(DISTINCT osm_id) AS member_osm_ids
|
||||||
|
FROM osm_highway_linestring
|
||||||
|
-- We only care about roads for labelling
|
||||||
|
WHERE name <> ''
|
||||||
|
GROUP BY name, highway
|
||||||
|
) AS highway_union
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_geometry_idx ON osm_important_place_point USING gist(geometry);
|
Ładowanie…
Reference in New Issue