fix group_symbolizer_helper

This commit is contained in:
artemp 2015-03-18 13:50:15 +01:00
parent c1fca4f539
commit 6a8e78ab9c
2 changed files with 39 additions and 16 deletions

View file

@ -80,22 +80,23 @@ public:
pixel_position_list const& get();
private:
/** Iterate over the given path, placing line-following labels or point labels with respect to label_spacing. */
// Iterate over the given path, placing line-following labels or point labels with respect to label_spacing.
template <typename T>
bool find_line_placements(T & path);
/** Check if a point placement fits at given position */
private:
// Check if a point placement fits at given position
bool check_point_placement(pixel_position const& pos);
/** Checks for collision. */
// Checks for collision.
bool collision(box2d<double> const& box, value_unicode_string const& repeat_key = "") const;
double get_spacing(double path_length) const;
DetectorType & detector_;
/** Boxes and repeat keys to take into account when finding placement.
* Boxes are relative to starting point of current placement.
*/
// Boxes and repeat keys to take into account when finding placement.
// Boxes are relative to starting point of current placement.
//
std::list<box_element> box_elements_;
pixel_position_list results_;

View file

@ -23,7 +23,9 @@
// mapnik
#include <mapnik/group/group_symbolizer_helper.hpp>
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/geom_util.hpp>
//#include <mapnik/geom_util.hpp>
#include <mapnik/geometry_impl.hpp>
#include <mapnik/vertex_processor.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/symbolizer.hpp>
#include <mapnik/value_types.hpp>
@ -35,7 +37,30 @@
//agg
#include "agg_conv_clip_polyline.h"
namespace mapnik {
namespace mapnik { namespace detail {
template <typename Helper>
struct apply_find_line_placements : util::noncopyable
{
apply_find_line_placements(view_transform const& t, proj_transform const& prj_trans, Helper & helper)
: t_(t),
prj_trans_(prj_trans),
helper_(helper) {}
template <typename Adapter>
void operator() (Adapter & va) const
{
using vertex_adapter_type = Adapter;
using path_type = transform_path_adapter<view_transform, vertex_adapter_type>;
path_type path(t_, va, prj_trans_);
helper_.find_line_placements(path);
}
view_transform const& t_;
proj_transform const& prj_trans_;
Helper & helper_;
};
} // ns detail
group_symbolizer_helper::group_symbolizer_helper(
group_symbolizer const& sym, feature_impl const& feature,
@ -61,16 +86,13 @@ pixel_position_list const& group_symbolizer_helper::get()
}
else
{
using apply_find_line_placements = detail::apply_find_line_placements<group_symbolizer_helper>;
for (auto const* geom : geometries_to_process_)
{
// TODO to support clipped geometries this needs to use
// vertex_converters
using path_type = transform_path_adapter<view_transform,vertex_adapter>;
#if 0 // FIXME
vertex_adapter va(*geom);
path_type path(t_, va, prj_trans_);
find_line_placements(path);
#endif
apply_find_line_placements apply(t_, prj_trans_, *this);
mapnik::util::apply_visitor(new_geometry::vertex_processor<apply_find_line_placements>(apply), *geom);
}
}