LineIndex

class LineIndex(lines, reverse=False)

Wrapper to scipy.spatial.cKDTree to facilitate systematic processing of a line collection.

Implementation note: we use the available bool array because deleting stuff from the index is costly.

Methods

__getitem__

__init__

__len__

rtype

int

_find_nearest_in_index

Check the N nearest lines, hopefully find one that is active.

_find_nearest_within_in_index

Find nearest in specific index.

_make_index

rtype

None

_reindex

rtype

None

find_nearest

rtype

Tuple[int, bool]

find_nearest_within

Find the closest line, assuming a maximum admissible distance.

pop

rtype

Optional[ndarray]

pop_front

rtype

ndarray

Methods

LineIndex.__getitem__(item)
LineIndex.__init__(lines, reverse=False)
LineIndex.__len__()
Return type

int

LineIndex._find_nearest_in_index(p, index)

Check the N nearest lines, hopefully find one that is active.

Return type

Tuple[Optional[int], float]

LineIndex._find_nearest_within_in_index(p, max_dist, index)

Find nearest in specific index. Return (reindex, idx, dist) tuple, where reindex indicates if a reindex is needed.

Return type

Tuple[bool, Optional[int], Optional[float]]

LineIndex._make_index()
Return type

None

LineIndex._reindex()
Return type

None

LineIndex.find_nearest(p)
Return type

Tuple[int, bool]

LineIndex.find_nearest_within(p, max_dist)

Find the closest line, assuming a maximum admissible distance. Returns a tuple of (idx, reverse), where idx may be None if nothing is found. reverse indicates whether or not a line ending has been matched instead of a start. False is always returned if index was created with reverse=False.s

Return type

Tuple[Optional[int], bool]

LineIndex.pop(idx)
Return type

Optional[ndarray]

LineIndex.pop_front()
Return type

ndarray