fix angle calculation
Conflicts: src/text/vertex_cache.cpp
This commit is contained in:
parent
21d213a653
commit
67d8f41a1b
2 changed files with 22 additions and 10 deletions
|
@ -138,6 +138,7 @@ private:
|
||||||
void rewind_subpath();
|
void rewind_subpath();
|
||||||
bool next_segment();
|
bool next_segment();
|
||||||
bool previous_segment();
|
bool previous_segment();
|
||||||
|
double current_segment_angle();
|
||||||
// Position as calculated by last move/forward/next call.
|
// Position as calculated by last move/forward/next call.
|
||||||
pixel_position current_position_;
|
pixel_position current_position_;
|
||||||
// First pixel of current segment.
|
// First pixel of current segment.
|
||||||
|
|
|
@ -29,29 +29,40 @@
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
|
double vertex_cache::current_segment_angle()
|
||||||
|
{
|
||||||
|
return std::atan2(-(current_segment_->pos.y - segment_starting_point_.y),
|
||||||
|
current_segment_->pos.x - segment_starting_point_.x);
|
||||||
|
}
|
||||||
|
|
||||||
double vertex_cache::angle(double width)
|
double vertex_cache::angle(double width)
|
||||||
{
|
{
|
||||||
/* IMPORTANT NOTE: See note about coordinate systems in placement_finder::find_point_placement()
|
// IMPORTANT NOTE: See note about coordinate systems in placement_finder::find_point_placement()
|
||||||
* for imformation about why the y axis is inverted! */
|
// for imformation about why the y axis is inverted!
|
||||||
double tmp = width + position_in_segment_;
|
double tmp = width + position_in_segment_;
|
||||||
if ((tmp <= current_segment_->length) && (tmp >= 0))
|
if ((tmp <= current_segment_->length) && (tmp >= 0))
|
||||||
{
|
{
|
||||||
//Only calculate angle on request as it is expensive
|
//Only calculate angle on request as it is expensive
|
||||||
if (!angle_valid_)
|
if (!angle_valid_)
|
||||||
{
|
{
|
||||||
angle_ = std::atan2(-(current_segment_->pos.y - segment_starting_point_.y),
|
angle_ = current_segment_angle();
|
||||||
current_segment_->pos.x - segment_starting_point_.x);
|
|
||||||
}
|
}
|
||||||
return width >= 0 ? angle_ : angle_ + M_PI;
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
scoped_state s(*this);
|
scoped_state s(*this);
|
||||||
pixel_position const& old_pos = s.get_state().position();
|
if (move(width))
|
||||||
move(width);
|
{
|
||||||
double angle = std::atan2(-(current_position_.y - old_pos.y),
|
pixel_position const& old_pos = s.get_state().position();
|
||||||
current_position_.x - old_pos.x);
|
return std::atan2(-(current_position_.y - old_pos.y),
|
||||||
return angle;
|
current_position_.x - old_pos.x);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s.restore();
|
||||||
|
angle_ = current_segment_angle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return width >= 0 ? angle_ : angle_ + M_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vertex_cache::next_subpath()
|
bool vertex_cache::next_subpath()
|
||||||
|
|
Loading…
Reference in a new issue