Changeset 02e3694
- Timestamp:
- 11/14/10 03:58:36 (3 years ago)
- Branches:
- master
- Children:
- 102aa48
- Parents:
- cb42f66
- git-author:
- xkolman2 <xkolman2@…> (11/14/10 03:58:36)
- git-committer:
- xkolman2 <xkolman2@…> (11/14/10 03:58:36)
- Location:
- modules
- Files:
-
- 11 edited
-
mod_loadTracklogs.pyc (modified) (previous)
-
mod_menu.pyc (modified) (previous)
-
mod_notification.pyc (modified) (previous)
-
mod_onlineServices.py (modified) (4 diffs)
-
mod_onlineServices.pyc (modified) (previous)
-
mod_options.pyc (modified) (previous)
-
mod_route.py (modified) (3 diffs)
-
mod_route.pyc (modified) (previous)
-
mod_tracklogManager.pyc (modified) (previous)
-
mod_turnByTurn.pyc (modified) (previous)
-
upoints/gpx.pyc (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
modules/mod_onlineServices.py
rcb42f66 r02e3694 122 122 local = self.googleLocalQuery(queryWithLL) 123 123 return local 124 125 126 124 127 125 def googleDirectionsAsync(self, start, destination, outputHandler, key): 128 126 """a background running googledirections query 129 outputHandler will be proided with the results + the specified key string""" 127 -> verbatim start and destination will be used in route descritpion, no geocoding 128 outputHandler will be provided with the results + the specified key string""" 129 self.routingThread = self.Worker(self, "onlineRoute", (start, destination), outputHandler, key) 130 self.routingThread.daemon = True 131 self.routingThread.start() 132 133 def googleDirectionsLLAsync(self, start, destination, outputHandler, key): 134 """a background running googledirections query 135 - Lat Lon pairsversion -> for geocoding the start/destination points (NOT first/last route points) 136 outputHandler will be provided with the results + the specified key string""" 130 137 self.routingThread = self.Worker(self, "onlineRouteLL", (start, destination), outputHandler, key) 131 138 self.routingThread.daemon = True … … 164 171 165 172 try: 173 print start, destination 166 174 directions = gmap.directions(start, destination, dir) 167 175 except: … … 169 177 try: 170 178 directions = gmap.directions(start, destination) 171 except Exception, e: 172 if e.status == 604: 173 print "onlineServices:Gdirections:ruting failed -> no route found" % e 174 self.sendMessage("ml:notification:m:No route found;3") 179 except googlemaps.googlemaps.GoogleMapsError, e: 180 if e.status == 602: 181 print "onlineServices:Gdirections:routing failed -> address not found" % e 182 self.sendMessage("ml:notification:m:Address(es) not found;5") 183 elif e.status == 604: 184 print "onlineServices:Gdirections:routing failed -> no route found" % e 185 self.sendMessage("ml:notification:m:No route found;5") 175 186 else: 176 187 print "onlineServices:Gdirections:ruting failed with exception:\n%s" % e 177 188 178 189 directions = [] 190 self.set('needRedraw', True) 179 191 180 192 else: … … 256 268 directions = self.getOnlineRoute(start,destination) 257 269 258 if type == "onlineRouteLL":270 if self.type == "onlineRouteLL": 259 271 # reverse geocode the start and destination coordinates (for the info menu) 260 272 (fromLat,fromLon) = start 261 273 (toLat,toLon) = destination 262 self.setStatusMessage("geocoding start ")274 self.setStatusMessage("geocoding start...") 263 275 startAddress = self.reverseGeocode(fromLat,fromLon) 264 self.setStatusMessage("geocoding destination ")276 self.setStatusMessage("geocoding destination...") 265 277 destinationAddress = self.reverseGeocode(toLat,toLon) 266 278 else: 267 startAddress = "start address unknown"268 destinationAddress = "destination address unknown"279 startAddress = start 280 destinationAddress = destination 269 281 self.setStatusMessage("online routing done") 270 282 # send the results to the output handler -
modules/mod_route.py
rcb42f66 r02e3694 205 205 traceback.print_exc(file=sys.stdout) 206 206 self.sendMessage('ml:notification:m:No route found;3') 207 self.set('needRedraw', True) 207 208 if "show" in args: 208 209 """switch to map view and go to start/destination, if requested""" … … 306 307 online = self.m.get('onlineServices', None) 307 308 if online: 308 # directions = online.googleDirectionsLL(fromLat, fromLon, toLat, toLon) 309 online.googleDirectionsAsync((fromLat, fromLon), (toLat, toLon), self.handleRoute, "onlineRoute") 309 online.googleDirectionsLLAsync((fromLat, fromLon), (toLat, toLon), self.handleRoute, "onlineRoute") 310 311 def doAddressRoute(self, start, destination): 312 """Route from one point to another, and set that as the active route""" 313 online = self.m.get('onlineServices', None) 314 if online: 315 print "routing from %s to %s" % (start,destination) 316 online.googleDirectionsAsync(start, destination, self.handleRoute, "onlineRouteAdress2Adress") 310 317 311 318 def handleRoute(self, key, resultsTupple): … … 316 323 # remove any possible prev. route description, so new a new one for this route is created 317 324 self.text = None 318 if directions: # is there actually something in th directions ?325 if directions: # is there actually something in the directions ? 319 326 polyline = directions['Directions']['Polyline']['points'] # the route is encoded as a polyline 320 327 route = self.decode_line(polyline) # we decode the polyline to a list of points 321 328 self.processAndSaveResults(route, directions, startAddress, destinationAddress) 322 323 def doAddressRoute(self, start, destination): 324 """Route from one point to another, and set that as the active route""" 325 online = self.m.get('onlineServices', None) 326 if online == None: 327 return 328 print "routing from %s to %s" % (start,destination) 329 directions = None 330 try: 331 directions = online.googleDirections(start, destination) 332 except googlemaps.googlemaps.GoogleMapsError, e: 333 if e.status == 602: # address/addresses not found 334 print "address not found" 335 self.sendMessage('notification:adress(es) not found#5') 336 337 if directions == None: 338 return 339 340 # remove any possible prev. route description, so new a new one for this route is created 341 self.text = None 342 343 polyline = directions['Directions']['Polyline']['points'] # the route is encoded as a polyline 344 route = self.decode_line(polyline) # we decode the polyline to a list of points 345 # handle the results 346 if len(route) >= 2: 347 start = (route[0]) 348 destination = (route[-1]) 349 self.processAndSaveResults(route, directions, start, destination) 329 elif key == "onlineRouteAdress2Adress": 330 if len(resultsTupple) == 3: 331 (directions, startAddress, destinationAddress) = resultsTupple 332 # remove any possible prev. route description, so new a new one for this route is created 333 self.text = None 334 if directions: # is there actually something in the directions ? 335 polyline = directions['Directions']['Polyline']['points'] # the route is encoded as a polyline 336 route = self.decode_line(polyline) # we decode the polyline to a list of points 337 self.processAndSaveResults(route, directions, startAddress, destinationAddress) 338 self.set('needRedraw', True) 350 339 351 340 def processAndSaveResults(self, route, directions, startAddress, destinationAddress):
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/trac/gps_navigace/chrome/site/nlp-logo.png)