LineIndex#
- class LineIndex(lines: Iterable[ndarray], reverse: bool = False)#
Wrapper to scipy.spatial.KDTree 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
Check the N nearest lines, hopefully find one that is active.
Find nearest in specific index.
Find the closest line, assuming a maximum admissible distance.
- Parameters:
lines (Iterable[np.ndarray]) --
reverse (bool) --
Methods#
- LineIndex._find_nearest_in_index(p: complex, index: KDTree) tuple[int | None, float] #
Check the N nearest lines, hopefully find one that is active.
- LineIndex._find_nearest_within_in_index(p: complex, max_dist: float, index: KDTree) tuple[bool, int | None, float | None] #
Find nearest in specific index. Return (reindex, idx, dist) tuple, where reindex indicates if a reindex is needed.
- LineIndex.find_nearest_within(p: complex, max_dist: float) tuple[int | None, bool] #
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.
- LineIndex.pop(idx: int) numpy.ndarray | None #
- Parameters:
idx (int) --
- Return type:
numpy.ndarray | None
- LineIndex.pop_front() ndarray #
- Return type:
ndarray