Support motorway highway labels for lower zooms
This commit is contained in:
parent
c85f60ff50
commit
eecb853a60
@ -10,7 +10,7 @@ layer:
|
|||||||
datasource:
|
datasource:
|
||||||
geometry_field: geometry
|
geometry_field: geometry
|
||||||
srid: 900913
|
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:
|
schema:
|
||||||
- ./merge_highways.sql
|
- ./merge_highways.sql
|
||||||
- ./layer.sql
|
- ./layer.sql
|
||||||
|
|||||||
@ -1,15 +1,27 @@
|
|||||||
CREATE OR REPLACE FUNCTION layer_highway_name(bbox geometry, zoom_level integer)
|
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 $$
|
RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, class highway_class, subclass text) AS $$
|
||||||
SELECT osm_id, geometry, name, to_highway_class(highway) AS class, highway AS subclass FROM (
|
SELECT osm_id, geometry, name, ref, to_highway_class(highway) AS class, highway AS subclass FROM (
|
||||||
SELECT * FROM osm_highway_name_linestring
|
SELECT * FROM osm_highway_name_linestring_gen3
|
||||||
WHERE zoom_level = 12 AND to_highway_class(highway) < 'minor_road'::highway_class AND NOT highway_is_link(highway)
|
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
|
UNION ALL
|
||||||
SELECT * FROM osm_highway_name_linestring
|
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
|
UNION ALL
|
||||||
SELECT * FROM osm_highway_name_linestring
|
SELECT * FROM osm_highway_name_linestring
|
||||||
WHERE zoom_level >= 14
|
WHERE zoom_level >= 14
|
||||||
) AS zoom_levels
|
) AS zoom_levels
|
||||||
WHERE geometry && bbox
|
WHERE geometry && bbox AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry)
|
||||||
ORDER BY z_order ASC;
|
ORDER BY z_order ASC;
|
||||||
$$ LANGUAGE SQL IMMUTABLE;
|
$$ 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[0] AS osm_id,
|
||||||
member_osm_ids,
|
member_osm_ids,
|
||||||
name,
|
name,
|
||||||
|
ref,
|
||||||
highway,
|
highway,
|
||||||
z_order
|
z_order
|
||||||
FROM (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
ST_LineMerge(ST_Union(geometry)) AS geometry,
|
ST_LineMerge(ST_Union(geometry)) AS geometry,
|
||||||
name,
|
name,
|
||||||
|
ref,
|
||||||
highway,
|
highway,
|
||||||
min(z_order) AS z_order,
|
min(z_order) AS z_order,
|
||||||
array_agg(DISTINCT osm_id) AS member_osm_ids
|
array_agg(DISTINCT osm_id) AS member_osm_ids
|
||||||
FROM osm_highway_linestring
|
FROM osm_highway_linestring
|
||||||
-- We only care about roads for labelling
|
-- We only care about roads for labelling
|
||||||
WHERE name <> ''
|
WHERE name <> '' OR ref <> ''
|
||||||
GROUP BY name, highway
|
GROUP BY name, highway, ref
|
||||||
) AS highway_union
|
) 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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user