[polygons] Making simplify_tolerance and preserve_topology for polygon simplification configurable per class

This commit is contained in:
Al
2015-09-10 11:06:18 -07:00
parent 6a5b01b51b
commit fca7f21b1d
2 changed files with 9 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ DEFAULT_POLYS_FILENAME = 'polygons.geojson'
class RTreePolygonIndex(object):
include_only_properties = None
simplify_tolerance = 0.0001
preserve_topology = True
def __init__(self, index=None, polygons=None, save_dir=None,
index_filename=None,
@@ -46,7 +48,11 @@ class RTreePolygonIndex(object):
def index_polygon(self, id, polygon):
self.index.insert(id, polygon.bounds)
def simplify_polygon(self, poly, simplify_tolerance=0.0001, preserve_topology=True):
def simplify_polygon(self, poly, simplify_tolerance=None, preserve_topology=None):
if simplify_tolerance is None:
simplify_tolerance = self.simplify_tolerance
if preserve_topology is None:
preserve_topology = self.preserve_topology
return poly.simplify(simplify_tolerance, preserve_topology=preserve_topology)
def add_polygon(self, poly, properties):

View File

@@ -26,6 +26,8 @@ class LanguagePolygonIndex(RTreePolygonIndex):
'admin_level'
])
simplify_tolerance = 0.00001
@classmethod
def create_from_shapefiles(cls,
admin0_shapefile,