move render_markers_symbolizer to separate .cpp
This commit is contained in:
parent
f99c0e5a6f
commit
6d84094f77
9 changed files with 129 additions and 82 deletions
4
Makefile
4
Makefile
|
@ -41,6 +41,7 @@ src/json/libmapnik-json.a:
|
||||||
$(PYTHON) scons/scons.py -j1 \
|
$(PYTHON) scons/scons.py -j1 \
|
||||||
--config=cache --implicit-cache --max-drift=1 \
|
--config=cache --implicit-cache --max-drift=1 \
|
||||||
src/renderer_common/render_group_symbolizer.os \
|
src/renderer_common/render_group_symbolizer.os \
|
||||||
|
src/renderer_common/render_markers_symbolizer.os \
|
||||||
src/renderer_common/render_thunk_extractor.os \
|
src/renderer_common/render_thunk_extractor.os \
|
||||||
src/json/libmapnik-json.a \
|
src/json/libmapnik-json.a \
|
||||||
src/wkt/libmapnik-wkt.a \
|
src/wkt/libmapnik-wkt.a \
|
||||||
|
@ -48,9 +49,6 @@ src/json/libmapnik-json.a:
|
||||||
src/expression_grammar.os \
|
src/expression_grammar.os \
|
||||||
src/transform_expression_grammar.os \
|
src/transform_expression_grammar.os \
|
||||||
src/image_filter_grammar.os \
|
src/image_filter_grammar.os \
|
||||||
src/agg/process_markers_symbolizer.os \
|
|
||||||
src/grid/process_markers_symbolizer.os \
|
|
||||||
src/cairo/process_markers_symbolizer.os \
|
|
||||||
|
|
||||||
mapnik: src/json/libmapnik-json.a
|
mapnik: src/json/libmapnik-json.a
|
||||||
# then install the rest with -j$(JOBS)
|
# then install the rest with -j$(JOBS)
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <mapnik/box2d.hpp>
|
#include <mapnik/box2d.hpp>
|
||||||
#include <mapnik/vertex_processor.hpp>
|
#include <mapnik/vertex_processor.hpp>
|
||||||
#include <mapnik/renderer_common/apply_vertex_converter.hpp>
|
#include <mapnik/renderer_common/apply_vertex_converter.hpp>
|
||||||
|
#include <mapnik/renderer_common/render_markers_symbolizer.hpp>
|
||||||
|
|
||||||
// agg
|
// agg
|
||||||
#include "agg_trans_affine.h"
|
#include "agg_trans_affine.h"
|
||||||
|
@ -48,55 +49,6 @@ struct clip_poly_tag;
|
||||||
|
|
||||||
using svg_attribute_type = agg::pod_bvector<svg::path_attributes>;
|
using svg_attribute_type = agg::pod_bvector<svg::path_attributes>;
|
||||||
|
|
||||||
struct markers_dispatch_params
|
|
||||||
{
|
|
||||||
// placement
|
|
||||||
markers_placement_params placement_params;
|
|
||||||
marker_placement_enum placement_method;
|
|
||||||
value_bool ignore_placement;
|
|
||||||
// rendering
|
|
||||||
bool snap_to_pixels;
|
|
||||||
double scale_factor;
|
|
||||||
value_double opacity;
|
|
||||||
|
|
||||||
markers_dispatch_params(box2d<double> const& size,
|
|
||||||
agg::trans_affine const& tr,
|
|
||||||
symbolizer_base const& sym,
|
|
||||||
feature_impl const& feature,
|
|
||||||
attributes const& vars,
|
|
||||||
double scale = 1.0,
|
|
||||||
bool snap = false)
|
|
||||||
: placement_params{
|
|
||||||
.size = size,
|
|
||||||
.tr = tr,
|
|
||||||
.spacing = get<value_double, keys::spacing>(sym, feature, vars),
|
|
||||||
.max_error = get<value_double, keys::max_error>(sym, feature, vars),
|
|
||||||
.allow_overlap = get<value_bool, keys::allow_overlap>(sym, feature, vars),
|
|
||||||
.avoid_edges = get<value_bool, keys::avoid_edges>(sym, feature, vars),
|
|
||||||
.direction = get<direction_enum, keys::direction>(sym, feature, vars)}
|
|
||||||
, placement_method(get<marker_placement_enum, keys::markers_placement_type>(sym, feature, vars))
|
|
||||||
, ignore_placement(get<value_bool, keys::ignore_placement>(sym, feature, vars))
|
|
||||||
, snap_to_pixels(snap)
|
|
||||||
, scale_factor(scale)
|
|
||||||
, opacity(get<value_double, keys::opacity>(sym, feature, vars))
|
|
||||||
{
|
|
||||||
placement_params.spacing *= scale;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct markers_renderer_context : util::noncopyable
|
|
||||||
{
|
|
||||||
virtual void render_marker(image_rgba8 const& src,
|
|
||||||
markers_dispatch_params const& params,
|
|
||||||
agg::trans_affine const& marker_tr) = 0;
|
|
||||||
|
|
||||||
virtual void render_marker(svg_path_ptr const& src,
|
|
||||||
svg_path_adapter & path,
|
|
||||||
svg_attribute_type const& attrs,
|
|
||||||
markers_dispatch_params const& params,
|
|
||||||
agg::trans_affine const& marker_tr) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Detector>
|
template <typename Detector>
|
||||||
struct vector_markers_dispatch : util::noncopyable
|
struct vector_markers_dispatch : util::noncopyable
|
||||||
{
|
{
|
||||||
|
|
76
include/mapnik/renderer_common/render_markers_symbolizer.hpp
Normal file
76
include/mapnik/renderer_common/render_markers_symbolizer.hpp
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Artem Pavlenko
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef MAPNIK_RENDERER_COMMON_RENDER_MARKERS_SYMBOLIZER_HPP
|
||||||
|
#define MAPNIK_RENDERER_COMMON_RENDER_MARKERS_SYMBOLIZER_HPP
|
||||||
|
|
||||||
|
#include <mapnik/marker.hpp>
|
||||||
|
#include <mapnik/markers_placement.hpp>
|
||||||
|
#include <mapnik/renderer_common.hpp>
|
||||||
|
#include <mapnik/symbolizer_base.hpp>
|
||||||
|
|
||||||
|
namespace mapnik {
|
||||||
|
|
||||||
|
struct markers_dispatch_params
|
||||||
|
{
|
||||||
|
// placement
|
||||||
|
markers_placement_params placement_params;
|
||||||
|
marker_placement_enum placement_method;
|
||||||
|
value_bool ignore_placement;
|
||||||
|
// rendering
|
||||||
|
bool snap_to_pixels;
|
||||||
|
double scale_factor;
|
||||||
|
value_double opacity;
|
||||||
|
|
||||||
|
markers_dispatch_params(box2d<double> const& size,
|
||||||
|
agg::trans_affine const& tr,
|
||||||
|
symbolizer_base const& sym,
|
||||||
|
feature_impl const& feature,
|
||||||
|
attributes const& vars,
|
||||||
|
double scale_factor = 1.0,
|
||||||
|
bool snap_to_pixels = false);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct markers_renderer_context : util::noncopyable
|
||||||
|
{
|
||||||
|
virtual void render_marker(image_rgba8 const& src,
|
||||||
|
markers_dispatch_params const& params,
|
||||||
|
agg::trans_affine const& marker_tr) = 0;
|
||||||
|
|
||||||
|
virtual void render_marker(svg_path_ptr const& src,
|
||||||
|
svg_path_adapter & path,
|
||||||
|
svg_attribute_type const& attrs,
|
||||||
|
markers_dispatch_params const& params,
|
||||||
|
agg::trans_affine const& marker_tr) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
MAPNIK_DECL
|
||||||
|
void render_markers_symbolizer(markers_symbolizer const& sym,
|
||||||
|
mapnik::feature_impl & feature,
|
||||||
|
proj_transform const& prj_trans,
|
||||||
|
renderer_common const& common,
|
||||||
|
box2d<double> const& clip_box,
|
||||||
|
markers_renderer_context & renderer_context);
|
||||||
|
|
||||||
|
} // namespace mapnik
|
||||||
|
|
||||||
|
#endif // MAPNIK_RENDERER_COMMON_RENDER_MARKERS_SYMBOLIZER_HPP
|
|
@ -38,8 +38,9 @@
|
||||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||||
#include <mapnik/symbolizer.hpp>
|
#include <mapnik/symbolizer.hpp>
|
||||||
#include <mapnik/parse_path.hpp>
|
#include <mapnik/parse_path.hpp>
|
||||||
#include <mapnik/renderer_common/process_markers_symbolizer.hpp>
|
|
||||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||||
|
#include <mapnik/renderer_common/render_markers_symbolizer.hpp>
|
||||||
|
|
||||||
// agg
|
// agg
|
||||||
#include "agg_basics.h"
|
#include "agg_basics.h"
|
||||||
#include "agg_renderer_base.h"
|
#include "agg_renderer_base.h"
|
||||||
|
|
|
@ -254,6 +254,7 @@ source = Split(
|
||||||
color_factory.cpp
|
color_factory.cpp
|
||||||
renderer_common.cpp
|
renderer_common.cpp
|
||||||
renderer_common/render_group_symbolizer.cpp
|
renderer_common/render_group_symbolizer.cpp
|
||||||
|
renderer_common/render_markers_symbolizer.cpp
|
||||||
renderer_common/render_pattern.cpp
|
renderer_common/render_pattern.cpp
|
||||||
renderer_common/render_thunk_extractor.cpp
|
renderer_common/render_thunk_extractor.cpp
|
||||||
math.cpp
|
math.cpp
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <mapnik/marker.hpp>
|
#include <mapnik/marker.hpp>
|
||||||
#include <mapnik/marker_cache.hpp>
|
#include <mapnik/marker_cache.hpp>
|
||||||
#include <mapnik/marker_helpers.hpp>
|
#include <mapnik/marker_helpers.hpp>
|
||||||
#include <mapnik/renderer_common/process_markers_symbolizer.hpp>
|
#include <mapnik/renderer_common/render_markers_symbolizer.hpp>
|
||||||
|
|
||||||
// agg
|
// agg
|
||||||
#include "agg/include/agg_array.h" // for pod_bvector
|
#include "agg/include/agg_array.h" // for pod_bvector
|
||||||
|
|
|
@ -63,7 +63,7 @@ porting notes -->
|
||||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||||
#include <mapnik/parse_path.hpp>
|
#include <mapnik/parse_path.hpp>
|
||||||
#include <mapnik/renderer_common/process_markers_symbolizer.hpp>
|
#include <mapnik/renderer_common/render_markers_symbolizer.hpp>
|
||||||
|
|
||||||
// agg
|
// agg
|
||||||
#include "agg_basics.h"
|
#include "agg_basics.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Artem Pavlenko
|
* Copyright (C) 2016 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,23 +20,24 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef MAPNIK_RENDERER_COMMON_PROCESS_MARKERS_SYMBOLIZER_HPP
|
|
||||||
#define MAPNIK_RENDERER_COMMON_PROCESS_MARKERS_SYMBOLIZER_HPP
|
|
||||||
|
|
||||||
#include <mapnik/svg/svg_storage.hpp>
|
#include <mapnik/svg/svg_storage.hpp>
|
||||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||||
#include <mapnik/vertex_converters.hpp>
|
#include <mapnik/vertex_converters.hpp>
|
||||||
#include <mapnik/marker_cache.hpp>
|
#include <mapnik/marker_cache.hpp>
|
||||||
#include <mapnik/marker_helpers.hpp>
|
#include <mapnik/marker_helpers.hpp>
|
||||||
#include <mapnik/geometry_type.hpp>
|
#include <mapnik/geometry_type.hpp>
|
||||||
|
#include <mapnik/renderer_common/render_markers_symbolizer.hpp>
|
||||||
|
#include <mapnik/symbolizer.hpp>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
template <typename VD, typename RD, typename RendererType, typename ContextType>
|
namespace detail {
|
||||||
|
|
||||||
|
template <typename Detector, typename RendererType, typename ContextType>
|
||||||
struct render_marker_symbolizer_visitor
|
struct render_marker_symbolizer_visitor
|
||||||
{
|
{
|
||||||
using vector_dispatch_type = VD;
|
using vector_dispatch_type = vector_markers_dispatch<Detector>;
|
||||||
using raster_dispatch_type = RD;
|
using raster_dispatch_type = raster_markers_dispatch<Detector>;
|
||||||
|
|
||||||
using vertex_converter_type = vertex_converter<clip_line_tag,
|
using vertex_converter_type = vertex_converter<clip_line_tag,
|
||||||
clip_poly_tag,
|
clip_poly_tag,
|
||||||
|
@ -52,7 +53,7 @@ struct render_marker_symbolizer_visitor
|
||||||
proj_transform const& prj_trans,
|
proj_transform const& prj_trans,
|
||||||
RendererType const& common,
|
RendererType const& common,
|
||||||
box2d<double> const& clip_box,
|
box2d<double> const& clip_box,
|
||||||
ContextType const& renderer_context)
|
ContextType & renderer_context)
|
||||||
: filename_(filename),
|
: filename_(filename),
|
||||||
sym_(sym),
|
sym_(sym),
|
||||||
feature_(feature),
|
feature_(feature),
|
||||||
|
@ -242,38 +243,57 @@ struct render_marker_symbolizer_visitor
|
||||||
proj_transform const& prj_trans_;
|
proj_transform const& prj_trans_;
|
||||||
RendererType const& common_;
|
RendererType const& common_;
|
||||||
box2d<double> const& clip_box_;
|
box2d<double> const& clip_box_;
|
||||||
ContextType const& renderer_context_;
|
ContextType & renderer_context_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename RendererType>
|
} // namespace detail
|
||||||
|
|
||||||
|
markers_dispatch_params::markers_dispatch_params(box2d<double> const& size,
|
||||||
|
agg::trans_affine const& tr,
|
||||||
|
symbolizer_base const& sym,
|
||||||
|
feature_impl const& feature,
|
||||||
|
attributes const& vars,
|
||||||
|
double scale,
|
||||||
|
bool snap)
|
||||||
|
: placement_params{
|
||||||
|
.size = size,
|
||||||
|
.tr = tr,
|
||||||
|
.spacing = get<value_double, keys::spacing>(sym, feature, vars),
|
||||||
|
.max_error = get<value_double, keys::max_error>(sym, feature, vars),
|
||||||
|
.allow_overlap = get<value_bool, keys::allow_overlap>(sym, feature, vars),
|
||||||
|
.avoid_edges = get<value_bool, keys::avoid_edges>(sym, feature, vars),
|
||||||
|
.direction = get<direction_enum, keys::direction>(sym, feature, vars)}
|
||||||
|
, placement_method(get<marker_placement_enum, keys::markers_placement_type>(sym, feature, vars))
|
||||||
|
, ignore_placement(get<value_bool, keys::ignore_placement>(sym, feature, vars))
|
||||||
|
, snap_to_pixels(snap)
|
||||||
|
, scale_factor(scale)
|
||||||
|
, opacity(get<value_double, keys::opacity>(sym, feature, vars))
|
||||||
|
{
|
||||||
|
placement_params.spacing *= scale;
|
||||||
|
}
|
||||||
|
|
||||||
void render_markers_symbolizer(markers_symbolizer const& sym,
|
void render_markers_symbolizer(markers_symbolizer const& sym,
|
||||||
mapnik::feature_impl & feature,
|
mapnik::feature_impl & feature,
|
||||||
proj_transform const& prj_trans,
|
proj_transform const& prj_trans,
|
||||||
RendererType const& common,
|
renderer_common const& common,
|
||||||
box2d<double> const& clip_box,
|
box2d<double> const& clip_box,
|
||||||
markers_renderer_context & renderer_context)
|
markers_renderer_context & renderer_context)
|
||||||
{
|
{
|
||||||
using Detector = decltype(*common.detector_);
|
using Detector = decltype(*common.detector_);
|
||||||
using VD = vector_markers_dispatch<Detector>;
|
using RendererType = renderer_common;
|
||||||
using RD = raster_markers_dispatch<Detector>;
|
using ContextType = markers_renderer_context;
|
||||||
using ContextType = markers_renderer_context & ;
|
using VisitorType = detail::render_marker_symbolizer_visitor<Detector,
|
||||||
|
RendererType,
|
||||||
|
ContextType>;
|
||||||
|
|
||||||
using namespace mapnik::svg;
|
|
||||||
std::string filename = get<std::string>(sym, keys::file, feature, common.vars_, "shape://ellipse");
|
std::string filename = get<std::string>(sym, keys::file, feature, common.vars_, "shape://ellipse");
|
||||||
if (!filename.empty())
|
if (!filename.empty())
|
||||||
{
|
{
|
||||||
std::shared_ptr<mapnik::marker const> mark = mapnik::marker_cache::instance().find(filename, true);
|
auto mark = mapnik::marker_cache::instance().find(filename, true);
|
||||||
render_marker_symbolizer_visitor<VD,RD,RendererType,ContextType> visitor(filename,
|
VisitorType visitor(filename, sym, feature, prj_trans, common, clip_box,
|
||||||
sym,
|
renderer_context);
|
||||||
feature,
|
|
||||||
prj_trans,
|
|
||||||
common,
|
|
||||||
clip_box,
|
|
||||||
renderer_context);
|
|
||||||
util::apply_visitor(visitor, *mark);
|
util::apply_visitor(visitor, *mark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mapnik
|
} // namespace mapnik
|
||||||
|
|
||||||
#endif // MAPNIK_RENDERER_COMMON_PROCESS_MARKERS_SYMBOLIZER_HPP
|
|
|
@ -23,8 +23,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/label_collision_detector.hpp>
|
#include <mapnik/label_collision_detector.hpp>
|
||||||
#include <mapnik/make_unique.hpp>
|
#include <mapnik/make_unique.hpp>
|
||||||
#include <mapnik/marker_helpers.hpp>
|
#include <mapnik/renderer_common/render_markers_symbolizer.hpp>
|
||||||
#include <mapnik/renderer_common/process_markers_symbolizer.hpp>
|
|
||||||
#include <mapnik/renderer_common/render_thunk_extractor.hpp>
|
#include <mapnik/renderer_common/render_thunk_extractor.hpp>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
Loading…
Reference in a new issue