mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
add 'interior' point placement option to point_symbolizer - closes #709
This commit is contained in:
parent
e803b1c2ec
commit
75649b8863
@ -723,6 +723,7 @@ __all__ = [
|
||||
'ViewTransform',
|
||||
# enums
|
||||
'aspect_fix_mode',
|
||||
'point_placement',
|
||||
'label_placement',
|
||||
'line_cap',
|
||||
'line_join',
|
||||
|
||||
@ -22,12 +22,14 @@
|
||||
//$Id$
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include <mapnik/graphics.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/point_symbolizer.hpp>
|
||||
#include <mapnik/parse_path.hpp>
|
||||
#include "mapnik_svg.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::point_symbolizer;
|
||||
using mapnik::symbolizer_with_image;
|
||||
using mapnik::path_processor_type;
|
||||
@ -89,6 +91,11 @@ struct point_symbolizer_pickle_suite : boost::python::pickle_suite
|
||||
void export_point_symbolizer()
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
enumeration_<point_placement_e>("point_placement")
|
||||
.value("CENTROID",CENTROID_POINT_PLACEMENT)
|
||||
.value("INTERIOR",INTERIOR_POINT_PLACEMENT)
|
||||
;
|
||||
|
||||
class_<point_symbolizer>("PointSymbolizer",
|
||||
init<>("Default Point Symbolizer - 4x4 black square"))
|
||||
|
||||
@ -26,9 +26,18 @@
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
|
||||
#include <mapnik/enumeration.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
{
|
||||
|
||||
enum point_placement_enum {
|
||||
CENTROID_POINT_PLACEMENT,
|
||||
INTERIOR_POINT_PLACEMENT,
|
||||
point_placement_enum_MAX
|
||||
};
|
||||
|
||||
DEFINE_ENUM( point_placement_e, point_placement_enum );
|
||||
|
||||
struct MAPNIK_DECL point_symbolizer :
|
||||
public symbolizer_with_image, public symbolizer_base
|
||||
@ -38,11 +47,14 @@ struct MAPNIK_DECL point_symbolizer :
|
||||
point_symbolizer(point_symbolizer const& rhs);
|
||||
void set_allow_overlap(bool overlap);
|
||||
bool get_allow_overlap() const;
|
||||
void set_point_placement(point_placement_e point_p);
|
||||
point_placement_e get_point_placement() const;
|
||||
void set_ignore_placement(bool ignore_placement);
|
||||
bool get_ignore_placement() const;
|
||||
|
||||
private:
|
||||
bool overlap_;
|
||||
point_placement_e point_p_;
|
||||
bool ignore_placement_;
|
||||
};
|
||||
}
|
||||
|
||||
@ -64,8 +64,11 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
|
||||
double x;
|
||||
double y;
|
||||
double z=0;
|
||||
if (sym.get_point_placement() == POINT_PLACEMENT)
|
||||
geom.label_position(&x, &y);
|
||||
else
|
||||
geom.label_interior_position(&x, &y);
|
||||
|
||||
geom.label_position(&x,&y);
|
||||
prj_trans.backward(x,y,z);
|
||||
t_.forward(&x,&y);
|
||||
|
||||
|
||||
@ -1033,7 +1033,11 @@ void cairo_renderer_base::process(point_symbolizer const& sym,
|
||||
double y;
|
||||
double z = 0;
|
||||
|
||||
geom.label_position(&x, &y);
|
||||
if (sym.get_point_placement() == POINT_PLACEMENT)
|
||||
geom.label_position(&x, &y);
|
||||
else
|
||||
geom.label_interior_position(&x, &y);
|
||||
|
||||
prj_trans.backward(x, y, z);
|
||||
t_.forward(&x, &y);
|
||||
|
||||
|
||||
@ -786,6 +786,10 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym )
|
||||
{
|
||||
symbol.set_ignore_placement( * ignore_placement );
|
||||
}
|
||||
point_placement_e placement =
|
||||
get_attr<point_placement_e>(sym, "placement", CENTROID_POINT_PLACEMENT);
|
||||
symbol.set_point_placement( placement );
|
||||
|
||||
if (transform_wkt)
|
||||
{
|
||||
agg::trans_affine tr;
|
||||
@ -837,6 +841,9 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym )
|
||||
{
|
||||
symbol.set_ignore_placement( * ignore_placement );
|
||||
}
|
||||
point_placement_e placement =
|
||||
get_attr<point_placement_e>(sym, "placement", CENTROID_POINT_PLACEMENT);
|
||||
symbol.set_point_placement( placement );
|
||||
|
||||
parse_metawriter_in_symbolizer(symbol, sym);
|
||||
rule.append(symbol);
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include <mapnik/point_symbolizer.hpp>
|
||||
#include <mapnik/image_data.hpp>
|
||||
#include <mapnik/image_reader.hpp>
|
||||
#include <mapnik/enumeration.hpp>
|
||||
// boost
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
// stl
|
||||
@ -33,20 +34,31 @@
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
static const char * point_placement_strings[] = {
|
||||
"centroid",
|
||||
"interior",
|
||||
""
|
||||
};
|
||||
|
||||
IMPLEMENT_ENUM( point_placement_e, point_placement_strings );
|
||||
|
||||
point_symbolizer::point_symbolizer()
|
||||
: symbolizer_with_image(path_expression_ptr(new path_expression)), // FIXME
|
||||
symbolizer_base(),
|
||||
overlap_(false),
|
||||
point_p_(CENTROID_POINT_PLACEMENT),
|
||||
ignore_placement_(false) {}
|
||||
|
||||
point_symbolizer::point_symbolizer(path_expression_ptr file)
|
||||
: symbolizer_with_image(file), symbolizer_base(),
|
||||
overlap_(false),
|
||||
point_p_(CENTROID_POINT_PLACEMENT),
|
||||
ignore_placement_(false) {}
|
||||
|
||||
point_symbolizer::point_symbolizer(point_symbolizer const& rhs)
|
||||
: symbolizer_with_image(rhs), symbolizer_base(rhs),
|
||||
overlap_(rhs.overlap_),
|
||||
point_p_(rhs.point_p_),
|
||||
ignore_placement_(rhs.ignore_placement_) {}
|
||||
|
||||
void point_symbolizer::set_allow_overlap(bool overlap)
|
||||
@ -59,6 +71,16 @@ bool point_symbolizer::get_allow_overlap() const
|
||||
return overlap_;
|
||||
}
|
||||
|
||||
void point_symbolizer::set_point_placement(point_placement_e point_p)
|
||||
{
|
||||
point_p_ = point_p;
|
||||
}
|
||||
|
||||
point_placement_e point_symbolizer::get_point_placement() const
|
||||
{
|
||||
return point_p_;
|
||||
}
|
||||
|
||||
void point_symbolizer::set_ignore_placement(bool ignore_placement)
|
||||
{
|
||||
ignore_placement_ = ignore_placement;
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user