import numpy as np from pydantic.main import BaseModel class Coordinate(BaseModel): latitude: float longitude: float def __str__(self): return f"({round(self.latitude, 6)}, {round(self.longitude, 6)})" def to_radians(self) -> 'Coordinate': return Coordinate( latitude=self.latitude * np.pi / 180., longitude=self.longitude * np.pi / 180. ) @staticmethod def from_radians(latitude: float, longitude: float) -> 'Coordinate': return Coordinate( latitude=latitude * 180. / np.pi, longitude=longitude * 180. / np.pi )