[polygons] only applying the new fix-on-read solution in the OSM admin/subdivision indices
This commit is contained in:
@@ -25,6 +25,7 @@ class PolygonIndex(object):
|
|||||||
preserve_topology = True
|
preserve_topology = True
|
||||||
persistent_polygons = False
|
persistent_polygons = False
|
||||||
cache_size = 0
|
cache_size = 0
|
||||||
|
fix_invalid_polygons = False
|
||||||
|
|
||||||
INDEX_FILENAME = None
|
INDEX_FILENAME = None
|
||||||
POLYGONS_DB_DIR = 'polygons'
|
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]
|
holes = [(lon + 360.0 if lon < 0 else lon, lat) for lon, lat in holes]
|
||||||
|
|
||||||
poly = Polygon(coords, 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)
|
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())):
|
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
|
poly = poly_fix
|
||||||
|
|||||||
@@ -289,6 +289,8 @@ class OSMReverseGeocoder(RTreePolygonIndex):
|
|||||||
cache_size = 250000
|
cache_size = 250000
|
||||||
simplify_polygons = False
|
simplify_polygons = False
|
||||||
|
|
||||||
|
fix_invalid_polygons = True
|
||||||
|
|
||||||
include_property_patterns = set([
|
include_property_patterns = set([
|
||||||
'id',
|
'id',
|
||||||
'type',
|
'type',
|
||||||
@@ -436,6 +438,7 @@ class OSMReverseGeocoder(RTreePolygonIndex):
|
|||||||
candidates = super(OSMReverseGeocoder, self).get_candidate_polygons(lat, lon)
|
candidates = super(OSMReverseGeocoder, self).get_candidate_polygons(lat, lon)
|
||||||
return sorted(candidates, key=self.sort_level, reverse=True)
|
return sorted(candidates, key=self.sort_level, reverse=True)
|
||||||
|
|
||||||
|
|
||||||
class OSMSubdivisionReverseGeocoder(OSMReverseGeocoder):
|
class OSMSubdivisionReverseGeocoder(OSMReverseGeocoder):
|
||||||
persistent_polygons = True
|
persistent_polygons = True
|
||||||
cache_size = 10000
|
cache_size = 10000
|
||||||
@@ -448,6 +451,9 @@ class OSMBuildingReverseGeocoder(OSMReverseGeocoder):
|
|||||||
persistent_polygons = True
|
persistent_polygons = True
|
||||||
cache_size = 10000
|
cache_size = 10000
|
||||||
simplify_polygons = False
|
simplify_polygons = False
|
||||||
|
|
||||||
|
fix_invalid_polygons = False
|
||||||
|
|
||||||
polygon_reader = OSMBuildingPolygonReader
|
polygon_reader = OSMBuildingPolygonReader
|
||||||
include_property_patterns = OSMReverseGeocoder.include_property_patterns | set(['building', 'building:levels', 'building:part', 'addr:*'])
|
include_property_patterns = OSMReverseGeocoder.include_property_patterns | set(['building', 'building:levels', 'building:part', 'addr:*'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user