Render ShieldSymbolizer tests with varying width. Triggers the problem in #1078.

Update script to handle case when no reference image is found.
This commit is contained in:
Hermann Kraus 2012-02-20 17:42:12 +01:00
parent 6f5d16bfe3
commit 73339b3936
2 changed files with 35 additions and 20 deletions

View file

@ -20,7 +20,11 @@ def compare_pixels(pixel1, pixel2):
def compare(fn1, fn2):
global errors
im1 = Image.open(fn1)
im2 = Image.open(fn2)
try:
im2 = Image.open(fn2)
except IOError:
errors.append((fn1, None))
return -1
diff = 0
pixels = im1.size[0] * im1.size[1]
im1 = im1.getdata()
@ -38,6 +42,9 @@ def summary():
print "-"*80
print "Summary:"
for error in errors:
print "%s failed: %d different pixels" % error
if (error[1] is None):
print "Could not verify %s: No reference image found!" % error[0]
else:
print "%s failed: %d different pixels" % error
print "-"*80
sys.exit(1)

View file

@ -8,15 +8,26 @@ import os.path
from compare import compare, summary
dirname = os.path.dirname(sys.argv[0])
widths = [ 800, 600, 400, 300, 250, 200, 150, 100]
filenames = ["list", "simple"]
filenames_one_width = ["simple-E", "simple-NE", "simple-NW", "simple-N",
"simple-SE", "simple-SW", "simple-S", "simple-W",
"formating-1", "formating-2", "formating-3", "formating-4",
"shieldsymbolizer-1", "expressionformat"]
files = [
("list", 800, 600, 400, 300, 250, 200, 150, 100),
("simple", 800, 600, 400, 300, 250, 200, 150, 100),
("simple-E", 500),
("simple-NE", 500),
("simple-NW", 500),
("simple-N", 500),
("simple-SE", 500),
("simple-SW", 500),
("simple-S", 500),
("simple-W", 500),
("formating-1", 500),
("formating-2", 500),
("formating-3", 500),
("formating-4", 500),
("shieldsymbolizer-1", 490, 495, 497, 498, 499, 500, 501, 502, 505, 510),
("expressionformat", 500)]
def render(filename, width):
width = int(width)
m = mapnik.Map(width, 100)
mapnik.load_map(m, os.path.join(dirname, "%s.xml" % filename), False)
bbox = mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)
@ -32,18 +43,15 @@ def render(filename, width):
print "Rendering style \"%s\" with width %d ... %s" % (filename, width, rms)
return m
if len(sys.argv) > 1:
filenames = []
filenames_one_width = sys.argv[1:]
if len(sys.argv) == 2:
files = [(sys.argv[1], 500)]
elif len(sys.argv) > 2:
files = [sys.argv[1:]]
for filename in filenames:
for width in widths:
m = render(filename, width)
mapnik.save_map(m, "%s-out.xml" % filename)
for filename in filenames_one_width:
m = render(filename, 500)
mapnik.save_map(m, "%s-out.xml" % filename)
for f in files:
for width in f[1:]:
m = render(f[0], width)
mapnik.save_map(m, "%s-out.xml" % f[0])
summary()