From cfdb2d7e61e0c8af924219113cade4fea9b51b46 Mon Sep 17 00:00:00 2001 From: josidd <joseph.siddons@noc.ac.uk> Date: Tue, 15 Oct 2024 06:49:42 +0100 Subject: [PATCH] fix: account for Rectangle fully inside another in intersects method --- GeoSpatialTools/octtree.py | 10 ++++++++-- GeoSpatialTools/quadtree.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/GeoSpatialTools/octtree.py b/GeoSpatialTools/octtree.py index 0029986..2a8bc2a 100644 --- a/GeoSpatialTools/octtree.py +++ b/GeoSpatialTools/octtree.py @@ -224,8 +224,14 @@ class SpaceTimeRectangle: # Other is fully south of self return False # Handle east / west edges - return self._test_east_west(other.west) or self._test_east_west( - other.east + return ( + self._test_east_west(other.west) + or self._test_east_west(other.east) + # Fully contained within other + or ( + other._test_east_west(self.west) + and other._test_east_west(self.east) + ) ) def nearby( diff --git a/GeoSpatialTools/quadtree.py b/GeoSpatialTools/quadtree.py index 1bf7e7d..dc26f84 100644 --- a/GeoSpatialTools/quadtree.py +++ b/GeoSpatialTools/quadtree.py @@ -192,8 +192,14 @@ class Rectangle: # Other is fully south of self return False # Handle east / west edges - return self._test_east_west(other.west) or self._test_east_west( - other.east + return ( + self._test_east_west(other.west) + or self._test_east_west(other.east) + # Fully contained within other + or ( + other._test_east_west(self.west) + and other._test_east_west(self.east) + ) ) def nearby( -- GitLab