source: subversion/applications/routing/pyroute-dev/routeOrDirect.py @ 18449

Last change on this file since 18449 was 18449, checked in by buerste, 10 years ago

-adding rev replacement

  • Property svn:keywords set to Rev
File size: 2.1 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""
5"""
6
7__version__ = "$Rev: 18449 $"
8__license__ = """This program is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 3 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program. If not, see <http://www.gnu.org/licenses/>."""
20_debug = 0
21
22
23from route import Router
24
25class RouteOrDirect(Router):
26        def __init__(self, data):
27                Router.__init__(self,data)
28                self.route = {'valid':False}
29                self.mode = 'direct';
30        def setMode(self, mode):
31                self.mode = mode
32        def setStartNode(self,node):
33                self.route['startnode'] = node
34                self.route['startpos'] = self.data.nodes[node]
35        def setEndNode(self,node):
36                self.route['endnode'] = node
37                self.route['endpos'] = self.data.nodes[node]
38        def setStartLL(self,lat,lon,transport):
39                self.route['startnode'] = self.data.findNode(lat,lon,transport)
40                self.route['startpos'] = (lat,lon)
41                self.route['transport'] = transport
42        def setEndLL(self,lat,lon,transport):
43                self.route['endnode'] = self.data.findNode(lat,lon,transport)
44                self.route['endpos'] = (lat,lon)
45                self.route['transport'] = transport
46        def update(self):
47                if(self.mode == 'route'):
48                        result, newroute = self.doRouteAsLL( \
49                                self.route['startnode'],
50                                self.route['endnode'],
51                                self.route['transport'])
52                        if result == 'success':
53                                self.route['route'] = newroute
54                                self.route['valid'] = True
55                        else:
56                                self.route['route'] = [self.route['startpos'],self.route['endpos']]
57                                self.route['valid'] = True
58                else:
59                        self.route['route'] = []
60                        self.route['route'].append(self.route['startpos'])
61                        self.route['route'].append(self.route['endpos'])
62                        self.route['valid'] = True
63               
64        def valid(self):
65                return(self.route['valid'])
Note: See TracBrowser for help on using the repository browser.