From c77c13c1bd943c550c89c119ada75cc6175e6845 Mon Sep 17 00:00:00 2001 From: Al Date: Thu, 19 May 2016 01:43:09 -0400 Subject: [PATCH] [polygons] When loading polygons from disk/GeoJSON, include holes --- scripts/geodata/addresses/components.py | 2 +- scripts/geodata/polygons/index.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/geodata/addresses/components.py b/scripts/geodata/addresses/components.py index 4c63a2f5..bce99499 100644 --- a/scripts/geodata/addresses/components.py +++ b/scripts/geodata/addresses/components.py @@ -297,7 +297,7 @@ class AddressComponents(object): combo = weighted_choice(values, probs) if combo is not None: components = OrderedDict.fromkeys(combo['components']).keys() - if not all((c in address_components and (c in generated_components or self.is_numeric(address_components[c])) for c in components)): + if not all((c in address_components and (c in generated_components or address_components[c].isdigit()) for c in components)): return None values = [] diff --git a/scripts/geodata/polygons/index.py b/scripts/geodata/polygons/index.py index e8cd1efa..4e3ebd33 100644 --- a/scripts/geodata/polygons/index.py +++ b/scripts/geodata/polygons/index.py @@ -255,12 +255,13 @@ class PolygonIndex(object): def polygon_from_geojson(cls, feature): poly_type = feature['geometry']['type'] if poly_type == 'Polygon': - poly = cls.to_polygon(feature['geometry']['coordinates'][0]) + coords = feature['geometry']['coordinates'] + poly = cls.to_polygon(coords[0], holes=coords[1:] or None) return poly elif poly_type == 'MultiPolygon': polys = [] for coords in feature['geometry']['coordinates']: - poly = cls.to_polygon(coords[0]) + poly = cls.to_polygon(coords[0], holes=coords[1:] or None) polys.append(poly) return MultiPolygon(polys)