kopia lustrzana https://github.com/openmaptiles/openmaptiles
Support motorway highway labels for lower zooms
rodzic
c85f60ff50
commit
eecb853a60
|
@ -10,7 +10,7 @@ layer:
|
|||
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
|
||||
query: (SELECT osm_id, geometry, name, ref, class::text, subclass FROM layer_highway_name(!bbox!, z(!scale_denominator!))) AS t
|
||||
schema:
|
||||
- ./merge_highways.sql
|
||||
- ./layer.sql
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
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)
|
||||
RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, class highway_class, subclass text) AS $$
|
||||
SELECT osm_id, geometry, name, ref, to_highway_class(highway) AS class, highway AS subclass FROM (
|
||||
SELECT * FROM osm_highway_name_linestring_gen3
|
||||
WHERE zoom_level = 8
|
||||
UNION ALL
|
||||
SELECT * FROM osm_highway_name_linestring_gen2
|
||||
WHERE zoom_level = 9
|
||||
UNION ALL
|
||||
SELECT * FROM osm_highway_name_linestring_gen1
|
||||
WHERE zoom_level BETWEEN 10 AND 11
|
||||
UNION ALL
|
||||
SELECT * FROM osm_highway_name_linestring
|
||||
WHERE zoom_level = 13 AND to_highway_class(highway) < 'path'::highway_class
|
||||
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
|
||||
WHERE geometry && bbox AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry)
|
||||
ORDER BY z_order ASC;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
|
|
|
@ -10,20 +10,43 @@ CREATE TABLE IF NOT EXISTS osm_highway_name_linestring AS (
|
|||
member_osm_ids[0] AS osm_id,
|
||||
member_osm_ids,
|
||||
name,
|
||||
ref,
|
||||
highway,
|
||||
z_order
|
||||
FROM (
|
||||
SELECT
|
||||
ST_LineMerge(ST_Union(geometry)) AS geometry,
|
||||
name,
|
||||
ref,
|
||||
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
|
||||
WHERE name <> '' OR ref <> ''
|
||||
GROUP BY name, highway, ref
|
||||
) AS highway_union
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_geometry_idx ON osm_important_place_point USING gist(geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_geometry_idx ON osm_highway_name_linestring USING gist(geometry);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen1 AS (
|
||||
SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_highway_name_linestring
|
||||
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen1_geometry_idx ON osm_highway_name_linestring_gen1 USING gist(geometry);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen2 AS (
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_highway_name_linestring_gen1
|
||||
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen2_geometry_idx ON osm_highway_name_linestring_gen2 USING gist(geometry);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen3 AS (
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order
|
||||
FROM osm_highway_name_linestring_gen2
|
||||
WHERE highway = 'motorway' AND ST_Length(geometry) > 20000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen3_geometry_idx ON osm_highway_name_linestring_gen3 USING gist(geometry);
|
||||
|
|
Ładowanie…
Reference in New Issue