Merge branch 'master' into conv_simplify
|
@ -153,6 +153,14 @@ If you see bits of code around that do not follow these please don't hesitate to
|
||||||
// more...
|
// more...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#### Prefer `empty()` over `size() == 0` if container supports it
|
||||||
|
|
||||||
|
This avoids implicit conversions to bool and reduces compiler warnings.
|
||||||
|
|
||||||
|
if (container.empty()) // please
|
||||||
|
|
||||||
|
if (container.size() == 0) // no
|
||||||
|
|
||||||
|
|
||||||
### Other C++ style resources
|
### Other C++ style resources
|
||||||
|
|
||||||
|
|
|
@ -665,7 +665,9 @@ void csv_datasource::parse_csv(T & stream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now, add all values as attributes
|
// now, add attributes, skipping any WKT or JSON fiels
|
||||||
|
if ((has_wkt_field) && (i == wkt_idx)) continue;
|
||||||
|
if ((has_json_field) && (i == json_idx)) continue;
|
||||||
/* First we detect likely strings, then try parsing likely numbers,
|
/* First we detect likely strings, then try parsing likely numbers,
|
||||||
finally falling back to string type
|
finally falling back to string type
|
||||||
* We intentionally do not try to detect boolean or null types
|
* We intentionally do not try to detect boolean or null types
|
||||||
|
|
|
@ -62,8 +62,8 @@ raster_datasource::raster_datasource(parameters const& params, bool bind)
|
||||||
filename_ = *file;
|
filename_ = *file;
|
||||||
|
|
||||||
multi_tiles_ = *params_.get<bool>("multi", false);
|
multi_tiles_ = *params_.get<bool>("multi", false);
|
||||||
tile_size_ = *params_.get<unsigned>("tile-size", 256);
|
tile_size_ = *params_.get<unsigned>("tile_size", 256);
|
||||||
tile_stride_ = *params_.get<unsigned>("tile-stride", 1);
|
tile_stride_ = *params_.get<unsigned>("tile_stride", 1);
|
||||||
|
|
||||||
format_ = *params_.get<std::string>("format","tiff");
|
format_ = *params_.get<std::string>("format","tiff");
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ void raster_datasource::bind() const
|
||||||
|
|
||||||
if (multi_tiles_)
|
if (multi_tiles_)
|
||||||
{
|
{
|
||||||
boost::optional<unsigned> x_width = params_.get<unsigned>("x-width");
|
boost::optional<unsigned> x_width = params_.get<unsigned>("x_width");
|
||||||
boost::optional<unsigned> y_width = params_.get<unsigned>("y-width");
|
boost::optional<unsigned> y_width = params_.get<unsigned>("y_width");
|
||||||
|
|
||||||
if (! x_width)
|
if (! x_width)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,7 +83,8 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
|
||||||
if (scaling_method == SCALING_BILINEAR8)
|
if (scaling_method == SCALING_BILINEAR8)
|
||||||
{
|
{
|
||||||
scale_image_bilinear8<image_data_32>(target.data_,source->data_, 0.0, 0.0);
|
scale_image_bilinear8<image_data_32>(target.data_,source->data_, 0.0, 0.0);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
double scaling_ratio = ext.width() / source->data_.width();
|
double scaling_ratio = ext.width() / source->data_.width();
|
||||||
scale_image_agg<image_data_32>(target.data_,
|
scale_image_agg<image_data_32>(target.data_,
|
||||||
|
|
|
@ -1154,7 +1154,7 @@ void map_parser::parse_text_symbolizer(rule & rule, xml_node const& sym)
|
||||||
placement_finder->defaults.from_xml(sym, fontsets_);
|
placement_finder->defaults.from_xml(sym, fontsets_);
|
||||||
}
|
}
|
||||||
if (strict_ &&
|
if (strict_ &&
|
||||||
!placement_finder->defaults.format.fontset->size())
|
!placement_finder->defaults.format.fontset)
|
||||||
{
|
{
|
||||||
ensure_font_face(placement_finder->defaults.format.face_name);
|
ensure_font_face(placement_finder->defaults.format.face_name);
|
||||||
}
|
}
|
||||||
|
@ -1183,7 +1183,7 @@ void map_parser::parse_shield_symbolizer(rule & rule, xml_node const& sym)
|
||||||
}
|
}
|
||||||
placement_finder->defaults.from_xml(sym, fontsets_);
|
placement_finder->defaults.from_xml(sym, fontsets_);
|
||||||
if (strict_ &&
|
if (strict_ &&
|
||||||
!placement_finder->defaults.format.fontset->size())
|
!placement_finder->defaults.format.fontset)
|
||||||
{
|
{
|
||||||
ensure_font_face(placement_finder->defaults.format.face_name);
|
ensure_font_face(placement_finder->defaults.format.face_name);
|
||||||
}
|
}
|
||||||
|
|
18
src/warp.cpp
|
@ -47,11 +47,11 @@
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
void reproject_and_scale_raster(raster & target, raster const& source,
|
void reproject_and_scale_raster(raster & target, raster const& source,
|
||||||
proj_transform const& prj_trans,
|
proj_transform const& prj_trans,
|
||||||
double offset_x, double offset_y,
|
double offset_x, double offset_y,
|
||||||
unsigned mesh_size,
|
unsigned mesh_size,
|
||||||
double filter_radius,
|
double filter_radius,
|
||||||
scaling_method_e scaling_method)
|
scaling_method_e scaling_method)
|
||||||
{
|
{
|
||||||
CoordTransform ts(source.data_.width(), source.data_.height(),
|
CoordTransform ts(source.data_.width(), source.data_.height(),
|
||||||
source.ext_);
|
source.ext_);
|
||||||
|
@ -160,10 +160,10 @@ void reproject_and_scale_raster(raster & target, raster const& source,
|
||||||
tt.forward(polygon+6, polygon+7);
|
tt.forward(polygon+6, polygon+7);
|
||||||
|
|
||||||
rasterizer.reset();
|
rasterizer.reset();
|
||||||
rasterizer.move_to_d(polygon[0]-1, polygon[1]-1);
|
rasterizer.move_to_d(std::floor(polygon[0]), std::floor(polygon[1]));
|
||||||
rasterizer.line_to_d(polygon[2]+1, polygon[3]-1);
|
rasterizer.line_to_d(std::floor(polygon[2]), std::floor(polygon[3]));
|
||||||
rasterizer.line_to_d(polygon[4]+1, polygon[5]+1);
|
rasterizer.line_to_d(std::floor(polygon[4]), std::floor(polygon[5]));
|
||||||
rasterizer.line_to_d(polygon[6]-1, polygon[7]+1);
|
rasterizer.line_to_d(std::floor(polygon[6]), std::floor(polygon[7]));
|
||||||
|
|
||||||
unsigned x0 = i * mesh_size;
|
unsigned x0 = i * mesh_size;
|
||||||
unsigned y0 = j * mesh_size;
|
unsigned y0 = j * mesh_size;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
x,y,line
|
||||||
|
0,0,"
|
||||||
|
many
|
||||||
|
lines
|
||||||
|
of text
|
||||||
|
with unix newlines
|
||||||
|
"
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
x,y,line
|
||||||
|
0,0,"\r\nmany\r\nlines\r\nof text\r\nwith unix newlines\r\n"
|
|
7
tests/data/csv/mac_newlines_with_unix_inline.csv
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
x,y,line
|
||||||
|
0,0,"
|
||||||
|
many
|
||||||
|
lines
|
||||||
|
of text
|
||||||
|
with unix newlines
|
||||||
|
"
|
|
2
tests/data/csv/mac_newlines_with_unix_inline_escaped.csv
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
x,y,line
|
||||||
|
0,0,"many\n lines\n of text\n with unix newlines"
|
|
7
tests/data/csv/windows_newlines_with_unix_inline.csv
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
x,y,line
|
||||||
|
0,0,"
|
||||||
|
many
|
||||||
|
lines
|
||||||
|
of text
|
||||||
|
with unix newlines
|
||||||
|
"
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
x,y,line
|
||||||
|
0,0,"many\n lines\n of text\n with unix newlines"
|
|
|
@ -6,6 +6,8 @@ from nose.tools import *
|
||||||
from utilities import execution_path
|
from utilities import execution_path
|
||||||
|
|
||||||
import os, mapnik
|
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():
|
def setup():
|
||||||
# All of the paths used are relative, if we run the tests
|
# All of the paths used are relative, if we run the tests
|
||||||
|
@ -137,9 +139,9 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
|
||||||
|
|
||||||
def test_wkt_field(**kwargs):
|
def test_wkt_field(**kwargs):
|
||||||
ds = get_csv_ds('wkt.csv')
|
ds = get_csv_ds('wkt.csv')
|
||||||
eq_(len(ds.fields()),2)
|
eq_(len(ds.fields()),1)
|
||||||
eq_(ds.fields(),['type','WKT'])
|
eq_(ds.fields(),['type'])
|
||||||
eq_(ds.field_types(),['str','str'])
|
eq_(ds.field_types(),['str'])
|
||||||
fs = ds.all_features()
|
fs = ds.all_features()
|
||||||
eq_(len(fs[0].geometries()),1)
|
eq_(len(fs[0].geometries()),1)
|
||||||
eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point)
|
eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point)
|
||||||
|
@ -396,9 +398,9 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
|
||||||
eq_(feat['Name'],u"Winthrop, WA")
|
eq_(feat['Name'],u"Winthrop, WA")
|
||||||
|
|
||||||
def validate_geojson_datasource(ds):
|
def validate_geojson_datasource(ds):
|
||||||
eq_(len(ds.fields()),2)
|
eq_(len(ds.fields()),1)
|
||||||
eq_(ds.fields(),['type','GeoJSON'])
|
eq_(ds.fields(),['type'])
|
||||||
eq_(ds.field_types(),['str','str'])
|
eq_(ds.field_types(),['str'])
|
||||||
fs = ds.all_features()
|
fs = ds.all_features()
|
||||||
eq_(len(fs[0].geometries()),1)
|
eq_(len(fs[0].geometries()),1)
|
||||||
eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point)
|
eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point)
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
from nose.tools import *
|
from nose.tools import *
|
||||||
import os,sys
|
import os,sys
|
||||||
import mapnik
|
import mapnik
|
||||||
import json
|
try:
|
||||||
|
import json
|
||||||
|
except ImportError:
|
||||||
|
import simplejson as json
|
||||||
|
|
||||||
chars = [
|
chars = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from nose.tools import *
|
from nose.tools import *
|
||||||
from utilities import execution_path, save_data, contains_word
|
from utilities import execution_path, contains_word
|
||||||
|
|
||||||
import os, mapnik
|
import os, mapnik
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@ def test_multi_tile_policy():
|
||||||
im = mapnik.Image(_map.width, _map.height)
|
im = mapnik.Image(_map.width, _map.height)
|
||||||
mapnik.render(_map, im)
|
mapnik.render(_map, im)
|
||||||
|
|
||||||
save_data('test_multi_tile_policy.png', im.tostring('png'))
|
|
||||||
|
|
||||||
# test green chunk
|
# test green chunk
|
||||||
eq_(im.view(0,64,1,1).tostring(), '\x00\xff\x00\xff')
|
eq_(im.view(0,64,1,1).tostring(), '\x00\xff\x00\xff')
|
||||||
eq_(im.view(127,64,1,1).tostring(), '\x00\xff\x00\xff')
|
eq_(im.view(127,64,1,1).tostring(), '\x00\xff\x00\xff')
|
||||||
|
|
|
@ -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,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from nose.tools import *
|
from nose.tools import *
|
||||||
from utilities import execution_path, save_data, contains_word
|
from utilities import execution_path, contains_word
|
||||||
|
|
||||||
import os, mapnik
|
import os, mapnik
|
||||||
|
|
||||||
|
@ -51,8 +51,6 @@ def test_dataraster_coloring():
|
||||||
|
|
||||||
im = mapnik.Image(_map.width,_map.height)
|
im = mapnik.Image(_map.width,_map.height)
|
||||||
mapnik.render(_map, im)
|
mapnik.render(_map, im)
|
||||||
# save a png somewhere so we can see it
|
|
||||||
save_data('test_dataraster_coloring.png', im.tostring('png'))
|
|
||||||
imdata = im.tostring()
|
imdata = im.tostring()
|
||||||
# we have some values in the [20,30) interval so check that they're colored
|
# we have some values in the [20,30) interval so check that they're colored
|
||||||
assert contains_word('\xff\xff\x00\xff', imdata)
|
assert contains_word('\xff\xff\x00\xff', imdata)
|
||||||
|
@ -135,8 +133,6 @@ def test_raster_with_alpha_blends_correctly_with_background():
|
||||||
mim = mapnik.Image(WIDTH, HEIGHT)
|
mim = mapnik.Image(WIDTH, HEIGHT)
|
||||||
|
|
||||||
mapnik.render(map, mim)
|
mapnik.render(map, mim)
|
||||||
save_data('test_raster_with_alpha_blends_correctly_with_background.png',
|
|
||||||
mim.tostring('png'))
|
|
||||||
imdata = mim.tostring()
|
imdata = mim.tostring()
|
||||||
# All white is expected
|
# All white is expected
|
||||||
assert contains_word('\xff\xff\xff\xff', imdata)
|
assert contains_word('\xff\xff\xff\xff', imdata)
|
||||||
|
@ -166,8 +162,6 @@ def test_raster_warping():
|
||||||
|
|
||||||
im = mapnik.Image(_map.width,_map.height)
|
im = mapnik.Image(_map.width,_map.height)
|
||||||
mapnik.render(_map, im)
|
mapnik.render(_map, im)
|
||||||
# save a png somewhere so we can see it
|
|
||||||
save_data('test_raster_warping.png', im.tostring('png'))
|
|
||||||
imdata = im.tostring()
|
imdata = im.tostring()
|
||||||
assert contains_word('\xff\xff\x00\xff', imdata)
|
assert contains_word('\xff\xff\x00\xff', imdata)
|
||||||
|
|
||||||
|
@ -195,9 +189,6 @@ def test_raster_warping_does_not_overclip_source():
|
||||||
|
|
||||||
im = mapnik.Image(_map.width,_map.height)
|
im = mapnik.Image(_map.width,_map.height)
|
||||||
mapnik.render(_map, im)
|
mapnik.render(_map, im)
|
||||||
# save a png somewhere so we can see it
|
|
||||||
save_data('test_raster_warping_does_not_overclip_source.png',
|
|
||||||
im.tostring('png'))
|
|
||||||
assert im.view(0,200,1,1).tostring()=='\xff\xff\x00\xff'
|
assert im.view(0,200,1,1).tostring()=='\xff\xff\x00\xff'
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -15,20 +15,6 @@ class TodoPlugin(ErrorClassPlugin):
|
||||||
|
|
||||||
todo = ErrorClass(Todo, label='TODO', isfailure=False)
|
todo = ErrorClass(Todo, label='TODO', isfailure=False)
|
||||||
|
|
||||||
def save_data(filename, data, key='MAPNIK_TEST_DATA_DIR'):
|
|
||||||
"""Saves bytestring 'data' into os.environ[key]/filename if
|
|
||||||
key in os.environ"""
|
|
||||||
if key in os.environ:
|
|
||||||
dir = os.environ[key]
|
|
||||||
if not os.path.exists(dir):
|
|
||||||
os.makedirs(dir)
|
|
||||||
fname = os.path.join(dir, filename)
|
|
||||||
f = open(fname, 'w')
|
|
||||||
try:
|
|
||||||
f.write(data)
|
|
||||||
finally:
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def contains_word(word, bytestring_):
|
def contains_word(word, bytestring_):
|
||||||
"""
|
"""
|
||||||
Checks that a bytestring contains a given word. len(bytestring) should be
|
Checks that a bytestring contains a given word. len(bytestring) should be
|
||||||
|
|
1
tests/visual_tests/.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
*-agg.png
|
|
||||||
*-out.xml
|
*-out.xml
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
rm -f images/*-agg.png
|
|
||||||
rm -f xml_output/*-out.xml
|
rm -f xml_output/*-out.xml
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ def compare(actual, expected):
|
||||||
passed += 1
|
passed += 1
|
||||||
return diff
|
return diff
|
||||||
|
|
||||||
def summary():
|
def summary(generate=False):
|
||||||
global errors
|
global errors
|
||||||
global passed
|
global passed
|
||||||
print "-"*80
|
print "-"*80
|
||||||
|
@ -57,7 +57,13 @@ def summary():
|
||||||
if len(errors) != 0:
|
if len(errors) != 0:
|
||||||
for error in errors:
|
for error in errors:
|
||||||
if (error[0] is None):
|
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:
|
else:
|
||||||
print "Failed: %d different pixels:\n\t%s (actual)\n\t%s (expected)" % error
|
print "Failed: %d different pixels:\n\t%s (actual)\n\t%s (expected)" % error
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
BIN
tests/visual_tests/images/tiff-alpha-gdal-600-reference.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 70 KiB |
BIN
tests/visual_tests/images/tiff-alpha-raster-600-reference.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 202 KiB After Width: | Height: | Size: 202 KiB |
After Width: | Height: | Size: 202 KiB |
|
@ -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">
|
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>
|
<StyleName>white</StyleName>
|
||||||
<Datasource>
|
<Datasource>
|
||||||
<Parameter name="file">../raster/white-alpha.tiff</Parameter>
|
<Parameter name="file">../../data/raster/white-alpha.tiff</Parameter>
|
||||||
<Parameter name="type">gdal</Parameter>
|
<Parameter name="type">gdal</Parameter>
|
||||||
</Datasource>
|
</Datasource>
|
||||||
</Layer>
|
</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">
|
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>
|
<StyleName>transp</StyleName>
|
||||||
<Datasource>
|
<Datasource>
|
||||||
<Parameter name="file">../raster/transp.tiff</Parameter>
|
<Parameter name="file">../../data/raster/transp.tiff</Parameter>
|
||||||
<Parameter name="type">gdal</Parameter>
|
<Parameter name="type">gdal</Parameter>
|
||||||
</Datasource>
|
</Datasource>
|
||||||
</Layer>
|
</Layer>
|
20
tests/visual_tests/styles/tiff-alpha-gradient-raster.xml
Normal file
|
@ -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>
|
20
tests/visual_tests/styles/tiff-alpha-raster.xml
Normal file
|
@ -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>
|
<StyleName>style</StyleName>
|
||||||
<Datasource>
|
<Datasource>
|
||||||
<!-- https://github.com/mapnik/mapnik/issues/1471 -->
|
<!-- 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>
|
<Parameter name="type">gdal</Parameter>
|
||||||
</Datasource>
|
</Datasource>
|
||||||
</Layer>
|
</Layer>
|
21
tests/visual_tests/styles/tiff-nodata-edge-raster.xml
Normal file
|
@ -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>
|
|
@ -7,8 +7,7 @@ import os.path
|
||||||
from compare import compare, summary
|
from compare import compare, summary
|
||||||
|
|
||||||
defaults = {
|
defaults = {
|
||||||
'sizes': [(500, 100)],
|
'sizes': [(500, 100)]
|
||||||
'bbox': mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sizes_many_in_big_range = [(800, 100), (600, 100), (400, 100),
|
sizes_many_in_big_range = [(800, 100), (600, 100), (400, 100),
|
||||||
|
@ -18,33 +17,39 @@ sizes_few_square = [(800, 800), (600, 600), (400, 400), (200, 200)]
|
||||||
sizes_many_in_small_range = [(490, 100), (495, 100), (497, 100), (498, 100),
|
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)]
|
(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__)
|
dirname = os.path.dirname(__file__)
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
{'name': "list", 'sizes': sizes_many_in_big_range},
|
{'name': "list", 'sizes': sizes_many_in_big_range,'bbox':default_text_box},
|
||||||
{'name': "simple", 'sizes': sizes_many_in_big_range},
|
{'name': "simple", 'sizes': sizes_many_in_big_range,'bbox':default_text_box},
|
||||||
{'name': "lines-1", 'sizes': sizes_few_square},
|
{'name': "lines-1", 'sizes': sizes_few_square,'bbox':default_text_box},
|
||||||
{'name': "lines-2", 'sizes': sizes_few_square},
|
{'name': "lines-2", 'sizes': sizes_few_square,'bbox':default_text_box},
|
||||||
{'name': "lines-3", 'sizes': sizes_few_square},
|
{'name': "lines-3", 'sizes': sizes_few_square,'bbox':default_text_box},
|
||||||
{'name': "lines-shield", 'sizes': sizes_few_square},
|
{'name': "lines-shield", 'sizes': sizes_few_square,'bbox':default_text_box},
|
||||||
{'name': "simple-E"},
|
{'name': "simple-E", 'bbox':mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)},
|
||||||
{'name': "simple-NE"},
|
{'name': "simple-NE",'bbox':default_text_box},
|
||||||
{'name': "simple-NW"},
|
{'name': "simple-NW",'bbox':default_text_box},
|
||||||
{'name': "simple-N"},
|
{'name': "simple-N",'bbox':default_text_box},
|
||||||
{'name': "simple-SE"},
|
{'name': "simple-SE",'bbox':default_text_box},
|
||||||
{'name': "simple-SW"},
|
{'name': "simple-SW",'bbox':default_text_box},
|
||||||
{'name': "simple-S"},
|
{'name': "simple-S",'bbox':default_text_box},
|
||||||
{'name': "simple-W"},
|
{'name': "simple-W",'bbox':default_text_box},
|
||||||
{'name': "formatting-1"},
|
{'name': "formatting-1",'bbox':default_text_box},
|
||||||
{'name': "formatting-2"},
|
{'name': "formatting-2",'bbox':default_text_box},
|
||||||
{'name': "formatting-3"},
|
{'name': "formatting-3",'bbox':default_text_box},
|
||||||
{'name': "formatting-4"},
|
{'name': "formatting-4",'bbox':default_text_box},
|
||||||
{'name': "expressionformat"},
|
{'name': "expressionformat",'bbox':default_text_box},
|
||||||
{'name': "shieldsymbolizer-1", 'sizes': sizes_many_in_small_range},
|
{'name': "shieldsymbolizer-1", 'sizes': sizes_many_in_small_range,'bbox':default_text_box},
|
||||||
{'name': "rtl-point", 'sizes': [(200, 200)]},
|
{'name': "rtl-point", 'sizes': [(200, 200)],'bbox':default_text_box},
|
||||||
{'name': "jalign-auto", 'sizes': [(200, 200)]},
|
{'name': "jalign-auto", 'sizes': [(200, 200)],'bbox':default_text_box},
|
||||||
{'name': "line-offset", 'sizes':[(900, 250)],
|
{'name': "line-offset", 'sizes':[(900, 250)],'bbox': mapnik.Box2d(-5.192, 50.189, -5.174, 50.195)},
|
||||||
'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):
|
def render(filename, width, height, bbox, quiet=False):
|
||||||
|
@ -89,7 +94,7 @@ if __name__ == "__main__":
|
||||||
config = dict(defaults)
|
config = dict(defaults)
|
||||||
config.update(f)
|
config.update(f)
|
||||||
for size in config['sizes']:
|
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']))
|
mapnik.save_map(m, os.path.join(dirname, 'xml_output', "%s-out.xml" % config['name']))
|
||||||
|
|
||||||
summary()
|
summary(generate=False)
|
||||||
|
|