[polygons] only applying the new fix-on-read solution in the OSM admin/subdivision indices

This commit is contained in:
Al
2016-11-17 00:33:06 -05:00
parent c1d4b03bb4
commit d701bb1320
2 changed files with 8 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ class PolygonIndex(object):
preserve_topology = True
persistent_polygons = False
cache_size = 0
fix_invalid_polygons = False
INDEX_FILENAME = None
POLYGONS_DB_DIR = 'polygons'
@@ -167,7 +168,7 @@ class PolygonIndex(object):
holes = [(lon + 360.0 if lon < 0 else lon, lat) for lon, lat in holes]
poly = Polygon(coords, holes)
if not poly.is_valid and not poly.contains(poly.centroid):
if cls.fix_invalid_polygons and not poly.is_valid and not poly.contains(poly.centroid):
poly_fix = cls.fix_polygon(poly)
if poly_fix is not None and poly_fix.bounds and len(poly_fix.bounds) == 4 and poly_fix.is_valid and (poly_fix.contains(poly.centroid) or poly_fix.contains(poly_fix.representative_point())):
poly = poly_fix