Created
March 3, 2021 22:03
-
-
Save MartinThoma/83f873232f4ac347678c41e293f65519 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dataclass | |
class Position: | |
longitude: float | |
latitude: float | |
address: Optional[str] = None | |
@property | |
def latitude(self) -> float: | |
"""Getter for latitude.""" | |
return self._latitude | |
@latitude.setter | |
def latitude(self, latitude: float) -> None: | |
"""Setter for latitude.""" | |
if not (-90 <= latitude <= 90): | |
raise ValueError(f"latitude was {latitude}, but has to be in [-90, 90]") | |
self._latitude = latitude | |
@property | |
def longitude(self) -> float: | |
"""Getter for longitude.""" | |
return self._longitude | |
@longitude.setter | |
def longitude(self, longitude: float) -> None: | |
"""Setter for longitude.""" | |
if not (-180 <= longitude <= 180): | |
raise ValueError(f"longitude was {longitude}, but has to be in [-180, 180]") | |
self._longitude = longitude |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment