Use pixel_position consistently everywhere.
This commit is contained in:
parent
6b3810c9b0
commit
a953d535ad
16 changed files with 119 additions and 88 deletions
|
@ -39,7 +39,7 @@ using mapnik::path_expression_ptr;
|
||||||
using mapnik::guess_type;
|
using mapnik::guess_type;
|
||||||
using mapnik::expression_ptr;
|
using mapnik::expression_ptr;
|
||||||
using mapnik::parse_path;
|
using mapnik::parse_path;
|
||||||
using mapnik::position;
|
using mapnik::pixel_position;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -47,8 +47,8 @@ using namespace boost::python;
|
||||||
|
|
||||||
tuple get_shield_displacement(const shield_symbolizer& s)
|
tuple get_shield_displacement(const shield_symbolizer& s)
|
||||||
{
|
{
|
||||||
position const& pos = s.get_shield_displacement();
|
pixel_position const& pos = s.get_shield_displacement();
|
||||||
return boost::python::make_tuple(pos.first, pos.second);
|
return boost::python::make_tuple(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_shield_displacement(shield_symbolizer & s, boost::python::tuple arg)
|
void set_shield_displacement(shield_symbolizer & s, boost::python::tuple arg)
|
||||||
|
@ -58,8 +58,8 @@ void set_shield_displacement(shield_symbolizer & s, boost::python::tuple arg)
|
||||||
|
|
||||||
tuple get_text_displacement(const shield_symbolizer& t)
|
tuple get_text_displacement(const shield_symbolizer& t)
|
||||||
{
|
{
|
||||||
position const& pos = t.get_displacement();
|
pixel_position const& pos = t.get_displacement();
|
||||||
return boost::python::make_tuple(pos.first, pos.second);
|
return boost::python::make_tuple(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_text_displacement(shield_symbolizer & t, boost::python::tuple arg)
|
void set_text_displacement(shield_symbolizer & t, boost::python::tuple arg)
|
||||||
|
|
|
@ -56,7 +56,7 @@ using namespace boost::python;
|
||||||
|
|
||||||
boost::python::tuple get_displacement(text_symbolizer_properties const& t)
|
boost::python::tuple get_displacement(text_symbolizer_properties const& t)
|
||||||
{
|
{
|
||||||
return boost::python::make_tuple(t.displacement.first, t.displacement.second);
|
return boost::python::make_tuple(t.displacement.x, t.displacement.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_displacement(text_symbolizer_properties &t, boost::python::tuple arg)
|
void set_displacement(text_symbolizer_properties &t, boost::python::tuple arg)
|
||||||
|
@ -72,7 +72,7 @@ void set_displacement(text_symbolizer_properties &t, boost::python::tuple arg)
|
||||||
|
|
||||||
double x = extract<double>(arg[0]);
|
double x = extract<double>(arg[0]);
|
||||||
double y = extract<double>(arg[1]);
|
double y = extract<double>(arg[1]);
|
||||||
t.displacement = std::make_pair(x, y);
|
t.displacement.set(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
|
#include <mapnik/pixel_position.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
#ifndef MAPNIK_PIXEL_POSITION_HPP
|
#ifndef MAPNIK_PIXEL_POSITION_HPP
|
||||||
#define MAPNIK_PIXEL_POSITION_HPP
|
#define MAPNIK_PIXEL_POSITION_HPP
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
|
||||||
/** Store a pixel position. */
|
/** Store a pixel position. */
|
||||||
struct pixel_position
|
struct pixel_position
|
||||||
{
|
{
|
||||||
|
@ -29,6 +32,40 @@ struct pixel_position
|
||||||
double y;
|
double y;
|
||||||
pixel_position(double x, double y) : x(x), y(y) { }
|
pixel_position(double x, double y) : x(x), y(y) { }
|
||||||
pixel_position() : x(0), y(0) { }
|
pixel_position() : x(0), y(0) { }
|
||||||
|
pixel_position operator+ (pixel_position const& other)
|
||||||
|
{
|
||||||
|
return pixel_position(x + other.x, y + other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
pixel_position operator- (pixel_position const& other)
|
||||||
|
{
|
||||||
|
return pixel_position(x - other.x, y - other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
pixel_position operator* (double other)
|
||||||
|
{
|
||||||
|
return pixel_position(x * other, y * other);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(double x_, double y_)
|
||||||
|
{
|
||||||
|
x = x_;
|
||||||
|
y = y_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline pixel_position operator* (double factor, pixel_position const& pos)
|
||||||
|
{
|
||||||
|
return pixel_position(factor * pos.x, factor * pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // MAPNIK_PIXEL_POSITION_HPP
|
#endif // MAPNIK_PIXEL_POSITION_HPP
|
||||||
|
|
|
@ -52,11 +52,11 @@ struct MAPNIK_DECL shield_symbolizer : public text_symbolizer,
|
||||||
bool get_unlock_image() const; // image is not locked to the text placement
|
bool get_unlock_image() const; // image is not locked to the text placement
|
||||||
void set_unlock_image(bool unlock_image);
|
void set_unlock_image(bool unlock_image);
|
||||||
void set_shield_displacement(double shield_dx, double shield_dy);
|
void set_shield_displacement(double shield_dx, double shield_dy);
|
||||||
position const& get_shield_displacement() const;
|
pixel_position const& get_shield_displacement() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool unlock_image_;
|
bool unlock_image_;
|
||||||
position shield_displacement_;
|
pixel_position shield_displacement_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ protected:
|
||||||
/** Geometry currently being processed. */
|
/** Geometry currently being processed. */
|
||||||
std::list<geometry_type*>::iterator geo_itr_;
|
std::list<geometry_type*>::iterator geo_itr_;
|
||||||
/** Remaining points to be processed. */
|
/** Remaining points to be processed. */
|
||||||
std::list<position> points_;
|
std::list<pixel_position> points_;
|
||||||
/** Point currently being processed. */
|
/** Point currently being processed. */
|
||||||
std::list<position>::iterator point_itr_;
|
std::list<pixel_position>::iterator point_itr_;
|
||||||
/** Use point placement. Otherwise line placement is used. */
|
/** Use point placement. Otherwise line placement is used. */
|
||||||
bool point_placement_;
|
bool point_placement_;
|
||||||
/** Place text at points on a line instead of following the line (used for ShieldSymbolizer) .*/
|
/** Place text at points on a line instead of following the line (used for ShieldSymbolizer) .*/
|
||||||
|
@ -116,14 +116,9 @@ public:
|
||||||
return marker_ext_;
|
return marker_ext_;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_marker_height() const
|
pixel_position get_marker_size() const
|
||||||
{
|
{
|
||||||
return marker_h_;
|
return marker_size_;
|
||||||
}
|
|
||||||
|
|
||||||
double get_marker_width() const
|
|
||||||
{
|
|
||||||
return marker_w_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool next();
|
bool next();
|
||||||
|
@ -138,10 +133,8 @@ protected:
|
||||||
box2d<double> marker_ext_;
|
box2d<double> marker_ext_;
|
||||||
boost::optional<marker_ptr> marker_;
|
boost::optional<marker_ptr> marker_;
|
||||||
agg::trans_affine image_transform_;
|
agg::trans_affine image_transform_;
|
||||||
double marker_w_;
|
pixel_position marker_size_;
|
||||||
double marker_h_;
|
pixel_position marker_pos_;
|
||||||
double marker_x_;
|
|
||||||
double marker_y_;
|
|
||||||
|
|
||||||
using text_symbolizer_helper<FaceManagerT, DetectorT>::geometries_to_process_;
|
using text_symbolizer_helper<FaceManagerT, DetectorT>::geometries_to_process_;
|
||||||
using text_symbolizer_helper<FaceManagerT, DetectorT>::placement_;
|
using text_symbolizer_helper<FaceManagerT, DetectorT>::placement_;
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
face_manager_freetype & font_manager);
|
face_manager_freetype & font_manager);
|
||||||
|
|
||||||
/** Try to place a single label at the given point. */
|
/** Try to place a single label at the given point. */
|
||||||
glyph_positions_ptr find_point_placement(double pos_x, double pos_y);
|
glyph_positions_ptr find_point_placement(pixel_position pos);
|
||||||
|
|
||||||
bool next_position();
|
bool next_position();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <mapnik/enumeration.hpp>
|
#include <mapnik/enumeration.hpp>
|
||||||
#include <mapnik/expression.hpp>
|
#include <mapnik/expression.hpp>
|
||||||
#include <mapnik/formatting/base.hpp>
|
#include <mapnik/formatting/base.hpp>
|
||||||
|
#include <mapnik/pixel_position.hpp>
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -118,7 +119,6 @@ enum justify_alignment
|
||||||
|
|
||||||
DEFINE_ENUM(justify_alignment_e, justify_alignment);
|
DEFINE_ENUM(justify_alignment_e, justify_alignment);
|
||||||
|
|
||||||
typedef std::pair<double, double> position;
|
|
||||||
class text_layout;
|
class text_layout;
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ struct text_symbolizer_properties
|
||||||
|
|
||||||
//Per symbolizer options
|
//Per symbolizer options
|
||||||
expression_ptr orientation;
|
expression_ptr orientation;
|
||||||
position displacement;
|
pixel_position displacement;
|
||||||
label_placement_e label_placement;
|
label_placement_e label_placement;
|
||||||
horizontal_alignment_e halign;
|
horizontal_alignment_e halign;
|
||||||
justify_alignment_e jalign;
|
justify_alignment_e jalign;
|
||||||
|
|
|
@ -105,8 +105,8 @@ struct MAPNIK_DECL text_symbolizer : public symbolizer_base
|
||||||
void set_vertical_alignment(vertical_alignment_e valign);
|
void set_vertical_alignment(vertical_alignment_e valign);
|
||||||
vertical_alignment_e get_vertical_alignment() const func_deprecated;
|
vertical_alignment_e get_vertical_alignment() const func_deprecated;
|
||||||
void set_displacement(double x, double y);
|
void set_displacement(double x, double y);
|
||||||
void set_displacement(position const& p);
|
void set_displacement(pixel_position const& p);
|
||||||
position const& get_displacement() const func_deprecated;
|
pixel_position const& get_displacement() const func_deprecated;
|
||||||
void set_avoid_edges(bool avoid);
|
void set_avoid_edges(bool avoid);
|
||||||
bool get_avoid_edges() const func_deprecated;
|
bool get_avoid_edges() const func_deprecated;
|
||||||
void set_minimum_distance(double distance);
|
void set_minimum_distance(double distance);
|
||||||
|
|
|
@ -205,14 +205,14 @@ public:
|
||||||
{
|
{
|
||||||
set_attr(sym_node, "text-opacity", sym.get_text_opacity());
|
set_attr(sym_node, "text-opacity", sym.get_text_opacity());
|
||||||
}
|
}
|
||||||
position displacement = sym.get_shield_displacement();
|
pixel_position displacement = sym.get_shield_displacement();
|
||||||
if (displacement.first != dfl.get_shield_displacement().first || explicit_defaults_)
|
if (displacement.x != dfl.get_shield_displacement().x || explicit_defaults_)
|
||||||
{
|
{
|
||||||
set_attr(sym_node, "shield-dx", displacement.first);
|
set_attr(sym_node, "shield-dx", displacement.x);
|
||||||
}
|
}
|
||||||
if (displacement.second != dfl.get_shield_displacement().second || explicit_defaults_)
|
if (displacement.y != dfl.get_shield_displacement().y || explicit_defaults_)
|
||||||
{
|
{
|
||||||
set_attr(sym_node, "shield-dy", displacement.second);
|
set_attr(sym_node, "shield-dy", displacement.y);
|
||||||
}
|
}
|
||||||
serialize_symbolizer_base(sym_node, sym);
|
serialize_symbolizer_base(sym_node, sym);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,10 +79,10 @@ bool shield_symbolizer::get_unlock_image() const
|
||||||
|
|
||||||
void shield_symbolizer::set_shield_displacement(double shield_dx,double shield_dy)
|
void shield_symbolizer::set_shield_displacement(double shield_dx,double shield_dy)
|
||||||
{
|
{
|
||||||
shield_displacement_ = std::make_pair(shield_dx, shield_dy);
|
shield_displacement_.set(shield_dx, shield_dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
position const& shield_symbolizer::get_shield_displacement() const
|
pixel_position const& shield_symbolizer::get_shield_displacement() const
|
||||||
{
|
{
|
||||||
return shield_displacement_;
|
return shield_displacement_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ glyph_positions_ptr text_symbolizer_helper<FaceManagerT, DetectorT>::next_point_
|
||||||
point_itr_ = points_.begin();
|
point_itr_ = points_.begin();
|
||||||
continue; //Reexecute size check
|
continue; //Reexecute size check
|
||||||
}
|
}
|
||||||
glyph_positions_ptr glyphs = finder_.find_point_placement(point_itr_->first, point_itr_->second);
|
glyph_positions_ptr glyphs = finder_.find_point_placement(*point_itr_);
|
||||||
if (glyphs)
|
if (glyphs)
|
||||||
{
|
{
|
||||||
//Found a placement
|
//Found a placement
|
||||||
|
@ -215,7 +215,7 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_points()
|
||||||
geom.vertex(&label_x, &label_y);
|
geom.vertex(&label_x, &label_y);
|
||||||
prj_trans_.backward(label_x, label_y, z);
|
prj_trans_.backward(label_x, label_y, z);
|
||||||
t_.forward(&label_x, &label_y);
|
t_.forward(&label_x, &label_y);
|
||||||
points_.push_back(std::make_pair(label_x, label_y));
|
points_.push_back(pixel_position(label_x, label_y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -234,7 +234,7 @@ void text_symbolizer_helper<FaceManagerT, DetectorT>::initialize_points()
|
||||||
}
|
}
|
||||||
prj_trans_.backward(label_x, label_y, z);
|
prj_trans_.backward(label_x, label_y, z);
|
||||||
t_.forward(&label_x, &label_y);
|
t_.forward(&label_x, &label_y);
|
||||||
points_.push_back(std::make_pair(label_x, label_y));
|
points_.push_back(pixel_position(label_x, label_y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
point_itr_ = points_.begin();
|
point_itr_ = points_.begin();
|
||||||
|
@ -275,7 +275,7 @@ bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next()
|
||||||
template <typename FaceManagerT, typename DetectorT>
|
template <typename FaceManagerT, typename DetectorT>
|
||||||
bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_point_placement()
|
bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_point_placement()
|
||||||
{
|
{
|
||||||
position const& shield_pos = sym_.get_shield_displacement();
|
pixel_position const& shield_pos = sym_.get_shield_displacement();
|
||||||
while (!points_.empty())
|
while (!points_.empty())
|
||||||
{
|
{
|
||||||
if (point_itr_ == points_.end())
|
if (point_itr_ == points_.end())
|
||||||
|
@ -286,11 +286,10 @@ bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_point_placement()
|
||||||
point_itr_ = points_.begin();
|
point_itr_ = points_.begin();
|
||||||
continue; //Reexecute size check
|
continue; //Reexecute size check
|
||||||
}
|
}
|
||||||
position const& text_disp = placement_->properties.displacement;
|
pixel_position const& text_disp = placement_->properties.displacement;
|
||||||
double label_x = point_itr_->first + shield_pos.first;
|
pixel_position label_pos = *point_itr_ + shield_pos;
|
||||||
double label_y = point_itr_->second + shield_pos.second;
|
|
||||||
|
|
||||||
glyph_positions_ptr glyphs = finder_.find_point_placement(label_x, label_y);
|
glyph_positions_ptr glyphs = finder_.find_point_placement(label_pos);
|
||||||
if (!glyphs)
|
if (!glyphs)
|
||||||
{
|
{
|
||||||
//No placement for this point. Keep it in points_ for next try.
|
//No placement for this point. Keep it in points_ for next try.
|
||||||
|
@ -314,9 +313,8 @@ bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_point_placement()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // center image at reference location
|
{ // center image at reference location
|
||||||
marker_x_ = label_x - 0.5 * marker_w_;
|
marker_pos_ = label_pos - 0.5 * marker_size_;
|
||||||
marker_y_ = label_y - 0.5 * marker_h_;
|
marker_ext_.re_center(label_pos.x, label_pos.y);
|
||||||
marker_ext_.re_center(label_x, label_y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placement_->properties.allow_overlap || detector_.has_placement(marker_ext_))
|
if (placement_->properties.allow_overlap || detector_.has_placement(marker_ext_))
|
||||||
|
@ -343,7 +341,7 @@ bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_point_placement()
|
||||||
template <typename FaceManagerT, typename DetectorT>
|
template <typename FaceManagerT, typename DetectorT>
|
||||||
bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_line_placement()
|
bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_line_placement()
|
||||||
{
|
{
|
||||||
position const& pos = placement_->properties.displacement;
|
pixel_position const& pos = placement_->properties.displacement;
|
||||||
#if 0
|
#if 0
|
||||||
finder_->additional_boxes.clear();
|
finder_->additional_boxes.clear();
|
||||||
//Markers are automatically centered
|
//Markers are automatically centered
|
||||||
|
@ -368,17 +366,15 @@ void shield_symbolizer_helper<FaceManagerT, DetectorT>::init_marker()
|
||||||
marker_ = marker_cache::instance()->find(filename, true);
|
marker_ = marker_cache::instance()->find(filename, true);
|
||||||
}
|
}
|
||||||
if (!marker_) {
|
if (!marker_) {
|
||||||
marker_w_ = 0;
|
marker_size_.clear();
|
||||||
marker_h_ = 0;
|
|
||||||
marker_ext_.init(0, 0, 0, 0);
|
marker_ext_.init(0, 0, 0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
marker_w_ = (*marker_)->width();
|
marker_size_.set((*marker_)->width(), (*marker_)->height());
|
||||||
marker_h_ = (*marker_)->height();
|
double px0 = - 0.5 * marker_size_.x;
|
||||||
double px0 = - 0.5 * marker_w_;
|
double py0 = - 0.5 * marker_size_.y;
|
||||||
double py0 = - 0.5 * marker_h_;
|
double px1 = 0.5 * marker_size_.x;
|
||||||
double px1 = 0.5 * marker_w_;
|
double py1 = 0.5 * marker_size_.y;
|
||||||
double py1 = 0.5 * marker_h_;
|
|
||||||
double px2 = px1;
|
double px2 = px1;
|
||||||
double py2 = py0;
|
double py2 = py0;
|
||||||
double px3 = px0;
|
double px3 = px0;
|
||||||
|
|
|
@ -36,15 +36,6 @@ placement_finder_ng::placement_finder_ng(Feature const& feature, DetectorType &d
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph_positions_ptr placement_finder_ng::find_point_placement(double pos_x, double pos_y)
|
|
||||||
{
|
|
||||||
glyph_positions_ptr glyphs = boost::make_shared<glyph_positions>();
|
|
||||||
// glyphs->point_placement(pixel_position(pos_x, pos_y));
|
|
||||||
//TODO: angle
|
|
||||||
//TODO: Check for placement
|
|
||||||
return glyphs;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool placement_finder_ng::next_position()
|
bool placement_finder_ng::next_position()
|
||||||
{
|
{
|
||||||
if (!valid_)
|
if (!valid_)
|
||||||
|
@ -79,10 +70,10 @@ void placement_finder_ng::init_alignment()
|
||||||
valign_ = p.valign;
|
valign_ = p.valign;
|
||||||
if (valign_ == V_AUTO)
|
if (valign_ == V_AUTO)
|
||||||
{
|
{
|
||||||
if (p.displacement.second > 0.0)
|
if (p.displacement.y > 0.0)
|
||||||
{
|
{
|
||||||
valign_ = V_BOTTOM;
|
valign_ = V_BOTTOM;
|
||||||
} else if (p.displacement.second < 0.0)
|
} else if (p.displacement.y < 0.0)
|
||||||
{
|
{
|
||||||
valign_ = V_TOP;
|
valign_ = V_TOP;
|
||||||
} else
|
} else
|
||||||
|
@ -94,10 +85,10 @@ void placement_finder_ng::init_alignment()
|
||||||
halign_ = p.halign;
|
halign_ = p.halign;
|
||||||
if (halign_ == H_AUTO)
|
if (halign_ == H_AUTO)
|
||||||
{
|
{
|
||||||
if (p.displacement.first > 0.0)
|
if (p.displacement.x > 0.0)
|
||||||
{
|
{
|
||||||
halign_ = H_RIGHT;
|
halign_ = H_RIGHT;
|
||||||
} else if (p.displacement.first < 0.0)
|
} else if (p.displacement.x < 0.0)
|
||||||
{
|
{
|
||||||
halign_ = H_LEFT;
|
halign_ = H_LEFT;
|
||||||
} else
|
} else
|
||||||
|
@ -109,10 +100,10 @@ void placement_finder_ng::init_alignment()
|
||||||
jalign_ = p.jalign;
|
jalign_ = p.jalign;
|
||||||
if (jalign_ == J_AUTO)
|
if (jalign_ == J_AUTO)
|
||||||
{
|
{
|
||||||
if (p.displacement.first > 0.0)
|
if (p.displacement.x > 0.0)
|
||||||
{
|
{
|
||||||
jalign_ = J_LEFT;
|
jalign_ = J_LEFT;
|
||||||
} else if (p.displacement.first < 0.0)
|
} else if (p.displacement.x < 0.0)
|
||||||
{
|
{
|
||||||
jalign_ = J_RIGHT;
|
jalign_ = J_RIGHT;
|
||||||
} else {
|
} else {
|
||||||
|
@ -121,6 +112,19 @@ void placement_finder_ng::init_alignment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glyph_positions_ptr placement_finder_ng::find_point_placement(pixel_position pos)
|
||||||
|
{
|
||||||
|
glyph_positions_ptr glyphs = boost::make_shared<glyph_positions>();
|
||||||
|
glyphs->set_base_point(pos + info_->properties.displacement);
|
||||||
|
// glyphs->point_placement(pixel_position(pos_x, pos_y));
|
||||||
|
//TODO: angle
|
||||||
|
//TODO: Check for placement
|
||||||
|
return glyphs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
glyph_positions::glyph_positions()
|
glyph_positions::glyph_positions()
|
||||||
: base_point_(), const_angle_(true)
|
: base_point_(), const_angle_(true)
|
||||||
|
|
|
@ -62,8 +62,8 @@ bool text_placement_info_simple::next()
|
||||||
|
|
||||||
bool text_placement_info_simple::next_position_only()
|
bool text_placement_info_simple::next_position_only()
|
||||||
{
|
{
|
||||||
const position &pdisp = parent_->defaults.displacement;
|
pixel_position const& pdisp = parent_->defaults.displacement;
|
||||||
position &displacement = properties.displacement;
|
pixel_position &displacement = properties.displacement;
|
||||||
if (position_state >= parent_->direction_.size()) return false;
|
if (position_state >= parent_->direction_.size()) return false;
|
||||||
directions_t dir = parent_->direction_[position_state];
|
directions_t dir = parent_->direction_[position_state];
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
|
@ -71,28 +71,28 @@ bool text_placement_info_simple::next_position_only()
|
||||||
displacement = pdisp;
|
displacement = pdisp;
|
||||||
break;
|
break;
|
||||||
case NORTH:
|
case NORTH:
|
||||||
displacement = std::make_pair(0, -abs(pdisp.second));
|
displacement.set(0, -abs(pdisp.y));
|
||||||
break;
|
break;
|
||||||
case EAST:
|
case EAST:
|
||||||
displacement = std::make_pair(abs(pdisp.first), 0);
|
displacement.set(abs(pdisp.x), 0);
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
displacement = std::make_pair(0, abs(pdisp.second));
|
displacement.set(0, abs(pdisp.y));
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
displacement = std::make_pair(-abs(pdisp.first), 0);
|
displacement.set(-abs(pdisp.x), 0);
|
||||||
break;
|
break;
|
||||||
case NORTHEAST:
|
case NORTHEAST:
|
||||||
displacement = std::make_pair(abs(pdisp.first), -abs(pdisp.second));
|
displacement.set(abs(pdisp.x), -abs(pdisp.y));
|
||||||
break;
|
break;
|
||||||
case SOUTHEAST:
|
case SOUTHEAST:
|
||||||
displacement = std::make_pair(abs(pdisp.first), abs(pdisp.second));
|
displacement.set(abs(pdisp.x), abs(pdisp.y));
|
||||||
break;
|
break;
|
||||||
case NORTHWEST:
|
case NORTHWEST:
|
||||||
displacement = std::make_pair(-abs(pdisp.first), -abs(pdisp.second));
|
displacement.set(-abs(pdisp.x), -abs(pdisp.y));
|
||||||
break;
|
break;
|
||||||
case SOUTHWEST:
|
case SOUTHWEST:
|
||||||
displacement = std::make_pair(-abs(pdisp.first), abs(pdisp.second));
|
displacement.set(-abs(pdisp.x), abs(pdisp.y));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MAPNIK_LOG_WARN(text_placements) << "Unknown placement";
|
MAPNIK_LOG_WARN(text_placements) << "Unknown placement";
|
||||||
|
|
|
@ -113,9 +113,9 @@ void text_symbolizer_properties::from_xml(xml_node const &sym, fontset_map const
|
||||||
optional<expression_ptr> orientation_ = sym.get_opt_attr<expression_ptr>("orientation");
|
optional<expression_ptr> orientation_ = sym.get_opt_attr<expression_ptr>("orientation");
|
||||||
if (orientation_) orientation = *orientation_;
|
if (orientation_) orientation = *orientation_;
|
||||||
optional<double> dx = sym.get_opt_attr<double>("dx");
|
optional<double> dx = sym.get_opt_attr<double>("dx");
|
||||||
if (dx) displacement.first = *dx;
|
if (dx) displacement.x = *dx;
|
||||||
optional<double> dy = sym.get_opt_attr<double>("dy");
|
optional<double> dy = sym.get_opt_attr<double>("dy");
|
||||||
if (dy) displacement.second = *dy;
|
if (dy) displacement.y = *dy;
|
||||||
optional<double> max_char_angle_delta_ = sym.get_opt_attr<double>("max-char-angle-delta");
|
optional<double> max_char_angle_delta_ = sym.get_opt_attr<double>("max-char-angle-delta");
|
||||||
if (max_char_angle_delta_) max_char_angle_delta=(*max_char_angle_delta_)*(M_PI/180);
|
if (max_char_angle_delta_) max_char_angle_delta=(*max_char_angle_delta_)*(M_PI/180);
|
||||||
|
|
||||||
|
@ -144,13 +144,13 @@ void text_symbolizer_properties::to_xml(boost::property_tree::ptree &node,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displacement.first != dfl.displacement.first || explicit_defaults)
|
if (displacement.x != dfl.displacement.x || explicit_defaults)
|
||||||
{
|
{
|
||||||
set_attr(node, "dx", displacement.first);
|
set_attr(node, "dx", displacement.x);
|
||||||
}
|
}
|
||||||
if (displacement.second != dfl.displacement.second || explicit_defaults)
|
if (displacement.y != dfl.displacement.y || explicit_defaults)
|
||||||
{
|
{
|
||||||
set_attr(node, "dy", displacement.second);
|
set_attr(node, "dy", displacement.y);
|
||||||
}
|
}
|
||||||
if (label_placement != dfl.label_placement || explicit_defaults)
|
if (label_placement != dfl.label_placement || explicit_defaults)
|
||||||
{
|
{
|
||||||
|
|
|
@ -350,15 +350,15 @@ label_placement_e text_symbolizer::get_label_placement() const
|
||||||
|
|
||||||
void text_symbolizer::set_displacement(double x, double y)
|
void text_symbolizer::set_displacement(double x, double y)
|
||||||
{
|
{
|
||||||
placement_options_->defaults.displacement = std::make_pair(x,y);
|
placement_options_->defaults.displacement.set(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void text_symbolizer::set_displacement(position const& p)
|
void text_symbolizer::set_displacement(const pixel_position &p)
|
||||||
{
|
{
|
||||||
placement_options_->defaults.displacement = p;
|
placement_options_->defaults.displacement = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
position const& text_symbolizer::get_displacement() const
|
pixel_position const& text_symbolizer::get_displacement() const
|
||||||
{
|
{
|
||||||
return placement_options_->defaults.displacement;
|
return placement_options_->defaults.displacement;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue