Module pyaurorax.search.location

Class definition for AuroraX search engine location data

Classes

class Location (lat: float | None = None, lon: float | None = None)
Expand source code
class Location:
    """
    Representation for an AuroraX search engine location. This data can be in geodetic 
    coordinates, GSM coordinates, or geodetic northern/southern B-trace magnetic footprints.

    Latitude and longitude values are in decimal degrees format, ranging from -90 to 90
    for latitude and -180 to 180 for longitude.

    Note that latitude and longitude must both be numbers, or both be None.

    Attributes:
        lat (float): latitude value
        lon (float): longitude value
    
    Raises:
        ValueError: if both latitude and longitude are not real numbers, or not both None.
    """

    def __init__(self, lat: Optional[float] = None, lon: Optional[float] = None):
        if (lat is None and lon is not None) or (lat is not None and lon is None):
            # one of them is None, not allowed
            raise ValueError("Latitude and longitude must both be numbers, or both be None")
        self.__lat = lat
        self.__lon = lon

    @property
    def lat(self):
        return self.__lat

    @lat.setter
    def lat(self, value: float):
        if (self.__lon is None and value is not None) or (self.__lon is not None and value is None):
            # one of them is None, not allowed
            raise ValueError("Latitude and longitude must both be numbers, or both be None")
        self.__lat = value

    @property
    def lon(self):
        return self.__lon

    @lon.setter
    def lon(self, value: float):
        if (self.__lat is None and value is not None) or (self.__lat is not None and value is None):
            # one of them is None, not allowed
            raise ValueError("Latitude and longitude must both be numbers, or both be None")
        self.__lon = value

    def to_json_serializable(self) -> Dict:
        """
        Convert object to a JSON-serializable object (ie. translate
        datetime objects to strings)

        Returns:
            a dictionary object that is JSON-serializable
        """
        return {"lat": self.lat, "lon": self.lon}

    def __str__(self) -> str:
        return self.__repr__()

    def __repr__(self) -> str:
        return "%s(lat=%s, lon=%s)" % (self.__class__.__name__, str(self.lat), str(self.lon))

Representation for an AuroraX search engine location. This data can be in geodetic coordinates, GSM coordinates, or geodetic northern/southern B-trace magnetic footprints.

Latitude and longitude values are in decimal degrees format, ranging from -90 to 90 for latitude and -180 to 180 for longitude.

Note that latitude and longitude must both be numbers, or both be None.

Attributes

lat : float
latitude value
lon : float
longitude value

Raises

ValueError
if both latitude and longitude are not real numbers, or not both None.

Instance variables

prop lat
Expand source code
@property
def lat(self):
    return self.__lat
prop lon
Expand source code
@property
def lon(self):
    return self.__lon

Methods

def to_json_serializable(self) ‑> Dict
Expand source code
def to_json_serializable(self) -> Dict:
    """
    Convert object to a JSON-serializable object (ie. translate
    datetime objects to strings)

    Returns:
        a dictionary object that is JSON-serializable
    """
    return {"lat": self.lat, "lon": self.lon}

Convert object to a JSON-serializable object (ie. translate datetime objects to strings)

Returns

a dictionary object that is JSON-serializable