mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
Better tests.
Reference images.
This commit is contained in:
parent
fae698bc59
commit
a47019ac7b
BIN
tests/visual_tests/python-MyText-reference.png
Normal file
BIN
tests/visual_tests/python-MyText-reference.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
BIN
tests/visual_tests/python-TextNode-reference.png
Normal file
BIN
tests/visual_tests/python-TextNode-reference.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@ -6,27 +6,33 @@ class MyText(mapnik.FormatingNode):
|
||||
def __init__(self):
|
||||
mapnik.FormatingNode.__init__(self)
|
||||
self.expr = mapnik.Expression("[name]")
|
||||
self.expr_nr = mapnik.Expression("[nr]")
|
||||
|
||||
def apply(self, properties, feature, output):
|
||||
colors = [mapnik.Color('red'),
|
||||
mapnik.Color('green'),
|
||||
mapnik.Color('blue')]
|
||||
text = self.expr.evaluate(feature)
|
||||
i = 0
|
||||
my_properties = mapnik.CharProperties(properties)
|
||||
for char in text:
|
||||
my_properties.fill = colors[i % len(colors)]
|
||||
output.append(my_properties, char)
|
||||
i += 1
|
||||
if int(feature['nr']) > 5:
|
||||
i = 0
|
||||
my_properties = mapnik.CharProperties(properties)
|
||||
for char in text:
|
||||
my_properties.fill = colors[i % len(colors)]
|
||||
output.append(my_properties, char)
|
||||
i += 1
|
||||
else:
|
||||
output.append(properties, text)
|
||||
|
||||
def add_expressions(self, output):
|
||||
output.insert(self.expr)
|
||||
output.insert(self.expr_nr)
|
||||
|
||||
m = mapnik.Map(600,300)
|
||||
m = mapnik.Map(600, 100)
|
||||
m.background = mapnik.Color('white')
|
||||
|
||||
text = mapnik.TextSymbolizer()
|
||||
text.face_name = 'DejaVu Sans Book'
|
||||
text.placements.defaults.displacement = (0, 5)
|
||||
text.placements.defaults.default_format.face_name = 'DejaVu Sans Book'
|
||||
|
||||
point = mapnik.PointSymbolizer()
|
||||
|
||||
@ -45,7 +51,8 @@ layer.datasource = mapnik.Shapefile(file="points.shp")
|
||||
layer.styles.append('Style')
|
||||
m.layers.append(layer)
|
||||
|
||||
m.zoom_all()
|
||||
bbox = mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)
|
||||
m.zoom_to_box(bbox)
|
||||
|
||||
|
||||
format_trees = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user