From 48a305c8c4672119f1e241b44db7757d0ff68009 Mon Sep 17 00:00:00 2001 From: Al Date: Sun, 1 Nov 2015 16:23:41 -0500 Subject: [PATCH] [fix] Reverting last two changes, have to fix on the OSM side --- scripts/geodata/polygons/index.py | 3 ++- scripts/geodata/polygons/reverse_geocode.py | 15 +-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/scripts/geodata/polygons/index.py b/scripts/geodata/polygons/index.py index 26a87a10..1df9c074 100644 --- a/scripts/geodata/polygons/index.py +++ b/scripts/geodata/polygons/index.py @@ -104,7 +104,8 @@ class PolygonIndex(object): ''' if not coords or len(coords) < 3: return None - return Polygon(coords) + poly = Polygon(coords) + return cls.fix_polygon(poly) def add_geojson_like_record(self, rec, include_only_properties=None): if not rec or not rec.get('geometry') or 'type' not in rec['geometry']: diff --git a/scripts/geodata/polygons/reverse_geocode.py b/scripts/geodata/polygons/reverse_geocode.py index 448c89cd..5d63f637 100644 --- a/scripts/geodata/polygons/reverse_geocode.py +++ b/scripts/geodata/polygons/reverse_geocode.py @@ -23,7 +23,6 @@ import sys import tempfile from functools import partial -from shapely.geos import TopologicalError this_dir = os.path.realpath(os.path.dirname(__file__)) sys.path.append(os.path.realpath(os.path.join(os.pardir, os.pardir))) @@ -688,19 +687,7 @@ class OSMReverseGeocoder(RTreePolygonIndex): if poly is None or not poly.bounds or len(poly.bounds) != 4: continue # Figure out which outer polygon contains each inner polygon - try: - interior = [p2 for p2 in inner if poly.contains(p2)] - except TopologicalError: - poly = cls.fix_polygon(poly) - fixed_inner = [] - for p in inner: - p = cls.fix_polygon(p) - if p.type != 'MultiPolygon': - fixed_inner.append(p) - else: - fixed_inner.extend(p) - inner = fixed_inner - interior = [p2 for p2 in inner if poly.contains(p2)] + interior = [p2 for p2 in inner if poly.contains(p2)] if interior: # Polygon with holes constructor