From 05912281a56609424f41a89a5a1681730c6a311e Mon Sep 17 00:00:00 2001 From: josidd <joseph.siddons@noc.ac.uk> Date: Wed, 27 Nov 2024 11:01:10 +0000 Subject: [PATCH] feat: add missing spatial distance method to SpaceTimeRecord class --- GeoSpatialTools/octtree.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/GeoSpatialTools/octtree.py b/GeoSpatialTools/octtree.py index d989bbc..a82a2be 100644 --- a/GeoSpatialTools/octtree.py +++ b/GeoSpatialTools/octtree.py @@ -80,6 +80,15 @@ class SpaceTimeRecord: and (not (self.uid or other.uid) or self.uid == other.uid) ) + def distance(self, other: object) -> float: + """ + Compute the Haversine distance to another SpaceTimeRecord. + Only computes spatial distance. + """ + if not isinstance(other, SpaceTimeRecord): + raise TypeError("Argument other must be an instance of Record") + return haversine(self.lon, self.lat, other.lon, other.lat) + class SpaceTimeRecords(List[SpaceTimeRecord]): """List of SpaceTimeRecords""" -- GitLab