From c212d1c25095f3b6e2f88cfccdc5c49280b22be0 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Wed, 13 Dec 2017 13:07:07 +0000 Subject: [PATCH 1/5] Add test for tilequeue changes related to #1387. --- integration-test/1387-business-and-spur-routes.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 integration-test/1387-business-and-spur-routes.py diff --git a/integration-test/1387-business-and-spur-routes.py b/integration-test/1387-business-and-spur-routes.py new file mode 100644 index 000000000..03a494211 --- /dev/null +++ b/integration-test/1387-business-and-spur-routes.py @@ -0,0 +1,15 @@ +from . import FixtureTest + + +class BusinessAndSpurRoutes(FixtureTest): + + def test_first_capitol_dr_i70_business(self): + self.load_fixtures([ + 'https://www.openstreetmap.org/relation/1933234', + ]) + + # check that First Capitol Dr, part of the above relation, is given + # a network that includes the "business" extension. + self.assert_has_feature( + 16, 16294, 25097, 'roads', + {'id': 12276055, 'shield_text': '70', 'network': 'US:I:Business'}) From 4a3da350105314310cb0a44f11b50c9c6c6617ee Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Mon, 18 Dec 2017 16:47:51 +0000 Subject: [PATCH 2/5] Add more test cases for spur / business route modifiers. --- .../1387-business-and-spur-routes.py | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/integration-test/1387-business-and-spur-routes.py b/integration-test/1387-business-and-spur-routes.py index 03a494211..f7855e3fa 100644 --- a/integration-test/1387-business-and-spur-routes.py +++ b/integration-test/1387-business-and-spur-routes.py @@ -3,13 +3,32 @@ class BusinessAndSpurRoutes(FixtureTest): - def test_first_capitol_dr_i70_business(self): + def _check_route_relation( + self, rel_id, way_id, tile, shield_text, network): + z, x, y = map(int, tile.split('/')) + self.load_fixtures([ - 'https://www.openstreetmap.org/relation/1933234', - ]) + 'https://www.openstreetmap.org/relation/%d' % (rel_id,), + ], clip=self.tile_bbox(z, x, y)) # check that First Capitol Dr, part of the above relation, is given # a network that includes the "business" extension. self.assert_has_feature( - 16, 16294, 25097, 'roads', - {'id': 12276055, 'shield_text': '70', 'network': 'US:I:Business'}) + z, x, y, 'roads', + {'id': way_id, 'shield_text': shield_text, 'network': network}) + + def test_first_capitol_dr_i70_business(self): + self._check_route_relation( + 1933234, 12276055, '16/16294/25097', '70', 'US:I:Business') + + def test_business_loop(self): + self._check_route_relation( + 1935116, 5807439, '16/12285/23316', '15', 'US:I:Business:Loop') + + def test_nj_essex(self): + self._check_route_relation( + 945855, 221295008, '16/19267/24623', '672', 'US:NJ:Essex:Spur') + + def test_nj_cr(self): + self._check_route_relation( + 941526, 60523740, '16/19192/24767', '526', 'US:NJ:CR:Spur') From 13cb465da3bbfae130c3ec38f2cb816208230921 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Mon, 18 Dec 2017 16:48:11 +0000 Subject: [PATCH 3/5] Back-port route modifier logic from Python. --- data/functions.sql | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/data/functions.sql b/data/functions.sql index 67f4ac951..39992b85a 100644 --- a/data/functions.sql +++ b/data/functions.sql @@ -83,6 +83,33 @@ BEGIN END; $$ LANGUAGE plpgsql IMMUTABLE; +-- mz_modify_network returns an hstore of {route, network, ref} +-- where the network has been modified according to the +-- modifier tag, if there is any. +CREATE OR REPLACE FUNCTION mz_modify_network( + tags hstore) +RETURNS hstore AS $$ +DECLARE + network text := tags->'network'; + modifier text := tags->'modifier'; +BEGIN + RETURN + tags || + hstore('network', + CASE WHEN + network LIKE 'US:%' AND + modifier IN ('Business', 'Spur', 'Truck', 'Alternate', 'Bypass', + 'Connector', 'Historic', 'Toll', 'Scenic') AND + POSITION(modifier IN network) = 0 + THEN + network || ':' || modifier + ELSE + network + END + ); +END; +$$ LANGUAGE plpgsql IMMUTABLE; + -- mz_get_rel_networks returns a list of triples of route type, -- network and ref tags, or NULL, for a given way ID. -- @@ -100,7 +127,7 @@ FROM ( unnest(tags) AS unnested FROM ( SELECT - hstore(tags)->ARRAY['route','network','ref'] AS tags + mz_modify_network(hstore(tags))->ARRAY['route','network','ref'] AS tags FROM planet_osm_rels WHERE From 7225b40bb8dbad2535d541979c6fc39c1ced671f Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Mon, 18 Dec 2017 16:50:37 +0000 Subject: [PATCH 4/5] Add note about route modifiers. --- docs/layers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/layers.md b/docs/layers.md index 20d115c7d..1515acd17 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -1048,7 +1048,7 @@ To improve performance, some road segments are merged at low and mid-zooms. To f * `min_zoom`: a suggestion for which zoom to draw a feature. The value is a float. * `ref`: Commonly-used reference for roads, for example "I 90" for Interstate 90. To use with shields, see `network` and `shield_text`. Related, see `symbol` for pistes. * `all_networks` and `all_shield_texts`: All the networks of which this road is a part, and all of the shield texts. See `network` and `shield_text` below. **Note** that these properties will not be present on MVT format tiles, as we cannot currently encode lists as values. -* `network`: eg: `US:I` for the United States Interstate network, useful for shields and road selections. This only contains _road_ network types. Please see `bicycle_network` and `walking_network` for bicycle and walking networks, respectively. +* `network`: eg: `US:I` for the United States Interstate network, useful for shields and road selections. This only contains _road_ network types. Please see `bicycle_network` and `walking_network` for bicycle and walking networks, respectively. Note that networks may include "modifier" information, for example `US:I:Business` for a business route or `US:I:Truck` for a truck route. * `shield_text`: Contains text to display on a shield. For example, I 90 would have a `network` of `US:I` and a `shield_text` of `90`. The `ref`, `I 90`, is less useful for shield display without further processing. For some roads, this can include non-numeric characters, for example the M1 motorway in the UK will have a `shield_text` of `M1`, rather than just `1`. #### Road properties (common optional): From 82e1f9a141e9029b372d2cf4a687c4d08578e290 Mon Sep 17 00:00:00 2001 From: Matt Amos Date: Mon, 18 Dec 2017 19:06:47 +0000 Subject: [PATCH 5/5] Document whitelist of modifier values. --- docs/layers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/layers.md b/docs/layers.md index 1515acd17..bf80deb79 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -1048,7 +1048,7 @@ To improve performance, some road segments are merged at low and mid-zooms. To f * `min_zoom`: a suggestion for which zoom to draw a feature. The value is a float. * `ref`: Commonly-used reference for roads, for example "I 90" for Interstate 90. To use with shields, see `network` and `shield_text`. Related, see `symbol` for pistes. * `all_networks` and `all_shield_texts`: All the networks of which this road is a part, and all of the shield texts. See `network` and `shield_text` below. **Note** that these properties will not be present on MVT format tiles, as we cannot currently encode lists as values. -* `network`: eg: `US:I` for the United States Interstate network, useful for shields and road selections. This only contains _road_ network types. Please see `bicycle_network` and `walking_network` for bicycle and walking networks, respectively. Note that networks may include "modifier" information, for example `US:I:Business` for a business route or `US:I:Truck` for a truck route. +* `network`: eg: `US:I` for the United States Interstate network, useful for shields and road selections. This only contains _road_ network types. Please see `bicycle_network` and `walking_network` for bicycle and walking networks, respectively. Note that networks may include "modifier" information, for example `US:I:Business` for a business route or `US:I:Truck` for a truck route. The whitelist of "modifier" values is; `Alternate`, `Business`, `Bypass`, `Connector`, `Historic`, `Scenic`, `Spur`, `Toll` and `Truck`. * `shield_text`: Contains text to display on a shield. For example, I 90 would have a `network` of `US:I` and a `shield_text` of `90`. The `ref`, `I 90`, is less useful for shield display without further processing. For some roads, this can include non-numeric characters, for example the M1 motorway in the UK will have a `shield_text` of `M1`, rather than just `1`. #### Road properties (common optional):