source: subversion/applications/routing/pyroute/mod_base.py @ 5853

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

ability to add waypoints, which get stored back into whatever gpx file
was originally loaded (data/waypoints.gpx)

File size: 950 bytes
Line 
1import geometry
2from base import pyrouteModule
3
4class dataItem:
5  def __init__(self,lat,lon):
6    self.lat = lat
7    self.lon = lon
8    self.title = 'Untitled at %1.3f, %1.3f' % (lat,lon)
9  def formatText(self):
10    return(self.title)
11  def formatPos(self, ownPos = None):
12    if(ownPos and ownPos['valid']):
13      a = (ownPos['lat'], ownPos['lon'])
14      b = (self.lat,self.lon)
15      return("%1.2fkm at %03.1f" % \
16        (geometry.distance(a,b),
17        geometry.bearing(a,b)))
18    else:
19      return("%f,%f" % (self.lat,self.lon))
20
21class dataGroup:
22  def __init__(self,name):
23    self.items = []
24    self.name = name
25
26class dataSource(pyrouteModule):
27  def __init__(self, modules):
28    pyrouteModule.__init__(self, modules)
29    self.groups = []
30
31  def report(self):
32    for g in self.groups:
33      print "=== %s ===" % g.name
34      for i in g.items:
35        print "%1.3f, %1.3f = %s" % (i.lat, i.lon, i.title)
Note: See TracBrowser for help on using the repository browser.