diff --git a/src/stratigraphy/util/geometric_line_utilities.py b/src/stratigraphy/util/geometric_line_utilities.py index 88d927e8..87ad54cb 100644 --- a/src/stratigraphy/util/geometric_line_utilities.py +++ b/src/stratigraphy/util/geometric_line_utilities.py @@ -227,7 +227,6 @@ def merge_parallel_lines_quadtree(lines: list[Line], tol: int, angle_threshold: lines_quad_tree = LinesQuadTree(width, height) keys_queue = queue.Queue() - print("lines", len(lines)) for line in lines: line_key = lines_quad_tree.add(line) keys_queue.put(line_key) diff --git a/src/stratigraphy/util/linesquadtree.py b/src/stratigraphy/util/linesquadtree.py index 5f5c9bbb..76aa8afc 100644 --- a/src/stratigraphy/util/linesquadtree.py +++ b/src/stratigraphy/util/linesquadtree.py @@ -14,12 +14,28 @@ class LinesQuadTree: """ def __init__(self, width: float, height: float): + """Create a LinesQuadTree instance. + + The LinesQuadTree will contain an actual quad tree with the end points of all lines, as well as a hashmap to + keep track of the lines themselves. + + Args: + width (float): width of the area that should contain all (endpoints of) all lines. + height (float): height of the area that should contain all (endpoints of) all lines. + """ self.qtree = quads.QuadTree( (width / 2, height / 2), width + 1000, height + 1000 ) # Add some margin to the width and height to allow for slightly negative values self.hashmap = {} def remove(self, line_key: str): + """Remove a line from the quad tree. + + If no matching line exists in the quad tree, then the method returns immediately without error. + + Args: + line_key (str): The key of the line to be removed from the quad tree. + """ if line_key in self.hashmap: line = self.hashmap[line_key] self._qtree_delete(line.start, line_key) @@ -27,6 +43,15 @@ def remove(self, line_key: str): del self.hashmap[line_key] def add(self, line: Line) -> str: + """Add a line to the quad tree. + + Args: + line (Line): the line to be added to the quad tree. + + Returns: + str: the UUID key that is automatically generated for the new line. + + """ line_key = uuid.uuid4().hex self.hashmap[line_key] = line