1. removed dependency on boost_serialization ( we don't really need it) at this time.
2. coord and envelope operator<< to use 16 digit precision. 3. added 'inside polygon' method impl.
This commit is contained in:
parent
0bb121a747
commit
72fae1daa1
11 changed files with 516 additions and 595 deletions
|
@ -76,11 +76,6 @@ C_LIBSHEADERS = [
|
|||
BOOST_LIBSHEADERS = [
|
||||
['thread', 'boost/thread/mutex.hpp', True],
|
||||
['filesystem', 'boost/filesystem/operations.hpp', True],
|
||||
['serialization', ['boost/archive/text_oarchive.hpp',
|
||||
'boost/archive/text_iarchive.hpp',
|
||||
'boost/archive/xml_oarchive.hpp',
|
||||
'boost/archive/xml_iarchive.hpp'], True
|
||||
],
|
||||
['regex', 'boost/regex.hpp', True],
|
||||
['program_options', 'boost/program_options.hpp', False]
|
||||
]
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define COORD_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
namespace mapnik
|
||||
|
@ -113,7 +114,8 @@ namespace mapnik
|
|||
std::basic_ostringstream<charT,traits> s;
|
||||
s.copyfmt(out);
|
||||
s.width(0);
|
||||
s<<"coord2("<<c.x<<","<<c.y<<")";
|
||||
s << "coord2(" << std::setprecision(16)
|
||||
<< c.x << "," << c.y<< ")";
|
||||
out << s.str();
|
||||
return out;
|
||||
}
|
||||
|
@ -126,7 +128,8 @@ namespace mapnik
|
|||
std::basic_ostringstream<charT,traits> s;
|
||||
s.copyfmt(out);
|
||||
s.width(0);
|
||||
s<<"coord3("<<c.x<<","<<c.y<<","<<c.z<<")";
|
||||
s << "coord3(" << std::setprecision(16)
|
||||
<< c.x << "," << c.y<< "," << c.z<<")";
|
||||
out << s.str();
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define ENVELOPE_HPP
|
||||
|
||||
#include "config.hpp"
|
||||
#include <iomanip>
|
||||
#include "coord.hpp"
|
||||
|
||||
namespace mapnik
|
||||
|
@ -34,50 +35,52 @@ namespace mapnik
|
|||
template <class T> class MAPNIK_DECL Envelope
|
||||
{
|
||||
public:
|
||||
typedef Envelope<T> EnvelopeType;
|
||||
typedef Envelope<T> EnvelopeType;
|
||||
private:
|
||||
T minx_;
|
||||
T miny_;
|
||||
T maxx_;
|
||||
T maxy_;
|
||||
T minx_;
|
||||
T miny_;
|
||||
T maxx_;
|
||||
T maxy_;
|
||||
public:
|
||||
Envelope();
|
||||
Envelope(T minx,T miny,T maxx,T maxy);
|
||||
Envelope(const coord<T,2>& c0,const coord<T,2>& c1);
|
||||
Envelope(const EnvelopeType& rhs);
|
||||
T minx() const;
|
||||
T miny() const;
|
||||
T maxx() const;
|
||||
T maxy() const;
|
||||
T width() const;
|
||||
T height() const;
|
||||
void width(T w);
|
||||
void height(T h);
|
||||
coord<T,2> center() const;
|
||||
void expand_to_include(T x,T y);
|
||||
void expand_to_include(const coord<T,2>& c);
|
||||
void expand_to_include(const EnvelopeType& other);
|
||||
bool contains(const coord<T,2> &c) const;
|
||||
bool contains(T x,T y) const;
|
||||
bool contains(const EnvelopeType &other) const;
|
||||
bool intersects(const coord<T,2> &c) const;
|
||||
bool intersects(T x,T y) const;
|
||||
bool intersects(const EnvelopeType &other) const;
|
||||
EnvelopeType intersect(const EnvelopeType& other) const;
|
||||
bool operator==(const EnvelopeType &other) const;
|
||||
void re_center(T cx,T cy);
|
||||
void init(T x0,T y0,T x1,T y1);
|
||||
Envelope();
|
||||
Envelope(T minx,T miny,T maxx,T maxy);
|
||||
Envelope(const coord<T,2>& c0,const coord<T,2>& c1);
|
||||
Envelope(const EnvelopeType& rhs);
|
||||
T minx() const;
|
||||
T miny() const;
|
||||
T maxx() const;
|
||||
T maxy() const;
|
||||
T width() const;
|
||||
T height() const;
|
||||
void width(T w);
|
||||
void height(T h);
|
||||
coord<T,2> center() const;
|
||||
void expand_to_include(T x,T y);
|
||||
void expand_to_include(const coord<T,2>& c);
|
||||
void expand_to_include(const EnvelopeType& other);
|
||||
bool contains(const coord<T,2> &c) const;
|
||||
bool contains(T x,T y) const;
|
||||
bool contains(const EnvelopeType &other) const;
|
||||
bool intersects(const coord<T,2> &c) const;
|
||||
bool intersects(T x,T y) const;
|
||||
bool intersects(const EnvelopeType &other) const;
|
||||
EnvelopeType intersect(const EnvelopeType& other) const;
|
||||
bool operator==(const EnvelopeType &other) const;
|
||||
void re_center(T cx,T cy);
|
||||
void init(T x0,T y0,T x1,T y1);
|
||||
};
|
||||
|
||||
template <class charT,class traits,class T>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
const Envelope<T>& e)
|
||||
const Envelope<T>& e)
|
||||
{
|
||||
std::basic_ostringstream<charT,traits> s;
|
||||
s.copyfmt(out);
|
||||
s.width(0);
|
||||
s<<"Envelope("<<e.minx()<<","<<e.miny()<<","<<e.maxx()<<","<<e.maxy()<<")";
|
||||
s <<"Envelope(" << std::setprecision(16)
|
||||
<< e.minx() << "," << e.miny() <<","
|
||||
<< e.maxx() << "," << e.maxy() <<")";
|
||||
out << s.str();
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace mapnik
|
|||
{
|
||||
|
||||
template <typename T>
|
||||
bool clip_test(T p,T q,double& tmin,double& tmax)
|
||||
bool clip_test(T p,T q,double& tmin,double& tmax)
|
||||
{
|
||||
double r;
|
||||
bool result=true;
|
||||
|
@ -86,78 +86,80 @@ namespace mapnik
|
|||
template <typename Iter>
|
||||
inline bool point_inside_path(double x,double y,Iter start,Iter end)
|
||||
{
|
||||
bool inside=false;
|
||||
double x0=start->x;
|
||||
double y0=start->y;
|
||||
double x1,y1;
|
||||
while (++start!=end)
|
||||
{
|
||||
if (start->cmd == SEG_MOVETO)
|
||||
{
|
||||
x0=start->x;
|
||||
y0=start->y;
|
||||
continue;
|
||||
}
|
||||
x1=start->x;
|
||||
y1=start->y;
|
||||
if ((((y1 <= y) && (y < y0)) ||
|
||||
((y0 <= y) && (y < y1))) &&
|
||||
( x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
|
||||
inside=!inside;
|
||||
x0=x1;
|
||||
y0=y1;
|
||||
}
|
||||
bool inside=false;
|
||||
double x0=boost::get<0>(*start);
|
||||
double y0=boost::get<1>(*start);
|
||||
|
||||
double x1,y1;
|
||||
while (++start!=end)
|
||||
{
|
||||
if ( boost::get<2>(*start) == SEG_MOVETO)
|
||||
{
|
||||
x0 = boost::get<0>(*start);
|
||||
y0 = boost::get<1>(*start);
|
||||
continue;
|
||||
}
|
||||
x1=boost::get<0>(*start);
|
||||
y1=boost::get<1>(*start);
|
||||
|
||||
if ((((y1 <= y) && (y < y0)) ||
|
||||
((y0 <= y) && (y < y1))) &&
|
||||
( x < (x0 - x1) * (y - y1)/ (y0 - y1) + x1))
|
||||
inside=!inside;
|
||||
x0=x1;
|
||||
y0=y1;
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
||||
#define TOL 0.00001
|
||||
|
||||
/*
|
||||
/*
|
||||
(Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
|
||||
s = -----------------------------
|
||||
L^2
|
||||
*/
|
||||
s = -----------------------------
|
||||
L^2
|
||||
*/
|
||||
|
||||
inline bool point_in_circle(double x,double y,double cx,double cy,double r)
|
||||
{
|
||||
double dx = x - cx;
|
||||
double dy = y - cy;
|
||||
double d2 = dx * dx + dy * dy;
|
||||
return (d2 <= r * r);
|
||||
double dx = x - cx;
|
||||
double dy = y - cy;
|
||||
double d2 = dx * dx + dy * dy;
|
||||
return (d2 <= r * r);
|
||||
}
|
||||
|
||||
inline bool point_on_segment(double x,double y,double x0,double y0,double x1,double y1)
|
||||
{
|
||||
double dx = x1 - x0;
|
||||
double dy = y1 - y0;
|
||||
if ( fabs(dx) > TOL || fabs(dy) > TOL )
|
||||
{
|
||||
double s = (y0 - y) * dx - (x0 - x) * dy;
|
||||
return ( fabs (s) < TOL ) ;
|
||||
}
|
||||
return false;
|
||||
double dx = x1 - x0;
|
||||
double dy = y1 - y0;
|
||||
if ( fabs(dx) > TOL || fabs(dy) > TOL )
|
||||
{
|
||||
double s = (y0 - y) * dx - (x0 - x) * dy;
|
||||
return ( fabs (s) < TOL ) ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool point_on_segment2(double x,double y,double x0,double y0,double x1,double y1)
|
||||
{
|
||||
double d = sqrt ((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
|
||||
double d0 = sqrt ((x0 - x) * (x0 - x) + (y0 - y) * (y0 - y));
|
||||
double d1 = sqrt ((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y));
|
||||
double d2 = d0 + d1;
|
||||
return ( d2 - d < 0.01);
|
||||
double d = sqrt ((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
|
||||
double d0 = sqrt ((x0 - x) * (x0 - x) + (y0 - y) * (y0 - y));
|
||||
double d1 = sqrt ((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y));
|
||||
double d2 = d0 + d1;
|
||||
return ( d2 - d < 0.01);
|
||||
}
|
||||
|
||||
#undef TOL
|
||||
template <typename Iter>
|
||||
inline bool point_on_path(double x,double y,Iter start,Iter end)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Iter>
|
||||
inline bool point_on_points (double x,double y,Iter start,Iter end)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
struct filter_in_box
|
||||
|
|
|
@ -45,333 +45,334 @@ namespace mapnik
|
|||
class geometry : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
typedef T vertex_type;
|
||||
typedef typename vertex_type::type value_type;
|
||||
typedef T vertex_type;
|
||||
typedef typename vertex_type::type value_type;
|
||||
private:
|
||||
int srid_;
|
||||
int srid_;
|
||||
public:
|
||||
geometry (int srid=-1)
|
||||
: srid_(srid) {}
|
||||
geometry (int srid=-1)
|
||||
: srid_(srid) {}
|
||||
|
||||
int srid() const
|
||||
{
|
||||
return srid_;
|
||||
}
|
||||
int srid() const
|
||||
{
|
||||
return srid_;
|
||||
}
|
||||
|
||||
Envelope<double> envelope()
|
||||
{
|
||||
Envelope<double> result;
|
||||
double x,y;
|
||||
for (unsigned i=0;i<num_points();++i)
|
||||
{
|
||||
vertex(&x,&y);
|
||||
if (i==0)
|
||||
{
|
||||
result.init(x,y,x,y);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.expand_to_include(x,y);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Envelope<double> envelope()
|
||||
{
|
||||
Envelope<double> result;
|
||||
double x,y;
|
||||
for (unsigned i=0;i<num_points();++i)
|
||||
{
|
||||
vertex(&x,&y);
|
||||
if (i==0)
|
||||
{
|
||||
result.init(x,y,x,y);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.expand_to_include(x,y);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual int type() const=0;
|
||||
virtual bool hit_test(value_type x,value_type y) const=0;
|
||||
virtual void label_position(double *x, double *y) const=0;
|
||||
virtual void move_to(value_type x,value_type y)=0;
|
||||
virtual void line_to(value_type x,value_type y)=0;
|
||||
virtual void transform(const mapnik::CoordTransform& t)=0;
|
||||
virtual unsigned num_points() const = 0;
|
||||
virtual unsigned vertex(double* x, double* y)=0;
|
||||
virtual void rewind(unsigned )=0;
|
||||
virtual void set_capacity(size_t size)=0;
|
||||
virtual ~geometry() {}
|
||||
virtual int type() const=0;
|
||||
virtual bool hit_test(value_type x,value_type y) const=0;
|
||||
virtual void label_position(double *x, double *y) const=0;
|
||||
virtual void move_to(value_type x,value_type y)=0;
|
||||
virtual void line_to(value_type x,value_type y)=0;
|
||||
virtual void transform(const mapnik::CoordTransform& t)=0;
|
||||
virtual unsigned num_points() const = 0;
|
||||
virtual unsigned vertex(double* x, double* y)=0;
|
||||
virtual void rewind(unsigned )=0;
|
||||
virtual void set_capacity(size_t size)=0;
|
||||
virtual ~geometry() {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class point : public geometry<T>
|
||||
{
|
||||
typedef geometry<T> geometry_base;
|
||||
typedef typename geometry<T>::vertex_type vertex_type;
|
||||
typedef typename geometry<T>::value_type value_type;
|
||||
typedef geometry<T> geometry_base;
|
||||
typedef typename geometry<T>::vertex_type vertex_type;
|
||||
typedef typename geometry<T>::value_type value_type;
|
||||
private:
|
||||
vertex_type pt_;
|
||||
vertex_type pt_;
|
||||
public:
|
||||
point(int srid)
|
||||
: geometry<T>(srid)
|
||||
{}
|
||||
point(int srid)
|
||||
: geometry<T>(srid)
|
||||
{}
|
||||
|
||||
int type() const
|
||||
{
|
||||
return Point;
|
||||
}
|
||||
void label_position(double *x, double *y) const
|
||||
{
|
||||
*x = pt_.x;
|
||||
*y = pt_.y;
|
||||
}
|
||||
int type() const
|
||||
{
|
||||
return Point;
|
||||
}
|
||||
void label_position(double *x, double *y) const
|
||||
{
|
||||
*x = pt_.x;
|
||||
*y = pt_.y;
|
||||
}
|
||||
|
||||
void move_to(value_type x,value_type y)
|
||||
{
|
||||
pt_.x = x;
|
||||
pt_.y = y;
|
||||
}
|
||||
void move_to(value_type x,value_type y)
|
||||
{
|
||||
pt_.x = x;
|
||||
pt_.y = y;
|
||||
}
|
||||
|
||||
void line_to(value_type ,value_type ) {}
|
||||
void line_to(value_type ,value_type ) {}
|
||||
|
||||
void transform(const mapnik::CoordTransform& t)
|
||||
{
|
||||
t.forward_x(&pt_.x);
|
||||
t.forward_y(&pt_.y);
|
||||
}
|
||||
|
||||
unsigned num_points() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
*x = pt_.x;
|
||||
*y = pt_.y;
|
||||
return SEG_LINETO;
|
||||
}
|
||||
|
||||
void rewind(unsigned ) {}
|
||||
|
||||
bool hit_test(value_type x,value_type y) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void set_capacity(size_t) {}
|
||||
virtual ~point() {}
|
||||
};
|
||||
|
||||
template <typename T, template <typename> class Container=vertex_vector>
|
||||
class polygon : public geometry<T>
|
||||
{
|
||||
typedef geometry<T> geometry_base;
|
||||
typedef typename geometry<T>::vertex_type vertex_type;
|
||||
typedef typename geometry_base::value_type value_type;
|
||||
typedef Container<vertex_type> container_type;
|
||||
private:
|
||||
container_type cont_;
|
||||
mutable unsigned itr_;
|
||||
public:
|
||||
polygon(int srid)
|
||||
: geometry_base(srid),
|
||||
itr_(0)
|
||||
{}
|
||||
|
||||
int type() const
|
||||
{
|
||||
return Polygon;
|
||||
}
|
||||
|
||||
void label_position(double *x, double *y) const
|
||||
{
|
||||
|
||||
unsigned size = cont_.size();
|
||||
if (size < 3)
|
||||
{
|
||||
cont_.get_vertex(0,x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
double ai;
|
||||
double atmp = 0;
|
||||
double xtmp = 0;
|
||||
double ytmp = 0;
|
||||
double x0 =0;
|
||||
double y0 =0;
|
||||
double x1 =0;
|
||||
double y1 =0;
|
||||
|
||||
unsigned i,j;
|
||||
for (i = size-1,j = 0; j < size; i = j, ++j)
|
||||
{
|
||||
|
||||
cont_.get_vertex(i,&x0,&y0);
|
||||
cont_.get_vertex(j,&x1,&y1);
|
||||
ai = x0 * y1 - x1 * y0;
|
||||
atmp += ai;
|
||||
xtmp += (x1 + x0) * ai;
|
||||
ytmp += (y1 + y0) * ai;
|
||||
}
|
||||
if (atmp != 0)
|
||||
{
|
||||
*x = xtmp/(3*atmp);
|
||||
*y = ytmp /(3*atmp);
|
||||
return;
|
||||
}
|
||||
*x=x0;
|
||||
*y=y0;
|
||||
}
|
||||
|
||||
void line_to(value_type x,value_type y)
|
||||
{
|
||||
cont_.push_back(x,y,SEG_LINETO);
|
||||
}
|
||||
|
||||
void move_to(value_type x,value_type y)
|
||||
{
|
||||
cont_.push_back(x,y,SEG_MOVETO);
|
||||
}
|
||||
|
||||
void transform(mapnik::CoordTransform const& t)
|
||||
{
|
||||
unsigned size = cont_.size();
|
||||
for (unsigned pos=0; pos < size; ++pos)
|
||||
{
|
||||
cont_.transform_at(pos,t);
|
||||
}
|
||||
}
|
||||
void transform(const mapnik::CoordTransform& t)
|
||||
{
|
||||
t.forward_x(&pt_.x);
|
||||
t.forward_y(&pt_.y);
|
||||
}
|
||||
|
||||
unsigned num_points() const
|
||||
{
|
||||
return cont_.size();
|
||||
}
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return cont_.get_vertex(itr_++,x,y);
|
||||
}
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
*x = pt_.x;
|
||||
*y = pt_.y;
|
||||
return SEG_LINETO;
|
||||
}
|
||||
|
||||
void rewind(unsigned )
|
||||
{
|
||||
itr_=0;
|
||||
}
|
||||
void rewind(unsigned ) {}
|
||||
|
||||
bool hit_test(value_type x,value_type y) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void set_capacity(size_t size)
|
||||
{
|
||||
cont_.set_capacity(size);
|
||||
}
|
||||
virtual ~polygon() {}
|
||||
bool hit_test(value_type x,value_type y) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void set_capacity(size_t) {}
|
||||
virtual ~point() {}
|
||||
};
|
||||
|
||||
template <typename T, template <typename> class Container=vertex_vector2>
|
||||
class polygon : public geometry<T>
|
||||
{
|
||||
typedef geometry<T> geometry_base;
|
||||
typedef typename geometry<T>::vertex_type vertex_type;
|
||||
typedef typename geometry_base::value_type value_type;
|
||||
typedef Container<vertex_type> container_type;
|
||||
private:
|
||||
container_type cont_;
|
||||
mutable unsigned itr_;
|
||||
public:
|
||||
polygon(int srid)
|
||||
: geometry_base(srid),
|
||||
itr_(0)
|
||||
{}
|
||||
|
||||
int type() const
|
||||
{
|
||||
return Polygon;
|
||||
}
|
||||
|
||||
void label_position(double *x, double *y) const
|
||||
{
|
||||
|
||||
unsigned size = cont_.size();
|
||||
if (size < 3)
|
||||
{
|
||||
cont_.get_vertex(0,x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
double ai;
|
||||
double atmp = 0;
|
||||
double xtmp = 0;
|
||||
double ytmp = 0;
|
||||
double x0 =0;
|
||||
double y0 =0;
|
||||
double x1 =0;
|
||||
double y1 =0;
|
||||
|
||||
unsigned i,j;
|
||||
for (i = size-1,j = 0; j < size; i = j, ++j)
|
||||
{
|
||||
|
||||
cont_.get_vertex(i,&x0,&y0);
|
||||
cont_.get_vertex(j,&x1,&y1);
|
||||
ai = x0 * y1 - x1 * y0;
|
||||
atmp += ai;
|
||||
xtmp += (x1 + x0) * ai;
|
||||
ytmp += (y1 + y0) * ai;
|
||||
}
|
||||
if (atmp != 0)
|
||||
{
|
||||
*x = xtmp/(3*atmp);
|
||||
*y = ytmp /(3*atmp);
|
||||
return;
|
||||
}
|
||||
*x=x0;
|
||||
*y=y0;
|
||||
}
|
||||
|
||||
void line_to(value_type x,value_type y)
|
||||
{
|
||||
cont_.push_back(x,y,SEG_LINETO);
|
||||
}
|
||||
|
||||
void move_to(value_type x,value_type y)
|
||||
{
|
||||
cont_.push_back(x,y,SEG_MOVETO);
|
||||
}
|
||||
|
||||
void transform(mapnik::CoordTransform const& t)
|
||||
{
|
||||
unsigned size = cont_.size();
|
||||
for (unsigned pos=0; pos < size; ++pos)
|
||||
{
|
||||
cont_.transform_at(pos,t);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_points() const
|
||||
{
|
||||
return cont_.size();
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return cont_.get_vertex(itr_++,x,y);
|
||||
}
|
||||
|
||||
void rewind(unsigned )
|
||||
{
|
||||
itr_=0;
|
||||
}
|
||||
|
||||
bool hit_test(value_type x,value_type y) const
|
||||
{
|
||||
return point_inside_path(x,y,cont_.begin(),cont_.end());
|
||||
}
|
||||
|
||||
void set_capacity(size_t size)
|
||||
{
|
||||
cont_.set_capacity(size);
|
||||
}
|
||||
virtual ~polygon() {}
|
||||
};
|
||||
|
||||
template <typename T, template <typename> class Container=vertex_vector>
|
||||
class line_string : public geometry<T>
|
||||
{
|
||||
typedef geometry<T> geometry_base;
|
||||
typedef typename geometry_base::value_type value_type;
|
||||
typedef typename geometry<T>::vertex_type vertex_type;
|
||||
typedef Container<vertex_type> container_type;
|
||||
typedef geometry<T> geometry_base;
|
||||
typedef typename geometry_base::value_type value_type;
|
||||
typedef typename geometry<T>::vertex_type vertex_type;
|
||||
typedef Container<vertex_type> container_type;
|
||||
private:
|
||||
container_type cont_;
|
||||
mutable unsigned itr_;
|
||||
container_type cont_;
|
||||
mutable unsigned itr_;
|
||||
public:
|
||||
line_string(int srid)
|
||||
: geometry_base(srid),
|
||||
itr_(0)
|
||||
{}
|
||||
line_string(int srid)
|
||||
: geometry_base(srid),
|
||||
itr_(0)
|
||||
{}
|
||||
|
||||
int type() const
|
||||
{
|
||||
return LineString;
|
||||
}
|
||||
int type() const
|
||||
{
|
||||
return LineString;
|
||||
}
|
||||
void label_position(double *x, double *y) const
|
||||
{
|
||||
// calculate mid point on line string
|
||||
double x0=0;
|
||||
double y0=0;
|
||||
double x1=0;
|
||||
double y1=0;
|
||||
{
|
||||
// calculate mid point on line string
|
||||
double x0=0;
|
||||
double y0=0;
|
||||
double x1=0;
|
||||
double y1=0;
|
||||
|
||||
unsigned size = cont_.size();
|
||||
if (size == 1)
|
||||
{
|
||||
cont_.get_vertex(0,x,y);
|
||||
}
|
||||
else if (size == 2)
|
||||
{
|
||||
unsigned size = cont_.size();
|
||||
if (size == 1)
|
||||
{
|
||||
cont_.get_vertex(0,x,y);
|
||||
}
|
||||
else if (size == 2)
|
||||
{
|
||||
|
||||
cont_.get_vertex(0,&x0,&y0);
|
||||
cont_.get_vertex(1,&x1,&y1);
|
||||
*x = 0.5 * (x1 + x0);
|
||||
*y = 0.5 * (y1 + y0);
|
||||
}
|
||||
else
|
||||
{
|
||||
double len=0.0;
|
||||
for (unsigned pos = 1; pos < size; ++pos)
|
||||
{
|
||||
cont_.get_vertex(pos-1,&x0,&y0);
|
||||
cont_.get_vertex(pos,&x1,&y1);
|
||||
double dx = x1 - x0;
|
||||
double dy = y1 - y0;
|
||||
len += sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
double midlen = 0.5 * len;
|
||||
double dist = 0.0;
|
||||
for (unsigned pos = 1; pos < size;++pos)
|
||||
{
|
||||
cont_.get_vertex(pos-1,&x0,&y0);
|
||||
cont_.get_vertex(pos,&x1,&y1);
|
||||
double dx = x1 - x0;
|
||||
double dy = y1 - y0;
|
||||
double seg_len = sqrt(dx * dx + dy * dy);
|
||||
if (( dist + seg_len) >= midlen)
|
||||
{
|
||||
double r = (midlen - dist)/seg_len;
|
||||
*x = x0 + (x1 - x0) * r;
|
||||
*y = y0 + (y1 - y0) * r;
|
||||
break;
|
||||
}
|
||||
dist += seg_len;
|
||||
}
|
||||
}
|
||||
cont_.get_vertex(0,&x0,&y0);
|
||||
cont_.get_vertex(1,&x1,&y1);
|
||||
*x = 0.5 * (x1 + x0);
|
||||
*y = 0.5 * (y1 + y0);
|
||||
}
|
||||
else
|
||||
{
|
||||
double len=0.0;
|
||||
for (unsigned pos = 1; pos < size; ++pos)
|
||||
{
|
||||
cont_.get_vertex(pos-1,&x0,&y0);
|
||||
cont_.get_vertex(pos,&x1,&y1);
|
||||
double dx = x1 - x0;
|
||||
double dy = y1 - y0;
|
||||
len += sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
double midlen = 0.5 * len;
|
||||
double dist = 0.0;
|
||||
for (unsigned pos = 1; pos < size;++pos)
|
||||
{
|
||||
cont_.get_vertex(pos-1,&x0,&y0);
|
||||
cont_.get_vertex(pos,&x1,&y1);
|
||||
double dx = x1 - x0;
|
||||
double dy = y1 - y0;
|
||||
double seg_len = sqrt(dx * dx + dy * dy);
|
||||
if (( dist + seg_len) >= midlen)
|
||||
{
|
||||
double r = (midlen - dist)/seg_len;
|
||||
*x = x0 + (x1 - x0) * r;
|
||||
*y = y0 + (y1 - y0) * r;
|
||||
break;
|
||||
}
|
||||
dist += seg_len;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void line_to(value_type x,value_type y)
|
||||
{
|
||||
cont_.push_back(x,y,SEG_LINETO);
|
||||
}
|
||||
}
|
||||
void line_to(value_type x,value_type y)
|
||||
{
|
||||
cont_.push_back(x,y,SEG_LINETO);
|
||||
}
|
||||
|
||||
void move_to(value_type x,value_type y)
|
||||
{
|
||||
cont_.push_back(x,y,SEG_MOVETO);
|
||||
}
|
||||
void move_to(value_type x,value_type y)
|
||||
{
|
||||
cont_.push_back(x,y,SEG_MOVETO);
|
||||
}
|
||||
|
||||
void transform(mapnik::CoordTransform const& t)
|
||||
{
|
||||
unsigned size = cont_.size();
|
||||
for (unsigned pos=0; pos < size; ++pos)
|
||||
{
|
||||
cont_.transform_at(pos,t);
|
||||
}
|
||||
}
|
||||
void transform(mapnik::CoordTransform const& t)
|
||||
{
|
||||
unsigned size = cont_.size();
|
||||
for (unsigned pos=0; pos < size; ++pos)
|
||||
{
|
||||
cont_.transform_at(pos,t);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_points() const
|
||||
{
|
||||
return cont_.size();
|
||||
}
|
||||
{
|
||||
return cont_.size();
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return cont_.get_vertex(itr_++,x,y);
|
||||
}
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return cont_.get_vertex(itr_++,x,y);
|
||||
}
|
||||
|
||||
void rewind(unsigned )
|
||||
{
|
||||
itr_=0;
|
||||
}
|
||||
void rewind(unsigned )
|
||||
{
|
||||
itr_=0;
|
||||
}
|
||||
|
||||
bool hit_test(value_type x,value_type y) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool hit_test(value_type x,value_type y) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void set_capacity(size_t size)
|
||||
{
|
||||
cont_.set_capacity(size);
|
||||
}
|
||||
virtual ~line_string() {}
|
||||
void set_capacity(size_t size)
|
||||
{
|
||||
cont_.set_capacity(size);
|
||||
}
|
||||
virtual ~line_string() {}
|
||||
};
|
||||
|
||||
typedef point<vertex2d> point_impl;
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
* #include <boost/serialization/serialization.hpp>
|
||||
License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
//$Id: layer.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
||||
|
||||
#ifndef LAYER_HPP
|
||||
|
@ -28,27 +29,11 @@
|
|||
#include "feature.hpp"
|
||||
#include "datasource.hpp"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
class MAPNIK_DECL Layer
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
template <typename Archive>
|
||||
void serialize(Archive & ar, const unsigned int /*version*/)
|
||||
{
|
||||
ar & boost::serialization::make_nvp("name",name_)
|
||||
& boost::serialization::make_nvp("title",title_)
|
||||
& boost::serialization::make_nvp("abstract",abstract_)
|
||||
& boost::serialization::make_nvp("params",params_)
|
||||
& boost::serialization::make_nvp("min_zoom",minZoom_)
|
||||
& boost::serialization::make_nvp("max_zoom",maxZoom_)
|
||||
& boost::serialization::make_nvp("active",active_)
|
||||
& boost::serialization::make_nvp("selectable",selectable_)
|
||||
& boost::serialization::make_nvp("styles",styles_)
|
||||
;
|
||||
}
|
||||
parameters params_;
|
||||
std::string name_;
|
||||
std::string title_;
|
||||
|
@ -102,10 +87,4 @@ namespace mapnik
|
|||
};
|
||||
}
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(std::vector<std::string>, boost::serialization::object_serializable)
|
||||
BOOST_CLASS_TRACKING(std::vector<std::string>, boost::serialization::track_never)
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(mapnik::Layer, boost::serialization::object_serializable)
|
||||
BOOST_CLASS_TRACKING(mapnik::Layer, boost::serialization::track_never)
|
||||
|
||||
#endif //LAYER_HPP
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#ifndef MAP_HPP
|
||||
#define MAP_HPP
|
||||
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include "feature_type_style.hpp"
|
||||
|
||||
namespace mapnik
|
||||
|
@ -33,17 +31,7 @@ namespace mapnik
|
|||
class Layer;
|
||||
|
||||
class MAPNIK_DECL Map
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
template <typename Archive>
|
||||
void serialize(Archive & ar, const unsigned int /*version*/)
|
||||
{
|
||||
ar & boost::serialization::make_nvp("width",width_)
|
||||
& boost::serialization::make_nvp("height",height_)
|
||||
& boost::serialization::make_nvp("srid",srid_)
|
||||
& boost::serialization::make_nvp("layers",layers_);
|
||||
}
|
||||
|
||||
{
|
||||
static const unsigned MIN_MAPSIZE=16;
|
||||
static const unsigned MAX_MAPSIZE=2048;
|
||||
unsigned width_;
|
||||
|
@ -94,10 +82,4 @@ namespace mapnik
|
|||
};
|
||||
}
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(std::vector<mapnik::Layer>, boost::serialization::object_serializable)
|
||||
BOOST_CLASS_TRACKING(std::vector<mapnik::Layer>, boost::serialization::track_never)
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(mapnik::Map, boost::serialization::object_serializable)
|
||||
BOOST_CLASS_TRACKING(mapnik::Map, boost::serialization::track_never)
|
||||
|
||||
#endif //MAP_HPP
|
||||
|
|
|
@ -79,8 +79,6 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
void MAPNIK_DECL save_to_xml(Map const& map,const char* filename);
|
||||
void MAPNIK_DECL load_from_xml(Map & map, const char * filename);
|
||||
}
|
||||
|
||||
#endif //MAPNIK_HPP
|
||||
|
|
|
@ -44,36 +44,6 @@ namespace mapnik
|
|||
|
||||
class parameters : public param_map
|
||||
{
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template <typename Archive>
|
||||
void save(Archive & ar, const unsigned int /*version*/) const
|
||||
{
|
||||
const size_t size = param_map::size();
|
||||
ar & boost::serialization::make_nvp("count",size);
|
||||
param_map::const_iterator itr;
|
||||
for (itr=param_map::begin();itr!=param_map::end();++itr)
|
||||
{
|
||||
ar & boost::serialization::make_nvp("name",itr->first);
|
||||
ar & boost::serialization::make_nvp("value",itr->second);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Archive>
|
||||
void load(Archive & ar, const unsigned int /*version*/)
|
||||
{
|
||||
size_t size;
|
||||
ar & boost::serialization::make_nvp("size",size);
|
||||
for (size_t i=0;i<size;++i)
|
||||
{
|
||||
std::string name;
|
||||
std::string value;
|
||||
ar & boost::serialization::make_nvp("name",name);
|
||||
ar & boost::serialization::make_nvp("value",value);
|
||||
param_map::insert(make_pair(name,value));
|
||||
}
|
||||
}
|
||||
BOOST_SERIALIZATION_SPLIT_MEMBER()
|
||||
public:
|
||||
|
||||
parameters() {}
|
||||
|
@ -89,10 +59,4 @@ namespace mapnik
|
|||
};
|
||||
}
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(mapnik::parameter, boost::serialization::object_serializable)
|
||||
BOOST_CLASS_TRACKING(mapnik::parameter, boost::serialization::track_never)
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(mapnik::parameters, boost::serialization::object_serializable)
|
||||
BOOST_CLASS_TRACKING(mapnik::parameters, boost::serialization::track_never)
|
||||
|
||||
#endif //PARAMS_HPP
|
||||
|
|
|
@ -42,146 +42,157 @@ namespace mapnik
|
|||
template <typename T>
|
||||
class vertex_vector : private boost::noncopyable
|
||||
{
|
||||
typedef typename T::type value_type;
|
||||
typedef vertex<value_type,2> vertex_type;
|
||||
enum {
|
||||
block_shift = 8,
|
||||
block_size = 1<<block_shift,
|
||||
block_mask = block_size - 1,
|
||||
grow_by = 256
|
||||
};
|
||||
typedef typename T::type value_type;
|
||||
typedef vertex<value_type,2> vertex_type;
|
||||
enum {
|
||||
block_shift = 8,
|
||||
block_size = 1<<block_shift,
|
||||
block_mask = block_size - 1,
|
||||
grow_by = 256
|
||||
};
|
||||
|
||||
private:
|
||||
unsigned num_blocks_;
|
||||
unsigned max_blocks_;
|
||||
value_type** vertexs_;
|
||||
unsigned char** commands_;
|
||||
unsigned pos_;
|
||||
unsigned num_blocks_;
|
||||
unsigned max_blocks_;
|
||||
value_type** vertexs_;
|
||||
unsigned char** commands_;
|
||||
unsigned pos_;
|
||||
public:
|
||||
|
||||
vertex_vector()
|
||||
: num_blocks_(0),
|
||||
max_blocks_(0),
|
||||
vertexs_(0),
|
||||
commands_(0),
|
||||
pos_(0) {}
|
||||
vertex_vector()
|
||||
: num_blocks_(0),
|
||||
max_blocks_(0),
|
||||
vertexs_(0),
|
||||
commands_(0),
|
||||
pos_(0) {}
|
||||
|
||||
~vertex_vector()
|
||||
{
|
||||
if ( num_blocks_ )
|
||||
{
|
||||
value_type** vertexs=vertexs_ + num_blocks_ - 1;
|
||||
while ( num_blocks_-- )
|
||||
{
|
||||
delete [] *vertexs;
|
||||
--vertexs;
|
||||
}
|
||||
delete [] vertexs_;
|
||||
}
|
||||
}
|
||||
unsigned size() const
|
||||
{
|
||||
return pos_;
|
||||
}
|
||||
~vertex_vector()
|
||||
{
|
||||
if ( num_blocks_ )
|
||||
{
|
||||
value_type** vertexs=vertexs_ + num_blocks_ - 1;
|
||||
while ( num_blocks_-- )
|
||||
{
|
||||
delete [] *vertexs;
|
||||
--vertexs;
|
||||
}
|
||||
delete [] vertexs_;
|
||||
}
|
||||
}
|
||||
unsigned size() const
|
||||
{
|
||||
return pos_;
|
||||
}
|
||||
|
||||
void push_back (value_type x,value_type y,unsigned command)
|
||||
{
|
||||
unsigned block = pos_ >> block_shift;
|
||||
if (block >= num_blocks_)
|
||||
{
|
||||
allocate_block(block);
|
||||
}
|
||||
value_type* vertex = vertexs_[block] + ((pos_ & block_mask) << 1);
|
||||
unsigned char* cmd= commands_[block] + (pos_ & block_mask);
|
||||
void push_back (value_type x,value_type y,unsigned command)
|
||||
{
|
||||
unsigned block = pos_ >> block_shift;
|
||||
if (block >= num_blocks_)
|
||||
{
|
||||
allocate_block(block);
|
||||
}
|
||||
value_type* vertex = vertexs_[block] + ((pos_ & block_mask) << 1);
|
||||
unsigned char* cmd= commands_[block] + (pos_ & block_mask);
|
||||
|
||||
*cmd = static_cast<unsigned char>(command);
|
||||
*vertex++ = x;
|
||||
*vertex = y;
|
||||
++pos_;
|
||||
}
|
||||
unsigned get_vertex(unsigned pos,value_type* x,value_type* y) const
|
||||
{
|
||||
if (pos >= pos_) return SEG_END;
|
||||
unsigned block = pos >> block_shift;
|
||||
const value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1);
|
||||
*x = (*vertex++);
|
||||
*y = (*vertex);
|
||||
return commands_[block] [pos & block_mask];
|
||||
}
|
||||
*cmd = static_cast<unsigned char>(command);
|
||||
*vertex++ = x;
|
||||
*vertex = y;
|
||||
++pos_;
|
||||
}
|
||||
unsigned get_vertex(unsigned pos,value_type* x,value_type* y) const
|
||||
{
|
||||
if (pos >= pos_) return SEG_END;
|
||||
unsigned block = pos >> block_shift;
|
||||
const value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1);
|
||||
*x = (*vertex++);
|
||||
*y = (*vertex);
|
||||
return commands_[block] [pos & block_mask];
|
||||
}
|
||||
|
||||
void transform_at(unsigned pos,const CoordTransform& t)
|
||||
{
|
||||
if (pos >= pos_) return;
|
||||
unsigned block = pos >> block_shift;
|
||||
value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1);
|
||||
t.forward_x(vertex);
|
||||
++vertex;
|
||||
t.forward_y(vertex);
|
||||
}
|
||||
void set_capacity(size_t)
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
void transform_at(unsigned pos,const CoordTransform& t)
|
||||
{
|
||||
if (pos >= pos_) return;
|
||||
unsigned block = pos >> block_shift;
|
||||
value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1);
|
||||
t.forward_x(vertex);
|
||||
++vertex;
|
||||
t.forward_y(vertex);
|
||||
}
|
||||
void set_capacity(size_t)
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
private:
|
||||
void allocate_block(unsigned block)
|
||||
{
|
||||
if (block >= max_blocks_)
|
||||
{
|
||||
value_type** new_vertexs = new value_type* [(max_blocks_ + grow_by) * 2];
|
||||
unsigned char** new_commands = (unsigned char**)(new_vertexs + max_blocks_ + grow_by);
|
||||
if (vertexs_)
|
||||
{
|
||||
std::memcpy(new_vertexs,vertexs_,max_blocks_ * sizeof(value_type*));
|
||||
std::memcpy(new_commands,commands_,max_blocks_ * sizeof(unsigned char*));
|
||||
delete [] vertexs_;
|
||||
}
|
||||
vertexs_ = new_vertexs;
|
||||
commands_ = new_commands;
|
||||
max_blocks_ += grow_by;
|
||||
}
|
||||
vertexs_[block] = new value_type [block_size * 2 + block_size / (sizeof(value_type))];
|
||||
commands_[block] = (unsigned char*)(vertexs_[block] + block_size*2);
|
||||
++num_blocks_;
|
||||
}
|
||||
void allocate_block(unsigned block)
|
||||
{
|
||||
if (block >= max_blocks_)
|
||||
{
|
||||
value_type** new_vertexs = new value_type* [(max_blocks_ + grow_by) * 2];
|
||||
unsigned char** new_commands = (unsigned char**)(new_vertexs + max_blocks_ + grow_by);
|
||||
if (vertexs_)
|
||||
{
|
||||
std::memcpy(new_vertexs,vertexs_,max_blocks_ * sizeof(value_type*));
|
||||
std::memcpy(new_commands,commands_,max_blocks_ * sizeof(unsigned char*));
|
||||
delete [] vertexs_;
|
||||
}
|
||||
vertexs_ = new_vertexs;
|
||||
commands_ = new_commands;
|
||||
max_blocks_ += grow_by;
|
||||
}
|
||||
vertexs_[block] = new value_type [block_size * 2 + block_size / (sizeof(value_type))];
|
||||
commands_[block] = (unsigned char*)(vertexs_[block] + block_size*2);
|
||||
++num_blocks_;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct vertex_vector2 : boost::noncopyable
|
||||
{
|
||||
typedef typename T::type value_type;
|
||||
typedef boost::tuple<value_type,value_type,char> vertex_type;
|
||||
vertex_vector2() {}
|
||||
unsigned size() const
|
||||
{
|
||||
return cont_.size();
|
||||
}
|
||||
typedef typename T::type value_type;
|
||||
typedef boost::tuple<value_type,value_type,char> vertex_type;
|
||||
typedef typename std::vector<vertex_type>::const_iterator const_iterator;
|
||||
vertex_vector2() {}
|
||||
unsigned size() const
|
||||
{
|
||||
return cont_.size();
|
||||
}
|
||||
|
||||
void push_back (value_type x,value_type y,unsigned command)
|
||||
{
|
||||
cont_.push_back(vertex_type(x,y,command));
|
||||
}
|
||||
unsigned get_vertex(unsigned pos,value_type* x,value_type* y) const
|
||||
{
|
||||
if (pos >= cont_.size()) return SEG_END;
|
||||
vertex_type const& c = cont_[pos];
|
||||
*x = boost::get<0>(c);
|
||||
*y = boost::get<1>(c);
|
||||
return boost::get<2>(c);
|
||||
}
|
||||
|
||||
void transform_at(unsigned pos,const CoordTransform& t)
|
||||
{
|
||||
if (pos >= cont_.size()) return;
|
||||
vertex_type & c = cont_[pos];
|
||||
t.forward_x(&boost::get<0>(c));
|
||||
t.forward_y(&boost::get<1>(c));
|
||||
}
|
||||
void set_capacity(size_t size)
|
||||
{
|
||||
cont_.reserve(size);
|
||||
}
|
||||
void push_back (value_type x,value_type y,unsigned command)
|
||||
{
|
||||
cont_.push_back(vertex_type(x,y,command));
|
||||
}
|
||||
unsigned get_vertex(unsigned pos,value_type* x,value_type* y) const
|
||||
{
|
||||
if (pos >= cont_.size()) return SEG_END;
|
||||
vertex_type const& c = cont_[pos];
|
||||
*x = boost::get<0>(c);
|
||||
*y = boost::get<1>(c);
|
||||
return boost::get<2>(c);
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return cont_.begin();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return cont_.end();
|
||||
}
|
||||
|
||||
void transform_at(unsigned pos,const CoordTransform& t)
|
||||
{
|
||||
if (pos >= cont_.size()) return;
|
||||
vertex_type & c = cont_[pos];
|
||||
t.forward_x(&boost::get<0>(c));
|
||||
t.forward_y(&boost::get<1>(c));
|
||||
}
|
||||
void set_capacity(size_t size)
|
||||
{
|
||||
cont_.reserve(size);
|
||||
}
|
||||
private:
|
||||
std::vector<vertex_type> cont_;
|
||||
std::vector<vertex_type> cont_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -23,27 +23,10 @@
|
|||
//$Id$
|
||||
|
||||
#include <fstream>
|
||||
#include <boost/archive/xml_iarchive.hpp>
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
#include "mapnik.hpp"
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
void save_to_xml(Map const& m,const char* filename)
|
||||
{
|
||||
std::ofstream ofs(filename);
|
||||
assert(ofs.good());
|
||||
boost::archive::xml_oarchive oa(ofs);
|
||||
oa << boost::serialization::make_nvp("map",m);
|
||||
}
|
||||
|
||||
void load_from_xml(Map & m,const char* filename)
|
||||
{
|
||||
std::ifstream ifs(filename);
|
||||
assert(ifs.good());
|
||||
boost::archive::xml_iarchive ia(ifs);
|
||||
ia >> boost::serialization::make_nvp("map",m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue