Merge branch 'master' into harfbuzz

This commit is contained in:
Hermann Kraus 2013-03-23 14:39:04 +01:00
commit 9834fb73ed
27 changed files with 193 additions and 112 deletions

View file

@ -22,11 +22,15 @@
// boost
#include <boost/python.hpp>
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/query.hpp>
#include <mapnik/box2d.hpp>
#include <string>
#include <set>
using mapnik::query;
using mapnik::box2d;
@ -46,11 +50,30 @@ struct resolution_to_tuple
}
};
struct names_to_list
{
static PyObject* convert(std::set<std::string> const& names)
{
boost::python::list l;
BOOST_FOREACH( std::string const& name, names )
{
l.append(name);
}
return python::incref(l.ptr());
}
static PyTypeObject const* get_pytype()
{
return &PyList_Type;
}
};
void export_query()
{
using namespace boost::python;
to_python_converter<query::resolution_type, resolution_to_tuple> ();
to_python_converter<std::set<std::string>, names_to_list> ();
class_<query>("Query", "a spatial query data object",
init<box2d<double>,query::resolution_type const&,double>() )

View file

@ -85,7 +85,11 @@ namespace agg
{
if(x < m_start) return 0.0;
if(x > m_end) return 1.0;
return (x - m_start) / (m_end - m_start);
double delta = m_end - m_start;
// avoid nan from potential zero division
// https://github.com/mapnik/mapnik/issues/761
if (delta <= 0.0) return 0.0;
return (x - m_start) / delta;
}
private:

View file

@ -155,6 +155,8 @@ private:
boost::shared_ptr<label_collision_detector4> detector_;
boost::scoped_ptr<rasterizer> ras_ptr;
box2d<double> query_extent_;
gamma_method_e gamma_method_;
double gamma_;
void setup(Map const& m);
};
}

View file

@ -118,9 +118,9 @@ public:
private:
inline bool checkBounds(unsigned x, unsigned y) const
inline bool checkBounds(int x, int y) const
{
return (x < width_ && y < height_);
return (x >= 0 && x < width_ && y >= 0 && y < height_);
}
public:

View file

@ -531,12 +531,12 @@ struct mod: public boost::static_visitor<V>
value_type operator() (value_double lhs, value_integer rhs) const
{
return std::fmod(lhs, rhs);
return std::fmod(lhs, static_cast<value_double>(rhs));
}
value_type operator() (value_integer lhs, value_double rhs) const
{
return std::fmod(lhs, rhs);
return std::fmod(static_cast<value_double>(lhs), rhs);
}
value_type operator() (value_double lhs, value_double rhs) const

View file

@ -79,7 +79,10 @@ agg_renderer<T>::agg_renderer(Map const& m, T & pixmap, double scale_factor, uns
font_engine_(),
font_manager_(font_engine_),
detector_(boost::make_shared<label_collision_detector4>(box2d<double>(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size()))),
ras_ptr(new rasterizer)
ras_ptr(new rasterizer),
query_extent_(),
gamma_method_(GAMMA_POWER),
gamma_(1.0)
{
setup(m);
}
@ -98,7 +101,10 @@ agg_renderer<T>::agg_renderer(Map const& m, request const& req, T & pixmap, doub
font_engine_(),
font_manager_(font_engine_),
detector_(boost::make_shared<label_collision_detector4>(box2d<double>(-req.buffer_size(), -req.buffer_size(), req.width() + req.buffer_size() ,req.height() + req.buffer_size()))),
ras_ptr(new rasterizer)
ras_ptr(new rasterizer),
query_extent_(),
gamma_method_(GAMMA_POWER),
gamma_(1.0)
{
setup(m);
}
@ -118,7 +124,10 @@ agg_renderer<T>::agg_renderer(Map const& m, T & pixmap, boost::shared_ptr<label_
font_engine_(),
font_manager_(font_engine_),
detector_(detector),
ras_ptr(new rasterizer)
ras_ptr(new rasterizer),
query_extent_(),
gamma_method_(GAMMA_POWER),
gamma_(1.0)
{
setup(m);
}
@ -297,7 +306,12 @@ void agg_renderer<T>::render_marker(pixel_position const& pos,
typedef agg::pod_bvector<mapnik::svg::path_attributes> svg_attribute_type;
ras_ptr->reset();
if (gamma_method_ != GAMMA_POWER || gamma_ != 1.0)
{
ras_ptr->gamma(agg::gamma_power());
gamma_method_ = GAMMA_POWER;
gamma_ = 1.0;
}
agg::scanline_u8 sl;
agg::rendering_buffer buf(current_buffer_->raw_data(), width_, height_, width_ * 4);
pixfmt_comp_type pixf(buf);

View file

@ -70,7 +70,12 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
agg::scanline_u8 sl;
ras_ptr->reset();
if (gamma_method_ != GAMMA_POWER || gamma_ != 1.0)
{
ras_ptr->gamma(agg::gamma_power());
gamma_method_ = GAMMA_POWER;
gamma_ = 1.0;
}
double height = 0.0;
expression_ptr height_expr = sym.height();

View file

@ -30,17 +30,17 @@ namespace mapnik {
void draw_rect(image_32 &pixmap, box2d<double> const& box)
{
double x0 = box.minx();
double x1 = box.maxx();
double y0 = box.miny();
double y1 = box.maxy();
int x0 = static_cast<int>(box.minx());
int x1 = static_cast<int>(box.maxx());
int y0 = static_cast<int>(box.miny());
int y1 = static_cast<int>(box.maxy());
unsigned color1 = 0xff0000ff;
for (double x=x0; x<x1; x++)
for (int x=x0; x<x1; x++)
{
pixmap.setPixel(x, y0, color1);
pixmap.setPixel(x, y1, color1);
}
for (double y=y0; y<y1; y++)
for (int y=y0; y<y1; y++)
{
pixmap.setPixel(x0, y, color1);
pixmap.setPixel(x1, y, color1);

View file

@ -66,7 +66,12 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
unsigned a=col.alpha();
ras_ptr->reset();
if (stroke_.get_gamma() != gamma_ || stroke_.get_gamma_method() != gamma_method_)
{
set_gamma_method(stroke_, ras_ptr);
gamma_method_ = stroke_.get_gamma_method();
gamma_ = stroke_.get_gamma();
}
agg::rendering_buffer buf(current_buffer_->raw_data(),width_,height_, width_ * 4);

View file

@ -83,7 +83,12 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
if (mark && *mark)
{
ras_ptr->reset();
if (gamma_method_ != GAMMA_POWER || gamma_ != 1.0)
{
ras_ptr->gamma(agg::gamma_power());
gamma_method_ = GAMMA_POWER;
gamma_ = 1.0;
}
agg::trans_affine geom_tr;
evaluate_transform(geom_tr, feature, sym.get_transform());
agg::trans_affine tr = agg::trans_affine_scaling(scale_factor_);

View file

@ -61,8 +61,12 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
agg::rendering_buffer buf(current_buffer_->raw_data(), width_, height_, width_ * 4);
ras_ptr->reset();
if (sym.get_gamma() != gamma_ || sym.get_gamma_method() != gamma_method_)
{
set_gamma_method(sym, ras_ptr);
gamma_method_ = sym.get_gamma_method();
gamma_ = sym.get_gamma();
}
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker;
if ( !filename.empty() )

View file

@ -48,8 +48,12 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
{
ras_ptr->reset();
if (sym.get_gamma() != gamma_ || sym.get_gamma_method() != gamma_method_)
{
set_gamma_method(sym, ras_ptr);
gamma_method_ = sym.get_gamma_method();
gamma_ = sym.get_gamma();
}
agg::trans_affine tr;
evaluate_transform(tr, feature, sym.get_transform());

View file

@ -4,4 +4,4 @@
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
# 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

View file

@ -154,14 +154,13 @@ int main( int, char*[] )
BOOST_TEST(result);
BOOST_TEST_EQ(*result, std::string("GeometryCollection EMPTY"));
}
#endif
{
std::string wkt_in("Polygon((0 0,100 200,200 0,0 0 ))");
boost::optional<std::string> result = polygon_bbox_clipping(mapnik::box2d<double>(50,50,150,150),wkt_in);
BOOST_TEST(result);
BOOST_TEST_EQ(*result,std::string("Polygon((50 50,50 100,75 150,125 150,150 100,150 50,50 50))"));
}
#endif
if (!::boost::detail::test_errors())
{
std::clog << "C++ geometry conversions: \x1b[1;32m✓ \x1b[0m\n";

View file

@ -46,8 +46,7 @@ def test_mapnik_config_valid_opts():
'--includes',
'--dep-includes',
'--cxxflags',
'--cflags',
'--all-flags'
'--cflags'
]
for item in valid_args:
cmd = 'mapnik-config ' + item

View file

@ -17,6 +17,10 @@ def test_query_init():
r = query.resolution
assert_almost_equal(r[0], 1.0, places=7)
assert_almost_equal(r[1], 1.0, places=7)
# https://github.com/mapnik/mapnik/issues/1762
eq_(query.property_names,[])
query.add_property_name('migurski')
eq_(query.property_names,['migurski'])
# Converting *from* tuples *to* resolutions is not yet supported
@raises(TypeError)

View file

@ -17,15 +17,16 @@ config_variables = '''#!/bin/sh
## variables
CONFIG_PREFIX="$( cd "$( dirname $( dirname "$0" ))" && pwd )"
CONFIG_MAPNIK_VERSION='%(version)s'
CONFIG_GIT_REVISION='%(git_revision)s'
CONFIG_GIT_DESCRIBE='%(git_describe)s'
CONFIG_FONTS='%(fonts)s'
CONFIG_INPUT_PLUGINS='%(input_plugins)s'
CONFIG_FONTS="%(fonts)s"
CONFIG_INPUT_PLUGINS="%(input_plugins)s"
CONFIG_MAPNIK_DEFINES='%(defines)s'
CONFIG_PREFIX="$( cd "$( dirname $( dirname "$0" ))" && pwd )"
CONFIG_MAPNIK_LIBNAME='%(mapnik_libname)s'
CONFIG_MAPNIK_LIB="${CONFIG_PREFIX}/%(libdir_schema)s"
CONFIG_MAPNIK_LIBPATH="%(mapnik_libpath)s"
CONFIG_DEP_LIBS='%(dep_libs)s'
CONFIG_MAPNIK_LDFLAGS='%(ldflags)s'
CONFIG_MAPNIK_INCLUDE="${CONFIG_PREFIX}/include -I${CONFIG_PREFIX}/include/mapnik/agg"
@ -82,17 +83,29 @@ else:
if not stderr:
git_describe = stdin.strip()
# for fonts and input plugins we should try
# to store the relative path, if feasible
fontspath = config_env['MAPNIK_FONTS']
lib_root = os.path.join(config_env['INSTALL_PREFIX'], config_env['LIBDIR_SCHEMA'])
if lib_root in fontspath:
fontspath = "${CONFIG_PREFIX}/" + os.path.relpath(fontspath,config_env['INSTALL_PREFIX'])
inputpluginspath = config_env['MAPNIK_INPUT_PLUGINS']
if lib_root in inputpluginspath:
inputpluginspath = "${CONFIG_PREFIX}/" + os.path.relpath(inputpluginspath,config_env['INSTALL_PREFIX'])
lib_path = "${CONFIG_PREFIX}/" + config_env['LIBDIR_SCHEMA']
configuration = {
"git_revision": git_revision,
"git_describe": git_describe,
"version": config_env['MAPNIK_VERSION_STRING'],
"mapnik_libname": 'mapnik',
"libdir_schema": config_env['LIBDIR_SCHEMA'],
"mapnik_libpath": lib_path,
"ldflags": ldflags,
"dep_libs": dep_libs,
"dep_includes": dep_includes,
"fonts": config_env['MAPNIK_FONTS'],
"input_plugins": config_env['MAPNIK_INPUT_PLUGINS'],
"fonts": fontspath,
"input_plugins": inputpluginspath,
"defines":defines,
"cxxflags":cxxflags
}

View file

@ -86,7 +86,7 @@ while test $# -gt 0; do
;;
--libs)
echo -L${CONFIG_MAPNIK_LIB} -l${CONFIG_MAPNIK_LIBNAME}
echo -L${CONFIG_MAPNIK_LIBPATH} -l${CONFIG_MAPNIK_LIBNAME}
;;
--dep-libs)