format dir include and src
format all files Revert "format all files" This reverts commit 95d5812e49e7f916b68e786596f5a8eb5bcac414. Revert "format some files" This reverts commit ed3c8762d4d828b2b28e7b18809fc33f4f8ccaf5. format all files fix formatting in dir include fix formatting of debug macro
This commit is contained in:
parent
6fe46f61e2
commit
e7c3d04309
648 changed files with 25217 additions and 26024 deletions
|
@ -9,8 +9,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include "agg_conv_smooth_poly1.h"
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
struct vcgen_smooth_calucate_adaptive
|
||||
{
|
||||
|
@ -57,12 +56,8 @@ struct vcgen_smooth_calucate_adaptive
|
|||
}
|
||||
}
|
||||
|
||||
return {
|
||||
{v1.x + s1 * smooth_value * (v2.x - xm1),
|
||||
v1.y + s1 * smooth_value * (v2.y - ym1)},
|
||||
{v2.x + s2 * smooth_value * (v1.x - xm2),
|
||||
v2.y + s2 * smooth_value * (v1.y - ym2)}
|
||||
};
|
||||
return {{v1.x + s1 * smooth_value * (v2.x - xm1), v1.y + s1 * smooth_value * (v2.y - ym1)},
|
||||
{v2.x + s2 * smooth_value * (v1.x - xm2), v2.y + s2 * smooth_value * (v1.y - ym2)}};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -95,45 +90,34 @@ class smooth_converter
|
|||
}
|
||||
|
||||
public:
|
||||
smooth_converter(Geometry & geom) :
|
||||
geom_(geom),
|
||||
impl_(std::move(init_impl(SMOOTH_ALGORITHM_BASIC, geom)))
|
||||
smooth_converter(Geometry& geom)
|
||||
: geom_(geom)
|
||||
, impl_(std::move(init_impl(SMOOTH_ALGORITHM_BASIC, geom)))
|
||||
{}
|
||||
|
||||
void algorithm(smooth_algorithm_enum algo)
|
||||
{
|
||||
impl_ = init_impl(algo, geom_);
|
||||
}
|
||||
void algorithm(smooth_algorithm_enum algo) { impl_ = init_impl(algo, geom_); }
|
||||
|
||||
void smooth_value(double v)
|
||||
{
|
||||
return util::apply_visitor([=](auto & impl) {
|
||||
impl.smooth_value(v);
|
||||
}, impl_);
|
||||
return util::apply_visitor([=](auto& impl) { impl.smooth_value(v); }, impl_);
|
||||
}
|
||||
|
||||
void rewind(unsigned path_id)
|
||||
{
|
||||
return util::apply_visitor([=](auto & impl) {
|
||||
return impl.rewind(path_id);
|
||||
}, impl_);
|
||||
return util::apply_visitor([=](auto& impl) { return impl.rewind(path_id); }, impl_);
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return util::apply_visitor([=](auto & impl) {
|
||||
return impl.vertex(x, y);
|
||||
}, impl_);
|
||||
return util::apply_visitor([=](auto& impl) { return impl.vertex(x, y); }, impl_);
|
||||
}
|
||||
|
||||
unsigned type() const
|
||||
{
|
||||
return util::apply_visitor([](auto const& impl) {
|
||||
return impl.type();
|
||||
}, impl_);
|
||||
return util::apply_visitor([](auto const& impl) { return impl.type(); }, impl_);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_ADAPTIVE_SMOOTH_HPP
|
||||
|
|
|
@ -78,41 +78,40 @@ struct agg_polygon_pattern : agg_pattern_base
|
|||
using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
|
||||
using wrap_x_type = agg::wrap_mode_repeat;
|
||||
using wrap_y_type = agg::wrap_mode_repeat;
|
||||
using img_source_type = agg::image_accessor_wrap<agg::pixfmt_rgba32_pre,
|
||||
wrap_x_type,
|
||||
wrap_y_type>;
|
||||
using img_source_type = agg::image_accessor_wrap<agg::pixfmt_rgba32_pre, wrap_x_type, wrap_y_type>;
|
||||
using span_gen_type = agg::span_pattern_rgba<img_source_type>;
|
||||
using renderer_base = agg::renderer_base<pixfmt_type>;
|
||||
using renderer_type = agg::renderer_scanline_aa_alpha<renderer_base,
|
||||
agg::span_allocator<agg::rgba8>,
|
||||
span_gen_type>;
|
||||
using renderer_type =
|
||||
agg::renderer_scanline_aa_alpha<renderer_base, agg::span_allocator<agg::rgba8>, span_gen_type>;
|
||||
|
||||
agg_polygon_pattern(image_rgba8 const& pattern_img,
|
||||
renderer_common const& common,
|
||||
symbolizer_base const& sym,
|
||||
mapnik::feature_impl const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
: agg_pattern_base{pattern_img, common, sym, feature, prj_trans},
|
||||
clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_)),
|
||||
clip_box_(clipping_extent(common)),
|
||||
tr_(geom_transform()),
|
||||
converter_(clip_box_, sym, common.t_, prj_trans, tr_,
|
||||
feature, common.vars_, common.scale_factor_)
|
||||
: agg_pattern_base{pattern_img, common, sym, feature, prj_trans}
|
||||
, clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_))
|
||||
, clip_box_(clipping_extent(common))
|
||||
, tr_(geom_transform())
|
||||
, converter_(clip_box_, sym, common.t_, prj_trans, tr_, feature, common.vars_, common.scale_factor_)
|
||||
{
|
||||
value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym_, feature_, common_.vars_);
|
||||
value_double smooth = get<value_double, keys::smooth>(sym_, feature_, common_.vars_);
|
||||
|
||||
if (simplify_tolerance > 0.0) converter_.template set<simplify_tag>();
|
||||
if (simplify_tolerance > 0.0)
|
||||
converter_.template set<simplify_tag>();
|
||||
converter_.template set<affine_transform_tag>();
|
||||
if (smooth > 0.0) converter_.template set<smooth_tag>();
|
||||
if (smooth > 0.0)
|
||||
converter_.template set<smooth_tag>();
|
||||
}
|
||||
|
||||
void render(renderer_base& ren_base, rasterizer& ras)
|
||||
{
|
||||
coord<double, 2> offset(pattern_offset(sym_, feature_, prj_trans_, common_,
|
||||
pattern_img_.width(), pattern_img_.height()));
|
||||
coord<double, 2> offset(
|
||||
pattern_offset(sym_, feature_, prj_trans_, common_, pattern_img_.width(), pattern_img_.height()));
|
||||
agg::rendering_buffer pattern_rbuf((agg::int8u*)pattern_img_.bytes(),
|
||||
pattern_img_.width(), pattern_img_.height(),
|
||||
pattern_img_.width(),
|
||||
pattern_img_.height(),
|
||||
pattern_img_.width() * 4);
|
||||
agg::pixfmt_rgba32_pre pixf_pattern(pattern_rbuf);
|
||||
img_source_type img_src(pixf_pattern);
|
||||
|
@ -122,8 +121,7 @@ struct agg_polygon_pattern : agg_pattern_base
|
|||
value_double opacity = get<double, keys::opacity>(sym_, feature_, common_.vars_);
|
||||
renderer_type rp(ren_base, sa, sg, unsigned(opacity * 255));
|
||||
|
||||
using apply_vertex_converter_type = detail::apply_vertex_converter<
|
||||
VertexConverter, rasterizer>;
|
||||
using apply_vertex_converter_type = detail::apply_vertex_converter<VertexConverter, rasterizer>;
|
||||
using vertex_processor_type = geometry::vertex_processor<apply_vertex_converter_type>;
|
||||
apply_vertex_converter_type apply(converter_, ras);
|
||||
mapnik::util::apply_visitor(vertex_processor_type(apply), feature_.get_geometry());
|
||||
|
@ -139,5 +137,4 @@ struct agg_polygon_pattern : agg_pattern_base
|
|||
|
||||
} // namespace mapnik
|
||||
|
||||
|
||||
#endif // MAPNIK_RENDER_POLYGON_PATTERN_HPP
|
||||
|
|
|
@ -59,6 +59,6 @@ void set_gamma_method(T & ras_ptr, double gamma, gamma_method_enum method)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_HELPERS_HPP
|
||||
|
|
|
@ -33,24 +33,18 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include "agg_color_rgba.h"
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
class pattern_source : private util::noncopyable
|
||||
{
|
||||
public:
|
||||
pattern_source(image_rgba8 const& pattern, double opacity = 1.0)
|
||||
: pattern_(pattern),
|
||||
opacity_(opacity) {}
|
||||
: pattern_(pattern)
|
||||
, opacity_(opacity)
|
||||
{}
|
||||
|
||||
unsigned int width() const
|
||||
{
|
||||
return pattern_.width();
|
||||
}
|
||||
unsigned int height() const
|
||||
{
|
||||
return pattern_.height();
|
||||
}
|
||||
unsigned int width() const { return pattern_.width(); }
|
||||
unsigned int height() const { return pattern_.height(); }
|
||||
agg::rgba8 pixel(int x, int y) const
|
||||
{
|
||||
unsigned c = pattern_(x, y);
|
||||
|
@ -59,10 +53,11 @@ public:
|
|||
static_cast<unsigned>(((c >> 16) & 0xff) * opacity_),
|
||||
static_cast<unsigned>(((c >> 24) & 0xff) * opacity_));
|
||||
}
|
||||
|
||||
private:
|
||||
image_rgba8 const& pattern_;
|
||||
double opacity_;
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_PATTERN_SOURCE_HPP
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
|
||||
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore_agg.hpp>
|
||||
|
@ -35,8 +34,10 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
struct rasterizer : agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_int_sat>, util::noncopyable {};
|
||||
struct rasterizer : agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_int_sat>,
|
||||
util::noncopyable
|
||||
{};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_RASTERIZER_HPP
|
||||
|
|
|
@ -53,9 +53,13 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
namespace mapnik {
|
||||
|
||||
template<typename SvgRenderer, typename RasterizerType, typename RendererBaseType>
|
||||
void render_vector_marker(SvgRenderer & svg_renderer, RasterizerType & ras, RendererBaseType & renb,
|
||||
box2d<double> const& bbox, agg::trans_affine const& tr,
|
||||
double opacity, bool snap_to_pixels)
|
||||
void render_vector_marker(SvgRenderer& svg_renderer,
|
||||
RasterizerType& ras,
|
||||
RendererBaseType& renb,
|
||||
box2d<double> const& bbox,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity,
|
||||
bool snap_to_pixels)
|
||||
{
|
||||
agg::scanline_u8 sl;
|
||||
if (snap_to_pixels)
|
||||
|
@ -73,9 +77,13 @@ void render_vector_marker(SvgRenderer & svg_renderer, RasterizerType & ras, Rend
|
|||
}
|
||||
|
||||
template<typename RendererType, typename RasterizerType>
|
||||
void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 const& src,
|
||||
agg::trans_affine const& tr, double opacity,
|
||||
float scale_factor, bool snap_to_pixels)
|
||||
void render_raster_marker(RendererType renb,
|
||||
RasterizerType& ras,
|
||||
image_rgba8 const& src,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity,
|
||||
float scale_factor,
|
||||
bool snap_to_pixels)
|
||||
{
|
||||
using color_type = agg::rgba8;
|
||||
using const_rendering_buffer = util::rendering_buffer<image_rgba8>;
|
||||
|
@ -84,11 +92,9 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
agg::scanline_u8 sl;
|
||||
double width = src.width();
|
||||
double height = src.height();
|
||||
if (std::fabs(1.0 - scale_factor) < 0.001
|
||||
&& (std::fabs(1.0 - tr.sx) < agg::affine_epsilon)
|
||||
&& (std::fabs(0.0 - tr.shy) < agg::affine_epsilon)
|
||||
&& (std::fabs(0.0 - tr.shx) < agg::affine_epsilon)
|
||||
&& (std::fabs(1.0 - tr.sy) < agg::affine_epsilon))
|
||||
if (std::fabs(1.0 - scale_factor) < 0.001 && (std::fabs(1.0 - tr.sx) < agg::affine_epsilon) &&
|
||||
(std::fabs(0.0 - tr.shy) < agg::affine_epsilon) && (std::fabs(0.0 - tr.shx) < agg::affine_epsilon) &&
|
||||
(std::fabs(1.0 - tr.sy) < agg::affine_epsilon))
|
||||
{
|
||||
const_rendering_buffer src_buffer(src);
|
||||
pixfmt_pre pixf_mask(src_buffer);
|
||||
|
@ -102,11 +108,7 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
}
|
||||
else
|
||||
{
|
||||
renb.blend_from(pixf_mask,
|
||||
0,
|
||||
static_cast<int>(tr.tx),
|
||||
static_cast<int>(tr.ty),
|
||||
unsigned(255*opacity));
|
||||
renb.blend_from(pixf_mask, 0, static_cast<int>(tr.tx), static_cast<int>(tr.ty), unsigned(255 * opacity));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -115,15 +117,18 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
// using span_gen_type = agg::span_image_filter_rgba_2x2<img_accessor_type,interpolator_type>;
|
||||
using span_gen_type = agg::span_image_resample_rgba_affine<img_accessor_type>;
|
||||
using renderer_type = agg::renderer_scanline_aa_alpha<RendererType,
|
||||
agg::span_allocator<color_type>,
|
||||
span_gen_type>;
|
||||
using renderer_type =
|
||||
agg::renderer_scanline_aa_alpha<RendererType, agg::span_allocator<color_type>, span_gen_type>;
|
||||
|
||||
double p[8];
|
||||
p[0] = 0; p[1] = 0;
|
||||
p[2] = width; p[3] = 0;
|
||||
p[4] = width; p[5] = height;
|
||||
p[6] = 0; p[7] = height;
|
||||
p[0] = 0;
|
||||
p[1] = 0;
|
||||
p[2] = width;
|
||||
p[3] = 0;
|
||||
p[4] = width;
|
||||
p[5] = height;
|
||||
p[6] = 0;
|
||||
p[7] = height;
|
||||
tr.transform(&p[0], &p[1]);
|
||||
tr.transform(&p[2], &p[3]);
|
||||
tr.transform(&p[4], &p[5]);
|
||||
|
@ -151,6 +156,6 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_RENDER_MARKER_HPP
|
||||
|
|
|
@ -41,7 +41,9 @@
|
|||
#include <stack>
|
||||
|
||||
// fwd declaration to avoid dependence on agg headers
|
||||
namespace agg { struct trans_affine; }
|
||||
namespace agg {
|
||||
struct trans_affine;
|
||||
}
|
||||
|
||||
// fwd declarations to speed up compile
|
||||
namespace mapnik {
|
||||
|
@ -55,8 +57,9 @@ namespace mapnik {
|
|||
class proj_transform;
|
||||
struct rasterizer;
|
||||
struct rgba8_t;
|
||||
template<typename T> class image;
|
||||
}
|
||||
template<typename T>
|
||||
class image;
|
||||
} // namespace mapnik
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -65,12 +68,11 @@ class buffer_stack
|
|||
{
|
||||
public:
|
||||
buffer_stack(std::size_t width, std::size_t height)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
buffers_(),
|
||||
position_(buffers_.begin())
|
||||
{
|
||||
}
|
||||
: width_(width)
|
||||
, height_(height)
|
||||
, buffers_()
|
||||
, position_(buffers_.begin())
|
||||
{}
|
||||
|
||||
T& push()
|
||||
{
|
||||
|
@ -86,10 +88,7 @@ public:
|
|||
}
|
||||
return *position_;
|
||||
}
|
||||
bool in_range() const
|
||||
{
|
||||
return (position_ != buffers_.end());
|
||||
}
|
||||
bool in_range() const { return (position_ != buffers_.end()); }
|
||||
|
||||
void pop()
|
||||
{
|
||||
|
@ -98,10 +97,7 @@ public:
|
|||
++position_;
|
||||
}
|
||||
|
||||
T & top() const
|
||||
{
|
||||
return *position_;
|
||||
}
|
||||
T& top() const { return *position_; }
|
||||
|
||||
private:
|
||||
const std::size_t width_;
|
||||
|
@ -114,18 +110,31 @@ template <typename T0, typename T1=label_collision_detector4>
|
|||
class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T0>>,
|
||||
private util::noncopyable
|
||||
{
|
||||
|
||||
public:
|
||||
using buffer_type = T0;
|
||||
using processor_impl_type = agg_renderer<T0>;
|
||||
using detector_type = T1;
|
||||
// create with default, empty placement detector
|
||||
agg_renderer(Map const& m, buffer_type & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
agg_renderer(Map const& m,
|
||||
buffer_type& pixmap,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0);
|
||||
// create with external placement detector, possibly non-empty
|
||||
agg_renderer(Map const &m, buffer_type & pixmap, std::shared_ptr<detector_type> detector,
|
||||
double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
agg_renderer(Map const& m,
|
||||
buffer_type& pixmap,
|
||||
std::shared_ptr<detector_type> detector,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0);
|
||||
// pass in mapnik::request object to provide the mutable things per render
|
||||
agg_renderer(Map const& m, request const& req, attributes const& vars, buffer_type & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
agg_renderer(Map const& m,
|
||||
request const& req,
|
||||
attributes const& vars,
|
||||
buffer_type& pixmap,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0);
|
||||
~agg_renderer();
|
||||
void start_map_processing(Map const& map);
|
||||
void end_map_processing(Map const& map);
|
||||
|
@ -135,52 +144,27 @@ public:
|
|||
void start_style_processing(feature_type_style const& st);
|
||||
void end_style_processing(feature_type_style const& st);
|
||||
|
||||
void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr,
|
||||
double opacity, composite_mode_e comp_op);
|
||||
void render_marker(pixel_position const& pos,
|
||||
marker const& marker,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity,
|
||||
composite_mode_e comp_op);
|
||||
|
||||
void process(point_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym,
|
||||
feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(dot_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(point_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym, feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(dot_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
|
||||
inline bool process(rule::symbolizers const&,
|
||||
mapnik::feature_impl&,
|
||||
proj_transform const& )
|
||||
inline bool process(rule::symbolizers const&, mapnik::feature_impl&, proj_transform const&)
|
||||
{
|
||||
// agg renderer doesn't support processing of multiple symbolizers.
|
||||
return false;
|
||||
|
@ -189,26 +173,16 @@ public:
|
|||
void painted(bool painted);
|
||||
bool painted();
|
||||
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const
|
||||
{
|
||||
return DEFAULT;
|
||||
}
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; }
|
||||
|
||||
inline double scale_factor() const
|
||||
{
|
||||
return common_.scale_factor_;
|
||||
}
|
||||
inline double scale_factor() const { return common_.scale_factor_; }
|
||||
|
||||
inline attributes const& variables() const { return common_.vars_; }
|
||||
|
||||
inline attributes const& variables() const
|
||||
{
|
||||
return common_.vars_;
|
||||
}
|
||||
protected:
|
||||
template<typename R>
|
||||
void debug_draw_box(R& buf, box2d<double> const& extent,
|
||||
double x, double y, double angle = 0.0);
|
||||
void debug_draw_box(box2d<double> const& extent,
|
||||
double x, double y, double angle = 0.0);
|
||||
void debug_draw_box(R& buf, box2d<double> const& extent, double x, double y, double angle = 0.0);
|
||||
void debug_draw_box(box2d<double> const& extent, double x, double y, double angle = 0.0);
|
||||
void draw_geo_extent(box2d<double> const& extent, mapnik::color const& color);
|
||||
|
||||
private:
|
||||
|
|
|
@ -37,7 +37,8 @@ struct attribute
|
|||
{
|
||||
std::string name_;
|
||||
explicit attribute(std::string const& _name)
|
||||
: name_(_name) {}
|
||||
: name_(_name)
|
||||
{}
|
||||
|
||||
template<typename V, typename F>
|
||||
V const& value(F const& f) const
|
||||
|
@ -61,7 +62,8 @@ struct global_attribute
|
|||
{
|
||||
std::string name;
|
||||
explicit global_attribute(std::string const& name_)
|
||||
: name(name_) {}
|
||||
: name(name_)
|
||||
{}
|
||||
|
||||
template<typename V, typename C>
|
||||
V const& operator()(C const& ctx)
|
||||
|
@ -72,6 +74,6 @@ struct global_attribute
|
|||
|
||||
using attributes = std::unordered_map<std::string, value>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_ATTRIBUTE_HPP
|
||||
|
|
|
@ -55,12 +55,10 @@ template <typename Container>
|
|||
struct expression_attributes
|
||||
{
|
||||
explicit expression_attributes(Container& names)
|
||||
: names_(names) {}
|
||||
: names_(names)
|
||||
{}
|
||||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
names_.emplace(attr.name());
|
||||
}
|
||||
void operator()(attribute const& attr) const { names_.emplace(attr.name()); }
|
||||
|
||||
template<typename Tag>
|
||||
void operator()(binary_node<Tag> const& x) const
|
||||
|
@ -75,18 +73,13 @@ struct expression_attributes
|
|||
util::apply_visitor(*this, x.expr);
|
||||
}
|
||||
|
||||
void operator() (regex_match_node const& x) const
|
||||
{
|
||||
util::apply_visitor(*this, x.expr);
|
||||
}
|
||||
void operator()(regex_match_node const& x) const { util::apply_visitor(*this, x.expr); }
|
||||
|
||||
void operator() (regex_replace_node const& x) const
|
||||
{
|
||||
util::apply_visitor(*this, x.expr);
|
||||
}
|
||||
void operator()(regex_replace_node const& x) const { util::apply_visitor(*this, x.expr); }
|
||||
|
||||
template<typename T>
|
||||
void operator() (T const&) const {}
|
||||
void operator()(T const&) const
|
||||
{}
|
||||
|
||||
private:
|
||||
Container& names_;
|
||||
|
@ -97,11 +90,12 @@ class group_attribute_collector : public util::noncopyable
|
|||
private:
|
||||
std::set<std::string>& names_;
|
||||
bool expand_index_columns_;
|
||||
|
||||
public:
|
||||
group_attribute_collector(std::set<std::string>& names,
|
||||
bool expand_index_columns)
|
||||
: names_(names),
|
||||
expand_index_columns_(expand_index_columns) {}
|
||||
group_attribute_collector(std::set<std::string>& names, bool expand_index_columns)
|
||||
: names_(names)
|
||||
, expand_index_columns_(expand_index_columns)
|
||||
{}
|
||||
|
||||
void operator()(group_symbolizer const& sym);
|
||||
};
|
||||
|
@ -110,8 +104,9 @@ template <typename Container>
|
|||
struct extract_attribute_names
|
||||
{
|
||||
explicit extract_attribute_names(Container& names)
|
||||
: names_(names),
|
||||
f_attr_(names) {}
|
||||
: names_(names)
|
||||
, f_attr_(names)
|
||||
{}
|
||||
|
||||
void operator()(mapnik::expression_ptr const& expr) const
|
||||
{
|
||||
|
@ -138,7 +133,8 @@ struct extract_attribute_names
|
|||
expr->add_expressions(expressions);
|
||||
for (it = expressions.begin(); it != expressions.end(); ++it)
|
||||
{
|
||||
if (*it) util::apply_visitor(f_attr_, **it);
|
||||
if (*it)
|
||||
util::apply_visitor(f_attr_, **it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +148,8 @@ struct extract_attribute_names
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void operator() (T const&) const {}
|
||||
void operator()(T const&) const
|
||||
{}
|
||||
|
||||
private:
|
||||
Container& names_;
|
||||
|
@ -161,11 +158,11 @@ private:
|
|||
|
||||
struct symbolizer_attributes
|
||||
{
|
||||
symbolizer_attributes(std::set<std::string>& names,
|
||||
double & filter_factor)
|
||||
: filter_factor_(filter_factor),
|
||||
f_attrs_(names),
|
||||
g_attrs_(names, true) {}
|
||||
symbolizer_attributes(std::set<std::string>& names, double& filter_factor)
|
||||
: filter_factor_(filter_factor)
|
||||
, f_attrs_(names)
|
||||
, g_attrs_(names, true)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
void operator()(T const& sym)
|
||||
|
@ -197,10 +194,7 @@ struct symbolizer_attributes
|
|||
}
|
||||
}
|
||||
|
||||
void operator () (group_symbolizer const& sym)
|
||||
{
|
||||
g_attrs_(sym);
|
||||
}
|
||||
void operator()(group_symbolizer const& sym) { g_attrs_(sym); }
|
||||
|
||||
private:
|
||||
double& filter_factor_;
|
||||
|
@ -208,19 +202,20 @@ private:
|
|||
group_attribute_collector g_attrs_;
|
||||
};
|
||||
|
||||
|
||||
class attribute_collector : public util::noncopyable
|
||||
{
|
||||
private:
|
||||
std::set<std::string>& names_;
|
||||
double filter_factor_;
|
||||
expression_attributes<std::set<std::string>> f_attr;
|
||||
|
||||
public:
|
||||
|
||||
attribute_collector(std::set<std::string>& names)
|
||||
: names_(names),
|
||||
filter_factor_(1.0),
|
||||
f_attr(names) {}
|
||||
: names_(names)
|
||||
, filter_factor_(1.0)
|
||||
, f_attr(names)
|
||||
{}
|
||||
template<typename RuleType>
|
||||
void operator()(RuleType const& r)
|
||||
{
|
||||
|
@ -235,13 +230,9 @@ public:
|
|||
util::apply_visitor(f_attr, *expr);
|
||||
}
|
||||
|
||||
double get_filter_factor() const
|
||||
{
|
||||
return filter_factor_;
|
||||
}
|
||||
double get_filter_factor() const { return filter_factor_; }
|
||||
};
|
||||
|
||||
|
||||
inline void group_attribute_collector::operator()(group_symbolizer const& sym)
|
||||
{
|
||||
// find all column names referenced in the group symbolizer
|
||||
|
|
|
@ -27,35 +27,30 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
enum eAttributeType {
|
||||
Integer=1,
|
||||
Float =2,
|
||||
Double =3,
|
||||
String =4,
|
||||
Boolean =5,
|
||||
Geometry=6,
|
||||
Object=7
|
||||
};
|
||||
enum eAttributeType { Integer = 1, Float = 2, Double = 3, String = 4, Boolean = 5, Geometry = 6, Object = 7 };
|
||||
|
||||
class attribute_descriptor
|
||||
{
|
||||
public:
|
||||
attribute_descriptor(std::string const& name,unsigned type,
|
||||
attribute_descriptor(std::string const& name,
|
||||
unsigned type,
|
||||
bool primary_key = false,
|
||||
int size = -1,
|
||||
int precision = -1)
|
||||
: name_(name),
|
||||
type_(type),
|
||||
size_(size),
|
||||
precision_(precision),
|
||||
primary_key_(primary_key) {}
|
||||
: name_(name)
|
||||
, type_(type)
|
||||
, size_(size)
|
||||
, precision_(precision)
|
||||
, primary_key_(primary_key)
|
||||
{}
|
||||
|
||||
attribute_descriptor(attribute_descriptor const& other)
|
||||
: name_(other.name_),
|
||||
type_(other.type_),
|
||||
size_(other.size_),
|
||||
precision_(other.precision_),
|
||||
primary_key_(other.primary_key_) {}
|
||||
: name_(other.name_)
|
||||
, type_(other.type_)
|
||||
, size_(other.size_)
|
||||
, precision_(other.precision_)
|
||||
, primary_key_(other.primary_key_)
|
||||
{}
|
||||
|
||||
attribute_descriptor& operator=(attribute_descriptor rhs)
|
||||
{
|
||||
|
@ -68,30 +63,15 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
std::string const& get_name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
std::string const& get_name() const { return name_; }
|
||||
|
||||
unsigned int get_type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
unsigned int get_type() const { return type_; }
|
||||
|
||||
bool is_primary_key() const
|
||||
{
|
||||
return primary_key_;
|
||||
}
|
||||
bool is_primary_key() const { return primary_key_; }
|
||||
|
||||
int get_size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
int get_size() const { return size_; }
|
||||
|
||||
int get_precision() const
|
||||
{
|
||||
return precision_;
|
||||
}
|
||||
int get_precision() const { return precision_; }
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
|
@ -101,6 +81,6 @@ private:
|
|||
bool primary_key_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_ATTRIBUTE_DESCRIPTOR_HPP
|
||||
|
|
|
@ -30,23 +30,22 @@
|
|||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
class MAPNIK_DECL boolean_type
|
||||
{
|
||||
public:
|
||||
boolean_type()
|
||||
: b_(false) {}
|
||||
: b_(false)
|
||||
{}
|
||||
boolean_type(bool b)
|
||||
: b_(b) {}
|
||||
: b_(b)
|
||||
{}
|
||||
boolean_type(boolean_type const& b)
|
||||
: b_(b.b_) {}
|
||||
: b_(b.b_)
|
||||
{}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return b_;
|
||||
}
|
||||
operator bool() const { return b_; }
|
||||
|
||||
boolean_type& operator=(boolean_type const& other)
|
||||
{
|
||||
|
@ -62,27 +61,26 @@ private:
|
|||
|
||||
// Special stream input operator for boolean_type values
|
||||
template<typename charT, typename traits>
|
||||
std::basic_istream<charT, traits> &
|
||||
operator >> ( std::basic_istream<charT, traits> & s, boolean_type & b )
|
||||
std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& s, boolean_type& b)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
std::string word;
|
||||
s >> word;
|
||||
bool result;
|
||||
if (util::string2bool(word,result)) b = result;
|
||||
if (util::string2bool(word, result))
|
||||
b = result;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
std::basic_ostream<charT, traits> &
|
||||
operator << ( std::basic_ostream<charT, traits> & s, boolean_type const& b )
|
||||
std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& s, boolean_type const& b)
|
||||
{
|
||||
s << (b ? "true" : "false");
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_BOOLEAN_HPP
|
||||
|
|
|
@ -23,17 +23,21 @@
|
|||
#ifndef MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP
|
||||
#define MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
namespace boost {
|
||||
namespace spirit {
|
||||
namespace x3 {
|
||||
// helper macro
|
||||
#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \
|
||||
template bool parse_rule<Iterator, Context, boost::spirit::x3::unused_type const>( \
|
||||
rule_type rule_ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, boost::spirit::x3::unused_type const& ); \
|
||||
rule_type rule_, \
|
||||
Iterator & first, \
|
||||
Iterator const& last, \
|
||||
Context const& context, \
|
||||
boost::spirit::x3::unused_type const&); \
|
||||
/***/
|
||||
|
||||
}}}
|
||||
|
||||
} // namespace x3
|
||||
} // namespace spirit
|
||||
} // namespace boost
|
||||
|
||||
#endif // MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_CAIRO_CONTEXT_HPP
|
||||
#define MAPNIK_CAIRO_CONTEXT_HPP
|
||||
|
||||
|
@ -57,7 +56,8 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T> class box2d;
|
||||
template<typename T>
|
||||
class box2d;
|
||||
|
||||
using ErrorStatus = cairo_status_t;
|
||||
|
||||
|
@ -86,12 +86,15 @@ public:
|
|||
cairo_face(std::shared_ptr<font_library> const& library, face_ptr const& face);
|
||||
~cairo_face();
|
||||
cairo_font_face_t* face() const;
|
||||
|
||||
private:
|
||||
class handle
|
||||
{
|
||||
public:
|
||||
handle(std::shared_ptr<font_library> const& library, face_ptr const& face)
|
||||
: library_(library), face_(face) {}
|
||||
: library_(library)
|
||||
, face_(face)
|
||||
{}
|
||||
|
||||
private:
|
||||
std::shared_ptr<font_library> library_;
|
||||
|
@ -127,7 +130,8 @@ struct cairo_closer
|
|||
{
|
||||
void operator()(cairo_t* obj)
|
||||
{
|
||||
if (obj) cairo_destroy(obj);
|
||||
if (obj)
|
||||
cairo_destroy(obj);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -135,7 +139,8 @@ struct cairo_surface_closer
|
|||
{
|
||||
void operator()(cairo_surface_t* surface)
|
||||
{
|
||||
if (surface) cairo_surface_destroy(surface);
|
||||
if (surface)
|
||||
cairo_surface_destroy(surface);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -157,15 +162,12 @@ public:
|
|||
const unsigned int* in_end = in_ptr + pixels;
|
||||
unsigned int* out_ptr;
|
||||
|
||||
surface_ = cairo_surface_ptr(
|
||||
cairo_image_surface_create(
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
surface_ = cairo_surface_ptr(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
|
||||
static_cast<int>(data.width()),
|
||||
static_cast<int>(data.height())),
|
||||
cairo_surface_closer());
|
||||
|
||||
out_ptr = reinterpret_cast<unsigned int *>(
|
||||
cairo_image_surface_get_data(surface_.get()));
|
||||
out_ptr = reinterpret_cast<unsigned int*>(cairo_image_surface_get_data(surface_.get()));
|
||||
|
||||
while (in_ptr < in_end)
|
||||
{
|
||||
|
@ -186,21 +188,18 @@ public:
|
|||
pattern_ = cairo_pattern_create_for_surface(surface_.get());
|
||||
}
|
||||
|
||||
cairo_pattern(cairo_surface_ptr const& surface) :
|
||||
surface_(surface),
|
||||
pattern_(cairo_pattern_create_for_surface(surface_.get()))
|
||||
{
|
||||
}
|
||||
cairo_pattern(cairo_surface_ptr const& surface)
|
||||
: surface_(surface)
|
||||
, pattern_(cairo_pattern_create_for_surface(surface_.get()))
|
||||
{}
|
||||
|
||||
~cairo_pattern()
|
||||
{
|
||||
if (pattern_) cairo_pattern_destroy(pattern_);
|
||||
if (pattern_)
|
||||
cairo_pattern_destroy(pattern_);
|
||||
}
|
||||
|
||||
void set_matrix(cairo_matrix_t const& matrix)
|
||||
{
|
||||
cairo_pattern_set_matrix(pattern_, &matrix);
|
||||
}
|
||||
void set_matrix(cairo_matrix_t const& matrix) { cairo_pattern_set_matrix(pattern_, &matrix); }
|
||||
|
||||
void set_origin(double x, double y)
|
||||
{
|
||||
|
@ -211,27 +210,17 @@ public:
|
|||
cairo_pattern_set_matrix(pattern_, &matrix);
|
||||
}
|
||||
|
||||
void set_extend(cairo_extend_t extend)
|
||||
{
|
||||
cairo_pattern_set_extend(pattern_, extend);
|
||||
}
|
||||
void set_extend(cairo_extend_t extend) { cairo_pattern_set_extend(pattern_, extend); }
|
||||
|
||||
void set_filter(cairo_filter_t filter)
|
||||
{
|
||||
cairo_pattern_set_filter(pattern_, filter);
|
||||
}
|
||||
void set_filter(cairo_filter_t filter) { cairo_pattern_set_filter(pattern_, filter); }
|
||||
|
||||
cairo_pattern_t * pattern() const
|
||||
{
|
||||
return pattern_;
|
||||
}
|
||||
cairo_pattern_t* pattern() const { return pattern_; }
|
||||
|
||||
private:
|
||||
cairo_surface_ptr surface_;
|
||||
cairo_pattern_t* pattern_;
|
||||
};
|
||||
|
||||
|
||||
class cairo_gradient : private util::noncopyable
|
||||
{
|
||||
public:
|
||||
|
@ -275,21 +264,13 @@ public:
|
|||
cairo_pattern_destroy(pattern_);
|
||||
}
|
||||
|
||||
cairo_pattern_t* gradient() const { return pattern_; }
|
||||
|
||||
cairo_pattern_t * gradient() const
|
||||
{
|
||||
return pattern_;
|
||||
}
|
||||
|
||||
gradient_unit_e units() const
|
||||
{
|
||||
return units_;
|
||||
}
|
||||
gradient_unit_e units() const { return units_; }
|
||||
|
||||
private:
|
||||
cairo_pattern_t* pattern_;
|
||||
gradient_unit_e units_;
|
||||
|
||||
};
|
||||
|
||||
class cairo_context : private util::noncopyable
|
||||
|
@ -297,10 +278,7 @@ class cairo_context : private util::noncopyable
|
|||
public:
|
||||
cairo_context(cairo_ptr const& cairo);
|
||||
|
||||
inline ErrorStatus get_status() const
|
||||
{
|
||||
return cairo_status(cairo_.get());
|
||||
}
|
||||
inline ErrorStatus get_status() const { return cairo_status(cairo_.get()); }
|
||||
|
||||
void clip();
|
||||
void show_page();
|
||||
|
@ -434,10 +412,11 @@ template <typename Context>
|
|||
struct line_pattern_rasterizer
|
||||
{
|
||||
line_pattern_rasterizer(Context& context, cairo_pattern& pattern, unsigned width, unsigned height)
|
||||
: context_(context),
|
||||
pattern_(pattern),
|
||||
width_(width),
|
||||
height_(height) {}
|
||||
: context_(context)
|
||||
, pattern_(pattern)
|
||||
, width_(width)
|
||||
, height_(height)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
void add_path(T& path, unsigned start_index = 0)
|
||||
|
@ -485,7 +464,6 @@ struct line_pattern_rasterizer
|
|||
unsigned height_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_CONTEXT_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_CAIRO_IMAGE_UTIL_HPP
|
||||
#define MAPNIK_CAIRO_IMAGE_UTIL_HPP
|
||||
|
||||
|
@ -33,8 +32,7 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data,
|
||||
cairo_surface_ptr const& surface)
|
||||
static inline void cairo_image_to_rgba8(mapnik::image_rgba8& data, cairo_surface_ptr const& surface)
|
||||
{
|
||||
if (cairo_image_surface_get_format(&*surface) != CAIRO_FORMAT_ARGB32)
|
||||
{
|
||||
|
@ -62,10 +60,15 @@ static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data,
|
|||
unsigned int g = (in >> 8) & 0xff;
|
||||
unsigned int b = (in >> 0) & 0xff;
|
||||
|
||||
#define DE_ALPHA(x) do { \
|
||||
if (a == 0) x = 0; \
|
||||
else x = x * 255 / a; \
|
||||
if (x > 255) x = 255; \
|
||||
#define DE_ALPHA(x) \
|
||||
do \
|
||||
{ \
|
||||
if (a == 0) \
|
||||
x = 0; \
|
||||
else \
|
||||
x = x * 255 / a; \
|
||||
if (x > 255) \
|
||||
x = 255; \
|
||||
} while (0)
|
||||
|
||||
DE_ALPHA(r);
|
||||
|
@ -78,7 +81,6 @@ static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data,
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_IMAGE_UTIL_HPP
|
||||
|
|
|
@ -32,12 +32,14 @@ namespace mapnik {
|
|||
|
||||
class cairo_context;
|
||||
|
||||
void render_vector_marker(cairo_context & context, svg_path_adapter & svg_path,
|
||||
void render_vector_marker(cairo_context& context,
|
||||
svg_path_adapter& svg_path,
|
||||
svg_attribute_type const& attributes,
|
||||
box2d<double> const& bbox, agg::trans_affine const& tr,
|
||||
box2d<double> const& bbox,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity);
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_RENDER_VECTOR_HPP
|
||||
|
||||
|
|
|
@ -58,10 +58,7 @@ struct cairo_save_restore
|
|||
{
|
||||
context_.save();
|
||||
}
|
||||
~cairo_save_restore()
|
||||
{
|
||||
context_.restore();
|
||||
}
|
||||
~cairo_save_restore() { context_.restore(); }
|
||||
cairo_context& context_;
|
||||
};
|
||||
|
||||
|
@ -71,11 +68,7 @@ class MAPNIK_DECL cairo_renderer : public feature_style_processor<cairo_renderer
|
|||
{
|
||||
public:
|
||||
using processor_impl_type = cairo_renderer<T>;
|
||||
cairo_renderer(Map const& m,
|
||||
T const& obj,
|
||||
double scale_factor=1.0,
|
||||
unsigned offset_x=0,
|
||||
unsigned offset_y=0);
|
||||
cairo_renderer(Map const& m, T const& obj, double scale_factor = 1.0, unsigned offset_x = 0, unsigned offset_y = 0);
|
||||
cairo_renderer(Map const& m,
|
||||
request const& req,
|
||||
attributes const& vars,
|
||||
|
@ -97,80 +90,44 @@ public:
|
|||
void end_layer_processing(layer const& lay);
|
||||
void start_style_processing(feature_type_style const& st);
|
||||
void end_style_processing(feature_type_style const& st);
|
||||
void process(point_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
inline bool process(rule::symbolizers const& /*syms*/,
|
||||
mapnik::feature_impl & /*feature*/,
|
||||
proj_transform const& /*prj_trans*/)
|
||||
void process(point_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
inline bool
|
||||
process(rule::symbolizers const& /*syms*/, mapnik::feature_impl& /*feature*/, proj_transform const& /*prj_trans*/)
|
||||
{
|
||||
// cairo renderer doesn't support processing of multiple symbolizers.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool painted()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool painted() { return true; }
|
||||
|
||||
void painted(bool /*painted*/)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const
|
||||
{
|
||||
return DEFAULT;
|
||||
}
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; }
|
||||
|
||||
inline double scale_factor() const
|
||||
{
|
||||
return common_.scale_factor_;
|
||||
}
|
||||
inline double scale_factor() const { return common_.scale_factor_; }
|
||||
|
||||
inline attributes const& variables() const
|
||||
{
|
||||
return common_.vars_;
|
||||
}
|
||||
inline attributes const& variables() const { return common_.vars_; }
|
||||
|
||||
void render_marker(pixel_position const& pos,
|
||||
marker const& marker,
|
||||
agg::trans_affine const& mtx,
|
||||
double opacity = 1.0,
|
||||
bool recenter = true);
|
||||
|
||||
protected:
|
||||
Map const& m_;
|
||||
cairo_context context_;
|
||||
|
@ -178,12 +135,11 @@ protected:
|
|||
cairo_face_manager face_manager_;
|
||||
bool style_level_compositing_;
|
||||
void setup(Map const& m);
|
||||
|
||||
};
|
||||
|
||||
extern template class MAPNIK_DECL cairo_renderer<cairo_ptr>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_RENDERER_HPP
|
||||
|
||||
|
|
|
@ -36,10 +36,9 @@ namespace mapnik {
|
|||
|
||||
struct cairo_renderer_process_visitor_p
|
||||
{
|
||||
cairo_renderer_process_visitor_p(agg::trans_affine const& image_tr,
|
||||
double opacity)
|
||||
: image_tr_(image_tr),
|
||||
opacity_(opacity)
|
||||
cairo_renderer_process_visitor_p(agg::trans_affine const& image_tr, double opacity)
|
||||
: image_tr_(image_tr)
|
||||
, opacity_(opacity)
|
||||
{}
|
||||
|
||||
cairo_surface_ptr operator()(marker_svg const& marker) const
|
||||
|
@ -50,9 +49,7 @@ struct cairo_renderer_process_visitor_p
|
|||
double width = std::max(1.0, std::round(bbox.width()));
|
||||
double height = std::max(1.0, std::round(bbox.height()));
|
||||
cairo_rectangle_t extent{0, 0, width, height};
|
||||
cairo_surface_ptr surface(
|
||||
cairo_recording_surface_create(
|
||||
CAIRO_CONTENT_COLOR_ALPHA, &extent),
|
||||
cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &extent),
|
||||
cairo_surface_closer());
|
||||
|
||||
cairo_ptr cairo = create_context(surface);
|
||||
|
@ -60,12 +57,10 @@ struct cairo_renderer_process_visitor_p
|
|||
|
||||
svg_storage_type& svg = *marker.get_data();
|
||||
svg_attribute_type const& svg_attributes = svg.attributes();
|
||||
svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(
|
||||
svg.source());
|
||||
svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(svg.source());
|
||||
svg::svg_path_adapter svg_path(stl_storage);
|
||||
|
||||
render_vector_marker(context, svg_path, svg_attributes,
|
||||
bbox, tr, opacity_);
|
||||
render_vector_marker(context, svg_path, svg_attributes, bbox, tr, opacity_);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
@ -76,9 +71,7 @@ struct cairo_renderer_process_visitor_p
|
|||
agg::trans_affine tr(transform(bbox));
|
||||
|
||||
cairo_rectangle_t extent{0, 0, bbox.width(), bbox.height()};
|
||||
cairo_surface_ptr surface(
|
||||
cairo_recording_surface_create(
|
||||
CAIRO_CONTENT_COLOR_ALPHA, &extent),
|
||||
cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &extent),
|
||||
cairo_surface_closer());
|
||||
|
||||
cairo_ptr cairo = create_context(surface);
|
||||
|
@ -91,9 +84,7 @@ struct cairo_renderer_process_visitor_p
|
|||
|
||||
cairo_surface_ptr operator()(marker_null const&) const
|
||||
{
|
||||
cairo_surface_ptr surface(
|
||||
cairo_recording_surface_create(
|
||||
CAIRO_CONTENT_COLOR_ALPHA, nullptr),
|
||||
cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, nullptr),
|
||||
cairo_surface_closer());
|
||||
cairo_ptr cairo = create_context(surface);
|
||||
cairo_context context(cairo);
|
||||
|
@ -105,9 +96,7 @@ private:
|
|||
{
|
||||
bbox *= image_tr_;
|
||||
coord<double, 2> c = bbox.center();
|
||||
agg::trans_affine mtx = agg::trans_affine_translation(
|
||||
0.5 * bbox.width() - c.x,
|
||||
0.5 * bbox.height() - c.y);
|
||||
agg::trans_affine mtx = agg::trans_affine_translation(0.5 * bbox.width() - c.x, 0.5 * bbox.height() - c.y);
|
||||
return image_tr_ * mtx;
|
||||
}
|
||||
|
||||
|
@ -143,19 +132,20 @@ struct cairo_polygon_pattern : cairo_pattern_base
|
|||
symbolizer_base const& sym,
|
||||
mapnik::feature_impl const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
: cairo_pattern_base{marker, common, sym, feature, prj_trans},
|
||||
clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_)),
|
||||
clip_box_(clipping_extent(common)),
|
||||
tr_(geom_transform()),
|
||||
converter_(clip_box_, sym, common.t_, prj_trans, tr_,
|
||||
feature, common.vars_, common.scale_factor_)
|
||||
: cairo_pattern_base{marker, common, sym, feature, prj_trans}
|
||||
, clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_))
|
||||
, clip_box_(clipping_extent(common))
|
||||
, tr_(geom_transform())
|
||||
, converter_(clip_box_, sym, common.t_, prj_trans, tr_, feature, common.vars_, common.scale_factor_)
|
||||
{
|
||||
value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym, feature, common_.vars_);
|
||||
value_double smooth = get<value_double, keys::smooth>(sym, feature, common_.vars_);
|
||||
|
||||
converter_.template set<affine_transform_tag>();
|
||||
if (simplify_tolerance > 0.0) converter_.template set<simplify_tag>();
|
||||
if (smooth > 0.0) converter_.template set<smooth_tag>();
|
||||
if (simplify_tolerance > 0.0)
|
||||
converter_.template set<simplify_tag>();
|
||||
if (smooth > 0.0)
|
||||
converter_.template set<smooth_tag>();
|
||||
}
|
||||
|
||||
void render(cairo_fill_rule_t fill_rule, cairo_context& context)
|
||||
|
@ -181,8 +171,12 @@ struct cairo_polygon_pattern : cairo_pattern_base
|
|||
cairo_rectangle_t pattern_surface_extent;
|
||||
if (cairo_recording_surface_get_extents(surface.get(), &pattern_surface_extent))
|
||||
{
|
||||
offset = pattern_offset(sym_, feature_, prj_trans_, common_,
|
||||
pattern_surface_extent.width, pattern_surface_extent.height);
|
||||
offset = pattern_offset(sym_,
|
||||
feature_,
|
||||
prj_trans_,
|
||||
common_,
|
||||
pattern_surface_extent.width,
|
||||
pattern_surface_extent.height);
|
||||
}
|
||||
|
||||
cairo_pattern pattern(surface);
|
||||
|
@ -207,5 +201,4 @@ struct cairo_polygon_pattern : cairo_pattern_base
|
|||
|
||||
} // namespace mapnik
|
||||
|
||||
|
||||
#endif // MAPNIK_CAIRO_RENDER_POLYGON_PATTERN_HPP
|
||||
|
|
|
@ -44,6 +44,6 @@ MAPNIK_DECL void save_to_cairo_file(mapnik::Map const& map,
|
|||
double scale_denominator = 0.0);
|
||||
#endif
|
||||
|
||||
} // end ns
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_IO_HPP
|
||||
|
|
|
@ -50,44 +50,50 @@ public:
|
|||
|
||||
// default ctor
|
||||
color()
|
||||
: red_(0xff),
|
||||
green_(0xff),
|
||||
blue_(0xff),
|
||||
alpha_(0xff),
|
||||
premultiplied_(false)
|
||||
: red_(0xff)
|
||||
, green_(0xff)
|
||||
, blue_(0xff)
|
||||
, alpha_(0xff)
|
||||
, premultiplied_(false)
|
||||
{}
|
||||
|
||||
color(std::uint8_t _red, std::uint8_t _green, std::uint8_t _blue, std::uint8_t _alpha = 0xff, bool premultiplied = false)
|
||||
: red_(_red),
|
||||
green_(_green),
|
||||
blue_(_blue),
|
||||
alpha_(_alpha),
|
||||
premultiplied_(premultiplied)
|
||||
color(std::uint8_t _red,
|
||||
std::uint8_t _green,
|
||||
std::uint8_t _blue,
|
||||
std::uint8_t _alpha = 0xff,
|
||||
bool premultiplied = false)
|
||||
: red_(_red)
|
||||
, green_(_green)
|
||||
, blue_(_blue)
|
||||
, alpha_(_alpha)
|
||||
, premultiplied_(premultiplied)
|
||||
{}
|
||||
|
||||
color(std::uint32_t _rgba, bool premultiplied = false)
|
||||
: red_(_rgba & 0xff),
|
||||
green_((_rgba >> 8) & 0xff),
|
||||
blue_((_rgba >> 16) & 0xff),
|
||||
alpha_((_rgba >> 24) & 0xff),
|
||||
premultiplied_(premultiplied) {}
|
||||
: red_(_rgba & 0xff)
|
||||
, green_((_rgba >> 8) & 0xff)
|
||||
, blue_((_rgba >> 16) & 0xff)
|
||||
, alpha_((_rgba >> 24) & 0xff)
|
||||
, premultiplied_(premultiplied)
|
||||
{}
|
||||
|
||||
// copy ctor
|
||||
color(const color& rhs)
|
||||
: red_(rhs.red_),
|
||||
green_(rhs.green_),
|
||||
blue_(rhs.blue_),
|
||||
alpha_(rhs.alpha_),
|
||||
premultiplied_(rhs.premultiplied_)
|
||||
: red_(rhs.red_)
|
||||
, green_(rhs.green_)
|
||||
, blue_(rhs.blue_)
|
||||
, alpha_(rhs.alpha_)
|
||||
, premultiplied_(rhs.premultiplied_)
|
||||
{}
|
||||
|
||||
// move ctor
|
||||
color(color&& rhs)
|
||||
: red_(std::move(rhs.red_)),
|
||||
green_(std::move(rhs.green_)),
|
||||
blue_(std::move(rhs.blue_)),
|
||||
alpha_(std::move(rhs.alpha_)),
|
||||
premultiplied_(std::move(rhs.premultiplied_)) {}
|
||||
: red_(std::move(rhs.red_))
|
||||
, green_(std::move(rhs.green_))
|
||||
, blue_(std::move(rhs.blue_))
|
||||
, alpha_(std::move(rhs.alpha_))
|
||||
, premultiplied_(std::move(rhs.premultiplied_))
|
||||
{}
|
||||
|
||||
color(std::string const& str, bool premultiplied = false);
|
||||
|
||||
|
@ -104,64 +110,32 @@ public:
|
|||
|
||||
inline bool operator==(color const& rhs) const
|
||||
{
|
||||
return (red_== rhs.red_) &&
|
||||
(green_ == rhs.green_) &&
|
||||
(blue_ == rhs.blue_) &&
|
||||
(alpha_ == rhs.alpha_) &&
|
||||
return (red_ == rhs.red_) && (green_ == rhs.green_) && (blue_ == rhs.blue_) && (alpha_ == rhs.alpha_) &&
|
||||
(premultiplied_ == rhs.premultiplied_);
|
||||
}
|
||||
|
||||
inline std::uint8_t red() const
|
||||
{
|
||||
return red_;
|
||||
}
|
||||
inline std::uint8_t red() const { return red_; }
|
||||
|
||||
inline std::uint8_t green() const
|
||||
{
|
||||
return green_;
|
||||
}
|
||||
inline std::uint8_t green() const { return green_; }
|
||||
|
||||
inline std::uint8_t blue() const
|
||||
{
|
||||
return blue_;
|
||||
}
|
||||
inline std::uint8_t blue() const { return blue_; }
|
||||
|
||||
inline std::uint8_t alpha() const
|
||||
{
|
||||
return alpha_;
|
||||
}
|
||||
inline std::uint8_t alpha() const { return alpha_; }
|
||||
|
||||
inline void set_red(std::uint8_t _red)
|
||||
{
|
||||
red_ = _red;
|
||||
}
|
||||
inline void set_red(std::uint8_t _red) { red_ = _red; }
|
||||
|
||||
inline void set_green(std::uint8_t _green)
|
||||
{
|
||||
green_ = _green;
|
||||
}
|
||||
inline void set_green(std::uint8_t _green) { green_ = _green; }
|
||||
|
||||
inline void set_blue(std::uint8_t _blue)
|
||||
{
|
||||
blue_ = _blue;
|
||||
}
|
||||
inline void set_alpha(std::uint8_t _alpha)
|
||||
{
|
||||
alpha_ = _alpha;
|
||||
}
|
||||
inline bool get_premultiplied() const
|
||||
{
|
||||
return premultiplied_;
|
||||
}
|
||||
inline void set_premultiplied(bool val)
|
||||
{
|
||||
premultiplied_ = val;
|
||||
}
|
||||
inline void set_blue(std::uint8_t _blue) { blue_ = _blue; }
|
||||
inline void set_alpha(std::uint8_t _alpha) { alpha_ = _alpha; }
|
||||
inline bool get_premultiplied() const { return premultiplied_; }
|
||||
inline void set_premultiplied(bool val) { premultiplied_ = val; }
|
||||
|
||||
inline unsigned rgba() const
|
||||
{
|
||||
return static_cast<unsigned>((alpha_ << 24) | (blue_ << 16) | (green_ << 8) | (red_));
|
||||
}
|
||||
|
||||
private:
|
||||
void swap(color& rhs)
|
||||
{
|
||||
|
@ -174,8 +148,7 @@ private:
|
|||
};
|
||||
|
||||
template<typename charT, typename traits>
|
||||
std::basic_ostream<charT, traits> &
|
||||
operator << ( std::basic_ostream<charT, traits> & s, mapnik::color const& c )
|
||||
std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& s, mapnik::color const& c)
|
||||
{
|
||||
s << c.to_string();
|
||||
return s;
|
||||
|
@ -187,6 +160,6 @@ inline std::size_t hash_value(color const& c)
|
|||
return c.rgba();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_COLOR_HPP
|
||||
|
|
|
@ -36,16 +36,14 @@ class config_error : public std::exception
|
|||
{
|
||||
public:
|
||||
config_error(std::string const& what);
|
||||
config_error(std::string const& what,
|
||||
xml_node const& node);
|
||||
config_error(std::string const& what,
|
||||
unsigned line_number,
|
||||
std::string const& filename);
|
||||
config_error(std::string const& what, xml_node const& node);
|
||||
config_error(std::string const& what, unsigned line_number, std::string const& filename);
|
||||
virtual ~config_error() {}
|
||||
virtual const char* what() const noexcept;
|
||||
void append_context(std::string const& ctx) const;
|
||||
void append_context(std::string const& ctx, xml_node const& node) const;
|
||||
void append_context(xml_node const& node) const;
|
||||
|
||||
protected:
|
||||
mutable std::string what_;
|
||||
mutable unsigned line_number_;
|
||||
|
@ -54,6 +52,6 @@ protected:
|
|||
mutable std::string msg_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CONFIG_ERROR_HPP
|
||||
|
|
|
@ -31,41 +31,53 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
namespace mapnik {
|
||||
template<typename T, int dim>
|
||||
struct coord {
|
||||
struct coord
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct coord<T, 2>
|
||||
: boost::addable<coord<T,2>,
|
||||
boost::addable2<coord<T,2>,T,
|
||||
boost::subtractable<coord<T,2>,
|
||||
boost::subtractable2<coord<T,2>,T,
|
||||
boost::dividable2<coord<T,2>, T,
|
||||
boost::multipliable2<coord<T,2>, T > > > > > >
|
||||
: boost::addable<
|
||||
coord<T, 2>,
|
||||
boost::addable2<
|
||||
coord<T, 2>,
|
||||
T,
|
||||
boost::subtractable<
|
||||
coord<T, 2>,
|
||||
boost::
|
||||
subtractable2<coord<T, 2>, T, boost::dividable2<coord<T, 2>, T, boost::multipliable2<coord<T, 2>, T>>>>>>
|
||||
|
||||
{
|
||||
using type = T;
|
||||
T x;
|
||||
T y;
|
||||
|
||||
public:
|
||||
coord()
|
||||
: x(),y() {}
|
||||
: x()
|
||||
, y()
|
||||
{}
|
||||
coord(T x_, T y_)
|
||||
: x(x_),y(y_) {}
|
||||
: x(x_)
|
||||
, y(y_)
|
||||
{}
|
||||
|
||||
coord(coord<T, 2> const& rhs)
|
||||
: x(rhs.x),
|
||||
y(rhs.y) {}
|
||||
: x(rhs.x)
|
||||
, y(rhs.y)
|
||||
{}
|
||||
|
||||
template<typename T2>
|
||||
coord(coord<T2, 2> const& rhs)
|
||||
: x(type(rhs.x)),
|
||||
y(type(rhs.y)) {}
|
||||
: x(type(rhs.x))
|
||||
, y(type(rhs.y))
|
||||
{}
|
||||
|
||||
coord(coord<T, 2>&& rhs) noexcept
|
||||
: x(std::move(rhs.x)),
|
||||
y(std::move(rhs.y)) {}
|
||||
: x(std::move(rhs.x))
|
||||
, y(std::move(rhs.y))
|
||||
{}
|
||||
|
||||
coord<T, 2>& operator=(coord<T, 2> rhs)
|
||||
{
|
||||
|
@ -127,6 +139,7 @@ public:
|
|||
y /= t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void swap(coord<T, 2>& rhs)
|
||||
{
|
||||
|
@ -142,22 +155,31 @@ struct coord<T,3>
|
|||
T x;
|
||||
T y;
|
||||
T z;
|
||||
|
||||
public:
|
||||
coord()
|
||||
: x(),y(),z() {}
|
||||
: x()
|
||||
, y()
|
||||
, z()
|
||||
{}
|
||||
coord(T x_, T y_, T z_)
|
||||
: x(x_),y(y_),z(z_) {}
|
||||
: x(x_)
|
||||
, y(y_)
|
||||
, z(z_)
|
||||
{}
|
||||
|
||||
template<typename T2>
|
||||
coord(coord<T2, 3> const& rhs)
|
||||
: x(type(rhs.x)),
|
||||
y(type(rhs.y)),
|
||||
z(type(rhs.z)) {}
|
||||
: x(type(rhs.x))
|
||||
, y(type(rhs.y))
|
||||
, z(type(rhs.z))
|
||||
{}
|
||||
|
||||
coord(coord<T, 3>&& rhs) noexcept
|
||||
: x(std::move(rhs.x)),
|
||||
y(std::move(rhs.y)),
|
||||
z(std::move(rhs.z)) {}
|
||||
: x(std::move(rhs.x))
|
||||
, y(std::move(rhs.y))
|
||||
, z(std::move(rhs.z))
|
||||
{}
|
||||
|
||||
coord<T, 3> operator=(coord<T, 3> rhs)
|
||||
{
|
||||
|
@ -172,6 +194,7 @@ public:
|
|||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void swap(coord<T, 3>& rhs)
|
||||
{
|
||||
|
@ -185,6 +208,6 @@ using coord2d = coord<double,2>;
|
|||
using coord2f = coord<float, 2>;
|
||||
using coord2i = coord<int, 2>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_COORD_HPP
|
||||
|
|
|
@ -31,13 +31,11 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/spirit/home/x3.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
|
||||
namespace css_color_grammar
|
||||
{
|
||||
namespace css_color_grammar {
|
||||
|
||||
struct css_color_class;
|
||||
using css_color_grammar_type = x3::rule<css_color_class, mapnik::color>;
|
||||
|
@ -46,6 +44,7 @@ css_color_grammar_type const css_color = "css_color";
|
|||
|
||||
BOOST_SPIRIT_DECLARE(css_color_grammar_type);
|
||||
|
||||
}}
|
||||
} // namespace css_color_grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_HPP
|
||||
|
|
|
@ -37,13 +37,8 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT (
|
||||
mapnik::color,
|
||||
(std::uint8_t, red_)
|
||||
(std::uint8_t, green_)
|
||||
(std::uint8_t, blue_)
|
||||
(std::uint8_t, alpha_)
|
||||
)
|
||||
BOOST_FUSION_ADAPT_STRUCT(mapnik::color,
|
||||
(std::uint8_t, red_)(std::uint8_t, green_)(std::uint8_t, blue_)(std::uint8_t, alpha_))
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -51,20 +46,21 @@ namespace x3 = boost::spirit::x3;
|
|||
|
||||
namespace css_color_grammar {
|
||||
|
||||
using x3::lit;
|
||||
using x3::uint_parser;
|
||||
using x3::hex;
|
||||
using x3::symbols;
|
||||
using x3::omit;
|
||||
using x3::attr;
|
||||
using x3::double_;
|
||||
using x3::hex;
|
||||
using x3::lit;
|
||||
using x3::no_case;
|
||||
using x3::no_skip;
|
||||
using x3::omit;
|
||||
using x3::symbols;
|
||||
using x3::uint_parser;
|
||||
|
||||
struct named_colors_ : x3::symbols<color>
|
||||
{
|
||||
named_colors_()
|
||||
{
|
||||
// clang-format off
|
||||
add
|
||||
("aliceblue", color(240, 248, 255))
|
||||
("antiquewhite", color(250, 235, 215))
|
||||
|
@ -216,6 +212,7 @@ struct named_colors_ : x3::symbols<color>
|
|||
("yellowgreen", color(154, 205, 50))
|
||||
("transparent", color(0, 0, 0, 0))
|
||||
;
|
||||
// clang-format on
|
||||
}
|
||||
} named_colors;
|
||||
|
||||
|
@ -235,97 +232,80 @@ struct clip_opacity
|
|||
{
|
||||
static double call(double val)
|
||||
{
|
||||
if (val > 1.0) return 1.0;
|
||||
if (val < 0.0) return 0.0;
|
||||
if (val > 1.0)
|
||||
return 1.0;
|
||||
if (val < 0.0)
|
||||
return 0.0;
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
struct percent_converter
|
||||
{
|
||||
static std::uint8_t call(double val)
|
||||
{
|
||||
return safe_cast<std::uint8_t>(std::lround((255.0 * val)/100.0));
|
||||
}
|
||||
static std::uint8_t call(double val) { return safe_cast<std::uint8_t>(std::lround((255.0 * val) / 100.0)); }
|
||||
};
|
||||
|
||||
auto dec_red = [](auto& ctx)
|
||||
{
|
||||
auto dec_red = [](auto& ctx) {
|
||||
_val(ctx).red_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto dec_green = [](auto& ctx)
|
||||
{
|
||||
auto dec_green = [](auto& ctx) {
|
||||
_val(ctx).green_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto dec_blue = [](auto& ctx)
|
||||
{
|
||||
auto dec_blue = [](auto& ctx) {
|
||||
_val(ctx).blue_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto opacity = [](auto& ctx)
|
||||
{
|
||||
auto opacity = [](auto& ctx) {
|
||||
_val(ctx).alpha_ = uint8_t((255.0 * clip_opacity::call(_attr(ctx))) + 0.5);
|
||||
};
|
||||
|
||||
auto percent_red = [] (auto & ctx)
|
||||
{
|
||||
auto percent_red = [](auto& ctx) {
|
||||
_val(ctx).red_ = percent_converter::call(_attr(ctx));
|
||||
};
|
||||
|
||||
auto percent_green = [] (auto & ctx)
|
||||
{
|
||||
auto percent_green = [](auto& ctx) {
|
||||
_val(ctx).green_ = percent_converter::call(_attr(ctx));
|
||||
};
|
||||
|
||||
auto percent_blue = [] (auto & ctx)
|
||||
{
|
||||
auto percent_blue = [](auto& ctx) {
|
||||
_val(ctx).blue_ = percent_converter::call(_attr(ctx));
|
||||
};
|
||||
|
||||
auto hex1_red = [](auto& ctx)
|
||||
{
|
||||
auto hex1_red = [](auto& ctx) {
|
||||
_val(ctx).red_ = _attr(ctx) | _attr(ctx) << 4;
|
||||
};
|
||||
|
||||
auto hex1_green = [](auto& ctx)
|
||||
{
|
||||
auto hex1_green = [](auto& ctx) {
|
||||
_val(ctx).green_ = _attr(ctx) | _attr(ctx) << 4;
|
||||
};
|
||||
|
||||
auto hex1_blue = [](auto& ctx)
|
||||
{
|
||||
auto hex1_blue = [](auto& ctx) {
|
||||
_val(ctx).blue_ = _attr(ctx) | _attr(ctx) << 4;
|
||||
};
|
||||
|
||||
auto hex1_opacity = [](auto& ctx)
|
||||
{
|
||||
auto hex1_opacity = [](auto& ctx) {
|
||||
_val(ctx).alpha_ = _attr(ctx) | _attr(ctx) << 4;
|
||||
};
|
||||
|
||||
auto hex2_red = [](auto& ctx)
|
||||
{
|
||||
auto hex2_red = [](auto& ctx) {
|
||||
_val(ctx).red_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto hex2_green = [](auto& ctx)
|
||||
{
|
||||
auto hex2_green = [](auto& ctx) {
|
||||
_val(ctx).green_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto hex2_blue = [](auto& ctx)
|
||||
{
|
||||
auto hex2_blue = [](auto& ctx) {
|
||||
_val(ctx).blue_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto hex2_opacity = [](auto& ctx)
|
||||
{
|
||||
auto hex2_opacity = [](auto& ctx) {
|
||||
_val(ctx).alpha_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto hsl_to_rgba = [] (auto& ctx)
|
||||
{
|
||||
auto hsl_to_rgba = [](auto& ctx) {
|
||||
double h = std::get<0>(_attr(ctx));
|
||||
double s = std::get<1>(_attr(ctx));
|
||||
double l = std::get<2>(_attr(ctx));
|
||||
|
@ -354,7 +334,7 @@ auto hsl_to_rgba = [] (auto& ctx)
|
|||
safe_cast<uint8_t>(std::lround(255.0 * b)),
|
||||
alpha);
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
auto const hex2_color_def = no_skip[lit('#')
|
||||
>> hex2[hex2_red]
|
||||
>> hex2[hex2_green]
|
||||
|
@ -429,21 +409,13 @@ auto const css_color_def =
|
|||
|
|
||||
hsla_color
|
||||
;
|
||||
|
||||
// clang-format on
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
BOOST_SPIRIT_DEFINE(
|
||||
css_color,
|
||||
hex2_color,
|
||||
hex1_color,
|
||||
rgb_color,
|
||||
rgba_color,
|
||||
rgb_color_percent,
|
||||
rgba_color_percent
|
||||
);
|
||||
BOOST_SPIRIT_DEFINE(css_color, hex2_color, hex1_color, rgb_color, rgba_color, rgb_color_percent, rgba_color_percent);
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
} // ns
|
||||
} //ns mapnik
|
||||
} // namespace css_color_grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -31,8 +31,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/spirit/home/x3.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
using property_value_type = boost::iterator_range<char const*>;
|
||||
using css_key_value = std::pair<std::string, property_value_type>;
|
||||
using definition_type = std::vector<css_key_value>;
|
||||
|
@ -40,8 +39,7 @@ using css_data = std::unordered_multimap<std::string, definition_type>;
|
|||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
|
||||
namespace css_grammar
|
||||
{
|
||||
namespace css_grammar {
|
||||
|
||||
class css_tag;
|
||||
class ident_tag;
|
||||
|
@ -58,17 +56,14 @@ css_grammar_type const css_grammar{"css"};
|
|||
css_skipper_type const css_skipper{"css skipper"};
|
||||
css_classes_type const css_classes{"css classes"};
|
||||
|
||||
BOOST_SPIRIT_DECLARE(ident_grammar_type,
|
||||
css_classes_type,
|
||||
css_grammar_type,
|
||||
css_skipper_type);
|
||||
BOOST_SPIRIT_DECLARE(ident_grammar_type, css_classes_type, css_grammar_type, css_skipper_type);
|
||||
|
||||
}
|
||||
} // namespace css_grammar
|
||||
|
||||
css_grammar::ident_grammar_type const ident_grammar();
|
||||
css_grammar::css_classes_type const classes();
|
||||
css_grammar::css_grammar_type const grammar();
|
||||
css_grammar::css_skipper_type const skipper();
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_GRAMMAR_X3_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_CSS_GRAMMAR_X3_DEF_HPP
|
||||
#define MAPNIK_CSS_GRAMMAR_X3_DEF_HPP
|
||||
|
||||
|
@ -33,9 +32,10 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/fusion/adapted/std_pair.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
|
||||
/*
|
||||
The grammar below is LL(1) (but note that most UA's should not use it directly, since it doesn't express the parsing conventions, only the CSS1 syntax). The format of the productions is optimized for human consumption and some shorthand notation beyond yacc [15] is used:
|
||||
The grammar below is LL(1) (but note that most UA's should not use it directly, since it doesn't express the parsing
|
||||
conventions, only the CSS1 syntax). The format of the productions is optimized for human consumption and some shorthand
|
||||
notation beyond yacc [15] is used:
|
||||
|
||||
* : 0 or more
|
||||
+ : 1 or more
|
||||
|
@ -148,34 +148,36 @@ namespace x3 = boost::spirit::x3;
|
|||
|
||||
namespace css_grammar {
|
||||
|
||||
using x3::lit;
|
||||
using x3::alnum;
|
||||
using x3::alpha;
|
||||
using x3::attr;
|
||||
using x3::char_;
|
||||
using x3::lexeme;
|
||||
using x3::lit;
|
||||
using x3::no_case;
|
||||
using x3::no_skip;
|
||||
using x3::lexeme;
|
||||
using x3::alpha;
|
||||
using x3::alnum;
|
||||
using x3::char_;
|
||||
using x3::raw;
|
||||
using x3::standard::space;
|
||||
|
||||
// import unicode string rule
|
||||
namespace { auto const& css_string = mapnik::json::grammar::unicode_string; }
|
||||
namespace {
|
||||
auto const& css_string = mapnik::json::grammar::unicode_string;
|
||||
}
|
||||
|
||||
auto assign_def = [] (auto const& ctx)
|
||||
{
|
||||
auto assign_def = [](auto const& ctx) {
|
||||
for (auto const& k : std::get<0>(_attr(ctx)))
|
||||
{
|
||||
_val(ctx).emplace(k, std::get<1>(_attr(ctx)));
|
||||
}
|
||||
};
|
||||
|
||||
auto assign_key = [] (auto const& ctx)
|
||||
{
|
||||
auto assign_key = [](auto const& ctx) {
|
||||
_val(ctx).first = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
auto assign_value = [] (auto const& ctx) {_val(ctx).second = std::move(_attr(ctx));};
|
||||
auto assign_value = [](auto const& ctx) {
|
||||
_val(ctx).second = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
// rules
|
||||
x3::rule<class simple_selector_tag, std::string> const simple_selector{"Simple selector"};
|
||||
|
@ -185,9 +187,9 @@ x3::rule<class key_value_tag, css_key_value> const key_value {"CSS Key/Value"};
|
|||
x3::rule<class definition_tag, std::pair<std::vector<std::string>, definition_type>> const definition{"CSS Definition"};
|
||||
|
||||
auto const ident_def = alpha >> *(alnum | char_('-'));
|
||||
auto const simple_selector_def = lexeme[ident >> -((char_('.') | char_('#') | char_(':')) >> ident)]
|
||||
| lexeme[char_('#') >> ident >> -((char_('.') | char_(':')) >> ident)]
|
||||
| lexeme[char_('.') >> ident >> -(char_(':') >> ident)];
|
||||
auto const simple_selector_def = lexeme[ident >> -((char_('.') | char_('#') | char_(':')) >> ident)] |
|
||||
lexeme[char_('#') >> ident >> -((char_('.') | char_(':')) >> ident)] |
|
||||
lexeme[char_('.') >> ident >> -(char_(':') >> ident)];
|
||||
|
||||
auto const selector_def = simple_selector % lit(',');
|
||||
auto const value_def = raw[lexeme[+~char_(";}")]];
|
||||
|
@ -202,8 +204,7 @@ auto const css_classes_def = +lexeme[ident];
|
|||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
BOOST_SPIRIT_DEFINE(
|
||||
ident,
|
||||
BOOST_SPIRIT_DEFINE(ident,
|
||||
css_classes,
|
||||
simple_selector,
|
||||
selector,
|
||||
|
@ -211,12 +212,11 @@ BOOST_SPIRIT_DEFINE(
|
|||
key_value,
|
||||
definition,
|
||||
css_grammar,
|
||||
css_skipper
|
||||
);
|
||||
css_skipper);
|
||||
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
} //css_grammar
|
||||
} //mapnik
|
||||
} // namespace css_grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_CSS_UNIT_VALUE_HPP
|
||||
#define MAPNIK_CSS_UNIT_VALUE_HPP
|
||||
|
||||
|
@ -36,7 +35,7 @@ struct css_unit_value : x3::symbols<double>
|
|||
constexpr static double DPI = 96;
|
||||
css_unit_value()
|
||||
{
|
||||
add
|
||||
add //
|
||||
("px", 1.0) // pixels
|
||||
("pt", DPI / 72.0) // points
|
||||
("pc", DPI / 6.0) // picas
|
||||
|
@ -53,14 +52,14 @@ struct css_absolute_size : x3::symbols<double>
|
|||
constexpr static double EM = 10.0; // 1em == 10px
|
||||
css_absolute_size()
|
||||
{
|
||||
add
|
||||
("xx-small", 0.6 * EM)
|
||||
("x-small", 0.75 * EM)
|
||||
("small", 0.88 * EM)
|
||||
("medium", 1.0 * EM)
|
||||
("large", 1.2 * EM)
|
||||
("x-large", 1.5 * EM)
|
||||
("xx-large", 2.0 * EM)
|
||||
add //
|
||||
("xx-small", 0.6 * EM) //
|
||||
("x-small", 0.75 * EM) //
|
||||
("small", 0.88 * EM) //
|
||||
("medium", 1.0 * EM) //
|
||||
("large", 1.2 * EM) //
|
||||
("x-large", 1.5 * EM) //
|
||||
("xx-large", 2.0 * EM) //
|
||||
;
|
||||
}
|
||||
};
|
||||
|
@ -69,13 +68,12 @@ struct css_relative_size : x3::symbols<double>
|
|||
{
|
||||
css_relative_size()
|
||||
{
|
||||
add
|
||||
("larger", 1.2)
|
||||
("smaller", 0.8)
|
||||
;
|
||||
add //
|
||||
("larger", 1.2) //
|
||||
("smaller", 0.8);
|
||||
}
|
||||
};
|
||||
|
||||
} //mapnik
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -36,8 +36,7 @@ struct csv_white_space_skipper : x3::parser<csv_white_space_skipper>
|
|||
static bool const has_attribute = false;
|
||||
|
||||
template<typename Iterator, typename Context, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last,
|
||||
Context const& context, x3::unused_type, Attribute& ) const
|
||||
bool parse(Iterator& first, Iterator const& last, Context const& context, x3::unused_type, Attribute&) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
if (first != last && *first == ' ')
|
||||
|
@ -64,6 +63,7 @@ csv_line_grammar_type const line = "csv-line";
|
|||
|
||||
BOOST_SPIRIT_DECLARE(csv_line_grammar_type);
|
||||
|
||||
}}
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSV_GRAMMAR_X3_HPP
|
||||
|
|
|
@ -29,30 +29,30 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <mapnik/csv/csv_grammar_x3.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
namespace mapnik {
|
||||
namespace grammar {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
namespace standard = boost::spirit::x3::standard;
|
||||
|
||||
using x3::lit;
|
||||
using x3::lexeme;
|
||||
using standard::char_;
|
||||
using x3::lexeme;
|
||||
using x3::lit;
|
||||
|
||||
struct unesc_char_ : x3::symbols<char>
|
||||
{
|
||||
unesc_char_()
|
||||
{
|
||||
add("\\a", '\a')
|
||||
("\\b", '\b')
|
||||
("\\f", '\f')
|
||||
("\\n", '\n')
|
||||
("\\r", '\r')
|
||||
("\\t", '\t')
|
||||
("\\v", '\v')
|
||||
("\\\\",'\\')
|
||||
("\\\'", '\'')
|
||||
("\\\"", '\"')
|
||||
add("\\a", '\a') //
|
||||
("\\b", '\b') //
|
||||
("\\f", '\f') //
|
||||
("\\n", '\n') //
|
||||
("\\r", '\r') //
|
||||
("\\t", '\t') //
|
||||
("\\v", '\v') //
|
||||
("\\\\", '\\') //
|
||||
("\\\'", '\'') //
|
||||
("\\\"", '\"') //
|
||||
("\"\"", '\"') // double quote
|
||||
;
|
||||
}
|
||||
|
@ -66,8 +66,7 @@ struct literal : x3::parser<literal<T>>
|
|||
static bool const has_attribute = false;
|
||||
|
||||
template<typename Iterator, typename Context, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last,
|
||||
Context const& context, x3::unused_type, Attribute& ) const
|
||||
bool parse(Iterator& first, Iterator const& last, Context const& context, x3::unused_type, Attribute&) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
if (first != last && *first == x3::get<context_tag>(context))
|
||||
|
@ -87,27 +86,18 @@ x3::rule<class csv_column, csv_value> const column("csv-column");
|
|||
x3::rule<class csv_text, csv_value> const text("csv-text");
|
||||
x3::rule<class csc_quoted_text, csv_value> const quoted_text("csv-quoted-text");
|
||||
|
||||
auto const line_def = -lit('\r') > -lit('\n') > lexeme[column] % separator
|
||||
;
|
||||
auto const line_def = -lit('\r') > -lit('\n') > lexeme[column] % separator;
|
||||
|
||||
auto const column_def = quoted_text | *(char_ - separator)
|
||||
;
|
||||
auto const column_def = quoted_text | *(char_ - separator);
|
||||
|
||||
auto const quoted_text_def = quote > text > quote // support unmatched quotes or not (??)
|
||||
;
|
||||
|
||||
auto const text_def = *(unesc_char | (char_ - quote))
|
||||
;
|
||||
auto const text_def = *(unesc_char | (char_ - quote));
|
||||
|
||||
BOOST_SPIRIT_DEFINE (
|
||||
line,
|
||||
column,
|
||||
quoted_text,
|
||||
text
|
||||
);
|
||||
BOOST_SPIRIT_DEFINE(line, column, quoted_text, text);
|
||||
|
||||
} // grammar
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
|
||||
#endif // MAPNIK_CSV_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -32,6 +32,6 @@ using csv_value = std::string;
|
|||
using csv_line = std::vector<csv_value>;
|
||||
using csv_data = std::vector<csv_line>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSV_TYPES_HPP
|
||||
|
|
|
@ -50,10 +50,8 @@ public:
|
|||
|
||||
~datasource_exception() {}
|
||||
|
||||
virtual const char* what() const noexcept
|
||||
{
|
||||
return message_.c_str();
|
||||
}
|
||||
virtual const char* what() const noexcept { return message_.c_str(); }
|
||||
|
||||
private:
|
||||
std::string message_;
|
||||
};
|
||||
|
@ -61,13 +59,11 @@ private:
|
|||
class MAPNIK_DECL datasource : private util::noncopyable
|
||||
{
|
||||
public:
|
||||
enum datasource_t : std::uint8_t {
|
||||
Vector,
|
||||
Raster
|
||||
};
|
||||
enum datasource_t : std::uint8_t { Vector, Raster };
|
||||
|
||||
datasource(parameters const& _params)
|
||||
: params_(_params) {}
|
||||
: params_(_params)
|
||||
{}
|
||||
|
||||
/*!
|
||||
* @brief Get the configuration parameters of the data source.
|
||||
|
@ -76,25 +72,13 @@ public:
|
|||
*
|
||||
* @return The configuration parameters of the data source.
|
||||
*/
|
||||
parameters const& params() const
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
parameters const& params() const { return params_; }
|
||||
|
||||
parameters & params()
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
parameters& params() { return params_; }
|
||||
|
||||
bool operator==(datasource const& rhs) const
|
||||
{
|
||||
return params_ == rhs.params();
|
||||
}
|
||||
bool operator==(datasource const& rhs) const { return params_ == rhs.params(); }
|
||||
|
||||
bool operator!=(datasource const& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
bool operator!=(datasource const& rhs) const { return !(*this == rhs); }
|
||||
|
||||
/*!
|
||||
* @brief Get the type of the datasource
|
||||
|
@ -113,6 +97,7 @@ public:
|
|||
virtual box2d<double> envelope() const = 0;
|
||||
virtual layer_descriptor get_descriptor() const = 0;
|
||||
virtual ~datasource() {}
|
||||
|
||||
protected:
|
||||
parameters params_;
|
||||
};
|
||||
|
@ -124,10 +109,7 @@ using destroy_ds = void (*) (datasource *);
|
|||
class datasource_deleter
|
||||
{
|
||||
public:
|
||||
void operator() (datasource* ds)
|
||||
{
|
||||
delete ds;
|
||||
}
|
||||
void operator()(datasource* ds) { delete ds; }
|
||||
};
|
||||
|
||||
using datasource_ptr = std::shared_ptr<datasource>;
|
||||
|
@ -136,20 +118,11 @@ using datasource_ptr = std::shared_ptr<datasource>;
|
|||
#define DATASOURCE_PLUGIN(classname)
|
||||
#else
|
||||
#define DATASOURCE_PLUGIN(classname) \
|
||||
extern "C" MAPNIK_EXP const char * datasource_name() \
|
||||
{ \
|
||||
return classname::name(); \
|
||||
} \
|
||||
extern "C" MAPNIK_EXP datasource* create(parameters const& params) \
|
||||
{ \
|
||||
return new classname(params); \
|
||||
} \
|
||||
extern "C" MAPNIK_EXP void destroy(datasource *ds) \
|
||||
{ \
|
||||
delete ds; \
|
||||
}
|
||||
extern "C" MAPNIK_EXP const char* datasource_name() { return classname::name(); } \
|
||||
extern "C" MAPNIK_EXP datasource* create(parameters const& params) { return new classname(params); } \
|
||||
extern "C" MAPNIK_EXP void destroy(datasource* ds) { delete ds; }
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_DATASOURCE_HPP
|
||||
|
|
|
@ -41,17 +41,18 @@ class datasource;
|
|||
class parameters;
|
||||
class PluginInfo;
|
||||
|
||||
class MAPNIK_DECL datasource_cache
|
||||
: public singleton<datasource_cache, CreateStatic>,
|
||||
class MAPNIK_DECL datasource_cache : public singleton<datasource_cache, CreateStatic>,
|
||||
private util::noncopyable
|
||||
{
|
||||
friend class CreateStatic<datasource_cache>;
|
||||
|
||||
public:
|
||||
std::vector<std::string> plugin_names();
|
||||
std::string plugin_directories();
|
||||
bool register_datasources(std::string const& path, bool recurse = false);
|
||||
bool register_datasource(std::string const& path);
|
||||
std::shared_ptr<datasource> create(parameters const& params);
|
||||
|
||||
private:
|
||||
datasource_cache();
|
||||
~datasource_cache();
|
||||
|
@ -66,6 +67,6 @@ private:
|
|||
|
||||
extern template class MAPNIK_DECL singleton<datasource_cache, CreateStatic>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_DATASOURCE_CACHE_HPP
|
||||
|
|
|
@ -27,15 +27,8 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
enum datasource_geometry_t : std::uint8_t {
|
||||
Unknown = 0,
|
||||
Point = 1,
|
||||
LineString = 2,
|
||||
Polygon = 3,
|
||||
Collection = 4
|
||||
};
|
||||
enum datasource_geometry_t : std::uint8_t { Unknown = 0, Point = 1, LineString = 2, Polygon = 3, Collection = 4 };
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // MAPNIK_DATASOURCE_GEOMETRY_TYPE_HPP
|
||||
|
|
|
@ -42,35 +42,21 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
|
||||
// Global logger class that holds the configuration of severity, format
|
||||
// and file/console redirection.
|
||||
|
||||
class MAPNIK_DECL logger :
|
||||
public singleton<logger,CreateStatic>,
|
||||
class MAPNIK_DECL logger : public singleton<logger, CreateStatic>,
|
||||
private util::noncopyable
|
||||
{
|
||||
public:
|
||||
enum severity_type
|
||||
{
|
||||
debug = 0,
|
||||
warn = 1,
|
||||
error = 2,
|
||||
none = 3
|
||||
};
|
||||
enum severity_type { debug = 0, warn = 1, error = 2, none = 3 };
|
||||
|
||||
using severity_map = std::unordered_map<std::string, severity_type>;
|
||||
|
||||
// global security level
|
||||
static severity_type get_severity()
|
||||
{
|
||||
return severity_level_;
|
||||
}
|
||||
static severity_type get_severity() { return severity_level_; }
|
||||
|
||||
static void set_severity(severity_type severity_level)
|
||||
{
|
||||
severity_level_ = severity_level;
|
||||
}
|
||||
static void set_severity(severity_type severity_level) { severity_level_ = severity_level; }
|
||||
|
||||
// per object security levels
|
||||
static severity_type get_object_severity(std::string const& object_name)
|
||||
|
@ -89,8 +75,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static void set_object_severity(std::string const& object_name,
|
||||
severity_type const& security_level)
|
||||
static void set_object_severity(std::string const& object_name, severity_type const& security_level)
|
||||
{
|
||||
if (!object_name.empty())
|
||||
{
|
||||
|
@ -111,10 +96,7 @@ public:
|
|||
}
|
||||
|
||||
// format
|
||||
static std::string const& get_format()
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
static std::string const& get_format() { return format_; }
|
||||
|
||||
static void set_format(std::string const& format)
|
||||
{
|
||||
|
@ -151,7 +133,6 @@ private:
|
|||
#endif
|
||||
};
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Default sink, it regulates access to clog
|
||||
|
@ -198,9 +179,7 @@ public:
|
|||
}
|
||||
}
|
||||
#else
|
||||
base_log(const char* /*object_name*/)
|
||||
{
|
||||
}
|
||||
base_log(const char* /*object_name*/) {}
|
||||
#endif
|
||||
|
||||
~base_log()
|
||||
|
@ -217,32 +196,25 @@ public:
|
|||
#ifdef MAPNIK_LOG
|
||||
base_log& operator<<(T const& x)
|
||||
{
|
||||
|
||||
streambuf_ << x;
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
base_log& operator<<(T const& /*x*/)
|
||||
{
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef MAPNIK_LOG
|
||||
inline bool check_severity()
|
||||
{
|
||||
return Severity >= logger::get_object_severity(object_name_);
|
||||
}
|
||||
inline bool check_severity() { return Severity >= logger::get_object_severity(object_name_); }
|
||||
|
||||
typename output_policy::stream_buffer streambuf_;
|
||||
std::string object_name_;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Base log class that always log, regardless of MAPNIK_LOG.
|
||||
// This is used for error reporting that should always log something
|
||||
|
||||
|
@ -282,49 +254,56 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
inline bool check_severity()
|
||||
{
|
||||
return Severity >= logger::get_object_severity(object_name_);
|
||||
}
|
||||
inline bool check_severity() { return Severity >= logger::get_object_severity(object_name_); }
|
||||
|
||||
typename output_policy::stream_buffer streambuf_;
|
||||
std::string object_name_;
|
||||
};
|
||||
|
||||
|
||||
using base_log_debug = base_log<clog_sink, logger::debug>;
|
||||
using base_log_warn = base_log<clog_sink, logger::warn>;
|
||||
using base_log_error = base_log_always<clog_sink, logger::error>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
// real interfaces
|
||||
class MAPNIK_DECL warn : public detail::base_log_warn
|
||||
{
|
||||
public:
|
||||
warn() : detail::base_log_warn() {}
|
||||
warn(const char* object_name) : detail::base_log_warn(object_name) {}
|
||||
warn()
|
||||
: detail::base_log_warn()
|
||||
{}
|
||||
warn(const char* object_name)
|
||||
: detail::base_log_warn(object_name)
|
||||
{}
|
||||
};
|
||||
|
||||
class MAPNIK_DECL debug : public detail::base_log_debug
|
||||
{
|
||||
public:
|
||||
debug() : detail::base_log_debug() {}
|
||||
debug(const char* object_name) : detail::base_log_debug(object_name) {}
|
||||
debug()
|
||||
: detail::base_log_debug()
|
||||
{}
|
||||
debug(const char* object_name)
|
||||
: detail::base_log_debug(object_name)
|
||||
{}
|
||||
};
|
||||
|
||||
class MAPNIK_DECL error : public detail::base_log_error
|
||||
{
|
||||
public:
|
||||
error() : detail::base_log_error() {}
|
||||
error(const char* object_name) : detail::base_log_error(object_name) {}
|
||||
error()
|
||||
: detail::base_log_error()
|
||||
{}
|
||||
error(const char* object_name)
|
||||
: detail::base_log_error(object_name)
|
||||
{}
|
||||
};
|
||||
|
||||
// logging helpers
|
||||
#define MAPNIK_LOG_DEBUG(s) mapnik::debug(#s)
|
||||
#define MAPNIK_LOG_WARN(s) mapnik::warn(#s)
|
||||
#define MAPNIK_LOG_ERROR(s) mapnik::error(#s)
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_DEBUG_HPP
|
||||
|
|
|
@ -39,25 +39,21 @@ namespace mapnik {
|
|||
class illegal_enum_value : public std::exception
|
||||
{
|
||||
public:
|
||||
illegal_enum_value():
|
||||
what_() {}
|
||||
illegal_enum_value()
|
||||
: what_()
|
||||
{}
|
||||
|
||||
illegal_enum_value( std::string const& _what ) :
|
||||
what_( _what )
|
||||
{
|
||||
}
|
||||
illegal_enum_value(std::string const& _what)
|
||||
: what_(_what)
|
||||
{}
|
||||
virtual ~illegal_enum_value() {}
|
||||
|
||||
virtual const char * what() const noexcept
|
||||
{
|
||||
return what_.c_str();
|
||||
}
|
||||
virtual const char* what() const noexcept { return what_.c_str(); }
|
||||
|
||||
protected:
|
||||
std::string what_;
|
||||
};
|
||||
|
||||
|
||||
/** Slim wrapper for enumerations. It creates a new type from a native enum and
|
||||
* a char pointer array. It almost exactly behaves like a native enumeration
|
||||
* type. It supports string conversion through stream operators. This is useful
|
||||
|
@ -138,41 +134,33 @@ protected:
|
|||
*/
|
||||
|
||||
template<typename ENUM, int THE_MAX>
|
||||
class MAPNIK_DECL enumeration {
|
||||
class MAPNIK_DECL enumeration
|
||||
{
|
||||
public:
|
||||
using native_type = ENUM;
|
||||
|
||||
enumeration()
|
||||
: value_() {}
|
||||
: value_()
|
||||
{}
|
||||
|
||||
enumeration(ENUM v)
|
||||
: value_(v) {}
|
||||
: value_(v)
|
||||
{}
|
||||
|
||||
enumeration(enumeration const& other)
|
||||
: value_(other.value_) {}
|
||||
: value_(other.value_)
|
||||
{}
|
||||
|
||||
/** Assignment operator for native enum values. */
|
||||
void operator=(ENUM v)
|
||||
{
|
||||
value_ = v;
|
||||
}
|
||||
void operator=(ENUM v) { value_ = v; }
|
||||
|
||||
/** Assignment operator. */
|
||||
void operator=(enumeration const& other)
|
||||
{
|
||||
value_ = other.value_;
|
||||
}
|
||||
void operator=(enumeration const& other) { value_ = other.value_; }
|
||||
|
||||
/** Conversion operator for native enum values. */
|
||||
operator ENUM() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
operator ENUM() const { return value_; }
|
||||
|
||||
enum Max
|
||||
{
|
||||
MAX = THE_MAX
|
||||
};
|
||||
enum Max { MAX = THE_MAX };
|
||||
|
||||
/** Converts @p str to an enum.
|
||||
* @throw illegal_enum_value @p str is not a legal identifier.
|
||||
|
@ -190,7 +178,6 @@ public:
|
|||
}
|
||||
for (unsigned i = 0; i < THE_MAX; ++i)
|
||||
{
|
||||
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS
|
||||
MAPNIK_DISABLE_WARNING_PRAGMAS
|
||||
|
@ -201,7 +188,10 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
value_ = static_cast<ENUM>(i);
|
||||
if (deprecated)
|
||||
{
|
||||
MAPNIK_LOG_ERROR(enumerations) << "enumeration value (" << str << ") using \"_\" is deprecated and will be removed in Mapnik 4.x, use '" << str_copy << "' instead";
|
||||
MAPNIK_LOG_ERROR(enumerations)
|
||||
<< "enumeration value (" << str
|
||||
<< ") using \"_\" is deprecated and will be removed in Mapnik 4.x, use '" << str_copy
|
||||
<< "' instead";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -210,8 +200,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS
|
||||
MAPNIK_DISABLE_WARNING_PRAGMAS
|
||||
MAPNIK_DISABLE_LONG_LONG
|
||||
throw illegal_enum_value(std::string("Illegal enumeration value '") +
|
||||
str + "' for enum " + our_name_);
|
||||
throw illegal_enum_value(std::string("Illegal enumeration value '") + str + "' for enum " + our_name_);
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
}
|
||||
|
||||
|
@ -227,10 +216,7 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
}
|
||||
|
||||
/** Static helper function to iterate over valid identifiers. */
|
||||
static const char * get_string(unsigned i)
|
||||
{
|
||||
return our_strings_[i];
|
||||
}
|
||||
static const char* get_string(unsigned i) { return our_strings_[i]; }
|
||||
|
||||
/** Performs some simple checks and quits the application if
|
||||
* any error is detected. Tries to print helpful error messages.
|
||||
|
@ -241,16 +227,14 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
{
|
||||
if (our_strings_[i] == 0)
|
||||
{
|
||||
std::cerr << "### FATAL: Not enough strings for enum "
|
||||
<< our_name_ << " defined in file '" << filename
|
||||
std::cerr << "### FATAL: Not enough strings for enum " << our_name_ << " defined in file '" << filename
|
||||
<< "' at line " << line_no;
|
||||
}
|
||||
}
|
||||
if (std::string("") != our_strings_[THE_MAX])
|
||||
{
|
||||
std::cerr << "### FATAL: The string array for enum " << our_name_
|
||||
<< " defined in file '" << filename << "' at line " << line_no
|
||||
<< " has too many items or is not terminated with an "
|
||||
std::cerr << "### FATAL: The string array for enum " << our_name_ << " defined in file '" << filename
|
||||
<< "' at line " << line_no << " has too many items or is not terminated with an "
|
||||
<< "empty string";
|
||||
}
|
||||
return true;
|
||||
|
@ -267,13 +251,12 @@ private:
|
|||
* @relates mapnik::enumeration
|
||||
*/
|
||||
template<class ENUM, int THE_MAX>
|
||||
std::ostream &
|
||||
operator<<(std::ostream & os, const mapnik::enumeration<ENUM, THE_MAX> & e)
|
||||
std::ostream& operator<<(std::ostream& os, const mapnik::enumeration<ENUM, THE_MAX>& e)
|
||||
{
|
||||
return os << e.as_string();
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
} // namespace mapnik
|
||||
|
||||
/** Helper macro.
|
||||
* @relates mapnik::enumeration
|
||||
|
@ -285,9 +268,12 @@ operator<<(std::ostream & os, const mapnik::enumeration<ENUM, THE_MAX> & e)
|
|||
#else
|
||||
#define DEFINE_ENUM(name, e) \
|
||||
using name = enumeration<e, e##_MAX>; \
|
||||
template <> MAPNIK_DECL const char ** name ::our_strings_; \
|
||||
template <> MAPNIK_DECL std::string name ::our_name_; \
|
||||
template <> MAPNIK_DECL bool name ::our_verified_flag_;
|
||||
template<> \
|
||||
MAPNIK_DECL const char** name ::our_strings_; \
|
||||
template<> \
|
||||
MAPNIK_DECL std::string name ::our_name_; \
|
||||
template<> \
|
||||
MAPNIK_DECL bool name ::our_verified_flag_;
|
||||
#endif
|
||||
|
||||
/** Helper macro. Runs the verify_mapnik_enum() method during static initialization.
|
||||
|
@ -295,8 +281,11 @@ operator<<(std::ostream & os, const mapnik::enumeration<ENUM, THE_MAX> & e)
|
|||
*/
|
||||
|
||||
#define IMPLEMENT_ENUM(name, strings) \
|
||||
template <> MAPNIK_DECL const char ** name ::our_strings_ = strings; \
|
||||
template <> MAPNIK_DECL std::string name ::our_name_ = #name; \
|
||||
template <> MAPNIK_DECL bool name ::our_verified_flag_( name ::verify_mapnik_enum(__FILE__, __LINE__));
|
||||
template<> \
|
||||
MAPNIK_DECL const char** name ::our_strings_ = strings; \
|
||||
template<> \
|
||||
MAPNIK_DECL std::string name ::our_name_ = #name; \
|
||||
template<> \
|
||||
MAPNIK_DECL bool name ::our_verified_flag_(name ::verify_mapnik_enum(__FILE__, __LINE__));
|
||||
|
||||
#endif // MAPNIK_ENUMERATION_HPP
|
||||
|
|
|
@ -44,7 +44,8 @@ struct evaluate_expression
|
|||
using value_type = T;
|
||||
|
||||
explicit evaluate_expression(Attributes const& attrs)
|
||||
: attrs_(attrs) {}
|
||||
: attrs_(attrs)
|
||||
{}
|
||||
|
||||
value_type operator()(attribute const&) const
|
||||
{
|
||||
|
@ -68,22 +69,19 @@ struct evaluate_expression
|
|||
|
||||
value_type operator()(binary_node<tags::logical_and> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this, x.left).to_bool())
|
||||
&& (util::apply_visitor(*this, x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) && (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
value_type operator()(binary_node<tags::logical_or> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this,x.left).to_bool())
|
||||
|| (util::apply_visitor(*this,x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) || (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
value_type operator()(binary_node<Tag> const& x) const
|
||||
{
|
||||
typename make_op<Tag>::type operation;
|
||||
return operation(util::apply_visitor(*this, x.left),
|
||||
util::apply_visitor(*this, x.right));
|
||||
return operation(util::apply_visitor(*this, x.left), util::apply_visitor(*this, x.right));
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
|
@ -156,22 +154,19 @@ struct evaluate_expression<T, boost::none_t>
|
|||
|
||||
value_type operator()(binary_node<tags::logical_and> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this, x.left).to_bool())
|
||||
&& (util::apply_visitor(*this, x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) && (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
value_type operator()(binary_node<tags::logical_or> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this,x.left).to_bool())
|
||||
|| (util::apply_visitor(*this,x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) || (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
value_type operator()(binary_node<Tag> const& x) const
|
||||
{
|
||||
typename make_op<Tag>::type operation;
|
||||
return operation(util::apply_visitor(*this, x.left),
|
||||
util::apply_visitor(*this, x.right));
|
||||
return operation(util::apply_visitor(*this, x.left), util::apply_visitor(*this, x.right));
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
|
@ -221,33 +216,39 @@ struct evaluate_expression<T, boost::none_t>
|
|||
struct assign_value
|
||||
{
|
||||
template<typename Attributes>
|
||||
static void apply(symbolizer_base::value_type & val, expression_ptr const& expr, Attributes const& attrs, property_types target )
|
||||
static void apply(symbolizer_base::value_type& val,
|
||||
expression_ptr const& expr,
|
||||
Attributes const& attrs,
|
||||
property_types target)
|
||||
{
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case property_types::target_color:
|
||||
{
|
||||
case property_types::target_color: {
|
||||
// evaluate expression as a string then parse as css color
|
||||
std::string str = util::apply_visitor(mapnik::evaluate_expression<mapnik::value,
|
||||
Attributes>(attrs),*expr).to_string();
|
||||
try { val = parse_color(str); }
|
||||
catch (...) { val = color(0,0,0);}
|
||||
std::string str =
|
||||
util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs), *expr).to_string();
|
||||
try
|
||||
{
|
||||
val = parse_color(str);
|
||||
} catch (...)
|
||||
{
|
||||
val = color(0, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case property_types::target_double:
|
||||
{
|
||||
val = util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs),*expr).to_double();
|
||||
case property_types::target_double: {
|
||||
val =
|
||||
util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs), *expr).to_double();
|
||||
break;
|
||||
}
|
||||
case property_types::target_integer:
|
||||
{
|
||||
val = util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs),*expr).to_int();
|
||||
case property_types::target_integer: {
|
||||
val =
|
||||
util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs), *expr).to_int();
|
||||
break;
|
||||
}
|
||||
case property_types::target_bool:
|
||||
{
|
||||
val = util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs),*expr).to_bool();
|
||||
case property_types::target_bool: {
|
||||
val =
|
||||
util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs), *expr).to_bool();
|
||||
break;
|
||||
}
|
||||
default: // no-op
|
||||
|
@ -256,16 +257,16 @@ struct assign_value
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template<typename T>
|
||||
std::tuple<T, bool> pre_evaluate_expression(expression_ptr const& expr)
|
||||
{
|
||||
try
|
||||
{
|
||||
return std::make_tuple(util::apply_visitor(mapnik::evaluate_expression<T, boost::none_t>(boost::none),*expr), true);
|
||||
}
|
||||
catch (...)
|
||||
return std::make_tuple(util::apply_visitor(mapnik::evaluate_expression<T, boost::none_t>(boost::none), *expr),
|
||||
true);
|
||||
} catch (...)
|
||||
{
|
||||
return std::make_tuple(T(), false);
|
||||
}
|
||||
|
@ -277,8 +278,9 @@ struct evaluate_global_attributes : util::noncopyable
|
|||
struct evaluator
|
||||
{
|
||||
evaluator(symbolizer_base::cont_type::value_type& prop, Attributes const& attrs)
|
||||
: prop_(prop),
|
||||
attrs_(attrs) {}
|
||||
: prop_(prop)
|
||||
, attrs_(attrs)
|
||||
{}
|
||||
|
||||
void operator()(expression_ptr const& expr) const
|
||||
{
|
||||
|
@ -299,7 +301,8 @@ struct evaluate_global_attributes : util::noncopyable
|
|||
struct extract_symbolizer
|
||||
{
|
||||
extract_symbolizer(Attributes const& attrs)
|
||||
: attrs_(attrs) {}
|
||||
: attrs_(attrs)
|
||||
{}
|
||||
|
||||
template<typename Symbolizer>
|
||||
void operator()(Symbolizer& sym) const
|
||||
|
@ -328,6 +331,6 @@ struct evaluate_global_attributes : util::noncopyable
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EVALUATE_GLOBAL_ATTRIBUTES_HPP
|
||||
|
|
|
@ -34,14 +34,13 @@
|
|||
#include <string>
|
||||
#include <set>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
// fwd declare to reduce compile time
|
||||
using expression_ptr = std::shared_ptr<expr_node>;
|
||||
using expression_set = std::set<expression_ptr>;
|
||||
|
||||
MAPNIK_DECL expression_ptr parse_expression(std::string const& wkt);
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_HPP
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
template<typename T0, typename T1, typename T2>
|
||||
struct evaluate
|
||||
|
@ -42,38 +41,21 @@ struct evaluate
|
|||
using variable_type = T2;
|
||||
using result_type = T1; // we need this because automatic result_type deduction fails
|
||||
explicit evaluate(feature_type const& f, variable_type const& v)
|
||||
: feature_(f),
|
||||
vars_(v) {}
|
||||
: feature_(f)
|
||||
, vars_(v)
|
||||
{}
|
||||
|
||||
value_type operator() (value_integer val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
value_type operator()(value_integer val) const { return val; }
|
||||
|
||||
value_type operator() (value_double val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
value_type operator()(value_double val) const { return val; }
|
||||
|
||||
value_type operator() (value_bool val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
value_type operator()(value_bool val) const { return val; }
|
||||
|
||||
value_type operator() (value_null val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
value_type operator()(value_null val) const { return val; }
|
||||
|
||||
value_type operator() (value_unicode_string const& str) const
|
||||
{
|
||||
return str;
|
||||
}
|
||||
value_type operator()(value_unicode_string const& str) const { return str; }
|
||||
|
||||
value_type operator() (attribute const& attr) const
|
||||
{
|
||||
return attr.value<value_type,feature_type>(feature_);
|
||||
}
|
||||
value_type operator()(attribute const& attr) const { return attr.value<value_type, feature_type>(feature_); }
|
||||
|
||||
value_type operator()(global_attribute const& attr) const
|
||||
{
|
||||
|
@ -92,22 +74,19 @@ struct evaluate
|
|||
|
||||
value_type operator()(binary_node<tags::logical_and> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this, x.left).to_bool())
|
||||
&& (util::apply_visitor(*this, x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) && (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
value_type operator()(binary_node<tags::logical_or> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this, x.left).to_bool())
|
||||
|| (util::apply_visitor(*this, x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) || (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
value_type operator()(binary_node<Tag> const& x) const
|
||||
{
|
||||
typename make_op<Tag>::type operation;
|
||||
return operation(util::apply_visitor(*this, x.left),
|
||||
util::apply_visitor(*this, x.right));
|
||||
return operation(util::apply_visitor(*this, x.left), util::apply_visitor(*this, x.right));
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
|
@ -151,6 +130,6 @@ struct evaluate
|
|||
variable_type const& vars_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_EVALUATOR_HPP
|
||||
|
|
|
@ -31,7 +31,8 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/spirit/home/x3.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
namespace mapnik {
|
||||
namespace grammar {
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
using transcoder_type = mapnik::transcoder;
|
||||
|
@ -39,7 +40,6 @@ using transcoder_type = mapnik::transcoder;
|
|||
using transcoder_type = std::reference_wrapper<mapnik::transcoder const>;
|
||||
#endif
|
||||
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
struct transcoder_tag;
|
||||
struct expression_class; // top-most ID
|
||||
|
@ -49,6 +49,7 @@ expression_grammar_type const expression("expression");
|
|||
|
||||
BOOST_SPIRIT_DECLARE(expression_grammar_type);
|
||||
|
||||
}}
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP
|
||||
|
|
|
@ -26,16 +26,16 @@
|
|||
#include <mapnik/expression_grammar_x3.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
namespace mapnik {
|
||||
namespace grammar {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
using iterator_type = std::string::const_iterator;
|
||||
using phrase_context_type = x3::phrase_parse_context<x3::ascii::space_type>::type;
|
||||
// define combined context
|
||||
using context_type = x3::context<transcoder_tag,
|
||||
transcoder_type const,
|
||||
phrase_context_type>;
|
||||
using context_type = x3::context<transcoder_tag, transcoder_type const, phrase_context_type>;
|
||||
|
||||
}}
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_CONFIG_HPP
|
||||
|
|
|
@ -24,47 +24,45 @@
|
|||
#define MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
|
||||
|
||||
#include <mapnik/expression_grammar_x3.hpp>
|
||||
#include <mapnik/json/unicode_string_grammar_x3_def.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/function_call.hpp>
|
||||
#include <mapnik/json/unicode_string_grammar_x3_def.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/home/x3.hpp>
|
||||
#include <boost/spirit/home/x3/support/ast/variant.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
#include <boost/fusion/include/std_pair.hpp>
|
||||
#include <boost/spirit/home/x3.hpp>
|
||||
#include <boost/spirit/home/x3/support/ast/variant.hpp>
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(mapnik::unary_function_call,
|
||||
(mapnik::unary_function_impl, fun)
|
||||
(mapnik::unary_function_call::argument_type, arg))
|
||||
(mapnik::unary_function_impl, fun)(mapnik::unary_function_call::argument_type, arg))
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(mapnik::binary_function_call,
|
||||
(mapnik::binary_function_impl, fun)
|
||||
(mapnik::binary_function_call::argument_type, arg1)
|
||||
(mapnik::binary_function_call::argument_type, arg2))
|
||||
(mapnik::binary_function_impl, fun)(mapnik::binary_function_call::argument_type,
|
||||
arg1)(mapnik::binary_function_call::argument_type, arg2))
|
||||
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
namespace mapnik {
|
||||
namespace grammar {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
namespace ascii = boost::spirit::x3::ascii;
|
||||
using ascii::char_;
|
||||
using ascii::string;
|
||||
using x3::lit;
|
||||
using x3::double_;
|
||||
using x3::int_;
|
||||
using x3::bool_;
|
||||
using x3::_attr;
|
||||
using x3::_val;
|
||||
using x3::no_skip;
|
||||
using x3::lexeme;
|
||||
using x3::no_case;
|
||||
using x3::alpha;
|
||||
using x3::alnum;
|
||||
using x3::alpha;
|
||||
using x3::bool_;
|
||||
using x3::double_;
|
||||
using x3::int_;
|
||||
using x3::lexeme;
|
||||
using x3::lit;
|
||||
using x3::no_case;
|
||||
using x3::no_skip;
|
||||
x3::uint_parser<char, 16, 2, 2> const hex2{};
|
||||
|
||||
namespace {
|
||||
|
@ -77,23 +75,19 @@ namespace mapnik { namespace grammar {
|
|||
return x3::get<transcoder_tag>(ctx);
|
||||
}
|
||||
|
||||
auto append = [](auto const& ctx)
|
||||
{
|
||||
auto append = [](auto const& ctx) {
|
||||
_val(ctx) += _attr(ctx);
|
||||
};
|
||||
|
||||
auto do_assign = [] (auto const& ctx)
|
||||
{
|
||||
auto do_assign = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
auto do_negate = [] (auto const& ctx)
|
||||
{
|
||||
auto do_negate = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(unary_node<mapnik::tags::negate>(_attr(ctx)));
|
||||
};
|
||||
|
||||
auto do_attribute = [] (auto const& ctx)
|
||||
{
|
||||
auto do_attribute = [](auto const& ctx) {
|
||||
auto const& attr = _attr(ctx);
|
||||
if (attr == "mapnik::geometry_type")
|
||||
{
|
||||
|
@ -105,102 +99,84 @@ namespace mapnik { namespace grammar {
|
|||
}
|
||||
};
|
||||
|
||||
auto do_global_attribute = [] (auto const& ctx)
|
||||
{
|
||||
auto do_global_attribute = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(global_attribute(_attr(ctx)));
|
||||
};
|
||||
|
||||
auto do_add = [] (auto const& ctx)
|
||||
{
|
||||
auto do_add = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::plus>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_subt = [] (auto const& ctx)
|
||||
{
|
||||
auto do_subt = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::minus>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_mult = [] (auto const& ctx)
|
||||
{
|
||||
auto do_mult = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mult>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_div = [] (auto const& ctx)
|
||||
{
|
||||
auto do_div = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::div>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_mod = [] (auto const& ctx)
|
||||
{
|
||||
auto do_mod = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mod>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_unicode = [] (auto const& ctx)
|
||||
{
|
||||
auto do_unicode = [](auto const& ctx) {
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
_val(ctx) = std::move(tr.transcode(_attr(ctx).c_str()));
|
||||
};
|
||||
|
||||
auto do_null = [] (auto const& ctx)
|
||||
{
|
||||
auto do_null = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::value_null());
|
||||
};
|
||||
|
||||
auto do_not = [] (auto const& ctx)
|
||||
{
|
||||
auto do_not = [](auto const& ctx) {
|
||||
mapnik::unary_node<mapnik::tags::logical_not> node(_attr(ctx));
|
||||
_val(ctx) = std::move(node);
|
||||
};
|
||||
|
||||
auto do_and = [] (auto const& ctx)
|
||||
{
|
||||
auto do_and = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_and>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_or = [] (auto const& ctx)
|
||||
{
|
||||
auto do_or = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_or>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_equal = [] (auto const& ctx)
|
||||
{
|
||||
auto do_equal = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_not_equal = [] (auto const& ctx)
|
||||
{
|
||||
auto do_not_equal = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::not_equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_less = [] (auto const& ctx)
|
||||
{
|
||||
auto do_less = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_less_equal = [] (auto const& ctx)
|
||||
{
|
||||
auto do_less_equal = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_greater = [] (auto const& ctx)
|
||||
{
|
||||
auto do_greater = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::greater>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_greater_equal = [] (auto const& ctx)
|
||||
{
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::greater_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
auto do_greater_equal = [](auto const& ctx) {
|
||||
_val(ctx) =
|
||||
std::move(mapnik::binary_node<mapnik::tags::greater_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
// regex
|
||||
auto do_regex_match = [] (auto const& ctx)
|
||||
{
|
||||
auto do_regex_match = [](auto const& ctx) {
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
_val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_regex_replace = [] (auto const& ctx)
|
||||
{
|
||||
auto do_regex_replace = [](auto const& ctx) {
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
auto const& pair = _attr(ctx);
|
||||
auto const& pattern = std::get<0>(pair);
|
||||
|
@ -217,9 +193,8 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
boolean_()
|
||||
{
|
||||
add
|
||||
("true", true)
|
||||
("false", false)
|
||||
add("true", true) //
|
||||
("false", false) //
|
||||
;
|
||||
}
|
||||
} boolean;
|
||||
|
@ -228,10 +203,9 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
floating_point_constants()
|
||||
{
|
||||
add
|
||||
("pi", 3.1415926535897932384626433832795)
|
||||
("deg_to_rad",0.017453292519943295769236907684886)
|
||||
("rad_to_deg",57.295779513082320876798154814105)
|
||||
add("pi", 3.1415926535897932384626433832795) //
|
||||
("deg_to_rad", 0.017453292519943295769236907684886) //
|
||||
("rad_to_deg", 57.295779513082320876798154814105) //
|
||||
;
|
||||
}
|
||||
} float_const;
|
||||
|
@ -241,30 +215,27 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
unary_function_types_()
|
||||
{
|
||||
add
|
||||
("sin", sin_impl())
|
||||
("cos", cos_impl())
|
||||
("tan", tan_impl())
|
||||
("atan", atan_impl())
|
||||
("exp", exp_impl())
|
||||
("log", log_impl())
|
||||
("abs", abs_impl())
|
||||
("length",length_impl())
|
||||
add("sin", sin_impl()) //
|
||||
("cos", cos_impl()) //
|
||||
("tan", tan_impl()) //
|
||||
("atan", atan_impl()) //
|
||||
("exp", exp_impl()) //
|
||||
("log", log_impl()) //
|
||||
("abs", abs_impl()) //
|
||||
("length", length_impl()) //
|
||||
;
|
||||
}
|
||||
} unary_func_types;
|
||||
|
||||
|
||||
// binary functions
|
||||
|
||||
struct binary_function_types_ : x3::symbols<binary_function_impl>
|
||||
{
|
||||
binary_function_types_()
|
||||
{
|
||||
add
|
||||
("min", binary_function_impl(min_impl))
|
||||
("max", binary_function_impl(max_impl))
|
||||
("pow", binary_function_impl(pow_impl))
|
||||
add("min", binary_function_impl(min_impl)) //
|
||||
("max", binary_function_impl(max_impl)) //
|
||||
("pow", binary_function_impl(pow_impl)) //
|
||||
;
|
||||
}
|
||||
} binary_func_types;
|
||||
|
@ -274,11 +245,10 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
geometry_types_()
|
||||
{
|
||||
add
|
||||
("point", 1)
|
||||
("linestring", 2)
|
||||
("polygon",3)
|
||||
("collection",4)
|
||||
add("point", 1) //
|
||||
("linestring", 2) //
|
||||
("polygon", 3) //
|
||||
("collection", 4) //
|
||||
;
|
||||
}
|
||||
} geometry_type;
|
||||
|
@ -287,17 +257,16 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
unesc_chars_()
|
||||
{
|
||||
add
|
||||
("\\a", '\a')
|
||||
("\\b", '\b')
|
||||
("\\f", '\f')
|
||||
("\\n", '\n')
|
||||
("\\r", '\r')
|
||||
("\\t", '\t')
|
||||
("\\v", '\v')
|
||||
("\\\\", '\\')
|
||||
("\\\'", '\'')
|
||||
("\\\"", '\"')
|
||||
add("\\a", '\a') //
|
||||
("\\b", '\b') //
|
||||
("\\f", '\f') //
|
||||
("\\n", '\n') //
|
||||
("\\r", '\r') //
|
||||
("\\t", '\t') //
|
||||
("\\v", '\v') //
|
||||
("\\\\", '\\') //
|
||||
("\\\'", '\'') //
|
||||
("\\\"", '\"') //
|
||||
;
|
||||
}
|
||||
} unesc_char;
|
||||
|
@ -309,14 +278,18 @@ namespace mapnik { namespace grammar {
|
|||
x3::rule<class equality_expression, mapnik::expr_node> const equality_expression("equality expression");
|
||||
x3::rule<class relational_expression, mapnik::expr_node> const relational_expression("relational expression");
|
||||
x3::rule<class additive_expression, mapnik::expr_node> const additive_expression("additive expression");
|
||||
x3::rule<class multiplicative_expression, mapnik::expr_node> const multiplicative_expression("multiplicative expression");
|
||||
x3::rule<class unary_func_expression, mapnik::unary_function_call> const unary_func_expression("unary function expression");
|
||||
x3::rule<class binary_func_expression, mapnik::binary_function_call> const binary_func_expression("binary function expression");
|
||||
x3::rule<class multiplicative_expression, mapnik::expr_node> const
|
||||
multiplicative_expression("multiplicative expression");
|
||||
x3::rule<class unary_func_expression, mapnik::unary_function_call> const
|
||||
unary_func_expression("unary function expression");
|
||||
x3::rule<class binary_func_expression, mapnik::binary_function_call> const
|
||||
binary_func_expression("binary function expression");
|
||||
x3::rule<class unary_expression, mapnik::expr_node> const unary_expression("unary expression");
|
||||
x3::rule<class primary_expression, mapnik::expr_node> const primary_expression("primary expression");
|
||||
x3::rule<class regex_match_expression, std::string> const regex_match_expression("regex match expression");
|
||||
x3::rule<class regex_replace_expression, std::pair<std::string,std::string> > const regex_replace_expression("regex replace expression");
|
||||
|
||||
x3::rule<class regex_replace_expression, std::pair<std::string, std::string>> const
|
||||
regex_replace_expression("regex replace expression");
|
||||
// clang-format off
|
||||
// strings
|
||||
auto const single_quoted_string = x3::rule<class single_quoted_string, std::string> {} = lit('\'')
|
||||
>> no_skip[*(unesc_char[append]
|
||||
|
@ -431,9 +404,8 @@ namespace mapnik { namespace grammar {
|
|||
unquoted_ustring[do_unicode]
|
||||
// ^ https://github.com/mapnik/mapnik/pull/3389
|
||||
;
|
||||
|
||||
BOOST_SPIRIT_DEFINE (
|
||||
expression,
|
||||
// clang-format on
|
||||
BOOST_SPIRIT_DEFINE(expression,
|
||||
logical_expression,
|
||||
not_expression,
|
||||
conditional_expression,
|
||||
|
@ -446,9 +418,9 @@ namespace mapnik { namespace grammar {
|
|||
unary_func_expression,
|
||||
binary_func_expression,
|
||||
unary_expression,
|
||||
primary_expression
|
||||
);
|
||||
primary_expression);
|
||||
|
||||
}}
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -34,41 +34,100 @@
|
|||
// stl
|
||||
#include <memory>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
using value_type = mapnik::value;
|
||||
|
||||
template <typename Tag> struct make_op;
|
||||
template <> struct make_op<mapnik::tags::negate> { using type = std::negate<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::plus> { using type = std::plus<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::minus> { using type = std::minus<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::mult> { using type = std::multiplies<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::div> { using type = std::divides<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::mod> { using type = std::modulus<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::less> { using type = std::less<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::less_equal> { using type = std::less_equal<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::greater> { using type = std::greater<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::greater_equal> { using type = std::greater_equal<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::equal_to> { using type = std::equal_to<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::not_equal_to> { using type = std::not_equal_to<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::logical_not> { using type = std::logical_not<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::logical_and> { using type = std::logical_and<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::logical_or> { using type = std::logical_or<value_type>;};
|
||||
template<typename Tag>
|
||||
struct make_op;
|
||||
template<>
|
||||
struct make_op<mapnik::tags::negate>
|
||||
{
|
||||
using type = std::negate<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::plus>
|
||||
{
|
||||
using type = std::plus<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::minus>
|
||||
{
|
||||
using type = std::minus<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::mult>
|
||||
{
|
||||
using type = std::multiplies<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::div>
|
||||
{
|
||||
using type = std::divides<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::mod>
|
||||
{
|
||||
using type = std::modulus<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::less>
|
||||
{
|
||||
using type = std::less<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::less_equal>
|
||||
{
|
||||
using type = std::less_equal<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::greater>
|
||||
{
|
||||
using type = std::greater<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::greater_equal>
|
||||
{
|
||||
using type = std::greater_equal<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::equal_to>
|
||||
{
|
||||
using type = std::equal_to<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::not_equal_to>
|
||||
{
|
||||
using type = std::not_equal_to<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::logical_not>
|
||||
{
|
||||
using type = std::logical_not<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::logical_and>
|
||||
{
|
||||
using type = std::logical_and<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::logical_or>
|
||||
{
|
||||
using type = std::logical_or<value_type>;
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct unary_node
|
||||
{
|
||||
unary_node(expr_node&& a)
|
||||
: expr(std::move(a)) {}
|
||||
: expr(std::move(a))
|
||||
{}
|
||||
|
||||
unary_node(expr_node const& a)
|
||||
: expr(a) {}
|
||||
: expr(a)
|
||||
{}
|
||||
|
||||
static const char* type()
|
||||
{
|
||||
return Tag::str();
|
||||
}
|
||||
static const char* type() { return Tag::str(); }
|
||||
|
||||
expr_node expr;
|
||||
};
|
||||
|
@ -77,17 +136,16 @@ template <typename Tag>
|
|||
struct binary_node
|
||||
{
|
||||
binary_node(expr_node&& a, expr_node&& b)
|
||||
: left(std::move(a)),
|
||||
right(std::move(b)) {}
|
||||
: left(std::move(a))
|
||||
, right(std::move(b))
|
||||
{}
|
||||
|
||||
binary_node(expr_node const& a, expr_node const& b)
|
||||
: left(a),
|
||||
right(b) {}
|
||||
: left(a)
|
||||
, right(b)
|
||||
{}
|
||||
|
||||
static const char* type()
|
||||
{
|
||||
return Tag::str();
|
||||
}
|
||||
static const char* type() { return Tag::str(); }
|
||||
expr_node left, right;
|
||||
};
|
||||
|
||||
|
@ -96,7 +154,9 @@ struct unary_function_call
|
|||
using argument_type = expr_node;
|
||||
unary_function_call() = default;
|
||||
unary_function_call(unary_function_impl _fun, argument_type const& _arg)
|
||||
: fun(_fun), arg(_arg) {}
|
||||
: fun(_fun)
|
||||
, arg(_arg)
|
||||
{}
|
||||
|
||||
unary_function_impl fun;
|
||||
argument_type arg;
|
||||
|
@ -107,7 +167,10 @@ struct binary_function_call
|
|||
using argument_type = expr_node;
|
||||
binary_function_call() = default;
|
||||
binary_function_call(binary_function_impl _fun, argument_type const& _arg1, argument_type const& _arg2)
|
||||
: fun(_fun), arg1(_arg1), arg2(_arg2) {}
|
||||
: fun(_fun)
|
||||
, arg1(_arg1)
|
||||
, arg2(_arg2)
|
||||
{}
|
||||
binary_function_impl fun;
|
||||
argument_type arg1;
|
||||
argument_type arg2;
|
||||
|
@ -137,7 +200,6 @@ struct MAPNIK_DECL regex_replace_node
|
|||
std::shared_ptr<_regex_replace_impl> impl_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_NODE_HPP
|
||||
|
|
|
@ -28,136 +28,90 @@
|
|||
#include <mapnik/value/types.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
namespace tags {
|
||||
struct negate
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "-";
|
||||
}
|
||||
static const char* str() { return "-"; }
|
||||
};
|
||||
|
||||
struct plus
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "+";
|
||||
}
|
||||
static const char* str() { return "+"; }
|
||||
};
|
||||
|
||||
struct minus
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "-";
|
||||
}
|
||||
static const char* str() { return "-"; }
|
||||
};
|
||||
|
||||
struct mult
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "*";
|
||||
}
|
||||
static const char* str() { return "*"; }
|
||||
};
|
||||
|
||||
struct div
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
static const char* str() { return "/"; }
|
||||
};
|
||||
|
||||
|
||||
struct mod
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
static const char* str() { return "%"; }
|
||||
};
|
||||
|
||||
struct less
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "<";
|
||||
}
|
||||
static const char* str() { return "<"; }
|
||||
};
|
||||
|
||||
struct less_equal
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "<=";
|
||||
}
|
||||
static const char* str() { return "<="; }
|
||||
};
|
||||
|
||||
struct greater
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return ">";
|
||||
}
|
||||
static const char* str() { return ">"; }
|
||||
};
|
||||
|
||||
struct greater_equal
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return ">=";
|
||||
}
|
||||
static const char* str() { return ">="; }
|
||||
};
|
||||
|
||||
struct equal_to
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "=";
|
||||
}
|
||||
static const char* str() { return "="; }
|
||||
};
|
||||
|
||||
struct not_equal_to
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "!=";
|
||||
}
|
||||
static const char* str() { return "!="; }
|
||||
};
|
||||
|
||||
struct logical_not
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "not ";
|
||||
}
|
||||
static const char* str() { return "not "; }
|
||||
};
|
||||
|
||||
struct logical_and
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return " and ";
|
||||
}
|
||||
static const char* str() { return " and "; }
|
||||
};
|
||||
|
||||
struct logical_or
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return " or ";
|
||||
}
|
||||
static const char* str() { return " or "; }
|
||||
};
|
||||
|
||||
} // end operation tags
|
||||
} // namespace tags
|
||||
|
||||
|
||||
template <typename Tag> struct binary_node;
|
||||
template <typename Tag> struct unary_node;
|
||||
template<typename Tag>
|
||||
struct binary_node;
|
||||
template<typename Tag>
|
||||
struct unary_node;
|
||||
struct regex_match_node;
|
||||
struct regex_replace_node;
|
||||
struct attribute;
|
||||
|
@ -166,8 +120,7 @@ struct geometry_type_attribute;
|
|||
struct unary_function_call;
|
||||
struct binary_function_call;
|
||||
|
||||
using expr_node = util::variant<
|
||||
value_null,
|
||||
using expr_node = util::variant<value_null,
|
||||
value_bool,
|
||||
value_integer,
|
||||
value_double,
|
||||
|
@ -193,10 +146,8 @@ util::recursive_wrapper<binary_node<mapnik::tags::logical_or> >,
|
|||
util::recursive_wrapper<regex_match_node>,
|
||||
util::recursive_wrapper<regex_replace_node>,
|
||||
util::recursive_wrapper<unary_function_call>,
|
||||
util::recursive_wrapper<binary_function_call>
|
||||
>;
|
||||
|
||||
}
|
||||
util::recursive_wrapper<binary_function_call>>;
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_NODE_HPP
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
MAPNIK_DECL std::string to_expression_string(expr_node const& node);
|
||||
|
||||
/*
|
||||
|
@ -63,6 +62,6 @@ std::string to_expression_string(std::shared_ptr<T> const& expr_node_ptr)
|
|||
// compile error intended here; comment on the next line shows in clang output
|
||||
return expr_node_ptr; // to_expression_string() called with pointer argument
|
||||
}
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_STRING_HPP
|
||||
|
|
|
@ -38,11 +38,9 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
// stl
|
||||
#include <cmath>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
namespace detail {
|
||||
|
||||
namespace msm = boost::msm;
|
||||
namespace mpl = boost::mpl;
|
||||
|
@ -55,26 +53,37 @@ T extend(T const & v1, T const & v2, double length)
|
|||
double dy = v2.y - v1.y;
|
||||
double l12 = std::sqrt(dx * dx + dy * dy);
|
||||
double coef = 1.0 + length / l12;
|
||||
return vertex2d(v1.x + dx * coef,
|
||||
v1.y + dy * coef, v2.cmd);
|
||||
return vertex2d(v1.x + dx * coef, v1.y + dy * coef, v2.cmd);
|
||||
}
|
||||
|
||||
namespace events
|
||||
{
|
||||
namespace events {
|
||||
struct vertex_event
|
||||
{
|
||||
vertex_event(vertex2d const & vertex) : vertex(vertex) { }
|
||||
vertex_event(vertex2d const& vertex)
|
||||
: vertex(vertex)
|
||||
{}
|
||||
vertex2d const& vertex;
|
||||
};
|
||||
|
||||
struct move_to : vertex_event { using vertex_event::vertex_event; };
|
||||
struct line_to : vertex_event { using vertex_event::vertex_event; };
|
||||
struct close : vertex_event { using vertex_event::vertex_event; };
|
||||
struct end : vertex_event { using vertex_event::vertex_event; };
|
||||
}
|
||||
|
||||
namespace actions
|
||||
struct move_to : vertex_event
|
||||
{
|
||||
using vertex_event::vertex_event;
|
||||
};
|
||||
struct line_to : vertex_event
|
||||
{
|
||||
using vertex_event::vertex_event;
|
||||
};
|
||||
struct close : vertex_event
|
||||
{
|
||||
using vertex_event::vertex_event;
|
||||
};
|
||||
struct end : vertex_event
|
||||
{
|
||||
using vertex_event::vertex_event;
|
||||
};
|
||||
} // namespace events
|
||||
|
||||
namespace actions {
|
||||
struct store
|
||||
{
|
||||
template<class FSM, class EVT, class SourceState, class TargetState>
|
||||
|
@ -126,20 +135,25 @@ namespace actions
|
|||
m.v1 = e.vertex;
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace actions
|
||||
|
||||
struct extender_def : public msm::front::state_machine_def<extender_def>
|
||||
{
|
||||
using no_exception_thrown = int;
|
||||
using no_message_queue = int;
|
||||
|
||||
struct initial : public msm::front::state<> { };
|
||||
struct vertex_one : public msm::front::state<> { };
|
||||
struct vertex_two : public msm::front::state<> { };
|
||||
struct end : public msm::front::state<> { };
|
||||
struct initial : public msm::front::state<>
|
||||
{};
|
||||
struct vertex_one : public msm::front::state<>
|
||||
{};
|
||||
struct vertex_two : public msm::front::state<>
|
||||
{};
|
||||
struct end : public msm::front::state<>
|
||||
{};
|
||||
|
||||
using initial_state = initial;
|
||||
|
||||
// clang-format off
|
||||
struct transition_table : mpl::vector<
|
||||
// Start Event Next Action Guard
|
||||
// +------------+-----------------+------------+--------------------+------+
|
||||
|
@ -157,11 +171,11 @@ struct extender_def : public msm::front::state_machine_def<extender_def>
|
|||
Row < vertex_two , events::end , end , actions::output_end >,
|
||||
Row < end , events::end , end , actions::output >
|
||||
> {};
|
||||
// clang-format on
|
||||
|
||||
extender_def(double extend_length)
|
||||
: extend_length(extend_length)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
boost::optional<vertex2d> output;
|
||||
vertex2d v1, v2;
|
||||
|
@ -170,7 +184,7 @@ struct extender_def : public msm::front::state_machine_def<extender_def>
|
|||
|
||||
using extender = msm::back::state_machine<extender_def>;
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename Geometry>
|
||||
struct extend_converter
|
||||
|
@ -180,13 +194,11 @@ struct extend_converter
|
|||
{}
|
||||
|
||||
extend_converter(Geometry& geom, double extend)
|
||||
: geom_(geom), extender_(extend)
|
||||
: geom_(geom)
|
||||
, extender_(extend)
|
||||
{}
|
||||
|
||||
void set_extend(double extend)
|
||||
{
|
||||
extender_.extend_length = extend;
|
||||
}
|
||||
void set_extend(double extend) { extender_.extend_length = extend; }
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
|
@ -229,6 +241,6 @@ private:
|
|||
detail::extender extender_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXTEND_CONVERTER_HPP
|
||||
|
|
|
@ -32,19 +32,14 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
template
|
||||
<
|
||||
typename product_type,
|
||||
typename key_type,
|
||||
typename ...Args >
|
||||
class factory : public singleton<factory <product_type,
|
||||
key_type,
|
||||
Args...> >
|
||||
template<typename product_type, typename key_type, typename... Args>
|
||||
class factory : public singleton<factory<product_type, key_type, Args...>>
|
||||
{
|
||||
private:
|
||||
using product_creator = product_type* (*)(Args...);
|
||||
using product_map = std::map<key_type, product_creator>;
|
||||
product_map map_;
|
||||
|
||||
public:
|
||||
|
||||
bool register_product(key_type const& key, product_creator creator)
|
||||
|
@ -52,10 +47,7 @@ public:
|
|||
return map_.insert(typename product_map::value_type(key, creator)).second;
|
||||
}
|
||||
|
||||
bool unregister_product(const key_type& key)
|
||||
{
|
||||
return map_.erase(key)==1;
|
||||
}
|
||||
bool unregister_product(const key_type& key) { return map_.erase(key) == 1; }
|
||||
|
||||
product_type* create_object(key_type const& key, Args... args)
|
||||
{
|
||||
|
@ -67,6 +59,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FACTORY_HPP
|
||||
|
|
|
@ -55,6 +55,7 @@ class context : private util::noncopyable
|
|||
|
||||
{
|
||||
friend class feature_impl;
|
||||
|
||||
public:
|
||||
using map_type = T;
|
||||
using value_type = typename map_type::value_type;
|
||||
|
@ -65,7 +66,8 @@ public:
|
|||
using const_iterator = typename map_type::const_iterator;
|
||||
|
||||
context()
|
||||
: mapping_() {}
|
||||
: mapping_()
|
||||
{}
|
||||
|
||||
inline size_type push(key_type const& name)
|
||||
{
|
||||
|
@ -74,10 +76,7 @@ public:
|
|||
return index;
|
||||
}
|
||||
|
||||
inline void add(key_type const& name, size_type index)
|
||||
{
|
||||
mapping_.emplace(name, index);
|
||||
}
|
||||
inline void add(key_type const& name, size_type index) { mapping_.emplace(name, index); }
|
||||
|
||||
inline size_type size() const { return mapping_.size(); }
|
||||
inline const_iterator begin() const { return mapping_.begin(); }
|
||||
|
@ -95,6 +94,7 @@ static const value default_feature_value{};
|
|||
class MAPNIK_DECL feature_impl : private util::noncopyable
|
||||
{
|
||||
friend class feature_kv_iterator;
|
||||
|
||||
public:
|
||||
|
||||
using value_type = mapnik::value;
|
||||
|
@ -102,11 +102,12 @@ public:
|
|||
using iterator = feature_kv_iterator;
|
||||
|
||||
feature_impl(context_ptr const& ctx, mapnik::value_integer _id)
|
||||
: id_(_id),
|
||||
ctx_(ctx),
|
||||
data_(ctx_->mapping_.size()),
|
||||
geom_(geometry::geometry_empty()),
|
||||
raster_() {}
|
||||
: id_(_id)
|
||||
, ctx_(ctx)
|
||||
, data_(ctx_->mapping_.size())
|
||||
, geom_(geometry::geometry_empty())
|
||||
, raster_()
|
||||
{}
|
||||
|
||||
inline mapnik::value_integer id() const { return id_; }
|
||||
inline void set_id(mapnik::value_integer _id) { id_ = _id; }
|
||||
|
@ -125,8 +126,7 @@ public:
|
|||
inline void put(context_type::key_type const& key, value&& val)
|
||||
{
|
||||
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
|
||||
if (itr != ctx_->mapping_.end()
|
||||
&& itr->second < data_.size())
|
||||
if (itr != ctx_->mapping_.end() && itr->second < data_.size())
|
||||
{
|
||||
data_[itr->second] = std::move(val);
|
||||
}
|
||||
|
@ -139,8 +139,7 @@ public:
|
|||
inline void put_new(context_type::key_type const& key, value&& val)
|
||||
{
|
||||
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
|
||||
if (itr != ctx_->mapping_.end()
|
||||
&& itr->second < data_.size())
|
||||
if (itr != ctx_->mapping_.end() && itr->second < data_.size())
|
||||
{
|
||||
data_[itr->second] = std::move(val);
|
||||
}
|
||||
|
@ -152,10 +151,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
inline bool has_key(context_type::key_type const& key) const
|
||||
{
|
||||
return (ctx_->mapping_.count(key) == 1);
|
||||
}
|
||||
inline bool has_key(context_type::key_type const& key) const { return (ctx_->mapping_.count(key) == 1); }
|
||||
|
||||
inline value_type const& get(context_type::key_type const& key) const
|
||||
{
|
||||
|
@ -173,70 +169,31 @@ public:
|
|||
return default_feature_value;
|
||||
}
|
||||
|
||||
inline std::size_t size() const
|
||||
{
|
||||
return data_.size();
|
||||
}
|
||||
inline std::size_t size() const { return data_.size(); }
|
||||
|
||||
inline cont_type const& get_data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
inline cont_type const& get_data() const { return data_; }
|
||||
|
||||
inline void set_data(cont_type const& data)
|
||||
{
|
||||
data_ = data;
|
||||
}
|
||||
inline void set_data(cont_type const& data) { data_ = data; }
|
||||
|
||||
inline context_ptr context() const
|
||||
{
|
||||
return ctx_;
|
||||
}
|
||||
inline context_ptr context() const { return ctx_; }
|
||||
|
||||
inline void set_geometry(geometry::geometry<double> && geom)
|
||||
{
|
||||
geom_ = std::move(geom);
|
||||
}
|
||||
inline void set_geometry(geometry::geometry<double>&& geom) { geom_ = std::move(geom); }
|
||||
|
||||
inline void set_geometry_copy(geometry::geometry<double> const& geom)
|
||||
{
|
||||
geom_ = geom;
|
||||
}
|
||||
inline void set_geometry_copy(geometry::geometry<double> const& geom) { geom_ = geom; }
|
||||
|
||||
inline geometry::geometry<double> const& get_geometry() const
|
||||
{
|
||||
return geom_;
|
||||
}
|
||||
inline geometry::geometry<double> const& get_geometry() const { return geom_; }
|
||||
|
||||
inline geometry::geometry<double> & get_geometry()
|
||||
{
|
||||
return geom_;
|
||||
}
|
||||
inline geometry::geometry<double>& get_geometry() { return geom_; }
|
||||
|
||||
inline box2d<double> envelope() const
|
||||
{
|
||||
return mapnik::geometry::envelope(geom_);
|
||||
}
|
||||
inline box2d<double> envelope() const { return mapnik::geometry::envelope(geom_); }
|
||||
|
||||
inline raster_ptr const& get_raster() const
|
||||
{
|
||||
return raster_;
|
||||
}
|
||||
inline raster_ptr const& get_raster() const { return raster_; }
|
||||
|
||||
inline void set_raster(raster_ptr const& raster)
|
||||
{
|
||||
raster_ = raster;
|
||||
}
|
||||
inline void set_raster(raster_ptr const& raster) { raster_ = raster; }
|
||||
|
||||
inline feature_kv_iterator begin() const
|
||||
{
|
||||
return feature_kv_iterator(*this,true);
|
||||
}
|
||||
inline feature_kv_iterator begin() const { return feature_kv_iterator(*this, true); }
|
||||
|
||||
inline feature_kv_iterator end() const
|
||||
{
|
||||
return feature_kv_iterator(*this);
|
||||
}
|
||||
inline feature_kv_iterator end() const { return feature_kv_iterator(*this); }
|
||||
|
||||
std::string to_string() const
|
||||
{
|
||||
|
@ -269,7 +226,6 @@ private:
|
|||
raster_ptr raster_;
|
||||
};
|
||||
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, feature_impl const& f)
|
||||
{
|
||||
out << f.to_string();
|
||||
|
@ -278,6 +234,6 @@ inline std::ostream& operator<< (std::ostream & out,feature_impl const& f)
|
|||
|
||||
using feature_ptr = std::shared_ptr<feature_impl>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FEATURE_HPP
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
// boost
|
||||
//#include <boost/pool/pool_alloc.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
struct feature_factory
|
||||
{
|
||||
static std::shared_ptr<feature_impl> create(context_ptr const& ctx, mapnik::value_integer fid)
|
||||
|
@ -41,6 +40,6 @@ struct feature_factory
|
|||
return std::make_shared<feature_impl>(ctx, fid);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FEATURE_FACTORY_HPP
|
||||
|
|
|
@ -45,14 +45,14 @@ namespace mapnik {
|
|||
|
||||
class feature_impl;
|
||||
|
||||
class MAPNIK_DECL feature_kv_iterator :
|
||||
public boost::iterator_facade<feature_kv_iterator,
|
||||
class MAPNIK_DECL feature_kv_iterator : public boost::iterator_facade<feature_kv_iterator,
|
||||
std::tuple<std::string, value> const,
|
||||
boost::forward_traversal_tag>
|
||||
{
|
||||
public:
|
||||
using value_type = std::tuple<std::string, value>;
|
||||
feature_kv_iterator(feature_impl const& f, bool begin = false);
|
||||
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
void increment();
|
||||
|
@ -65,7 +65,6 @@ private:
|
|||
feature_impl const& f_;
|
||||
std::map<std::string, std::size_t>::const_iterator itr_;
|
||||
mutable value_type kv_;
|
||||
|
||||
};
|
||||
|
||||
struct value_not_null
|
||||
|
@ -78,6 +77,6 @@ struct value_not_null
|
|||
|
||||
using feature_kv_iterator2 = boost::filter_iterator<value_not_null, feature_kv_iterator>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FEATURE_KV_ITERATOR_HPP
|
||||
|
|
|
@ -32,83 +32,58 @@
|
|||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
class layer_descriptor
|
||||
{
|
||||
public:
|
||||
layer_descriptor(std::string const& name, std::string const& encoding)
|
||||
: name_(name),
|
||||
encoding_(encoding),
|
||||
descriptors_(),
|
||||
extra_params_() {}
|
||||
: name_(name)
|
||||
, encoding_(encoding)
|
||||
, descriptors_()
|
||||
, extra_params_()
|
||||
{}
|
||||
|
||||
layer_descriptor(layer_descriptor const& other)
|
||||
: name_(other.name_),
|
||||
encoding_(other.encoding_),
|
||||
descriptors_(other.descriptors_),
|
||||
extra_params_(other.extra_params_) {}
|
||||
: name_(other.name_)
|
||||
, encoding_(other.encoding_)
|
||||
, descriptors_(other.descriptors_)
|
||||
, extra_params_(other.extra_params_)
|
||||
{}
|
||||
|
||||
void set_name(std::string const& name)
|
||||
{
|
||||
name_ = name;
|
||||
}
|
||||
void set_name(std::string const& name) { name_ = name; }
|
||||
|
||||
std::string const& get_name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
std::string const& get_name() const { return name_; }
|
||||
|
||||
void set_encoding(std::string const& encoding)
|
||||
{
|
||||
encoding_ = encoding;
|
||||
}
|
||||
void set_encoding(std::string const& encoding) { encoding_ = encoding; }
|
||||
|
||||
std::string const& get_encoding() const
|
||||
{
|
||||
return encoding_;
|
||||
}
|
||||
std::string const& get_encoding() const { return encoding_; }
|
||||
|
||||
void add_descriptor(attribute_descriptor const& desc)
|
||||
{
|
||||
descriptors_.push_back(desc);
|
||||
}
|
||||
void add_descriptor(attribute_descriptor const& desc) { descriptors_.push_back(desc); }
|
||||
|
||||
std::vector<attribute_descriptor> const& get_descriptors() const
|
||||
{
|
||||
return descriptors_;
|
||||
}
|
||||
std::vector<attribute_descriptor> const& get_descriptors() const { return descriptors_; }
|
||||
|
||||
std::vector<attribute_descriptor>& get_descriptors()
|
||||
{
|
||||
return descriptors_;
|
||||
}
|
||||
std::vector<attribute_descriptor>& get_descriptors() { return descriptors_; }
|
||||
|
||||
parameters const& get_extra_parameters() const
|
||||
{
|
||||
return extra_params_;
|
||||
}
|
||||
parameters const& get_extra_parameters() const { return extra_params_; }
|
||||
|
||||
parameters& get_extra_parameters()
|
||||
{
|
||||
return extra_params_;
|
||||
}
|
||||
parameters& get_extra_parameters() { return extra_params_; }
|
||||
|
||||
bool has_name(std::string const& name) const
|
||||
{
|
||||
auto result = std::find_if(std::begin(descriptors_), std::end(descriptors_),
|
||||
auto result = std::find_if(std::begin(descriptors_),
|
||||
std::end(descriptors_),
|
||||
[&name](attribute_descriptor const& desc) { return name == desc.get_name(); });
|
||||
return result != std::end(descriptors_);
|
||||
}
|
||||
void order_by_name()
|
||||
{
|
||||
std::sort(std::begin(descriptors_), std::end(descriptors_),
|
||||
[](attribute_descriptor const& d0, attribute_descriptor const& d1)
|
||||
{
|
||||
return d0.get_name() < d1.get_name();
|
||||
});
|
||||
std::sort(
|
||||
std::begin(descriptors_),
|
||||
std::end(descriptors_),
|
||||
[](attribute_descriptor const& d0, attribute_descriptor const& d1) { return d0.get_name() < d1.get_name(); });
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
std::string encoding_;
|
||||
|
@ -116,6 +91,6 @@ private:
|
|||
parameters extra_params_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FEATURE_LAYER_DESC_HPP
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
class Map;
|
||||
class layer;
|
||||
|
@ -45,18 +44,13 @@ class feature_type_style;
|
|||
class rule_cache;
|
||||
struct layer_rendering_material;
|
||||
|
||||
enum eAttributeCollectionPolicy
|
||||
{
|
||||
DEFAULT = 0,
|
||||
COLLECT_ALL = 1
|
||||
};
|
||||
enum eAttributeCollectionPolicy { DEFAULT = 0, COLLECT_ALL = 1 };
|
||||
|
||||
template<typename Processor>
|
||||
class feature_style_processor
|
||||
{
|
||||
public:
|
||||
explicit feature_style_processor(Map const& m,
|
||||
double scale_factor = 1.0);
|
||||
explicit feature_style_processor(Map const& m, double scale_factor = 1.0);
|
||||
|
||||
/*!
|
||||
* \brief apply renderer to all map layers.
|
||||
|
@ -66,9 +60,7 @@ public:
|
|||
/*!
|
||||
* \brief apply renderer to a single layer, providing pre-populated set of query attribute names.
|
||||
*/
|
||||
void apply(mapnik::layer const& lyr,
|
||||
std::set<std::string>& names,
|
||||
double scale_denom_override=0.0);
|
||||
void apply(mapnik::layer const& lyr, std::set<std::string>& names, double scale_denom_override = 0.0);
|
||||
|
||||
/*!
|
||||
* \brief render a layer given a projection and scale.
|
||||
|
@ -122,6 +114,6 @@ private:
|
|||
|
||||
Map const& m_;
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FEATURE_STYLE_PROCESSOR_HPP
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
|
||||
class IProcessorContext {
|
||||
class IProcessorContext
|
||||
{
|
||||
public:
|
||||
virtual ~IProcessorContext() {}
|
||||
};
|
||||
|
@ -39,6 +39,6 @@ public:
|
|||
using processor_context_ptr = std::shared_ptr<IProcessorContext>;
|
||||
using feature_style_context_map = std::map<std::string, processor_context_ptr>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // FEATURE_STYLE_PROCESSOR_CONTEXT_HPP
|
||||
|
|
|
@ -50,8 +50,7 @@
|
|||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
// Store material for layer rendering in a two step process
|
||||
struct layer_rendering_material
|
||||
|
@ -66,9 +65,10 @@ struct layer_rendering_material
|
|||
std::vector<layer_rendering_material> materials_;
|
||||
|
||||
layer_rendering_material(layer const& lay, projection const& dest)
|
||||
: lay_(lay),
|
||||
proj0_(dest),
|
||||
proj1_(lay.srs(), true) {}
|
||||
: lay_(lay)
|
||||
, proj0_(dest)
|
||||
, proj1_(lay.srs(), true)
|
||||
{}
|
||||
|
||||
layer_rendering_material(layer_rendering_material&& rhs) = default;
|
||||
};
|
||||
|
@ -197,16 +197,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay,
|
|||
feature_style_context_map ctx_map;
|
||||
layer_rendering_material mat(lay, proj0);
|
||||
|
||||
prepare_layer(mat,
|
||||
ctx_map,
|
||||
p,
|
||||
scale,
|
||||
scale_denom,
|
||||
width,
|
||||
height,
|
||||
extent,
|
||||
buffer_size,
|
||||
names);
|
||||
prepare_layer(mat, ctx_map, p, scale, scale_denom, width, height, extent, buffer_size, names);
|
||||
|
||||
prepare_layers(mat, lay.layers(), ctx_map, p, scale_denom);
|
||||
|
||||
|
@ -240,16 +231,14 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
|
|||
std::size_t num_styles = style_names.size();
|
||||
if (num_styles == 0)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(feature_style_processor)
|
||||
<< "feature_style_processor: No style for layer=" << lay.name();
|
||||
MAPNIK_LOG_DEBUG(feature_style_processor) << "feature_style_processor: No style for layer=" << lay.name();
|
||||
return;
|
||||
}
|
||||
|
||||
mapnik::datasource_ptr ds = lay.datasource();
|
||||
if (!ds)
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(feature_style_processor)
|
||||
<< "feature_style_processor: No datasource for layer=" << lay.name();
|
||||
MAPNIK_LOG_DEBUG(feature_style_processor) << "feature_style_processor: No datasource for layer=" << lay.name();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -295,15 +284,15 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
|
|||
early_return = true;
|
||||
}
|
||||
// next try intersection of layer extent back projected into map srs
|
||||
else if (proj_trans_ptr->backward(layer_ext, PROJ_ENVELOPE_POINTS) && buffered_query_ext_map_srs.intersects(layer_ext))
|
||||
else if (proj_trans_ptr->backward(layer_ext, PROJ_ENVELOPE_POINTS) &&
|
||||
buffered_query_ext_map_srs.intersects(layer_ext))
|
||||
{
|
||||
layer_ext.clip(buffered_query_ext_map_srs);
|
||||
// forward project layer extent back into native projection
|
||||
if (!proj_trans_ptr->forward(layer_ext, PROJ_ENVELOPE_POINTS))
|
||||
{
|
||||
MAPNIK_LOG_ERROR(feature_style_processor)
|
||||
<< "feature_style_processor: Layer=" << lay.name()
|
||||
<< " extent=" << layer_ext << " in map projection "
|
||||
<< "feature_style_processor: Layer=" << lay.name() << " extent=" << layer_ext << " in map projection "
|
||||
<< " did not reproject properly back to layer projection";
|
||||
}
|
||||
}
|
||||
|
@ -374,8 +363,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
|
|||
boost::optional<feature_type_style const&> style = m_.find_style(style_name);
|
||||
if (!style)
|
||||
{
|
||||
MAPNIK_LOG_ERROR(feature_style_processor)
|
||||
<< "feature_style_processor: Style=" << style_name
|
||||
MAPNIK_LOG_ERROR(feature_style_processor) << "feature_style_processor: Style=" << style_name
|
||||
<< " required for layer=" << lay.name() << " does not exist.";
|
||||
|
||||
continue;
|
||||
|
@ -408,8 +396,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
|
|||
|
||||
double qw = query_ext.width() > 0 ? query_ext.width() : 1;
|
||||
double qh = query_ext.height() > 0 ? query_ext.height() : 1;
|
||||
query::resolution_type res(width/qw,
|
||||
height/qh);
|
||||
query::resolution_type res(width / qw, height / qh);
|
||||
|
||||
query q(layer_ext, res, scale_denom, extent);
|
||||
q.set_variables(p.variables());
|
||||
|
@ -455,8 +442,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
|
|||
}
|
||||
|
||||
template<typename Processor>
|
||||
void feature_style_processor<Processor>::render_submaterials(layer_rendering_material const & parent_mat,
|
||||
Processor & p)
|
||||
void feature_style_processor<Processor>::render_submaterials(layer_rendering_material const& parent_mat, Processor& p)
|
||||
{
|
||||
for (layer_rendering_material const& mat : parent_mat.materials_)
|
||||
{
|
||||
|
@ -473,8 +459,7 @@ void feature_style_processor<Processor>::render_submaterials(layer_rendering_mat
|
|||
}
|
||||
|
||||
template<typename Processor>
|
||||
void feature_style_processor<Processor>::render_material(layer_rendering_material const & mat,
|
||||
Processor & p)
|
||||
void feature_style_processor<Processor>::render_material(layer_rendering_material const& mat, Processor& p)
|
||||
{
|
||||
std::vector<feature_type_style const*> const& active_styles = mat.active_styles_;
|
||||
std::vector<featureset_ptr> const& featureset_ptr_list = mat.featureset_ptr_list_;
|
||||
|
@ -518,12 +503,8 @@ void feature_style_processor<Processor>::render_material(layer_rendering_materia
|
|||
std::size_t i = 0;
|
||||
for (feature_type_style const* style : active_styles)
|
||||
{
|
||||
|
||||
cache->prepare();
|
||||
render_style(p, style,
|
||||
rule_caches[i++],
|
||||
cache,
|
||||
*proj_trans_ptr);
|
||||
render_style(p, style, rule_caches[i++], cache, *proj_trans_ptr);
|
||||
}
|
||||
cache->clear();
|
||||
}
|
||||
|
@ -550,7 +531,6 @@ void feature_style_processor<Processor>::render_material(layer_rendering_materia
|
|||
feature_ptr feature;
|
||||
while ((feature = features->next()))
|
||||
{
|
||||
|
||||
cache->push(feature);
|
||||
}
|
||||
}
|
||||
|
@ -558,9 +538,7 @@ void feature_style_processor<Processor>::render_material(layer_rendering_materia
|
|||
for (feature_type_style const* style : active_styles)
|
||||
{
|
||||
cache->prepare();
|
||||
render_style(p, style,
|
||||
rule_caches[i++],
|
||||
cache, *proj_trans_ptr);
|
||||
render_style(p, style, rule_caches[i++], cache, *proj_trans_ptr);
|
||||
}
|
||||
}
|
||||
// We only have a single style and no grouping.
|
||||
|
@ -571,17 +549,13 @@ void feature_style_processor<Processor>::render_material(layer_rendering_materia
|
|||
for (feature_type_style const* style : active_styles)
|
||||
{
|
||||
featureset_ptr features = *featuresets++;
|
||||
render_style(p, style,
|
||||
rule_caches[i++],
|
||||
features,
|
||||
*proj_trans_ptr);
|
||||
render_style(p, style, rule_caches[i++], features, *proj_trans_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Processor>
|
||||
void feature_style_processor<Processor>::render_style(
|
||||
Processor & p,
|
||||
void feature_style_processor<Processor>::render_style(Processor& p,
|
||||
feature_type_style const* style,
|
||||
rule_cache const& rc,
|
||||
featureset_ptr features,
|
||||
|
@ -603,7 +577,8 @@ void feature_style_processor<Processor>::render_style(
|
|||
for (rule const* r : rc.get_if_rules())
|
||||
{
|
||||
expression_ptr const& expr = r->get_filter();
|
||||
value_type result = util::apply_visitor(evaluate<feature_impl,value_type,attributes>(*feature,vars),*expr);
|
||||
value_type result =
|
||||
util::apply_visitor(evaluate<feature_impl, value_type, attributes>(*feature, vars), *expr);
|
||||
if (result.to_bool())
|
||||
{
|
||||
was_painted = true;
|
||||
|
@ -660,4 +635,4 @@ void feature_style_processor<Processor>::render_style(
|
|||
p.end_style_processing(*style);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
|
|
@ -39,16 +39,11 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
#include <vector>
|
||||
#include <cstddef>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
class rule;
|
||||
|
||||
enum filter_mode_enum {
|
||||
FILTER_ALL,
|
||||
FILTER_FIRST,
|
||||
filter_mode_enum_MAX
|
||||
};
|
||||
enum filter_mode_enum { FILTER_ALL, FILTER_FIRST, filter_mode_enum_MAX };
|
||||
|
||||
DEFINE_ENUM(filter_mode_e, filter_mode_enum);
|
||||
|
||||
|
@ -67,6 +62,7 @@ private:
|
|||
float opacity_;
|
||||
bool image_filters_inflate_;
|
||||
friend void swap(feature_type_style& lhs, feature_type_style& rhs);
|
||||
|
||||
public:
|
||||
// ctor
|
||||
feature_type_style();
|
||||
|
@ -98,14 +94,10 @@ public:
|
|||
float get_opacity() const;
|
||||
void set_image_filters_inflate(bool inflate);
|
||||
bool image_filters_inflate() const;
|
||||
inline void reserve(std::size_t size)
|
||||
{
|
||||
rules_.reserve(size);
|
||||
}
|
||||
inline void reserve(std::size_t size) { rules_.reserve(size); }
|
||||
|
||||
~feature_type_style() {}
|
||||
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FEATURE_TYPE_STYLE_HPP
|
||||
|
|
|
@ -43,10 +43,7 @@ struct MAPNIK_DECL Featureset : private util::noncopyable
|
|||
|
||||
struct MAPNIK_DECL invalid_featureset final : Featureset
|
||||
{
|
||||
feature_ptr next()
|
||||
{
|
||||
return feature_ptr();
|
||||
}
|
||||
feature_ptr next() { return feature_ptr(); }
|
||||
~invalid_featureset() {}
|
||||
};
|
||||
|
||||
|
@ -62,6 +59,6 @@ inline bool is_valid(featureset_ptr const& ptr)
|
|||
return (dynamic_cast<invalid_featureset*>(ptr.get()) == nullptr) ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FEATURESET_HPP
|
||||
|
|
|
@ -36,7 +36,9 @@ class filter_featureset : public Featureset
|
|||
|
||||
public:
|
||||
filter_featureset(featureset_ptr const& fs, filter_type&& filter)
|
||||
: fs_(fs), filter_(std::move(filter)) {}
|
||||
: fs_(fs)
|
||||
, filter_(std::move(filter))
|
||||
{}
|
||||
|
||||
feature_ptr next()
|
||||
{
|
||||
|
@ -52,6 +54,6 @@ private:
|
|||
featureset_ptr fs_;
|
||||
filter_type filter_;
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FILTER_FEATURESET_HPP
|
||||
|
|
|
@ -36,10 +36,12 @@
|
|||
#include <utility> // pair
|
||||
#include <vector>
|
||||
|
||||
namespace boost { template <class T> class optional; }
|
||||
namespace boost {
|
||||
template<class T>
|
||||
class optional;
|
||||
}
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
class stroker;
|
||||
using stroker_ptr = std::shared_ptr<stroker>;
|
||||
|
@ -53,6 +55,7 @@ class MAPNIK_DECL freetype_engine : public singleton<freetype_engine, CreateUsin
|
|||
{
|
||||
friend class CreateUsingNew<freetype_engine>;
|
||||
friend class Map;
|
||||
|
||||
public:
|
||||
using font_file_mapping_type = std::map<std::string, std::pair<int, std::string>>;
|
||||
using font_memory_cache_type = std::map<std::string, std::pair<std::unique_ptr<char[]>, std::size_t>>;
|
||||
|
@ -74,6 +77,7 @@ public:
|
|||
freetype_engine::font_memory_cache_type const& font_cache,
|
||||
font_file_mapping_type const& global_font_file_mapping,
|
||||
freetype_engine::font_memory_cache_type& global_memory_fonts);
|
||||
|
||||
private:
|
||||
bool is_font_file_impl(std::string const& file_name);
|
||||
std::vector<std::string> face_names_impl();
|
||||
|
@ -94,9 +98,8 @@ private:
|
|||
bool register_fonts_impl(std::string const& dir, bool recurse);
|
||||
bool register_font_impl(std::string const& file_name, FT_LibraryRec_* library);
|
||||
bool register_fonts_impl(std::string const& dir, FT_LibraryRec_* library, bool recurse = false);
|
||||
bool register_font_impl(std::string const& file_name,
|
||||
font_library & libary,
|
||||
font_file_mapping_type & font_file_mapping);
|
||||
bool
|
||||
register_font_impl(std::string const& file_name, font_library& libary, font_file_mapping_type& font_file_mapping);
|
||||
bool register_fonts_impl(std::string const& dir,
|
||||
font_library& libary,
|
||||
font_file_mapping_type& font_file_mapping,
|
||||
|
@ -130,6 +133,6 @@ private:
|
|||
|
||||
using face_manager_freetype = face_manager;
|
||||
extern template class MAPNIK_DECL singleton<freetype_engine, CreateUsingNew>;
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FONT_ENGINE_FREETYPE_HPP
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
class MAPNIK_DECL font_set
|
||||
{
|
||||
public:
|
||||
|
@ -54,6 +53,6 @@ private:
|
|||
std::string name_;
|
||||
std::vector<std::string> face_names_;
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_FONT_SET_HPP
|
||||
|
|
|
@ -43,74 +43,50 @@ char const* binary_function_name(binary_function_impl const& fun);
|
|||
struct exp_impl
|
||||
{
|
||||
// using type = T;
|
||||
value_type operator() (value_type const& val) const
|
||||
{
|
||||
return std::exp(val.to_double());
|
||||
}
|
||||
value_type operator()(value_type const& val) const { return std::exp(val.to_double()); }
|
||||
};
|
||||
|
||||
// log
|
||||
struct log_impl
|
||||
{
|
||||
// using type = T;
|
||||
value_type operator() (value_type const& val) const
|
||||
{
|
||||
return std::log(val.to_double());
|
||||
}
|
||||
value_type operator()(value_type const& val) const { return std::log(val.to_double()); }
|
||||
};
|
||||
|
||||
// sin
|
||||
struct sin_impl
|
||||
{
|
||||
value_type operator() (value_type const& val) const
|
||||
{
|
||||
return std::sin(val.to_double());
|
||||
}
|
||||
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());
|
||||
}
|
||||
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());
|
||||
}
|
||||
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());
|
||||
}
|
||||
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::abs(val.to_double());
|
||||
}
|
||||
value_type operator()(value_type const& val) const { return std::abs(val.to_double()); }
|
||||
};
|
||||
|
||||
// length
|
||||
struct length_impl
|
||||
{
|
||||
value_type operator() (value_type const& val) const
|
||||
{
|
||||
return val.to_unicode().length();
|
||||
}
|
||||
value_type operator()(value_type const& val) const { return val.to_unicode().length(); }
|
||||
};
|
||||
|
||||
// min
|
||||
|
|
|
@ -42,8 +42,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/optional.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
template<typename T>
|
||||
bool clip_test(T p, T q, double& tmin, double& tmax)
|
||||
{
|
||||
|
@ -52,15 +51,21 @@ bool clip_test(T p,T q,double& tmin,double& tmax)
|
|||
if (p < 0.0)
|
||||
{
|
||||
r = q / p;
|
||||
if (r>tmax) result=false;
|
||||
else if (r>tmin) tmin=r;
|
||||
if (r > tmax)
|
||||
result = false;
|
||||
else if (r > tmin)
|
||||
tmin = r;
|
||||
}
|
||||
else if (p > 0.0)
|
||||
{
|
||||
r = q / p;
|
||||
if (r<tmin) result=false;
|
||||
else if (r<tmax) tmax=r;
|
||||
} else if (q<0.0) result=false;
|
||||
if (r < tmin)
|
||||
result = false;
|
||||
else if (r < tmax)
|
||||
tmax = r;
|
||||
}
|
||||
else if (q < 0.0)
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -117,9 +122,7 @@ inline bool point_inside_path(double x,double y,Iter start,Iter end)
|
|||
x1 = std::get<0>(*start);
|
||||
y1 = std::get<1>(*start);
|
||||
|
||||
if ((((y1 <= y) && (y < y0)) ||
|
||||
((y0 <= y) && (y < y1))) &&
|
||||
( x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
|
||||
if ((((y1 <= y) && (y < y0)) || ((y0 <= y) && (y < y1))) && (x < (x0 - x1) * (y - y1) / (y0 - y1) + x1))
|
||||
inside = !inside;
|
||||
x0 = x1;
|
||||
y0 = y1;
|
||||
|
@ -153,9 +156,7 @@ inline double distance(double x0, double y0, double x1, double y1)
|
|||
return std::sqrt(distance2(x0, y0, x1, y1));
|
||||
}
|
||||
|
||||
inline double point_to_segment_distance(double x, double y,
|
||||
double ax, double ay,
|
||||
double bx, double by)
|
||||
inline double point_to_segment_distance(double x, double y, double ax, double ay, double bx, double by)
|
||||
{
|
||||
double len2 = distance2(ax, ay, bx, by);
|
||||
|
||||
|
@ -211,12 +212,10 @@ struct bounding_box_filter
|
|||
using value_type = T;
|
||||
box2d<value_type> box_;
|
||||
explicit bounding_box_filter(box2d<value_type> const& box)
|
||||
: box_(box) {}
|
||||
: box_(box)
|
||||
{}
|
||||
|
||||
bool pass(box2d<value_type> const& extent) const
|
||||
{
|
||||
return extent.intersects(box_);
|
||||
}
|
||||
bool pass(box2d<value_type> const& extent) const { return extent.intersects(box_); }
|
||||
};
|
||||
|
||||
using filter_in_box = bounding_box_filter<double>;
|
||||
|
@ -232,10 +231,7 @@ struct at_point_filter
|
|||
box_.pad(tol);
|
||||
}
|
||||
|
||||
bool pass(box2d<value_type> const& extent) const
|
||||
{
|
||||
return extent.intersects(box_);
|
||||
}
|
||||
bool pass(box2d<value_type> const& extent) const { return extent.intersects(box_); }
|
||||
};
|
||||
|
||||
using filter_at_point = at_point_filter<double>;
|
||||
|
@ -250,11 +246,13 @@ double path_length(PathType & path)
|
|||
double y1 = 0;
|
||||
path.rewind(0);
|
||||
unsigned command = path.vertex(&x0, &y0);
|
||||
if (command == SEG_END) return 0;
|
||||
if (command == SEG_END)
|
||||
return 0;
|
||||
double length = 0;
|
||||
while (SEG_END != (command = path.vertex(&x1, &y1)))
|
||||
{
|
||||
if (command == SEG_CLOSE) continue;
|
||||
if (command == SEG_CLOSE)
|
||||
continue;
|
||||
length += distance(x0, y0, x1, y1);
|
||||
x0 = x1;
|
||||
y0 = y1;
|
||||
|
@ -291,9 +289,7 @@ bool hit_test_first(PathType & path, double x, double y)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((((y1 <= y) && (y < y0)) ||
|
||||
((y0 <= y) && (y < y1))) &&
|
||||
(x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
|
||||
if ((((y1 <= y) && (y < y0)) || ((y0 <= y) && (y < y1))) && (x < (x0 - x1) * (y - y1) / (y0 - y1) + x1))
|
||||
inside = !inside;
|
||||
|
||||
x0 = x1;
|
||||
|
@ -314,7 +310,8 @@ bool middle_point(PathType & path, double & x, double & y, boost::optional<doubl
|
|||
double mid_length = 0.5 * path_length(path);
|
||||
path.rewind(0);
|
||||
unsigned command = path.vertex(&x0, &y0);
|
||||
if (command == SEG_END) return false;
|
||||
if (command == SEG_END)
|
||||
return false;
|
||||
if (std::abs(mid_length) < std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
x = x0;
|
||||
|
@ -324,7 +321,8 @@ bool middle_point(PathType & path, double & x, double & y, boost::optional<doubl
|
|||
double dist = 0.0;
|
||||
while (SEG_END != (command = path.vertex(&x1, &y1)))
|
||||
{
|
||||
if (command == SEG_CLOSE) continue;
|
||||
if (command == SEG_CLOSE)
|
||||
continue;
|
||||
double seg_length = distance(x0, y0, x1, y1);
|
||||
|
||||
if (dist + seg_length >= mid_length)
|
||||
|
@ -352,7 +350,8 @@ bool centroid(PathType & path, double & x, double & y)
|
|||
|
||||
path.rewind(0);
|
||||
unsigned command = path.vertex(&p0.x, &p0.y);
|
||||
if (command == SEG_END) return false;
|
||||
if (command == SEG_END)
|
||||
return false;
|
||||
|
||||
start = move_to = p0;
|
||||
|
||||
|
@ -380,7 +379,6 @@ bool centroid(PathType & path, double & x, double & y)
|
|||
xtmp += (dx1 + dx0) * ai;
|
||||
ytmp += (dy1 + dy0) * ai;
|
||||
break;
|
||||
|
||||
}
|
||||
p0 = p1;
|
||||
++count;
|
||||
|
@ -514,16 +512,12 @@ bool hit_test(PathType & path, double x, double y, double tol)
|
|||
}
|
||||
switch (geom_type)
|
||||
{
|
||||
case mapnik::geometry::geometry_types::Polygon:
|
||||
{
|
||||
if ((((y1 <= y) && (y < y0)) ||
|
||||
((y0 <= y) && (y < y1))) &&
|
||||
(x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
|
||||
case mapnik::geometry::geometry_types::Polygon: {
|
||||
if ((((y1 <= y) && (y < y0)) || ((y0 <= y) && (y < y1))) && (x < (x0 - x1) * (y - y1) / (y0 - y1) + x1))
|
||||
inside = !inside;
|
||||
break;
|
||||
}
|
||||
case mapnik::geometry::geometry_types::LineString:
|
||||
{
|
||||
case mapnik::geometry::geometry_types::LineString: {
|
||||
double distance = point_to_segment_distance(x, y, x0, y0, x1, y1);
|
||||
if (distance < tol)
|
||||
return true;
|
||||
|
@ -544,6 +538,7 @@ bool hit_test(PathType & path, double x, double y, double tol)
|
|||
return inside;
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace label
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOM_UTIL_HPP
|
||||
|
|
|
@ -38,12 +38,14 @@
|
|||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<typename T, template<typename...> class Cont = std::vector>
|
||||
struct geometry_collection;
|
||||
|
||||
struct geometry_empty {};
|
||||
struct geometry_empty
|
||||
{};
|
||||
|
||||
template<typename T>
|
||||
using geometry_base = mapnik::util::variant<geometry_empty,
|
||||
|
@ -69,18 +71,19 @@ struct geometry : geometry_base<T>
|
|||
|
||||
template<typename G>
|
||||
geometry(G&& geom)
|
||||
: geometry_base<T>(std::forward<G>(geom)) {}
|
||||
: geometry_base<T>(std::forward<G>(geom))
|
||||
{}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
template<typename T, template<typename...> class Cont>
|
||||
struct geometry_collection : Cont<geometry<T>>
|
||||
{
|
||||
using coordinate_type = T;
|
||||
};
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_BOOST_GEOMETRY_ADAPTERS_HPP
|
||||
#define MAPNIK_BOOST_GEOMETRY_ADAPTERS_HPP
|
||||
|
||||
|
@ -45,7 +44,11 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
#include <mapnik/geometry/box2d.hpp>
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::geometry::point<double>, double, boost::geometry::cs::cartesian, x, y)
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point<std::int64_t>, std::int64_t, boost::geometry::cs::cartesian, x, y)
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::geometry::point<std::int64_t>,
|
||||
std::int64_t,
|
||||
boost::geometry::cs::cartesian,
|
||||
x,
|
||||
y)
|
||||
BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(mapnik::geometry::line_string)
|
||||
BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(mapnik::geometry::linear_ring)
|
||||
// needed by box2d<T>
|
||||
|
@ -63,7 +66,8 @@ struct const_interior_rings
|
|||
using value_type = typename polygon_type::value_type;
|
||||
|
||||
const_interior_rings(polygon_type const& poly)
|
||||
: poly_(poly) {}
|
||||
: poly_(poly)
|
||||
{}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
|
@ -74,16 +78,12 @@ struct const_interior_rings
|
|||
|
||||
const_iterator end() const { return poly_.cend(); }
|
||||
|
||||
std::size_t size() const
|
||||
{
|
||||
return poly_.empty() ? 0 : poly_.size() - 1;
|
||||
}
|
||||
std::size_t size() const { return poly_.empty() ? 0 : poly_.size() - 1; }
|
||||
|
||||
value_type const& back() const { return poly_.back(); }
|
||||
polygon_type const& poly_;
|
||||
};
|
||||
|
||||
|
||||
template<typename CoordinateType>
|
||||
struct interior_rings
|
||||
{
|
||||
|
@ -93,7 +93,8 @@ struct interior_rings
|
|||
using value_type = typename polygon_type::value_type;
|
||||
|
||||
interior_rings(polygon_type& poly)
|
||||
: poly_(poly) {}
|
||||
: poly_(poly)
|
||||
{}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
|
@ -112,20 +113,11 @@ struct interior_rings
|
|||
|
||||
const_iterator end() const { return poly_.cend(); }
|
||||
|
||||
void clear()
|
||||
{
|
||||
poly_.resize(1);
|
||||
}
|
||||
void clear() { poly_.resize(1); }
|
||||
|
||||
void resize(std::size_t size)
|
||||
{
|
||||
poly_.resize(size + 1);
|
||||
}
|
||||
void resize(std::size_t size) { poly_.resize(size + 1); }
|
||||
|
||||
std::size_t size() const
|
||||
{
|
||||
return poly_.empty() ? 0 : poly_.size() - 1;
|
||||
}
|
||||
std::size_t size() const { return poly_.empty() ? 0 : poly_.size() - 1; }
|
||||
|
||||
void push_back(value_type const& val) { poly_.push_back(val); }
|
||||
value_type& back() { return poly_.back(); }
|
||||
|
@ -133,9 +125,11 @@ struct interior_rings
|
|||
polygon_type& poly_;
|
||||
};
|
||||
|
||||
} // ns mapnik
|
||||
} // namespace mapnik
|
||||
|
||||
namespace boost { namespace geometry { namespace traits {
|
||||
namespace boost {
|
||||
namespace geometry {
|
||||
namespace traits {
|
||||
|
||||
template<typename CoordinateType>
|
||||
struct tag<mapnik::box2d<CoordinateType>>
|
||||
|
@ -143,8 +137,16 @@ struct tag<mapnik::box2d<CoordinateType> >
|
|||
using type = box_tag;
|
||||
};
|
||||
|
||||
template<> struct point_type<mapnik::box2d<double> > { using type = mapnik::coord2d; };
|
||||
template<> struct point_type<mapnik::box2d<float> > { using type = mapnik::coord2f; };
|
||||
template<>
|
||||
struct point_type<mapnik::box2d<double>>
|
||||
{
|
||||
using type = mapnik::coord2d;
|
||||
};
|
||||
template<>
|
||||
struct point_type<mapnik::box2d<float>>
|
||||
{
|
||||
using type = mapnik::coord2f;
|
||||
};
|
||||
|
||||
template<typename CoordinateType>
|
||||
struct indexed_access<mapnik::box2d<CoordinateType>, min_corner, 0>
|
||||
|
@ -241,13 +243,15 @@ struct exterior_ring<mapnik::geometry::polygon<CoordinateType> >
|
|||
using ring_mutable_type = typename ring_mutable_type<mapnik::geometry::polygon<CoordinateType>>::type;
|
||||
static ring_mutable_type get(mapnik::geometry::polygon<CoordinateType>& p)
|
||||
{
|
||||
if (p.empty()) p.resize(1);
|
||||
if (p.empty())
|
||||
p.resize(1);
|
||||
return p[0];
|
||||
}
|
||||
|
||||
static ring_const_type get(mapnik::geometry::polygon<CoordinateType> const& p)
|
||||
{
|
||||
if (p.empty()) throw std::runtime_error("Exterior ring must be initialized!");
|
||||
if (p.empty())
|
||||
throw std::runtime_error("Exterior ring must be initialized!");
|
||||
return p[0];
|
||||
}
|
||||
};
|
||||
|
@ -281,10 +285,7 @@ struct resize<mapnik::interior_rings<CoordinateType>>
|
|||
template<typename CoordinateType>
|
||||
struct clear<mapnik::interior_rings<CoordinateType>>
|
||||
{
|
||||
static inline void apply(mapnik::interior_rings<CoordinateType> interiors)
|
||||
{
|
||||
interiors.clear();
|
||||
}
|
||||
static inline void apply(mapnik::interior_rings<CoordinateType> interiors) { interiors.clear(); }
|
||||
};
|
||||
|
||||
template<typename CoordinateType>
|
||||
|
@ -297,6 +298,8 @@ struct push_back<mapnik::interior_rings<CoordinateType>>
|
|||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
} // namespace traits
|
||||
} // namespace geometry
|
||||
} // namespace boost
|
||||
|
||||
#endif // MAPNIK_BOOST_GEOMETRY_ADAPTERS_HPP
|
||||
|
|
|
@ -20,45 +20,39 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_BOOST_SPIRIT_KARMA_ADAPTER_HPP
|
||||
#define MAPNIK_BOOST_SPIRIT_KARMA_ADAPTER_HPP
|
||||
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
namespace boost { using mapbox::util::get; }
|
||||
namespace boost {
|
||||
using mapbox::util::get;
|
||||
}
|
||||
|
||||
#include <boost/spirit/home/karma/domain.hpp>
|
||||
#include <boost/spirit/home/support/attributes.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace traits
|
||||
{
|
||||
namespace boost {
|
||||
namespace spirit {
|
||||
namespace traits {
|
||||
template<>
|
||||
struct not_is_variant<mapnik::geometry::geometry<double>, karma::domain>
|
||||
: mpl::false_
|
||||
struct not_is_variant<mapnik::geometry::geometry<double>, karma::domain> : mpl::false_
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct not_is_variant<mapnik::geometry::geometry<std::int64_t>, karma::domain>
|
||||
: mpl::false_
|
||||
struct not_is_variant<mapnik::geometry::geometry<std::int64_t>, karma::domain> : mpl::false_
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct variant_which<mapnik::geometry::geometry<double>>
|
||||
{
|
||||
static int call(mapnik::geometry::geometry<double> const& v)
|
||||
{
|
||||
return v.which();
|
||||
}
|
||||
static int call(mapnik::geometry::geometry<double> const& v) { return v.which(); }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct variant_which<mapnik::geometry::geometry<std::int64_t>>
|
||||
{
|
||||
static int call(mapnik::geometry::geometry<std::int64_t> const& v)
|
||||
{
|
||||
return v.which();
|
||||
}
|
||||
static int call(mapnik::geometry::geometry<std::int64_t> const& v) { return v.which(); }
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
@ -67,13 +61,16 @@ template <typename T, typename Tuple>
|
|||
struct has_type;
|
||||
|
||||
template<typename T>
|
||||
struct has_type<T, std::tuple<>> : std::false_type {};
|
||||
struct has_type<T, std::tuple<>> : std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename U, typename... Types>
|
||||
struct has_type<T, std::tuple<U, Types...>> : has_type<T, std::tuple<Types...>> {};
|
||||
struct has_type<T, std::tuple<U, Types...>> : has_type<T, std::tuple<Types...>>
|
||||
{};
|
||||
|
||||
template<typename T, typename... Types>
|
||||
struct has_type<T, std::tuple<T, Types...>> : std::true_type {};
|
||||
struct has_type<T, std::tuple<T, Types...>> : std::true_type
|
||||
{};
|
||||
|
||||
template<typename T, typename Tuple>
|
||||
struct index;
|
||||
|
@ -90,7 +87,7 @@ struct index<T, std::tuple<U, Types...>>
|
|||
static const std::size_t value = 1 + index<T, std::tuple<Types...>>::value;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename Expected>
|
||||
struct compute_compatible_component_variant<mapnik::geometry::geometry<double>, Expected>
|
||||
|
@ -114,8 +111,8 @@ struct compute_compatible_component_variant<mapnik::geometry::geometry<std::int6
|
|||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
|
||||
} // namespace traits
|
||||
} // namespace spirit
|
||||
} // namespace boost
|
||||
|
||||
#endif // MAPNIK_BOOST_SPIRIT_KARMA_ADAPTER_HPP
|
||||
|
|
|
@ -46,11 +46,10 @@ namespace mapnik {
|
|||
|
||||
// A spatial envelope (i.e. bounding box) which also defines some basic operators.
|
||||
|
||||
template <typename T> class MAPNIK_DECL box2d
|
||||
: boost::equality_comparable<box2d<T> ,
|
||||
boost::addable<box2d<T>,
|
||||
boost::dividable2<box2d<T>, T,
|
||||
boost::multipliable2<box2d<T>, T > > > >
|
||||
template<typename T>
|
||||
class MAPNIK_DECL box2d : boost::equality_comparable<
|
||||
box2d<T>,
|
||||
boost::addable<box2d<T>, boost::dividable2<box2d<T>, T, boost::multipliable2<box2d<T>, T>>>>
|
||||
{
|
||||
public:
|
||||
using value_type = T;
|
||||
|
@ -59,6 +58,7 @@ public:
|
|||
T miny_;
|
||||
T maxx_;
|
||||
T maxy_;
|
||||
|
||||
private:
|
||||
friend inline void swap(box2d_type& lhs, box2d_type& rhs)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ private:
|
|||
swap(lhs.maxx_, rhs.maxx_);
|
||||
swap(lhs.maxy_, rhs.maxy_);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
box2d();
|
||||
|
@ -80,10 +81,10 @@ public:
|
|||
// converting ctor
|
||||
template<typename T1>
|
||||
explicit box2d(box2d<T1> other)
|
||||
: minx_(static_cast<value_type>(other.minx())),
|
||||
miny_(static_cast<value_type>(other.miny())),
|
||||
maxx_(static_cast<value_type>(other.maxx())),
|
||||
maxy_(static_cast<value_type>(other.maxy()))
|
||||
: minx_(static_cast<value_type>(other.minx()))
|
||||
, miny_(static_cast<value_type>(other.miny()))
|
||||
, maxx_(static_cast<value_type>(other.maxx()))
|
||||
, maxy_(static_cast<value_type>(other.maxy()))
|
||||
{}
|
||||
box2d_type& operator=(box2d_type other);
|
||||
T minx() const;
|
||||
|
@ -136,13 +137,11 @@ public:
|
|||
};
|
||||
|
||||
template<class charT, class traits, class T>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const box2d<T>& e)
|
||||
inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& out, const box2d<T>& e)
|
||||
{
|
||||
out << e.to_string();
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_BOX2D_HPP
|
||||
|
|
|
@ -41,15 +41,11 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
// agg
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
BOOST_FUSION_ADAPT_TPL_STRUCT(
|
||||
(T),
|
||||
(mapnik::box2d)(T),
|
||||
(T, minx_),
|
||||
(T, miny_),
|
||||
(T, maxx_),
|
||||
(T, maxy_))
|
||||
BOOST_FUSION_ADAPT_TPL_STRUCT((T), (mapnik::box2d)(T), (T, minx_), (T, miny_), (T, maxx_), (T, maxy_))
|
||||
|
||||
namespace mapnik { namespace detail { namespace {
|
||||
namespace mapnik {
|
||||
namespace detail {
|
||||
namespace {
|
||||
|
||||
template<typename T>
|
||||
struct assign
|
||||
|
@ -60,15 +56,16 @@ struct assign
|
|||
_val(ctx) = safe_cast<T>(_attr(ctx));
|
||||
}
|
||||
};
|
||||
} // anonymous
|
||||
} // detail
|
||||
} // namespace
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
box2d<T>::box2d()
|
||||
:minx_( std::numeric_limits<T>::max()),
|
||||
miny_( std::numeric_limits<T>::max()),
|
||||
maxx_(-std::numeric_limits<T>::max()),
|
||||
maxy_(-std::numeric_limits<T>::max()) {}
|
||||
: minx_(std::numeric_limits<T>::max())
|
||||
, miny_(std::numeric_limits<T>::max())
|
||||
, maxx_(-std::numeric_limits<T>::max())
|
||||
, maxy_(-std::numeric_limits<T>::max())
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
box2d<T>::box2d(T minx, T miny, T maxx, T maxy)
|
||||
|
@ -84,17 +81,19 @@ box2d<T>::box2d(coord<T,2> const& c0, coord<T,2> const& c1)
|
|||
|
||||
template<typename T>
|
||||
box2d<T>::box2d(box2d_type const& rhs)
|
||||
: minx_(rhs.minx_),
|
||||
miny_(rhs.miny_),
|
||||
maxx_(rhs.maxx_),
|
||||
maxy_(rhs.maxy_) {}
|
||||
: minx_(rhs.minx_)
|
||||
, miny_(rhs.miny_)
|
||||
, maxx_(rhs.maxx_)
|
||||
, maxy_(rhs.maxy_)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
box2d<T>::box2d(box2d_type&& rhs)
|
||||
: minx_(std::move(rhs.minx_)),
|
||||
miny_(std::move(rhs.miny_)),
|
||||
maxx_(std::move(rhs.maxx_)),
|
||||
maxy_(std::move(rhs.maxy_)) {}
|
||||
: minx_(std::move(rhs.minx_))
|
||||
, miny_(std::move(rhs.miny_))
|
||||
, maxx_(std::move(rhs.maxx_))
|
||||
, maxy_(std::move(rhs.maxy_))
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
box2d<T>& box2d<T>::operator=(box2d_type other)
|
||||
|
@ -114,8 +113,7 @@ box2d<T>::box2d(box2d_type const& rhs, agg::trans_affine const& tr)
|
|||
tr.transform(&x1, &y1);
|
||||
tr.transform(&x2, &y2);
|
||||
tr.transform(&x3, &y3);
|
||||
init(static_cast<T>(x0), static_cast<T>(y0),
|
||||
static_cast<T>(x2), static_cast<T>(y2));
|
||||
init(static_cast<T>(x0), static_cast<T>(y0), static_cast<T>(x2), static_cast<T>(y2));
|
||||
expand_to_include(static_cast<T>(x1), static_cast<T>(y1));
|
||||
expand_to_include(static_cast<T>(x3), static_cast<T>(y3));
|
||||
}
|
||||
|
@ -123,10 +121,7 @@ box2d<T>::box2d(box2d_type const& rhs, agg::trans_affine const& tr)
|
|||
template<typename T>
|
||||
bool box2d<T>::operator==(box2d<T> const& other) const
|
||||
{
|
||||
return minx_==other.minx_ &&
|
||||
miny_==other.miny_ &&
|
||||
maxx_==other.maxx_ &&
|
||||
maxy_==other.maxy_;
|
||||
return minx_ == other.minx_ && miny_ == other.miny_ && maxx_ == other.maxx_ && maxy_ == other.maxy_;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -208,8 +203,7 @@ void box2d<T>::height(T h)
|
|||
template<typename T>
|
||||
coord<T, 2> box2d<T>::center() const
|
||||
{
|
||||
return coord<T,2>(static_cast<T>(0.5*(minx_+maxx_)),
|
||||
static_cast<T>(0.5*(miny_+maxy_)));
|
||||
return coord<T, 2>(static_cast<T>(0.5 * (minx_ + maxx_)), static_cast<T>(0.5 * (miny_ + maxy_)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -221,19 +215,27 @@ void box2d<T>::expand_to_include(coord<T,2> const& c)
|
|||
template<typename T>
|
||||
void box2d<T>::expand_to_include(T x, T y)
|
||||
{
|
||||
if (x<minx_) minx_=x;
|
||||
if (x>maxx_) maxx_=x;
|
||||
if (y<miny_) miny_=y;
|
||||
if (y>maxy_) maxy_=y;
|
||||
if (x < minx_)
|
||||
minx_ = x;
|
||||
if (x > maxx_)
|
||||
maxx_ = x;
|
||||
if (y < miny_)
|
||||
miny_ = y;
|
||||
if (y > maxy_)
|
||||
maxy_ = y;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void box2d<T>::expand_to_include(box2d<T> const& other)
|
||||
{
|
||||
if (other.minx_<minx_) minx_=other.minx_;
|
||||
if (other.maxx_>maxx_) maxx_=other.maxx_;
|
||||
if (other.miny_<miny_) miny_=other.miny_;
|
||||
if (other.maxy_>maxy_) maxy_=other.maxy_;
|
||||
if (other.minx_ < minx_)
|
||||
minx_ = other.minx_;
|
||||
if (other.maxx_ > maxx_)
|
||||
maxx_ = other.maxx_;
|
||||
if (other.miny_ < miny_)
|
||||
miny_ = other.miny_;
|
||||
if (other.maxy_ > maxy_)
|
||||
maxy_ = other.maxy_;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -251,10 +253,7 @@ bool box2d<T>::contains(T x,T y) const
|
|||
template<typename T>
|
||||
bool box2d<T>::contains(box2d<T> const& other) const
|
||||
{
|
||||
return other.minx_>=minx_ &&
|
||||
other.maxx_<=maxx_ &&
|
||||
other.miny_>=miny_ &&
|
||||
other.maxy_<=maxy_;
|
||||
return other.minx_ >= minx_ && other.maxx_ <= maxx_ && other.miny_ >= miny_ && other.maxy_ <= maxy_;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -272,8 +271,7 @@ bool box2d<T>::intersects(T x,T y) const
|
|||
template<typename T>
|
||||
bool box2d<T>::intersects(box2d<T> const& other) const
|
||||
{
|
||||
return !(other.minx_>maxx_ || other.maxx_<minx_ ||
|
||||
other.miny_>maxy_ || other.maxy_<miny_);
|
||||
return !(other.minx_ > maxx_ || other.maxx_ < minx_ || other.miny_ > maxy_ || other.maxy_ < miny_);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -365,12 +363,11 @@ bool box2d<T>::from_string(std::string const& str)
|
|||
using boost::spirit::x3::lit;
|
||||
boost::spirit::x3::double_type double_;
|
||||
boost::spirit::x3::ascii::space_type space;
|
||||
bool r = boost::spirit::x3::phrase_parse(str.begin(),
|
||||
bool r = boost::spirit::x3::phrase_parse(
|
||||
str.begin(),
|
||||
str.end(),
|
||||
double_[detail::assign<T>()] >> -lit(',') >>
|
||||
double_[detail::assign<T>()] >> -lit(',') >>
|
||||
double_[detail::assign<T>()] >> -lit(',') >>
|
||||
double_[detail::assign<T>()],
|
||||
double_[detail::assign<T>()] >> -lit(',') >> double_[detail::assign<T>()] >> -lit(',') >>
|
||||
double_[detail::assign<T>()] >> -lit(',') >> double_[detail::assign<T>()],
|
||||
space,
|
||||
*this);
|
||||
return r;
|
||||
|
@ -397,9 +394,8 @@ std::string box2d<T>::to_string() const
|
|||
std::ostringstream s;
|
||||
if (valid())
|
||||
{
|
||||
s << "box2d(" << std::fixed << std::setprecision(16)
|
||||
<< minx_ << ',' << miny_ << ','
|
||||
<< maxx_ << ',' << maxy_ << ')';
|
||||
s << "box2d(" << std::fixed << std::setprecision(16) << minx_ << ',' << miny_ << ',' << maxx_ << ',' << maxy_
|
||||
<< ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -437,7 +433,6 @@ box2d<T>& box2d<T>::operator+= (T other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
box2d<T>& box2d<T>::operator*=(T t)
|
||||
{
|
||||
|
@ -507,10 +502,9 @@ box2d<T>& box2d<T>::operator*=(agg::trans_affine const& tr)
|
|||
tr.transform(&x1, &y1);
|
||||
tr.transform(&x2, &y2);
|
||||
tr.transform(&x3, &y3);
|
||||
init(static_cast<T>(x0), static_cast<T>(y0),
|
||||
static_cast<T>(x2), static_cast<T>(y2));
|
||||
init(static_cast<T>(x0), static_cast<T>(y0), static_cast<T>(x2), static_cast<T>(y2));
|
||||
expand_to_include(static_cast<T>(x1), static_cast<T>(y1));
|
||||
expand_to_include(static_cast<T>(x3), static_cast<T>(y3));
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#include <mapnik/geometry/is_empty.hpp>
|
||||
#include <mapnik/geometry/remove_empty.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@ -39,7 +40,8 @@ struct geometry_centroid
|
|||
using result_type = bool;
|
||||
|
||||
geometry_centroid(point<T>& pt)
|
||||
: pt_(pt) {}
|
||||
: pt_(pt)
|
||||
{}
|
||||
|
||||
template<typename U>
|
||||
result_type operator()(U const& geom) const
|
||||
|
@ -47,45 +49,21 @@ struct geometry_centroid
|
|||
return util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
result_type operator()(geometry_empty const&) const { return false; }
|
||||
|
||||
result_type operator() (geometry_collection<T> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
result_type operator()(geometry_collection<T> const&) const { return false; }
|
||||
|
||||
result_type operator() (point<T> const& geom) const
|
||||
{
|
||||
return centroid_simple(geom);
|
||||
}
|
||||
result_type operator()(point<T> const& geom) const { return centroid_simple(geom); }
|
||||
|
||||
result_type operator() (line_string<T> const& geom) const
|
||||
{
|
||||
return centroid_simple(geom);
|
||||
}
|
||||
result_type operator()(line_string<T> const& geom) const { return centroid_simple(geom); }
|
||||
|
||||
result_type operator() (polygon<T> const& geom) const
|
||||
{
|
||||
return centroid_simple(geom);
|
||||
}
|
||||
result_type operator()(polygon<T> const& geom) const { return centroid_simple(geom); }
|
||||
|
||||
result_type operator() (multi_point<T> const& geom) const
|
||||
{
|
||||
return centroid_simple(geom);
|
||||
}
|
||||
result_type operator()(multi_point<T> const& geom) const { return centroid_simple(geom); }
|
||||
|
||||
result_type operator() (multi_line_string<T> const& geom) const
|
||||
{
|
||||
return centroid_multi(geom);
|
||||
}
|
||||
result_type operator()(multi_line_string<T> const& geom) const { return centroid_multi(geom); }
|
||||
|
||||
result_type operator() (multi_polygon<T> const& geom) const
|
||||
{
|
||||
return centroid_multi(geom);
|
||||
}
|
||||
result_type operator()(multi_polygon<T> const& geom) const { return centroid_multi(geom); }
|
||||
|
||||
point<T>& pt_;
|
||||
|
||||
|
@ -97,8 +75,7 @@ private:
|
|||
{
|
||||
boost::geometry::centroid(geom, pt_);
|
||||
return true;
|
||||
}
|
||||
catch (boost::geometry::centroid_exception const & e)
|
||||
} catch (boost::geometry::centroid_exception const& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -111,7 +88,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename T1, typename T2>
|
||||
inline bool centroid(T1 const& geom, point<T2>& pt)
|
||||
|
@ -119,6 +96,7 @@ inline bool centroid(T1 const& geom, point<T2> & pt)
|
|||
return detail::geometry_centroid<T2>(pt)(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_CENTROID_HPP
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry/boost_adapters.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
using coordinate_type = double;
|
||||
|
||||
struct closest_point_result
|
||||
|
@ -44,8 +45,8 @@ using result_type = closest_point_result;
|
|||
template<typename T1, typename T2>
|
||||
MAPNIK_DECL result_type closest_point(T1 const& geom, mapnik::geometry::point<T2> const& pt);
|
||||
|
||||
}}
|
||||
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif //
|
||||
#endif // MAPNIK_GEOMETRY_CLOSEST_POINT_HPP
|
||||
|
|
|
@ -35,7 +35,8 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
#include <type_traits>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@ -61,13 +62,15 @@ struct geometry_correct
|
|||
template<typename T>
|
||||
result_type operator()(polygon<T>& poly) const
|
||||
{
|
||||
if (!poly.empty()) boost::geometry::correct(poly);
|
||||
if (!poly.empty())
|
||||
boost::geometry::correct(poly);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
result_type operator()(multi_polygon<T>& multi_poly) const
|
||||
{
|
||||
if (!multi_poly.empty()) boost::geometry::correct(multi_poly);
|
||||
if (!multi_poly.empty())
|
||||
boost::geometry::correct(multi_poly);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -75,10 +78,9 @@ struct geometry_correct
|
|||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename GeomType>
|
||||
inline void correct(GeomType& geom)
|
||||
|
@ -87,6 +89,7 @@ inline void correct(GeomType & geom)
|
|||
detail::geometry_correct()(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_CORRECT_HPP
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace geometry {
|
|||
template<typename T>
|
||||
MAPNIK_DECL auto envelope(T const& geom) -> box2d<typename T::coordinate_type>;
|
||||
|
||||
} // end ns geometry
|
||||
} // end ns mapnik
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_ENVELOPE_HPP
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry/box2d.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@ -36,7 +37,8 @@ struct geometry_envelope
|
|||
bbox_type& bbox;
|
||||
|
||||
explicit geometry_envelope(bbox_type& bbox_)
|
||||
: bbox(bbox_) {}
|
||||
: bbox(bbox_)
|
||||
{}
|
||||
|
||||
template<typename U>
|
||||
void operator()(U const& geom) const
|
||||
|
@ -55,25 +57,17 @@ struct geometry_envelope
|
|||
bbox.expand_to_include(pt.x, pt.y);
|
||||
}
|
||||
|
||||
void operator() (mapnik::geometry::line_string<T> const& line) const
|
||||
{
|
||||
_envelope_impl(line, bbox);
|
||||
}
|
||||
void operator()(mapnik::geometry::line_string<T> const& line) const { _envelope_impl(line, bbox); }
|
||||
|
||||
void operator() (mapnik::geometry::linear_ring<T> const& ring) const
|
||||
{
|
||||
_envelope_impl(ring, bbox);
|
||||
}
|
||||
void operator()(mapnik::geometry::linear_ring<T> const& ring) const { _envelope_impl(ring, bbox); }
|
||||
|
||||
void operator()(mapnik::geometry::polygon<T> const& poly) const
|
||||
{
|
||||
if (!poly.empty()) _envelope_impl(poly[0], bbox);
|
||||
if (!poly.empty())
|
||||
_envelope_impl(poly[0], bbox);
|
||||
}
|
||||
|
||||
void operator() (mapnik::geometry::multi_point<T> const& multi_point) const
|
||||
{
|
||||
_envelope_impl(multi_point, bbox);
|
||||
}
|
||||
void operator()(mapnik::geometry::multi_point<T> const& multi_point) const { _envelope_impl(multi_point, bbox); }
|
||||
|
||||
void operator()(mapnik::geometry::multi_line_string<T> const& multi_line) const
|
||||
{
|
||||
|
@ -119,7 +113,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
} // end ns detail
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
auto envelope(T const& geom) -> box2d<typename T::coordinate_type>
|
||||
|
@ -131,5 +125,5 @@ auto envelope(T const& geom) -> box2d<typename T::coordinate_type>
|
|||
return bbox;
|
||||
}
|
||||
|
||||
} // end ns geometry
|
||||
} // end ns mapnik
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
|
|
@ -20,23 +20,14 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP
|
||||
#define MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP
|
||||
|
||||
#include <mapnik/geometry/polygon.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
mapnik::geometry::point<double>,
|
||||
(double, x)
|
||||
(double, y)
|
||||
)
|
||||
BOOST_FUSION_ADAPT_STRUCT(mapnik::geometry::point<double>, (double, x)(double, y))
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
mapnik::geometry::point<std::int64_t>,
|
||||
(std::int64_t, x)
|
||||
(std::int64_t, y)
|
||||
)
|
||||
BOOST_FUSION_ADAPT_STRUCT(mapnik::geometry::point<std::int64_t>, (std::int64_t, x)(std::int64_t, y))
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry/geometry_types.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry { namespace detail {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct geometry_type
|
||||
|
@ -77,7 +79,7 @@ struct geometry_type
|
|||
return mapnik::geometry::geometry_types::GeometryCollection;
|
||||
}
|
||||
};
|
||||
} // detail
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
static inline mapnik::geometry::geometry_types geometry_type(T const& geom)
|
||||
|
@ -86,7 +88,7 @@ static inline mapnik::geometry::geometry_types geometry_type(T const& geom)
|
|||
return detail::geometry_type<coordinate_type>()(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_TYPE_HPP
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
// OGC compatible types
|
||||
enum geometry_types : std::uint8_t
|
||||
{
|
||||
enum geometry_types : std::uint8_t {
|
||||
Unknown = 0,
|
||||
Point = 1,
|
||||
LineString = 2,
|
||||
|
@ -40,6 +40,7 @@ enum geometry_types : std::uint8_t
|
|||
GeometryCollection = 7,
|
||||
};
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_TYPES_HPP
|
||||
|
|
|
@ -27,13 +27,13 @@
|
|||
#include <mapnik/geometry/polygon.hpp>
|
||||
#include <mapnik/geometry/point.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<class T>
|
||||
MAPNIK_DECL bool interior(polygon<T> const& polygon,
|
||||
double scale_factor,
|
||||
point<T> & pt);
|
||||
MAPNIK_DECL bool interior(polygon<T> const& polygon, double scale_factor, point<T>& pt);
|
||||
|
||||
} }
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_INTERIOR_HPP
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@ -36,49 +37,30 @@ struct geometry_is_empty
|
|||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::point<double> const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool operator()(mapnik::geometry::point<double> const&) const { return false; }
|
||||
|
||||
bool operator() (mapnik::geometry::line_string<double> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
bool operator()(mapnik::geometry::line_string<double> const& geom) const { return geom.empty(); }
|
||||
|
||||
bool operator()(mapnik::geometry::polygon<double> const& geom) const
|
||||
{
|
||||
return geom.empty() || geom.front().empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::geometry::multi_point<double> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
bool operator()(mapnik::geometry::multi_point<double> const& geom) const { return geom.empty(); }
|
||||
|
||||
bool operator() (mapnik::geometry::multi_line_string<double> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
bool operator()(mapnik::geometry::multi_line_string<double> const& geom) const { return geom.empty(); }
|
||||
|
||||
bool operator() (mapnik::geometry::multi_polygon<double> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
bool operator()(mapnik::geometry::multi_polygon<double> const& geom) const { return geom.empty(); }
|
||||
|
||||
bool operator() (mapnik::geometry::geometry_collection<double> const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
bool operator()(mapnik::geometry::geometry_collection<double> const& geom) const { return geom.empty(); }
|
||||
|
||||
template<typename T>
|
||||
bool operator()(T const&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// returns true if the geometry is the empty set
|
||||
template<typename GeomType>
|
||||
|
@ -87,6 +69,7 @@ inline bool is_empty(GeomType const& geom)
|
|||
return detail::geometry_is_empty()(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_IS_EMPTY_HPP
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include <mapnik/geometry/boost_adapters.hpp>
|
||||
#include <boost/geometry/algorithms/is_simple.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@ -58,7 +59,8 @@ struct geometry_is_simple
|
|||
{
|
||||
for (auto const& geom : collection)
|
||||
{
|
||||
if ( !(*this)(geom)) return false;
|
||||
if (!(*this)(geom))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -107,7 +109,8 @@ struct geometry_is_simple
|
|||
}
|
||||
for (auto const& line : multi_line)
|
||||
{
|
||||
if (!(*this)(line)) return false;
|
||||
if (!(*this)(line))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -122,14 +125,14 @@ struct geometry_is_simple
|
|||
}
|
||||
for (auto const& poly : multi_poly)
|
||||
{
|
||||
if (!(*this)(poly)) return false;
|
||||
if (!(*this)(poly))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
inline bool is_simple(T const& geom)
|
||||
|
@ -143,7 +146,8 @@ inline bool is_simple(mapnik::geometry::geometry<T> const& geom)
|
|||
return util::apply_visitor(detail::geometry_is_simple(), geom);
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // BOOST_VERSION >= 1.56
|
||||
#endif // MAPNIK_GEOMETRY_IS_SIMPLE_HPP
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
#include <boost/geometry/algorithms/is_valid.hpp>
|
||||
#include <boost/geometry/algorithms/validity_failure_type.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
@ -47,17 +48,15 @@ struct geometry_is_valid
|
|||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
result_type operator() (geometry_empty const& ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
result_type operator()(geometry_empty const&) const { return true; }
|
||||
|
||||
template<typename T>
|
||||
result_type operator()(geometry_collection<T> const& collection) const
|
||||
{
|
||||
for (auto const& geom : collection)
|
||||
{
|
||||
if ( !(*this)(geom)) return false;
|
||||
if (!(*this)(geom))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -105,8 +104,9 @@ struct geometry_is_valid_reason
|
|||
|
||||
boost::geometry::validity_failure_type& failure_;
|
||||
|
||||
geometry_is_valid_reason(boost::geometry::validity_failure_type & failure):
|
||||
failure_(failure) {}
|
||||
geometry_is_valid_reason(boost::geometry::validity_failure_type& failure)
|
||||
: failure_(failure)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
result_type operator()(geometry<T> const& geom) const
|
||||
|
@ -125,7 +125,8 @@ struct geometry_is_valid_reason
|
|||
{
|
||||
for (auto const& geom : collection)
|
||||
{
|
||||
if ( !(*this)(geom)) return false;
|
||||
if (!(*this)(geom))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -173,8 +174,9 @@ struct geometry_is_valid_string
|
|||
|
||||
std::string& message_;
|
||||
|
||||
geometry_is_valid_string(std::string & message):
|
||||
message_(message) {}
|
||||
geometry_is_valid_string(std::string& message)
|
||||
: message_(message)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
result_type operator()(geometry<T> const& geom) const
|
||||
|
@ -193,7 +195,8 @@ struct geometry_is_valid_string
|
|||
{
|
||||
for (auto const& geom : collection)
|
||||
{
|
||||
if ( !(*this)(geom)) return false;
|
||||
if (!(*this)(geom))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -235,8 +238,7 @@ struct geometry_is_valid_string
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
inline bool is_valid(T const& geom)
|
||||
|
@ -257,8 +259,7 @@ inline bool is_valid(T const& geom, boost::geometry::validity_failure_type & fai
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
|
||||
boost::geometry::validity_failure_type & failure)
|
||||
inline bool is_valid(mapnik::geometry::geometry<T> const& geom, boost::geometry::validity_failure_type& failure)
|
||||
{
|
||||
return util::apply_visitor(detail::geometry_is_valid_reason(failure), geom);
|
||||
}
|
||||
|
@ -270,13 +271,13 @@ inline bool is_valid(T const& geom, std::string & message)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
|
||||
std::string & message)
|
||||
inline bool is_valid(mapnik::geometry::geometry<T> const& geom, std::string& message)
|
||||
{
|
||||
return util::apply_visitor(detail::geometry_is_valid_string(message), geom);
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // BOOST_VERSION >= 1.58
|
||||
#endif // MAPNIK_GEOMETRY_IS_VALID_HPP
|
||||
|
|
|
@ -26,10 +26,12 @@
|
|||
// mapnik
|
||||
#include <mapbox/geometry/line_string.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<typename T>
|
||||
using line_string = mapbox::geometry::line_string<T>;
|
||||
}}
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_LINE_STRING_HPP
|
||||
|
|
|
@ -26,11 +26,13 @@
|
|||
// geometry
|
||||
#include <mapbox/geometry/multi_line_string.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<typename T>
|
||||
using multi_line_string = mapbox::geometry::multi_line_string<T>;
|
||||
|
||||
}}
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_MULTI_LINE_STRING_HPP
|
||||
|
|
|
@ -26,11 +26,13 @@
|
|||
// geometry
|
||||
#include <mapbox/geometry/multi_point.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<typename T>
|
||||
using multi_point = mapbox::geometry::multi_point<T>;
|
||||
|
||||
}}
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_MULTI_POINT_HPP
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
// geometry
|
||||
#include <mapnik/geometry/polygon.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<typename T, template<typename...> class Cont = std::vector>
|
||||
struct multi_polygon : Cont<polygon<T>>
|
||||
|
@ -37,7 +38,7 @@ struct multi_polygon : Cont<polygon<T>>
|
|||
using container_type::container_type;
|
||||
};
|
||||
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_MULTI_POLYGON_HPP
|
||||
|
|
|
@ -25,11 +25,13 @@
|
|||
|
||||
#include <mapbox/geometry/point.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<typename T>
|
||||
using point = mapbox::geometry::point<T>;
|
||||
|
||||
}}
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_POINT_HPP
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
// geometry
|
||||
#include <mapbox/geometry/polygon.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<typename T>
|
||||
using linear_ring = mapbox::geometry::linear_ring<T>;
|
||||
|
@ -34,6 +35,7 @@ using linear_ring = mapbox::geometry::linear_ring<T>;
|
|||
template<typename T>
|
||||
using polygon = mapbox::geometry::polygon<T>;
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_POLYGON_HPP
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
#include <mapnik/geometry/point.hpp>
|
||||
#include <mapnik/geometry/polygon.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<typename T>
|
||||
struct polygon_vertex_processor
|
||||
|
@ -61,6 +62,7 @@ struct polygon_vertex_processor
|
|||
polygon<T> polygon_;
|
||||
};
|
||||
|
||||
} }
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_POLYGON_VERTEX_PROCESSOR_HPP
|
||||
|
|
|
@ -27,17 +27,16 @@
|
|||
#include <mapnik/geometry/polygon.hpp>
|
||||
#include <mapnik/geometry/point.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
template<class T>
|
||||
MAPNIK_DECL bool polylabel(polygon<T> const& polygon,
|
||||
T precision,
|
||||
point<T> & pt);
|
||||
MAPNIK_DECL bool polylabel(polygon<T> const& polygon, T precision, point<T>& pt);
|
||||
|
||||
template<class T>
|
||||
MAPNIK_DECL T polylabel_precision(polygon<T> const& polygon,
|
||||
double scale_factor);
|
||||
MAPNIK_DECL T polylabel_precision(polygon<T> const& polygon, double scale_factor);
|
||||
|
||||
} }
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_POLYLABEL_HPP
|
||||
|
|
|
@ -26,13 +26,15 @@
|
|||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry/is_empty.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct geometry_remove_empty
|
||||
{
|
||||
mapnik::geometry::multi_line_string<double> operator() (mapnik::geometry::multi_line_string<double> const& geom) const
|
||||
mapnik::geometry::multi_line_string<double>
|
||||
operator()(mapnik::geometry::multi_line_string<double> const& geom) const
|
||||
{
|
||||
return remove_empty(geom);
|
||||
}
|
||||
|
@ -64,7 +66,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename GeomType>
|
||||
inline GeomType remove_empty(GeomType const& geom)
|
||||
|
@ -72,6 +74,7 @@ inline GeomType remove_empty(GeomType const& geom)
|
|||
return detail::geometry_remove_empty()(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_REMOVE_EMPTY_HPP
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <mapnik/proj_transform.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
namespace geometry {
|
||||
|
@ -46,7 +45,6 @@ MAPNIK_DECL T reproject_copy(T const& geom, proj_transform const& proj_trans, un
|
|||
template<typename T>
|
||||
MAPNIK_DECL T reproject_copy(T const& geom, projection const& source, projection const& dest, unsigned int& n_err);
|
||||
|
||||
|
||||
// No error count is required for a non const reprojection and this will reproject in place.
|
||||
// because the reprojection is done on the same memory it is important to check if it succeeded,
|
||||
// otherwise you could be dealing with a corrupt geometry.
|
||||
|
@ -57,8 +55,8 @@ MAPNIK_DECL bool reproject(T & geom, proj_transform const& proj_trans);
|
|||
template<typename T>
|
||||
MAPNIK_DECL bool reproject(T& geom, projection const& source, projection const& dest);
|
||||
|
||||
} // end geometry ns
|
||||
} // namespace geometry
|
||||
|
||||
} // end mapnik ns
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_REPROJECTION_HPP
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
#include <mapnik/geometry/reprojection.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry { namespace detail {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
namespace detail {
|
||||
|
||||
// template <typename T>
|
||||
geometry_empty reproject_internal(geometry_empty const&, proj_transform const&, unsigned int&)
|
||||
|
@ -70,11 +72,12 @@ polygon<T> reproject_internal(polygon<T> const& poly, proj_transform const& proj
|
|||
n_err += err;
|
||||
// If there is an error in interior ring drop
|
||||
// it from polygon.
|
||||
if (!exterior) continue;
|
||||
if (!exterior)
|
||||
continue;
|
||||
}
|
||||
if (exterior) exterior = false;
|
||||
if (exterior)
|
||||
exterior = false;
|
||||
new_poly.push_back(std::move(new_lr));
|
||||
|
||||
}
|
||||
return new_poly;
|
||||
}
|
||||
|
@ -110,7 +113,8 @@ multi_point<T> reproject_internal(multi_point<T> const & mp, proj_transform cons
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
multi_line_string<T> reproject_internal(multi_line_string<T> const & mls, proj_transform const& proj_trans, unsigned int & n_err)
|
||||
multi_line_string<T>
|
||||
reproject_internal(multi_line_string<T> const& mls, proj_transform const& proj_trans, unsigned int& n_err)
|
||||
{
|
||||
multi_line_string<T> new_mls;
|
||||
new_mls.reserve(mls.size());
|
||||
|
@ -126,7 +130,8 @@ multi_line_string<T> reproject_internal(multi_line_string<T> const & mls, proj_t
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
multi_polygon<T> reproject_internal(multi_polygon<T> const & mpoly, proj_transform const& proj_trans, unsigned int & n_err)
|
||||
multi_polygon<T>
|
||||
reproject_internal(multi_polygon<T> const& mpoly, proj_transform const& proj_trans, unsigned int& n_err)
|
||||
{
|
||||
multi_polygon<T> new_mpoly;
|
||||
new_mpoly.reserve(mpoly.size());
|
||||
|
@ -142,13 +147,13 @@ multi_polygon<T> reproject_internal(multi_polygon<T> const & mpoly, proj_transfo
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
geometry_collection<T> reproject_internal(geometry_collection<T> const & c, proj_transform const& proj_trans, unsigned int & n_err)
|
||||
geometry_collection<T>
|
||||
reproject_internal(geometry_collection<T> const& c, proj_transform const& proj_trans, unsigned int& n_err)
|
||||
{
|
||||
geometry_collection<T> new_c;
|
||||
new_c.reserve(c.size());
|
||||
for (auto const& g : c)
|
||||
{
|
||||
|
||||
geometry<T> new_g = reproject_copy(g, proj_trans, n_err);
|
||||
if (!new_g.template is<geometry_empty>())
|
||||
{
|
||||
|
@ -161,22 +166,20 @@ geometry_collection<T> reproject_internal(geometry_collection<T> const & c, proj
|
|||
template<typename T>
|
||||
struct geom_reproj_copy_visitor
|
||||
{
|
||||
|
||||
geom_reproj_copy_visitor(proj_transform const& proj_trans, unsigned int& n_err)
|
||||
: proj_trans_(proj_trans),
|
||||
n_err_(n_err) {}
|
||||
: proj_trans_(proj_trans)
|
||||
, n_err_(n_err)
|
||||
{}
|
||||
|
||||
geometry<T> operator() (geometry_empty) const
|
||||
{
|
||||
return geometry_empty();
|
||||
}
|
||||
geometry<T> operator()(geometry_empty) const { return geometry_empty(); }
|
||||
|
||||
geometry<T> operator()(point<T> const& p) const
|
||||
{
|
||||
geometry<T> geom; // default empty
|
||||
unsigned int intial_err = n_err_;
|
||||
point<T> new_p = reproject_internal(p, proj_trans_, n_err_);
|
||||
if (n_err_ > intial_err) return geom;
|
||||
if (n_err_ > intial_err)
|
||||
return geom;
|
||||
geom = std::move(new_p);
|
||||
return geom;
|
||||
}
|
||||
|
@ -186,7 +189,8 @@ struct geom_reproj_copy_visitor
|
|||
geometry<T> geom; // default empty
|
||||
unsigned int intial_err = n_err_;
|
||||
line_string<T> new_ls = reproject_internal(ls, proj_trans_, n_err_);
|
||||
if (n_err_ > intial_err || new_ls.empty()) return geom;
|
||||
if (n_err_ > intial_err || new_ls.empty())
|
||||
return geom;
|
||||
geom = std::move(new_ls);
|
||||
return geom;
|
||||
}
|
||||
|
@ -195,7 +199,8 @@ struct geom_reproj_copy_visitor
|
|||
{
|
||||
geometry<T> geom; // default empty
|
||||
polygon<T> new_poly = reproject_internal(poly, proj_trans_, n_err_);
|
||||
if (new_poly.size() == 0 || new_poly[0].size() == 0) return geom;
|
||||
if (new_poly.size() == 0 || new_poly[0].size() == 0)
|
||||
return geom;
|
||||
geom = std::move(new_poly);
|
||||
return geom;
|
||||
}
|
||||
|
@ -204,7 +209,8 @@ struct geom_reproj_copy_visitor
|
|||
{
|
||||
geometry<T> geom; // default empty
|
||||
multi_point<T> new_mp = reproject_internal(mp, proj_trans_, n_err_);
|
||||
if (new_mp.empty()) return geom;
|
||||
if (new_mp.empty())
|
||||
return geom;
|
||||
geom = std::move(new_mp);
|
||||
return geom;
|
||||
}
|
||||
|
@ -213,7 +219,8 @@ struct geom_reproj_copy_visitor
|
|||
{
|
||||
geometry<T> geom; // default empty
|
||||
multi_line_string<T> new_mls = reproject_internal(mls, proj_trans_, n_err_);
|
||||
if (new_mls.empty()) return geom;
|
||||
if (new_mls.empty())
|
||||
return geom;
|
||||
geom = std::move(new_mls);
|
||||
return geom;
|
||||
}
|
||||
|
@ -222,7 +229,8 @@ struct geom_reproj_copy_visitor
|
|||
{
|
||||
geometry<T> geom; // default empty
|
||||
multi_polygon<T> new_mpoly = reproject_internal(mpoly, proj_trans_, n_err_);
|
||||
if (new_mpoly.empty()) return geom;
|
||||
if (new_mpoly.empty())
|
||||
return geom;
|
||||
geom = std::move(new_mpoly);
|
||||
return geom;
|
||||
}
|
||||
|
@ -231,7 +239,8 @@ struct geom_reproj_copy_visitor
|
|||
{
|
||||
geometry<T> geom; // default empty
|
||||
geometry_collection<T> new_c = reproject_internal(c, proj_trans_, n_err_);
|
||||
if (new_c.empty()) return geom;
|
||||
if (new_c.empty())
|
||||
return geom;
|
||||
geom = std::move(new_c);
|
||||
return geom;
|
||||
}
|
||||
|
@ -239,10 +248,9 @@ struct geom_reproj_copy_visitor
|
|||
private:
|
||||
proj_transform const& proj_trans_;
|
||||
unsigned int& n_err_;
|
||||
|
||||
};
|
||||
|
||||
} // end detail ns
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
geometry<T> reproject_copy(geometry<T> const& geom, proj_transform const& proj_trans, unsigned int& n_err)
|
||||
|
@ -266,10 +274,11 @@ T reproject_copy(T const& geom, projection const& source, projection const& dest
|
|||
|
||||
namespace detail {
|
||||
|
||||
struct geom_reproj_visitor {
|
||||
|
||||
struct geom_reproj_visitor
|
||||
{
|
||||
geom_reproj_visitor(proj_transform const& proj_trans)
|
||||
: proj_trans_(proj_trans) {}
|
||||
: proj_trans_(proj_trans)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
bool operator()(geometry<T>& geom) const
|
||||
|
@ -364,10 +373,9 @@ struct geom_reproj_visitor {
|
|||
|
||||
private:
|
||||
proj_transform const& proj_trans_;
|
||||
|
||||
};
|
||||
|
||||
} // end detail ns
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
bool reproject(T& geom, proj_transform const& proj_trans)
|
||||
|
@ -384,5 +392,5 @@ bool reproject(T & geom, projection const& source, projection const& dest)
|
|||
return visit(geom);
|
||||
}
|
||||
|
||||
} // end geometry ns
|
||||
} // end mapnik ns
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
|
|
@ -29,24 +29,27 @@
|
|||
namespace mapnik {
|
||||
namespace geometry {
|
||||
|
||||
namespace helper
|
||||
{
|
||||
namespace helper {
|
||||
template<std::size_t... Ts>
|
||||
struct index {};
|
||||
struct index
|
||||
{};
|
||||
|
||||
template<std::size_t N, std::size_t... Ts>
|
||||
struct gen_seq : gen_seq<N - 1, N - 1, Ts...> {};
|
||||
struct gen_seq : gen_seq<N - 1, N - 1, Ts...>
|
||||
{};
|
||||
|
||||
template<std::size_t... Ts>
|
||||
struct gen_seq<0, Ts...> : index<Ts...> {};
|
||||
}
|
||||
struct gen_seq<0, Ts...> : index<Ts...>
|
||||
{};
|
||||
} // namespace helper
|
||||
|
||||
// Groups a set of strategies at runtime, the conversion from P1 to P2 will take place on the LAST strategy.
|
||||
template<typename... Strategies>
|
||||
struct strategy_group
|
||||
{
|
||||
strategy_group(Strategies const&... ops)
|
||||
: ops_(ops ...) {}
|
||||
: ops_(ops...)
|
||||
{}
|
||||
|
||||
template<typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2& p2) const
|
||||
|
@ -57,7 +60,8 @@ struct strategy_group
|
|||
}
|
||||
|
||||
template<typename P1, typename P2, typename... Args, std::size_t... Is>
|
||||
inline P2 execute_start(P1 const & p1, bool & status, std::tuple<Args const&...> const& tup, helper::index<Is...>) const
|
||||
inline P2
|
||||
execute_start(P1 const& p1, bool& status, std::tuple<Args const&...> const& tup, helper::index<Is...>) const
|
||||
{
|
||||
return execute<P1, P2, Args...>(p1, status, std::get<Is>(tup)...);
|
||||
}
|
||||
|
@ -82,17 +86,16 @@ struct strategy_group
|
|||
|
||||
private:
|
||||
std::tuple<Strategies const&...> ops_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// The difference between this strategy group and the previous is that the conversion from P1 to P2 happens
|
||||
// in the first strategy rather then the last strategy.
|
||||
template<typename... Strategies>
|
||||
struct strategy_group_first
|
||||
{
|
||||
strategy_group_first(Strategies const&... ops)
|
||||
: ops_(ops ...) {}
|
||||
: ops_(ops...)
|
||||
{}
|
||||
|
||||
template<typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2& p2) const
|
||||
|
@ -103,7 +106,8 @@ struct strategy_group_first
|
|||
}
|
||||
|
||||
template<typename P1, typename P2, typename... Args, std::size_t... Is>
|
||||
inline P2 execute_start(P1 const & p1, bool & status, std::tuple<Args const&...> const& tup, helper::index<Is...>) const
|
||||
inline P2
|
||||
execute_start(P1 const& p1, bool& status, std::tuple<Args const&...> const& tup, helper::index<Is...>) const
|
||||
{
|
||||
return execute_first<P1, P2, Args...>(p1, status, std::get<Is>(tup)...);
|
||||
}
|
||||
|
@ -140,18 +144,18 @@ struct strategy_group_first
|
|||
|
||||
private:
|
||||
std::tuple<Strategies const&...> ops_;
|
||||
|
||||
};
|
||||
|
||||
struct scale_strategy
|
||||
{
|
||||
scale_strategy(double scale, double offset = 0)
|
||||
: scale_(scale), offset_(offset) {}
|
||||
: scale_(scale)
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
template<typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2& p2) const
|
||||
{
|
||||
|
||||
using p2_type = typename boost::geometry::coordinate_type<P2>::type;
|
||||
double x = (boost::geometry::get<0>(p1) * scale_) + offset_;
|
||||
double y = (boost::geometry::get<1>(p1) * scale_) + offset_;
|
||||
|
@ -176,12 +180,13 @@ private:
|
|||
struct scale_rounding_strategy
|
||||
{
|
||||
scale_rounding_strategy(double scale, double offset = 0)
|
||||
: scale_(scale), offset_(offset) {}
|
||||
: scale_(scale)
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
template<typename P1, typename P2>
|
||||
inline bool apply(P1 const& p1, P2& p2) const
|
||||
{
|
||||
|
||||
using p2_type = typename boost::geometry::coordinate_type<P2>::type;
|
||||
double x = (boost::geometry::get<0>(p1) * scale_) + offset_;
|
||||
double y = (boost::geometry::get<1>(p1) * scale_) + offset_;
|
||||
|
@ -203,8 +208,7 @@ private:
|
|||
double offset_;
|
||||
};
|
||||
|
||||
|
||||
} // end geometry ns
|
||||
} // end mapnik ns
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_STRATEGY_HPP
|
||||
|
|
|
@ -26,18 +26,18 @@
|
|||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/path.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry { namespace detail {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
struct geometry_to_path
|
||||
{
|
||||
geometry_to_path(path_type& p)
|
||||
: p_(p) {}
|
||||
: p_(p)
|
||||
{}
|
||||
|
||||
void operator() (geometry<T> const& geom) const
|
||||
{
|
||||
mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
void operator()(geometry<T> const& geom) const { mapnik::util::apply_visitor(*this, geom); }
|
||||
|
||||
void operator()(geometry_empty const&) const
|
||||
{
|
||||
|
@ -59,8 +59,13 @@ struct geometry_to_path
|
|||
{
|
||||
// point pt_new;
|
||||
// Transformer::apply(pt, pt_new);
|
||||
if (first) { p_.move_to(pt.x, pt.y); first=false;}
|
||||
else p_.line_to(pt.x, pt.y);
|
||||
if (first)
|
||||
{
|
||||
p_.move_to(pt.x, pt.y);
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
p_.line_to(pt.x, pt.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,9 +130,8 @@ struct geometry_to_path
|
|||
}
|
||||
|
||||
path_type& p_;
|
||||
|
||||
};
|
||||
} // ns detail
|
||||
} // namespace detail
|
||||
|
||||
template<typename T>
|
||||
void to_path(T const& geom, path_type& p)
|
||||
|
@ -137,6 +141,7 @@ void to_path(T const& geom, path_type & p)
|
|||
func(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_TO_PATH_HPP
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include <mapnik/geometry/boost_adapters.hpp>
|
||||
#include <boost/geometry/algorithms/transform.hpp>
|
||||
|
||||
namespace mapnik { namespace geometry { namespace detail {
|
||||
namespace mapnik {
|
||||
namespace geometry {
|
||||
namespace detail {
|
||||
|
||||
template<typename V, typename T, typename Transformer>
|
||||
inline point<V> transform_geometry(point<T> const& geom, Transformer const& transformer)
|
||||
|
@ -99,14 +101,12 @@ template <typename Transformer, typename V>
|
|||
struct geometry_transform
|
||||
{
|
||||
geometry_transform(Transformer const& transformer)
|
||||
: transformer_(transformer) {}
|
||||
: transformer_(transformer)
|
||||
{}
|
||||
|
||||
using result_type = geometry<V>;
|
||||
|
||||
geometry<V> operator() (geometry_empty const& empty) const
|
||||
{
|
||||
return geometry_empty();
|
||||
}
|
||||
geometry<V> operator()(geometry_empty const& empty) const { return geometry_empty(); }
|
||||
|
||||
template<typename T>
|
||||
geometry<V> operator()(geometry_collection<T> const& collection) const
|
||||
|
@ -164,7 +164,7 @@ struct geometry_transform
|
|||
Transformer const& transformer_;
|
||||
};
|
||||
|
||||
} // ns detail
|
||||
} // namespace detail
|
||||
|
||||
template<typename T0, typename T1, typename T2>
|
||||
geometry<T0> transform(geometry<T1> const& geom, T2 const& transformer)
|
||||
|
@ -214,7 +214,7 @@ multi_polygon<T0> transform(multi_polygon<T1> const& geom, T2 const& transformer
|
|||
return detail::transform_geometry<T0>(geom, transformer);
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
} // namespace geometry
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_TRANSFORM_HPP
|
||||
|
|
|
@ -28,27 +28,24 @@
|
|||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
#define int2net(A) (int16_t) (((std::uint16_t) ((std::uint8_t) (A)[1])) | \
|
||||
(((std::uint16_t) ((std::uint8_t) (A)[0])) << 8))
|
||||
#define int2net(A) (int16_t)(((std::uint16_t)((std::uint8_t)(A)[1])) | (((std::uint16_t)((std::uint8_t)(A)[0])) << 8))
|
||||
|
||||
#define int4net(A) (int32_t) (((std::uint32_t) ((std::uint8_t) (A)[3])) | \
|
||||
(((std::uint32_t) ((std::uint8_t) (A)[2])) << 8) | \
|
||||
(((std::uint32_t) ((std::uint8_t) (A)[1])) << 16) | \
|
||||
(((std::uint32_t) ((std::uint8_t) (A)[0])) << 24))
|
||||
#define int4net(A) \
|
||||
(int32_t)(((std::uint32_t)((std::uint8_t)(A)[3])) | (((std::uint32_t)((std::uint8_t)(A)[2])) << 8) | \
|
||||
(((std::uint32_t)((std::uint8_t)(A)[1])) << 16) | (((std::uint32_t)((std::uint8_t)(A)[0])) << 24))
|
||||
|
||||
#define int8net(A) (int64_t) (((std::uint64_t) ((std::uint8_t) (A)[7])) | \
|
||||
(((std::uint64_t) ((std::uint8_t) (A)[6])) << 8) | \
|
||||
(((std::uint64_t) ((std::uint8_t) (A)[5])) << 16) | \
|
||||
(((std::uint64_t) ((std::uint8_t) (A)[4])) << 24) | \
|
||||
(((std::uint64_t) ((std::uint8_t) (A)[3])) << 32) | \
|
||||
(((std::uint64_t) ((std::uint8_t) (A)[2])) << 40) | \
|
||||
(((std::uint64_t) ((std::uint8_t) (A)[1])) << 48) | \
|
||||
(((std::uint64_t) ((std::uint8_t) (A)[0])) << 56))
|
||||
#define int8net(A) \
|
||||
(int64_t)(((std::uint64_t)((std::uint8_t)(A)[7])) | (((std::uint64_t)((std::uint8_t)(A)[6])) << 8) | \
|
||||
(((std::uint64_t)((std::uint8_t)(A)[5])) << 16) | (((std::uint64_t)((std::uint8_t)(A)[4])) << 24) | \
|
||||
(((std::uint64_t)((std::uint8_t)(A)[3])) << 32) | (((std::uint64_t)((std::uint8_t)(A)[2])) << 40) | \
|
||||
(((std::uint64_t)((std::uint8_t)(A)[1])) << 48) | (((std::uint64_t)((std::uint8_t)(A)[0])) << 56))
|
||||
|
||||
#define float8net(V,M) do { double def_temp; \
|
||||
#define float8net(V, M) \
|
||||
do \
|
||||
{ \
|
||||
double def_temp; \
|
||||
((std::uint8_t*)&def_temp)[0] = (M)[7]; \
|
||||
((std::uint8_t*)&def_temp)[1] = (M)[6]; \
|
||||
((std::uint8_t*)&def_temp)[2] = (M)[5]; \
|
||||
|
@ -57,14 +54,18 @@ namespace mapnik
|
|||
((std::uint8_t*)&def_temp)[5] = (M)[2]; \
|
||||
((std::uint8_t*)&def_temp)[6] = (M)[1]; \
|
||||
((std::uint8_t*)&def_temp)[7] = (M)[0]; \
|
||||
(V) = def_temp; } while(0)
|
||||
#define float4net(V,M) do { float def_temp; \
|
||||
(V) = def_temp; \
|
||||
} while (0)
|
||||
#define float4net(V, M) \
|
||||
do \
|
||||
{ \
|
||||
float def_temp; \
|
||||
((std::uint8_t*)&def_temp)[0] = (M)[3]; \
|
||||
((std::uint8_t*)&def_temp)[1] = (M)[2]; \
|
||||
((std::uint8_t*)&def_temp)[2] = (M)[1]; \
|
||||
((std::uint8_t*)&def_temp)[3] = (M)[0]; \
|
||||
(V)=def_temp; } while(0)
|
||||
|
||||
(V) = def_temp; \
|
||||
} while (0)
|
||||
|
||||
// read int16_t NDR (little endian)
|
||||
inline void read_int16_ndr(const char* data, std::int16_t& val)
|
||||
|
@ -99,14 +100,11 @@ inline void read_int32_xdr(const char* data, std::int32_t & val)
|
|||
// read double XDR (big endian)
|
||||
inline void read_double_xdr(const char* data, double& val)
|
||||
{
|
||||
std::int64_t bits = (static_cast<std::int64_t>(data[7]) & 0xff) |
|
||||
(static_cast<std::int64_t>(data[6]) & 0xff) << 8 |
|
||||
(static_cast<std::int64_t>(data[5]) & 0xff) << 16 |
|
||||
(static_cast<std::int64_t>(data[4]) & 0xff) << 24 |
|
||||
(static_cast<std::int64_t>(data[3]) & 0xff) << 32 |
|
||||
(static_cast<std::int64_t>(data[2]) & 0xff) << 40 |
|
||||
(static_cast<std::int64_t>(data[1]) & 0xff) << 48 |
|
||||
(static_cast<std::int64_t>(data[0]) & 0xff) << 56 ;
|
||||
std::int64_t bits =
|
||||
(static_cast<std::int64_t>(data[7]) & 0xff) | (static_cast<std::int64_t>(data[6]) & 0xff) << 8 |
|
||||
(static_cast<std::int64_t>(data[5]) & 0xff) << 16 | (static_cast<std::int64_t>(data[4]) & 0xff) << 24 |
|
||||
(static_cast<std::int64_t>(data[3]) & 0xff) << 32 | (static_cast<std::int64_t>(data[2]) & 0xff) << 40 |
|
||||
(static_cast<std::int64_t>(data[1]) & 0xff) << 48 | (static_cast<std::int64_t>(data[0]) & 0xff) << 56;
|
||||
std::memcpy(&val, &bits, 8);
|
||||
}
|
||||
|
||||
|
@ -117,6 +115,6 @@ inline double round(double val)
|
|||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GLOBAL_HPP
|
||||
|
|
|
@ -35,24 +35,18 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
// stl
|
||||
#include <vector>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
using stop_pair = std::pair<double, mapnik::color>;
|
||||
using stop_array = std::vector<stop_pair>;
|
||||
|
||||
enum gradient_e
|
||||
{
|
||||
NO_GRADIENT,
|
||||
LINEAR,
|
||||
RADIAL
|
||||
};
|
||||
enum gradient_e { NO_GRADIENT, LINEAR, RADIAL };
|
||||
|
||||
enum gradient_unit_e
|
||||
{
|
||||
enum gradient_unit_e {
|
||||
USER_SPACE_ON_USE,
|
||||
USER_SPACE_ON_USE_BOUNDING_BOX, // used to indicate % age values were specified. This are % of the svg image extent.
|
||||
OBJECT_BOUNDING_BOX // (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding box and (1,1) is at the bottom/right of the object bounding box)
|
||||
OBJECT_BOUNDING_BOX // (i.e., the abstract coordinate system where (0,0) is at the top/left of the object bounding
|
||||
// box and (1,1) is at the bottom/right of the object bounding box)
|
||||
};
|
||||
|
||||
class MAPNIK_DECL gradient
|
||||
|
@ -99,6 +93,6 @@ public:
|
|||
private:
|
||||
void swap(gradient& other) noexcept;
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GRADIENT_HPP
|
||||
|
|
|
@ -42,8 +42,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
template<typename T>
|
||||
class MAPNIK_DECL hit_grid
|
||||
|
@ -79,90 +78,44 @@ public:
|
|||
|
||||
void clear();
|
||||
|
||||
inline void painted(bool is_painted)
|
||||
{
|
||||
painted_ = is_painted;
|
||||
}
|
||||
inline void painted(bool is_painted) { painted_ = is_painted; }
|
||||
|
||||
inline bool painted() const
|
||||
{
|
||||
return painted_;
|
||||
}
|
||||
inline bool painted() const { return painted_; }
|
||||
|
||||
inline std::string const& key_name() const
|
||||
{
|
||||
return id_name_;
|
||||
}
|
||||
inline std::string const& key_name() const { return id_name_; }
|
||||
|
||||
void add_feature(mapnik::feature_impl const& feature);
|
||||
|
||||
inline void add_field(std::string const& name)
|
||||
{
|
||||
names_.insert(name);
|
||||
}
|
||||
inline void add_field(std::string const& name) { names_.insert(name); }
|
||||
|
||||
inline std::set<std::string> const& get_fields() const
|
||||
{
|
||||
return names_;
|
||||
}
|
||||
inline std::set<std::string> const& get_fields() const { return names_; }
|
||||
|
||||
inline feature_type const& get_grid_features() const
|
||||
{
|
||||
return features_;
|
||||
}
|
||||
inline feature_type const& get_grid_features() const { return features_; }
|
||||
|
||||
inline feature_key_type const& get_feature_keys() const
|
||||
{
|
||||
return f_keys_;
|
||||
}
|
||||
inline feature_key_type const& get_feature_keys() const { return f_keys_; }
|
||||
|
||||
inline std::string const& get_key() const
|
||||
{
|
||||
return key_;
|
||||
}
|
||||
inline std::string const& get_key() const { return key_; }
|
||||
|
||||
inline void set_key(std::string const& key)
|
||||
{
|
||||
key_ = key;
|
||||
}
|
||||
inline void set_key(std::string const& key) { key_ = key; }
|
||||
|
||||
inline data_type const& data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
inline data_type const& data() const { return data_; }
|
||||
|
||||
inline data_type& data()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
inline data_type& data() { return data_; }
|
||||
|
||||
inline value_type const * raw_data() const
|
||||
{
|
||||
return data_.data();
|
||||
}
|
||||
inline value_type const* raw_data() const { return data_.data(); }
|
||||
|
||||
inline value_type* raw_data()
|
||||
{
|
||||
return data_.data();
|
||||
}
|
||||
inline value_type* raw_data() { return data_.data(); }
|
||||
|
||||
inline value_type const * get_row(std::size_t row) const
|
||||
{
|
||||
return data_.get_row(row);
|
||||
}
|
||||
inline value_type const* get_row(std::size_t row) const { return data_.get_row(row); }
|
||||
|
||||
inline mapnik::grid_view get_view(std::size_t x, std::size_t y, std::size_t w, std::size_t h)
|
||||
{
|
||||
return mapnik::grid_view(x, y, w, h,
|
||||
data_, key_, id_name_, names_, f_keys_, features_);
|
||||
return mapnik::grid_view(x, y, w, h, data_, key_, id_name_, names_, f_keys_, features_);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
inline bool checkBounds(std::size_t x, std::size_t y) const
|
||||
{
|
||||
return (x < width_ && y < height_);
|
||||
}
|
||||
inline bool checkBounds(std::size_t x, std::size_t y) const { return (x < width_ && y < height_); }
|
||||
|
||||
hit_grid& operator=(const hit_grid&);
|
||||
|
||||
|
@ -174,15 +127,9 @@ public:
|
|||
data_(x, y) = feature_id;
|
||||
}
|
||||
}
|
||||
inline std::size_t width() const
|
||||
{
|
||||
return width_;
|
||||
}
|
||||
inline std::size_t width() const { return width_; }
|
||||
|
||||
inline std::size_t height() const
|
||||
{
|
||||
return height_;
|
||||
}
|
||||
inline std::size_t height() const { return height_; }
|
||||
|
||||
inline void set_rectangle(value_type id, image_rgba8 const& data, std::size_t x0, std::size_t y0)
|
||||
{
|
||||
|
@ -219,5 +166,5 @@ public:
|
|||
|
||||
using grid = hit_grid<mapnik::value_integer_pixel>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
#endif // MAPNIK_GRID_HPP
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
|
||||
#include "agg_basics.h"
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
//==================================================================gray16
|
||||
struct gray16
|
||||
|
@ -34,12 +33,7 @@ struct gray16
|
|||
using value_type = agg::int16u;
|
||||
using calc_type = agg::int32u;
|
||||
using long_type = agg::int64;
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 16,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1
|
||||
};
|
||||
enum base_scale_e { base_shift = 16, base_scale = 1 << base_shift, base_mask = base_scale - 1 };
|
||||
using self_type = gray16;
|
||||
|
||||
value_type v;
|
||||
|
@ -49,18 +43,19 @@ struct gray16
|
|||
gray16() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(unsigned v_, unsigned a_=base_mask) :
|
||||
v(agg::int16u(v_)), a(agg::int16u(a_)) {}
|
||||
gray16(unsigned v_, unsigned a_ = base_mask)
|
||||
: v(agg::int16u(v_))
|
||||
, a(agg::int16u(a_))
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray16(const self_type& c, unsigned a_) :
|
||||
v(c.v), a(value_type(a_)) {}
|
||||
gray16(const self_type& c, unsigned a_)
|
||||
: v(c.v)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void clear()
|
||||
{
|
||||
v = a = 0;
|
||||
}
|
||||
void clear() { v = a = 0; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& transparent()
|
||||
|
@ -69,11 +64,11 @@ struct gray16
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& premultiply()
|
||||
{
|
||||
if(a == base_mask) return *this;
|
||||
if (a == base_mask)
|
||||
return *this;
|
||||
if (a == 0)
|
||||
{
|
||||
v = 0;
|
||||
|
@ -86,7 +81,8 @@ struct gray16
|
|||
//--------------------------------------------------------------------
|
||||
const self_type& premultiply(unsigned a_)
|
||||
{
|
||||
if(a == base_mask && a_ >= base_mask) return *this;
|
||||
if (a == base_mask && a_ >= base_mask)
|
||||
return *this;
|
||||
if (a == 0 || a_ == 0)
|
||||
{
|
||||
v = a = 0;
|
||||
|
@ -101,7 +97,8 @@ struct gray16
|
|||
//--------------------------------------------------------------------
|
||||
const self_type& demultiply()
|
||||
{
|
||||
if(a == base_mask) return *this;
|
||||
if (a == base_mask)
|
||||
return *this;
|
||||
if (a == 0)
|
||||
{
|
||||
v = 0;
|
||||
|
@ -134,8 +131,10 @@ struct gray16
|
|||
}
|
||||
else
|
||||
{
|
||||
cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
|
||||
ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
|
||||
cv = v + c.v;
|
||||
v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
|
||||
ca = a + c.a;
|
||||
a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -162,12 +161,7 @@ struct gray32
|
|||
// in grid_pixfmt.hpp#blend_hiline#l256
|
||||
// otherwise code will get invoked that breaks
|
||||
// with 32 bit or 64 bit ints (blender_gray::blend_pix)
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 16,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1
|
||||
};
|
||||
enum base_scale_e { base_shift = 16, base_scale = 1 << base_shift, base_mask = base_scale - 1 };
|
||||
using self_type = gray32;
|
||||
|
||||
value_type v;
|
||||
|
@ -177,18 +171,19 @@ struct gray32
|
|||
gray32() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(value_type v_, unsigned a_=base_mask) :
|
||||
v(v_), a(value_type(a_)) {}
|
||||
gray32(value_type v_, unsigned a_ = base_mask)
|
||||
: v(v_)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray32(const self_type& c, unsigned a_) :
|
||||
v(c.v), a(value_type(a_)) {}
|
||||
gray32(const self_type& c, unsigned a_)
|
||||
: v(c.v)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void clear()
|
||||
{
|
||||
v = a = 0;
|
||||
}
|
||||
void clear() { v = a = 0; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& transparent()
|
||||
|
@ -197,11 +192,11 @@ struct gray32
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& premultiply()
|
||||
{
|
||||
if(a == base_mask) return *this;
|
||||
if (a == base_mask)
|
||||
return *this;
|
||||
if (a == 0)
|
||||
{
|
||||
v = 0;
|
||||
|
@ -214,7 +209,8 @@ struct gray32
|
|||
//--------------------------------------------------------------------
|
||||
const self_type& premultiply(unsigned a_)
|
||||
{
|
||||
if(a == base_mask && a_ >= base_mask) return *this;
|
||||
if (a == base_mask && a_ >= base_mask)
|
||||
return *this;
|
||||
if (a == 0 || a_ == 0)
|
||||
{
|
||||
v = a = 0;
|
||||
|
@ -229,7 +225,8 @@ struct gray32
|
|||
//--------------------------------------------------------------------
|
||||
const self_type& demultiply()
|
||||
{
|
||||
if(a == base_mask) return *this;
|
||||
if (a == base_mask)
|
||||
return *this;
|
||||
if (a == 0)
|
||||
{
|
||||
v = 0;
|
||||
|
@ -262,8 +259,10 @@ struct gray32
|
|||
}
|
||||
else
|
||||
{
|
||||
cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
|
||||
ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
|
||||
cv = v + c.v;
|
||||
v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
|
||||
ca = a + c.a;
|
||||
a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -290,12 +289,7 @@ struct gray64
|
|||
// in grid_pixfmt.hpp#blend_hiline#l256
|
||||
// otherwise code will get invoked that breaks
|
||||
// with 32 bit or 64 bit ints (blender_gray::blend_pix)
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = 16,
|
||||
base_scale = 1 << base_shift,
|
||||
base_mask = base_scale - 1
|
||||
};
|
||||
enum base_scale_e { base_shift = 16, base_scale = 1 << base_shift, base_mask = base_scale - 1 };
|
||||
using self_type = gray64;
|
||||
|
||||
value_type v;
|
||||
|
@ -305,18 +299,19 @@ struct gray64
|
|||
gray64() {}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray64(value_type v_, unsigned a_=base_mask) :
|
||||
v(v_), a(value_type(a_)) {}
|
||||
gray64(value_type v_, unsigned a_ = base_mask)
|
||||
: v(v_)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
gray64(const self_type& c, unsigned a_) :
|
||||
v(c.v), a(value_type(a_)) {}
|
||||
gray64(const self_type& c, unsigned a_)
|
||||
: v(c.v)
|
||||
, a(value_type(a_))
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void clear()
|
||||
{
|
||||
v = a = 0;
|
||||
}
|
||||
void clear() { v = a = 0; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& transparent()
|
||||
|
@ -325,11 +320,11 @@ struct gray64
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
const self_type& premultiply()
|
||||
{
|
||||
if(a == base_mask) return *this;
|
||||
if (a == base_mask)
|
||||
return *this;
|
||||
if (a == 0)
|
||||
{
|
||||
v = 0;
|
||||
|
@ -342,7 +337,8 @@ struct gray64
|
|||
//--------------------------------------------------------------------
|
||||
const self_type& premultiply(unsigned a_)
|
||||
{
|
||||
if(a == base_mask && a_ >= base_mask) return *this;
|
||||
if (a == base_mask && a_ >= base_mask)
|
||||
return *this;
|
||||
if (a == 0 || a_ == 0)
|
||||
{
|
||||
v = a = 0;
|
||||
|
@ -357,7 +353,8 @@ struct gray64
|
|||
//--------------------------------------------------------------------
|
||||
const self_type& demultiply()
|
||||
{
|
||||
if(a == base_mask) return *this;
|
||||
if (a == base_mask)
|
||||
return *this;
|
||||
if (a == 0)
|
||||
{
|
||||
v = 0;
|
||||
|
@ -390,8 +387,10 @@ struct gray64
|
|||
}
|
||||
else
|
||||
{
|
||||
cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
|
||||
ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
|
||||
cv = v + c.v;
|
||||
v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv;
|
||||
ca = a + c.a;
|
||||
a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -407,6 +406,6 @@ struct gray64
|
|||
static self_type no_color() { return self_type(0, 0); }
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,64 +33,57 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
//============================================================blender_gray
|
||||
template<typename ColorT> struct blender_gray
|
||||
template<typename ColorT>
|
||||
struct blender_gray
|
||||
{
|
||||
using color_type = ColorT;
|
||||
using value_type = typename color_type::value_type;
|
||||
using calc_type = typename color_type::calc_type;
|
||||
enum base_scale_e { base_shift = color_type::base_shift };
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p, unsigned cv,
|
||||
unsigned alpha, unsigned /*cover*/=0)
|
||||
static AGG_INLINE void blend_pix(value_type* p, unsigned cv, unsigned alpha, unsigned /*cover*/ = 0)
|
||||
{
|
||||
*p = (value_type)((((cv - calc_type(*p)) * alpha) + (calc_type(*p) << base_shift)) >> base_shift);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=====================================================apply_gamma_dir_gray
|
||||
template<typename ColorT, class GammaLut> class apply_gamma_dir_gray
|
||||
template<typename ColorT, class GammaLut>
|
||||
class apply_gamma_dir_gray
|
||||
{
|
||||
public:
|
||||
using value_type = typename ColorT::value_type;
|
||||
|
||||
apply_gamma_dir_gray(const GammaLut& gamma) : m_gamma(gamma) {}
|
||||
apply_gamma_dir_gray(const GammaLut& gamma)
|
||||
: m_gamma(gamma)
|
||||
{}
|
||||
|
||||
AGG_INLINE void operator () (value_type* p)
|
||||
{
|
||||
*p = m_gamma.dir(*p);
|
||||
}
|
||||
AGG_INLINE void operator()(value_type* p) { *p = m_gamma.dir(*p); }
|
||||
|
||||
private:
|
||||
const GammaLut& m_gamma;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=====================================================apply_gamma_inv_gray
|
||||
template<typename ColorT, class GammaLut> class apply_gamma_inv_gray
|
||||
template<typename ColorT, class GammaLut>
|
||||
class apply_gamma_inv_gray
|
||||
{
|
||||
public:
|
||||
using value_type = typename ColorT::value_type;
|
||||
|
||||
apply_gamma_inv_gray(const GammaLut& gamma) : m_gamma(gamma) {}
|
||||
apply_gamma_inv_gray(const GammaLut& gamma)
|
||||
: m_gamma(gamma)
|
||||
{}
|
||||
|
||||
AGG_INLINE void operator () (value_type* p)
|
||||
{
|
||||
*p = m_gamma.inv(*p);
|
||||
}
|
||||
AGG_INLINE void operator()(value_type* p) { *p = m_gamma.inv(*p); }
|
||||
|
||||
private:
|
||||
const GammaLut& m_gamma;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=================================================pixfmt_alpha_blend_gray
|
||||
template<typename Blender, class RenBuf, unsigned Step = 1, unsigned Offset = 0>
|
||||
class pixfmt_alpha_blend_gray
|
||||
|
@ -103,8 +96,7 @@ public:
|
|||
using order_type = int; // A fake one
|
||||
using value_type = typename color_type::value_type;
|
||||
using calc_type = typename color_type::calc_type;
|
||||
enum base_scale_e
|
||||
{
|
||||
enum base_scale_e {
|
||||
base_shift = color_type::base_shift,
|
||||
base_scale = color_type::base_scale,
|
||||
base_mask = color_type::base_mask,
|
||||
|
@ -115,9 +107,7 @@ public:
|
|||
|
||||
private:
|
||||
//--------------------------------------------------------------------
|
||||
static AGG_INLINE void copy_or_blend_pix(value_type* p,
|
||||
const color_type& c,
|
||||
unsigned cover)
|
||||
static AGG_INLINE void copy_or_blend_pix(value_type* p, const color_type& c, unsigned cover)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
|
@ -133,9 +123,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static AGG_INLINE void copy_or_blend_pix(value_type* p,
|
||||
const color_type& c)
|
||||
static AGG_INLINE void copy_or_blend_pix(value_type* p, const color_type& c)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
|
@ -150,11 +138,10 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
//--------------------------------------------------------------------
|
||||
explicit pixfmt_alpha_blend_gray(rbuf_type& rb) :
|
||||
m_rbuf(&rb)
|
||||
explicit pixfmt_alpha_blend_gray(rbuf_type& rb)
|
||||
: m_rbuf(&rb)
|
||||
{}
|
||||
void attach(rbuf_type& rb) { m_rbuf = &rb; }
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -166,10 +153,7 @@ public:
|
|||
if (r.clip(agg::rect_i(0, 0, pixf.width() - 1, pixf.height() - 1)))
|
||||
{
|
||||
int stride = pixf.stride();
|
||||
m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1),
|
||||
(r.x2 - r.x1) + 1,
|
||||
(r.y2 - r.y1) + 1,
|
||||
stride);
|
||||
m_rbuf->attach(pixf.pix_ptr(r.x1, stride < 0 ? r.y2 : r.y1), (r.x2 - r.x1) + 1, (r.y2 - r.y1) + 1, stride);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -185,21 +169,12 @@ public:
|
|||
const agg::int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); }
|
||||
row_data row(int y) const { return m_rbuf->row(y); }
|
||||
|
||||
const agg::int8u* pix_ptr(int x, int y) const
|
||||
{
|
||||
return m_rbuf->row_ptr(y) + x * Step + Offset;
|
||||
}
|
||||
const agg::int8u* pix_ptr(int x, int y) const { return m_rbuf->row_ptr(y) + x * Step + Offset; }
|
||||
|
||||
agg::int8u* pix_ptr(int x, int y)
|
||||
{
|
||||
return m_rbuf->row_ptr(y) + x * Step + Offset;
|
||||
}
|
||||
agg::int8u* pix_ptr(int x, int y) { return m_rbuf->row_ptr(y) + x * Step + Offset; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE static void make_pix(agg::int8u* p, const color_type& c)
|
||||
{
|
||||
*(value_type*)p = c.v;
|
||||
}
|
||||
AGG_INLINE static void make_pix(agg::int8u* p, const color_type& c) { *(value_type*)p = c.v; }
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE color_type pixel(int x, int y) const
|
||||
|
@ -217,60 +192,41 @@ public:
|
|||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void blend_pixel(int x, int y, const color_type& c, agg::int8u cover)
|
||||
{
|
||||
copy_or_blend_pix((value_type*)
|
||||
m_rbuf->row_ptr(x, y, 1) + x * Step + Offset,
|
||||
c,
|
||||
cover);
|
||||
copy_or_blend_pix((value_type*)m_rbuf->row_ptr(x, y, 1) + x * Step + Offset, c, cover);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
AGG_INLINE void copy_hline(int x, int y, unsigned len, const color_type& c)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
|
||||
do
|
||||
{
|
||||
*p = c.v;
|
||||
p += Step;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
AGG_INLINE void copy_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c)
|
||||
AGG_INLINE void copy_vline(int x, int y, unsigned len, const color_type& c)
|
||||
{
|
||||
do
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
*p = c.v;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_hline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
agg::int8u /*cover*/)
|
||||
void blend_hline(int x, int y, unsigned len, const color_type& c, agg::int8u /*cover*/)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
do
|
||||
{
|
||||
*p = c.v;
|
||||
p += Step;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
// We ignore alpha since grid_renderer is a binary renderer for now
|
||||
/*if (c.a)
|
||||
{
|
||||
|
@ -299,12 +255,8 @@ public:
|
|||
}*/
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_vline(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
agg::int8u cover)
|
||||
void blend_vline(int x, int y, unsigned len, const color_type& c, agg::int8u cover)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
|
@ -314,38 +266,29 @@ public:
|
|||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
*p = c.v;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
Blender::blend_pix(p, c.v, alpha, cover);
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const agg::int8u* covers)
|
||||
void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const agg::int8u* covers)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -360,17 +303,12 @@ public:
|
|||
}
|
||||
p += Step;
|
||||
++covers;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_solid_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type& c,
|
||||
const agg::int8u* covers)
|
||||
void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const agg::int8u* covers)
|
||||
{
|
||||
if (c.a)
|
||||
{
|
||||
|
@ -378,8 +316,7 @@ public:
|
|||
{
|
||||
calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8;
|
||||
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
if (alpha == base_mask)
|
||||
{
|
||||
|
@ -390,55 +327,43 @@ public:
|
|||
Blender::blend_pix(p, c.v, alpha, *covers);
|
||||
}
|
||||
++covers;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_hspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors)
|
||||
void copy_color_hspan(int x, int y, unsigned len, const color_type* colors)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
|
||||
do
|
||||
{
|
||||
*p = colors->v;
|
||||
p += Step;
|
||||
++colors;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void copy_color_vspan(int x, int y,
|
||||
unsigned len,
|
||||
const color_type* colors)
|
||||
void copy_color_vspan(int x, int y, unsigned len, const color_type* colors)
|
||||
{
|
||||
do
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
*p = colors->v;
|
||||
++colors;
|
||||
} while (--len);
|
||||
}
|
||||
while(--len);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_hspan(int x, int y,
|
||||
void blend_color_hspan(int x,
|
||||
int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const agg::int8u* covers,
|
||||
agg::int8u cover)
|
||||
{
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x * Step + Offset;
|
||||
|
||||
if (covers)
|
||||
{
|
||||
|
@ -446,8 +371,7 @@ public:
|
|||
{
|
||||
copy_or_blend_pix(p, *colors++, *covers++);
|
||||
p += Step;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -465,8 +389,7 @@ public:
|
|||
}
|
||||
p += Step;
|
||||
++colors;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -474,16 +397,14 @@ public:
|
|||
{
|
||||
copy_or_blend_pix(p, *colors++, cover);
|
||||
p += Step;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void blend_color_vspan(int x, int y,
|
||||
void blend_color_vspan(int x,
|
||||
int y,
|
||||
unsigned len,
|
||||
const color_type* colors,
|
||||
const agg::int8u* covers,
|
||||
|
@ -494,12 +415,10 @@ public:
|
|||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
copy_or_blend_pix(p, *colors++, *covers++);
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -507,8 +426,7 @@ public:
|
|||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
if (colors->a == base_mask)
|
||||
{
|
||||
|
@ -519,19 +437,16 @@ public:
|
|||
copy_or_blend_pix(p, *colors);
|
||||
}
|
||||
++colors;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
p = (value_type*)
|
||||
m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset;
|
||||
|
||||
copy_or_blend_pix(p, *colors++, cover);
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -547,44 +462,39 @@ public:
|
|||
{
|
||||
unsigned len = r.x2 - r.x1 + 1;
|
||||
|
||||
value_type* p = (value_type*)
|
||||
m_rbuf->row_ptr(r.x1, y, len) + r.x1 * Step + Offset;
|
||||
value_type* p = (value_type*)m_rbuf->row_ptr(r.x1, y, len) + r.x1 * Step + Offset;
|
||||
|
||||
do
|
||||
{
|
||||
f(p);
|
||||
p += Step;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<typename GammaLut> void apply_gamma_dir(const GammaLut& g)
|
||||
template<typename GammaLut>
|
||||
void apply_gamma_dir(const GammaLut& g)
|
||||
{
|
||||
for_each_pixel(apply_gamma_dir_gray<color_type, GammaLut>(g));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<typename GammaLut> void apply_gamma_inv(const GammaLut& g)
|
||||
template<typename GammaLut>
|
||||
void apply_gamma_inv(const GammaLut& g)
|
||||
{
|
||||
for_each_pixel(apply_gamma_inv_gray<color_type, GammaLut>(g));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
template<typename RenBuf2>
|
||||
void copy_from(const RenBuf2& from,
|
||||
int xdst, int ydst,
|
||||
int xsrc, int ysrc,
|
||||
unsigned len)
|
||||
void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len)
|
||||
{
|
||||
const agg::int8u* p = from.row_ptr(ysrc);
|
||||
if (p)
|
||||
{
|
||||
memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width,
|
||||
p + xsrc * pix_width,
|
||||
len * pix_width);
|
||||
memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, p + xsrc * pix_width, len * pix_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,8 +502,10 @@ public:
|
|||
template<typename SrcPixelFormatRenderer>
|
||||
void blend_from_color(const SrcPixelFormatRenderer& from,
|
||||
const color_type& color,
|
||||
int xdst, int ydst,
|
||||
int /*xsrc*/, int ysrc,
|
||||
int xdst,
|
||||
int ydst,
|
||||
int /*xsrc*/,
|
||||
int ysrc,
|
||||
unsigned len,
|
||||
agg::int8u cover)
|
||||
{
|
||||
|
@ -601,17 +513,13 @@ public:
|
|||
const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc);
|
||||
if (psrc)
|
||||
{
|
||||
value_type* pdst =
|
||||
(value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst;
|
||||
value_type* pdst = (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst;
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(pdst,
|
||||
color,
|
||||
(*psrc * cover + base_mask) >> base_shift);
|
||||
copy_or_blend_pix(pdst, color, (*psrc * cover + base_mask) >> base_shift);
|
||||
++psrc;
|
||||
++pdst;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -619,8 +527,10 @@ public:
|
|||
template<typename SrcPixelFormatRenderer>
|
||||
void blend_from_lut(const SrcPixelFormatRenderer& from,
|
||||
const color_type* color_lut,
|
||||
int xdst, int ydst,
|
||||
int /*xsrc*/, int ysrc,
|
||||
int xdst,
|
||||
int ydst,
|
||||
int /*xsrc*/,
|
||||
int ysrc,
|
||||
unsigned len,
|
||||
agg::int8u cover)
|
||||
{
|
||||
|
@ -628,15 +538,13 @@ public:
|
|||
const src_value_type* psrc = (src_value_type*)from.row_ptr(ysrc);
|
||||
if (psrc)
|
||||
{
|
||||
value_type* pdst =
|
||||
(value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst;
|
||||
value_type* pdst = (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst;
|
||||
do
|
||||
{
|
||||
copy_or_blend_pix(pdst, color_lut[*psrc], cover);
|
||||
++psrc;
|
||||
++pdst;
|
||||
}
|
||||
while(--len);
|
||||
} while (--len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,6 +567,6 @@ using blender_gray64 = blender_gray<gray64>;
|
|||
using pixfmt_gray64 = pixfmt_alpha_blend_gray<blender_gray64,
|
||||
mapnik::grid_rendering_buffer>; //----pixfmt_gray64
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,8 +33,10 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
struct grid_rasterizer : agg::rasterizer_scanline_aa<>, util::noncopyable {};
|
||||
struct grid_rasterizer : agg::rasterizer_scanline_aa<>,
|
||||
util::noncopyable
|
||||
{};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_RASTERIZER_HPP
|
||||
|
|
|
@ -53,10 +53,14 @@ void render_raster_marker(RendererType ren,
|
|||
double width = src.width();
|
||||
double height = src.height();
|
||||
double p[8];
|
||||
p[0] = 0; p[1] = 0;
|
||||
p[2] = width; p[3] = 0;
|
||||
p[4] = width; p[5] = height;
|
||||
p[6] = 0; p[7] = height;
|
||||
p[0] = 0;
|
||||
p[1] = 0;
|
||||
p[2] = width;
|
||||
p[3] = 0;
|
||||
p[4] = width;
|
||||
p[5] = height;
|
||||
p[6] = 0;
|
||||
p[7] = height;
|
||||
marker_tr.transform(&p[0], &p[1]);
|
||||
marker_tr.transform(&p[2], &p[3]);
|
||||
marker_tr.transform(&p[4], &p[5]);
|
||||
|
@ -69,6 +73,6 @@ void render_raster_marker(RendererType ren,
|
|||
agg::render_scanlines(ras, sl, ren);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,7 +40,9 @@
|
|||
#include <memory>
|
||||
|
||||
// fwd declaration to avoid depedence on agg headers
|
||||
namespace agg { struct trans_affine; }
|
||||
namespace agg {
|
||||
struct trans_affine;
|
||||
}
|
||||
|
||||
// fwd declarations to speed up compile
|
||||
namespace mapnik {
|
||||
|
@ -53,7 +55,7 @@ namespace mapnik {
|
|||
class proj_transform;
|
||||
struct grid_rasterizer;
|
||||
class request;
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -61,12 +63,17 @@ template <typename T>
|
|||
class MAPNIK_DECL grid_renderer : public feature_style_processor<grid_renderer<T>>,
|
||||
private util::noncopyable
|
||||
{
|
||||
|
||||
public:
|
||||
using buffer_type = T;
|
||||
using processor_impl_type = grid_renderer<T>;
|
||||
grid_renderer(Map const& m, T& pixmap, double scale_factor = 1.0, unsigned offset_x = 0, unsigned offset_y = 0);
|
||||
grid_renderer(Map const& m, request const& req, attributes const& vars, T & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
grid_renderer(Map const& m,
|
||||
request const& req,
|
||||
attributes const& vars,
|
||||
T& pixmap,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0);
|
||||
~grid_renderer();
|
||||
void start_map_processing(Map const& map);
|
||||
void end_map_processing(Map const& map);
|
||||
|
@ -75,74 +82,39 @@ public:
|
|||
void start_style_processing(feature_type_style const& /*st*/) {}
|
||||
void end_style_processing(feature_type_style const& /*st*/) {}
|
||||
void render_marker(mapnik::feature_impl const& feature,
|
||||
pixel_position const& pos, marker const& marker,
|
||||
agg::trans_affine const& tr, double opacity, composite_mode_e comp_op);
|
||||
pixel_position const& pos,
|
||||
marker const& marker,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity,
|
||||
composite_mode_e comp_op);
|
||||
|
||||
void process(point_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
inline bool process(rule::symbolizers const& /*syms*/,
|
||||
mapnik::feature_impl & /*feature*/,
|
||||
proj_transform const& /*prj_trans*/)
|
||||
void process(point_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
inline bool
|
||||
process(rule::symbolizers const& /*syms*/, mapnik::feature_impl& /*feature*/, proj_transform const& /*prj_trans*/)
|
||||
{
|
||||
// grid renderer doesn't support processing of multiple symbolizers.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool painted()
|
||||
{
|
||||
return pixmap_.painted();
|
||||
}
|
||||
bool painted() { return pixmap_.painted(); }
|
||||
|
||||
void painted(bool _painted)
|
||||
{
|
||||
pixmap_.painted(_painted);
|
||||
}
|
||||
void painted(bool _painted) { pixmap_.painted(_painted); }
|
||||
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const
|
||||
{
|
||||
return DEFAULT;
|
||||
}
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; }
|
||||
|
||||
inline double scale_factor() const
|
||||
{
|
||||
return common_.scale_factor_;
|
||||
}
|
||||
inline double scale_factor() const { return common_.scale_factor_; }
|
||||
|
||||
inline attributes const& variables() const
|
||||
{
|
||||
return common_.vars_;
|
||||
}
|
||||
inline attributes const& variables() const { return common_.vars_; }
|
||||
|
||||
private:
|
||||
buffer_type& pixmap_;
|
||||
|
@ -150,6 +122,6 @@ private:
|
|||
renderer_common common_;
|
||||
void setup(Map const& m);
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // GRID_RENDERER_HPP
|
||||
|
|
|
@ -39,6 +39,6 @@ using grid_renderer_base_type = agg::renderer_base<mapnik::pixfmt_gray64>;
|
|||
using grid_renderer_base_type = agg::renderer_base<mapnik::pixfmt_gray32>;
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_RASTERIZER_HPP
|
||||
|
|
|
@ -50,51 +50,57 @@ public:
|
|||
using feature_key_type = std::map<value_type, lookup_type>;
|
||||
using feature_type = std::map<std::string, mapnik::feature_ptr>;
|
||||
|
||||
hit_grid_view(unsigned x, unsigned y,
|
||||
unsigned width, unsigned height,
|
||||
hit_grid_view(unsigned x,
|
||||
unsigned y,
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
T const& _data,
|
||||
std::string const& key,
|
||||
std::string const& id_name,
|
||||
std::set<std::string> const& names,
|
||||
feature_key_type const& f_keys,
|
||||
feature_type const& features
|
||||
)
|
||||
: x_(x),
|
||||
y_(y),
|
||||
width_(width),
|
||||
height_(height),
|
||||
data_(_data),
|
||||
key_(key),
|
||||
id_name_(id_name),
|
||||
names_(names),
|
||||
f_keys_(f_keys),
|
||||
features_(features)
|
||||
feature_type const& features)
|
||||
: x_(x)
|
||||
, y_(y)
|
||||
, width_(width)
|
||||
, height_(height)
|
||||
, data_(_data)
|
||||
, key_(key)
|
||||
, id_name_(id_name)
|
||||
, names_(names)
|
||||
, f_keys_(f_keys)
|
||||
, features_(features)
|
||||
|
||||
{
|
||||
if (x_ >= data_.width()) x_=data_.width()-1;
|
||||
if (y_ >= data_.height()) y_=data_.height()-1;
|
||||
if (x_ + width_ > data_.width()) width_= data_.width() - x_;
|
||||
if (y_ + height_ > data_.height()) height_= data_.height() - y_;
|
||||
if (x_ >= data_.width())
|
||||
x_ = data_.width() - 1;
|
||||
if (y_ >= data_.height())
|
||||
y_ = data_.height() - 1;
|
||||
if (x_ + width_ > data_.width())
|
||||
width_ = data_.width() - x_;
|
||||
if (y_ + height_ > data_.height())
|
||||
height_ = data_.height() - y_;
|
||||
}
|
||||
|
||||
~hit_grid_view() {}
|
||||
|
||||
hit_grid_view(hit_grid_view<T> const& rhs)
|
||||
: x_(rhs.x_),
|
||||
y_(rhs.y_),
|
||||
width_(rhs.width_),
|
||||
height_(rhs.height_),
|
||||
data_(rhs.data_),
|
||||
key_(rhs.key_),
|
||||
id_name_(rhs.id_name_),
|
||||
names_(rhs.names_),
|
||||
f_keys_(rhs.f_keys_),
|
||||
features_(rhs.features_)
|
||||
: x_(rhs.x_)
|
||||
, y_(rhs.y_)
|
||||
, width_(rhs.width_)
|
||||
, height_(rhs.height_)
|
||||
, data_(rhs.data_)
|
||||
, key_(rhs.key_)
|
||||
, id_name_(rhs.id_name_)
|
||||
, names_(rhs.names_)
|
||||
, f_keys_(rhs.f_keys_)
|
||||
, features_(rhs.features_)
|
||||
{}
|
||||
|
||||
hit_grid_view<T>& operator=(hit_grid_view<T> const& rhs)
|
||||
{
|
||||
if (&rhs==this) return *this;
|
||||
if (&rhs == this)
|
||||
return *this;
|
||||
x_ = rhs.x_;
|
||||
y_ = rhs.y_;
|
||||
width_ = rhs.width_;
|
||||
|
@ -108,70 +114,31 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline unsigned x() const
|
||||
{
|
||||
return x_;
|
||||
}
|
||||
inline unsigned x() const { return x_; }
|
||||
|
||||
inline unsigned y() const
|
||||
{
|
||||
return y_;
|
||||
}
|
||||
inline unsigned y() const { return y_; }
|
||||
|
||||
inline unsigned width() const
|
||||
{
|
||||
return width_;
|
||||
}
|
||||
inline unsigned width() const { return width_; }
|
||||
|
||||
inline unsigned height() const
|
||||
{
|
||||
return height_;
|
||||
}
|
||||
inline unsigned height() const { return height_; }
|
||||
|
||||
inline std::string const& key_name() const
|
||||
{
|
||||
return id_name_;
|
||||
}
|
||||
inline std::string const& key_name() const { return id_name_; }
|
||||
|
||||
inline value_type const * get_row(unsigned row) const
|
||||
{
|
||||
return data_.get_row(row + y_) + x_;
|
||||
}
|
||||
inline value_type const* get_row(unsigned row) const { return data_.get_row(row + y_) + x_; }
|
||||
|
||||
inline T& data()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
inline T& data() { return data_; }
|
||||
|
||||
inline T const& data() const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
inline T const& data() const { return data_; }
|
||||
|
||||
inline const unsigned char* raw_data() const
|
||||
{
|
||||
return data_.bytes();
|
||||
}
|
||||
inline const unsigned char* raw_data() const { return data_.bytes(); }
|
||||
|
||||
inline std::set<std::string> const& get_fields() const
|
||||
{
|
||||
return names_;
|
||||
}
|
||||
inline std::set<std::string> const& get_fields() const { return names_; }
|
||||
|
||||
inline feature_type const& get_grid_features() const
|
||||
{
|
||||
return features_;
|
||||
}
|
||||
inline feature_type const& get_grid_features() const { return features_; }
|
||||
|
||||
inline feature_key_type const& get_feature_keys() const
|
||||
{
|
||||
return f_keys_;
|
||||
}
|
||||
inline feature_key_type const& get_feature_keys() const { return f_keys_; }
|
||||
|
||||
inline lookup_type const& get_key() const
|
||||
{
|
||||
return key_;
|
||||
}
|
||||
inline lookup_type const& get_key() const { return key_; }
|
||||
|
||||
private:
|
||||
unsigned x_;
|
||||
|
@ -188,6 +155,6 @@ private:
|
|||
|
||||
using grid_view = hit_grid_view<mapnik::image<mapnik::value_integer_pixel>>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_GRID_VIEW_HPP
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue