Spaces:
Runtime error
Runtime error
File size: 629 Bytes
1791df2 dfbe385 1791df2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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
) |