[fix] Reverting last two changes, have to fix on the OSM side
This commit is contained in:
@@ -104,7 +104,8 @@ class PolygonIndex(object):
|
|||||||
'''
|
'''
|
||||||
if not coords or len(coords) < 3:
|
if not coords or len(coords) < 3:
|
||||||
return None
|
return None
|
||||||
return Polygon(coords)
|
poly = Polygon(coords)
|
||||||
|
return cls.fix_polygon(poly)
|
||||||
|
|
||||||
def add_geojson_like_record(self, rec, include_only_properties=None):
|
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']:
|
if not rec or not rec.get('geometry') or 'type' not in rec['geometry']:
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from shapely.geos import TopologicalError
|
|
||||||
|
|
||||||
this_dir = os.path.realpath(os.path.dirname(__file__))
|
this_dir = os.path.realpath(os.path.dirname(__file__))
|
||||||
sys.path.append(os.path.realpath(os.path.join(os.pardir, os.pardir)))
|
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:
|
if poly is None or not poly.bounds or len(poly.bounds) != 4:
|
||||||
continue
|
continue
|
||||||
# Figure out which outer polygon contains each inner polygon
|
# Figure out which outer polygon contains each inner polygon
|
||||||
try:
|
interior = [p2 for p2 in inner if poly.contains(p2)]
|
||||||
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)]
|
|
||||||
|
|
||||||
if interior:
|
if interior:
|
||||||
# Polygon with holes constructor
|
# Polygon with holes constructor
|
||||||
|
|||||||
Reference in New Issue
Block a user