Commit 4f6461e8 authored by Joseph Siddons's avatar Joseph Siddons
Browse files

Merge remote-tracking branch 'upstream/main' into bounding_rect

parents 16bd1d75 9a529acd
......@@ -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(
......
......@@ -188,8 +188,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(
......
......@@ -10,7 +10,7 @@ to usage of type annotations.
As a dependency with `pip`
```bash
pip install git+git@git.noc.ac.uk:nocsurfaceprocesses/geospatialtools.git
pip install git+ssh://git@git.noc.ac.uk/nocsurfaceprocesses/geospatialtools.git
```
## Neighbours
......
......@@ -72,6 +72,16 @@ class TestRect(unittest.TestCase):
)
assert not rect.intersects(test_rect)
def test_inside(self):
# TEST: rectangle fully inside another
d = datetime(1978, 5, 17, 2, 33)
dt = timedelta(days=4, hours=7)
outer = Rectangle(-10, 10, d, -10, 10, dt)
inner = Rectangle(-5, 5, d, -5, 5, timedelta(days=1, hours=3))
assert outer.intersects(inner)
assert inner.intersects(outer)
class TestOctTree(unittest.TestCase):
def test_divides(self):
......
......@@ -46,6 +46,14 @@ class TestRect(unittest.TestCase):
test_rect = Rectangle(-140, -60, 20, 60)
assert rect.intersects(test_rect)
def test_inside(self):
# TEST: rectangle fully inside another
outer = Rectangle(-10, 10, -10, 10)
inner = Rectangle(-5, 5, -5, 5)
assert outer.intersects(inner)
assert inner.intersects(outer)
class TestQuadTree(unittest.TestCase):
def test_divides(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment