source: subversion/applications/routing/pyroute/routeOrDirect.py @ 5996

Last change on this file since 5996 was 5658, checked in by ojw, 12 years ago

direct route

File size: 1.6 KB
Line 
1from route import Router
2
3class RouteOrDirect(Router):
4    def __init__(self, data):
5        Router.__init__(self,data)
6        self.route = {'valid':False}
7        self.mode = 'direct';
8    def setMode(self, mode):
9      self.mode = mode
10    def setStartNode(self,node):
11        self.route['startnode'] = node
12        self.route['startpos'] = self.data.nodes[node]
13    def setEndNode(self,node):
14        self.route['endnode'] = node
15        self.route['endpos'] = self.data.nodes[node]
16    def setStartLL(self,lat,lon,transport):
17        self.route['startnode'] = self.data.findNode(lat,lon,transport)
18        self.route['startpos'] = (lat,lon)
19        self.route['transport'] = transport
20    def setEndLL(self,lat,lon,transport):
21        self.route['endnode'] = self.data.findNode(lat,lon,transport)
22        self.route['endpos'] = (lat,lon)
23        self.route['transport'] = transport
24    def update(self):
25      if(self.mode == 'route'):
26              result, newroute = self.doRouteAsLL( \
27                  self.route['startnode'],
28                  self.route['endnode'],
29                  self.route['transport'])
30              if result == 'success':
31                  self.route['route'] = newroute
32                  self.route['valid'] = True
33              else:
34                  self.route['route'] = [self.route['startpos'],self.route['endpos']]
35                  self.route['valid'] = True
36      else:
37        self.route['route'] = []
38        self.route['route'].append(self.route['startpos'])
39        self.route['route'].append(self.route['endpos'])
40        self.route['valid'] = True
41       
42    def valid(self):
43        return(self.route['valid'])
Note: See TracBrowser for help on using the repository browser.