source: subversion/applications/rendering/pyrender/renderer_labels.py @ 30322

Last change on this file since 30322 was 8499, checked in by spaetz, 11 years ago

refactor draw_ways out into a separate function. make zoom level available, so we can use different styles depending on that.

File size: 2.1 KB
Line 
1#!/usr/bin/python
2#----------------------------------------------------------------------------
3#
4#----------------------------------------------------------------------------
5# Copyright 2008, authors:
6# * Oliver White
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20#---------------------------------------------------------------------------
21from render_cairo_base import OsmRenderBase
22from tilenames import *
23
24class RenderClass(OsmRenderBase):
25 
26  # Specify the background for new tiles
27  def imageBackgroundColour(self, mapLayer=None):
28    return(0,0,0,0)
29  def requireDataTile(self):
30    return(False)
31 
32  # Draw a tile
33  def draw(self):
34    file = open("places.txt","r")
35    ctx = self.getCtx("mainlayer")
36
37    print self.proj.S, self.proj.dLat
38    #pLon = (lon - self.W) / self.dLon
39   
40    for line in file:
41      line = line.strip()
42      (lat,lon,id,type,name) = line.split("\t")
43      if(type in ('c', 't')):
44        (px,py) = latlon2relativeXY(float(lat), float(lon))
45        (x,y) = self.proj.project(py,px)
46        ctx.set_source_rgb(0.0, 0.0, 0.0)
47        ctx.set_font_size(12)
48        ctx.move_to(x,y)
49        ctx.show_text(name)
50        ctx.stroke()
51
52#-----------------------------------------------------------------
53# Test suite - call this file from the command-line to generate a
54# sample image
55if(__name__ == '__main__'):
56  a = RenderClass()
57  filename = "sample_"+__file__+".png"
58  a.RenderTile(8, 128, 84, 'default', filename) # norwch
59 
60  print "------------------------------------"
61  print "Saved image to " + filename
Note: See TracBrowser for help on using the repository browser.