Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def point_index_class_factory(implementation='best'):
if implementation in ['rtree','best']:
try:
from rtree.index import Rtree
# try to mimic the Rtree interface - starting by just using it...
return Rtree
except ImportError:
if implementation=='rtree':
raise
# otherwise fall through to next best
if implementation in ['qgis','best']:
try:
from . import qgis_spatialindex
return qgis_spatialindex.RtreeQgis
except ImportError:
if implementation=='qgis':
raise
# otherwise fall through to next
if implementation in ['kdtree','best']:
try:
def __init__(self, path=None):
if path is None:
self._index = index.Index()
else:
self._index = index.Rtree(path)