From 8e5ac3bb8d83ac6a84f03edc33ef6c281f7610b3 Mon Sep 17 00:00:00 2001 From: "Nathaniel V. KELSO" Date: Wed, 8 Dec 2021 16:40:09 -0800 Subject: [PATCH 1/2] Add min_zoom = 17 for generated address points --- vectordatasource/transform.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vectordatasource/transform.py b/vectordatasource/transform.py index 385e28618..dd80f15ae 100644 --- a/vectordatasource/transform.py +++ b/vectordatasource/transform.py @@ -2557,6 +2557,7 @@ def generate_address_points(ctx): # address points. label_properties = dict( addr_housenumber=addr_housenumber, + min_zoom=17, kind='address') source = properties.get('source') From 67176c8b1a979380b3e003d59aa7f843d752002d Mon Sep 17 00:00:00 2001 From: Travis Grigsby Date: Wed, 15 Dec 2021 12:42:38 -0800 Subject: [PATCH 2/2] adding tests --- ...ilding-address-points-missing-min-zooms.py | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 integration-test/2032-building-address-points-missing-min-zooms.py diff --git a/integration-test/2032-building-address-points-missing-min-zooms.py b/integration-test/2032-building-address-points-missing-min-zooms.py new file mode 100644 index 000000000..99e5ea74a --- /dev/null +++ b/integration-test/2032-building-address-points-missing-min-zooms.py @@ -0,0 +1,136 @@ +# -*- encoding: utf-8 -*- +import dsl + +from . import FixtureTest + + +class BuildingAddressPointsMissingMinZooms(FixtureTest): + + def test_address_point_gen_has_min_zoom_17(self): + import dsl + + z, x, y = (16, 19299, 24630) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/265302092 + dsl.way(265302092, dsl.tile_box(z, x, y), { + 'addr:city': 'New York', + 'addr:housenumber': '1071', + 'addr:postcode': '10018', + 'addr:street': '6th Avenue', + 'building': 'yes', + 'building:colour': '#86816E', + 'building:levels': '12', + 'height': '46.6', + 'name': '1071 Sixth Avenue', + 'nycdoitt:bin': '1022566', + 'roof:material': 'concrete', + 'roof:shape': 'flat', + 'source': 'openstreetmap.org', + 'start_date': '1920', + }), + ) + + self.assert_has_feature( + z, x, y, 'buildings', { + 'id': 265302092, + 'addr_housenumber': '1071', + 'kind': 'address', + 'min_zoom': 17 + }) + + # at zoom 15, there should be no address points generated + def test_no_address_points_generated_below_zoom_16(self): + import dsl + + z, x, y = (15, 9649, 12315) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/265302092 + dsl.way(265302092, dsl.tile_box(z, x, y), { + 'addr:city': 'New York', + 'addr:housenumber': '1071', + 'addr:postcode': '10018', + 'addr:street': '6th Avenue', + 'building': 'yes', + 'building:colour': '#86816E', + 'building:levels': '12', + 'height': '46.6', + 'name': '1071 Sixth Avenue', + 'nycdoitt:bin': '1022566', + 'roof:material': 'concrete', + 'roof:shape': 'flat', + 'source': 'openstreetmap.org', + 'start_date': '1920', + }), + ) + + self.assert_no_matching_feature( + z, x, y, 'buildings', { + 'kind': 'address', + }) + + # if there is no housenumber, and the building name is just a number, use that + def test_address_point_falls_back_to_name(self): + import dsl + + z, x, y = (16, 19299, 24630) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/265302092 + dsl.way(265302092, dsl.tile_box(z, x, y), { + 'addr:city': 'New York', + # omitted 'addr:housenumber': '1071', + 'addr:postcode': '10018', + 'addr:street': '6th Avenue', + 'building': 'yes', + 'building:colour': '#86816E', + 'building:levels': '12', + 'height': '46.6', + 'name': '999', # modified to be a number + 'nycdoitt:bin': '1022566', + 'roof:material': 'concrete', + 'roof:shape': 'flat', + 'source': 'openstreetmap.org', + 'start_date': '1920', + }), + ) + + self.assert_has_feature( + z, x, y, 'buildings', { + 'id': 265302092, + 'addr_housenumber': '999', + 'kind': 'address', + 'min_zoom': 17 + }) + + # if there is no housenumber, and the building name is not just a number, don't make an address point + def test_no_address_point_if_no_usable_address(self): + import dsl + + z, x, y = (16, 19299, 24630) + + self.generate_fixtures( + # https://www.openstreetmap.org/way/265302092 + dsl.way(265302092, dsl.tile_box(z, x, y), { + 'addr:city': 'New York', + # omitted 'addr:housenumber': '1071', + 'addr:postcode': '10018', + 'addr:street': '6th Avenue', + 'building': 'yes', + 'building:colour': '#86816E', + 'building:levels': '12', + 'height': '46.6', + 'name': '1071 Sixth Avenue', + 'nycdoitt:bin': '1022566', + 'roof:material': 'concrete', + 'roof:shape': 'flat', + 'source': 'openstreetmap.org', + 'start_date': '1920', + }), + ) + + self.assert_no_matching_feature( + z, x, y, 'buildings', { + 'kind': 'address', + })