diff --git a/GeoSpatialTools/quadtree.py b/GeoSpatialTools/quadtree.py index f58c41c3060787399d7a295e5225b6f69a207b9d..0dc942076962594b13ba5a3e39cd0ef421a40726 100644 --- a/GeoSpatialTools/quadtree.py +++ b/GeoSpatialTools/quadtree.py @@ -41,7 +41,7 @@ class Record: return None def __str__(self) -> str: - return f"Record(x = {self.lon}, y = {self.lat}, datetime = {self.datetime}, uid = {self.uid})" + return f"Record(lon = {self.lon}, lat = {self.lat}, datetime = {self.datetime}, uid = {self.uid})" def __eq__(self, other: object) -> bool: return ( @@ -52,6 +52,12 @@ class Record: and (not (self.uid or other.uid) or self.uid == other.uid) ) + def distance(self, other: object) -> float: + """Compute the Haversine distance to another Record""" + if not isinstance(other, Record): + raise TypeError("Argument other must be an instance of Record") + return haversine(self.lon, self.lat, other.lon, other.lat) + class Rectangle: """