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

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

Changes from the weekend

File size: 1.3 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   
8    def setStartNode(self,node):
9        self.route['startnode'] = node
10        self.route['startpos'] = self.data.nodes[node]
11    def setEndNode(self,node):
12        self.route['endnode'] = node
13        self.route['endpos'] = self.data.nodes[node]
14    def setStartLL(self,lat,lon,transport):
15        self.route['startnode'] = self.data.findNode(lat,lon,transport)
16        self.route['startpos'] = (lat,lon)
17        self.route['transport'] = transport
18    def setEndLL(self,lat,lon,transport):
19        self.route['endnode'] = self.data.findNode(lat,lon,transport)
20        self.route['endpos'] = (lat,lon)
21        self.route['transport'] = transport
22    def update(self):
23        result, newroute = self.doRouteAsLL( \
24            self.route['startnode'],
25            self.route['endnode'],
26            self.route['transport'])
27        if result == 'success':
28            self.route['route'] = newroute
29            self.route['valid'] = True
30        else:
31            self.route['route'] = [self.route['startpos'],self.route['endpos']]
32            self.route['valid'] = True
33    def valid(self):
34        return(self.route['valid'])
Note: See TracBrowser for help on using the repository browser.