[openaddresses] adding clear_cache method to clear the LRU cache for point-in-polygon indices and using it in OpenAddresses import since it heavily reuses polygons and only for the current file
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import fiona
|
||||
import gc
|
||||
import geohash
|
||||
import os
|
||||
import rtree
|
||||
@@ -86,6 +87,12 @@ class PolygonIndex(object):
|
||||
def setup(self):
|
||||
pass
|
||||
|
||||
def clear_cache(self, garbage_collect=True):
|
||||
if self.persistent_polygons and self.cache_size > 0:
|
||||
self.polygons.clear()
|
||||
if garbage_collect:
|
||||
gc.collect()
|
||||
|
||||
def simplify_polygon(self, poly, simplify_tolerance=None, preserve_topology=None):
|
||||
if simplify_tolerance is None:
|
||||
simplify_tolerance = self.simplify_tolerance
|
||||
|
||||
Reference in New Issue
Block a user