mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
more test fixes to set up to enforce desired behavior around tiff and premultiplied alpha in source files - refs #1508 and #1511
This commit is contained in:
parent
76dec5076e
commit
2714bdcef3
BIN
tests/data/raster/white-alpha-assoc-alpha-correct.tiff
Normal file
BIN
tests/data/raster/white-alpha-assoc-alpha-correct.tiff
Normal file
Binary file not shown.
@ -24,9 +24,9 @@ def compare_pixels(pixel1, pixel2):
|
||||
else:
|
||||
return False
|
||||
|
||||
def fail(actual,expected):
|
||||
def fail(actual,expected,message):
|
||||
global errors
|
||||
errors.append(('N/A', actual, expected))
|
||||
errors.append((message, actual, expected))
|
||||
|
||||
# compare two images and return number of different pixels
|
||||
def compare(actual, expected):
|
||||
@ -56,12 +56,14 @@ def compare(actual, expected):
|
||||
def summary(generate=False):
|
||||
global errors
|
||||
global passed
|
||||
print "-"*80
|
||||
print "Visual text rendering summary:"
|
||||
print "-"*80
|
||||
|
||||
if len(errors) != 0:
|
||||
for error in errors:
|
||||
if (error[0] is None):
|
||||
msg = "Visual text rendering: %s failures" % len(errors)
|
||||
print "-"*len(msg)
|
||||
print msg
|
||||
print "-"*len(msg)
|
||||
for idx,error in enumerate(errors):
|
||||
if error[0] is None:
|
||||
if generate:
|
||||
actual = open(error[1],'r').read()
|
||||
open(error[2],'wb').write(actual)
|
||||
@ -69,9 +71,14 @@ def summary(generate=False):
|
||||
continue
|
||||
else:
|
||||
print "Could not verify %s: No reference image found!" % error[1]
|
||||
else:
|
||||
print "\x1b[34m%s different pixels\x1b[0m:\n\t%s (\x1b[31mactual\x1b[0m)\n\t%s (\x1b[32mexpected\x1b[0m)" % error
|
||||
elif isinstance(error[0],int):
|
||||
print str(idx+1) + ") \x1b[34m%s different pixels\x1b[0m:\n\t%s (\x1b[31mactual\x1b[0m)\n\t%s (\x1b[32mexpected\x1b[0m)" % error
|
||||
elif isinstance(error[0],str):
|
||||
print str(idx+1) + ") \x1b[31mfailure to run test:\x1b[0m %s" % error[0]
|
||||
sys.exit(1)
|
||||
else:
|
||||
print 'All %s tests passed: \x1b[1;32m✓ \x1b[0m' % passed
|
||||
msg = 'All %s visual tests passed: \x1b[1;32m✓ \x1b[0m' % passed
|
||||
print "-"*len(msg)
|
||||
print msg
|
||||
print "-"*len(msg)
|
||||
sys.exit(0)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map[]>
|
||||
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="red">
|
||||
|
||||
<Style name="white">
|
||||
<Rule>
|
||||
<RasterSymbolizer opacity="1" scaling="bilinear" comp-op="src-over"/>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Layer name="white"
|
||||
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
|
||||
<StyleName>white</StyleName>
|
||||
<Datasource>
|
||||
<!-- tiffinfo data/raster/white-alpha-assoc-alpha-wrong.tiff reports 'Extra Samples: 1<assoc-alpha>' which is incorrect -->
|
||||
<!-- https://github.com/mapnik/mapnik/issues/1511 -->
|
||||
<Parameter name="file">../../data/raster/white-alpha-assoc-alpha-wrong.tiff</Parameter>
|
||||
<Parameter name="type">gdal</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
</Map>
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE Map[]>
|
||||
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" background-color="red">
|
||||
|
||||
<Style name="white">
|
||||
<Rule>
|
||||
<RasterSymbolizer opacity="1" scaling="bilinear" comp-op="src-over"/>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Layer name="white"
|
||||
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
|
||||
<StyleName>white</StyleName>
|
||||
<Datasource>
|
||||
<!-- tiffinfo data/raster/white-alpha-assoc-alpha-wrong.tiff reports 'Extra Samples: 1<assoc-alpha>' which is incorrect -->
|
||||
<!-- https://github.com/mapnik/mapnik/issues/1511 -->
|
||||
<Parameter name="file">../../data/raster/white-alpha-assoc-alpha-wrong.tiff</Parameter>
|
||||
<Parameter name="type">raster</Parameter>
|
||||
<Parameter name="extent">1001859.9561,5922814.94334,1021141.75555,5942096.74279</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
</Map>
|
||||
@ -11,7 +11,7 @@
|
||||
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
|
||||
<StyleName>white</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="file">../../data/raster/white-alpha.tiff</Parameter>
|
||||
<Parameter name="file">../../data/raster/white-alpha-assoc-alpha-correct.tiff</Parameter>
|
||||
<Parameter name="type">gdal</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
|
||||
<StyleName>white</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="file">../../data/raster/white-alpha.tiff</Parameter>
|
||||
<Parameter name="file">../../data/raster/white-alpha-assoc-alpha-correct.tiff</Parameter>
|
||||
<Parameter name="type">raster</Parameter>
|
||||
<Parameter name="extent">1001859.9561,5922814.94334,1021141.75555,5942096.74279</Parameter>
|
||||
</Datasource>
|
||||
|
||||
@ -49,6 +49,8 @@ files = [
|
||||
{'name': "line-offset", 'sizes':[(900, 250)],'bbox': mapnik.Box2d(-5.192, 50.189, -5.174, 50.195)},
|
||||
{'name': "tiff-alpha-gdal", 'sizes':[(600,400)]},
|
||||
{'name': "tiff-alpha-raster", 'sizes':[(600,400)]},
|
||||
{'name': "tiff-alpha-broken-assoc-alpha-gdal", 'sizes':[(600,400)]},
|
||||
{'name': "tiff-alpha-broken-assoc-alpha-raster", 'sizes':[(600,400)]},
|
||||
{'name': "tiff-alpha-gradient-gdal", 'sizes':[(600,400)]},
|
||||
{'name': "tiff-nodata-edge-gdal", 'sizes':[(600,400)]},
|
||||
{'name': "tiff-nodata-edge-raster", 'sizes':[(600,400)]},
|
||||
@ -61,16 +63,16 @@ def render(filename, width, height, bbox, quiet=False):
|
||||
if not quiet:
|
||||
print "\"%s\" with size %dx%d ..." % (filename, width, height),
|
||||
m = mapnik.Map(width, height)
|
||||
mapnik.load_map(m, os.path.join(dirname, "styles", "%s.xml" % filename), False)
|
||||
if bbox is not None:
|
||||
m.zoom_to_box(bbox)
|
||||
else:
|
||||
m.zoom_all()
|
||||
expected = os.path.join(dirname, "images", '%s-%d-reference.png' % (filename, width))
|
||||
if not os.path.exists('/tmp/mapnik-visual-images'):
|
||||
os.makedirs('/tmp/mapnik-visual-images')
|
||||
actual = os.path.join("/tmp/mapnik-visual-images", '%s-%d-agg.png' % (filename, width))
|
||||
try:
|
||||
mapnik.load_map(m, os.path.join(dirname, "styles", "%s.xml" % filename), False)
|
||||
if bbox is not None:
|
||||
m.zoom_to_box(bbox)
|
||||
else:
|
||||
m.zoom_all()
|
||||
if not os.path.exists('/tmp/mapnik-visual-images'):
|
||||
os.makedirs('/tmp/mapnik-visual-images')
|
||||
mapnik.render_to_file(m, actual)
|
||||
diff = compare(actual, expected)
|
||||
if not quiet:
|
||||
@ -80,7 +82,7 @@ def render(filename, width, height, bbox, quiet=False):
|
||||
print '\x1b[32m✓\x1b[0m'
|
||||
except Exception, e:
|
||||
sys.stderr.write(e.message + '\n')
|
||||
fail(actual,expected)
|
||||
fail(actual,expected,str(e.message))
|
||||
return m
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user