Merge branch 'master' of github.com:mapnik/mapnik

This commit is contained in:
Dane Springmeyer 2012-07-06 11:54:04 -07:00
commit 3ddd38116c
4 changed files with 297 additions and 296 deletions

View file

@ -1330,7 +1330,9 @@ if not preconfigured:
py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip() py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip()
if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python': if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python':
env['BOOST_PYTHON_LIB'] = 'boost_python3' env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND']
elif env['BOOST_PYTHON_LIB'] == 'boost_python':
env['BOOST_PYTHON_LIB'] = 'boost_python%s' % env['BOOST_APPEND']
if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'):
color_print(1,'Could not find required header files for boost python') color_print(1,'Could not find required header files for boost python')

View file

@ -47,9 +47,9 @@ public:
typedef path_adapter<VertexContainer> self_type; typedef path_adapter<VertexContainer> self_type;
//-------------------------------------------------------------------- //--------------------------------------------------------------------
path_adapter(VertexContainer & vertices) : m_vertices(vertices), m_iterator(0) {} path_adapter(VertexContainer & vertices) : vertices_(vertices), iterator_(0) {}
//void remove_all() { m_vertices.remove_all(); m_iterator = 0; } //void remove_all() { vertices_.remove_all(); iterator_ = 0; }
//void free_all() { m_vertices.free_all(); m_iterator = 0; } //void free_all() { vertices_.free_all(); iterator_ = 0; }
// Make path functions // Make path functions
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -109,8 +109,8 @@ public:
// Accessors // Accessors
//-------------------------------------------------------------------- //--------------------------------------------------------------------
const container_type& vertices() const { return m_vertices; } const container_type& vertices() const { return vertices_; }
container_type& vertices() { return m_vertices; } container_type& vertices() { return vertices_; }
unsigned total_vertices() const; unsigned total_vertices() const;
@ -160,7 +160,7 @@ public:
vs.rewind(path_id); vs.rewind(path_id);
while(!is_stop(cmd = vs.vertex(&x, &y))) while(!is_stop(cmd = vs.vertex(&x, &y)))
{ {
m_vertices.add_vertex(x, y, cmd); vertices_.add_vertex(x, y, cmd);
} }
} }
@ -185,7 +185,7 @@ public:
if(calc_distance(x, y, x0, y0) > vertex_dist_epsilon) if(calc_distance(x, y, x0, y0) > vertex_dist_epsilon)
{ {
if(is_move_to(cmd)) cmd = path_cmd_line_to; if(is_move_to(cmd)) cmd = path_cmd_line_to;
m_vertices.add_vertex(x, y, cmd); vertices_.add_vertex(x, y, cmd);
} }
} }
else else
@ -198,12 +198,12 @@ public:
{ {
if(is_move_to(cmd)) cmd = path_cmd_line_to; if(is_move_to(cmd)) cmd = path_cmd_line_to;
} }
m_vertices.add_vertex(x, y, cmd); vertices_.add_vertex(x, y, cmd);
} }
} }
while(!is_stop(cmd = vs.vertex(&x, &y))) while(!is_stop(cmd = vs.vertex(&x, &y)))
{ {
m_vertices.add_vertex(x, y, is_move_to(cmd) ? vertices_.add_vertex(x, y, is_move_to(cmd) ?
unsigned(path_cmd_line_to) : unsigned(path_cmd_line_to) :
cmd); cmd);
} }
@ -218,16 +218,16 @@ public:
template<class Trans> template<class Trans>
void transform(const Trans& trans, unsigned path_id=0) void transform(const Trans& trans, unsigned path_id=0)
{ {
unsigned num_ver = m_vertices.total_vertices(); unsigned num_ver = vertices_.total_vertices();
for(; path_id < num_ver; path_id++) for(; path_id < num_ver; path_id++)
{ {
double x, y; double x, y;
unsigned cmd = m_vertices.vertex(path_id, &x, &y); unsigned cmd = vertices_.vertex(path_id, &x, &y);
if(is_stop(cmd)) break; if(is_stop(cmd)) break;
if(is_vertex(cmd)) if(is_vertex(cmd))
{ {
trans.transform(&x, &y); trans.transform(&x, &y);
m_vertices.modify_vertex(path_id, x, y); vertices_.modify_vertex(path_id, x, y);
} }
} }
} }
@ -237,14 +237,14 @@ public:
void transform_all_paths(const Trans& trans) void transform_all_paths(const Trans& trans)
{ {
unsigned idx; unsigned idx;
unsigned num_ver = m_vertices.total_vertices(); unsigned num_ver = vertices_.total_vertices();
for(idx = 0; idx < num_ver; idx++) for(idx = 0; idx < num_ver; idx++)
{ {
double x, y; double x, y;
if(is_vertex(m_vertices.vertex(idx, &x, &y))) if(is_vertex(vertices_.vertex(idx, &x, &y)))
{ {
trans.transform(&x, &y); trans.transform(&x, &y);
m_vertices.modify_vertex(idx, x, y); vertices_.modify_vertex(idx, x, y);
} }
} }
} }
@ -255,19 +255,21 @@ private:
unsigned perceive_polygon_orientation(unsigned start, unsigned end); unsigned perceive_polygon_orientation(unsigned start, unsigned end);
void invert_polygon(unsigned start, unsigned end); void invert_polygon(unsigned start, unsigned end);
VertexContainer & m_vertices; VertexContainer & vertices_;
unsigned m_iterator; unsigned iterator_;
double start_x_;
double start_y_;
}; };
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
unsigned path_adapter<VC>::start_new_path() unsigned path_adapter<VC>::start_new_path()
{ {
if(!is_stop(m_vertices.last_command())) if(!is_stop(vertices_.last_command()))
{ {
m_vertices.add_vertex(0.0, 0.0, path_cmd_stop); vertices_.add_vertex(0.0, 0.0, path_cmd_stop);
} }
return m_vertices.total_vertices(); return vertices_.total_vertices();
} }
@ -275,17 +277,12 @@ unsigned path_adapter<VC>::start_new_path()
template<class VC> template<class VC>
inline void path_adapter<VC>::rel_to_abs(double* x, double* y) const inline void path_adapter<VC>::rel_to_abs(double* x, double* y) const
{ {
if(m_vertices.total_vertices()) if(vertices_.total_vertices())
{ {
double x2; double x2;
double y2; double y2;
if(is_vertex(m_vertices.last_vertex(&x2, &y2))) if(is_vertex(vertices_.last_vertex(&x2, &y2))
{ || !is_stop(vertices_.last_command()))
*x += x2;
*y += y2;
}
else if (!is_stop(m_vertices.last_command()) &&
is_vertex(m_vertices.prev_vertex(&x2, &y2)))
{ {
*x += x2; *x += x2;
*y += y2; *y += y2;
@ -297,7 +294,9 @@ inline void path_adapter<VC>::rel_to_abs(double* x, double* y) const
template<class VC> template<class VC>
inline void path_adapter<VC>::move_to(double x, double y) inline void path_adapter<VC>::move_to(double x, double y)
{ {
m_vertices.add_vertex(x, y, path_cmd_move_to); start_x_ = x;
start_y_ = y;
vertices_.add_vertex(x, y, path_cmd_move_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -305,14 +304,14 @@ template<class VC>
inline void path_adapter<VC>::move_rel(double dx, double dy) inline void path_adapter<VC>::move_rel(double dx, double dy)
{ {
rel_to_abs(&dx, &dy); rel_to_abs(&dx, &dy);
m_vertices.add_vertex(dx, dy, path_cmd_move_to); vertices_.add_vertex(dx, dy, path_cmd_move_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_adapter<VC>::line_to(double x, double y) inline void path_adapter<VC>::line_to(double x, double y)
{ {
m_vertices.add_vertex(x, y, path_cmd_line_to); vertices_.add_vertex(x, y, path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -320,14 +319,14 @@ template<class VC>
inline void path_adapter<VC>::line_rel(double dx, double dy) inline void path_adapter<VC>::line_rel(double dx, double dy)
{ {
rel_to_abs(&dx, &dy); rel_to_abs(&dx, &dy);
m_vertices.add_vertex(dx, dy, path_cmd_line_to); vertices_.add_vertex(dx, dy, path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_adapter<VC>::hline_to(double x) inline void path_adapter<VC>::hline_to(double x)
{ {
m_vertices.add_vertex(x, last_y(), path_cmd_line_to); vertices_.add_vertex(x, last_y(), path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -336,14 +335,14 @@ inline void path_adapter<VC>::hline_rel(double dx)
{ {
double dy = 0; double dy = 0;
rel_to_abs(&dx, &dy); rel_to_abs(&dx, &dy);
m_vertices.add_vertex(dx, dy, path_cmd_line_to); vertices_.add_vertex(dx, dy, path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_adapter<VC>::vline_to(double y) inline void path_adapter<VC>::vline_to(double y)
{ {
m_vertices.add_vertex(last_x(), y, path_cmd_line_to); vertices_.add_vertex(last_x(), y, path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -352,7 +351,7 @@ inline void path_adapter<VC>::vline_rel(double dy)
{ {
double dx = 0; double dx = 0;
rel_to_abs(&dx, &dy); rel_to_abs(&dx, &dy);
m_vertices.add_vertex(dx, dy, path_cmd_line_to); vertices_.add_vertex(dx, dy, path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -363,12 +362,12 @@ void path_adapter<VC>::arc_to(double rx, double ry,
bool sweep_flag, bool sweep_flag,
double x, double y) double x, double y)
{ {
if(m_vertices.total_vertices() && is_vertex(m_vertices.last_command())) if(vertices_.total_vertices() && is_vertex(vertices_.last_command()))
{ {
const double epsilon = 1e-30; const double epsilon = 1e-30;
double x0 = 0.0; double x0 = 0.0;
double y0 = 0.0; double y0 = 0.0;
m_vertices.last_vertex(&x0, &y0); vertices_.last_vertex(&x0, &y0);
rx = fabs(rx); rx = fabs(rx);
ry = fabs(ry); ry = fabs(ry);
@ -420,8 +419,8 @@ template<class VC>
void path_adapter<VC>::curve3(double x_ctrl, double y_ctrl, void path_adapter<VC>::curve3(double x_ctrl, double y_ctrl,
double x_to, double y_to) double x_to, double y_to)
{ {
m_vertices.add_vertex(x_ctrl, y_ctrl, path_cmd_curve3); vertices_.add_vertex(x_ctrl, y_ctrl, path_cmd_curve3);
m_vertices.add_vertex(x_to, y_to, path_cmd_curve3); vertices_.add_vertex(x_to, y_to, path_cmd_curve3);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -431,8 +430,8 @@ void path_adapter<VC>::curve3_rel(double dx_ctrl, double dy_ctrl,
{ {
rel_to_abs(&dx_ctrl, &dy_ctrl); rel_to_abs(&dx_ctrl, &dy_ctrl);
rel_to_abs(&dx_to, &dy_to); rel_to_abs(&dx_to, &dy_to);
m_vertices.add_vertex(dx_ctrl, dy_ctrl, path_cmd_curve3); vertices_.add_vertex(dx_ctrl, dy_ctrl, path_cmd_curve3);
m_vertices.add_vertex(dx_to, dy_to, path_cmd_curve3); vertices_.add_vertex(dx_to, dy_to, path_cmd_curve3);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -441,11 +440,11 @@ void path_adapter<VC>::curve3(double x_to, double y_to)
{ {
double x0; double x0;
double y0; double y0;
if(is_vertex(m_vertices.last_vertex(&x0, &y0))) if(is_vertex(vertices_.last_vertex(&x0, &y0)))
{ {
double x_ctrl; double x_ctrl;
double y_ctrl; double y_ctrl;
unsigned cmd = m_vertices.prev_vertex(&x_ctrl, &y_ctrl); unsigned cmd = vertices_.prev_vertex(&x_ctrl, &y_ctrl);
if(is_curve(cmd)) if(is_curve(cmd))
{ {
x_ctrl = x0 + x0 - x_ctrl; x_ctrl = x0 + x0 - x_ctrl;
@ -474,9 +473,9 @@ void path_adapter<VC>::curve4(double x_ctrl1, double y_ctrl1,
double x_ctrl2, double y_ctrl2, double x_ctrl2, double y_ctrl2,
double x_to, double y_to) double x_to, double y_to)
{ {
m_vertices.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4); vertices_.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4);
m_vertices.add_vertex(x_ctrl2, y_ctrl2, path_cmd_curve4); vertices_.add_vertex(x_ctrl2, y_ctrl2, path_cmd_curve4);
m_vertices.add_vertex(x_to, y_to, path_cmd_curve4); vertices_.add_vertex(x_to, y_to, path_cmd_curve4);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -488,9 +487,9 @@ void path_adapter<VC>::curve4_rel(double dx_ctrl1, double dy_ctrl1,
rel_to_abs(&dx_ctrl1, &dy_ctrl1); rel_to_abs(&dx_ctrl1, &dy_ctrl1);
rel_to_abs(&dx_ctrl2, &dy_ctrl2); rel_to_abs(&dx_ctrl2, &dy_ctrl2);
rel_to_abs(&dx_to, &dy_to); rel_to_abs(&dx_to, &dy_to);
m_vertices.add_vertex(dx_ctrl1, dy_ctrl1, path_cmd_curve4); vertices_.add_vertex(dx_ctrl1, dy_ctrl1, path_cmd_curve4);
m_vertices.add_vertex(dx_ctrl2, dy_ctrl2, path_cmd_curve4); vertices_.add_vertex(dx_ctrl2, dy_ctrl2, path_cmd_curve4);
m_vertices.add_vertex(dx_to, dy_to, path_cmd_curve4); vertices_.add_vertex(dx_to, dy_to, path_cmd_curve4);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -533,9 +532,9 @@ void path_adapter<VC>::curve4_rel(double dx_ctrl2, double dy_ctrl2,
template<class VC> template<class VC>
inline void path_adapter<VC>::end_poly(unsigned flags) inline void path_adapter<VC>::end_poly(unsigned flags)
{ {
if(is_vertex(m_vertices.last_command())) if(is_vertex(vertices_.last_command()))
{ {
m_vertices.add_vertex(0.0, 0.0, path_cmd_end_poly | flags); vertices_.add_vertex(start_x_, start_y_, path_cmd_end_poly | flags);
} }
} }
@ -550,85 +549,85 @@ inline void path_adapter<VC>::close_polygon(unsigned flags)
template<class VC> template<class VC>
inline unsigned path_adapter<VC>::total_vertices() const inline unsigned path_adapter<VC>::total_vertices() const
{ {
return m_vertices.total_vertices(); return vertices_.total_vertices();
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_adapter<VC>::last_vertex(double* x, double* y) const inline unsigned path_adapter<VC>::last_vertex(double* x, double* y) const
{ {
return m_vertices.last_vertex(x, y); return vertices_.last_vertex(x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_adapter<VC>::prev_vertex(double* x, double* y) const inline unsigned path_adapter<VC>::prev_vertex(double* x, double* y) const
{ {
return m_vertices.prev_vertex(x, y); return vertices_.prev_vertex(x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline double path_adapter<VC>::last_x() const inline double path_adapter<VC>::last_x() const
{ {
return m_vertices.last_x(); return vertices_.last_x();
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline double path_adapter<VC>::last_y() const inline double path_adapter<VC>::last_y() const
{ {
return m_vertices.last_y(); return vertices_.last_y();
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_adapter<VC>::vertex(unsigned idx, double* x, double* y) const inline unsigned path_adapter<VC>::vertex(unsigned idx, double* x, double* y) const
{ {
return m_vertices.vertex(idx, x, y); return vertices_.vertex(idx, x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_adapter<VC>::command(unsigned idx) const inline unsigned path_adapter<VC>::command(unsigned idx) const
{ {
return m_vertices.command(idx); return vertices_.command(idx);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_adapter<VC>::modify_vertex(unsigned idx, double x, double y) void path_adapter<VC>::modify_vertex(unsigned idx, double x, double y)
{ {
m_vertices.modify_vertex(idx, x, y); vertices_.modify_vertex(idx, x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_adapter<VC>::modify_vertex(unsigned idx, double x, double y, unsigned cmd) void path_adapter<VC>::modify_vertex(unsigned idx, double x, double y, unsigned cmd)
{ {
m_vertices.modify_vertex(idx, x, y, cmd); vertices_.modify_vertex(idx, x, y, cmd);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_adapter<VC>::modify_command(unsigned idx, unsigned cmd) void path_adapter<VC>::modify_command(unsigned idx, unsigned cmd)
{ {
m_vertices.modify_command(idx, cmd); vertices_.modify_command(idx, cmd);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_adapter<VC>::rewind(unsigned path_id) inline void path_adapter<VC>::rewind(unsigned path_id)
{ {
m_iterator = path_id; iterator_ = path_id;
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_adapter<VC>::vertex(double* x, double* y) inline unsigned path_adapter<VC>::vertex(double* x, double* y)
{ {
if(m_iterator >= m_vertices.total_vertices()) return path_cmd_stop; if(iterator_ >= vertices_.total_vertices()) return path_cmd_stop;
return m_vertices.vertex(m_iterator++, x, y); return vertices_.vertex(iterator_++, x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -644,8 +643,8 @@ unsigned path_adapter<VC>::perceive_polygon_orientation(unsigned start,
for(i = 0; i < np; i++) for(i = 0; i < np; i++)
{ {
double x1, y1, x2, y2; double x1, y1, x2, y2;
m_vertices.vertex(start + i, &x1, &y1); vertices_.vertex(start + i, &x1, &y1);
m_vertices.vertex(start + (i + 1) % np, &x2, &y2); vertices_.vertex(start + (i + 1) % np, &x2, &y2);
area += x1 * y2 - y1 * x2; area += x1 * y2 - y1 * x2;
} }
return (area < 0.0) ? path_flags_cw : path_flags_ccw; return (area < 0.0) ? path_flags_cw : path_flags_ccw;
@ -656,23 +655,23 @@ template<class VC>
void path_adapter<VC>::invert_polygon(unsigned start, unsigned end) void path_adapter<VC>::invert_polygon(unsigned start, unsigned end)
{ {
unsigned i; unsigned i;
unsigned tmp_cmd = m_vertices.command(start); unsigned tmp_cmd = vertices_.command(start);
--end; // Make "end" inclusive --end; // Make "end" inclusive
// Shift all commands to one position // Shift all commands to one position
for(i = start; i < end; i++) for(i = start; i < end; i++)
{ {
m_vertices.modify_command(i, m_vertices.command(i + 1)); vertices_.modify_command(i, vertices_.command(i + 1));
} }
// Assign starting command to the ending command // Assign starting command to the ending command
m_vertices.modify_command(end, tmp_cmd); vertices_.modify_command(end, tmp_cmd);
// Reverse the polygon // Reverse the polygon
while(end > start) while(end > start)
{ {
m_vertices.swap_vertices(start++, end--); vertices_.swap_vertices(start++, end--);
} }
} }
@ -681,18 +680,18 @@ template<class VC>
void path_adapter<VC>::invert_polygon(unsigned start) void path_adapter<VC>::invert_polygon(unsigned start)
{ {
// Skip all non-vertices at the beginning // Skip all non-vertices at the beginning
while(start < m_vertices.total_vertices() && while(start < vertices_.total_vertices() &&
!is_vertex(m_vertices.command(start))) ++start; !is_vertex(vertices_.command(start))) ++start;
// Skip all insignificant move_to // Skip all insignificant move_to
while(start+1 < m_vertices.total_vertices() && while(start+1 < vertices_.total_vertices() &&
is_move_to(m_vertices.command(start)) && is_move_to(vertices_.command(start)) &&
is_move_to(m_vertices.command(start+1))) ++start; is_move_to(vertices_.command(start+1))) ++start;
// Find the last vertex // Find the last vertex
unsigned end = start + 1; unsigned end = start + 1;
while(end < m_vertices.total_vertices() && while(end < vertices_.total_vertices() &&
!is_next_poly(m_vertices.command(end))) ++end; !is_next_poly(vertices_.command(end))) ++end;
invert_polygon(start, end); invert_polygon(start, end);
} }
@ -705,18 +704,18 @@ unsigned path_adapter<VC>::arrange_polygon_orientation(unsigned start,
if(orientation == path_flags_none) return start; if(orientation == path_flags_none) return start;
// Skip all non-vertices at the beginning // Skip all non-vertices at the beginning
while(start < m_vertices.total_vertices() && while(start < vertices_.total_vertices() &&
!is_vertex(m_vertices.command(start))) ++start; !is_vertex(vertices_.command(start))) ++start;
// Skip all insignificant move_to // Skip all insignificant move_to
while(start+1 < m_vertices.total_vertices() && while(start+1 < vertices_.total_vertices() &&
is_move_to(m_vertices.command(start)) && is_move_to(vertices_.command(start)) &&
is_move_to(m_vertices.command(start+1))) ++start; is_move_to(vertices_.command(start+1))) ++start;
// Find the last vertex // Find the last vertex
unsigned end = start + 1; unsigned end = start + 1;
while(end < m_vertices.total_vertices() && while(end < vertices_.total_vertices() &&
!is_next_poly(m_vertices.command(end))) ++end; !is_next_poly(vertices_.command(end))) ++end;
if(end - start > 2) if(end - start > 2)
{ {
@ -725,10 +724,10 @@ unsigned path_adapter<VC>::arrange_polygon_orientation(unsigned start,
// Invert polygon, set orientation flag, and skip all end_poly // Invert polygon, set orientation flag, and skip all end_poly
invert_polygon(start, end); invert_polygon(start, end);
unsigned cmd; unsigned cmd;
while(end < m_vertices.total_vertices() && while(end < vertices_.total_vertices() &&
is_end_poly(cmd = m_vertices.command(end))) is_end_poly(cmd = vertices_.command(end)))
{ {
m_vertices.modify_command(end++, set_orientation(cmd, orientation)); vertices_.modify_command(end++, set_orientation(cmd, orientation));
} }
} }
} }
@ -742,10 +741,10 @@ unsigned path_adapter<VC>::arrange_orientations(unsigned start,
{ {
if(orientation != path_flags_none) if(orientation != path_flags_none)
{ {
while(start < m_vertices.total_vertices()) while(start < vertices_.total_vertices())
{ {
start = arrange_polygon_orientation(start, orientation); start = arrange_polygon_orientation(start, orientation);
if(is_stop(m_vertices.command(start))) if(is_stop(vertices_.command(start)))
{ {
++start; ++start;
break; break;
@ -762,7 +761,7 @@ void path_adapter<VC>::arrange_orientations_all_paths(path_flags_e orientation)
if(orientation != path_flags_none) if(orientation != path_flags_none)
{ {
unsigned start = 0; unsigned start = 0;
while(start < m_vertices.total_vertices()) while(start < vertices_.total_vertices())
{ {
start = arrange_orientations(start, orientation); start = arrange_orientations(start, orientation);
} }
@ -775,12 +774,12 @@ void path_adapter<VC>::flip_x(double x1, double x2)
{ {
unsigned i; unsigned i;
double x, y; double x, y;
for(i = 0; i < m_vertices.total_vertices(); i++) for(i = 0; i < vertices_.total_vertices(); i++)
{ {
unsigned cmd = m_vertices.vertex(i, &x, &y); unsigned cmd = vertices_.vertex(i, &x, &y);
if(is_vertex(cmd)) if(is_vertex(cmd))
{ {
m_vertices.modify_vertex(i, x2 - x + x1, y); vertices_.modify_vertex(i, x2 - x + x1, y);
} }
} }
} }
@ -791,12 +790,12 @@ void path_adapter<VC>::flip_y(double y1, double y2)
{ {
unsigned i; unsigned i;
double x, y; double x, y;
for(i = 0; i < m_vertices.total_vertices(); i++) for(i = 0; i < vertices_.total_vertices(); i++)
{ {
unsigned cmd = m_vertices.vertex(i, &x, &y); unsigned cmd = vertices_.vertex(i, &x, &y);
if(is_vertex(cmd)) if(is_vertex(cmd))
{ {
m_vertices.modify_vertex(i, x, y2 - y + y1); vertices_.modify_vertex(i, x, y2 - y + y1);
} }
} }
} }
@ -805,17 +804,17 @@ void path_adapter<VC>::flip_y(double y1, double y2)
template<class VC> template<class VC>
void path_adapter<VC>::translate(double dx, double dy, unsigned path_id) void path_adapter<VC>::translate(double dx, double dy, unsigned path_id)
{ {
unsigned num_ver = m_vertices.total_vertices(); unsigned num_ver = vertices_.total_vertices();
for(; path_id < num_ver; path_id++) for(; path_id < num_ver; path_id++)
{ {
double x, y; double x, y;
unsigned cmd = m_vertices.vertex(path_id, &x, &y); unsigned cmd = vertices_.vertex(path_id, &x, &y);
if(is_stop(cmd)) break; if(is_stop(cmd)) break;
if(is_vertex(cmd)) if(is_vertex(cmd))
{ {
x += dx; x += dx;
y += dy; y += dy;
m_vertices.modify_vertex(path_id, x, y); vertices_.modify_vertex(path_id, x, y);
} }
} }
} }
@ -825,15 +824,15 @@ template<class VC>
void path_adapter<VC>::translate_all_paths(double dx, double dy) void path_adapter<VC>::translate_all_paths(double dx, double dy)
{ {
unsigned idx; unsigned idx;
unsigned num_ver = m_vertices.total_vertices(); unsigned num_ver = vertices_.total_vertices();
for(idx = 0; idx < num_ver; idx++) for(idx = 0; idx < num_ver; idx++)
{ {
double x, y; double x, y;
if(is_vertex(m_vertices.vertex(idx, &x, &y))) if(is_vertex(vertices_.vertex(idx, &x, &y)))
{ {
x += dx; x += dx;
y += dy; y += dy;
m_vertices.modify_vertex(idx, x, y); vertices_.modify_vertex(idx, x, y);
} }
} }
} }
@ -847,25 +846,25 @@ public:
typedef typename vertex_type::value_type value_type; typedef typename vertex_type::value_type value_type;
explicit vertex_stl_adapter(Container & vertices) explicit vertex_stl_adapter(Container & vertices)
: m_vertices(vertices) {} : vertices_(vertices) {}
void add_vertex(double x, double y, unsigned cmd) void add_vertex(double x, double y, unsigned cmd)
{ {
m_vertices.push_back(vertex_type(value_type(x), vertices_.push_back(vertex_type(value_type(x),
value_type(y), value_type(y),
int8u(cmd))); int8u(cmd)));
} }
void modify_vertex(unsigned idx, double x, double y) void modify_vertex(unsigned idx, double x, double y)
{ {
vertex_type& v = m_vertices[idx]; vertex_type& v = vertices_[idx];
v.x = value_type(x); v.x = value_type(x);
v.y = value_type(y); v.y = value_type(y);
} }
void modify_vertex(unsigned idx, double x, double y, unsigned cmd) void modify_vertex(unsigned idx, double x, double y, unsigned cmd)
{ {
vertex_type& v = m_vertices[idx]; vertex_type& v = vertices_[idx];
v.x = value_type(x); v.x = value_type(x);
v.y = value_type(y); v.y = value_type(y);
v.cmd = int8u(cmd); v.cmd = int8u(cmd);
@ -873,61 +872,61 @@ public:
void modify_command(unsigned idx, unsigned cmd) void modify_command(unsigned idx, unsigned cmd)
{ {
m_vertices[idx].cmd = int8u(cmd); vertices_[idx].cmd = int8u(cmd);
} }
void swap_vertices(unsigned v1, unsigned v2) void swap_vertices(unsigned v1, unsigned v2)
{ {
vertex_type t = m_vertices[v1]; vertex_type t = vertices_[v1];
m_vertices[v1] = m_vertices[v2]; vertices_[v1] = vertices_[v2];
m_vertices[v2] = t; vertices_[v2] = t;
} }
unsigned last_command() const unsigned last_command() const
{ {
return m_vertices.size() ? return vertices_.size() ?
m_vertices[m_vertices.size() - 1].cmd : vertices_[vertices_.size() - 1].cmd :
(unsigned)path_cmd_stop; (unsigned)path_cmd_stop;
} }
unsigned last_vertex(double* x, double* y) const unsigned last_vertex(double* x, double* y) const
{ {
if(m_vertices.size() == 0) if(vertices_.size() == 0)
{ {
*x = *y = 0.0; *x = *y = 0.0;
return path_cmd_stop; return path_cmd_stop;
} }
return vertex(m_vertices.size() - 1, x, y); return vertex(vertices_.size() - 1, x, y);
} }
unsigned prev_vertex(double* x, double* y) const unsigned prev_vertex(double* x, double* y) const
{ {
if(m_vertices.size() < 2) if(vertices_.size() < 2)
{ {
*x = *y = 0.0; *x = *y = 0.0;
return path_cmd_stop; return path_cmd_stop;
} }
return vertex(m_vertices.size() - 2, x, y); return vertex(vertices_.size() - 2, x, y);
} }
double last_x() const double last_x() const
{ {
return m_vertices.size() ? m_vertices[m_vertices.size() - 1].x : 0.0; return vertices_.size() ? vertices_[vertices_.size() - 1].x : 0.0;
} }
double last_y() const double last_y() const
{ {
return m_vertices.size() ? m_vertices[m_vertices.size() - 1].y : 0.0; return vertices_.size() ? vertices_[vertices_.size() - 1].y : 0.0;
} }
unsigned total_vertices() const unsigned total_vertices() const
{ {
return m_vertices.size(); return vertices_.size();
} }
unsigned vertex(unsigned idx, double* x, double* y) const unsigned vertex(unsigned idx, double* x, double* y) const
{ {
const vertex_type& v = m_vertices[idx]; const vertex_type& v = vertices_[idx];
*x = v.x; *x = v.x;
*y = v.y; *y = v.y;
return v.cmd; return v.cmd;
@ -935,11 +934,11 @@ public:
unsigned command(unsigned idx) const unsigned command(unsigned idx) const
{ {
return m_vertices[idx].cmd; return vertices_[idx].cmd;
} }
private: private:
Container & m_vertices; Container & vertices_;
}; };

View file

@ -35,232 +35,232 @@
namespace mapnik { namespace svg { namespace mapnik { namespace svg {
using namespace boost::fusion; using namespace boost::fusion;
inline double deg2rad(double deg) inline double deg2rad(double deg)
{
return (M_PI * deg)/180.0;
}
template <typename PathType>
struct move_to
{
template <typename T0, typename T1>
struct result
{ {
return (M_PI * deg)/180.0; typedef void type;
};
explicit move_to(PathType & path)
: path_(path) {}
template <typename T0, typename T1>
void operator() (T0 v, T1 rel) const
{
path_.move_to(at_c<0>(v),at_c<1>(v),rel); // impl
} }
template <typename PathType> PathType & path_;
struct move_to };
template <typename PathType>
struct hline_to
{
template <typename T0, typename T1>
struct result
{ {
template <typename T0, typename T1> typedef void type;
struct result
{
typedef void type;
};
explicit move_to(PathType & path)
: path_(path) {}
template <typename T0, typename T1>
void operator() (T0 v, T1 rel) const
{
path_.move_to(at_c<0>(v),at_c<1>(v),rel); // impl
}
PathType & path_;
}; };
template <typename PathType> explicit hline_to(PathType & path)
struct hline_to : path_(path) {}
template <typename T0, typename T1>
void operator() (T0 const& x, T1 rel) const
{ {
template <typename T0, typename T1> path_.hline_to(x,rel);
struct result }
{
typedef void type;
};
explicit hline_to(PathType & path) PathType & path_;
: path_(path) {} };
template <typename T0, typename T1>
void operator() (T0 const& x, T1 rel) const
{
path_.hline_to(x,rel);
}
PathType & path_; template <typename PathType>
struct vline_to
{
template <typename T0, typename T1>
struct result
{
typedef void type;
}; };
explicit vline_to(PathType & path)
: path_(path) {}
template <typename PathType> template <typename T0, typename T1>
struct vline_to void operator() (T0 const& y, T1 rel) const
{ {
template <typename T0, typename T1> path_.vline_to(y,rel);
struct result }
{
typedef void type;
};
explicit vline_to(PathType & path) PathType & path_;
: path_(path) {} };
template <typename T0, typename T1> template <typename PathType>
void operator() (T0 const& y, T1 rel) const struct line_to
{ {
path_.vline_to(y,rel); template <typename T0, typename T1>
} struct result
{
PathType & path_; typedef void type;
}; };
template <typename PathType> explicit line_to(PathType & path)
struct line_to : path_(path) {}
template <typename T0, typename T1>
void operator() (T0 const& v, T1 rel) const
{ {
template <typename T0, typename T1> path_.line_to(at_c<0>(v),at_c<1>(v),rel); // impl
struct result }
{
typedef void type;
};
explicit line_to(PathType & path) PathType & path_;
: path_(path) {} };
template <typename T0, typename T1>
void operator() (T0 const& v, T1 rel) const
{
path_.line_to(at_c<0>(v),at_c<1>(v),rel); // impl
}
PathType & path_; template <typename PathType>
struct curve4
{
template <typename T0, typename T1, typename T2, typename T3>
struct result
{
typedef void type;
}; };
explicit curve4(PathType & path)
: path_(path) {}
template <typename PathType> template <typename T0, typename T1,typename T2, typename T3>
struct curve4 void operator() (T0 const& v0, T1 const& v1, T2 const& v2, T3 rel) const
{ {
template <typename T0, typename T1, typename T2, typename T3> path_.curve4(at_c<0>(v0),at_c<1>(v0),
struct result at_c<0>(v1),at_c<1>(v1),
{ at_c<0>(v2),at_c<1>(v2),
typedef void type; rel); // impl
}; }
explicit curve4(PathType & path) PathType & path_;
: path_(path) {} };
template <typename T0, typename T1,typename T2, typename T3>
void operator() (T0 const& v0, T1 const& v1, T2 const& v2, T3 rel) const
{
path_.curve4(at_c<0>(v0),at_c<1>(v0),
at_c<0>(v1),at_c<1>(v1),
at_c<0>(v2),at_c<1>(v2),
rel); // impl
}
PathType & path_; template <typename PathType>
struct curve4_smooth
{
template <typename T0, typename T1, typename T2>
struct result
{
typedef void type;
}; };
explicit curve4_smooth(PathType & path)
: path_(path) {}
template <typename PathType> template <typename T0, typename T1,typename T2>
struct curve4_smooth void operator() (T0 const& v0, T1 const& v1, T2 rel) const
{ {
template <typename T0, typename T1, typename T2> path_.curve4(at_c<0>(v0),at_c<1>(v0),
struct result at_c<0>(v1),at_c<1>(v1),
{ rel); // impl
typedef void type; }
}; PathType & path_;
};
explicit curve4_smooth(PathType & path) template <typename PathType>
: path_(path) {} struct curve3
{
template <typename T0, typename T1,typename T2> template <typename T0, typename T1, typename T2>
void operator() (T0 const& v0, T1 const& v1, T2 rel) const struct result
{ {
path_.curve4(at_c<0>(v0),at_c<1>(v0), typedef void type;
at_c<0>(v1),at_c<1>(v1),
rel); // impl
}
PathType & path_;
}; };
template <typename PathType> explicit curve3(PathType & path)
struct curve3 : path_(path) {}
template <typename T0, typename T1,typename T2>
void operator() (T0 const& v0, T1 const& v1, T2 rel) const
{ {
template <typename T0, typename T1, typename T2> path_.curve3(at_c<0>(v0),at_c<1>(v0),
struct result at_c<0>(v1),at_c<1>(v1),
{ rel); // impl
typedef void type; }
};
explicit curve3(PathType & path) PathType & path_;
: path_(path) {} };
template <typename T0, typename T1,typename T2> template <typename PathType>
void operator() (T0 const& v0, T1 const& v1, T2 rel) const struct curve3_smooth
{ {
path_.curve3(at_c<0>(v0),at_c<1>(v0), template <typename T0, typename T1>
at_c<0>(v1),at_c<1>(v1), struct result
rel); // impl {
} typedef void type;
PathType & path_;
}; };
template <typename PathType> explicit curve3_smooth(PathType & path)
struct curve3_smooth : path_(path) {}
template <typename T0, typename T1>
void operator() (T0 const& v0, T1 rel) const
{ {
template <typename T0, typename T1> path_.curve3(at_c<0>(v0),at_c<1>(v0),
struct result rel); // impl
{ }
typedef void type;
};
explicit curve3_smooth(PathType & path) PathType & path_;
: path_(path) {} };
template <typename T0, typename T1> template <typename PathType>
void operator() (T0 const& v0, T1 rel) const struct arc_to
{ {
path_.curve3(at_c<0>(v0),at_c<1>(v0), template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
rel); // impl struct result
} {
typedef void type;
PathType & path_;
}; };
template <typename PathType> explicit arc_to(PathType & path)
struct arc_to : path_(path) {}
template <typename T0, typename T1,typename T2, typename T3, typename T4, typename T5>
void operator() (T0 const& rv, T1 const& angle, T2 large_arc_flag, T3 sweep_flag, T4 const& v, T5 rel) const
{ {
template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5> path_.arc_to(at_c<0>(rv),at_c<1>(rv),
struct result deg2rad(angle),large_arc_flag,sweep_flag,
{ at_c<0>(v),at_c<1>(v),
typedef void type; rel);
}; }
explicit arc_to(PathType & path) PathType & path_;
: path_(path) {} };
template <typename T0, typename T1,typename T2, typename T3, typename T4, typename T5> template <typename PathType>
void operator() (T0 const& rv, T1 const& angle, T2 large_arc_flag, T3 sweep_flag, T4 const& v, T5 rel) const struct close
{ {
path_.arc_to(at_c<0>(rv),at_c<1>(rv), typedef void result_type;
deg2rad(angle),large_arc_flag,sweep_flag,
at_c<0>(v),at_c<1>(v),
rel);
}
PathType & path_; explicit close(PathType & path)
}; : path_(path) {}
template <typename PathType> void operator()() const
struct close
{ {
typedef void result_type; path_.close_subpath();
}
explicit close(PathType & path) PathType & path_;
: path_(path) {} };
void operator()() const }}
{
path_.close_subpath();
}
PathType & path_;
};
}}
#endif // MAPNIK_SVG_COMMANDS_HPP #endif // MAPNIK_SVG_COMMANDS_HPP

View file

@ -314,7 +314,7 @@ public:
{ {
// not-supported // not-supported
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
MAPNIK_LOG_WARN(save_map) << typeid(sym).name() << " is not supported" << std::endl; MAPNIK_LOG_WARN(save_map) << typeid(sym).name() << " is not supported";
#endif #endif
} }