From 2875ce63655acdce20ba91871aa71c395f67ea5c Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Tue, 9 Nov 2021 16:02:58 -0800 Subject: [PATCH 1/8] updating code --- vectordatasource/transform.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vectordatasource/transform.py b/vectordatasource/transform.py index 7ddac657b..7bc262d2a 100644 --- a/vectordatasource/transform.py +++ b/vectordatasource/transform.py @@ -8220,7 +8220,8 @@ def network_key(t): # expose first network as network/shield_text network, ref = tuples[0] properties[prefix + 'network'] = network - properties[prefix + 'shield_text'] = ref + properties[prefix + 'shield_text'] = str(ref) + properties[prefix + 'shield_text_length'] = len(ref) # replace properties with sorted versions of themselves properties[all_networks] = [n[0] for n in tuples] From 09a4d5e42e8f29831af3d9f59e8190edc9125b06 Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Tue, 9 Nov 2021 16:44:05 -0800 Subject: [PATCH 2/8] adding new test --- integration-test/1979-shield-text-length.py | 186 ++++++++++++++++++++ vectordatasource/transform.py | 3 +- 2 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 integration-test/1979-shield-text-length.py diff --git a/integration-test/1979-shield-text-length.py b/integration-test/1979-shield-text-length.py new file mode 100644 index 000000000..3895aa3b4 --- /dev/null +++ b/integration-test/1979-shield-text-length.py @@ -0,0 +1,186 @@ +# -*- encoding: utf-8 -*- +import dsl +from . import FixtureTest + + +class ShieldTextLengthTest(FixtureTest): + + # this is real data. For the rest of the tests, it will be modified + def test_create_shield_text_length(self): + import dsl + + z, x, y = (16, 10470, 25340) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/417097119 + dsl.way(417097119, dsl.tile_diagonal(z, x, y), { + 'cycleway:right': 'lane', + 'hgv': 'designated', + 'hgv:state_network': 'yes', + 'highway': 'primary', + 'lanes': '2', + 'lcn_ref': '50', + 'maxspeed': '35 mph', + 'name': 'Sloat Boulevard', + 'name:etymology:wikidata': 'Q634931', + 'oneway': 'yes', + 'ref': 'CA 35', + 'sidewalk': 'right', + 'source': 'openstreetmap.org', + 'source:hgv:state_network': 'Caltrans http://www.dot.ca.gov/hq/traffops/trucks/truckmap/', + 'tiger:cfcc': 'A45', + 'tiger:county': 'San Francisco, CA', + 'tiger:name_base': 'Sloat', + 'tiger:name_type': 'Blvd', + }), + dsl.relation(1976278, { + 'network': 'US:CA', + 'ref': '35', + 'route': 'road', + 'source': 'openstreetmap.org', + 'type': 'route', + }, ways=[417097119]), + dsl.relation(32312, { + 'cycle_network': 'US:CA:SF', + 'network': 'lcn', + 'ref': '50', + 'source': 'openstreetmap.org', + 'route': 'bicycle', + 'type': 'route', + }, ways=[417097119]), + dsl.relation(3002741, { + 'network': 'Muni', + 'ref': '23', + 'route': 'bus', + 'source': 'openstreetmap.org', + 'type': 'route', + }, ways=[417097119]) + ) + + self.assert_has_feature( + z, x, y, 'roads', { + 'id': 417097119, + 'shield_text': '35', + 'shield_text_length': '2', + 'bicycle_shield_text': '50', + 'bicycle_shield_text_length': '2', + 'bus_shield_text': '23', + 'bus_shield_text_length': '2' + }) + + def test_shield_text_length_is_a_string(self): + import dsl + + z, x, y = (16, 10470, 25340) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/417097119 + dsl.way(417097119, dsl.tile_diagonal(z, x, y), { + 'cycleway:right': 'lane', + 'hgv': 'designated', + 'hgv:state_network': 'yes', + 'highway': 'primary', + 'lanes': '2', + 'lcn_ref': '50', + 'maxspeed': '35 mph', + 'name': 'Sloat Boulevard', + 'name:etymology:wikidata': 'Q634931', + 'oneway': 'yes', + 'ref': 'CA 35', + 'sidewalk': 'right', + 'source': 'openstreetmap.org', + 'source:hgv:state_network': 'Caltrans http://www.dot.ca.gov/hq/traffops/trucks/truckmap/', + 'tiger:cfcc': 'A45', + 'tiger:county': 'San Francisco, CA', + 'tiger:name_base': 'Sloat', + 'tiger:name_type': 'Blvd', + }), + dsl.relation(1976278, { + 'network': 'US:CA', + 'ref': '35', + 'route': 'road', + 'source': 'openstreetmap.org', + 'type': 'route', + }, ways=[417097119]), + dsl.relation(32312, { + 'cycle_network': 'US:CA:SF', + 'network': 'lcn', + 'ref': '50', + 'source': 'openstreetmap.org', + 'route': 'bicycle', + 'type': 'route', + }, ways=[417097119]), + dsl.relation(3002741, { + 'network': 'Muni', + 'ref': '23', + 'route': 'bus', + 'source': 'openstreetmap.org', + 'type': 'route', + }, ways=[417097119]) + ) + + self.assert_no_matching_feature(z, x, y, 'roads', {'id': 417097119, 'shield_text_length': 2}) + + # make fields with text that is too long. Make sure things are still correct + def test_lengths_over_6_or_empty_are_not_reported(self): + import dsl + + z, x, y = (16, 10470, 25340) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/417097119 + dsl.way(417097119, dsl.tile_diagonal(z, x, y), { + 'cycleway:right': 'lane', + 'hgv': 'designated', + 'hgv:state_network': 'yes', + 'highway': 'primary', + 'lanes': '2', + 'lcn_ref': '50', + 'maxspeed': '35 mph', + 'name': 'Sloat Boulevard', + 'name:etymology:wikidata': 'Q634931', + 'oneway': 'yes', + 'ref': 'CA 35', + 'sidewalk': 'right', + 'source': 'openstreetmap.org', + 'source:hgv:state_network': 'Caltrans http://www.dot.ca.gov/hq/traffops/trucks/truckmap/', + 'tiger:cfcc': 'A45', + 'tiger:county': 'San Francisco, CA', + 'tiger:name_base': 'Sloat', + 'tiger:name_type': 'Blvd', + }), + dsl.relation(1976278, { + 'network': 'US:CA', + 'ref': '123456', + 'route': 'road', + 'source': 'openstreetmap.org', + 'type': 'route', + }, ways=[417097119]), + dsl.relation(32312, { + 'cycle_network': 'US:CA:SF', + 'network': 'lcn', + 'ref': '1234567', + 'source': 'openstreetmap.org', + 'route': 'bicycle', + 'type': 'route', + }, ways=[417097119]), + dsl.relation(3002741, { + 'network': 'Muni', + 'ref': '', + 'route': 'bus', + 'source': 'openstreetmap.org', + 'type': 'route', + }, ways=[417097119]) + ) + + self.assert_has_feature( + z, x, y, 'roads', { + 'id': 417097119, + 'shield_text': '123456', + 'shield_text_length': '6', + 'bicycle_shield_text': '1234567', + 'bus_shield_text': '', + }) + + self.assert_no_matching_feature(z, x, y, 'roads', { + 'id': 417097119, 'bicycle_shield_text_length': '7', 'bus_shield_text_length': '0'}) \ No newline at end of file diff --git a/vectordatasource/transform.py b/vectordatasource/transform.py index 7bc262d2a..71b15f1ac 100644 --- a/vectordatasource/transform.py +++ b/vectordatasource/transform.py @@ -8221,7 +8221,8 @@ def network_key(t): network, ref = tuples[0] properties[prefix + 'network'] = network properties[prefix + 'shield_text'] = str(ref) - properties[prefix + 'shield_text_length'] = len(ref) + if 0 < len(ref) <= 7: + properties[prefix + 'shield_text_length'] = str(len(ref)) # replace properties with sorted versions of themselves properties[all_networks] = [n[0] for n in tuples] From 56245046d801a75c52117158dd797116f6dcc3c4 Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Tue, 9 Nov 2021 16:53:24 -0800 Subject: [PATCH 3/8] more tests --- integration-test/1979-shield-text-length.py | 67 ++++++++++----------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/integration-test/1979-shield-text-length.py b/integration-test/1979-shield-text-length.py index 3895aa3b4..d32ee96c7 100644 --- a/integration-test/1979-shield-text-length.py +++ b/integration-test/1979-shield-text-length.py @@ -5,12 +5,12 @@ class ShieldTextLengthTest(FixtureTest): - # this is real data. For the rest of the tests, it will be modified def test_create_shield_text_length(self): import dsl z, x, y = (16, 10470, 25340) + # this is real data. For the rest of the tests, it will be modified self.generate_fixtures( # https://www.openstreetmap.org/way/417097119 dsl.way(417097119, dsl.tile_diagonal(z, x, y), { @@ -68,11 +68,16 @@ def test_create_shield_text_length(self): 'bus_shield_text_length': '2' }) - def test_shield_text_length_is_a_string(self): + # make sure text length is encoded as a string + self.assert_no_matching_feature(z, x, y, 'roads', {'id': 417097119, 'shield_text_length': 2}) + + # empty strings and route refs over 6 chars in length don't report length + def test_lengths_over_6_or_empty_are_not_reported(self): import dsl z, x, y = (16, 10470, 25340) + # modify the data to include different names whose lengths shouldn't be included in the output self.generate_fixtures( # https://www.openstreetmap.org/way/417097119 dsl.way(417097119, dsl.tile_diagonal(z, x, y), { @@ -97,7 +102,7 @@ def test_shield_text_length_is_a_string(self): }), dsl.relation(1976278, { 'network': 'US:CA', - 'ref': '35', + 'ref': '123456', 'route': 'road', 'source': 'openstreetmap.org', 'type': 'route', @@ -105,28 +110,38 @@ def test_shield_text_length_is_a_string(self): dsl.relation(32312, { 'cycle_network': 'US:CA:SF', 'network': 'lcn', - 'ref': '50', + 'ref': '1234567', 'source': 'openstreetmap.org', 'route': 'bicycle', 'type': 'route', }, ways=[417097119]), dsl.relation(3002741, { 'network': 'Muni', - 'ref': '23', + 'ref': '', 'route': 'bus', 'source': 'openstreetmap.org', 'type': 'route', }, ways=[417097119]) ) - self.assert_no_matching_feature(z, x, y, 'roads', {'id': 417097119, 'shield_text_length': 2}) + self.assert_has_feature( + z, x, y, 'roads', { + 'id': 417097119, + 'shield_text': '123456', + 'shield_text_length': '6', + 'bicycle_shield_text': '1234567', + 'bus_shield_text': '', + }) - # make fields with text that is too long. Make sure things are still correct - def test_lengths_over_6_or_empty_are_not_reported(self): + self.assert_no_matching_feature(z, x, y, 'roads', { + 'id': 417097119, 'bicycle_shield_text_length': '7', 'bus_shield_text_length': '0'}) + + def test_walking_shield_works(self): import dsl z, x, y = (16, 10470, 25340) + # modify the data to include a trail to make sure we're adding walking shield text length too self.generate_fixtures( # https://www.openstreetmap.org/way/417097119 dsl.way(417097119, dsl.tile_diagonal(z, x, y), { @@ -150,37 +165,19 @@ def test_lengths_over_6_or_empty_are_not_reported(self): 'tiger:name_type': 'Blvd', }), dsl.relation(1976278, { - 'network': 'US:CA', - 'ref': '123456', - 'route': 'road', - 'source': 'openstreetmap.org', - 'type': 'route', - }, ways=[417097119]), - dsl.relation(32312, { - 'cycle_network': 'US:CA:SF', - 'network': 'lcn', - 'ref': '1234567', - 'source': 'openstreetmap.org', - 'route': 'bicycle', - 'type': 'route', + "name": "Pacific Crest Trail", + "network": "nwn", + "ref": "PCT", + "route": "hiking", + "type": "route", + "wikidata": "Q2003736", + "wikipedia": "en:Pacific Crest Trail", }, ways=[417097119]), - dsl.relation(3002741, { - 'network': 'Muni', - 'ref': '', - 'route': 'bus', - 'source': 'openstreetmap.org', - 'type': 'route', - }, ways=[417097119]) ) self.assert_has_feature( z, x, y, 'roads', { 'id': 417097119, - 'shield_text': '123456', - 'shield_text_length': '6', - 'bicycle_shield_text': '1234567', - 'bus_shield_text': '', + 'walking_shield_text': 'PCT', + 'walking_shield_text_length': '3', }) - - self.assert_no_matching_feature(z, x, y, 'roads', { - 'id': 417097119, 'bicycle_shield_text_length': '7', 'bus_shield_text_length': '0'}) \ No newline at end of file From b4287ded1a5ceedbce38e8913d1bdb445f6f6322 Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Tue, 9 Nov 2021 17:15:48 -0800 Subject: [PATCH 4/8] adding hgv shield text length --- docs/layers.md | 4 ++++ integration-test/1979-shield-text-length.py | 17 +++++++++++++++++ vectordatasource/transform.py | 2 ++ 3 files changed, 23 insertions(+) diff --git a/docs/layers.md b/docs/layers.md index 11f6a1fca..c550d9974 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -1450,6 +1450,7 @@ To improve performance, some road segments are merged at low and mid-zooms. To f * `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. 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`. Whitepsace, punctuation, and prefixes are generally stripped. +* `shield_text_length`: The length of the `shield_text` field as a string. E.g. if `shield_text` is `'12345'`, `shield_text_length` would be `'5'` #### Road properties (common optional): @@ -1475,12 +1476,15 @@ To improve performance, some road segments are merged at low and mid-zooms. To f * `all_walking_networks` and `all_walking_shield_texts`: All of the walking networks of which this road is a part, and each corresponding shield text. See `walking_network` and `walking_shield_text` below. **Note** that these properties will not be present on MVT format tiles, as we cannot currently encode lists as values. * `walking_network`: e.g: `nwn` for a "National Walking Network". Other common values include `iwn` for international, `rwn` for regional and `lwn` for local walking networks. * `walking_shield_text`: Contains text intended to be displayed on a shield related to the walking network. This is the value from the `ref` tag and is _not_ guaranteed to be numeric, or even concise. +* `walking_shield_text_length`: The length of the `walking_shield_text` field as a string. E.g. if `walking_shield_text` is `'12345'`, `walking_shield_text_length` would be `'5'` * `all_bicycle_networks` and `all_bicycle_shield_texts`: All of the bicycle networks of which this road is a part, and each corresponding shield text. See `bicycle_network` and `bicycle_shield_text` below. **Note** that these properties will not be present on MVT format tiles, as we cannot currently encode lists as values. * `bicycle_network`: Present if the feature is part of a cycling network. If so, the value will be one of `icn` for International Cycling Network, `ncn` for National Cycling Network, `rcn` for Regional Cycling Network, `lcn` for Local Cycling Network. * `bicycle_shield_text`: Contains text intended to be displayed on a shield related to the bicycle network. This is the value from the `ref` tag and is _not_ guaranteed to be numeric, or even concise. +* `bicycle_shield_text_length`: The length of the `bicycle_shield_text` field as a string. E.g. if `bicycle_shield_text` is `'12345'`, `bicycle_shield_text_length` would be `'5'` * `all_bus_networks` and `all_bus_shield_texts`: All of the bus and trolley-bus routes of which this road is a part, and each corresponding shield text. See `bus_network` and `bus_shield_text` below. **Note** that these properties will not be present on MVT format tiles, as we cannot currently encode lists as values. * `bus_network`: Note that this is often not present for bus routes / networks. This may be replaced with `operator` in the future, see [issue 1194](https://github.com/tilezen/vector-datasource/issues/1194). * `bus_shield_text`: Contains text intended to be displayed on a shield related to the bus or trolley-bus network. This is the value from the `ref` tag and is _not_ guaranteed to be numeric, or even concise. +* `bus_shield_text_length`: The length of the `bus_shield_text` field as a string. E.g. if `bus_shield_text` is `'12345'`, `bus_shield_text_length` would be `'5'` * `surface`: Common values include `asphalt`, `unpaved`, `paved`, `ground`, `gravel`, `dirt`, `concrete`, `grass`, `paving_stones`, `compacted`, `sand`, and `cobblestone`. `cobblestone:flattened`, `concrete:plates` and `concrete:lanes` values are transformed to `cobblestone_flattened`, `concrete_plates` and `concrete_lanes` respectively. These values are simplified at lower zooms, see the section "Roads surface values simplification" for more details. #### Road properties (optional): diff --git a/integration-test/1979-shield-text-length.py b/integration-test/1979-shield-text-length.py index d32ee96c7..5b6ca60b5 100644 --- a/integration-test/1979-shield-text-length.py +++ b/integration-test/1979-shield-text-length.py @@ -181,3 +181,20 @@ def test_walking_shield_works(self): 'walking_shield_text': 'PCT', 'walking_shield_text_length': '3', }) + + def test_hgv_shield_text_length(self): + z, x, y = (16, 0, 0) + + self.generate_fixtures( + dsl.way(1, dsl.tile_diagonal(z, x, y), + {'highway': 'unclassified', + 'source': 'openstreetmap.org', + 'maxweight': 1.5})) + + self.assert_has_feature( + z, x, y, 'roads', { + 'kind': 'minor_road', + 'kind_detail': 'unclassified', + 'hgv_restriction': 'weight', + 'hgv_restriction_shield_text': '1.5t', + 'hgv_restriction_shield_text_length': '4'}) diff --git a/vectordatasource/transform.py b/vectordatasource/transform.py index 71b15f1ac..5c392602f 100644 --- a/vectordatasource/transform.py +++ b/vectordatasource/transform.py @@ -8995,6 +8995,8 @@ def _false(val): props['hgv_restriction'] = hgv_restriction if hgv_restriction_shield_text: props['hgv_restriction_shield_text'] = hgv_restriction_shield_text + if 0 < len(hgv_restriction_shield_text) < 7: + props['hgv_restriction_shield_text_length'] = str(len(hgv_restriction_shield_text)) return shape, props, fid From bb0344bc6d42c2624cb2ad4cea05e34094ca4ca7 Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Tue, 9 Nov 2021 17:18:32 -0800 Subject: [PATCH 5/8] updating docs --- docs/layers.md | 1 + integration-test/1553-hgv-properties.py | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/layers.md b/docs/layers.md index c550d9974..2665751c5 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -1502,6 +1502,7 @@ To improve performance, some road segments are merged at low and mid-zooms. To f * `hgv_restriction`: optional property indicating limitations to heavy goods vehicle truck access. See below for list of values. Available on both point and line geometries. See also `hgv_restriction_shield_text`. * `hgv_time_restrictions` - optional property specifying when heavy goods vehicle truck access is restricted. See the `hgv_time_restrictions` values list below. * `hgv_restriction_shield_text`: optional and paired with `hgv_restriction` points with values like `5.1m`. Because the units are different per restriction an abbreviation should be provided. Values in meters can be specified with one decimal precision but value of 5.0m should be given as 5m. +* `hgv_restriction_shield_text_length`: optional. Returns length of `hgv_restriction_shield_text` as a string. Missing if `hgv_restriction_field_text` is !(0 < length < 7) or field doesn't exist * `motor_vehicle`: OpenStreetMap features * `operator`: OpenStreetMap features * `piste_difficulty`: ski pistes from OpenStreetMap diff --git a/integration-test/1553-hgv-properties.py b/integration-test/1553-hgv-properties.py index c32a8e627..c1834a517 100644 --- a/integration-test/1553-hgv-properties.py +++ b/integration-test/1553-hgv-properties.py @@ -92,6 +92,7 @@ def _check_restriction(self, tags, restriction=None, shield_text=None): expect['hgv_restriction'] = restriction if shield_text: expect['hgv_restriction_shield_text'] = shield_text + expect['hgv_restriction_shield_text_length'] = str(len(shield_text)) self.assert_has_feature(z, x, y, 'roads', expect) From cb1dd7a9fd18fa57d05573b0f90628c09607c79b Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Tue, 9 Nov 2021 17:20:08 -0800 Subject: [PATCH 6/8] woops --- integration-test/1553-hgv-properties.py | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-test/1553-hgv-properties.py b/integration-test/1553-hgv-properties.py index c1834a517..c32a8e627 100644 --- a/integration-test/1553-hgv-properties.py +++ b/integration-test/1553-hgv-properties.py @@ -92,7 +92,6 @@ def _check_restriction(self, tags, restriction=None, shield_text=None): expect['hgv_restriction'] = restriction if shield_text: expect['hgv_restriction_shield_text'] = shield_text - expect['hgv_restriction_shield_text_length'] = str(len(shield_text)) self.assert_has_feature(z, x, y, 'roads', expect) From 4e184fd5294b05ce4f5baeeaac8dd5544413e67f Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Wed, 10 Nov 2021 09:27:33 -0800 Subject: [PATCH 7/8] removing more things --- integration-test/1979-shield-text-length.py | 182 +++++++------------- 1 file changed, 65 insertions(+), 117 deletions(-) diff --git a/integration-test/1979-shield-text-length.py b/integration-test/1979-shield-text-length.py index 5b6ca60b5..efd6e6a77 100644 --- a/integration-test/1979-shield-text-length.py +++ b/integration-test/1979-shield-text-length.py @@ -2,59 +2,64 @@ import dsl from . import FixtureTest +z, x, y = (16, 10470, 25340) + +way35 = { + 'cycleway:right': 'lane', + 'hgv': 'designated', + 'hgv:state_network': 'yes', + 'highway': 'primary', + 'lanes': '2', + 'lcn_ref': '50', + 'maxspeed': '35 mph', + 'name': 'Sloat Boulevard', + 'name:etymology:wikidata': 'Q634931', + 'oneway': 'yes', + 'ref': 'CA 35', + 'sidewalk': 'right', + 'source': 'openstreetmap.org', + 'source:hgv:state_network': 'Caltrans http://www.dot.ca.gov/hq/traffops/trucks/truckmap/', + 'tiger:cfcc': 'A45', + 'tiger:county': 'San Francisco, CA', + 'tiger:name_base': 'Sloat', + 'tiger:name_type': 'Blvd', +} + +rel35 = { + 'network': 'US:CA', + 'ref': '35', + 'route': 'road', + 'source': 'openstreetmap.org', + 'type': 'route', +} + +rel50Cycle = { + 'cycle_network': 'US:CA:SF', + 'network': 'lcn', + 'ref': '50', + 'source': 'openstreetmap.org', + 'route': 'bicycle', + 'type': 'route', +} + +rel23Bus = { + 'network': 'Muni', + 'ref': '23', + 'route': 'bus', + 'source': 'openstreetmap.org', + 'type': 'route', +} + class ShieldTextLengthTest(FixtureTest): def test_create_shield_text_length(self): - import dsl - - z, x, y = (16, 10470, 25340) - - # this is real data. For the rest of the tests, it will be modified self.generate_fixtures( # https://www.openstreetmap.org/way/417097119 - dsl.way(417097119, dsl.tile_diagonal(z, x, y), { - 'cycleway:right': 'lane', - 'hgv': 'designated', - 'hgv:state_network': 'yes', - 'highway': 'primary', - 'lanes': '2', - 'lcn_ref': '50', - 'maxspeed': '35 mph', - 'name': 'Sloat Boulevard', - 'name:etymology:wikidata': 'Q634931', - 'oneway': 'yes', - 'ref': 'CA 35', - 'sidewalk': 'right', - 'source': 'openstreetmap.org', - 'source:hgv:state_network': 'Caltrans http://www.dot.ca.gov/hq/traffops/trucks/truckmap/', - 'tiger:cfcc': 'A45', - 'tiger:county': 'San Francisco, CA', - 'tiger:name_base': 'Sloat', - 'tiger:name_type': 'Blvd', - }), - dsl.relation(1976278, { - 'network': 'US:CA', - 'ref': '35', - 'route': 'road', - 'source': 'openstreetmap.org', - 'type': 'route', - }, ways=[417097119]), - dsl.relation(32312, { - 'cycle_network': 'US:CA:SF', - 'network': 'lcn', - 'ref': '50', - 'source': 'openstreetmap.org', - 'route': 'bicycle', - 'type': 'route', - }, ways=[417097119]), - dsl.relation(3002741, { - 'network': 'Muni', - 'ref': '23', - 'route': 'bus', - 'source': 'openstreetmap.org', - 'type': 'route', - }, ways=[417097119]) + dsl.way(417097119, dsl.tile_diagonal(z, x, y), way35), + dsl.relation(1976278, rel35, ways=[417097119]), + dsl.relation(32312, rel50Cycle, ways=[417097119]), + dsl.relation(3002741, rel23Bus, ways=[417097119]) ) self.assert_has_feature( @@ -73,55 +78,22 @@ def test_create_shield_text_length(self): # empty strings and route refs over 6 chars in length don't report length def test_lengths_over_6_or_empty_are_not_reported(self): - import dsl - z, x, y = (16, 10470, 25340) + rel123456 = rel35.copy() + rel123456['ref'] = '123456' + + relCycleTooLong = rel50Cycle.copy() + relCycleTooLong['ref'] = '1234567' + + relBusEmpty = rel23Bus.copy() + relBusEmpty['ref'] = '' - # modify the data to include different names whose lengths shouldn't be included in the output self.generate_fixtures( # https://www.openstreetmap.org/way/417097119 - dsl.way(417097119, dsl.tile_diagonal(z, x, y), { - 'cycleway:right': 'lane', - 'hgv': 'designated', - 'hgv:state_network': 'yes', - 'highway': 'primary', - 'lanes': '2', - 'lcn_ref': '50', - 'maxspeed': '35 mph', - 'name': 'Sloat Boulevard', - 'name:etymology:wikidata': 'Q634931', - 'oneway': 'yes', - 'ref': 'CA 35', - 'sidewalk': 'right', - 'source': 'openstreetmap.org', - 'source:hgv:state_network': 'Caltrans http://www.dot.ca.gov/hq/traffops/trucks/truckmap/', - 'tiger:cfcc': 'A45', - 'tiger:county': 'San Francisco, CA', - 'tiger:name_base': 'Sloat', - 'tiger:name_type': 'Blvd', - }), - dsl.relation(1976278, { - 'network': 'US:CA', - 'ref': '123456', - 'route': 'road', - 'source': 'openstreetmap.org', - 'type': 'route', - }, ways=[417097119]), - dsl.relation(32312, { - 'cycle_network': 'US:CA:SF', - 'network': 'lcn', - 'ref': '1234567', - 'source': 'openstreetmap.org', - 'route': 'bicycle', - 'type': 'route', - }, ways=[417097119]), - dsl.relation(3002741, { - 'network': 'Muni', - 'ref': '', - 'route': 'bus', - 'source': 'openstreetmap.org', - 'type': 'route', - }, ways=[417097119]) + dsl.way(417097119, dsl.tile_diagonal(z, x, y), way35), + dsl.relation(1976278, rel123456, ways=[417097119]), + dsl.relation(32312, relCycleTooLong, ways=[417097119]), + dsl.relation(3002741, relBusEmpty, ways=[417097119]) ) self.assert_has_feature( @@ -137,33 +109,11 @@ def test_lengths_over_6_or_empty_are_not_reported(self): 'id': 417097119, 'bicycle_shield_text_length': '7', 'bus_shield_text_length': '0'}) def test_walking_shield_works(self): - import dsl - - z, x, y = (16, 10470, 25340) # modify the data to include a trail to make sure we're adding walking shield text length too self.generate_fixtures( # https://www.openstreetmap.org/way/417097119 - dsl.way(417097119, dsl.tile_diagonal(z, x, y), { - 'cycleway:right': 'lane', - 'hgv': 'designated', - 'hgv:state_network': 'yes', - 'highway': 'primary', - 'lanes': '2', - 'lcn_ref': '50', - 'maxspeed': '35 mph', - 'name': 'Sloat Boulevard', - 'name:etymology:wikidata': 'Q634931', - 'oneway': 'yes', - 'ref': 'CA 35', - 'sidewalk': 'right', - 'source': 'openstreetmap.org', - 'source:hgv:state_network': 'Caltrans http://www.dot.ca.gov/hq/traffops/trucks/truckmap/', - 'tiger:cfcc': 'A45', - 'tiger:county': 'San Francisco, CA', - 'tiger:name_base': 'Sloat', - 'tiger:name_type': 'Blvd', - }), + dsl.way(417097119, dsl.tile_diagonal(z, x, y), way35), dsl.relation(1976278, { "name": "Pacific Crest Trail", "network": "nwn", @@ -183,8 +133,6 @@ def test_walking_shield_works(self): }) def test_hgv_shield_text_length(self): - z, x, y = (16, 0, 0) - self.generate_fixtures( dsl.way(1, dsl.tile_diagonal(z, x, y), {'highway': 'unclassified', From 3c673d449a5732310d58b161d80303802ba25101 Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Wed, 10 Nov 2021 09:34:11 -0800 Subject: [PATCH 8/8] updating docs --- docs/layers.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/layers.md b/docs/layers.md index 2665751c5..c22dc37ca 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -1450,7 +1450,7 @@ To improve performance, some road segments are merged at low and mid-zooms. To f * `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. 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`. Whitepsace, punctuation, and prefixes are generally stripped. -* `shield_text_length`: The length of the `shield_text` field as a string. E.g. if `shield_text` is `'12345'`, `shield_text_length` would be `'5'` +* `shield_text_length`: The length of the `shield_text` field as a string. E.g. if `shield_text` is `'12345'`, `shield_text_length` would be `'5'`. Missing if `shield_text` is !(0 < length < 7) or field doesn't exist #### Road properties (common optional): @@ -1476,15 +1476,15 @@ To improve performance, some road segments are merged at low and mid-zooms. To f * `all_walking_networks` and `all_walking_shield_texts`: All of the walking networks of which this road is a part, and each corresponding shield text. See `walking_network` and `walking_shield_text` below. **Note** that these properties will not be present on MVT format tiles, as we cannot currently encode lists as values. * `walking_network`: e.g: `nwn` for a "National Walking Network". Other common values include `iwn` for international, `rwn` for regional and `lwn` for local walking networks. * `walking_shield_text`: Contains text intended to be displayed on a shield related to the walking network. This is the value from the `ref` tag and is _not_ guaranteed to be numeric, or even concise. -* `walking_shield_text_length`: The length of the `walking_shield_text` field as a string. E.g. if `walking_shield_text` is `'12345'`, `walking_shield_text_length` would be `'5'` +* `walking_shield_text_length`: The length of the `walking_shield_text` field as a string. E.g. if `walking_shield_text` is `'12345'`, `walking_shield_text_length` would be `'5'`. Missing if `walking_shield_text` is !(0 < length < 7) or field doesn't exist * `all_bicycle_networks` and `all_bicycle_shield_texts`: All of the bicycle networks of which this road is a part, and each corresponding shield text. See `bicycle_network` and `bicycle_shield_text` below. **Note** that these properties will not be present on MVT format tiles, as we cannot currently encode lists as values. * `bicycle_network`: Present if the feature is part of a cycling network. If so, the value will be one of `icn` for International Cycling Network, `ncn` for National Cycling Network, `rcn` for Regional Cycling Network, `lcn` for Local Cycling Network. * `bicycle_shield_text`: Contains text intended to be displayed on a shield related to the bicycle network. This is the value from the `ref` tag and is _not_ guaranteed to be numeric, or even concise. -* `bicycle_shield_text_length`: The length of the `bicycle_shield_text` field as a string. E.g. if `bicycle_shield_text` is `'12345'`, `bicycle_shield_text_length` would be `'5'` +* `bicycle_shield_text_length`: The length of the `bicycle_shield_text` field as a string. E.g. if `bicycle_shield_text` is `'12345'`, `bicycle_shield_text_length` would be `'5'`. Missing if `bicycle_shield_text` is !(0 < length < 7) or field doesn't exist * `all_bus_networks` and `all_bus_shield_texts`: All of the bus and trolley-bus routes of which this road is a part, and each corresponding shield text. See `bus_network` and `bus_shield_text` below. **Note** that these properties will not be present on MVT format tiles, as we cannot currently encode lists as values. * `bus_network`: Note that this is often not present for bus routes / networks. This may be replaced with `operator` in the future, see [issue 1194](https://github.com/tilezen/vector-datasource/issues/1194). * `bus_shield_text`: Contains text intended to be displayed on a shield related to the bus or trolley-bus network. This is the value from the `ref` tag and is _not_ guaranteed to be numeric, or even concise. -* `bus_shield_text_length`: The length of the `bus_shield_text` field as a string. E.g. if `bus_shield_text` is `'12345'`, `bus_shield_text_length` would be `'5'` +* `bus_shield_text_length`: The length of the `bus_shield_text` field as a string. E.g. if `bus_shield_text` is `'12345'`, `bus_shield_text_length` would be `'5'`. Missing if `bus_shield_text` is !(0 < length < 7) or field doesn't exist * `surface`: Common values include `asphalt`, `unpaved`, `paved`, `ground`, `gravel`, `dirt`, `concrete`, `grass`, `paving_stones`, `compacted`, `sand`, and `cobblestone`. `cobblestone:flattened`, `concrete:plates` and `concrete:lanes` values are transformed to `cobblestone_flattened`, `concrete_plates` and `concrete_lanes` respectively. These values are simplified at lower zooms, see the section "Roads surface values simplification" for more details. #### Road properties (optional): @@ -1502,7 +1502,7 @@ To improve performance, some road segments are merged at low and mid-zooms. To f * `hgv_restriction`: optional property indicating limitations to heavy goods vehicle truck access. See below for list of values. Available on both point and line geometries. See also `hgv_restriction_shield_text`. * `hgv_time_restrictions` - optional property specifying when heavy goods vehicle truck access is restricted. See the `hgv_time_restrictions` values list below. * `hgv_restriction_shield_text`: optional and paired with `hgv_restriction` points with values like `5.1m`. Because the units are different per restriction an abbreviation should be provided. Values in meters can be specified with one decimal precision but value of 5.0m should be given as 5m. -* `hgv_restriction_shield_text_length`: optional. Returns length of `hgv_restriction_shield_text` as a string. Missing if `hgv_restriction_field_text` is !(0 < length < 7) or field doesn't exist +* `hgv_restriction_shield_text_length`: optional. Returns length of `hgv_restriction_shield_text` as a string. Missing if `hgv_restriction_shield_text` is !(0 < length < 7) or field doesn't exist * `motor_vehicle`: OpenStreetMap features * `operator`: OpenStreetMap features * `piste_difficulty`: ski pistes from OpenStreetMap