kopia lustrzana https://github.com/hholzgra/ocitysmap
generating csv
rodzic
13aabc6043
commit
6cdbb10e3a
|
|
@ -287,6 +287,10 @@ class MapCanvas:
|
|||
if file_type == 'xml':
|
||||
mapnik.save_map(self._map, output_filename)
|
||||
return
|
||||
|
||||
elif file_type == 'csv':
|
||||
l.debug('not rendering map as csv (not supported)')
|
||||
return
|
||||
|
||||
elif file_type in ('png', 'png24'): # 24-bits, the default
|
||||
if (title is None) or (cairo is None):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8; mode: Python -*-
|
||||
|
||||
import logging, traceback
|
||||
import sys, os, tempfile, pgdb, re, math, cairo, locale, gzip
|
||||
import sys, os, tempfile, pgdb, re, math, cairo, locale, gzip, csv
|
||||
import ConfigParser
|
||||
from coords import BoundingBox
|
||||
|
||||
|
|
@ -469,6 +469,23 @@ class OCitySMap:
|
|||
|
||||
generator = IndexPageGenerator(self.streets)
|
||||
|
||||
if file_type == 'xml':
|
||||
l.debug('not rendering index as xml (not supported)')
|
||||
return
|
||||
|
||||
elif file_type == 'csv':
|
||||
try:
|
||||
writer = csv.writer(open(output_filename, 'w'))
|
||||
except Exception,ex:
|
||||
l.warning('error while opening destination file %s: %s'
|
||||
% (output_filename, ex))
|
||||
else:
|
||||
writer.writerow(['#', 'MapOSMatic', 'ISO-8859-1'])
|
||||
for street in self.streets:
|
||||
s = [e.encode('latin1', 'replace') for e in street]
|
||||
writer.writerow(s)
|
||||
return
|
||||
|
||||
if file_type in ('png', 'png24'):
|
||||
cairo_factory = \
|
||||
lambda w,h: cairo.ImageSurface(cairo.FORMAT_RGB24, w, h)
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue