geometry::multi_point - derive from std::vector<point<T>> instead of line_string<T>
This commit is contained in:
parent
fb385180cf
commit
2e0d83aa91
6 changed files with 33 additions and 13 deletions
|
@ -36,7 +36,14 @@
|
||||||
namespace mapnik { namespace geometry {
|
namespace mapnik { namespace geometry {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct multi_point : line_string<T> {};
|
struct multi_point : std::vector<point<T>>
|
||||||
|
{
|
||||||
|
multi_point() = default;
|
||||||
|
explicit multi_point(std::size_t size)
|
||||||
|
: std::vector<point<T> >(size) {}
|
||||||
|
inline std::size_t num_points() const { return std::vector<point<T>>::size(); }
|
||||||
|
inline void add_coord(T x, T y) { std::vector<point<T>>::template emplace_back(x,y);}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct multi_line_string : std::vector<line_string<T>> {};
|
struct multi_line_string : std::vector<line_string<T>> {};
|
||||||
|
|
|
@ -332,7 +332,11 @@ struct geom_reproj_visitor {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool operator() (multi_point<T> & mp) const
|
bool operator() (multi_point<T> & mp) const
|
||||||
{
|
{
|
||||||
return (*this) (static_cast<line_string<T> &>(mp));
|
if (proj_trans_.forward(mp) > 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -26,12 +26,13 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/util/noncopyable.hpp>
|
#include <mapnik/util/noncopyable.hpp>
|
||||||
|
// stl
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
namespace geometry {
|
namespace geometry {
|
||||||
template <typename T> struct point;
|
template <typename T> struct point;
|
||||||
template <typename T> struct line_string;
|
|
||||||
}
|
}
|
||||||
class projection;
|
class projection;
|
||||||
template <typename T> class box2d;
|
template <typename T> class box2d;
|
||||||
|
@ -50,8 +51,8 @@ public:
|
||||||
bool backward (double *x, double *y , double *z, int point_count, int offset = 1) const;
|
bool backward (double *x, double *y , double *z, int point_count, int offset = 1) const;
|
||||||
bool forward (geometry::point<double> & p) const;
|
bool forward (geometry::point<double> & p) const;
|
||||||
bool backward (geometry::point<double> & p) const;
|
bool backward (geometry::point<double> & p) const;
|
||||||
unsigned int forward (geometry::line_string<double> & ls) const;
|
unsigned int forward (std::vector<geometry::point<double>> & ls) const;
|
||||||
unsigned int backward (geometry::line_string<double> & ls) const;
|
unsigned int backward (std::vector<geometry::point<double>> & ls) const;
|
||||||
bool forward (box2d<double> & box) const;
|
bool forward (box2d<double> & box) const;
|
||||||
bool backward (box2d<double> & box) const;
|
bool backward (box2d<double> & box) const;
|
||||||
bool forward (box2d<double> & box, int points) const;
|
bool forward (box2d<double> & box, int points) const;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/global.hpp> // for M_PI on windows
|
#include <mapnik/global.hpp> // for M_PI on windows
|
||||||
#include <mapnik/enumeration.hpp>
|
#include <mapnik/enumeration.hpp>
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry/point.hpp>
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#include <mapnik/warning_ignore.hpp>
|
#include <mapnik/warning_ignore.hpp>
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
|
@ -93,9 +94,9 @@ static inline bool merc2lonlat(double * x, double * y , int point_count)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool lonlat2merc(geometry::line_string<double> & ls)
|
static inline bool lonlat2merc(std::vector<geometry::point<double>> & ls)
|
||||||
{
|
{
|
||||||
for(auto & p : ls)
|
for (auto& p : ls)
|
||||||
{
|
{
|
||||||
if (p.x > 180) p.x = 180;
|
if (p.x > 180) p.x = 180;
|
||||||
else if (p.x < -180) p.x = -180;
|
else if (p.x < -180) p.x = -180;
|
||||||
|
@ -108,7 +109,7 @@ static inline bool lonlat2merc(geometry::line_string<double> & ls)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool merc2lonlat(geometry::line_string<double> & ls)
|
static inline bool merc2lonlat(std::vector<geometry::point<double>> & ls)
|
||||||
{
|
{
|
||||||
for (auto & p : ls)
|
for (auto & p : ls)
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,7 +102,7 @@ bool proj_transform::forward (geometry::point<double> & p) const
|
||||||
return forward(&(p.x), &(p.y), &z, 1);
|
return forward(&(p.x), &(p.y), &z, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int proj_transform::forward (geometry::line_string<double> & ls) const
|
unsigned int proj_transform::forward (std::vector<geometry::point<double>> & ls) const
|
||||||
{
|
{
|
||||||
std::size_t size = ls.size();
|
std::size_t size = ls.size();
|
||||||
if (size == 0) return 0;
|
if (size == 0) return 0;
|
||||||
|
@ -242,7 +242,7 @@ bool proj_transform::backward (geometry::point<double> & p) const
|
||||||
return backward(&(p.x), &(p.y), &z, 1);
|
return backward(&(p.x), &(p.y), &z, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int proj_transform::backward (geometry::line_string<double> & ls) const
|
unsigned int proj_transform::backward (std::vector<geometry::point<double>> & ls) const
|
||||||
{
|
{
|
||||||
std::size_t size = ls.size();
|
std::size_t size = ls.size();
|
||||||
if (size == 0) return 0;
|
if (size == 0) return 0;
|
||||||
|
|
|
@ -119,7 +119,7 @@ struct geometry_equal_visitor
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void operator() (line_string<T> const& ls1, line_string<T> const& ls2) const
|
void operator() (std::vector<point<T>> const& ls1, std::vector<point<T>> const& ls2) const
|
||||||
{
|
{
|
||||||
if (ls1.size() != ls2.size())
|
if (ls1.size() != ls2.size())
|
||||||
{
|
{
|
||||||
|
@ -149,12 +149,19 @@ struct geometry_equal_visitor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void operator() (line_string<T> const& ls1, line_string<T> const& ls2) const
|
||||||
|
{
|
||||||
|
(*this)(static_cast<std::vector<point<T>> const&>(ls1), static_cast<std::vector<point<T>> const&>(ls2));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void operator() (multi_point<T> const& mp1, multi_point<T> const& mp2) const
|
void operator() (multi_point<T> const& mp1, multi_point<T> const& mp2) const
|
||||||
{
|
{
|
||||||
(*this)(static_cast<line_string<T> const&>(mp1), static_cast<line_string<T> const&>(mp2));
|
(*this)(static_cast<std::vector<point<T>> const&>(mp1), static_cast<std::vector<point<T>> const&>(mp2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void operator() (multi_line_string<T> const& mls1, multi_line_string<T> const& mls2) const
|
void operator() (multi_line_string<T> const& mls1, multi_line_string<T> const& mls2) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue