1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 """
22 Provide the tools to generate style sheets used by Mapnik for rendering maps.
23 """
24 import os.path
25
26 from sabx10.templating import TemplateProcessor, SabxProcessor, \
27 strip_end_slash
28
29 from consts import PIX_SCALE_FACTOR
30
32 """
33 Handle the processing of a style template. This will generate the style
34 sheet necessary for Mapnik to know how to generate a map.
35 """
36 - def __init__(self, template_file=None, man=None):
37 """
38 Add support for an OSM data file and a logo directory.
39
40 @param template_file: name of template file to use
41 @type template_file: C{string}
42 @param man: text for man page
43 @type man: C{string}
44 """
45 SabxProcessor.__init__(self, template_file, man)
46
47 self.parser.add_option("-d", "--datafile", dest="data_file",
48 help="osm data FILE name",
49 metavar="FILE")
50 self.parser.add_option("-l", "--logodir", dest="logo_dir",
51 help="osm logo directory",
52 metavar="LOGO")
53
54 self.template_data['PIX_SCALE_FACTOR'] = PIX_SCALE_FACTOR
55
57 """
58 Process the OSM data file file and logo directory.
59 """
60 SabxProcessor.process_options(self)
61
62 base_path, base_file = os.path.split(self.options.out_file)
63 self.template_data['osm_data'] = \
64 os.path.abspath(os.path.join(base_path, "map.osm"))
65 self.template_data['logo_dir'] = strip_end_slash(self.options.logo_dir)
66
68 """
69 Generate a template file for each ride in the rideset.
70 """
71 out_base = self.options.out_file
72 for index in range(len(self.template_data['ride_list'])):
73 self.template_data['route_index'] = index
74 self.options.out_file = "%s_%s.xml" % (out_base, index)
75 TemplateProcessor.process_template(self)
76