source: subversion/applications/routing/pyroute_webGUI/tile_route.py @ 27976

Last change on this file since 27976 was 8121, checked in by ojw, 11 years ago

don't display nonexistant route files

File size: 1.5 KB
Line 
1#!/usr/bin/python
2#----------------------------------------------------------------
3# Generates map tiles showing a route from stored CSV file
4#----------------------------------------------------------------
5# Copyright 2008, Oliver White
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19#----------------------------------------------------------------
20from tile_base import TileBase
21
22class TileRoute(TileBase):
23  def __init__(self, filename):
24    self.filename = filename
25  def draw(self):
26    self.ctx.set_source_rgb(0, 0, 0)
27    f = open(self.filename, 'r')
28    if(f):
29      first = True
30      for line in f:
31        (id,lat,lon) = map(float, line.split(','))
32        (x,y) = self.proj.project(lat,lon)
33        #print "%f,%f -> %f,%f" % (lat,lon,x,y)
34        if(first):
35          self.ctx.move_to(x,y)
36          first = False
37        else:
38          self.ctx.line_to(x,y)
39      f.close()
40      self.ctx.stroke()
Note: See TracBrowser for help on using the repository browser.