Merge branch 'master' of github.com:mapnik/mapnik into localized-font-cache

Conflicts:
	src/build.py
This commit is contained in:
Dane Springmeyer 2014-09-30 14:42:01 -07:00
commit 09b02ddc17
67 changed files with 846 additions and 991 deletions

View file

@ -501,7 +501,8 @@ elif HELP_REQUESTED:
# need no-op for clean on fresh checkout
# https://github.com/mapnik/mapnik/issues/2112
if not os.path.exists(SCONS_LOCAL_LOG) and ('-c' in command_line_args or '--clean' in command_line_args):
if not os.path.exists(SCONS_LOCAL_LOG) and not os.path.exists(SCONS_CONFIGURE_CACHE) \
and ('-c' in command_line_args or '--clean' in command_line_args):
print 'all good: nothing to clean, but you might want to run "make distclean"'
Exit(0)

View file

@ -30,11 +30,9 @@
#include <boost/python/call_method.hpp>
#include <boost/python/tuple.hpp>
#include <boost/python/to_python_converter.hpp>
#include <boost/noncopyable.hpp>
// mapnik
#include <mapnik/value_types.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/feature_factory.hpp>
@ -56,7 +54,7 @@ using mapnik::context_ptr;
using mapnik::feature_kv_iterator;
mapnik::geometry_type const& (mapnik::feature_impl::*get_geometry_by_const_ref)(std::size_t) const = &mapnik::feature_impl::get_geometry;
boost::ptr_vector<mapnik::geometry_type> const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths;
mapnik::geometry_container const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths;
void feature_add_geometries_from_wkb(mapnik::feature_impl & feature, std::string wkb)
{

View file

@ -28,12 +28,12 @@
#include <boost/python/exception_translator.hpp>
#include <boost/python/manage_new_object.hpp>
#include <boost/python/iterator.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/noncopyable.hpp>
#include <boost/version.hpp>
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/wkt/wkt_factory.hpp> // from_wkt
#include <mapnik/util/geometry_to_wkt.hpp>
#include <mapnik/json/geometry_parser.hpp> // from_geojson

View file

@ -30,9 +30,6 @@
// boost
#include <boost/operators.hpp>
// stl
#include <iomanip>
// agg
// forward declare so that apps using mapnik do not need agg headers
namespace agg {
@ -105,6 +102,7 @@ public:
bool from_string(std::string const& str);
bool valid() const;
void move(T x, T y);
std::string to_string() const;
// define some operators
box2d_type& operator+=(box2d_type const& other);
@ -124,13 +122,7 @@ inline std::basic_ostream<charT,traits>&
operator << (std::basic_ostream<charT,traits>& out,
const box2d<T>& e)
{
std::basic_ostringstream<charT,traits> s;
s.copyfmt(out);
s.width(0);
s << "box2d(" << std::fixed << std::setprecision(16)
<< e.minx() << ',' << e.miny() << ','
<< e.maxx() << ',' << e.maxy() << ')';
out << s.str();
out << e.to_string();
return out;
}
}

View file

@ -51,7 +51,6 @@
namespace mapnik {
class text_path;
template <typename T> class box2d;
using ErrorStatus = cairo_status_t;

View file

@ -34,12 +34,6 @@
#include <mapnik/function_call.hpp>
#include <mapnik/util/variant.hpp>
#if defined(BOOST_REGEX_HAS_ICU)
#include <boost/regex/icu.hpp>
#else
#include <boost/regex.hpp>
#endif
namespace mapnik {
namespace {
@ -107,24 +101,13 @@ struct evaluate_expression : util::static_visitor<T>
value_type operator() (regex_match_node const& x) const
{
value_type v = util::apply_visitor(*this, x.expr);
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_match(v.to_unicode(),x.pattern);
#else
return boost::regex_match(v.to_string(),x.pattern);
#endif
return x.apply(v);
}
value_type operator() (regex_replace_node const& x) const
{
value_type v = util::apply_visitor(*this, x.expr);
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format);
#else
std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format);
mapnik::transcoder tr_("utf8");
return tr_.transcode(repl.c_str());
#endif
return x.apply(v);
}
value_type operator() (unary_function_call const& call) const
@ -206,24 +189,13 @@ struct evaluate_expression<T, boost::none_t> : util::static_visitor<T>
value_type operator() (regex_match_node const& x) const
{
value_type v = util::apply_visitor(*this, x.expr);
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_match(v.to_unicode(),x.pattern);
#else
return boost::regex_match(v.to_string(),x.pattern);
#endif
return x.apply(v);
}
value_type operator() (regex_replace_node const& x) const
{
value_type v = util::apply_visitor(*this, x.expr);
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format);
#else
std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format);
mapnik::transcoder tr_("utf8");
return tr_.transcode(repl.c_str());
#endif
return x.apply(v);
}
value_type operator() (unary_function_call const& call) const

View file

@ -29,12 +29,6 @@
#include <mapnik/expression_node.hpp>
#include <mapnik/function_call.hpp>
#include <mapnik/util/variant.hpp>
// boost
#if defined(BOOST_REGEX_HAS_ICU)
#include <boost/regex/icu.hpp>
#else
#include <boost/regex.hpp>
#endif
namespace mapnik
{
@ -130,24 +124,13 @@ struct evaluate : util::static_visitor<T1>
value_type operator() (regex_match_node const& x) const
{
value_type v = util::apply_visitor(*this, x.expr);
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_match(v.to_unicode(),x.pattern);
#else
return boost::regex_match(v.to_string(),x.pattern);
#endif
return x.apply(v);
}
value_type operator() (regex_replace_node const& x) const
{
value_type v = util::apply_visitor(*this, x.expr);
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format);
#else
std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format);
mapnik::transcoder tr_("utf8");
return tr_.transcode(repl.c_str());
#endif
return x.apply(v);
}
value_type operator() (unary_function_call const& call) const

View file

@ -126,6 +126,17 @@ struct integer_parser
using type = qi::int_parser<T,10,1,-1>;
};
struct unary_function_types : qi::symbols<char, unary_function_impl>
{
unary_function_types();
};
struct binary_function_types : qi::symbols<char, binary_function_impl>
{
binary_function_types();
};
#ifdef __GNUC__
template <typename Iterator>
struct MAPNIK_DECL expression_grammar : qi::grammar<Iterator, expr_node(), space_type>

View file

@ -28,6 +28,7 @@
#include <mapnik/expression_grammar.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/function_call.hpp>
// boost
#include <boost/spirit/include/qi.hpp>
@ -43,24 +44,38 @@ namespace mapnik {
namespace mapnik
{
unary_function_types::unary_function_types()
{
add
("sin", sin_impl())
("cos", cos_impl())
("tan", tan_impl())
("atan", atan_impl())
("exp", exp_impl())
("abs", abs_impl())
("length",length_impl())
;
}
binary_function_types::binary_function_types()
{
add
("min", binary_function_impl(min_impl))
("max", binary_function_impl(max_impl))
("pow", binary_function_impl(pow_impl))
;
}
template <typename T0,typename T1>
expr_node regex_match_impl::operator() (T0 & node, T1 const& pattern) const
{
#if defined(BOOST_REGEX_HAS_ICU)
return regex_match_node(node,tr_.transcode(pattern.c_str()));
#else
return regex_match_node(node,pattern);
#endif
return regex_match_node(tr_,node,pattern);
}
template <typename T0,typename T1,typename T2>
expr_node regex_replace_impl::operator() (T0 & node, T1 const& pattern, T2 const& format) const
{
#if defined(BOOST_REGEX_HAS_ICU)
return regex_replace_node(node,tr_.transcode(pattern.c_str()),tr_.transcode(format.c_str()));
#else
return regex_replace_node(node,pattern,format);
#endif
return regex_replace_node(tr_,node,pattern,format);
}
template <typename Iterator>

View file

@ -26,16 +26,12 @@
// mapnik
#include <mapnik/value_types.hpp>
#include <mapnik/value.hpp>
#include <mapnik/config.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/function_call.hpp>
#include <mapnik/expression_node_types.hpp>
// boost
#if defined(BOOST_REGEX_HAS_ICU)
#include <boost/regex/icu.hpp>
#else
#include <boost/regex.hpp>
#endif
namespace mapnik
{
@ -86,46 +82,6 @@ struct binary_node
expr_node left,right;
};
#if defined(BOOST_REGEX_HAS_ICU)
struct regex_match_node
{
regex_match_node (expr_node const& a, mapnik::value_unicode_string const& ustr);
expr_node expr;
boost::u32regex pattern;
};
struct regex_replace_node
{
regex_replace_node (expr_node const& a, mapnik::value_unicode_string const& ustr, mapnik::value_unicode_string const& f);
expr_node expr;
boost::u32regex pattern;
mapnik::value_unicode_string format;
};
#else
struct regex_match_node
{
regex_match_node (expr_node const& a, std::string const& str);
expr_node expr;
boost::regex pattern;
};
struct regex_replace_node
{
regex_replace_node (expr_node const& a, std::string const& str, std::string const& f);
expr_node expr;
boost::regex pattern;
std::string format;
};
#endif
using unary_function_impl = std::function<value_type(value_type const&)>;
using binary_function_impl = std::function<value_type(value_type const&, value_type const&)>;
struct unary_function_call
{
using argument_type = expr_node;
@ -148,6 +104,29 @@ struct binary_function_call
argument_type arg2;
};
// pimpl
struct _regex_match_impl;
struct _regex_replace_impl;
struct MAPNIK_DECL regex_match_node
{
regex_match_node(transcoder const& tr, expr_node const& a, std::string const& ustr);
mapnik::value apply(mapnik::value const& v) const;
std::string to_string() const;
expr_node expr;
// TODO - use unique_ptr once https://github.com/mapnik/mapnik/issues/2457 is fixed
std::shared_ptr<_regex_match_impl> impl_;
};
struct MAPNIK_DECL regex_replace_node
{
regex_replace_node(transcoder const& tr, expr_node const& a, std::string const& ustr, std::string const& f);
mapnik::value apply(mapnik::value const& v) const;
std::string to_string() const;
expr_node expr;
// TODO - use unique_ptr once https://github.com/mapnik/mapnik/issues/2457 is fixed
std::shared_ptr<_regex_replace_impl> impl_;
};
inline expr_node & operator- (expr_node& expr)
{

View file

@ -29,6 +29,7 @@
#include <mapnik/value.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/feature_kv_iterator.hpp>
#include <mapnik/noncopyable.hpp>

View file

@ -24,28 +24,104 @@
#define MAPNIK_FUNCTION_CALL_HPP
#include <mapnik/value.hpp>
#include <mapnik/expression_node.hpp>
#include <functional>
#include <boost/spirit/include/qi_symbols.hpp>
#include <algorithm>
#include <cmath>
namespace mapnik {
using value_type = mapnik::value;
namespace qi = boost::spirit::qi;
struct unary_function_types : qi::symbols<char, unary_function_impl>
{
unary_function_types();
};
struct binary_function_types : qi::symbols<char, binary_function_impl>
{
binary_function_types();
};
using unary_function_impl = std::function<value_type(value_type const&)>;
using binary_function_impl = std::function<value_type(value_type const&, value_type const&)>;
char const* unary_function_name(unary_function_impl const& fun);
char const* binary_function_name(binary_function_impl const& fun);
// functions
// exp
struct exp_impl
{
//using type = T;
value_type operator() (value_type const& val) const
{
return std::exp(val.to_double());
}
};
// sin
struct sin_impl
{
value_type operator() (value_type const& val) const
{
return std::sin(val.to_double());
}
};
// cos
struct cos_impl
{
value_type operator() (value_type const& val) const
{
return std::cos(val.to_double());
}
};
// tan
struct tan_impl
{
value_type operator() (value_type const& val) const
{
return std::tan(val.to_double());
}
};
// atan
struct atan_impl
{
value_type operator()(value_type const& val) const
{
return std::atan(val.to_double());
}
};
// abs
struct abs_impl
{
value_type operator() (value_type const& val) const
{
return std::fabs(val.to_double());
}
};
// length
struct length_impl
{
value_type operator() (value_type const& val) const
{
return val.to_unicode().length();
}
};
// min
inline value_type min_impl(value_type const& arg1, value_type const& arg2)
{
return std::min(arg1.to_double(), arg2.to_double());
}
// max
inline value_type max_impl(value_type const& arg1, value_type const& arg2)
{
return std::max(arg1.to_double(), arg2.to_double());
}
// pow
inline value_type pow_impl(value_type const& arg1, value_type const& arg2)
{
return std::pow(arg1.to_double(), arg2.to_double());
}
} // namespace mapnik
#endif //MAPNIK_FUNCTION_CALL_HPP
#endif // MAPNIK_FUNCTION_CALL_HPP

View file

@ -32,6 +32,7 @@
// stl
#include <cmath>
#include <vector>
#include <algorithm>
namespace mapnik
{

View file

@ -28,10 +28,6 @@
#include <mapnik/box2d.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <memory>
#include <boost/ptr_container/ptr_vector.hpp>
namespace mapnik {
template <typename T, template <typename> class Container=vertex_vector>
@ -154,8 +150,6 @@ public:
};
using geometry_type = geometry<double,vertex_vector>;
using geometry_ptr = std::shared_ptr<geometry_type>;
using geometry_container = boost::ptr_vector<geometry_type>;
}

View file

@ -0,0 +1,35 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_GEOMETRY_CONTAINER_HPP
#define MAPNIK_GEOMETRY_CONTAINER_HPP
// boost
#include <boost/ptr_container/ptr_vector.hpp>
namespace mapnik {
using geometry_container = boost::ptr_vector<geometry_type>;
}
#endif // MAPNIK_GEOMETRY_CONTAINER_HPP

View file

@ -27,6 +27,7 @@
#include <mapnik/value_types.hpp>
#include <mapnik/value.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/json/geometry_generator_grammar.hpp>
#include <mapnik/feature_kv_iterator.hpp>

View file

@ -27,6 +27,7 @@
#include <mapnik/json/geometry_grammar.hpp>
#include <mapnik/value.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/value.hpp>
#include <mapnik/json/generic_json.hpp>

View file

@ -25,6 +25,7 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/json/geometry_grammar.hpp>
// boost
@ -33,7 +34,7 @@
namespace mapnik { namespace json {
inline bool from_geojson(std::string const& json, boost::ptr_vector<geometry_type> & paths)
inline bool from_geojson(std::string const& json, geometry_container & paths)
{
using namespace boost::spirit;
static const geometry_grammar<std::string::const_iterator> g;

View file

@ -60,11 +60,14 @@
// stl
#include <memory>
#include <type_traits> // remove_reference
#include <cmath>
namespace mapnik {
struct clip_poly_tag;
using svg_attribute_type = agg::pod_bvector<svg::path_attributes>;
template <typename SvgRenderer, typename Detector, typename RendererContext>
struct vector_markers_rasterizer_dispatch : mapnik::noncopyable
{
@ -80,7 +83,7 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable
attribute_source_type const& attrs,
box2d<double> const& bbox,
agg::trans_affine const& marker_trans,
markers_symbolizer const& sym,
symbolizer_base const& sym,
Detector & detector,
double scale_factor,
feature_impl & feature,
@ -145,7 +148,7 @@ private:
RasterizerType & ras_;
box2d<double> const& bbox_;
agg::trans_affine const& marker_trans_;
markers_symbolizer const& sym_;
symbolizer_base const& sym_;
Detector & detector_;
feature_impl & feature_;
attributes const& vars_;
@ -168,7 +171,7 @@ struct raster_markers_rasterizer_dispatch : mapnik::noncopyable
raster_markers_rasterizer_dispatch(image_data_32 const& src,
agg::trans_affine const& marker_trans,
markers_symbolizer const& sym,
symbolizer_base const& sym,
Detector & detector,
double scale_factor,
feature_impl & feature,
@ -299,7 +302,7 @@ private:
RasterizerType & ras_;
image_data_32 const& src_;
agg::trans_affine const& marker_trans_;
markers_symbolizer const& sym_;
symbolizer_base const& sym_;
Detector & detector_;
feature_impl & feature_;
attributes const& vars_;
@ -308,132 +311,24 @@ private:
};
template <typename T>
void build_ellipse(T const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path)
{
double width = 0.0;
double height = 0.0;
if (has_key<double>(sym,keys::width) && has_key<double>(sym,keys::height))
{
width = get<double>(sym, keys::width, feature, vars, 0.0);
height = get<double>(sym, keys::height, feature, vars, 0.0);
}
else if (has_key<double>(sym,keys::width))
{
width = height = get<double>(sym, keys::width, feature, vars, 0.0);
}
else if (has_key<double>(sym,keys::height))
{
width = height = get<double>(sym, keys::height, feature, vars, 0.0);
}
svg::svg_converter_type styled_svg(svg_path, marker_ellipse.attributes());
styled_svg.push_attr();
styled_svg.begin_path();
agg::ellipse c(0, 0, width/2.0, height/2.0);
styled_svg.storage().concat_path(c);
styled_svg.end_path();
styled_svg.pop_attr();
double lox,loy,hix,hiy;
styled_svg.bounding_rect(&lox, &loy, &hix, &hiy);
styled_svg.set_dimensions(width,height);
marker_ellipse.set_dimensions(width,height);
marker_ellipse.set_bounding_box(lox,loy,hix,hiy);
}
void build_ellipse(symbolizer_base const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path);
template <typename Attr>
bool push_explicit_style(Attr const& src, Attr & dst,
markers_symbolizer const& sym,
bool push_explicit_style(svg_attribute_type const& src,
svg_attribute_type & dst,
symbolizer_base const& sym,
feature_impl & feature,
attributes const& vars)
{
auto fill_color = get_optional<color>(sym, keys::fill, feature, vars);
auto fill_opacity = get_optional<double>(sym, keys::fill_opacity, feature, vars);
auto stroke_color = get_optional<color>(sym, keys::stroke, feature, vars);
auto stroke_width = get_optional<double>(sym, keys::stroke_width, feature, vars);
auto stroke_opacity = get_optional<double>(sym, keys::stroke_opacity, feature, vars);
if (fill_color ||
fill_opacity ||
stroke_color ||
stroke_width ||
stroke_opacity)
{
bool success = false;
for(unsigned i = 0; i < src.size(); ++i)
{
success = true;
dst.push_back(src[i]);
mapnik::svg::path_attributes & attr = dst.last();
if (attr.stroke_flag)
{
if (stroke_width)
{
attr.stroke_width = *stroke_width;
}
if (stroke_color)
{
color const& s_color = *stroke_color;
attr.stroke_color = agg::rgba(s_color.red()/255.0,
s_color.green()/255.0,
s_color.blue()/255.0,
s_color.alpha()/255.0);
}
if (stroke_opacity)
{
attr.stroke_opacity = *stroke_opacity;
}
}
if (attr.fill_flag)
{
if (fill_color)
{
color const& f_color = *fill_color;
attr.fill_color = agg::rgba(f_color.red()/255.0,
f_color.green()/255.0,
f_color.blue()/255.0,
f_color.alpha()/255.0);
}
if (fill_opacity)
{
attr.fill_opacity = *fill_opacity;
}
}
}
return success;
}
return false;
}
attributes const& vars);
template <typename T>
void setup_transform_scaling(agg::trans_affine & tr,
double svg_width,
double svg_height,
mapnik::feature_impl & feature,
attributes const& vars,
T const& sym)
{
double width = get<double>(sym, keys::width, feature, vars, 0.0);
double height = get<double>(sym, keys::height, feature, vars, 0.0);
if (width > 0 && height > 0)
{
double sx = width/svg_width;
double sy = height/svg_height;
tr *= agg::trans_affine_scaling(sx,sy);
}
else if (width > 0)
{
double sx = width/svg_width;
tr *= agg::trans_affine_scaling(sx);
}
else if (height > 0)
{
double sy = height/svg_height;
tr *= agg::trans_affine_scaling(sy);
}
}
symbolizer_base const& sym);
// Apply markers to a feature with multiple geometries
template <typename Converter>
void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, markers_symbolizer const& sym)
void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, symbolizer_base const& sym)
{
std::size_t geom_count = feature.paths().size();
if (geom_count == 1)

View file

@ -31,7 +31,9 @@
#include <mapnik/symbolizer_enumerations.hpp>
#include <mapnik/util/variant.hpp>
#include <boost/functional/value_factory.hpp>
#include <boost/function.hpp>
// stl
#include <map>
namespace mapnik
{
@ -86,7 +88,7 @@ private:
Detector &detector,
markers_placement_params const& params)
{
static const std::map<marker_placement_e, boost::function<markers_placement(
static const std::map<marker_placement_e, std::function<markers_placement(
Locator &locator,
Detector &detector,
markers_placement_params const& params)>> factories =

View file

@ -26,22 +26,18 @@
#ifdef MAPNIK_LOG
#include <mapnik/debug.hpp>
#endif
#include <mapnik/global.hpp>
#include <mapnik/config.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/vertex.hpp>
#include <mapnik/proj_transform.hpp>
// boost
#include <boost/math/constants/constants.hpp>
// stl
#include <cmath>
#include <vector>
#include <cstddef>
namespace mapnik
{
const double pi = boost::math::constants::pi<double>();
template <typename Geometry>
struct MAPNIK_DECL offset_converter
{
@ -176,13 +172,13 @@ private:
static double explement_reflex_angle(double angle)
{
if (angle > pi)
if (angle > M_PI)
{
return angle - 2 * pi;
return angle - 2 * M_PI;
}
else if (angle < -pi)
else if (angle < -M_PI)
{
return angle + 2 * pi;
return angle + 2 * M_PI;
}
else
{
@ -320,22 +316,22 @@ private:
{
if (joint_angle > 0.0)
{
joint_angle = joint_angle - 2 * pi;
joint_angle = joint_angle - 2 * M_PI;
}
else
{
bulge_steps = 1 + static_cast<int>(std::floor(half_turns / pi));
bulge_steps = 1 + static_cast<int>(std::floor(half_turns / M_PI));
}
}
else
{
if (joint_angle < 0.0)
{
joint_angle = joint_angle + 2 * pi;
joint_angle = joint_angle + 2 * M_PI;
}
else
{
bulge_steps = 1 + static_cast<int>(std::floor(half_turns / pi));
bulge_steps = 1 + static_cast<int>(std::floor(half_turns / M_PI));
}
}
@ -344,14 +340,14 @@ private:
{
// inside turn (sharp/obtuse angle)
MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:"
<< " Sharp joint [<< inside turn " << int(joint_angle*180/pi)
<< " Sharp joint [<< inside turn " << int(joint_angle*180/M_PI)
<< " degrees >>]";
}
else
{
// outside turn (reflex angle)
MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:"
<< " Bulge joint >)) outside turn " << int(joint_angle*180/pi)
<< " Bulge joint >)) outside turn " << int(joint_angle*180/M_PI)
<< " degrees ((< with " << bulge_steps << " segments";
}
#endif

View file

@ -26,14 +26,10 @@
#include <mapnik/renderer_common.hpp>
#include <mapnik/svg/svg_storage.hpp>
#include <mapnik/svg/svg_path_adapter.hpp>
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/vertex_converters.hpp>
#include <mapnik/marker_cache.hpp>
#include <mapnik/marker_helpers.hpp>
// boost
#include <boost/mpl/vector.hpp>
namespace mapnik {
template <typename T0, typename T1, typename T2>
@ -49,14 +45,6 @@ void render_markers_symbolizer(markers_symbolizer const& sym,
using raster_dispatch_type = T1;
using renderer_context_type = T2;
using svg_attribute_type = agg::pod_bvector<path_attributes>;
using conv_types = boost::mpl::vector<clip_line_tag,
clip_poly_tag,
transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag>;
std::string filename = get<std::string>(sym, keys::file, feature, common.vars_, "shape://ellipse");
bool clip = get<value_bool>(sym, keys::clip, feature, common.vars_, false);
double offset = get<value_double>(sym, keys::offset, feature, common.vars_, 0.0);
@ -105,9 +93,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym,
snap_to_pixels,
renderer_context);
vertex_converter<box2d<double>, vector_dispatch_type, markers_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_);
using vertex_converter_type = vertex_converter<vector_dispatch_type,clip_line_tag,
clip_poly_tag,
transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag>;
vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_);
if (clip && feature.paths().size() > 0) // optional clip (default: true)
{
geometry_type::types type = feature.paths()[0].type();
@ -145,9 +137,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym,
snap_to_pixels,
renderer_context);
vertex_converter<box2d<double>, vector_dispatch_type, markers_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_);
using vertex_converter_type = vertex_converter<vector_dispatch_type,clip_line_tag,
clip_poly_tag,
transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag>;
vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_);
if (clip && feature.paths().size() > 0) // optional clip (default: true)
{
geometry_type::types type = feature.paths()[0].type();
@ -184,9 +180,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym,
common.vars_,
renderer_context);
vertex_converter<box2d<double>, raster_dispatch_type, markers_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_);
using vertex_converter_type = vertex_converter<raster_dispatch_type,clip_line_tag,
clip_poly_tag,
transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag>;
vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_);
if (clip && feature.paths().size() > 0) // optional clip (default: true)
{

View file

@ -23,7 +23,11 @@
#ifndef MAPNIK_RENDERER_COMMON_PROCESS_POLYGON_SYMBOLIZER_HPP
#define MAPNIK_RENDERER_COMMON_PROCESS_POLYGON_SYMBOLIZER_HPP
#include <mapnik/renderer_common.hpp>
#include <mapnik/vertex_converters.hpp>
#include <mapnik/symbolizer.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/feature.hpp>
namespace mapnik {

View file

@ -31,7 +31,6 @@
#include <mapnik/simplify.hpp>
#include <mapnik/enumeration.hpp>
#include <mapnik/expression.hpp>
#include <mapnik/expression_node.hpp>
#include <mapnik/expression_evaluator.hpp>
#include <mapnik/path_expression.hpp>
#include <mapnik/parse_path.hpp>
@ -52,6 +51,11 @@
#include <vector>
#include <string>
#include <functional>
#include <map>
#include <tuple>
// boost
#include <boost/optional.hpp>
namespace agg { struct trans_affine; }
@ -410,7 +414,7 @@ struct evaluate_expression_wrapper<mapnik::dash_array>
dash_array dash;
std::vector<double> buf;
std::string str = val.to_string();
if (util::parse_dasharray(str.begin(),str.end(),buf))
if (util::parse_dasharray(str,buf))
{
util::add_dashes(buf,dash);
}

View file

@ -37,6 +37,7 @@
#include <mapnik/config_error.hpp>
#include <mapnik/evaluate_global_attributes.hpp>
#include <mapnik/parse_transform.hpp>
#include <mapnik/util/dasharray_parser.hpp>
#include <mapnik/util/variant.hpp>
namespace mapnik {
@ -395,7 +396,7 @@ struct set_symbolizer_property_impl<Symbolizer,dash_array,false>
{
std::vector<double> buf;
dash_array dash;
if (util::parse_dasharray((*str).begin(),(*str).end(),buf) && util::add_dashes(buf,dash))
if (util::parse_dasharray(*str,buf) && util::add_dashes(buf,dash))
{
put(sym,key,dash);
}

View file

@ -56,10 +56,7 @@ struct placement_finder_adapter
};
using conv_types = boost::mpl::vector<clip_line_tag , transform_tag, affine_transform_tag, simplify_tag, smooth_tag>;
using vertex_converter_type = vertex_converter<box2d<double>, placement_finder_adapter<placement_finder> , symbolizer_base,
view_transform, proj_transform, agg::trans_affine,
conv_types, feature_impl>;
using vertex_converter_type = vertex_converter<placement_finder_adapter<placement_finder>,clip_line_tag , transform_tag, affine_transform_tag, simplify_tag, smooth_tag>;
class base_symbolizer_helper
{

View file

@ -1,203 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2013 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_TEXT_PATH_HPP
#define MAPNIK_TEXT_PATH_HPP
// mapnik
#include <mapnik/text/char_info.hpp>
#include <mapnik/pixel_position.hpp>
#include <mapnik/noncopyable.hpp>
#include <mapnik/value_types.hpp>
//stl
#include <vector>
// boost
#include <memory>
#include <boost/ptr_container/ptr_vector.hpp>
namespace mapnik
{
class string_info : private mapnik::noncopyable
{
protected:
using characters_t = std::vector<char_info>;
characters_t characters_;
mapnik::value_unicode_string text_;
bool is_rtl;
public:
string_info(mapnik::value_unicode_string const& text)
: characters_(),
text_(text),
is_rtl(false)
{
}
string_info()
: characters_(),
text_(),
is_rtl(false)
{
}
void add_info(char_info const& info)
{
characters_.push_back(info);
}
void add_text(mapnik::value_unicode_string const& text)
{
text_ += text;
}
std::size_t num_characters() const
{
return characters_.size();
}
void set_rtl(bool value)
{
is_rtl = value;
}
bool get_rtl() const
{
return is_rtl;
}
char_info const& at(std::size_t i) const
{
return characters_[i];
}
char_info const& operator[](std::size_t i) const
{
return at(i);
}
mapnik::value_unicode_string const& get_string() const
{
return text_;
}
bool has_line_breaks() const
{
// uint16_t
UChar break_char = '\n';
return (text_.indexOf(break_char) >= 0);
}
// Resets object to initial state.
void clear()
{
text_.remove();
characters_.clear();
}
};
using char_info_ptr = char_info const *;
// List of all characters and their positions and formats for a placement.
class text_path : mapnik::noncopyable
{
struct character_node
{
char_info_ptr c;
pixel_position pos;
double angle;
character_node(char_info_ptr c_, double x_, double y_, double angle_)
: c(c_),
pos(x_, y_),
angle(angle_)
{
}
~character_node() {}
void vertex(char_info_ptr & c_, double & x_, double & y_, double & angle_) const
{
c_ = c;
x_ = pos.x;
y_ = pos.y;
angle_ = angle;
}
};
mutable int itr_;
public:
using character_nodes_t = std::vector<character_node>;
pixel_position center;
character_nodes_t nodes_;
text_path(double x, double y)
: itr_(0),
center(x,y),
nodes_()
{
}
~text_path() {}
/** Adds a new char to the list. */
void add_node(char_info_ptr c, double x, double y, double angle)
{
nodes_.push_back(character_node(c, x, y, angle));
}
/** Return node. Always returns a new node. Has no way to report that there are no more nodes. */
void vertex(char_info_ptr & c, double & x, double & y, double & angle) const
{
nodes_[itr_++].vertex(c, x, y, angle);
}
/** Start again at first node. */
void rewind() const
{
itr_ = 0;
}
/** Number of nodes. */
std::size_t num_nodes() const
{
return nodes_.size();
}
/** Delete all nodes. */
void clear()
{
nodes_.clear();
}
};
using text_path_ptr = std::shared_ptr<text_path>;
using placements_type = boost::ptr_vector<text_path>;
}
#endif // MAPNIK_TEXT_PATH_HPP

View file

@ -24,6 +24,10 @@
#define MAPNIK_TRANSFORM_PATH_ADAPTER_HPP
#include <mapnik/proj_transform.hpp>
#include <mapnik/vertex.hpp>
#include <mapnik/config.hpp>
#include <cstddef>
namespace mapnik {

View file

@ -26,15 +26,14 @@
//mapnik
#include <mapnik/config.hpp>
#include <mapnik/noncopyable.hpp>
// icu
#include <mapnik/value_types.hpp>
#include <unicode/ucnv.h>
// stl
#include <cstdint>
#include <string>
struct UConverter;
namespace mapnik {
class MAPNIK_DECL transcoder : private mapnik::noncopyable
@ -49,13 +48,4 @@ private:
};
}
namespace U_ICU_NAMESPACE {
inline std::size_t hash_value(mapnik::value_unicode_string const& val)
{
return val.hashCode();
}
}
#endif // MAPNIK_UNICODE_HPP

View file

@ -25,11 +25,11 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/util/path_iterator.hpp>
// boost
#include <boost/spirit/include/support_container.hpp>
#include <boost/concept_check.hpp>
namespace boost { namespace spirit { namespace traits {
@ -60,9 +60,8 @@ template <>
struct end_container<mapnik::geometry_type const>
{
static mapnik::util::path_iterator<mapnik::geometry_type>
call (mapnik::geometry_type const& g)
call (mapnik::geometry_type const&)
{
boost::ignore_unused_variable_warning(g);
return mapnik::util::path_iterator<mapnik::geometry_type>();
}
};

View file

@ -23,42 +23,12 @@
#ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP
#define MAPNIK_UTIL_DASHARRAY_PARSER_HPP
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <vector>
#include <string>
namespace mapnik { namespace util {
template <typename Iterator>
bool parse_dasharray(Iterator first, Iterator last, std::vector<double>& dasharray)
{
using namespace boost::spirit;
qi::double_type double_;
qi::_1_type _1;
qi::lit_type lit;
qi::char_type char_;
qi::ascii::space_type space;
qi::no_skip_type no_skip;
// SVG
// dasharray ::= (length | percentage) (comma-wsp dasharray)?
// no support for 'percentage' as viewport is unknown at load_map
//
bool r = qi::phrase_parse(first, last,
(double_[boost::phoenix::push_back(boost::phoenix::ref(dasharray), _1)] %
no_skip[char_(", ")]
| lit("none")),
space);
if (first != last)
{
return false;
}
return r;
}
bool parse_dasharray(std::string const& value, std::vector<double>& dasharray);
inline bool add_dashes(std::vector<double> & buf, std::vector<std::pair<double,double> > & dash)
{

View file

@ -26,6 +26,7 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/svg/geometry_svg_generator.hpp>
// boost

View file

@ -27,6 +27,7 @@
#include <mapnik/config.hpp>
#include <mapnik/make_unique.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/vertex.hpp>
// stl
@ -187,7 +188,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
using point_type = std::pair<double,double>;
using linear_ring = std::vector<point_type>;
boost::ptr_vector<linear_ring> rings;
std::vector<linear_ring> rings;
double x = 0;
double y = 0;
@ -197,8 +198,10 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order)
unsigned command = g.vertex(i,&x,&y);
if (command == SEG_MOVETO)
{
rings.push_back(new linear_ring); // start new loop
rings.back().emplace_back(x,y);
linear_ring ring;
ring.reserve(1);
ring.emplace_back(x,y);
rings.push_back(std::move(ring)); // start new loop
size += 4; // num_points
size += 2 * 8; // point
}

View file

@ -25,6 +25,7 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/wkt/wkt_generator_grammar.hpp>
namespace mapnik { namespace util {

View file

@ -26,12 +26,9 @@
// mapnik
#include <mapnik/value_types.hpp>
#include <mapnik/value_hash.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/util/conversions.hpp>
#include <mapnik/util/variant.hpp>
// boost
#include <boost/functional/hash.hpp>
// stl
#include <string>
#include <cmath>

View file

@ -26,10 +26,13 @@
// mapnik
#include <mapnik/util/variant.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/unicode.hpp>
// stl
#include <functional>
// icu
#include <unicode/unistr.h>
namespace mapnik { namespace detail {
template <class T>
@ -48,7 +51,7 @@ struct value_hasher: public util::static_visitor<std::size_t>
std::size_t operator() (value_unicode_string const& val) const
{
return hash_value(val);
return val.hashCode();
}
template <class T>

View file

@ -38,24 +38,6 @@
#include <mapnik/symbolizer_keys.hpp>
#include <mapnik/symbolizer.hpp>
// boost
#include <boost/type_traits/is_same.hpp>
// mpl
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/int.hpp>
// fusion
#include <boost/fusion/include/at_c.hpp>
#include <boost/fusion/container/vector.hpp>
// agg
#include "agg_math_stroke.h"
#include "agg_trans_affine.h"
@ -68,6 +50,7 @@
#include "agg_conv_transform.h"
// stl
#include <type_traits>
#include <stdexcept>
#include <array>
@ -91,11 +74,6 @@ struct converter_traits
{
using geometry_type = T0;
using conv_type = geometry_type;
template <typename Args>
static void setup(geometry_type & , Args const& )
{
throw std::runtime_error("invalid call to setup");
}
};
template <typename T>
@ -107,10 +85,7 @@ struct converter_traits<T,mapnik::smooth_tag>
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
auto const& feat = boost::fusion::at_c<6>(args);
auto const& vars = boost::fusion::at_c<7>(args);
geom.smooth_value(get<value_double>(sym, keys::smooth, feat, vars));
geom.smooth_value(get<value_double>(args.sym, keys::smooth, args.feature, args.vars));
}
};
@ -123,11 +98,8 @@ struct converter_traits<T,mapnik::simplify_tag>
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
auto const& feat = boost::fusion::at_c<6>(args);
auto const& vars = boost::fusion::at_c<7>(args);
geom.set_simplify_algorithm(static_cast<simplify_algorithm_e>(get<value_integer>(sym, keys::simplify_algorithm, feat, vars)));
geom.set_simplify_tolerance(get<value_double>(sym, keys::simplify_tolerance, feat, vars));
geom.set_simplify_algorithm(static_cast<simplify_algorithm_e>(get<value_integer>(args.sym, keys::simplify_algorithm, args.feature, args.vars)));
geom.set_simplify_tolerance(get<value_double>(args.sym, keys::simplify_tolerance,args.feature, args.vars));
}
};
@ -140,7 +112,7 @@ struct converter_traits<T, mapnik::clip_line_tag>
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<0> >::type box = boost::fusion::at_c<0>(args);
auto const& box = args.bbox;
geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy());
}
};
@ -154,10 +126,10 @@ struct converter_traits<T, mapnik::dash_tag>
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
auto const& feat = boost::fusion::at_c<6>(args);
auto const& vars = boost::fusion::at_c<7>(args);
double scale_factor = boost::fusion::at_c<8>(args);
auto const& sym = args.sym;
auto const& feat = args.feature;
auto const& vars = args.vars;
double scale_factor = args.scale_factor;
auto dash = get_optional<dash_array>(sym, keys::stroke_dasharray, feat, vars);
if (dash)
{
@ -213,13 +185,13 @@ struct converter_traits<T, mapnik::stroke_tag>
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
auto const& feat = boost::fusion::at_c<6>(args);
auto const& vars = boost::fusion::at_c<7>(args);
auto const& sym = args.sym;
auto const& feat = args.feature;
auto const& vars = args.vars;
set_join_caps(sym, geom, feat, vars);
double miterlimit = get<value_double>(sym, keys::stroke_miterlimit, feat, vars, 4.0);
geom.generator().miter_limit(miterlimit);
double scale_factor = boost::fusion::at_c<8>(args);
double scale_factor = args.scale_factor;
double width = get<value_double>(sym, keys::stroke_width, feat, vars, 1.0);
geom.generator().width(width * scale_factor);
}
@ -233,9 +205,8 @@ struct converter_traits<T,mapnik::clip_poly_tag>
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<0> >::type box = boost::fusion::at_c<0>(args);
auto const& box = args.bbox;
geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy());
//geom.set_clip_box(box);
}
};
@ -245,10 +216,7 @@ struct converter_traits<T,mapnik::close_poly_tag>
using geometry_type = T;
using conv_type = typename agg::conv_close_polygon<geometry_type>;
template <typename Args>
static void setup(geometry_type & , Args const&)
{
// no-op
}
static void setup(geometry_type & , Args const&) {}
};
template <typename T>
@ -260,8 +228,8 @@ struct converter_traits<T,mapnik::transform_tag>
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
geom.set_proj_trans(boost::fusion::at_c<4>(args));
geom.set_trans(boost::fusion::at_c<3>(args));
geom.set_proj_trans(args.prj_trans);
geom.set_trans(args.tr);
}
};
@ -279,7 +247,7 @@ struct converter_traits<T,mapnik::affine_transform_tag>
template <typename Args>
static void setup(geometry_type & geom, Args & args)
{
geom.transformer(boost::fusion::at_c<5>(args));
geom.transformer(args.affine_trans);
}
};
@ -292,118 +260,127 @@ struct converter_traits<T,mapnik::offset_transform_tag>
template <typename Args>
static void setup(geometry_type & geom, Args const& args)
{
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
auto const& feat = boost::fusion::at_c<6>(args);
auto const& vars = boost::fusion::at_c<7>(args);
auto const& sym = args.sym;
auto const& feat = args.feature;
auto const& vars = args.vars;
double offset = get<value_double>(sym, keys::offset, feat, vars);
double scale_factor = boost::fusion::at_c<8>(args);
geom.set_offset(offset * scale_factor);
geom.set_offset(offset * args.scale_factor);
}
};
template <bool>
struct converter_fwd
template <typename Dispatcher, typename... ConverterTypes>
struct converters_helper;
template <typename Dispatcher, typename Current, typename... ConverterTypes>
struct converters_helper<Dispatcher,Current,ConverterTypes...>
{
template <typename Base, typename T0,typename T1,typename T2, typename Iter,typename End>
static void forward(Base& base, T0 & geom,T1 const& args)
template <typename Converter>
static void set(Dispatcher & disp, int state)
{
using geometry_type = T0;
using conv_tag = T2;
using conv_type = typename detail::converter_traits<geometry_type,conv_tag>::conv_type;
conv_type conv(geom);
detail::converter_traits<conv_type,conv_tag>::setup(conv,args);
base.template dispatch<Iter,End>(conv, typename boost::is_same<Iter,End>::type());
}
};
template <>
struct converter_fwd<true>
{
template <typename Base, typename T0,typename T1,typename T2, typename Iter,typename End>
static void forward(Base& base, T0 & geom,T1 const& args)
{
base.template dispatch<Iter,End>(geom, typename boost::is_same<Iter,End>::type());
}
};
template <typename A, typename C>
struct dispatcher
{
using this_type = dispatcher;
using args_type = A;
using conv_types = C;
dispatcher(args_type const& args)
: args_(args)
{
//std::memset(&vec_[0], 0, sizeof(unsigned)*vec_.size());
std::fill(vec_.begin(), vec_.end(), 0);
}
template <typename Iter, typename End, typename Geometry>
void dispatch(Geometry & geom, boost::mpl::true_)
{
boost::fusion::at_c<1>(args_).add_path(geom);
}
template <typename Iter, typename End, typename Geometry>
void dispatch(Geometry & geom, boost::mpl::false_)
{
using conv_tag = typename boost::mpl::deref<Iter>::type;
using conv_type = typename detail::converter_traits<Geometry,conv_tag>::conv_type;
using Next = typename boost::mpl::next<Iter>::type;
std::size_t index = boost::mpl::distance<Iter,End>::value - 1;
if (vec_[index] == 1)
if (std::is_same<Converter,Current>::value)
{
converter_fwd<boost::is_same<Geometry,conv_type>::value>::
template forward<this_type,Geometry,args_type,conv_tag,Next,End>(*this,geom,args_);
constexpr std::size_t index = sizeof...(ConverterTypes) ;
disp.vec_[index] = state;
}
else
{
converter_fwd<boost::mpl::true_::value>::
template forward<this_type,Geometry,args_type,conv_tag,Next,End>(*this,geom,args_);
converters_helper<Dispatcher,ConverterTypes...>:: template set<Converter>(disp, state);
}
}
template <typename Geometry>
void apply(Geometry & geom)
static void forward(Dispatcher & disp, Geometry & geom)
{
using begin = typename boost::mpl::begin<conv_types>::type;
using end = typename boost::mpl::end <conv_types>::type;
dispatch<begin,end,Geometry>(geom, boost::false_type());
constexpr std::size_t index = sizeof...(ConverterTypes);
if (disp.vec_[index] == 1)
{
using conv_type = typename detail::converter_traits<Geometry,Current>::conv_type;
conv_type conv(geom);
detail::converter_traits<conv_type,Current>::setup(conv,disp.args_);
converters_helper<Dispatcher, ConverterTypes...>::forward(disp, conv);
}
else
{
converters_helper<Dispatcher,ConverterTypes...>::forward(disp, geom);
}
}
};
template <typename Dispatcher>
struct converters_helper<Dispatcher>
{
template <typename Converter>
static void set(Dispatcher & disp, int state) {}
template <typename Geometry>
static void forward(Dispatcher & disp, Geometry & geom)
{
disp.args_.proc.add_path(geom);
}
};
template <typename Args, typename... ConverterTypes>
struct dispatcher : mapnik::noncopyable
{
using this_type = dispatcher;
using args_type = Args;
dispatcher(typename Args::processor_type & proc, box2d<double> const& bbox, symbolizer_base const& sym, view_transform const& tr,
proj_transform const& prj_trans, agg::trans_affine const& affine_trans, feature_impl const& feature,
attributes const& vars, double scale_factor)
: args_(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor)
{
std::fill(vec_.begin(), vec_.end(), 0);
}
std::array<unsigned, boost::mpl::size<conv_types>::value> vec_;
std::array<unsigned, sizeof...(ConverterTypes)> vec_;
args_type args_;
};
template <typename Processor>
struct arguments : mapnik::noncopyable
{
using processor_type = Processor;
arguments(Processor & proc, box2d<double> const& bbox, symbolizer_base const& sym, view_transform const& tr,
proj_transform const& prj_trans, agg::trans_affine const& affine_trans, feature_impl const& feature,
attributes const& vars, double scale_factor)
: proc(proc),
bbox(bbox),
sym(sym),
tr(tr),
prj_trans(prj_trans),
affine_trans(affine_trans),
feature(feature),
vars(vars),
scale_factor(scale_factor) {}
Processor & proc;
box2d<double> const& bbox;
symbolizer_base const& sym;
view_transform const& tr;
proj_transform const& prj_trans;
agg::trans_affine const& affine_trans;
feature_impl const& feature;
attributes const& vars;
double scale_factor;
};
}
template <typename B, typename R, typename S, typename T, typename P, typename A, typename C, typename F >
template <typename Processor, typename... ConverterTypes >
struct vertex_converter : private mapnik::noncopyable
{
using conv_types = C;
using bbox_type = B;
using rasterizer_type = R;
using symbolizer_type = S;
using trans_type = T;
using proj_trans_type = P;
using affine_trans_type = A;
using feature_type = F;
using args_type = typename boost::fusion::vector<
bbox_type const&,
rasterizer_type&,
symbolizer_type const&,
trans_type const&,
proj_trans_type const&,
affine_trans_type const&,
feature_type const&,
attributes const&,
double //scale-factor
>;
using bbox_type = box2d<double>;
using processor_type = Processor;
using symbolizer_type = symbolizer_base;
using trans_type = view_transform;
using proj_trans_type = proj_transform;
using affine_trans_type = agg::trans_affine;
using feature_type = feature_impl;
using args_type = detail::arguments<Processor>;
using dispatcher_type = detail::dispatcher<args_type,ConverterTypes...>;
vertex_converter(bbox_type const& b,
rasterizer_type & ras,
vertex_converter(bbox_type const& bbox,
processor_type & proc,
symbolizer_type const& sym,
trans_type const& tr,
proj_trans_type const& prj_trans,
@ -411,44 +388,27 @@ struct vertex_converter : private mapnik::noncopyable
feature_type const& feature,
attributes const& vars,
double scale_factor)
: disp_(args_type(boost::cref(b),
boost::ref(ras),
boost::cref(sym),
boost::cref(tr),
boost::cref(prj_trans),
boost::cref(affine_trans),
boost::cref(feature),
boost::cref(vars),
scale_factor)) {}
: disp_(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor) {}
template <typename Geometry>
void apply(Geometry & geom)
{
using geometry_type = Geometry;
disp_.template apply<geometry_type>(geom);
detail::converters_helper<dispatcher_type, ConverterTypes...>:: template forward<Geometry>(disp_, geom);
}
template <typename Conv>
template <typename Converter>
void set()
{
using iter = typename boost::mpl::find<conv_types,Conv>::type;
using end = typename boost::mpl::end<conv_types>::type;
std::size_t index = boost::mpl::distance<iter,end>::value - 1;
if (index < disp_.vec_.size())
disp_.vec_[index]=1;
detail::converters_helper<dispatcher_type, ConverterTypes...>:: template set<Converter>(disp_, 1);
}
template <typename Conv>
template <typename Converter>
void unset()
{
using iter = typename boost::mpl::find<conv_types,Conv>::type;
using end = typename boost::mpl::end<conv_types>::type;
std::size_t index = boost::mpl::distance<iter,end>::value - 1;
if (index < disp_.vec_.size())
disp_.vec_[index]=0;
detail::converters_helper<dispatcher_type, ConverterTypes...>:: template set<Converter>(disp_, 0);
}
detail::dispatcher<args_type,conv_types> disp_;
dispatcher_type disp_;
};
}

View file

@ -24,15 +24,10 @@
#define MAPNIK_VIEW_TRANSFORM_HPP
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/vertex.hpp>
#include <mapnik/proj_transform.hpp>
// stl
#include <cstddef>
namespace mapnik
{

View file

@ -25,6 +25,7 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/noncopyable.hpp>
namespace mapnik

View file

@ -25,6 +25,7 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/wkt/wkt_grammar.hpp>
// stl

View file

@ -29,6 +29,7 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_container.hpp>
#include <mapnik/vertex.hpp>
namespace mapnik { namespace wkt {

View file

@ -41,7 +41,6 @@
#include <mapnik/util/conversions.hpp>
#include <mapnik/util/trim.hpp>
#include <mapnik/global.hpp> // for int2net
#include <boost/scoped_array.hpp>
// stl
#include <sstream>
@ -245,12 +244,12 @@ pgraster_featureset::~pgraster_featureset()
std::string numeric2string(const char* buf)
{
boost::int16_t ndigits = int2net(buf);
boost::int16_t weight = int2net(buf+2);
boost::int16_t sign = int2net(buf+4);
boost::int16_t dscale = int2net(buf+6);
std::int16_t ndigits = int2net(buf);
std::int16_t weight = int2net(buf+2);
std::int16_t sign = int2net(buf+4);
std::int16_t dscale = int2net(buf+6);
boost::scoped_array<boost::int16_t> digits(new boost::int16_t[ndigits]);
std::unique_ptr<std::int16_t[]> digits(new std::int16_t[ndigits]);
for (int n=0; n < ndigits ;++n)
{
digits[n] = int2net(buf+8+n*2);
@ -260,7 +259,7 @@ std::string numeric2string(const char* buf)
if (sign == 0x4000) ss << "-";
int i = std::max(weight,boost::int16_t(0));
int i = std::max(weight,std::int16_t(0));
int d = 0;
// Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field.

View file

@ -122,12 +122,10 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
clip_box.pad(padding);
}
using conv_types = boost::mpl::vector<clip_line_tag, transform_tag,
affine_transform_tag,
simplify_tag,smooth_tag,
offset_transform_tag>;
vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<rasterizer_type, clip_line_tag, transform_tag,
affine_transform_tag,
simplify_tag,smooth_tag,
offset_transform_tag>
converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (clip) converter.set<clip_line_tag>(); //optional clip (default: true)

View file

@ -116,11 +116,6 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
using blender_type = agg::comp_op_adaptor_rgba_pre<color_type, order_type>; // comp blender
using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
using renderer_base = agg::renderer_base<pixfmt_comp_type>;
using conv_types = boost::mpl::vector<clip_line_tag, transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag,
dash_tag, stroke_tag>;
pixfmt_comp_type pixf(buf);
pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over)));
@ -170,8 +165,11 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
rasterizer_type ras(ren);
set_join_caps_aa(sym, ras, feature, common_.vars_);
vertex_converter<box2d<double>, rasterizer_type, line_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<rasterizer_type,clip_line_tag, transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag,
dash_tag, stroke_tag>
converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)
converter.set<transform_tag>(); // always transform
@ -190,8 +188,11 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
}
else
{
vertex_converter<box2d<double>, rasterizer, line_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<rasterizer,clip_line_tag, transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag,
dash_tag, stroke_tag>
converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)

View file

@ -158,9 +158,7 @@ void agg_renderer<T0,T1>::process(polygon_pattern_symbolizer const& sym,
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
using conv_types = boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
vertex_converter<box2d<double>, rasterizer, polygon_pattern_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<rasterizer, clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>
converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (prj_trans.equal() && clip) converter.set<clip_poly_tag>(); //optional clip (default: true)

View file

@ -49,10 +49,7 @@ void agg_renderer<T0,T1>::process(polygon_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
using conv_types = boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
using vertex_converter_type = vertex_converter<box2d<double>, rasterizer, polygon_symbolizer,
view_transform, proj_transform, agg::trans_affine,
conv_types, feature_impl>;
using vertex_converter_type = vertex_converter<rasterizer,clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
ras_ptr->reset();
double gamma = get<value_double>(sym, keys::gamma, feature, common_.vars_, 1.0);

View file

@ -26,6 +26,8 @@
// stl
#include <stdexcept>
#include <sstream>
#include <iomanip>
// boost
// fusion
@ -360,6 +362,17 @@ void box2d<T>::move(T x, T y)
maxy_ += y;
}
template <typename T>
std::string box2d<T>::to_string() const
{
std::ostringstream s;
s << "box2d(" << std::fixed << std::setprecision(16)
<< minx_ << ',' << miny_ << ','
<< maxx_ << ',' << maxy_ << ')';
return s.str();
}
template <typename T>
box2d<T>& box2d<T>::operator+=(box2d<T> const& other)
{

View file

@ -143,6 +143,8 @@ else: # unix, non-macos
source = Split(
"""
font_library.cpp
marker_helpers.cpp
dasharray_parser.cpp
expression_grammar.cpp
fs.cpp
request.cpp

View file

@ -41,13 +41,6 @@ void cairo_renderer<T>::process(line_pattern_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
using conv_types = boost::mpl::vector<clip_line_tag, transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag,
dash_tag, stroke_tag>;
std::string filename = get<std::string>(sym, keys::file, feature, common_.vars_);
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
bool clip = get<bool>(sym, keys::clip, feature, common_.vars_, false);
@ -111,8 +104,11 @@ void cairo_renderer<T>::process(line_pattern_symbolizer const& sym,
using rasterizer_type = line_pattern_rasterizer<cairo_context>;
rasterizer_type ras(context_, *pattern, width, height);
vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<rasterizer_type,clip_line_tag, transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag,
dash_tag, stroke_tag>
converter(clipping_extent, ras, sym, common_.t_, prj_trans, tr, feature, common_.vars_, common_.scale_factor_);
if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)

View file

@ -36,12 +36,6 @@ void cairo_renderer<T>::process(line_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
using conv_types = boost::mpl::vector<clip_line_tag, transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag,
dash_tag, stroke_tag>;
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
bool clip = get<bool>(sym, keys::clip, feature, common_.vars_, false);
double offset = get<double>(sym, keys::offset, feature, common_.vars_, 0.0);
@ -84,8 +78,13 @@ void cairo_renderer<T>::process(line_symbolizer const& sym,
padding *= common_.scale_factor_;
clipping_extent.pad(padding);
}
vertex_converter<box2d<double>, cairo_context, line_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<cairo_context,
clip_line_tag,
transform_tag,
affine_transform_tag,
simplify_tag, smooth_tag,
offset_transform_tag,
dash_tag, stroke_tag>
converter(clipping_extent,context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)

View file

@ -102,9 +102,7 @@ void cairo_renderer<T>::process(polygon_pattern_symbolizer const& sym,
auto geom_transform = get_optional<transform_type>(sym, keys::geometry_transform);
if (geom_transform) { evaluate_transform(tr, feature, common_.vars_, *geom_transform, common_.scale_factor_); }
using conv_types = boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
vertex_converter<box2d<double>, cairo_context, polygon_pattern_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<cairo_context,clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>
converter(clip_box, context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (prj_trans.equal() && clip) converter.set<clip_poly_tag>(); //optional clip (default: true)

View file

@ -38,11 +38,7 @@ void cairo_renderer<T>::process(polygon_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
using conv_types = boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
using vertex_converter_type = vertex_converter<box2d<double>, cairo_context, polygon_symbolizer,
view_transform, proj_transform, agg::trans_affine,
conv_types, feature_impl>;
using vertex_converter_type = vertex_converter<cairo_context,clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
cairo_save_restore guard(context_);
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
context_.set_operator(comp_op);

64
src/dasharray_parser.cpp Normal file
View file

@ -0,0 +1,64 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2014 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// mapnik
#include <mapnik/util/dasharray_parser.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
namespace mapnik {
namespace util {
bool parse_dasharray(std::string const& value, std::vector<double>& dasharray)
{
using namespace boost::spirit;
qi::double_type double_;
qi::_1_type _1;
qi::lit_type lit;
qi::char_type char_;
qi::ascii::space_type space;
qi::no_skip_type no_skip;
// SVG
// dasharray ::= (length | percentage) (comma-wsp dasharray)?
// no support for 'percentage' as viewport is unknown at load_map
//
auto first = value.begin();
auto last = value.end();
bool r = qi::phrase_parse(first, last,
(double_[boost::phoenix::push_back(boost::phoenix::ref(dasharray), _1)] %
no_skip[char_(", ")]
| lit("none")),
space);
if (first != last)
{
return false;
}
return r;
}
} // end namespace util
} // end namespace mapnik

View file

@ -22,31 +22,135 @@
#include <mapnik/expression_node.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/noncopyable.hpp>
#if defined(BOOST_REGEX_HAS_ICU)
#include <boost/regex/icu.hpp>
#else
#include <boost/regex.hpp>
#endif
namespace mapnik
{
struct _regex_match_impl : noncopyable {
#if defined(BOOST_REGEX_HAS_ICU)
regex_match_node::regex_match_node (expr_node const& a, mapnik::value_unicode_string const& ustr)
: expr(a),
pattern(boost::make_u32regex(ustr)) {}
regex_replace_node::regex_replace_node (expr_node const& a, mapnik::value_unicode_string const& ustr, mapnik::value_unicode_string const& f)
: expr(a),
pattern(boost::make_u32regex(ustr)),
format(f) {}
_regex_match_impl(value_unicode_string const& ustr) :
pattern_(boost::make_u32regex(ustr)) {}
boost::u32regex pattern_;
#else
regex_match_node::regex_match_node (expr_node const& a, std::string const& str)
: expr(a),
pattern(str) {}
regex_replace_node::regex_replace_node (expr_node const& a, std::string const& str, std::string const& f)
: expr(a),
pattern(str),
format(f) {}
_regex_match_impl(std::string const& ustr) :
pattern_(ustr) {}
boost::regex pattern_;
#endif
};
struct _regex_replace_impl : noncopyable {
#if defined(BOOST_REGEX_HAS_ICU)
_regex_replace_impl(value_unicode_string const& ustr, value_unicode_string const& f) :
pattern_(boost::make_u32regex(ustr)),
format_(f) {}
boost::u32regex pattern_;
value_unicode_string format_;
#else
_regex_replace_impl(std::string const& ustr,std::string const& f) :
pattern_(ustr),
format_(f) {}
boost::regex pattern_;
std::string format_;
#endif
};
regex_match_node::regex_match_node(transcoder const& tr,
expr_node const& a,
std::string const& ustr)
: expr(a),
impl_(new _regex_match_impl(
#if defined(BOOST_REGEX_HAS_ICU)
tr.transcode(ustr.c_str())
#else
ustr
#endif
)) {}
value regex_match_node::apply(value const& v) const
{
auto const& pattern = impl_.get()->pattern_;
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_match(v.to_unicode(),pattern);
#else
return boost::regex_match(v.to_string(),pattern);
#endif
}
std::string regex_match_node::to_string() const
{
std::string str_;
str_ +=".match('";
auto const& pattern = impl_.get()->pattern_;
#if defined(BOOST_REGEX_HAS_ICU)
std::string utf8;
value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], pattern.str().length());
to_utf8(ustr,utf8);
str_ += utf8;
#else
str_ += pattern.str();
#endif
str_ +="')";
return str_;
}
regex_replace_node::regex_replace_node(transcoder const& tr,
expr_node const& a,
std::string const& ustr,
std::string const& f)
: expr(a),
impl_(new _regex_replace_impl(
#if defined(BOOST_REGEX_HAS_ICU)
tr.transcode(ustr.c_str()),
tr.transcode(f.c_str())
#else
ustr,
f
#endif
)) {}
value regex_replace_node::apply(value const& v) const
{
auto const& pattern = impl_.get()->pattern_;
auto const& format = impl_.get()->format_;
#if defined(BOOST_REGEX_HAS_ICU)
return boost::u32regex_replace(v.to_unicode(),pattern,format);
#else
std::string repl = boost::regex_replace(v.to_string(),pattern,format);
transcoder tr_("utf8");
return tr_.transcode(repl.c_str());
#endif
}
std::string regex_replace_node::to_string() const
{
std::string str_;
str_ +=".replace(";
str_ += "'";
auto const& pattern = impl_.get()->pattern_;
auto const& format = impl_.get()->format_;
#if defined(BOOST_REGEX_HAS_ICU)
std::string utf8;
value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], pattern.str().length());
to_utf8(ustr,utf8);
str_ += utf8;
str_ +="','";
to_utf8(format ,utf8);
str_ += utf8;
#else
str_ += pattern.str();
str_ +="','";
str_ += format;
#endif
str_ +="')";
return str_;
}
}

View file

@ -29,10 +29,6 @@
#include <mapnik/attribute.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value.hpp>
// boost
#if defined(BOOST_REGEX_HAS_ICU)
#include <boost/regex/icu.hpp> // for u32regex
#endif
namespace mapnik
{
@ -94,37 +90,13 @@ struct expression_string : util::static_visitor<void>
void operator() (regex_match_node const & x) const
{
util::apply_visitor(*this,x.expr);
str_ +=".match('";
#if defined(BOOST_REGEX_HAS_ICU)
std::string utf8;
mapnik::value_unicode_string ustr = mapnik::value_unicode_string::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length());
to_utf8(ustr,utf8);
str_ += utf8;
#else
str_ += x.pattern.str();
#endif
str_ +="')";
str_ += x.to_string();
}
void operator() (regex_replace_node const & x) const
{
util::apply_visitor(*this,x.expr);
str_ +=".replace(";
str_ += "'";
#if defined(BOOST_REGEX_HAS_ICU)
std::string utf8;
mapnik::value_unicode_string ustr = mapnik::value_unicode_string::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length());
to_utf8(ustr,utf8);
str_ += utf8;
str_ +="','";
to_utf8(x.format ,utf8);
str_ += utf8;
#else
str_ += x.pattern.str();
str_ +="','";
str_ += x.format;
#endif
str_ +="')";
str_ += x.to_string();
}
void operator() (unary_function_call const& call) const

View file

@ -24,87 +24,6 @@
namespace mapnik {
// functions
// exp
//template <typename T>
struct exp_impl
{
//using type = T;
value_type operator() (value_type const& val) const
{
return std::exp(val.to_double());
}
};
// sin
struct sin_impl
{
value_type operator() (value_type const& val) const
{
return std::sin(val.to_double());
}
};
// cos
struct cos_impl
{
value_type operator() (value_type const& val) const
{
return std::cos(val.to_double());
}
};
// tan
struct tan_impl
{
value_type operator() (value_type const& val) const
{
return std::tan(val.to_double());
}
};
// atan
struct atan_impl
{
value_type operator()(value_type const& val) const
{
return std::atan(val.to_double());
}
};
// abs
struct abs_impl
{
value_type operator() (value_type const& val) const
{
return std::fabs(val.to_double());
}
};
// length
struct length_impl
{
value_type operator() (value_type const& val) const
{
return val.to_unicode().length();
}
};
unary_function_types::unary_function_types()
{
add
("sin", sin_impl())
("cos", cos_impl())
("tan", tan_impl())
("atan", atan_impl())
("exp", exp_impl())
("abs", abs_impl())
("length",length_impl())
;
}
char const* unary_function_name(unary_function_impl const& fun)
{
if (fun.target<sin_impl>()) return "sin";
@ -118,31 +37,6 @@ char const* unary_function_name(unary_function_impl const& fun)
}
// binary functions
// min
inline value_type min_impl(value_type const& arg1, value_type const& arg2)
{
return std::min(arg1.to_double(), arg2.to_double());
}
// max
inline value_type max_impl(value_type const& arg1, value_type const& arg2)
{
return std::max(arg1.to_double(), arg2.to_double());
}
// pow
inline value_type pow_impl(value_type const& arg1, value_type const& arg2)
{
return std::pow(arg1.to_double(), arg2.to_double());
}
binary_function_types::binary_function_types()
{
add
("min", binary_function_impl(min_impl))
("max", binary_function_impl(max_impl))
("pow", binary_function_impl(pow_impl))
;
}
char const* binary_function_name(binary_function_impl const& fun)
{
value_type(*const* f_ptr)(value_type const&, value_type const&) =

View file

@ -73,9 +73,7 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
using pixfmt_type = typename grid_renderer_base_type::pixfmt_type;
using color_type = typename grid_renderer_base_type::pixfmt_type::color_type;
using renderer_type = agg::renderer_scanline_bin_solid<grid_renderer_base_type>;
using conv_types = boost::mpl::vector<clip_line_tag, transform_tag,
offset_transform_tag, affine_transform_tag,
simplify_tag, smooth_tag, stroke_tag>;
agg::scanline_bin sl;
grid_rendering_buffer buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_);
@ -119,8 +117,10 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
put<value_double>(line, keys::simplify_tolerance, value_double(simplify_tolerance));
put<value_double>(line, keys::smooth, value_double(smooth));
vertex_converter<box2d<double>, grid_rasterizer, line_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<grid_rasterizer,
clip_line_tag, transform_tag,
offset_transform_tag, affine_transform_tag,
simplify_tag, smooth_tag, stroke_tag>
converter(clipping_extent,*ras_ptr,line,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)
converter.set<transform_tag>(); // always transform

View file

@ -50,9 +50,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
using pixfmt_type = typename grid_renderer_base_type::pixfmt_type;
using color_type = typename grid_renderer_base_type::pixfmt_type::color_type;
using renderer_type = agg::renderer_scanline_bin_solid<grid_renderer_base_type>;
using conv_types = boost::mpl::vector<clip_line_tag, transform_tag,
offset_transform_tag, affine_transform_tag,
simplify_tag, smooth_tag, dash_tag, stroke_tag>;
agg::scanline_bin sl;
grid_rendering_buffer buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_);
@ -91,8 +89,9 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
clipping_extent.pad(padding);
}
vertex_converter<box2d<double>, grid_rasterizer, line_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<grid_rasterizer, clip_line_tag, transform_tag,
offset_transform_tag, affine_transform_tag,
simplify_tag, smooth_tag, dash_tag, stroke_tag>
converter(clipping_extent,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)
converter.set<transform_tag>(); // always transform

View file

@ -53,7 +53,6 @@ porting notes -->
#include <mapnik/debug.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/vertex_converters.hpp>
#include <mapnik/marker.hpp>
#include <mapnik/marker_cache.hpp>
#include <mapnik/marker_helpers.hpp>

View file

@ -77,9 +77,7 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
}
using conv_types = boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag>;
vertex_converter<box2d<double>, grid_rasterizer, polygon_pattern_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<grid_rasterizer, clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag>
converter(common_.query_extent_,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
if (prj_trans.equal() && clip) converter.set<clip_poly_tag>(); //optional clip (default: true)

View file

@ -53,10 +53,7 @@ void grid_renderer<T>::process(polygon_symbolizer const& sym,
using renderer_type = agg::renderer_scanline_bin_solid<grid_renderer_base_type>;
using pixfmt_type = typename grid_renderer_base_type::pixfmt_type;
using color_type = typename grid_renderer_base_type::pixfmt_type::color_type;
using conv_types = boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
using vertex_converter_type = vertex_converter<box2d<double>, grid_rasterizer, polygon_symbolizer,
view_transform, proj_transform, agg::trans_affine,
conv_types, feature_impl>;
using vertex_converter_type = vertex_converter<grid_rasterizer,clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>;
ras_ptr->reset();

150
src/marker_helpers.cpp Normal file
View file

@ -0,0 +1,150 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2014 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// mapnik
#include <mapnik/marker_helpers.hpp>
namespace mapnik {
void build_ellipse(symbolizer_base const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path)
{
double width = 0.0;
double height = 0.0;
if (has_key<double>(sym,keys::width) && has_key<double>(sym,keys::height))
{
width = get<double>(sym, keys::width, feature, vars, 0.0);
height = get<double>(sym, keys::height, feature, vars, 0.0);
}
else if (has_key<double>(sym,keys::width))
{
width = height = get<double>(sym, keys::width, feature, vars, 0.0);
}
else if (has_key<double>(sym,keys::height))
{
width = height = get<double>(sym, keys::height, feature, vars, 0.0);
}
svg::svg_converter_type styled_svg(svg_path, marker_ellipse.attributes());
styled_svg.push_attr();
styled_svg.begin_path();
agg::ellipse c(0, 0, width/2.0, height/2.0);
styled_svg.storage().concat_path(c);
styled_svg.end_path();
styled_svg.pop_attr();
double lox,loy,hix,hiy;
styled_svg.bounding_rect(&lox, &loy, &hix, &hiy);
styled_svg.set_dimensions(width,height);
marker_ellipse.set_dimensions(width,height);
marker_ellipse.set_bounding_box(lox,loy,hix,hiy);
}
bool push_explicit_style(svg_attribute_type const& src,
svg_attribute_type & dst,
symbolizer_base const& sym,
feature_impl & feature,
attributes const& vars)
{
auto fill_color = get_optional<color>(sym, keys::fill, feature, vars);
auto fill_opacity = get_optional<double>(sym, keys::fill_opacity, feature, vars);
auto stroke_color = get_optional<color>(sym, keys::stroke, feature, vars);
auto stroke_width = get_optional<double>(sym, keys::stroke_width, feature, vars);
auto stroke_opacity = get_optional<double>(sym, keys::stroke_opacity, feature, vars);
if (fill_color ||
fill_opacity ||
stroke_color ||
stroke_width ||
stroke_opacity)
{
bool success = false;
for(unsigned i = 0; i < src.size(); ++i)
{
success = true;
dst.push_back(src[i]);
mapnik::svg::path_attributes & attr = dst.last();
if (attr.stroke_flag)
{
if (stroke_width)
{
attr.stroke_width = *stroke_width;
}
if (stroke_color)
{
color const& s_color = *stroke_color;
attr.stroke_color = agg::rgba(s_color.red()/255.0,
s_color.green()/255.0,
s_color.blue()/255.0,
s_color.alpha()/255.0);
}
if (stroke_opacity)
{
attr.stroke_opacity = *stroke_opacity;
}
}
if (attr.fill_flag)
{
if (fill_color)
{
color const& f_color = *fill_color;
attr.fill_color = agg::rgba(f_color.red()/255.0,
f_color.green()/255.0,
f_color.blue()/255.0,
f_color.alpha()/255.0);
}
if (fill_opacity)
{
attr.fill_opacity = *fill_opacity;
}
}
}
return success;
}
return false;
}
void setup_transform_scaling(agg::trans_affine & tr,
double svg_width,
double svg_height,
mapnik::feature_impl & feature,
attributes const& vars,
symbolizer_base const& sym)
{
double width = get<double>(sym, keys::width, feature, vars, 0.0);
double height = get<double>(sym, keys::height, feature, vars, 0.0);
if (width > 0 && height > 0)
{
double sx = width/svg_width;
double sy = height/svg_height;
tr *= agg::trans_affine_scaling(sx,sy);
}
else if (width > 0)
{
double sx = width/svg_width;
tr *= agg::trans_affine_scaling(sx);
}
else if (height > 0)
{
double sy = height/svg_height;
tr *= agg::trans_affine_scaling(sy);
}
}
} // end namespace mapnik

View file

@ -58,7 +58,7 @@ void font_feature_settings::from_string(std::string const& features)
if (!qi::parse(features.begin(), features.end(), as_string[+(char_ - ',')][app] % ','))
{
throw config_error("failed to parse font-features: '" + features + "'");
throw config_error("failed to parse font-feature-settings: '" + features + "'");
}
}
@ -91,7 +91,7 @@ void font_feature_settings::append(std::string const& feature)
if (!hb_feature_from_string(feature.c_str(), feature.length(), &*current_feature))
{
features_.erase(current_feature);
throw config_error("failed to parse font-features: '" + feature + "'");
throw config_error("failed to parse font-feature-settings: '" + feature + "'");
}
}

View file

@ -28,6 +28,9 @@
#include <cstdlib>
#include <string>
// icu
#include <unicode/ucnv.h>
namespace mapnik {
transcoder::transcoder (std::string const& encoding)

View file

@ -128,7 +128,7 @@ public:
needSwap_ = byteOrder_ ? wkbXDR : wkbNDR;
}
void read(boost::ptr_vector<geometry_type> & paths)
void read(geometry_container & paths)
{
int type = read_integer();
@ -307,7 +307,7 @@ private:
}
}
void read_point(boost::ptr_vector<geometry_type> & paths)
void read_point(geometry_container & paths)
{
double x = read_double();
double y = read_double();
@ -316,7 +316,7 @@ private:
paths.push_back(pt.release());
}
void read_multipoint(boost::ptr_vector<geometry_type> & paths)
void read_multipoint(geometry_container & paths)
{
int num_points = read_integer();
for (int i = 0; i < num_points; ++i)
@ -326,7 +326,7 @@ private:
}
}
void read_point_xyz(boost::ptr_vector<geometry_type> & paths)
void read_point_xyz(geometry_container & paths)
{
double x = read_double();
double y = read_double();
@ -336,7 +336,7 @@ private:
paths.push_back(pt.release());
}
void read_point_xyzm(boost::ptr_vector<geometry_type> & paths)
void read_point_xyzm(geometry_container & paths)
{
double x = read_double();
double y = read_double();
@ -346,7 +346,7 @@ private:
paths.push_back(pt.release());
}
void read_multipoint_xyz(boost::ptr_vector<geometry_type> & paths)
void read_multipoint_xyz(geometry_container & paths)
{
int num_points = read_integer();
for (int i = 0; i < num_points; ++i)
@ -356,7 +356,7 @@ private:
}
}
void read_multipoint_xyzm(boost::ptr_vector<geometry_type> & paths)
void read_multipoint_xyzm(geometry_container & paths)
{
int num_points = read_integer();
for (int i = 0; i < num_points; ++i)
@ -366,7 +366,7 @@ private:
}
}
void read_linestring(boost::ptr_vector<geometry_type> & paths)
void read_linestring(geometry_container & paths)
{
int num_points = read_integer();
if (num_points > 0)
@ -383,7 +383,7 @@ private:
}
}
void read_multilinestring(boost::ptr_vector<geometry_type> & paths)
void read_multilinestring(geometry_container & paths)
{
int num_lines = read_integer();
for (int i = 0; i < num_lines; ++i)
@ -393,7 +393,7 @@ private:
}
}
void read_linestring_xyz(boost::ptr_vector<geometry_type> & paths)
void read_linestring_xyz(geometry_container & paths)
{
int num_points = read_integer();
if (num_points > 0)
@ -410,7 +410,7 @@ private:
}
}
void read_linestring_xyzm(boost::ptr_vector<geometry_type> & paths)
void read_linestring_xyzm(geometry_container & paths)
{
int num_points = read_integer();
if (num_points > 0)
@ -427,7 +427,7 @@ private:
}
}
void read_multilinestring_xyz(boost::ptr_vector<geometry_type> & paths)
void read_multilinestring_xyz(geometry_container & paths)
{
int num_lines = read_integer();
for (int i = 0; i < num_lines; ++i)
@ -437,7 +437,7 @@ private:
}
}
void read_multilinestring_xyzm(boost::ptr_vector<geometry_type> & paths)
void read_multilinestring_xyzm(geometry_container & paths)
{
int num_lines = read_integer();
for (int i = 0; i < num_lines; ++i)
@ -447,7 +447,7 @@ private:
}
}
void read_polygon(boost::ptr_vector<geometry_type> & paths)
void read_polygon(geometry_container & paths)
{
int num_rings = read_integer();
if (num_rings > 0)
@ -473,7 +473,7 @@ private:
}
}
void read_multipolygon(boost::ptr_vector<geometry_type> & paths)
void read_multipolygon(geometry_container & paths)
{
int num_polys = read_integer();
for (int i = 0; i < num_polys; ++i)
@ -483,7 +483,7 @@ private:
}
}
void read_polygon_xyz(boost::ptr_vector<geometry_type> & paths)
void read_polygon_xyz(geometry_container & paths)
{
int num_rings = read_integer();
if (num_rings > 0)
@ -509,7 +509,7 @@ private:
}
}
void read_polygon_xyzm(boost::ptr_vector<geometry_type> & paths)
void read_polygon_xyzm(geometry_container & paths)
{
int num_rings = read_integer();
if (num_rings > 0)
@ -535,7 +535,7 @@ private:
}
}
void read_multipolygon_xyz(boost::ptr_vector<geometry_type> & paths)
void read_multipolygon_xyz(geometry_container & paths)
{
int num_polys = read_integer();
for (int i = 0; i < num_polys; ++i)
@ -545,7 +545,7 @@ private:
}
}
void read_multipolygon_xyzm(boost::ptr_vector<geometry_type> & paths)
void read_multipolygon_xyzm(geometry_container & paths)
{
int num_polys = read_integer();
for (int i = 0; i < num_polys; ++i)
@ -555,7 +555,7 @@ private:
}
}
void read_collection(boost::ptr_vector<geometry_type> & paths)
void read_collection(geometry_container & paths)
{
int num_geometries = read_integer();
for (int i = 0; i < num_geometries; ++i)
@ -607,7 +607,7 @@ private:
};
bool geometry_utils::from_wkb(boost::ptr_vector<geometry_type>& paths,
bool geometry_utils::from_wkb(geometry_container& paths,
const char* wkb,
unsigned size,
wkbFormat format)

View file

@ -60,11 +60,9 @@ boost::optional<std::string> linestring_bbox_clipping(mapnik::box2d<double> bbox
mapnik::geometry_container output_paths;
output_geometry_backend backend(output_paths, mapnik::geometry_type::types::LineString);
using conv_types = boost::mpl::vector<clip_line_tag>;
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
mapnik::feature_impl f(ctx,0);
vertex_converter<box2d<double>, output_geometry_backend, line_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<output_geometry_backend,clip_line_tag>
converter(bbox, backend, sym, t, prj_trans, tr, f, attributes(), 1.0);
converter.set<clip_line_tag>();
@ -104,11 +102,9 @@ boost::optional<std::string> polygon_bbox_clipping(mapnik::box2d<double> bbox,
mapnik::geometry_container output_paths;
output_geometry_backend backend(output_paths, mapnik::geometry_type::types::Polygon);
using conv_types = boost::mpl::vector<clip_poly_tag>;
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
mapnik::feature_impl f(ctx,0);
vertex_converter<box2d<double>, output_geometry_backend, polygon_symbolizer,
view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl>
vertex_converter<output_geometry_backend, clip_poly_tag>
converter(bbox, backend, sym, t, prj_trans, tr, f, attributes(), 1.0);
converter.set<clip_poly_tag>();

View file

@ -81,7 +81,7 @@ int main (int argc, char ** argv )
while(f)
{
std::cerr << *f << std::endl;
boost::ptr_vector<mapnik::geometry_type> & paths = f->paths();
mapnik::geometry_container const& paths = f->paths();
for (mapnik::geometry_type const& geom : paths)
{
// NDR