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:
parent
6f5d16bfe3
commit
73339b3936
2 changed files with 35 additions and 20 deletions
|
@ -20,7 +20,11 @@ def compare_pixels(pixel1, pixel2):
|
||||||
def compare(fn1, fn2):
|
def compare(fn1, fn2):
|
||||||
global errors
|
global errors
|
||||||
im1 = Image.open(fn1)
|
im1 = Image.open(fn1)
|
||||||
im2 = Image.open(fn2)
|
try:
|
||||||
|
im2 = Image.open(fn2)
|
||||||
|
except IOError:
|
||||||
|
errors.append((fn1, None))
|
||||||
|
return -1
|
||||||
diff = 0
|
diff = 0
|
||||||
pixels = im1.size[0] * im1.size[1]
|
pixels = im1.size[0] * im1.size[1]
|
||||||
im1 = im1.getdata()
|
im1 = im1.getdata()
|
||||||
|
@ -38,6 +42,9 @@ def summary():
|
||||||
print "-"*80
|
print "-"*80
|
||||||
print "Summary:"
|
print "Summary:"
|
||||||
for error in errors:
|
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
|
print "-"*80
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -8,15 +8,26 @@ import os.path
|
||||||
from compare import compare, summary
|
from compare import compare, summary
|
||||||
|
|
||||||
dirname = os.path.dirname(sys.argv[0])
|
dirname = os.path.dirname(sys.argv[0])
|
||||||
|
files = [
|
||||||
widths = [ 800, 600, 400, 300, 250, 200, 150, 100]
|
("list", 800, 600, 400, 300, 250, 200, 150, 100),
|
||||||
filenames = ["list", "simple"]
|
("simple", 800, 600, 400, 300, 250, 200, 150, 100),
|
||||||
filenames_one_width = ["simple-E", "simple-NE", "simple-NW", "simple-N",
|
("simple-E", 500),
|
||||||
"simple-SE", "simple-SW", "simple-S", "simple-W",
|
("simple-NE", 500),
|
||||||
"formating-1", "formating-2", "formating-3", "formating-4",
|
("simple-NW", 500),
|
||||||
"shieldsymbolizer-1", "expressionformat"]
|
("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):
|
def render(filename, width):
|
||||||
|
width = int(width)
|
||||||
m = mapnik.Map(width, 100)
|
m = mapnik.Map(width, 100)
|
||||||
mapnik.load_map(m, os.path.join(dirname, "%s.xml" % filename), False)
|
mapnik.load_map(m, os.path.join(dirname, "%s.xml" % filename), False)
|
||||||
bbox = mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)
|
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)
|
print "Rendering style \"%s\" with width %d ... %s" % (filename, width, rms)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) == 2:
|
||||||
filenames = []
|
files = [(sys.argv[1], 500)]
|
||||||
filenames_one_width = sys.argv[1:]
|
elif len(sys.argv) > 2:
|
||||||
|
files = [sys.argv[1:]]
|
||||||
|
|
||||||
for filename in filenames:
|
for f in files:
|
||||||
for width in widths:
|
for width in f[1:]:
|
||||||
m = render(filename, width)
|
m = render(f[0], width)
|
||||||
mapnik.save_map(m, "%s-out.xml" % filename)
|
mapnik.save_map(m, "%s-out.xml" % f[0])
|
||||||
|
|
||||||
for filename in filenames_one_width:
|
|
||||||
m = render(filename, 500)
|
|
||||||
mapnik.save_map(m, "%s-out.xml" % filename)
|
|
||||||
|
|
||||||
summary()
|
summary()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue