[WIP] Expanded road route attributes (#1620)

This PR replaces the `route_N` attribute scheme with individual attributes for name and colour on routes.  Thus you will have:
* `route_N_network` to hold the route `network` value
* `route_N_ref` to hold the route `ref` value
* `route_N_name` to hold the route `name` value
* `route_N_colour` to hold the route `colour` or `ref:colour` value
pull/1635/head
Brian Sperlongano 2024-02-20 11:38:11 -05:00 zatwierdzone przez GitHub
rodzic ee8259ced5
commit b3c32321a3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
7 zmienionych plików z 154 dodań i 81 usunięć

Wyświetl plik

@ -102,10 +102,6 @@ name_de_field: &name_de
name: name_de
key: name:de
type: string
short_name_field: &short_name
key: short_name
name: short_name
type: string
tunnel_field: &tunnel
key: tunnel
name: is_tunnel
@ -236,7 +232,6 @@ tables:
- *name_de
- name: tags
type: hstore_tags
- *short_name
- *tunnel
- *bridge
- *ramp
@ -316,7 +311,6 @@ tables:
- *name_de
- name: tags
type: hstore_tags
- *short_name
- *tunnel
- *bridge
- *ramp
@ -354,7 +348,6 @@ tables:
- *name_de
- name: tags
type: hstore_tags
- *short_name
- *tunnel
- *bridge
- *ramp
@ -393,7 +386,6 @@ tables:
- *name_de
- name: tags
type: hstore_tags
- *short_name
- *tunnel
- *bridge
- *ramp
@ -491,6 +483,9 @@ tables:
- name: colour
key: colour
type: string
- name: ref_colour
key: ref:colour
type: string
mapping:
route:
- road

Wyświetl plik

@ -39,3 +39,15 @@ $$
);
$$ LANGUAGE sql IMMUTABLE
PARALLEL SAFE;
CREATE OR REPLACE FUNCTION create_route_hstore(network TEXT, ref TEXT, name TEXT, colour TEXT, ref_colour TEXT)
RETURNS hstore AS $$
SELECT CASE
WHEN network = '' THEN hstore('')
ELSE hstore(
ARRAY['network', 'ref', 'name', 'colour'],
ARRAY[network, NULLIF(ref, ''), NULLIF(name, ''), COALESCE(NULLIF(colour, ''), NULLIF(ref_colour, ''))]
)
END;
$$ LANGUAGE sql IMMUTABLE
PARALLEL SAFE;

Wyświetl plik

@ -90,6 +90,7 @@ CREATE TABLE IF NOT EXISTS transportation_route_member_coalesced
name varchar,
osmc_symbol varchar,
colour varchar,
ref_colour varchar,
network_type route_network_type,
concurrency_index integer,
rank integer,
@ -164,7 +165,8 @@ BEGIN
type,
name,
osmc_symbol,
colour
colour,
ref_colour
FROM osm_route_member
WHERE full_update OR EXISTS(
SELECT NULL
@ -174,7 +176,7 @@ BEGIN
) osm_route_member_filtered
ON CONFLICT (member, network, ref) DO UPDATE SET osm_id = EXCLUDED.osm_id, role = EXCLUDED.role,
type = EXCLUDED.type, name = EXCLUDED.name,
osmc_symbol = EXCLUDED.osmc_symbol, colour = EXCLUDED.colour,
osmc_symbol = EXCLUDED.osmc_symbol, colour = EXCLUDED.colour, ref_colour = EXCLUDED.ref_colour,
concurrency_index = EXCLUDED.concurrency_index,
rank = EXCLUDED.rank;
END;

Wyświetl plik

@ -84,12 +84,12 @@ FROM (
CASE WHEN highway IN ('footway', 'steps') THEN layer END AS layer,
CASE WHEN highway IN ('footway', 'steps') THEN level END AS level,
CASE WHEN highway IN ('footway', 'steps') THEN indoor END AS indoor,
NULLIF(rm1.network, '') || '=' || COALESCE(rm1.ref, '') AS route_1,
NULLIF(rm2.network, '') || '=' || COALESCE(rm2.ref, '') AS route_2,
NULLIF(rm3.network, '') || '=' || COALESCE(rm3.ref, '') AS route_3,
NULLIF(rm4.network, '') || '=' || COALESCE(rm4.ref, '') AS route_4,
NULLIF(rm5.network, '') || '=' || COALESCE(rm5.ref, '') AS route_5,
NULLIF(rm6.network, '') || '=' || COALESCE(rm6.ref, '') AS route_6,
create_route_hstore(rm1.network, rm1.ref, rm1.name, rm1.colour, rm1.ref_colour) AS route_1,
create_route_hstore(rm2.network, rm2.ref, rm2.name, rm2.colour, rm2.ref_colour) AS route_2,
create_route_hstore(rm3.network, rm3.ref, rm3.name, rm3.colour, rm3.ref_colour) AS route_3,
create_route_hstore(rm4.network, rm4.ref, rm4.name, rm4.colour, rm4.ref_colour) AS route_4,
create_route_hstore(rm5.network, rm5.ref, rm5.name, rm5.colour, rm5.ref_colour) AS route_5,
create_route_hstore(rm6.network, rm6.ref, rm6.name, rm6.colour, rm6.ref_colour) AS route_6,
hl.z_order,
LEAST(rm1.rank, rm2.rank, rm3.rank, rm4.rank, rm5.rank, rm6.rank) AS route_rank
FROM osm_highway_linestring hl

Wyświetl plik

@ -4,26 +4,44 @@
CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level integer)
RETURNS TABLE
(
geometry geometry,
name text,
name_en text,
name_de text,
tags hstore,
ref text,
ref_length int,
network text,
route_1 text,
route_2 text,
route_3 text,
route_4 text,
route_5 text,
route_6 text,
class text,
subclass text,
brunnel text,
layer int,
level int,
indoor int
geometry geometry,
name text,
name_en text,
name_de text,
tags hstore,
ref text,
ref_length int,
network text,
route_1_network text,
route_1_ref text,
route_1_name text,
route_1_colour text,
route_2_network text,
route_2_ref text,
route_2_name text,
route_2_colour text,
route_3_network text,
route_3_ref text,
route_3_name text,
route_3_colour text,
route_4_network text,
route_4_ref text,
route_4_name text,
route_4_colour text,
route_5_network text,
route_5_ref text,
route_5_name text,
route_5_colour text,
route_6_network text,
route_6_ref text,
route_6_name text,
route_6_colour text,
class text,
subclass text,
brunnel text,
layer int,
level int,
indoor int
)
AS
$$
@ -40,7 +58,35 @@ SELECT geometry,
WHEN length(coalesce(ref, '')) > 0
THEN 'road'
END AS network,
route_1, route_2, route_3, route_4, route_5, route_6,
route_1->'network' AS route_1_network,
route_1->'ref' AS route_1_ref,
route_1->'name' AS route_1_name,
route_1->'colour' AS route_1_colour,
route_2->'network' AS route_2_network,
route_2->'ref' AS route_2_ref,
route_2->'name' AS route_2_name,
route_2->'colour' AS route_2_colour,
route_3->'network' AS route_3_network,
route_3->'ref' AS route_3_ref,
route_3->'name' AS route_3_name,
route_3->'colour' AS route_3_colour,
route_4->'network' AS route_4_network,
route_4->'ref' AS route_4_ref,
route_4->'name' AS route_4_name,
route_4->'colour' AS route_4_colour,
route_5->'network' AS route_5_network,
route_5->'ref' AS route_5_ref,
route_5->'name' AS route_5_name,
route_5->'colour' AS route_5_colour,
route_6->'network' AS route_6_network,
route_6->'ref' AS route_6_ref,
route_6->'name' AS route_6_name,
route_6->'colour' AS route_6_colour,
highway_class(highway, '', subclass) AS class,
CASE
WHEN highway IS NOT NULL AND highway_class(highway, '', subclass) = 'path'
@ -225,12 +271,12 @@ FROM (
'junction'::text AS subclass,
NULL AS brunnel,
NULL AS network,
NULL::text AS route_1,
NULL::text AS route_2,
NULL::text AS route_3,
NULL::text AS route_4,
NULL::text AS route_5,
NULL::text AS route_6,
NULL::hstore AS route_1,
NULL::hstore AS route_2,
NULL::hstore AS route_3,
NULL::hstore AS route_4,
NULL::hstore AS route_5,
NULL::hstore AS route_6,
z_order,
layer,
NULL::int AS level,

Wyświetl plik

@ -101,16 +101,34 @@ layer:
value of [`indoor`](http://wiki.openstreetmap.org/wiki/Key:indoor) tag.
values:
- 1
route_1: 1st route concurrency.
route_2: 2nd route concurrency.
route_3: 3rd route concurrency.
route_4: 4th route concurrency.
route_5: 5th route concurrency.
route_6: 6th route concurrency.
route_1_network: 1st route concurrency network.
route_1_ref: 1st route concurrency ref.
route_1_name: 1st route concurrency name.
route_1_colour: 1st route concurrency colour.
route_2_network: 2nd route concurrency network.
route_2_ref: 2nd route concurrency ref.
route_2_name: 2nd route concurrency name.
route_2_colour: 2nd route concurrency colour.
route_3_network: 3rd route concurrency network.
route_3_ref: 3rd route concurrency ref.
route_3_name: 3rd route concurrency name.
route_3_colour: 3rd route concurrency colour.
route_4_network: 4th route concurrency network.
route_4_ref: 4th route concurrency ref.
route_4_name: 4th route concurrency name.
route_4_colour: 4th route concurrency colour.
route_5_network: 5th route concurrency network.
route_5_ref: 5th route concurrency ref.
route_5_name: 5th route concurrency name.
route_5_colour: 5th route concurrency colour.
route_6_network: 6th route concurrency network.
route_6_ref: 6th route concurrency ref.
route_6_name: 6th route concurrency name.
route_6_colour: 6th route concurrency colour.
datasource:
geometry_field: geometry
srid: 900913
query: (SELECT geometry, name, name_en, name_de, {name_languages}, ref, ref_length, network::text, class::text, subclass, brunnel, layer, level, indoor, route_1, route_2, route_3, route_4, route_5, route_6 FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
query: (SELECT geometry, name, name_en, name_de, {name_languages}, ref, ref_length, network::text, class::text, subclass, brunnel, layer, level, indoor, route_1_network, route_1_ref, route_1_name, route_1_colour, route_2_network, route_2_ref, route_2_name, route_2_colour, route_3_network, route_3_ref, route_3_name, route_3_colour, route_4_network, route_4_ref, route_4_name, route_4_colour, route_5_network, route_5_ref, route_5_name, route_5_colour, route_6_network, route_6_ref, route_6_name, route_6_colour FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
schema:
- ./highway_classification.sql
- ./update_transportation_name.sql

Wyświetl plik

@ -51,12 +51,12 @@ CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring(
layer integer,
indoor boolean,
network route_network_type,
route_1 text,
route_2 text,
route_3 text,
route_4 text,
route_5 text,
route_6 text,
route_1 hstore,
route_2 hstore,
route_3 hstore,
route_4 hstore,
route_5 hstore,
route_6 hstore,
z_order integer,
route_rank integer
);
@ -170,12 +170,12 @@ FROM (
layer,
NULL AS indoor,
NULL AS network_type,
NULL AS route_1,
NULL AS route_2,
NULL AS route_3,
NULL AS route_4,
NULL AS route_5,
NULL AS route_6,
NULL::hstore AS route_1,
NULL::hstore AS route_2,
NULL::hstore AS route_3,
NULL::hstore AS route_4,
NULL::hstore AS route_5,
NULL::hstore AS route_6,
min(z_order) AS z_order,
NULL::int AS route_rank
FROM (
@ -228,12 +228,12 @@ FROM (
layer,
NULL AS indoor,
NULL AS network_type,
NULL AS route_1,
NULL AS route_2,
NULL AS route_3,
NULL AS route_4,
NULL AS route_5,
NULL AS route_6,
NULL::hstore AS route_1,
NULL::hstore AS route_2,
NULL::hstore AS route_3,
NULL::hstore AS route_4,
NULL::hstore AS route_5,
NULL::hstore AS route_6,
min(z_order) AS z_order,
NULL::int AS route_rank
FROM (
@ -276,12 +276,12 @@ CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen1 (
subclass text,
brunnel text,
network route_network_type,
route_1 text,
route_2 text,
route_3 text,
route_4 text,
route_5 text,
route_6 text,
route_1 hstore,
route_2 hstore,
route_3 hstore,
route_4 hstore,
route_5 hstore,
route_6 hstore,
z_order integer
);
@ -752,13 +752,13 @@ BEGIN
CASE WHEN highway IN ('footway', 'steps') THEN layer END AS layer,
CASE WHEN highway IN ('footway', 'steps') THEN level END AS level,
CASE WHEN highway IN ('footway', 'steps') THEN indoor END AS indoor,
NULLIF(rm1.network, '') || '=' || COALESCE(rm1.ref, '') AS route_1,
NULLIF(rm2.network, '') || '=' || COALESCE(rm2.ref, '') AS route_2,
NULLIF(rm3.network, '') || '=' || COALESCE(rm3.ref, '') AS route_3,
NULLIF(rm4.network, '') || '=' || COALESCE(rm4.ref, '') AS route_4,
NULLIF(rm5.network, '') || '=' || COALESCE(rm5.ref, '') AS route_5,
NULLIF(rm6.network, '') || '=' || COALESCE(rm6.ref, '') AS route_6,
hl.z_order,
create_route_hstore(rm1.network, rm1.ref, rm1.name, rm1.colour, rm1.ref_colour) AS route_1,
create_route_hstore(rm2.network, rm2.ref, rm2.name, rm2.colour, rm2.ref_colour) AS route_2,
create_route_hstore(rm3.network, rm3.ref, rm3.name, rm3.colour, rm3.ref_colour) AS route_3,
create_route_hstore(rm4.network, rm4.ref, rm4.name, rm4.colour, rm4.ref_colour) AS route_4,
create_route_hstore(rm5.network, rm5.ref, rm5.name, rm5.colour, rm5.ref_colour) AS route_5,
create_route_hstore(rm6.network, rm6.ref, rm6.name, rm6.colour, rm6.ref_colour) AS route_6,
hl.z_order,
LEAST(rm1.rank, rm2.rank, rm3.rank, rm4.rank, rm5.rank, rm6.rank) AS route_rank
FROM osm_highway_linestring hl
JOIN transportation_name.network_changes AS c ON