@@ -49,21 +49,6 @@ def __init__(
4949 ------
5050 ValueError: If coordinates are out of valid range or if altitude_accuracy is provided without altitude.
5151 """
52- if not (- 90.0 <= latitude <= 90.0 ):
53- raise ValueError ("Latitude must be between -90.0 and 90.0" )
54- if not (- 180.0 <= longitude <= 180.0 ):
55- raise ValueError ("Longitude must be between -180.0 and 180.0" )
56- if accuracy < 0.0 :
57- raise ValueError ("Accuracy must be >= 0.0" )
58- if altitude_accuracy is not None and altitude is None :
59- raise ValueError ("altitude_accuracy cannot be set without altitude" )
60- if altitude_accuracy is not None and altitude_accuracy < 0.0 :
61- raise ValueError ("Altitude accuracy must be >= 0.0" )
62- if heading is not None and not (0.0 <= heading < 360.0 ):
63- raise ValueError ("Heading must be between 0.0 and 360.0" )
64- if speed is not None and speed < 0.0 :
65- raise ValueError ("Speed must be >= 0.0" )
66-
6752 self .latitude = latitude
6853 self .longitude = longitude
6954 self .accuracy = accuracy
@@ -72,6 +57,76 @@ def __init__(
7257 self .heading = heading
7358 self .speed = speed
7459
60+ @property
61+ def latitude (self ):
62+ return self ._latitude
63+
64+ @latitude .setter
65+ def latitude (self , value ):
66+ if not (- 90.0 <= value <= 90.0 ):
67+ raise ValueError ("Latitude must be between -90.0 and 90.0" )
68+ self ._latitude = value
69+
70+ @property
71+ def longitude (self ):
72+ return self ._longitude
73+
74+ @longitude .setter
75+ def longitude (self , value ):
76+ if not (- 180.0 <= value <= 180.0 ):
77+ raise ValueError ("Longitude must be between -180.0 and 180.0" )
78+ self ._longitude = value
79+
80+ @property
81+ def accuracy (self ):
82+ return self ._accuracy
83+
84+ @accuracy .setter
85+ def accuracy (self , value ):
86+ if value < 0.0 :
87+ raise ValueError ("Accuracy must be >= 0.0" )
88+ self ._accuracy = value
89+
90+ @property
91+ def altitude (self ):
92+ return self ._altitude
93+
94+ @altitude .setter
95+ def altitude (self , value ):
96+ self ._altitude = value
97+
98+ @property
99+ def altitude_accuracy (self ):
100+ return self ._altitude_accuracy
101+
102+ @altitude_accuracy .setter
103+ def altitude_accuracy (self , value ):
104+ if value is not None and self .altitude is None :
105+ raise ValueError ("altitude_accuracy cannot be set without altitude" )
106+ if value is not None and value < 0.0 :
107+ raise ValueError ("Altitude accuracy must be >= 0.0" )
108+ self ._altitude_accuracy = value
109+
110+ @property
111+ def heading (self ):
112+ return self ._heading
113+
114+ @heading .setter
115+ def heading (self , value ):
116+ if value is not None and not (0.0 <= value < 360.0 ):
117+ raise ValueError ("Heading must be between 0.0 and 360.0" )
118+ self ._heading = value
119+
120+ @property
121+ def speed (self ):
122+ return self ._speed
123+
124+ @speed .setter
125+ def speed (self , value ):
126+ if value is not None and value < 0.0 :
127+ raise ValueError ("Speed must be >= 0.0" )
128+ self ._speed = value
129+
75130 def to_dict (self ) -> dict [str , Union [float , None ]]:
76131 result : dict [str , Union [float , None ]] = {
77132 "latitude" : self .latitude ,
0 commit comments