+ use the same halo fill rgb(255,255,200) in both c++ and python demos

This commit is contained in:
artemp 2013-01-10 20:51:36 +00:00
parent 4a07a62bfd
commit b45a5aa76a

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# #
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# Copyright (C) 2005 Jean-Francois Doyon # Copyright (C) 2005 Jean-Francois Doyon
@ -186,7 +186,7 @@ m.layers.append(provlines_lyr)
roads34_lyr = mapnik.Layer('Roads') roads34_lyr = mapnik.Layer('Roads')
roads34_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" roads34_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
# create roads datasource (we're going to re-use it later) # create roads datasource (we're going to re-use it later)
roads34_lyr.datasource = mapnik.Shapefile(file='../data/roads') roads34_lyr.datasource = mapnik.Shapefile(file='../data/roads')
@ -221,7 +221,7 @@ m.layers.append(roads34_lyr)
roads2_lyr = mapnik.Layer('Roads') roads2_lyr = mapnik.Layer('Roads')
roads2_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs" roads2_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
# Just get a copy from roads34_lyr # Just get a copy from roads34_lyr
roads2_lyr.datasource = roads34_lyr.datasource roads2_lyr.datasource = roads34_lyr.datasource
roads2_style_1 = mapnik.Style() roads2_style_1 = mapnik.Style()
roads2_rule_1 = mapnik.Rule() roads2_rule_1 = mapnik.Rule()
@ -306,7 +306,7 @@ popplaces_text_symbolizer = mapnik.TextSymbolizer(mapnik.Expression("[GEONAME]")
# We set a "halo" around the text, which looks like an outline if thin enough, # We set a "halo" around the text, which looks like an outline if thin enough,
# or an outright background if large enough. # or an outright background if large enough.
popplaces_text_symbolizer.label_placement= mapnik.label_placement.POINT_PLACEMENT popplaces_text_symbolizer.label_placement= mapnik.label_placement.POINT_PLACEMENT
popplaces_text_symbolizer.halo_fill = mapnik.Color('white') popplaces_text_symbolizer.halo_fill = mapnik.Color(255,255,200)
popplaces_text_symbolizer.halo_radius = 1 popplaces_text_symbolizer.halo_radius = 1
popplaces_text_symbolizer.avoid_edges = True popplaces_text_symbolizer.avoid_edges = True
#popplaces_text_symbolizer.minimum_padding = 30 #popplaces_text_symbolizer.minimum_padding = 30
@ -322,7 +322,7 @@ m.layers.append(popplaces_lyr)
# Draw map # Draw map
# Set the initial extent of the map in 'master' spherical Mercator projection # 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)) m.zoom_to_box(mapnik.Box2d(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855))
# Render map # Render map
im = mapnik.Image(m.width,m.height) im = mapnik.Image(m.width,m.height)
@ -354,7 +354,7 @@ images_.append('demo.tif')
# Render cairo examples # Render cairo examples
if HAS_PYCAIRO_MODULE and mapnik.has_pycairo(): if HAS_PYCAIRO_MODULE and mapnik.has_pycairo():
svg_surface = cairo.SVGSurface('demo.svg', m.width,m.height) svg_surface = cairo.SVGSurface('demo.svg', m.width,m.height)
mapnik.render(m, svg_surface) mapnik.render(m, svg_surface)
svg_surface.finish() svg_surface.finish()
@ -368,7 +368,7 @@ if HAS_PYCAIRO_MODULE and mapnik.has_pycairo():
postscript_surface = cairo.PSSurface('demo.ps', m.width,m.height) postscript_surface = cairo.PSSurface('demo.ps', m.width,m.height)
mapnik.render(m, postscript_surface) mapnik.render(m, postscript_surface)
images_.append('demo.ps') images_.append('demo.ps')
postscript_surface.finish() postscript_surface.finish()
image_surface = cairo.ImageSurface(cairo.FORMAT_RGB24, m.width, m.height) image_surface = cairo.ImageSurface(cairo.FORMAT_RGB24, m.width, m.height)
mapnik.render(m, image_surface) mapnik.render(m, image_surface)
@ -381,12 +381,12 @@ if HAS_PYCAIRO_MODULE and mapnik.has_pycairo():
image_surface.write_to_png('demo_cairo_argb32.png') image_surface.write_to_png('demo_cairo_argb32.png')
images_.append('demo_cairo_argb32.png') images_.append('demo_cairo_argb32.png')
image_surface.finish() image_surface.finish()
else: else:
print '\n\nPycairo not available...', print '\n\nPycairo not available...',
if mapnik.has_cairo(): if mapnik.has_cairo():
print ' will render Cairo formats using alternative method' print ' will render Cairo formats using alternative method'
mapnik.render_to_file(m,'demo.pdf') mapnik.render_to_file(m,'demo.pdf')
images_.append('demo.pdf') images_.append('demo.pdf')
mapnik.render_to_file(m,'demo.ps') mapnik.render_to_file(m,'demo.ps')
@ -399,7 +399,7 @@ else:
images_.append('demo_cairo_argb.png') images_.append('demo_cairo_argb.png')
print "\n\n", len(images_), "maps have been rendered in the current directory:" print "\n\n", len(images_), "maps have been rendered in the current directory:"
for im_ in images_: for im_ in images_:
print "-", im_ print "-", im_