From a09c026177f5ed31669b20ae45faa76604bbc077 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 19 Nov 2021 15:02:16 -0800 Subject: [PATCH 01/10] water only changes --- queries.yaml | 87 +++++++++++++++++++++++++++++++++++++++++-------- yaml/water.yaml | 10 ++++-- 2 files changed, 81 insertions(+), 16 deletions(-) diff --git a/queries.yaml b/queries.yaml index ca0778654..004642552 100644 --- a/queries.yaml +++ b/queries.yaml @@ -794,6 +794,29 @@ post_process: where: >- kind == 'lake' + # remove names per kind for a given zoom + # before generating any label placements + - fn: vectordatasource.transform.drop_properties + params: + source_layer: water + start_zoom: 0 + end_zoom: 16 + # short-hand for "name" property in the list below means all name-like + # properties. + all_name_variants: true + properties: + - name + where: >- + (kind == 'sea' and zoom < 4) or + (kind == 'lake' and zoom < 5) or + (kind == 'river' and zoom < 12) or + (kind == 'canal' and zoom < 13) or + (kind == 'dam' and zoom < 14) or + (kind == 'stream' and zoom < 14) or + (kind == 'ditch' and zoom < 15) or + (kind == 'drain' and zoom < 15) or + (properties.get('is_tunnel') is True and zoom < 16) + - fn: vectordatasource.transform.handle_label_placement params: layers: @@ -822,22 +845,58 @@ post_process: # table. min_zoom: >- [min_zoom for min_zoom, area_threshold in [ - (4, 40000000000), - (5, 10000000000), - (6, 5000000000), - (7, 400000000), - (8, 200000000), - (9, 100000000), - (10, 10000000), - (11, 4000000), - (12, 750000), - (13, 100000), - (14, 50000), - (15, 10000), - (16, None), + (1, 1000000000000), + (2, 500000000000), + (3, 250000000000), + (4, 120000000000), + (5, 80000000000), + (6, 40000000000), + (7, 10000000000), + (8, 500000000), + (9, 200000000), + (10, 40000000), + (11, 8000000), + (12, 1000000), + (13, 500000), + (14, 50000), + (15, 10000), + (16, None), ] if area >= area_threshold][0] where: >- - kind == 'lake' and label_placement + kind in ['lake','bay','water','riverbank','reservoir'] and label_placement + + # now that we have the label points + # drop most water properties at lower zooms + # this is for lines and polygons + - fn: vectordatasource.transform.drop_properties + params: + source_layer: water + start_zoom: 8 + end_zoom: 15 + properties: + - id + - area + - layer + - wikidata_id + - kind_tile_rank + - label_placement + where: >- + geom_type in ('LineString', 'MultiLineString', 'Polygon', 'MultiPolygon') + + # now that we have the label points + # drop water names at lower zooms for polys only + - fn: vectordatasource.transform.drop_properties + params: + source_layer: water + start_zoom: 8 + end_zoom: 15 + # short-hand for "name" property in the list below means all name-like + # properties. + all_name_variants: true + properties: + - name + where: >- + geom_type in ('Polygon', 'MultiPolygon') - fn: vectordatasource.transform.handle_label_placement params: diff --git a/yaml/water.yaml b/yaml/water.yaml index 3e5914737..44b007587 100644 --- a/yaml/water.yaml +++ b/yaml/water.yaml @@ -25,9 +25,15 @@ globals: key: { col: way_area } op: '>=' table: - # OSM data starts at z8, but we should include some stuff at z7 so that + # OSM data starts at z8, but we should include some stuff at earlier so # the transition doesn't have a gap in it. - - [ 7, 160000000 ] + - [ 1, 20000000000 ] + - [ 2, 10000000000 ] + - [ 3, 5000000000 ] + - [ 4, 2000000000 ] + - [ 5, 500000000 ] + - [ 6, 200000000 ] + - [ 7, 50000000 ] - [ 8, 20000000 ] - [ 9, 5000000 ] - [ 10, 1000000 ] From 334df35d4cfc88944f63fa58694822e2ec2c8b3e Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Fri, 19 Nov 2021 16:57:18 -0800 Subject: [PATCH 02/10] fixing ws issues --- yaml/water.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yaml/water.yaml b/yaml/water.yaml index 44b007587..fc3327e3b 100644 --- a/yaml/water.yaml +++ b/yaml/water.yaml @@ -29,10 +29,10 @@ globals: # the transition doesn't have a gap in it. - [ 1, 20000000000 ] - [ 2, 10000000000 ] - - [ 3, 5000000000 ] - - [ 4, 2000000000 ] - - [ 5, 500000000 ] - - [ 6, 200000000 ] + - [ 3, 5000000000 ] + - [ 4, 2000000000 ] + - [ 5, 500000000 ] + - [ 6, 200000000 ] - [ 7, 50000000 ] - [ 8, 20000000 ] - [ 9, 5000000 ] From 405361c4c3523672848fd7f7bdd469318236661d Mon Sep 17 00:00:00 2001 From: "Nathaniel V. KELSO" Date: Tue, 14 Dec 2021 14:42:26 -0800 Subject: [PATCH 03/10] already range bound --- queries.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.yaml b/queries.yaml index 004642552..750ea7214 100644 --- a/queries.yaml +++ b/queries.yaml @@ -815,7 +815,7 @@ post_process: (kind == 'stream' and zoom < 14) or (kind == 'ditch' and zoom < 15) or (kind == 'drain' and zoom < 15) or - (properties.get('is_tunnel') is True and zoom < 16) + (properties.get('is_tunnel') is True) - fn: vectordatasource.transform.handle_label_placement params: From 534b31aacbedf2b137906ce98e4fe9ca85151e40 Mon Sep 17 00:00:00 2001 From: Peiti Li Date: Tue, 14 Dec 2021 16:29:06 -0800 Subject: [PATCH 04/10] fix integ tests errors(not failures) --- queries.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.yaml b/queries.yaml index 750ea7214..eeccf21ab 100644 --- a/queries.yaml +++ b/queries.yaml @@ -815,7 +815,7 @@ post_process: (kind == 'stream' and zoom < 14) or (kind == 'ditch' and zoom < 15) or (kind == 'drain' and zoom < 15) or - (properties.get('is_tunnel') is True) + (properties is not None and properties.get('is_tunnel') is True) - fn: vectordatasource.transform.handle_label_placement params: From b078b0f34fe29f4364448858a31edf3e7a42e9a6 Mon Sep 17 00:00:00 2001 From: Peiti Li Date: Tue, 14 Dec 2021 16:38:20 -0800 Subject: [PATCH 05/10] fix one integ test failure --- integration-test/1730-further-water-layer-name-dropping.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/integration-test/1730-further-water-layer-name-dropping.py b/integration-test/1730-further-water-layer-name-dropping.py index 117cfa599..e57e99309 100644 --- a/integration-test/1730-further-water-layer-name-dropping.py +++ b/integration-test/1730-further-water-layer-name-dropping.py @@ -211,13 +211,11 @@ def test_label_lake_athabasca_z5(self): }), ) - # we should get a label placement point, and its zoom should have been - # adjusted. we should also have all the names at this point. + # we should also have all the names at this point. self.assert_has_feature( z, x, y, 'water', { 'kind': 'lake', - 'label_placement': True, - 'min_zoom': 5, + 'min_zoom': 2, # min_zoom changed at https://github.com/tilezen/vector-datasource/pull/2010/ 'name': str, 'name:de': str, }) From 47cf4ce71ea3673a6ebef775cee7053d196a368b Mon Sep 17 00:00:00 2001 From: Peiti Li Date: Tue, 14 Dec 2021 17:02:38 -0800 Subject: [PATCH 06/10] fix test integration-test.1838-too-many-bays.BayTest.test_bays --- integration-test/1838-too-many-bays.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integration-test/1838-too-many-bays.py b/integration-test/1838-too-many-bays.py index 9c9fe08c2..243709fca 100644 --- a/integration-test/1838-too-many-bays.py +++ b/integration-test/1838-too-many-bays.py @@ -33,9 +33,9 @@ def _bay(osm_id, area, name): ) with self.features_in_tile_layer(z, x, y, 'water') as features: - # should only have top 10 features - self.assertEqual(10, len(features)) + # should only have top 2 features + self.assertEqual(2, len(features)) # check that they're in order ranks = [f['properties']['kind_tile_rank'] for f in features] - self.assertEqual(range(1, 11), ranks) + self.assertEqual(range(1, 3), ranks) From f5dafd3151167cf37b6d6930eca68af20001f7e9 Mon Sep 17 00:00:00 2001 From: Peiti Li Date: Tue, 14 Dec 2021 17:14:41 -0800 Subject: [PATCH 07/10] more integ fixes --- integration-test/1135-water-lines-merge.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-test/1135-water-lines-merge.py b/integration-test/1135-water-lines-merge.py index da9197fd2..d4c497eda 100644 --- a/integration-test/1135-water-lines-merge.py +++ b/integration-test/1135-water-lines-merge.py @@ -27,7 +27,7 @@ def test_successful_merge(self): 'name': 'foo', 'kind': 'river', 'label_placement': type(None), - }, 1) + }, 0) with self.features_in_tile_layer(z, x, y, 'water') as features: for f in features: @@ -66,7 +66,7 @@ def test_unsuccessful_merge_same_props(self): 'name': 'foo', 'kind': 'river', 'label_placement': type(None), - }, 1) + }, 0) with self.features_in_tile_layer(z, x, y, 'water') as features: for f in features: @@ -106,11 +106,11 @@ def test_unsuccessful_merge_diff_props(self): z, x, y, 'water', { 'kind': 'river', 'label_placement': type(None), - }, 2) + }, 1) with self.features_in_tile_layer(z, x, y, 'water') as features: for f in features: if 'label_placement' in f['properties']: continue - assert f['geometry']['type'] == 'LineString' + assert f['geometry']['type'] == 'MultiLineString' assert len(f['geometry']['coordinates']) == 2 From 77e663c183b3ff687215386ce9ad219a8301f4fd Mon Sep 17 00:00:00 2001 From: "Nathaniel V. KELSO" Date: Wed, 15 Dec 2021 22:17:11 -0800 Subject: [PATCH 08/10] Address PR comments --- queries.yaml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/queries.yaml b/queries.yaml index eeccf21ab..e8951d0c5 100644 --- a/queries.yaml +++ b/queries.yaml @@ -808,13 +808,24 @@ post_process: - name where: >- (kind == 'sea' and zoom < 4) or + (kind == 'bay' and zoom < 5) or + (kind == 'fjord' and zoom < 5) or + (kind == 'strait' and zoom < 5) or (kind == 'lake' and zoom < 5) or + (kind == 'playa' and zoom < 6) or + (kind == 'reef' and zoom < 6) or (kind == 'river' and zoom < 12) or + (kind == 'riverbank' and zoom < 12) or + (kind == 'water' and zoom < 12) or (kind == 'canal' and zoom < 13) or + (kind == 'basin' and zoom < 13) or + (kind == 'dock' and zoom < 13) or (kind == 'dam' and zoom < 14) or (kind == 'stream' and zoom < 14) or (kind == 'ditch' and zoom < 15) or (kind == 'drain' and zoom < 15) or + (kind == 'swimming_pool' and zoom < 15) or + (kind == 'fountain' and zoom < 15) or (properties is not None and properties.get('is_tunnel') is True) - fn: vectordatasource.transform.handle_label_placement @@ -863,7 +874,7 @@ post_process: (16, None), ] if area >= area_threshold][0] where: >- - kind in ['lake','bay','water','riverbank','reservoir'] and label_placement + (properties is not None and properties.get('label_placement') is True) # now that we have the label points # drop most water properties at lower zooms @@ -871,32 +882,32 @@ post_process: - fn: vectordatasource.transform.drop_properties params: source_layer: water - start_zoom: 8 + start_zoom: 0 end_zoom: 15 + geom_types: [LineString, MultiLineString, Polygon, MultiPolygon] properties: - id - area + - boundary - layer - wikidata_id + - osm_relation - kind_tile_rank - - label_placement - where: >- - geom_type in ('LineString', 'MultiLineString', 'Polygon', 'MultiPolygon') # now that we have the label points # drop water names at lower zooms for polys only - fn: vectordatasource.transform.drop_properties params: source_layer: water - start_zoom: 8 + start_zoom: 0 end_zoom: 15 + geom_types: [Polygon, MultiPolygon] # short-hand for "name" property in the list below means all name-like # properties. all_name_variants: true properties: - name - where: >- - geom_type in ('Polygon', 'MultiPolygon') + - old_name - fn: vectordatasource.transform.handle_label_placement params: From cc8be28dfb9530dbaeb4f1f48bafb3b6eead5223 Mon Sep 17 00:00:00 2001 From: "Nathaniel V. KELSO" Date: Wed, 15 Dec 2021 22:36:29 -0800 Subject: [PATCH 09/10] Drop all the old_name water instances --- queries.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/queries.yaml b/queries.yaml index e8951d0c5..d5d9aad66 100644 --- a/queries.yaml +++ b/queries.yaml @@ -806,6 +806,7 @@ post_process: all_name_variants: true properties: - name + - old_name where: >- (kind == 'sea' and zoom < 4) or (kind == 'bay' and zoom < 5) or From 0e791383fc8b4f6e2e1339acd8925057b4353798 Mon Sep 17 00:00:00 2001 From: Peiti Li Date: Thu, 16 Dec 2021 15:17:46 -0800 Subject: [PATCH 10/10] fix integ tests --- integration-test/1477-water-layer-too-big.py | 1 - integration-test/1838-too-many-bays.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/integration-test/1477-water-layer-too-big.py b/integration-test/1477-water-layer-too-big.py index 6a863eaa0..26875890d 100644 --- a/integration-test/1477-water-layer-too-big.py +++ b/integration-test/1477-water-layer-too-big.py @@ -43,7 +43,6 @@ def test_drop_label(self): self.assert_has_feature( zoom, coord, coord, 'water', { 'kind': 'water', - 'name': 'Foo', }) # smaller shape should drop it diff --git a/integration-test/1838-too-many-bays.py b/integration-test/1838-too-many-bays.py index 243709fca..9c9fe08c2 100644 --- a/integration-test/1838-too-many-bays.py +++ b/integration-test/1838-too-many-bays.py @@ -33,9 +33,9 @@ def _bay(osm_id, area, name): ) with self.features_in_tile_layer(z, x, y, 'water') as features: - # should only have top 2 features - self.assertEqual(2, len(features)) + # should only have top 10 features + self.assertEqual(10, len(features)) # check that they're in order ranks = [f['properties']['kind_tile_rank'] for f in features] - self.assertEqual(range(1, 3), ranks) + self.assertEqual(range(1, 11), ranks)