[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

View File

@@ -289,6 +289,8 @@ class OSMReverseGeocoder(RTreePolygonIndex):
cache_size = 250000
simplify_polygons = False
fix_invalid_polygons = True
include_property_patterns = set([
'id',
'type',
@@ -436,6 +438,7 @@ class OSMReverseGeocoder(RTreePolygonIndex):
candidates = super(OSMReverseGeocoder, self).get_candidate_polygons(lat, lon)
return sorted(candidates, key=self.sort_level, reverse=True)
class OSMSubdivisionReverseGeocoder(OSMReverseGeocoder):
persistent_polygons = True
cache_size = 10000
@@ -448,6 +451,9 @@ class OSMBuildingReverseGeocoder(OSMReverseGeocoder):
persistent_polygons = True
cache_size = 10000
simplify_polygons = False
fix_invalid_polygons = False
polygon_reader = OSMBuildingPolygonReader
include_property_patterns = OSMReverseGeocoder.include_property_patterns | set(['building', 'building:levels', 'building:part', 'addr:*'])