@@ -175,8 +175,45 @@ def map_from_gps(self, latitude = None, longitude = None, northing = None, easti
175175 if orientation is not None :
176176 if not isinstance (orientation , numtype ): raise TypeError ("Argument 'orientation' should have '{}' type" .format (numtype ))
177177 j ["orientation" ] = orientation
178- j = self .remote .command ("map/from_gps" , j )
179- return Transform .from_json (j )
178+ j = self .remote .command ("map/from_gps" , [j ])
179+ return Transform .from_json (j [0 ])
180+
181+ def map_from_gps_batch (self , coords ):
182+ # coords dictionary
183+ jarr = []
184+
185+ for c in coords :
186+ j = {}
187+ numtype = (int , float )
188+ if ("latitude" in c ) and ("longitude" in c ):
189+ if not isinstance (c ["latitude" ], numtype ): raise TypeError ("Argument 'latitude' should have '{}' type" .format (numtype ))
190+ if not isinstance (c ["longitude" ], numtype ): raise TypeError ("Argument 'longitude' should have '{}' type" .format (numtype ))
191+ if c ["latitude" ] < - 90 or c ["latitude" ] > 90 : raise ValueError ("Latitude is out of range" )
192+ if c ["longitude" ] < - 180 or c ["longitude" ] > 180 : raise ValueError ("Longitude is out of range" )
193+ j ["latitude" ] = c ["latitude" ]
194+ j ["longitude" ] = c ["longitude" ]
195+ elif ("northing" in c ) and ("easting" in c ):
196+ if not isinstance (c ["northing" ], numtype ): raise TypeError ("Argument 'northing' should have '{}' type" .format (numtype ))
197+ if not isinstance (c ["easting" ], numtype ): raise TypeError ("Argument 'easting' should have '{}' type" .format (numtype ))
198+ if c ["northing" ] < 0 or c ["northing" ] > 10000000 : raise ValueError ("Northing is out of range" )
199+ if c ["easting" ] < - 340000 or c ["easting" ] > 334000 : raise ValueError ("Easting is out of range" )
200+ j ["northing" ] = c ["northing" ]
201+ j ["easting" ] = c ["easting" ]
202+ else :
203+ raise Exception ("Either latitude and longitude or northing and easting should be specified" )
204+ if "altitude" in c :
205+ if not isinstance (c ["altitude" ], numtype ): raise TypeError ("Argument 'altitude' should have '{}' type" .format (numtype ))
206+ j ["altitude" ] = c ["altitude" ]
207+ if "orientation" in c :
208+ if not isinstance (c ["orientation" ], numtype ): raise TypeError ("Argument 'orientation' should have '{}' type" .format (numtype ))
209+ j ["orientation" ] = c ["orientation" ]
210+ jarr .append (j )
211+
212+ jarr = self .remote .command ("map/from_gps" , jarr )
213+ transforms = []
214+ for j in jarr :
215+ transforms .append (Transform .from_json (j ))
216+ return transforms
180217
181218 @accepts (Vector )
182219 def map_point_on_lane (self , point ):
0 commit comments