Merge commit '5e1a19cfda06382b34c8f6f6729b16a36543fc82' into harfbuzz

Conflicts:
	tests/visual_tests/test.py
This commit is contained in:
Hermann Kraus 2013-03-16 18:26:08 +01:00
commit 53320282f6
50 changed files with 1423 additions and 88 deletions

View file

@ -28,26 +28,28 @@ enum clipper_PolyFillType {clipper_even_odd, clipper_non_zero, clipper_positive,
template<class VSA, class VSB> class conv_clipper template<class VSA, class VSB> class conv_clipper
{ {
enum status { status_move_to, status_line_to, status_close_path, status_stop }; enum status { status_move_to, status_line_to, status_stop };
typedef VSA source_a_type; typedef VSA source_a_type;
typedef VSB source_b_type; typedef VSB source_b_type;
typedef conv_clipper<source_a_type, source_b_type> self_type; typedef conv_clipper<source_a_type, source_b_type> self_type;
private: private:
source_a_type* m_src_a; source_a_type* m_src_a;
source_b_type* m_src_b; source_b_type* m_src_b;
status m_status; status m_status;
int m_vertex; int m_vertex;
int m_contour; int m_contour;
int m_scaling_factor; int m_scaling_factor;
clipper_op_e m_operation; clipper_op_e m_operation;
pod_bvector<ClipperLib::IntPoint, 8> m_vertex_accumulator; pod_bvector<ClipperLib::IntPoint, 8> m_vertex_accumulator;
ClipperLib::Polygons m_poly_a; ClipperLib::Polygons m_poly_a;
ClipperLib::Polygons m_poly_b; ClipperLib::Polygons m_poly_b;
ClipperLib::Polygons m_result; ClipperLib::Polygons m_result;
ClipperLib::Clipper m_clipper; ClipperLib::Clipper m_clipper;
clipper_PolyFillType m_subjFillType; clipper_PolyFillType m_subjFillType;
clipper_PolyFillType m_clipFillType; clipper_PolyFillType m_clipFillType;
double start_x_;
double start_y_;
int Round(double val) int Round(double val)
{ {
@ -67,7 +69,9 @@ public:
m_contour(-1), m_contour(-1),
m_operation(op), m_operation(op),
m_subjFillType(subjFillType), m_subjFillType(subjFillType),
m_clipFillType(clipFillType) m_clipFillType(clipFillType),
start_x_(0),
start_y_(0)
{ {
m_scaling_factor = std::max(std::min(scaling_factor, 6),0); m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor)); m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
@ -84,7 +88,9 @@ public:
m_contour(-1), m_contour(-1),
m_operation(op), m_operation(op),
m_subjFillType(subjFillType), m_subjFillType(subjFillType),
m_clipFillType(clipFillType) m_clipFillType(clipFillType),
start_x_(0),
start_y_(0)
{ {
m_scaling_factor = std::max(std::min(scaling_factor, 6),0); m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor)); m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
@ -276,50 +282,42 @@ bool conv_clipper<VSA, VSB>::next_vertex(double *x, double *y)
template<class VSA, class VSB> template<class VSA, class VSB>
unsigned conv_clipper<VSA, VSB>::vertex(double *x, double *y) unsigned conv_clipper<VSA, VSB>::vertex(double *x, double *y)
{ {
switch (m_status) if( m_status == status_move_to )
{
case status_move_to:
{ {
if( next_contour() ) if( next_contour() )
{ {
if ( next_vertex( x, y ) ) if( next_vertex( x, y ) )
{ {
m_status = status_line_to; m_status =status_line_to;
start_x_ = *x;
start_y_ = *y;
return path_cmd_move_to; return path_cmd_move_to;
} }
else else
{ {
m_status = status_close_path; *x = start_x_;
return path_cmd_line_to; *y = start_y_;
m_status = status_stop;
return path_cmd_end_poly | path_flags_close;
} }
} }
else else
return path_cmd_stop; return path_cmd_stop;
} }
case status_close_path: else
{ {
*x = 0; if( next_vertex( x, y ) )
*y = 0;
m_status = status_move_to;
return path_cmd_end_poly | path_flags_close;
}
case status_stop:
{
return path_cmd_stop;
}
default:
{
if( next_vertex( x, y ) )
{ {
return path_cmd_line_to; return path_cmd_line_to;
} }
else else
{ {
m_status = status_close_path; m_status = status_move_to;
return path_cmd_line_to; *x = start_x_;
*y = start_y_;
return path_cmd_end_poly | path_flags_close;
} }
} }
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View file

@ -425,6 +425,7 @@ bool hit_test(PathType & path, double x, double y, double tol)
unsigned count = 0; unsigned count = 0;
while (SEG_END != (command = path.vertex(&x1, &y1))) while (SEG_END != (command = path.vertex(&x1, &y1)))
{ {
if (command == SEG_CLOSE) continue;
++count; ++count;
if (command == SEG_MOVETO) if (command == SEG_MOVETO)
{ {
@ -472,6 +473,8 @@ bool interior_position(PathType & path, double & x, double & y)
double y1 = 0; double y1 = 0;
while (SEG_END != (command = path.vertex(&x1, &y1))) while (SEG_END != (command = path.vertex(&x1, &y1)))
{ {
if (command == SEG_CLOSE)
continue;
if (command != SEG_MOVETO) if (command != SEG_MOVETO)
{ {
// if the segments overlap // if the segments overlap

View file

@ -61,11 +61,11 @@ template <typename Image>
void scale_image_agg(Image & target, void scale_image_agg(Image & target,
Image const& source, Image const& source,
scaling_method_e scaling_method, scaling_method_e scaling_method,
double scale_factor, double image_ratio_x,
double image_ratio_y,
double x_off_f=0, double x_off_f=0,
double y_off_f=0, double y_off_f=0,
double filter_radius=2, double filter_radius=2);
double ratio=1);
template <typename Image> template <typename Image>
void scale_image_bilinear_old(Image & target, void scale_image_bilinear_old(Image & target,

View file

@ -26,12 +26,7 @@ libraries = ['mapnik',env['BOOST_PYTHON_LIB'],boost_system,env['ICU_LIB_NAME']]
# python plugin is used by a app in python using mapnik's python bindings # python plugin is used by a app in python using mapnik's python bindings
# we explicitly link to libpython here so that this plugin # we explicitly link to libpython here so that this plugin
# can be used from a pure C++ calling application or a different binding language # can be used from a pure C++ calling application or a different binding language
python_link_flag = '-lpython%s' % env['PYTHON_VERSION'] if env['PLATFORM'] == 'Darwin' and env['FRAMEWORK_PYTHON']:
if env['PLATFORM'] == 'Darwin':
if env['PYTHON_DYNAMIC_LOOKUP']:
python_link_flag = '-undefined dynamic_lookup'
elif env['FRAMEWORK_PYTHON']:
if env['FRAMEWORK_SEARCH_PATH']: if env['FRAMEWORK_SEARCH_PATH']:
python_link_flag = '-F%s -framework Python -Z' % env['FRAMEWORK_SEARCH_PATH'] python_link_flag = '-F%s -framework Python -Z' % env['FRAMEWORK_SEARCH_PATH']
else: else:
@ -42,6 +37,11 @@ if env['PLATFORM'] == 'Darwin':
python_link_flag = '-F/System/Library/Frameworks/ -framework Python -Z' python_link_flag = '-F/System/Library/Frameworks/ -framework Python -Z'
else: else:
python_link_flag = '-F/ -framework Python' python_link_flag = '-F/ -framework Python'
else:
# on linux the linkflags end up to early in the compile flags to work correctly
python_link_flag = ''
# so instead add to libraries
libraries.append('python%s' % env['PYTHON_VERSION'])
if env['CUSTOM_LDFLAGS']: if env['CUSTOM_LDFLAGS']:
linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], python_link_flag) linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], python_link_flag)

View file

@ -63,10 +63,10 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
box2d<double> target_ext = box2d<double>(source->ext_); box2d<double> target_ext = box2d<double>(source->ext_);
prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS); prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS);
box2d<double> ext = t_.forward(target_ext); box2d<double> ext = t_.forward(target_ext);
int start_x = static_cast<int>(ext.minx()); int start_x = static_cast<int>(std::floor(ext.minx()+.5));
int start_y = static_cast<int>(ext.miny()); int start_y = static_cast<int>(std::floor(ext.miny()+.5));
int end_x = static_cast<int>(std::ceil(ext.maxx())); int end_x = static_cast<int>(std::floor(ext.maxx()+.5));
int end_y = static_cast<int>(std::ceil(ext.maxy())); int end_y = static_cast<int>(std::floor(ext.maxy()+.5));
int raster_width = end_x - start_x; int raster_width = end_x - start_x;
int raster_height = end_y - start_y; int raster_height = end_y - start_y;
if (raster_width > 0 && raster_height > 0) if (raster_width > 0 && raster_height > 0)
@ -111,11 +111,13 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
} }
else else
{ {
double scaling_ratio = ext.width() / source->data_.width(); double image_ratio_x = ext.width() / source->data_.width();
double image_ratio_y = ext.height() / source->data_.height();
scale_image_agg<image_data_32>(target.data_, scale_image_agg<image_data_32>(target.data_,
source->data_, source->data_,
scaling_method, scaling_method,
scaling_ratio, image_ratio_x,
image_ratio_y,
0.0, 0.0,
0.0, 0.0,
filter_radius); filter_radius);

View file

@ -889,10 +889,10 @@ void cairo_renderer_base::process(raster_symbolizer const& sym,
box2d<double> target_ext = box2d<double>(source->ext_); box2d<double> target_ext = box2d<double>(source->ext_);
prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS); prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS);
box2d<double> ext = t_.forward(target_ext); box2d<double> ext = t_.forward(target_ext);
int start_x = static_cast<int>(ext.minx()); int start_x = static_cast<int>(std::floor(ext.minx()+.5));
int start_y = static_cast<int>(ext.miny()); int start_y = static_cast<int>(std::floor(ext.miny()+.5));
int end_x = static_cast<int>(std::ceil(ext.maxx())); int end_x = static_cast<int>(std::floor(ext.maxx()+.5));
int end_y = static_cast<int>(std::ceil(ext.maxy())); int end_y = static_cast<int>(std::floor(ext.maxy()+.5));
int raster_width = end_x - start_x; int raster_width = end_x - start_x;
int raster_height = end_y - start_y; int raster_height = end_y - start_y;
if (raster_width > 0 && raster_height > 0) if (raster_width > 0 && raster_height > 0)
@ -909,7 +909,10 @@ void cairo_renderer_base::process(raster_symbolizer const& sym,
} }
if (premultiply_source) if (premultiply_source)
{ {
agg::rendering_buffer buffer(source->data_.getBytes(),source->data_.width(),source->data_.height(),source->data_.width() * 4); agg::rendering_buffer buffer(source->data_.getBytes(),
source->data_.width(),
source->data_.height(),
source->data_.width() * 4);
agg::pixfmt_rgba32 pixf(buffer); agg::pixfmt_rgba32 pixf(buffer);
pixf.premultiply(); pixf.premultiply();
} }
@ -927,14 +930,20 @@ void cairo_renderer_base::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_,
} else source->data_,
0.0,
0.0);
}
else
{ {
double scaling_ratio = ext.width() / source->data_.width(); double image_ratio_x = ext.width() / source->data_.width();
double image_ratio_y = ext.height() / source->data_.height();
scale_image_agg<image_data_32>(target.data_, scale_image_agg<image_data_32>(target.data_,
source->data_, source->data_,
scaling_method, scaling_method,
scaling_ratio, image_ratio_x,
image_ratio_y,
0.0, 0.0,
0.0, 0.0,
filter_radius); filter_radius);

View file

@ -198,8 +198,11 @@ void grid_renderer<T>::render_marker(mapnik::feature_impl & feature, unsigned in
// TODO - remove support for step != or add support for agg scaling with opacity // TODO - remove support for step != or add support for agg scaling with opacity
double ratio = (1.0/step); double ratio = (1.0/step);
image_data_32 target(ratio * data.width(), ratio * data.height()); image_data_32 target(ratio * data.width(), ratio * data.height());
mapnik::scale_image_agg<image_data_32>(target,data, SCALING_NEAR, mapnik::scale_image_agg<image_data_32>(target,
scale_factor_, 0.0, 0.0, 1.0, ratio); data,
SCALING_NEAR,
ratio,
ratio);
pixmap_.set_rectangle(feature.id(), target, pixmap_.set_rectangle(feature.id(), target,
boost::math::iround(pos.x - cx), boost::math::iround(pos.x - cx),
boost::math::iround(pos.y - cy)); boost::math::iround(pos.y - cy));

View file

@ -139,6 +139,12 @@ void composite(T1 & dst, T2 & src, composite_mode_e mode,
ren.blend_from(pixf_mask,0,dx,dy,unsigned(255*opacity)); ren.blend_from(pixf_mask,0,dx,dy,unsigned(255*opacity));
} }
template void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32&, mapnik::image_data_32& ,composite_mode_e, float, int, int, bool); template void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32&,
mapnik::image_data_32&,
composite_mode_e,
float,
int,
int,
bool);
} }

View file

@ -258,11 +258,11 @@ template <typename Image>
void scale_image_agg(Image & target, void scale_image_agg(Image & target,
Image const& source, Image const& source,
scaling_method_e scaling_method, scaling_method_e scaling_method,
double image_ratio, double image_ratio_x,
double image_ratio_y,
double x_off_f, double x_off_f,
double y_off_f, double y_off_f,
double filter_radius, double filter_radius)
double ratio)
{ {
// "the image filters should work namely in the premultiplied color space" // "the image filters should work namely in the premultiplied color space"
// http://old.nabble.com/Re:--AGG--Basic-image-transformations-p1110665.html // http://old.nabble.com/Re:--AGG--Basic-image-transformations-p1110665.html
@ -291,7 +291,7 @@ void scale_image_agg(Image & target,
// create a scaling matrix // create a scaling matrix
agg::trans_affine img_mtx; agg::trans_affine img_mtx;
img_mtx /= agg::trans_affine_scaling(image_ratio * ratio, image_ratio * ratio); img_mtx /= agg::trans_affine_scaling(image_ratio_x, image_ratio_y);
// create a linear interpolator for our scaling matrix // create a linear interpolator for our scaling matrix
typedef agg::span_interpolator_linear<> interpolator_type; typedef agg::span_interpolator_linear<> interpolator_type;
@ -367,7 +367,14 @@ void scale_image_agg(Image & target,
agg::render_scanlines_aa(ras, sl, rb_dst_pre, sa, sg); agg::render_scanlines_aa(ras, sl, rb_dst_pre, sa, sg);
} }
template void scale_image_agg<image_data_32> (image_data_32& target,const image_data_32& source, scaling_method_e scaling_method, double scale_factor, double x_off_f, double y_off_f, double filter_radius, double ratio); template void scale_image_agg<image_data_32>(image_data_32& target,
const image_data_32& source,
scaling_method_e scaling_method,
double image_ratio_x,
double image_ratio_y,
double x_off_f,
double y_off_f,
double filter_radius);
template void scale_image_bilinear_old<image_data_32> (image_data_32& target,const image_data_32& source, double x_off_f, double y_off_f); template void scale_image_bilinear_old<image_data_32> (image_data_32& target,const image_data_32& source, double x_off_f, double y_off_f);

View file

@ -0,0 +1,123 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/util/conversions.hpp>
// boost
#include <boost/detail/lightweight_test.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
// stl
#include <exception>
#include <iostream>
#include <fstream>
#include <vector>
// agg
#include "agg_conv_clip_polygon.h"
#include "agg_conv_clip_polyline.h"
//#include "agg_path_storage.h"
//#include "agg_conv_clipper.h"
template <typename T>
std::string dump_path(T & path)
{
unsigned cmd = 1;
double x = 0;
double y = 0;
unsigned idx = 0;
std::ostringstream s;
path.rewind(0);
while ((cmd = path.vertex(&x, &y)) != mapnik::SEG_END)
{
if (idx > 0) s << ",";
s << x << " " << y << " " << cmd;
idx++;
}
return s.str();
}
std::string clip_line(mapnik::box2d<double> const& bbox,
mapnik::geometry_type & geom)
{
typedef agg::conv_clip_polyline<mapnik::geometry_type> line_clipper;
line_clipper clipped(geom);
clipped.clip_box(bbox.minx(),bbox.miny(),bbox.maxx(),bbox.maxy());
return dump_path(clipped);
}
void parse_geom(mapnik::geometry_type & geom,
std::string const& geom_string) {
std::vector<std::string> vertices;
boost::split(vertices, geom_string, boost::is_any_of(","));
BOOST_FOREACH(std::string const& vert, vertices)
{
std::vector<std::string> commands;
boost::split(commands, vert, boost::is_any_of(" "));
if (commands.size() != 3)
{
throw std::runtime_error(std::string("could not parse geometry '") + geom_string + "'");
}
double x = 0;
double y = 0;
int c = 0;
if (mapnik::util::string2double(commands[0],x)
&& mapnik::util::string2double(commands[1],y)
&& mapnik::util::string2int(commands[2],c))
{
geom.push_vertex(x,y,(mapnik::CommandType)c);
}
else
{
throw std::runtime_error(std::string("could not parse geometry '") + geom_string + "'");
}
}
}
int main( int, char*[] )
{
try {
std::string filename("tests/cpp_tests/data/cases.txt");
std::ifstream stream(filename.c_str(),std::ios_base::in | std::ios_base::binary);
if (!stream.is_open())
throw std::runtime_error("could not open: '" + filename + "'");
std::string csv_line;
while(std::getline(stream,csv_line,'\n'))
{
if (csv_line.empty() || csv_line[0] == '#') continue;
std::vector<std::string> parts;
boost::split(parts, csv_line, boost::is_any_of(";"));
// first part is clipping box
mapnik::box2d<double> bbox;
if (!bbox.from_string(parts[0])) {
throw std::runtime_error(std::string("could not parse bbox '") + parts[0] + "'");
}
// second part is input geometry
mapnik::geometry_type geom;
parse_geom(geom,parts[1]);
//std::clog << dump_path(geom) << "\n";
// third part is expected, clipped geometry
BOOST_TEST_EQ(clip_line(bbox,geom),parts[2]);
}
stream.close();
}
catch (std::exception const& ex)
{
std::cerr << ex.what() << "\n";
}
if (!::boost::detail::test_errors())
{
std::clog << "C++ clipping: \x1b[1;32m✓ \x1b[0m\n";
#if BOOST_VERSION >= 104600
::boost::detail::report_errors_remind().called_report_errors_function = true;
#endif
}
else
{
return ::boost::report_errors();
}
}

View file

@ -0,0 +1,7 @@
# testcase format is:
# <bbox>;<input geometry>;<expected clipped geometry>
# SEG_END=0 SEG_MOVETO = 1 SEG_LINETO = 2 SEG_CLOSE = (0x40 | 0x0f)
50,50,150,150;0 0 1,200 200 2;50 50 1,150 150 2
50,50,150,150;50 50 1,150 50 2,150 150 2,50 150 2,50 50 2;50 50 1,150 50 2,150 150 2,50 150 2,50 50 2
# TODO - should the close path be kept after clipping?
50,50,150,150;50 50 1,150 50 2,150 150 2,50 150 2,50 50 2,0 0 79;50 50 1,150 50 2,150 150 2,50 150 2,50 50 2, 0 0 79

View file

@ -189,7 +189,6 @@ def test_render_with_scale_factor():
actual = mapnik.Image.open(expected_file) actual = mapnik.Image.open(expected_file)
expected = mapnik.Image.open(expected_file) expected = mapnik.Image.open(expected_file)
eq_(actual.tostring(),expected.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file)) eq_(actual.tostring(),expected.tostring(), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
im.save('./images/support/marker-text-line-scale-factor-%s.png' % size,'png8')
if __name__ == "__main__": if __name__ == "__main__":
setup() setup()

View file

@ -0,0 +1,6 @@
191.092170573681
0.000000000000
0.000000000000
-191.092170573681
-13383825.126807762310
4651869.862067188136

Binary file not shown.

View file

@ -0,0 +1,73 @@
{
"keys": [
""
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -0,0 +1,72 @@
{
"keys": [
""
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -0,0 +1,73 @@
{
"keys": [
""
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -0,0 +1,72 @@
{
"keys": [
""
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -0,0 +1,207 @@
{
"keys": [
""
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -0,0 +1,207 @@
{
"keys": [
""
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -0,0 +1,207 @@
{
"keys": [
""
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -0,0 +1,207 @@
{
"keys": [
""
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -0,0 +1,17 @@
<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="white">
<Style name="test">
<Rule>
<RasterSymbolizer scaling="bilinear" />
</Rule>
</Style>
<Layer name="test" 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>test</StyleName>
<Datasource>
<Parameter name="file">../data/Yosemite_L9.tif</Parameter>
<Parameter name="type">gdal</Parameter>
</Datasource>
</Layer>
</Map>

View file

@ -0,0 +1,17 @@
<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="white">
<Style name="test">
<Rule>
<RasterSymbolizer scaling="bilinear" />
</Rule>
</Style>
<Layer name="test" 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>test</StyleName>
<Datasource>
<Parameter name="file">../data/Yosemite_L9.tif</Parameter>
<Parameter name="type">gdal</Parameter>
</Datasource>
</Layer>
</Map>

View file

@ -76,11 +76,18 @@ files = [
{'name': "tiff-alpha-gdal", 'sizes':[(600,400)]}, {'name': "tiff-alpha-gdal", 'sizes':[(600,400)]},
{'name': "tiff-alpha-broken-assoc-alpha-gdal", 'sizes':[(600,400)]}, {'name': "tiff-alpha-broken-assoc-alpha-gdal", 'sizes':[(600,400)]},
{'name': "tiff-alpha-gradient-gdal", 'sizes':[(600,400)]}, {'name': "tiff-alpha-gradient-gdal", 'sizes':[(600,400)]},
{'name': "tiff-nodata-edge-gdal", 'sizes':[(600,400)]}, {'name': "tiff-nodata-edge-gdal", 'sizes':[(600,400),(969,793)]},
{'name': "tiff-opaque-edge-gdal", 'sizes':[(256,256)]}, {'name': "tiff-opaque-edge-gdal", 'sizes':[(256,256),(969,793)]},
{'name': "tiff-opaque-edge-gdal2", 'sizes':[(600,400)]}, {'name': "tiff-opaque-edge-gdal2", 'sizes':[(600,400),(969,793)]},
{'name': "tiff-opaque-edge-raster2", 'sizes':[(600,400)]}, {'name': "tiff-opaque-edge-raster2", 'sizes':[(600,400),(969,793)]},
{'name': "tiff-resampling", 'sizes':[(600,400)]}, {'name': "tiff-resampling", 'sizes':[(600,400)]},
# https://github.com/mapnik/mapnik/issues/1622
{'name': "tiff-edge-alignment-gdal1", 'sizes':[(256,256),(255,257)],
'bbox':mapnik.Box2d(-13267022.12540147,4618019.500877209,-13247454.246160466,4637587.380118214)
},
{'name': "tiff-edge-alignment-gdal2", 'sizes':[(256,256),(255,257)],
'bbox':mapnik.Box2d(-13267022.12540147,4598451.621636203,-13247454.246160466,4618019.500877209)
},
# https://github.com/mapnik/mapnik/issues/1520 # https://github.com/mapnik/mapnik/issues/1520
# commented because these are not critical failures # commented because these are not critical failures
#{'name': "tiff-alpha-raster", 'sizes':[(600,400)]}, #{'name': "tiff-alpha-raster", 'sizes':[(600,400)]},
@ -96,7 +103,7 @@ files = [
{'name': "line_break", 'sizes': [(800, 800)]}, {'name': "line_break", 'sizes': [(800, 800)]},
] ]
def report(diff,quiet=False,threshold=0): def report(diff,threshold,quiet=False):
if diff > threshold: if diff > threshold:
if quiet: if quiet:
sys.stderr.write('\x1b[31m.\x1b[0m') sys.stderr.write('\x1b[31m.\x1b[0m')
@ -108,7 +115,7 @@ def report(diff,quiet=False,threshold=0):
else: else:
print '\x1b[32m✓\x1b[0m' print '\x1b[32m✓\x1b[0m'
def render(config, width, height, bbox, quiet=False): def render(config, width, height, bbox, quiet=False, overwrite_failures=False):
filename = config['name'] filename = config['name']
m = mapnik.Map(width, height) m = mapnik.Map(width, height)
@ -137,7 +144,11 @@ def render(config, width, height, bbox, quiet=False):
fail(actual_agg,expected,None) fail(actual_agg,expected,None)
else: else:
diff = compare(actual_agg, expected, threshold=1, alpha=True) diff = compare(actual_agg, expected, threshold=1, alpha=True)
report(diff,quiet) threshold = 0
if overwrite_failures and diff > threshold:
fail(actual_agg,expected,None)
else:
report(diff,threshold,quiet)
except Exception, e: except Exception, e:
sys.stderr.write(e.message + '\n') sys.stderr.write(e.message + '\n')
fail(actual_agg,expected,str(e.message)) fail(actual_agg,expected,str(e.message))
@ -157,9 +168,12 @@ def render(config, width, height, bbox, quiet=False):
fail(actual_cairo,expected_cairo,None) fail(actual_cairo,expected_cairo,None)
else: else:
# cairo and agg differ in alpha for reasons unknown, so don't test it for now # cairo and agg differ in alpha for reasons unknown, so don't test it for now
diff_threshold = 1 threshold = 0
diff = compare(actual_cairo, expected_cairo, threshold=diff_threshold, alpha=False) diff = compare(actual_cairo, expected_cairo, threshold=threshold, alpha=False)
report(diff,quiet,threshold=diff_threshold) if overwrite_failures and diff > threshold:
fail(actual_cairo,expected_cairo,None)
else:
report(diff,threshold,quiet)
except Exception, e: except Exception, e:
sys.stderr.write(e.message + '\n') sys.stderr.write(e.message + '\n')
fail(actual_cairo,expected_cairo,str(e.message)) fail(actual_cairo,expected_cairo,str(e.message))
@ -179,8 +193,12 @@ def render(config, width, height, bbox, quiet=False):
# generate it on the fly # generate it on the fly
fail(actual_grid,expected_grid,None) fail(actual_grid,expected_grid,None)
else: else:
diff = compare_grids(actual_grid, expected_grid, threshold=1, alpha=False) threshold = 1
report(diff,quiet) diff = compare_grids(actual_grid, expected_grid, threshold=threshold, alpha=False)
if overwrite_failures and diff > threshold:
fail(actual_grid,expected_grid,None)
else:
report(diff,threshold,quiet)
except Exception, e: except Exception, e:
sys.stderr.write(e.message + '\n') sys.stderr.write(e.message + '\n')
fail(actual_grid,expected,str(e.message)) fail(actual_grid,expected,str(e.message))
@ -193,12 +211,14 @@ if __name__ == "__main__":
else: else:
quiet = False quiet = False
if len(sys.argv) <= 1: if '--overwrite' in sys.argv:
active = files overwrite_failures = True
elif len(sys.argv) == 2: sys.argv.remove('--overwrite')
active = [{"name": sys.argv[1], "sizes": sizes_few_square}] else:
overwrite_failures = False
elif len(sys.argv) > 2: elif len(sys.argv) > 2:
active = [] files = []
if sys.argv[1] == "-s": if sys.argv[1] == "-s":
name = sys.argv[2] name = sys.argv[2]
for f in files: for f in files:
@ -216,7 +236,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, size[0], size[1], config.get('bbox'), quiet=quiet) m = render(config, size[0], size[1], config.get('bbox'), quiet=quiet, overwrite_failures=overwrite_failures)
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(generate=True) summary(generate=True)