Skip to content

Geolocation Coordinates

GeolocationCoordinates

Bases: ABC

The coordinates of a geographic location, in one coordinate reference system. Use one of the subclasses: GeographicCRS84, ProjectedLV95 or ProjectedLV03.

Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/geolocation.py
11
12
13
14
15
16
17
18
19
class GeolocationCoordinates(ABC):
    """
    The coordinates of a geographic location, in one coordinate reference system.
    Use one of the subclasses: `GeographicCRS84`, `ProjectedLV95` or `ProjectedLV03`.
    """

    @abstractmethod
    def to_tuple(self) -> tuple[dict[str, Any], CoordinateSystem]:
        """Returns the coordinates by their XML attribute name, and the coordinate reference system."""

GeographicCRS84

Bases: GeolocationCoordinates

Coordinates in WGS84, with the longitude first (CRS84).

Attributes:

Name Type Description
longitude Any

between -180 and 180

latitude Any

between -90 and 90

Examples:

coordinates = xmllib.GeographicCRS84.create_new(longitude="8.550", latitude="47.37")
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/geolocation.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@dataclass(frozen=True, kw_only=True)
class GeographicCRS84(GeolocationCoordinates):
    """
    Coordinates in WGS84, with the longitude first (CRS84).

    Attributes:
        longitude: between -180 and 180
        latitude: between -90 and 90

    Examples:
        ```python
        coordinates = xmllib.GeographicCRS84.create_new(longitude="8.550", latitude="47.37")
        ```
    """

    longitude: Any
    latitude: Any

    @classmethod
    def create_new(cls, *, longitude: Any, latitude: Any) -> GeographicCRS84:
        """
        Creates new coordinates in CRS84.
        Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

        Args:
            longitude: the longitude, between -180 and 180
            latitude: the latitude, between -90 and 90

        Returns:
            The coordinates
        """
        return cls(longitude=longitude, latitude=latitude)

    def to_tuple(self) -> tuple[dict[str, Any], CoordinateSystem]:
        return {"longitude": self.longitude, "latitude": self.latitude}, CoordinateSystem.GEOGRAPHIC_CRS84

create_new

Creates new coordinates in CRS84. Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

Parameters:

Name Type Description Default
longitude Any

the longitude, between -180 and 180

required
latitude Any

the latitude, between -90 and 90

required

Returns:

Type Description
GeographicCRS84

The coordinates

Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/geolocation.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@classmethod
def create_new(cls, *, longitude: Any, latitude: Any) -> GeographicCRS84:
    """
    Creates new coordinates in CRS84.
    Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

    Args:
        longitude: the longitude, between -180 and 180
        latitude: the latitude, between -90 and 90

    Returns:
        The coordinates
    """
    return cls(longitude=longitude, latitude=latitude)

ProjectedLV95

Bases: GeolocationCoordinates

Coordinates in the Swiss coordinate system LV95.

Attributes:

Name Type Description
easting Any

between 2484273.3 and 2837939.88

northing Any

between 1073150.16 and 1299970.97

Examples:

coordinates = xmllib.ProjectedLV95.create_new(easting="2600000", northing="1200000")
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/geolocation.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@dataclass(frozen=True, kw_only=True)
class ProjectedLV95(GeolocationCoordinates):
    """
    Coordinates in the Swiss coordinate system LV95.

    Attributes:
        easting: between 2484273.3 and 2837939.88
        northing: between 1073150.16 and 1299970.97

    Examples:
        ```python
        coordinates = xmllib.ProjectedLV95.create_new(easting="2600000", northing="1200000")
        ```
    """

    easting: Any
    northing: Any

    @classmethod
    def create_new(cls, *, easting: Any, northing: Any) -> ProjectedLV95:
        """
        Creates new coordinates in LV95.
        Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

        Args:
            easting: the easting
            northing: the northing

        Returns:
            The coordinates
        """
        return cls(easting=easting, northing=northing)

    def to_tuple(self) -> tuple[dict[str, Any], CoordinateSystem]:
        return {"easting": self.easting, "northing": self.northing}, CoordinateSystem.PROJECTED_LV95

create_new

Creates new coordinates in LV95. Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

Parameters:

Name Type Description Default
easting Any

the easting

required
northing Any

the northing

required

Returns:

Type Description
ProjectedLV95

The coordinates

Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/geolocation.py
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@classmethod
def create_new(cls, *, easting: Any, northing: Any) -> ProjectedLV95:
    """
    Creates new coordinates in LV95.
    Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

    Args:
        easting: the easting
        northing: the northing

    Returns:
        The coordinates
    """
    return cls(easting=easting, northing=northing)

ProjectedLV03

Bases: GeolocationCoordinates

Coordinates in the old Swiss coordinate system LV03.

Attributes:

Name Type Description
easting Any

between 484273.3 and 837939.88

northing Any

between 73150.16 and 299970.97

Examples:

coordinates = xmllib.ProjectedLV03.create_new(easting="600000", northing="200000")
Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/geolocation.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
@dataclass(frozen=True, kw_only=True)
class ProjectedLV03(GeolocationCoordinates):
    """
    Coordinates in the old Swiss coordinate system LV03.

    Attributes:
        easting: between 484273.3 and 837939.88
        northing: between 73150.16 and 299970.97

    Examples:
        ```python
        coordinates = xmllib.ProjectedLV03.create_new(easting="600000", northing="200000")
        ```
    """

    easting: Any
    northing: Any

    @classmethod
    def create_new(cls, *, easting: Any, northing: Any) -> ProjectedLV03:
        """
        Creates new coordinates in LV03.
        Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

        Args:
            easting: the easting
            northing: the northing

        Returns:
            The coordinates
        """
        return cls(easting=easting, northing=northing)

    def to_tuple(self) -> tuple[dict[str, Any], CoordinateSystem]:
        return {"easting": self.easting, "northing": self.northing}, CoordinateSystem.PROJECTED_LV03

create_new

Creates new coordinates in LV03. Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

Parameters:

Name Type Description Default
easting Any

the easting

required
northing Any

the northing

required

Returns:

Type Description
ProjectedLV03

The coordinates

Source code in dsp/dsp-tools/src/dsp_tools/xmllib/models/geolocation.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@classmethod
def create_new(cls, *, easting: Any, northing: Any) -> ProjectedLV03:
    """
    Creates new coordinates in LV03.
    Pass the coordinates as strings to preserve their decimal precision: a float drops trailing zeroes.

    Args:
        easting: the easting
        northing: the northing

    Returns:
        The coordinates
    """
    return cls(easting=easting, northing=northing)