From f00354c2d2353069559800c0b0080c6b2998fb47 Mon Sep 17 00:00:00 2001 From: Leander van Eekelen Date: Thu, 24 Oct 2024 14:27:37 +0200 Subject: [PATCH] Fill rtree via stream instead of via insertion --- wholeslidedata/annotation/selector.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wholeslidedata/annotation/selector.py b/wholeslidedata/annotation/selector.py index fb73ef23..83d5fa6c 100644 --- a/wholeslidedata/annotation/selector.py +++ b/wholeslidedata/annotation/selector.py @@ -21,9 +21,10 @@ class AnnotationSelector: def __init__(self, annotations: List[Annotation], sorters): self._annotations = annotations self._sorters = sorters - self._tree = index.Index() - for pos, annotation in enumerate(annotations): - self._tree.insert(pos, annotation.bounds) + self._tree = index.Index( + (pos, annotation.bounds, None) + for pos, annotation in enumerate(self._annotations) + ) def select_annotations( self, center_x: int, center_y: int, width: int, height: int