Permalink
Browse files

Merge branch 'master' of github.com:mapnik/mapnik

  • Loading branch information...
2 parents e954bb1 + a3aec24 commit a7d7dd245a526281e80169d5f3ea787d67b72a7e Dane Springmeyer committed Sep 26, 2012
@@ -83,7 +83,8 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
if (scaling_method == SCALING_BILINEAR8)
{
scale_image_bilinear8<image_data_32>(target.data_,source->data_, 0.0, 0.0);
- } else
+ }
+ else
{
double scaling_ratio = ext.width() / source->data_.width();
scale_image_agg<image_data_32>(target.data_,
@@ -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
@@ -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 = [
{
@@ -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]
@@ -1,2 +1 @@
-*-agg.png
*-out.xml
@@ -1,3 +1,2 @@
-rm -f images/*-agg.png
rm -f xml_output/*-out.xml
@@ -49,15 +49,21 @@ def compare(actual, expected):
passed += 1
return diff
-def summary():
+def summary(generate=False):
global errors
global passed
print "-"*80
print "Visual text rendering 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)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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">../raster/white-alpha.tiff</Parameter>
+ <Parameter name="file">../../data/raster/white-alpha.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>transp</StyleName>
<Datasource>
- <Parameter name="file">../raster/transp.tiff</Parameter>
+ <Parameter name="file">../../data/raster/transp.tiff</Parameter>
<Parameter name="type">gdal</Parameter>
</Datasource>
</Layer>
@@ -0,0 +1,20 @@
+<?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="blue">
+
+<Style name="transp">
+ <Rule>
+ <RasterSymbolizer opacity="1" scaling="bilinear" />
+ </Rule>
+</Style>
+<Layer name="transp"
+ 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>transp</StyleName>
+ <Datasource>
+ <Parameter name="file">../../data/raster/transp.tiff</Parameter>
+ <Parameter name="type">raster</Parameter>
+ <Parameter name="extent">0,0,256,256</Parameter>
+ </Datasource>
+ </Layer>
+
+</Map>
@@ -0,0 +1,20 @@
+<?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>
+ <Parameter name="file">../../data/raster/white-alpha.tiff</Parameter>
+ <Parameter name="type">raster</Parameter>
+ <Parameter name="extent">1001859.9561,5922814.94334,1021141.75555,5942096.74279</Parameter>
+ </Datasource>
+ </Layer>
+
+</Map>
@@ -12,7 +12,7 @@
<StyleName>style</StyleName>
<Datasource>
<!-- https://github.com/mapnik/mapnik/issues/1471 -->
- <Parameter name="file">../raster/nodata-edge.tif</Parameter>
+ <Parameter name="file">../../data/raster/nodata-edge.tif</Parameter>
<Parameter name="type">gdal</Parameter>
</Datasource>
</Layer>
@@ -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="#F0CCAC">
+
+<Style name="style" >
+ <Rule>
+ <RasterSymbolizer opacity="1" />
+ </Rule>
+</Style>
+<Layer name="raster"
+ 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>style</StyleName>
+ <Datasource>
+ <!-- https://github.com/mapnik/mapnik/issues/1471 -->
+ <Parameter name="file">../../data/raster/nodata-edge.tif</Parameter>
+ <Parameter name="type">raster</Parameter>
+ <Parameter name="extent">-12329035.765216826,4508650.398543958,-12328653.027947057,4508957.346255356</Parameter>
+ </Datasource>
+ </Layer>
+
+</Map>
View
@@ -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)

0 comments on commit a7d7dd2

Please sign in to comment.