diff --git a/src/agg/process_raster_symbolizer.cpp b/src/agg/process_raster_symbolizer.cpp index dbdcc88b77..2830b25649 100644 --- a/src/agg/process_raster_symbolizer.cpp +++ b/src/agg/process_raster_symbolizer.cpp @@ -83,7 +83,8 @@ void agg_renderer::process(raster_symbolizer const& sym, if (scaling_method == SCALING_BILINEAR8) { scale_image_bilinear8(target.data_,source->data_, 0.0, 0.0); - } else + } + else { double scaling_ratio = ext.width() / source->data_.width(); scale_image_agg(target.data_, diff --git a/tests/python_tests/csv_test.py b/tests/python_tests/csv_test.py index 65db6a6547..ea57f245d3 100644 --- a/tests/python_tests/csv_test.py +++ b/tests/python_tests/csv_test.py @@ -6,6 +6,8 @@ from utilities import execution_path import os, mapnik +# make the tests silent since we intentially test error conditions that are noisy +mapnik.logger.set_severity(mapnik.severity_type.None) def setup(): # All of the paths used are relative, if we run the tests diff --git a/tests/python_tests/json_feature_properties_test.py b/tests/python_tests/json_feature_properties_test.py index 2eb92a20ac..0f27810c34 100644 --- a/tests/python_tests/json_feature_properties_test.py +++ b/tests/python_tests/json_feature_properties_test.py @@ -3,7 +3,10 @@ from nose.tools import * import os,sys import mapnik -import json +try: + import json +except ImportError: + import simplejson as json chars = [ { diff --git a/tests/python_tests/raster_alpha_test.py b/tests/python_tests/raster_alpha_test.py deleted file mode 100644 index 4346b0d2ea..0000000000 --- a/tests/python_tests/raster_alpha_test.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python - -from nose.tools import * -from utilities import execution_path - -import os, mapnik - -def setup(): - # All of the paths used are relative, if we run the tests - # from another directory we need to chdir() - os.chdir(execution_path('.')) - -if 'gdal' in mapnik.DatasourceCache.plugin_names(): - - def test_map_alpha_compare(): - m = mapnik.Map(600,400) - mapnik.load_map(m,'../data/good_maps/raster-alpha.xml') - m.zoom_all() - actual = '/tmp/mapnik-raster-alpha.png' - expected = 'images/support/raster-alpha.png' - im = mapnik.Image(m.width,m.height) - mapnik.render(m,im) - im.save(actual) - expected_im = mapnik.Image.open(expected) - eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected)) - - def test_map_alpha_gradient_compare(): - m = mapnik.Map(600,400) - mapnik.load_map(m,'../data/good_maps/raster-alpha-gradient.xml') - m.zoom_all() - actual = '/tmp/mapnik-raster-alpha-gradient.png' - expected = 'images/support/raster-alpha-gradient.png' - im = mapnik.Image(m.width,m.height) - mapnik.render(m,im) - im.save(actual) - expected_im = mapnik.Image.open(expected) - eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected)) - - # there should be no gray edges on raster - # https://github.com/mapnik/mapnik/issues/1471 - def test_edge_scaling_with_nodata(): - m = mapnik.Map(600,400) - mapnik.load_map(m,'../data/good_maps/raster-nodata-edge.xml') - m.zoom_all() - actual = '/tmp/mapnik-raster-nodata-edge.png' - expected = 'images/support/raster-nodata-edge.png' - im = mapnik.Image(m.width,m.height) - mapnik.render(m,im) - im.save(actual) - expected_im = mapnik.Image.open(expected) - eq_(im.tostring(),expected_im.tostring(), 'failed comparing actual (%s) and expected(%s)' % (actual,'tests/python_tests/'+ expected)) - - -if __name__ == "__main__": - setup() - [eval(run)() for run in dir() if 'test_' in run] diff --git a/tests/visual_tests/.gitignore b/tests/visual_tests/.gitignore index 0f3e46ba45..a39b720713 100644 --- a/tests/visual_tests/.gitignore +++ b/tests/visual_tests/.gitignore @@ -1,2 +1 @@ -*-agg.png *-out.xml diff --git a/tests/visual_tests/clean.sh b/tests/visual_tests/clean.sh index 1278159f47..d5ae9e4dec 100755 --- a/tests/visual_tests/clean.sh +++ b/tests/visual_tests/clean.sh @@ -1,3 +1,2 @@ -rm -f images/*-agg.png rm -f xml_output/*-out.xml diff --git a/tests/visual_tests/compare.py b/tests/visual_tests/compare.py index 8fa26360e9..43bd251d92 100644 --- a/tests/visual_tests/compare.py +++ b/tests/visual_tests/compare.py @@ -49,7 +49,7 @@ def compare(actual, expected): passed += 1 return diff -def summary(): +def summary(generate=False): global errors global passed print "-"*80 @@ -57,7 +57,13 @@ def summary(): if len(errors) != 0: for error in errors: if (error[0] is None): - print "Could not verify %s: No reference image found!" % error[1] + if generate: + actual = open(error[1],'r').read() + open(error[2],'wb').write(actual) + print "Generating reference image: '%s'" % error[2] + continue + else: + print "Could not verify %s: No reference image found!" % error[1] else: print "Failed: %d different pixels:\n\t%s (actual)\n\t%s (expected)" % error sys.exit(1) diff --git a/tests/visual_tests/images/tiff-alpha-gdal-600-reference.png b/tests/visual_tests/images/tiff-alpha-gdal-600-reference.png new file mode 100644 index 0000000000..3c79bb304f Binary files /dev/null and b/tests/visual_tests/images/tiff-alpha-gdal-600-reference.png differ diff --git a/tests/python_tests/images/support/raster-alpha-gradient.png b/tests/visual_tests/images/tiff-alpha-gradient-gdal-600-reference.png similarity index 100% rename from tests/python_tests/images/support/raster-alpha-gradient.png rename to tests/visual_tests/images/tiff-alpha-gradient-gdal-600-reference.png diff --git a/tests/visual_tests/images/tiff-alpha-gradient-raster-600-reference.png b/tests/visual_tests/images/tiff-alpha-gradient-raster-600-reference.png new file mode 100644 index 0000000000..92c3aaf2d3 Binary files /dev/null and b/tests/visual_tests/images/tiff-alpha-gradient-raster-600-reference.png differ diff --git a/tests/visual_tests/images/tiff-alpha-raster-600-reference.png b/tests/visual_tests/images/tiff-alpha-raster-600-reference.png new file mode 100644 index 0000000000..3c79bb304f Binary files /dev/null and b/tests/visual_tests/images/tiff-alpha-raster-600-reference.png differ diff --git a/tests/python_tests/images/support/raster-nodata-edge.png b/tests/visual_tests/images/tiff-nodata-edge-gdal-600-reference.png similarity index 100% rename from tests/python_tests/images/support/raster-nodata-edge.png rename to tests/visual_tests/images/tiff-nodata-edge-gdal-600-reference.png diff --git a/tests/visual_tests/images/tiff-nodata-edge-raster-600-reference.png b/tests/visual_tests/images/tiff-nodata-edge-raster-600-reference.png new file mode 100644 index 0000000000..df5fa419ee Binary files /dev/null and b/tests/visual_tests/images/tiff-nodata-edge-raster-600-reference.png differ diff --git a/tests/data/good_maps/raster-alpha.xml b/tests/visual_tests/styles/tiff-alpha-gdal.xml similarity index 88% rename from tests/data/good_maps/raster-alpha.xml rename to tests/visual_tests/styles/tiff-alpha-gdal.xml index ab643c7aae..e7fe884532 100644 --- a/tests/data/good_maps/raster-alpha.xml +++ b/tests/visual_tests/styles/tiff-alpha-gdal.xml @@ -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"> white - ../raster/white-alpha.tiff + ../../data/raster/white-alpha.tiff gdal diff --git a/tests/data/good_maps/raster-alpha-gradient.xml b/tests/visual_tests/styles/tiff-alpha-gradient-gdal.xml similarity index 88% rename from tests/data/good_maps/raster-alpha-gradient.xml rename to tests/visual_tests/styles/tiff-alpha-gradient-gdal.xml index b906668f20..7730bba4d4 100644 --- a/tests/data/good_maps/raster-alpha-gradient.xml +++ b/tests/visual_tests/styles/tiff-alpha-gradient-gdal.xml @@ -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"> transp - ../raster/transp.tiff + ../../data/raster/transp.tiff gdal diff --git a/tests/visual_tests/styles/tiff-alpha-gradient-raster.xml b/tests/visual_tests/styles/tiff-alpha-gradient-raster.xml new file mode 100644 index 0000000000..485a5fc1ff --- /dev/null +++ b/tests/visual_tests/styles/tiff-alpha-gradient-raster.xml @@ -0,0 +1,20 @@ + + + + + + + transp + + ../../data/raster/transp.tiff + raster + 0,0,256,256 + + + + \ No newline at end of file diff --git a/tests/visual_tests/styles/tiff-alpha-raster.xml b/tests/visual_tests/styles/tiff-alpha-raster.xml new file mode 100644 index 0000000000..ce9e2fb6c6 --- /dev/null +++ b/tests/visual_tests/styles/tiff-alpha-raster.xml @@ -0,0 +1,20 @@ + + + + + + + white + + ../../data/raster/white-alpha.tiff + raster + 1001859.9561,5922814.94334,1021141.75555,5942096.74279 + + + + \ No newline at end of file diff --git a/tests/data/good_maps/raster-nodata-edge.xml b/tests/visual_tests/styles/tiff-nodata-edge-gdal.xml similarity index 88% rename from tests/data/good_maps/raster-nodata-edge.xml rename to tests/visual_tests/styles/tiff-nodata-edge-gdal.xml index ce2a934259..21ed737b14 100644 --- a/tests/data/good_maps/raster-nodata-edge.xml +++ b/tests/visual_tests/styles/tiff-nodata-edge-gdal.xml @@ -12,7 +12,7 @@ style - ../raster/nodata-edge.tif + ../../data/raster/nodata-edge.tif gdal diff --git a/tests/visual_tests/styles/tiff-nodata-edge-raster.xml b/tests/visual_tests/styles/tiff-nodata-edge-raster.xml new file mode 100644 index 0000000000..0700c746b5 --- /dev/null +++ b/tests/visual_tests/styles/tiff-nodata-edge-raster.xml @@ -0,0 +1,21 @@ + + + + + + + style + + + ../../data/raster/nodata-edge.tif + raster + -12329035.765216826,4508650.398543958,-12328653.027947057,4508957.346255356 + + + + \ No newline at end of file diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index ddcec05bfa..1fe3167cf8 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -7,8 +7,7 @@ from compare import compare, summary defaults = { - 'sizes': [(500, 100)], - 'bbox': mapnik.Box2d(-0.05, -0.01, 0.95, 0.01) + 'sizes': [(500, 100)] } sizes_many_in_big_range = [(800, 100), (600, 100), (400, 100), @@ -18,33 +17,39 @@ sizes_many_in_small_range = [(490, 100), (495, 100), (497, 100), (498, 100), (499, 100), (500, 100), (501, 100), (502, 100), (505, 100), (510, 100)] +default_text_box = mapnik.Box2d(-0.05, -0.01, 0.95, 0.01) + dirname = os.path.dirname(__file__) files = [ - {'name': "list", 'sizes': sizes_many_in_big_range}, - {'name': "simple", 'sizes': sizes_many_in_big_range}, - {'name': "lines-1", 'sizes': sizes_few_square}, - {'name': "lines-2", 'sizes': sizes_few_square}, - {'name': "lines-3", 'sizes': sizes_few_square}, - {'name': "lines-shield", 'sizes': sizes_few_square}, - {'name': "simple-E"}, - {'name': "simple-NE"}, - {'name': "simple-NW"}, - {'name': "simple-N"}, - {'name': "simple-SE"}, - {'name': "simple-SW"}, - {'name': "simple-S"}, - {'name': "simple-W"}, - {'name': "formatting-1"}, - {'name': "formatting-2"}, - {'name': "formatting-3"}, - {'name': "formatting-4"}, - {'name': "expressionformat"}, - {'name': "shieldsymbolizer-1", 'sizes': sizes_many_in_small_range}, - {'name': "rtl-point", 'sizes': [(200, 200)]}, - {'name': "jalign-auto", 'sizes': [(200, 200)]}, - {'name': "line-offset", 'sizes':[(900, 250)], - 'bbox': mapnik.Box2d(-5.192, 50.189, -5.174, 50.195)}, + {'name': "list", 'sizes': sizes_many_in_big_range,'bbox':default_text_box}, + {'name': "simple", 'sizes': sizes_many_in_big_range,'bbox':default_text_box}, + {'name': "lines-1", 'sizes': sizes_few_square,'bbox':default_text_box}, + {'name': "lines-2", 'sizes': sizes_few_square,'bbox':default_text_box}, + {'name': "lines-3", 'sizes': sizes_few_square,'bbox':default_text_box}, + {'name': "lines-shield", 'sizes': sizes_few_square,'bbox':default_text_box}, + {'name': "simple-E", 'bbox':mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)}, + {'name': "simple-NE",'bbox':default_text_box}, + {'name': "simple-NW",'bbox':default_text_box}, + {'name': "simple-N",'bbox':default_text_box}, + {'name': "simple-SE",'bbox':default_text_box}, + {'name': "simple-SW",'bbox':default_text_box}, + {'name': "simple-S",'bbox':default_text_box}, + {'name': "simple-W",'bbox':default_text_box}, + {'name': "formatting-1",'bbox':default_text_box}, + {'name': "formatting-2",'bbox':default_text_box}, + {'name': "formatting-3",'bbox':default_text_box}, + {'name': "formatting-4",'bbox':default_text_box}, + {'name': "expressionformat",'bbox':default_text_box}, + {'name': "shieldsymbolizer-1", 'sizes': sizes_many_in_small_range,'bbox':default_text_box}, + {'name': "rtl-point", 'sizes': [(200, 200)],'bbox':default_text_box}, + {'name': "jalign-auto", 'sizes': [(200, 200)],'bbox':default_text_box}, + {'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-gradient-gdal", 'sizes':[(600,400)]}, + {'name': "tiff-nodata-edge-gdal", 'sizes':[(600,400)]}, + {'name': "tiff-nodata-edge-raster", 'sizes':[(600,400)]}, ] def render(filename, width, height, bbox, quiet=False): @@ -89,7 +94,7 @@ def render(filename, width, height, bbox, quiet=False): config = dict(defaults) config.update(f) for size in config['sizes']: - m = render(config['name'], size[0], size[1], config['bbox'], quiet=quiet) + m = render(config['name'], size[0], size[1], config.get('bbox'), quiet=quiet) mapnik.save_map(m, os.path.join(dirname, 'xml_output', "%s-out.xml" % config['name'])) - summary() + summary(generate=False)