Commit cf00a44b authored by Joseph Siddons's avatar Joseph Siddons
Browse files

feat: add distance method to Record class

parent efe703bc
......@@ -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:
"""
......
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