m.append_style('popplaces', popplaces_style) popplaces_lyr.styles.append('popplaces') m.layers.append(popplaces_lyr) # Draw map # Set the initial extent of the map in 'master' spherical Mercator projection m.zoom_to_box(mapnik.Box2d(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855)) # Render map im = mapnik.Image(m.width,m.height) mapnik.render(m, im) # Save image to files images_ = [] if mapnik.has_png(): im.save('demo.png', 'png') # true-colour RGBA images_.append('demo.png') # old behavior, now can do 'png8:c=256' im.save('demo256.png', 'png256') # save to palette based (max 256 colours) png images_.append('demo256.png') im.save('demo64_binary_transparency.png', 'png8:c=64:t=1') images_.append('demo64_binary_transparency.png') im.save('demo128_colors_hextree_no_alpha.png', 'png8:c=100:m=h:t=0') images_.append('demo128_colors_hextree_no_alpha.png') if mapnik.has_jpeg(): im.save('demo_high.jpg', 'jpeg100')
import os from nose.tools import eq_ import mapnik from .utilities import execution_path, run_all def setup(): # All of the paths used are relative, if we run the tests # from another directory we need to chdir() os.chdir(execution_path('.')) if mapnik.has_png(): tmp_dir = '/tmp/mapnik-png/' if not os.path.exists(tmp_dir): os.makedirs(tmp_dir) opts = [ 'png32', 'png32:t=0', 'png8:m=o', 'png8:m=o:c=1', 'png8:m=o:t=0', 'png8:m=o:c=1:t=0', 'png8:m=o:t=1', 'png8:m=o:t=2', 'png8:m=h', 'png8:m=h:c=1', 'png8:m=h:t=0', 'png8:m=h:c=1:t=0', 'png8:m=h:t=1', 'png8:m=h:t=2' ] # Todo - use itertools.product #z_opts = range(1,9+1) #t_opts = range(0,2+1)