Compare commits

...

32 commits

Author SHA1 Message Date
artemp
b565897546 Merge branch 'master' into issue-3242 2016-06-23 09:47:47 +01:00
artemp
e5e36fc3ce Merge branch 'master' into issue-3242 2016-06-22 17:35:48 +01:00
artemp
66ab20cf67 Merge branch 'master' into issue-3242 2016-06-22 17:26:02 +01:00
artemp
8ba78dcded remove <coord.hpp> 2016-06-21 10:01:31 +01:00
artemp
0460aa51ae add <algorithm> 2016-06-20 16:42:48 +01:00
artemp
beea072ec4 add <stdexcept> 2016-06-20 16:29:47 +01:00
artemp
e86a59223b only include what you need 2016-06-20 15:24:30 +01:00
artemp
44fc27a346 Merge branch 'geometry-refactor' into issue-3242 2016-06-20 15:03:09 +01:00
artemp
67d2a0e141 Merge branch 'master' into geometry-refactor 2016-06-20 15:01:29 +01:00
artemp
ac8c5e3669 pixel_position - derive from geometry::point<double> 2016-06-20 14:38:58 +01:00
artemp
10d9496d55 remove unused header 2016-06-20 14:38:38 +01:00
artemp
1879c3d8d8 add <limits> and fix compilation on linux/win 2016-06-20 12:51:26 +01:00
artemp
bc24a767d6 box2d<T> - move most methods implementations to box2d.hpp and let compiler do inlining as it wishes (ref #3242) 2016-06-20 11:15:07 +01:00
artemp
e11d81abdd revert auto clang-format header re-ordering ref b669115b2c (commitcomment-17917710) 2016-06-20 10:12:10 +01:00
artemp
173f7d037c remove boost::operators dependency + add standalobe implementions of required operators 2016-06-17 14:34:28 +02:00
artemp
f7125ac1be update visual-data 2016-06-17 13:34:01 +02:00
artemp
5d4a12f744 update geometry_adapters 2016-06-17 13:33:09 +02:00
artemp
b669115b2c remove coord<T, int> usage from box2d<T> 2016-06-17 12:46:33 +02:00
artemp
80176a6c83 fix `geometry_type' call 2016-04-29 18:09:32 +02:00
artemp
c4fcee7b66 add geometry dir 2016-04-29 17:08:17 +02:00
artemp
3184034414 refactor geometry core and algorithms templates + add missing typedefs + prepare for geometry update 2016-04-29 14:24:57 +02:00
artemp
de927a1571 Merge branch 'master' into geometry-refactor 2016-04-29 10:47:43 +02:00
artemp
a89c3fc007 c++ - make bbox standalone method 2016-04-22 12:51:20 +02:00
artemp
51069fe88a c++ style : prefix increment 2016-04-22 12:50:32 +02:00
artemp
4e57f7b115 Merge branch 'master' into geometry-refactor 2016-04-20 16:45:08 +02:00
artemp
633a2c1e07 Merge branch 'master' into geometry-refactor 2016-04-18 16:15:04 +02:00
artemp
9caac23d3c remove bogus fwd decl 2016-04-12 14:56:32 +02:00
artemp
271b70f960 geometry - template on container type + move multi geometries into separate headers 2016-04-12 14:49:23 +02:00
artemp
2106d7b162 remove debug stderr 2016-04-12 14:48:24 +02:00
artemp
2e0d83aa91 geometry::multi_point - derive from std::vector<point<T>> instead of line_string<T> 2016-04-12 10:12:16 +02:00
artemp
fb385180cf include what you need 2016-04-12 09:27:37 +02:00
artemp
0f711c0863 geometry - move point/line_string/polygon into separate headers 2016-04-12 09:17:53 +02:00
99 changed files with 965 additions and 1099 deletions

View file

@ -2,7 +2,6 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/vertex.hpp>
#include <mapnik/offset_converter.hpp>

View file

@ -45,7 +45,7 @@ using mapnik::image_rgba8;
using mapnik::Map;
using mapnik::layer;
using mapnik::box2d;
using mapnik::coord2d;
using mapnik::geometry::point;
using mapnik::feature_ptr;
using mapnik::view_transform;
using mapnik::projection;
@ -465,7 +465,7 @@ void MapWidget::zoomToLevel(int level)
mapnik::box2d<double> ext = map_->get_current_extent();
double width = static_cast<double>(map_->width());
double height= static_cast<double>(map_->height());
mapnik::coord2d pt = ext.center();
mapnik::geometry::point<double> pt = ext.center();
double res = scale_denom * 0.00028;

View file

@ -27,6 +27,7 @@ Import('env')
base = './mapnik/'
subdirs = [
'',
'geometry',
'csv',
'svg',
'wkt',

View file

@ -25,13 +25,12 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/coord.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/operators.hpp>
#pragma GCC diagnostic pop
#include <mapnik/geometry/point.hpp>
// stl
#include <limits>
#include <string>
#include <algorithm>
#include <stdexcept>
// agg
// forward declare so that apps using mapnik do not need agg headers
namespace agg {
@ -43,10 +42,6 @@ namespace mapnik {
// A spatial envelope (i.e. bounding box) which also defines some basic operators.
template <typename T> class MAPNIK_DECL box2d
: boost::equality_comparable<box2d<T> ,
boost::addable<box2d<T>,
boost::dividable2<box2d<T>, T,
boost::multipliable2<box2d<T>, T > > > >
{
public:
using value_type = T;
@ -66,64 +61,316 @@ private:
}
public:
box2d();
box2d(T minx,T miny,T maxx,T maxy);
box2d(coord<T,2> const& c0, coord<T,2> const& c1);
box2d(box2d_type const& rhs);
box2d()
: minx_(std::numeric_limits<T>::max()),
miny_(std::numeric_limits<T>::max()),
maxx_(-std::numeric_limits<T>::max()),
maxy_(-std::numeric_limits<T>::max()) {}
box2d(T minx,T miny,T maxx,T maxy)
{
init(minx, miny, maxx, maxy);
}
box2d(geometry::point<T> const& c0, geometry::point<T> const& c1)
{
init(c0.x,c0.y,c1.x,c1.y);
}
// move ctor
box2d(box2d_type&& rhs)
: minx_(std::move(rhs.minx_)),
miny_(std::move(rhs.miny_)),
maxx_(std::move(rhs.maxx_)),
maxy_(std::move(rhs.maxy_)) {}
// copy ctor
box2d(box2d_type const& rhs)
: minx_(rhs.minx_),
miny_(rhs.miny_),
maxx_(rhs.maxx_),
maxy_(rhs.maxy_) {}
box2d(box2d_type const& rhs, agg::trans_affine const& tr);
// move
box2d(box2d_type&& rhs);
// converting ctor
template <typename T1>
explicit box2d(box2d<T1> other)
: minx_(static_cast<value_type>(other.minx())),
: minx_(static_cast<value_type>(other.minx())),
miny_(static_cast<value_type>(other.miny())),
maxx_(static_cast<value_type>(other.maxx())),
maxy_(static_cast<value_type>(other.maxy()))
{}
box2d_type& operator=(box2d_type other);
T minx() const;
T miny() const;
T maxx() const;
T maxy() const;
void set_minx(T v);
void set_miny(T v);
void set_maxx(T v);
void set_maxy(T v);
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(coord<T,2> const& c);
void expand_to_include(box2d_type const& other);
bool contains(coord<T,2> const& c) const;
bool contains(T x,T y) const;
bool contains(box2d_type const& other) const;
bool intersects(coord<T,2> const& c) const;
bool intersects(T x,T y) const;
bool intersects(box2d_type const& other) const;
box2d_type intersect(box2d_type const& other) const;
bool operator==(box2d_type const& other) const;
void re_center(T cx,T cy);
void re_center(coord<T,2> const& c);
void init(T x0,T y0,T x1,T y1);
void init(T x, T y);
void clip(box2d_type const& other);
void pad(T padding);
box2d_type& operator=(box2d_type other)
{
swap(*this, other);
return *this;
}
T minx() const {return minx_;}
T miny() const {return miny_;}
T maxx() const {return maxx_;}
T maxy() const {return maxy_;}
void set_minx(T v) { minx_ = v;}
void set_miny(T v) { miny_ = v;}
void set_maxx(T v) { maxx_ = v;}
void set_maxy(T v) { maxy_ = v;}
T width() const {return maxx_ - minx_;}
T height() const {return maxy_ - miny_;}
void width(T w)
{
T cx = center().x;
minx_ = static_cast<T>(cx - w * 0.5);
maxx_ = static_cast<T>(cx + w * 0.5);
}
void height(T h)
{
T cy = center().y;
miny_ = static_cast<T>(cy - h * 0.5);
maxy_ = static_cast<T>(cy + h * 0.5);
}
geometry::point<T> center() const
{
return geometry::point<T>(static_cast<T>(0.5 * (minx_ + maxx_)),
static_cast<T>(0.5 * (miny_ + maxy_)));
}
void expand_to_include(T x,T y)
{
if (x < minx_) minx_ = x;
if (x > maxx_) maxx_ = x;
if (y < miny_) miny_ = y;
if (y > maxy_) maxy_ = y;
}
void expand_to_include(geometry::point<T> const& c)
{
expand_to_include(c.x,c.y);
}
void expand_to_include(box2d_type const& other)
{
if (other.minx_ < minx_) minx_ = other.minx_;
if (other.maxx_ > maxx_) maxx_ = other.maxx_;
if (other.miny_ < miny_) miny_ = other.miny_;
if (other.maxy_ > maxy_) maxy_ = other.maxy_;
}
bool contains(T x,T y) const
{
return x >= minx_ && x <= maxx_ && y >= miny_ && y <= maxy_;
}
bool contains(geometry::point<T> const& c) const
{
return contains(c.x,c.y);
}
bool contains(box2d_type const& other) const
{
return other.minx_ >= minx_ &&
other.maxx_ <= maxx_ &&
other.miny_ >= miny_ &&
other.maxy_ <= maxy_;
}
bool intersects(T x,T y) const
{
return !(x > maxx_ || x < minx_ || y > maxy_ || y < miny_);
}
bool intersects(geometry::point<T> const& c) const
{
return intersects(c.x,c.y);
}
bool intersects(box2d_type const& other) const
{
return !(other.minx_ > maxx_ || other.maxx_ < minx_ ||
other.miny_ > maxy_ || other.maxy_ < miny_);
}
box2d_type intersect(box2d_type const& other) const
{
if (intersects(other))
{
T x0 = std::max(minx_, other.minx_);
T y0 = std::max(miny_, other.miny_);
T x1 = std::min(maxx_, other.maxx_);
T y1 = std::min(maxy_, other.maxy_);
return box2d<T>(x0, y0, x1, y1);
}
else
{
return box2d<T>();
}
}
bool operator==(box2d_type const& other) const
{
return minx_ == other.minx_ &&
miny_ == other.miny_ &&
maxx_ == other.maxx_ &&
maxy_ == other.maxy_;
}
bool operator!=(box2d_type const& other) const
{
return !(*this == other);
}
void re_center(T cx,T cy)
{
T dx = cx - center().x;
T dy = cy - center().y;
minx_ += dx;
miny_ += dy;
maxx_ += dx;
maxy_ += dy;
}
void re_center(geometry::point<T> const& c)
{
re_center(c.x,c.y);
}
void init(T x0,T y0,T x1,T y1)
{
if (x0 < x1)
{
minx_ = x0;
maxx_ = x1;
}
else
{
minx_ = x1;
maxx_ = x0;
}
if (y0 < y1)
{
miny_ = y0;
maxy_ = y1;
}
else
{
miny_ = y1;
maxy_ = y0;
}
}
void init(T x, T y)
{
init(x, y, x, y);
}
void clip(box2d_type const& other)
{
minx_ = std::max(minx_, other.minx());
miny_ = std::max(miny_, other.miny());
maxx_ = std::min(maxx_, other.maxx());
maxy_ = std::min(maxy_, other.maxy());
}
void pad(T padding)
{
minx_ -= padding;
miny_ -= padding;
maxx_ += padding;
maxy_ += padding;
}
bool valid() const
{
return (minx_ <= maxx_ && miny_ <= maxy_);
}
void move(T x, T y)
{
minx_ += x;
maxx_ += x;
miny_ += y;
maxy_ += y;
}
// to/from std::string
bool from_string(std::string const& str);
bool valid() const;
void move(T x, T y);
std::string to_string() const;
// define some operators
box2d_type& operator+=(box2d_type const& other);
box2d_type& operator*=(T);
box2d_type& operator/=(T);
T operator[](int index) const;
box2d_type operator +(T other) const; //enlarge box by given amount
box2d_type& operator +=(T other); //enlarge box by given amount
// operators
box2d_type& operator+=(box2d_type const& other)
{
expand_to_include(other);
return *this;
}
box2d_type& operator*=(T val)
{
geometry::point<T> c = center();
T sx = static_cast<T>(0.5 * width() * val);
T sy = static_cast<T>(0.5 * height() * val);
minx_ = c.x - sx;
maxx_ = c.x + sx;
miny_ = c.y - sy;
maxy_ = c.y + sy;
return *this;
}
box2d_type operator*(T val) const
{
box2d<T> temp(*this);
return temp *= val;
}
box2d_type& operator/=(T val)
{
geometry::point<T> c = center();
T sx = static_cast<T>(0.5 * width() / val);
T sy = static_cast<T>(0.5 * height() / val);
minx_ = c.x - sx;
maxx_ = c.x + sx;
miny_ = c.y - sy;
maxy_ = c.y + sy;
return *this;
}
T operator[](int index) const
{
switch (index)
{
case 0:
return minx_;
case 1:
return miny_;
case 2:
return maxx_;
case 3:
return maxy_;
case -4:
return minx_;
case -3:
return miny_;
case -2:
return maxx_;
case -1:
return maxy_;
default:
throw std::out_of_range("index out of range, max value is 3, min value is -4 ");
}
}
box2d_type operator +(T val) const //enlarge box by given amount
{
return box2d<T>(minx_ - val, miny_ - val, maxx_ + val, maxy_ + val);
}
box2d_type& operator +=(T val) //enlarge box by given amount
{
minx_ -= val;
miny_ -= val;
maxx_ += val;
maxy_ += val;
return *this;
}
// compute the bounding box of this one transformed
box2d_type operator* (agg::trans_affine const& tr) const;

View file

@ -25,9 +25,9 @@
#include <mapnik/safe_cast.hpp>
// stl
#include <stdexcept>
#include <sstream>
#include <iomanip>
#include <sstream>
#include <stdexcept>
#include <mapnik/config.hpp>
@ -49,47 +49,7 @@ BOOST_FUSION_ADAPT_TPL_ADT(
(T, T, obj.maxx(), obj.set_maxx(mapnik::safe_cast<T>(val)))
(T, T, obj.maxy(), obj.set_maxy(mapnik::safe_cast<T>(val))))
namespace mapnik
{
template <typename T>
box2d<T>::box2d()
:minx_( std::numeric_limits<T>::max()),
miny_( std::numeric_limits<T>::max()),
maxx_(-std::numeric_limits<T>::max()),
maxy_(-std::numeric_limits<T>::max()) {}
template <typename T>
box2d<T>::box2d(T minx,T miny,T maxx,T maxy)
{
init(minx,miny,maxx,maxy);
}
template <typename T>
box2d<T>::box2d(coord<T,2> const& c0, coord<T,2> const& c1)
{
init(c0.x,c0.y,c1.x,c1.y);
}
template <typename T>
box2d<T>::box2d(box2d_type const& rhs)
: minx_(rhs.minx_),
miny_(rhs.miny_),
maxx_(rhs.maxx_),
maxy_(rhs.maxy_) {}
template <typename T>
box2d<T>::box2d(box2d_type && rhs)
: minx_(std::move(rhs.minx_)),
miny_(std::move(rhs.miny_)),
maxx_(std::move(rhs.maxx_)),
maxy_(std::move(rhs.maxy_)) {}
template <typename T>
box2d<T>& box2d<T>::operator=(box2d_type other)
{
swap(*this, other);
return *this;
}
namespace mapnik {
template <typename T>
box2d<T>::box2d(box2d_type const& rhs, agg::trans_affine const& tr)
@ -108,245 +68,6 @@ box2d<T>::box2d(box2d_type const& rhs, agg::trans_affine const& tr)
expand_to_include(static_cast<T>(x3), static_cast<T>(y3));
}
template <typename T>
bool box2d<T>::operator==(box2d<T> const& other) const
{
return minx_==other.minx_ &&
miny_==other.miny_ &&
maxx_==other.maxx_ &&
maxy_==other.maxy_;
}
template <typename T>
T box2d<T>::minx() const
{
return minx_;
}
template <typename T>
T box2d<T>::maxx() const
{
return maxx_;
}
template <typename T>
T box2d<T>::miny() const
{
return miny_;
}
template <typename T>
T box2d<T>::maxy() const
{
return maxy_;
}
template<typename T>
void box2d<T>::set_minx(T v)
{
minx_ = v;
}
template<typename T>
void box2d<T>::set_miny(T v)
{
miny_ = v;
}
template<typename T>
void box2d<T>::set_maxx(T v)
{
maxx_ = v;
}
template<typename T>
void box2d<T>::set_maxy(T v)
{
maxy_ = v;
}
template <typename T>
T box2d<T>::width() const
{
return maxx_-minx_;
}
template <typename T>
T box2d<T>::height() const
{
return maxy_-miny_;
}
template <typename T>
void box2d<T>::width(T w)
{
T cx=center().x;
minx_=static_cast<T>(cx-w*0.5);
maxx_=static_cast<T>(cx+w*0.5);
}
template <typename T>
void box2d<T>::height(T h)
{
T cy=center().y;
miny_=static_cast<T>(cy-h*0.5);
maxy_=static_cast<T>(cy+h*0.5);
}
template <typename T>
coord<T,2> box2d<T>::center() const
{
return coord<T,2>(static_cast<T>(0.5*(minx_+maxx_)),
static_cast<T>(0.5*(miny_+maxy_)));
}
template <typename T>
void box2d<T>::expand_to_include(coord<T,2> const& c)
{
expand_to_include(c.x,c.y);
}
template <typename T>
void box2d<T>::expand_to_include(T x,T y)
{
if (x<minx_) minx_=x;
if (x>maxx_) maxx_=x;
if (y<miny_) miny_=y;
if (y>maxy_) maxy_=y;
}
template <typename T>
void box2d<T>::expand_to_include(box2d<T> const& other)
{
if (other.minx_<minx_) minx_=other.minx_;
if (other.maxx_>maxx_) maxx_=other.maxx_;
if (other.miny_<miny_) miny_=other.miny_;
if (other.maxy_>maxy_) maxy_=other.maxy_;
}
template <typename T>
bool box2d<T>::contains(coord<T,2> const& c) const
{
return contains(c.x,c.y);
}
template <typename T>
bool box2d<T>::contains(T x,T y) const
{
return x>=minx_ && x<=maxx_ && y>=miny_ && y<=maxy_;
}
template <typename T>
bool box2d<T>::contains(box2d<T> const& other) const
{
return other.minx_>=minx_ &&
other.maxx_<=maxx_ &&
other.miny_>=miny_ &&
other.maxy_<=maxy_;
}
template <typename T>
bool box2d<T>::intersects(coord<T,2> const& c) const
{
return intersects(c.x,c.y);
}
template <typename T>
bool box2d<T>::intersects(T x,T y) const
{
return !(x>maxx_ || x<minx_ || y>maxy_ || y<miny_);
}
template <typename T>
bool box2d<T>::intersects(box2d<T> const& other) const
{
return !(other.minx_>maxx_ || other.maxx_<minx_ ||
other.miny_>maxy_ || other.maxy_<miny_);
}
template <typename T>
box2d<T> box2d<T>::intersect(box2d_type const& other) const
{
if (intersects(other))
{
T x0=std::max(minx_,other.minx_);
T y0=std::max(miny_,other.miny_);
T x1=std::min(maxx_,other.maxx_);
T y1=std::min(maxy_,other.maxy_);
return box2d<T>(x0,y0,x1,y1);
}
else
{
return box2d<T>();
}
}
template <typename T>
void box2d<T>::re_center(T cx,T cy)
{
T dx=cx-center().x;
T dy=cy-center().y;
minx_+=dx;
miny_+=dy;
maxx_+=dx;
maxy_+=dy;
}
template <typename T>
void box2d<T>::re_center(coord<T,2> const& c)
{
re_center(c.x,c.y);
}
template <typename T>
void box2d<T>::init(T x0, T y0, T x1, T y1)
{
if (x0 < x1)
{
minx_ = x0;
maxx_ = x1;
}
else
{
minx_ = x1;
maxx_ = x0;
}
if (y0 < y1)
{
miny_ = y0;
maxy_ = y1;
}
else
{
miny_ = y1;
maxy_ = y0;
}
}
template <typename T>
void box2d<T>::init(T x, T y)
{
init(x, y, x, y);
}
template <typename T>
void box2d<T>::clip(box2d_type const& other)
{
minx_ = std::max(minx_, other.minx());
miny_ = std::max(miny_, other.miny());
maxx_ = std::min(maxx_, other.maxx());
maxy_ = std::min(maxy_, other.maxy());
}
template <typename T>
void box2d<T>::pad(T padding)
{
minx_ -= padding;
miny_ -= padding;
maxx_ += padding;
maxy_ += padding;
}
template <typename T>
bool box2d<T>::from_string(std::string const& str)
{
@ -361,21 +82,6 @@ bool box2d<T>::from_string(std::string const& str)
return r;
}
template <typename T>
bool box2d<T>::valid() const
{
return (minx_ <= maxx_ && miny_ <= maxy_) ;
}
template <typename T>
void box2d<T>::move(T x, T y)
{
minx_ += x;
maxx_ += x;
miny_ += y;
maxy_ += y;
}
template <typename T>
std::string box2d<T>::to_string() const
{
@ -393,83 +99,6 @@ std::string box2d<T>::to_string() const
return s.str();
}
template <typename T>
box2d<T>& box2d<T>::operator+=(box2d<T> const& other)
{
expand_to_include(other);
return *this;
}
template <typename T>
box2d<T> box2d<T>::operator+ (T other) const
{
return box2d<T>(minx_ - other, miny_ - other, maxx_ + other, maxy_ + other);
}
template <typename T>
box2d<T>& box2d<T>::operator+= (T other)
{
minx_ -= other;
miny_ -= other;
maxx_ += other;
maxy_ += other;
return *this;
}
template <typename T>
box2d<T>& box2d<T>::operator*=(T t)
{
coord<T,2> c = center();
T sx = static_cast<T>(0.5 * width() * t);
T sy = static_cast<T>(0.5 * height() * t);
minx_ = c.x - sx;
maxx_ = c.x + sx;
miny_ = c.y - sy;
maxy_ = c.y + sy;
return *this;
}
template <typename T>
box2d<T>& box2d<T>::operator/=(T t)
{
coord<T,2> c = center();
T sx = static_cast<T>(0.5 * width() / t);
T sy = static_cast<T>(0.5 * height() / t);
minx_ = c.x - sx;
maxx_ = c.x + sx;
miny_ = c.y - sy;
maxy_ = c.y + sy;
return *this;
}
template <typename T>
T box2d<T>::operator[] (int index) const
{
switch(index)
{
case 0:
return minx_;
case 1:
return miny_;
case 2:
return maxx_;
case 3:
return maxy_;
case -4:
return minx_;
case -3:
return miny_;
case -2:
return maxx_;
case -1:
return maxy_;
default:
throw std::out_of_range("index out of range, max value is 3, min value is -4 ");
}
}
template <typename T>
box2d<T> box2d<T>::operator*(agg::trans_affine const& tr) const
{

View file

@ -1,188 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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
*
*****************************************************************************/
#ifndef MAPNIK_COORD_HPP
#define MAPNIK_COORD_HPP
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/operators.hpp>
#pragma GCC diagnostic pop
namespace mapnik {
template <typename T,int dim>
struct coord {
using type = T;
};
template <typename T>
struct coord<T,2>
: boost::addable<coord<T,2>,
boost::addable2<coord<T,2>,T,
boost::subtractable<coord<T,2>,
boost::subtractable2<coord<T,2>,T,
boost::dividable2<coord<T,2>, T,
boost::multipliable2<coord<T,2>, T > > > > > >
{
using type = T;
T x;
T y;
public:
coord()
: x(),y() {}
coord(T x_,T y_)
: x(x_),y(y_) {}
coord(coord<T,2> const& rhs)
: x(rhs.x),
y(rhs.y) {}
template <typename T2>
coord (coord<T2,2> const& rhs)
: x(type(rhs.x)),
y(type(rhs.y)) {}
coord(coord<T,2> && rhs) noexcept
: x(std::move(rhs.x)),
y(std::move(rhs.y)) {}
coord<T,2>& operator=(coord<T,2> rhs)
{
swap(rhs);
return *this;
}
template <typename T2>
coord<T,2>& operator=(const coord<T2,2>& rhs)
{
coord<T,2> tmp(rhs);
swap(rhs);
return *this;
}
template <typename T2>
bool operator==(coord<T2,2> const& rhs)
{
return x == rhs.x && y == rhs.y;
}
coord<T,2>& operator+=(coord<T,2> const& rhs)
{
x+=rhs.x;
y+=rhs.y;
return *this;
}
coord<T,2>& operator+=(T rhs)
{
x+=rhs;
y+=rhs;
return *this;
}
coord<T,2>& operator-=(coord<T,2> const& rhs)
{
x-=rhs.x;
y-=rhs.y;
return *this;
}
coord<T,2>& operator-=(T rhs)
{
x-=rhs;
y-=rhs;
return *this;
}
coord<T,2>& operator*=(T t)
{
x*=t;
y*=t;
return *this;
}
coord<T,2>& operator/=(T t)
{
x/=t;
y/=t;
return *this;
}
private:
void swap(coord<T,2> & rhs)
{
std::swap(this->x, rhs.x);
std::swap(this->y, rhs.y);
}
};
template <typename T>
struct coord<T,3>
{
using type = T;
T x;
T y;
T z;
public:
coord()
: x(),y(),z() {}
coord(T x_,T y_,T z_)
: x(x_),y(y_),z(z_) {}
template <typename T2>
coord (coord<T2,3> const& rhs)
: x(type(rhs.x)),
y(type(rhs.y)),
z(type(rhs.z)) {}
coord(coord<T,3> && rhs) noexcept
: x(std::move(rhs.x)),
y(std::move(rhs.y)),
z(std::move(rhs.z)) {}
coord<T,3> operator=(coord<T,3> rhs)
{
swap(rhs);
return *this;
}
template <typename T2>
coord<T,3>& operator=(coord<T2,3> const& rhs)
{
coord<T,3> tmp(rhs);
swap(tmp);
return *this;
}
private:
void swap(coord<T,3> & rhs)
{
std::swap(this->x, rhs.x);
std::swap(this->y, rhs.y);
std::swap(this->z, rhs.z);
}
};
using coord2d = coord<double,2>;
using coord2i = coord<int,2>;
}
#endif // MAPNIK_COORD_HPP

View file

@ -33,7 +33,6 @@
#include <mapnik/util/noncopyable.hpp>
#include <mapnik/feature_style_processor_context.hpp>
#include <mapnik/datasource_geometry_type.hpp>
// stl
#include <map>
#include <string>
@ -112,7 +111,7 @@ public:
}
virtual boost::optional<datasource_geometry_t> get_geometry_type() const = 0;
virtual featureset_ptr features(query const& q) const = 0;
virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const = 0;
virtual featureset_ptr features_at_point(geometry::point<double> const& pt, double tol = 0) const = 0;
virtual box2d<double> envelope() const = 0;
virtual layer_descriptor get_descriptor() const = 0;
virtual ~datasource() {}

View file

@ -105,7 +105,7 @@ public:
: id_(_id),
ctx_(ctx),
data_(ctx_->mapping_.size()),
geom_(geometry::geometry_empty()),
geom_(geometry::geometry_empty<double>()),
raster_() {}
inline mapnik::value_integer id() const { return id_;}

View file

@ -25,7 +25,6 @@
// mapnik
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/vertex.hpp>
#include <mapnik/geometry_types.hpp>
// stl
@ -211,8 +210,8 @@ struct filter_in_box
struct filter_at_point
{
box2d<double> box_;
explicit filter_at_point(coord2d const& pt, double tol=0)
: box_(pt,pt)
explicit filter_at_point(geometry::point<double> const& pt, double tol=0)
: box_(pt.x,pt.y, pt.x, pt.y)
{
box_.pad(tol);
}

View file

@ -23,117 +23,34 @@
#ifndef MAPNIK_GEOMETRY_HPP
#define MAPNIK_GEOMETRY_HPP
// mapnik
#include <mapnik/geometry/point.hpp>
#include <mapnik/geometry/line_string.hpp>
#include <mapnik/geometry/polygon.hpp>
#include <mapnik/geometry/multi_point.hpp>
#include <mapnik/geometry/multi_line_string.hpp>
#include <mapnik/geometry/multi_polygon.hpp>
//
#include <mapnik/util/variant.hpp>
// stl
#include <vector>
#include <deque>
#include <type_traits>
#include <cstddef>
namespace mapnik { namespace geometry {
template <typename T>
struct point
{
using coord_type = T;
point() {}
point(T x_, T y_)
: x(x_), y(y_)
{}
coord_type x;
coord_type y;
};
template <typename T>
bool operator==(point<T> const& lhs, point<T> const& rhs)
{
return lhs.x == rhs.x && lhs.y == rhs.y;
}
template <typename T>
bool operator!=(point<T> const& lhs, point<T> const& rhs)
{
return !(lhs == rhs);
}
template <typename T>
struct line_string : std::vector<point<T> >
{
using coord_type = T;
line_string() = default;
explicit line_string(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>
struct linear_ring : line_string<T>
{
using coord_type = T;
linear_ring() = default;
explicit linear_ring(std::size_t size)
: line_string<T>(size) {}
linear_ring(line_string<T> && other)
: line_string<T>(std::move(other)) {}
linear_ring(line_string<T> const& other)
: line_string<T>(other) {}
};
template <typename T>
using rings_container = std::vector<linear_ring<T>>;
template <typename T, template <typename> class InteriorRings = rings_container>
struct polygon
{
using coord_type = T;
using rings_container = InteriorRings<T>;
linear_ring<T> exterior_ring;
rings_container interior_rings;
inline void set_exterior_ring(linear_ring<T> && ring)
{
exterior_ring = std::move(ring);
}
inline void add_hole(linear_ring<T> && ring)
{
interior_rings.emplace_back(std::move(ring));
}
inline bool empty() const { return exterior_ring.empty(); }
inline std::size_t num_rings() const
{
return 1 + interior_rings.size();
}
};
template <typename T>
struct multi_point : line_string<T>
{
using coord_type = T;
};
template <typename T>
struct multi_line_string : std::vector<line_string<T>>
{
using coord_type = T;
};
template <typename T>
struct multi_polygon : std::vector<polygon<T>>
{
using coord_type = T;
};
template <typename T>
template <typename T, template <typename...> class Cont = std::vector>
struct geometry_collection;
struct geometry_empty {};
template <typename T>
struct geometry_empty
{
using coord_type = T;
};
template <typename T>
using geometry_base = mapnik::util::variant<geometry_empty,
using geometry_base = mapnik::util::variant<geometry_empty<T>,
point<T>,
line_string<T>,
polygon<T>,
@ -155,8 +72,9 @@ struct geometry : geometry_base<T>
};
template <typename T>
struct geometry_collection : std::vector<geometry<T>>
template <typename T, template <typename...> class Cont>
struct geometry_collection : Cont<geometry<T>>
{
using coord_type = T;
};

View file

@ -0,0 +1,48 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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
*
*****************************************************************************/
#ifndef MAPNIK_GEOMETRY_LINE_STRING_HPP
#define MAPNIK_GEOMETRY_LINE_STRING_HPP
// mapnik
#include <mapnik/geometry/point.hpp>
// stl
#include <vector>
namespace mapnik { namespace geometry {
template <typename T, template <typename...> class Cont = std::vector>
struct line_string : Cont<point<T> >
{
using coord_type = T;
using point_type = point<coord_type>;
using container_type = Cont<point_type>;
line_string() = default;
explicit line_string(std::size_t size)
: container_type(size) {}
inline std::size_t num_points() const { return container_type::size(); }
inline void add_coord(coord_type x, coord_type y) { container_type::template emplace_back(x,y);}
};
}}
#endif // MAPNIK_GEOMETRY_LINE_STRING_HPP

View file

@ -0,0 +1,41 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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
*
*****************************************************************************/
#ifndef MAPNIK_GEOMETRY_MULTI_LINE_STRING_HPP
#define MAPNIK_GEOMETRY_MULTI_LINE_STRING_HPP
// mapnik
#include <mapnik/geometry/line_string.hpp>
// stl
#include <vector>
namespace mapnik { namespace geometry {
template <typename T, template <typename...> class Cont = std::vector>
struct multi_line_string : Cont<line_string<T>>
{
using coord_type = T;
};
}}
#endif // MAPNIK_GEOMETRY_MULTI_LINE_STRING_HPP

View file

@ -0,0 +1,48 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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
*
*****************************************************************************/
#ifndef MAPNIK_GEOMETRY_MULTI_POINT_HPP
#define MAPNIK_GEOMETRY_MULTI_POINT_HPP
// mapnik
#include <mapnik/geometry/point.hpp>
// stl
#include <vector>
namespace mapnik { namespace geometry {
template <typename T, template <typename...> class Cont = std::vector>
struct multi_point : Cont<point<T>>
{
using coord_type = T;
using point_type = point<coord_type>;
using container_type = Cont<point_type>;
multi_point() = default;
explicit multi_point(std::size_t size)
: container_type(size) {}
inline std::size_t num_points() const { return container_type::size(); }
inline void add_coord(T x, T y) { container_type::template emplace_back(x, y);}
};
}}
#endif // MAPNIK_GEOMETRY_MULTI_POINT_HPP

View file

@ -0,0 +1,41 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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
*
*****************************************************************************/
#ifndef MAPNIK_GEOMETRY_MULTI_POLYGON_HPP
#define MAPNIK_GEOMETRY_MULTI_POLYGON_HPP
// mapnik
#include <mapnik/geometry/polygon.hpp>
// stl
#include <vector>
namespace mapnik { namespace geometry {
template <typename T, template <typename...> class Cont = std::vector>
struct multi_polygon : Cont<polygon<T>>
{
using coord_type = T;
};
}}
#endif // MAPNIK_GEOMETRY_MULTI_POLYGON_HPP

View file

@ -0,0 +1,54 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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
*
*****************************************************************************/
#ifndef MAPNIK_GEOMETRY_POINT_HPP
#define MAPNIK_GEOMETRY_POINT_HPP
namespace mapnik { namespace geometry {
template <typename T>
struct point
{
using coord_type = T;
point() {}
point(T x_, T y_)
: x(x_), y(y_)
{}
coord_type x;
coord_type y;
};
template <typename T>
bool operator==(point<T> const& lhs, point<T> const& rhs)
{
return lhs.x == rhs.x && lhs.y == rhs.y;
}
template <typename T>
bool operator!=(point<T> const& lhs, point<T> const& rhs)
{
return lhs.x != rhs.x || lhs.y != rhs.y;
}
}}
#endif // MAPNIK_GEOMETRY_POINT_HPP

View file

@ -0,0 +1,78 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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
*
*****************************************************************************/
#ifndef MAPNIK_GEOMETRY_POLYGON_HPP
#define MAPNIK_GEOMETRY_POLYGON_HPP
// mapnik
#include <mapnik/geometry/line_string.hpp>
// stl
#include <vector>
namespace mapnik { namespace geometry {
template <typename T>
struct linear_ring : line_string<T>
{
using coord_type = T;
linear_ring() = default;
explicit linear_ring(std::size_t size)
: line_string<T>(size) {}
linear_ring(line_string<T> && other)
: line_string<T>(std::move(other)) {}
linear_ring(line_string<T> const& other)
: line_string<T>(other) {}
};
template <typename T>
using rings_container = std::vector<linear_ring<T>>;
template <typename T, template <typename> class InteriorRings = rings_container>
struct polygon
{
using coord_type = T;
using rings_container = InteriorRings<coord_type>;
linear_ring<T> exterior_ring;
rings_container interior_rings;
inline void set_exterior_ring(linear_ring<T> && ring)
{
exterior_ring = std::move(ring);
}
inline void add_hole(linear_ring<T> && ring)
{
interior_rings.emplace_back(std::move(ring));
}
inline bool empty() const { return exterior_ring.empty(); }
inline std::size_t num_rings() const
{
return 1 + interior_rings.size();
}
};
}}
#endif // MAPNIK_GEOMETRY_POLYGON_HPP

View file

@ -39,7 +39,6 @@
#pragma GCC diagnostic pop
#include <mapnik/geometry.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/box2d.hpp>
#include <cstdint>
@ -49,8 +48,6 @@ BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point<double>, double, boost
BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point<std::int64_t>, std::int64_t, boost::geometry::cs::cartesian, x, y)
// ring
BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(mapnik::geometry::linear_ring)
// needed by box2d<double>
BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::coord2d, double, boost::geometry::cs::cartesian, x, y)
namespace boost {
@ -86,38 +83,34 @@ namespace geometry { namespace traits {
// register mapnik::box2d<double>
template<> struct tag<mapnik::box2d<double> > { using type = box_tag; };
template<> struct point_type<mapnik::box2d<double> > { using type = mapnik::coord2d; };
template<> struct point_type<mapnik::box2d<double> > { using type = mapnik::geometry::point<double>; };
template <>
struct indexed_access<mapnik::box2d<double>, min_corner, 0>
{
using ct = coordinate_type<mapnik::coord2d>::type;
static inline ct get(mapnik::box2d<double> const& b) { return b.minx();}
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_minx(value); }
static inline double get(mapnik::box2d<double> const& b) { return b.minx();}
static inline void set(mapnik::box2d<double> &b, double const& value) { b.set_minx(value); }
};
template <>
struct indexed_access<mapnik::box2d<double>, min_corner, 1>
{
using ct = coordinate_type<mapnik::coord2d>::type;
static inline ct get(mapnik::box2d<double> const& b) { return b.miny();}
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_miny(value); }
static inline double get(mapnik::box2d<double> const& b) { return b.miny();}
static inline void set(mapnik::box2d<double> &b, double const& value) { b.set_miny(value); }
};
template <>
struct indexed_access<mapnik::box2d<double>, max_corner, 0>
{
using ct = coordinate_type<mapnik::coord2d>::type;
static inline ct get(mapnik::box2d<double> const& b) { return b.maxx();}
static inline void set(mapnik::box2d<double> &b, ct const& value) { b.set_maxx(value); }
static inline double get(mapnik::box2d<double> const& b) { return b.maxx();}
static inline void set(mapnik::box2d<double> &b, double const& value) { b.set_maxx(value); }
};
template <>
struct indexed_access<mapnik::box2d<double>, max_corner, 1>
{
using ct = coordinate_type<mapnik::coord2d>::type;
static inline ct get(mapnik::box2d<double> const& b) { return b.maxy();}
static inline void set(mapnik::box2d<double> &b , ct const& value) { b.set_maxy(value); }
static inline double get(mapnik::box2d<double> const& b) { return b.maxy();}
static inline void set(mapnik::box2d<double> &b , double const& value) { b.set_maxy(value); }
};
// mapnik::geometry::line_string

View file

@ -41,13 +41,13 @@ struct geometry_centroid
geometry_centroid(point<T> & pt)
: pt_(pt) {}
template <typename T1>
result_type operator() (T1 const& geom) const
template <typename U>
result_type operator() (U const& geom) const
{
return util::apply_visitor(*this, geom);
}
result_type operator() (geometry_empty const&) const
result_type operator() (geometry_empty<T> const&) const
{
return false;
}

View file

@ -35,7 +35,7 @@ struct geometry_envelope
using bbox_type = box2d<coord_type>;
bbox_type & bbox;
geometry_envelope(bbox_type & bbox_)
explicit geometry_envelope(bbox_type & bbox_)
: bbox(bbox_) {}
template <typename U>
@ -44,7 +44,7 @@ struct geometry_envelope
return mapnik::util::apply_visitor(*this, geom);
}
void operator() (mapnik::geometry::geometry_empty const&) const {}
void operator() (mapnik::geometry::geometry_empty<T> const&) const {}
void operator() (mapnik::geometry::point<T> const& pt) const
{

View file

@ -24,7 +24,7 @@
#ifndef MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP
#define MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/polygon.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
BOOST_FUSION_ADAPT_STRUCT(

View file

@ -29,103 +29,105 @@ namespace mapnik { namespace geometry {
namespace detail {
template <typename T>
struct geometry_is_empty
{
bool operator() (mapnik::geometry::geometry<double> const& geom) const
bool operator() (mapnik::geometry::geometry<T> const& geom) const
{
return mapnik::util::apply_visitor(*this, geom);
}
bool operator() (mapnik::geometry::point<double> const&) const
bool operator() (mapnik::geometry::point<T> const&) const
{
return false;
}
bool operator() (mapnik::geometry::line_string<double> const& geom) const
bool operator() (mapnik::geometry::line_string<T> const& geom) const
{
return geom.empty();
}
bool operator() (mapnik::geometry::polygon<double> const& geom) const
bool operator() (mapnik::geometry::polygon<T> const& geom) const
{
return geom.empty();
}
bool operator() (mapnik::geometry::multi_point<double> const& geom) const
bool operator() (mapnik::geometry::multi_point<T> const& geom) const
{
return geom.empty();
}
bool operator() (mapnik::geometry::multi_line_string<double> const& geom) const
bool operator() (mapnik::geometry::multi_line_string<T> const& geom) const
{
return geom.empty();
}
bool operator() (mapnik::geometry::multi_polygon<double> const& geom) const
bool operator() (mapnik::geometry::multi_polygon<T> const& geom) const
{
return geom.empty();
}
bool operator() (mapnik::geometry::geometry_collection<double> const& geom) const
bool operator() (mapnik::geometry::geometry_collection<T> const& geom) const
{
return geom.empty();
}
template <typename T>
bool operator() (T const&) const
template <typename U>
bool operator() (U const&) const
{
return true;
}
};
template <typename T>
struct geometry_has_empty
{
bool operator() (mapnik::geometry::geometry<double> const& geom) const
bool operator() (mapnik::geometry::geometry<T> const& geom) const
{
return mapnik::util::apply_visitor(*this, geom);
}
bool operator() (mapnik::geometry::geometry_empty const&) const
bool operator() (mapnik::geometry::geometry_empty<T> const&) const
{
return false;
}
bool operator() (mapnik::geometry::point<double> const&) const
bool operator() (mapnik::geometry::point<T> const&) const
{
return false;
}
bool operator() (mapnik::geometry::line_string<double> const&) const
bool operator() (mapnik::geometry::line_string<T> const&) const
{
return false;
}
bool operator() (mapnik::geometry::polygon<double> const&) const
bool operator() (mapnik::geometry::polygon<T> const&) const
{
return false;
}
bool operator() (mapnik::geometry::multi_point<double> const&) const
bool operator() (mapnik::geometry::multi_point<T> const&) const
{
return false;
}
bool operator() (mapnik::geometry::multi_line_string<double> const& geom) const
bool operator() (mapnik::geometry::multi_line_string<T> const& geom) const
{
return test_multigeometry(geom);
}
bool operator() (mapnik::geometry::multi_polygon<double> const& geom) const
bool operator() (mapnik::geometry::multi_polygon<T> const& geom) const
{
return test_multigeometry(geom);
}
bool operator() (mapnik::geometry::geometry_collection<double> const& geom) const
bool operator() (mapnik::geometry::geometry_collection<T> const& geom) const
{
for (auto const & item : geom)
{
if (geometry_is_empty()(item) || (*this)(item))
if (geometry_is_empty<T>()(item) || (*this)(item))
{
return true;
}
@ -133,15 +135,15 @@ struct geometry_has_empty
return false;
}
template <typename T>
bool operator() (T const&) const
template <typename U>
bool operator() (U const&) const
{
return true;
}
private:
template <typename T>
bool test_multigeometry(T const & geom) const
template <typename U>
bool test_multigeometry(U const & geom) const
{
for (auto const & item : geom)
{
@ -156,16 +158,18 @@ private:
}
template <typename GeomType>
inline bool is_empty(GeomType const& geom)
template <typename G>
inline bool is_empty(G const& geom)
{
return detail::geometry_is_empty()(geom);
using coord_type = typename G::coord_type;
return detail::geometry_is_empty<coord_type>()(geom);
}
template <typename GeomType>
inline bool has_empty(GeomType const& geom)
template <typename G>
inline bool has_empty(G const& geom)
{
return detail::geometry_has_empty()(geom);
using coord_type = typename G::coord_type;
return detail::geometry_has_empty<coord_type>()(geom);
}
}}

View file

@ -36,24 +36,23 @@ namespace mapnik { namespace geometry {
namespace detail {
template <typename T>
struct geometry_is_simple
{
using result_type = bool;
template <typename T>
result_type operator() (geometry<T> const& geom) const
{
return mapnik::util::apply_visitor(*this, geom);
}
result_type operator() (geometry_empty const& ) const
result_type operator() (geometry_empty<T> const& ) const
{
// An empty geometry has no anomalous geometric points, such as self intersection or self tangency.
// Therefore, we will return true
return true;
}
template <typename T>
result_type operator() (geometry_collection<T> const& collection) const
{
for (auto const& geom : collection)
@ -63,12 +62,11 @@ struct geometry_is_simple
return true;
}
template <typename T>
result_type operator() (point<T> const& pt) const
{
return boost::geometry::is_simple(pt);
}
template <typename T>
result_type operator() (line_string<T> const& line) const
{
if (line.empty())
@ -80,12 +78,12 @@ struct geometry_is_simple
}
return boost::geometry::is_simple(line);
}
template <typename T>
result_type operator() (polygon<T> const& poly) const
{
return boost::geometry::is_simple(poly);
}
template <typename T>
result_type operator() (multi_point<T> const& multi_pt) const
{
if (multi_pt.empty())
@ -96,7 +94,7 @@ struct geometry_is_simple
}
return boost::geometry::is_simple(multi_pt);
}
template <typename T>
result_type operator() (multi_line_string<T> const& multi_line) const
{
if (multi_line.empty())
@ -111,7 +109,7 @@ struct geometry_is_simple
}
return true;
}
template <typename T>
result_type operator() (multi_polygon<T> const& multi_poly) const
{
if (multi_poly.empty())
@ -134,13 +132,14 @@ struct geometry_is_simple
template <typename T>
inline bool is_simple(T const& geom)
{
return detail::geometry_is_simple() (geom);
using coord_type = typename T::coord_type;
return detail::geometry_is_simple<coord_type>() (geom);
}
template <typename T>
inline bool is_simple(mapnik::geometry::geometry<T> const& geom)
{
return util::apply_visitor(detail::geometry_is_simple(), geom);
return util::apply_visitor(detail::geometry_is_simple<T>(), geom);
}
}}

View file

@ -37,22 +37,21 @@ namespace mapnik { namespace geometry {
namespace detail {
template <typename T>
struct geometry_is_valid
{
using result_type = bool;
template <typename T>
result_type operator() (geometry<T> const& geom) const
{
return mapnik::util::apply_visitor(*this, geom);
}
result_type operator() (geometry_empty const& ) const
result_type operator() (geometry_empty<T> const& ) const
{
return true;
}
template <typename T>
result_type operator() (geometry_collection<T> const& collection) const
{
for (auto const& geom : collection)
@ -62,43 +61,38 @@ struct geometry_is_valid
return true;
}
template <typename T>
result_type operator() (point<T> const& pt) const
{
return boost::geometry::is_valid(pt);
}
template <typename T>
result_type operator() (line_string<T> const& line) const
{
return boost::geometry::is_valid(line);
}
template <typename T>
result_type operator() (polygon<T> const& poly) const
{
return boost::geometry::is_valid(poly);
}
template <typename T>
result_type operator() (multi_point<T> const& multi_pt) const
{
return boost::geometry::is_valid(multi_pt);
}
template <typename T>
result_type operator() (multi_line_string<T> const& multi_line) const
{
return boost::geometry::is_valid(multi_line);
}
template <typename T>
result_type operator() (multi_polygon<T> const& multi_poly) const
{
return boost::geometry::is_valid(multi_poly);
}
};
template <typename T>
struct geometry_is_valid_reason
{
using result_type = bool;
@ -108,19 +102,17 @@ struct geometry_is_valid_reason
geometry_is_valid_reason(boost::geometry::validity_failure_type & failure):
failure_(failure) {}
template <typename T>
result_type operator() (geometry<T> const& geom) const
{
return mapnik::util::apply_visitor(*this, geom);
}
result_type operator() (geometry_empty const& ) const
result_type operator() (geometry_empty<T> const& ) const
{
failure_ = boost::geometry::no_failure;
return true;
}
template <typename T>
result_type operator() (geometry_collection<T> const& collection) const
{
for (auto const& geom : collection)
@ -130,43 +122,38 @@ struct geometry_is_valid_reason
return true;
}
template <typename T>
result_type operator() (point<T> const& pt) const
{
return boost::geometry::is_valid(pt, failure_);
}
template <typename T>
result_type operator() (line_string<T> const& line) const
{
return boost::geometry::is_valid(line, failure_);
}
template <typename T>
result_type operator() (polygon<T> const& poly) const
{
return boost::geometry::is_valid(poly, failure_);
}
template <typename T>
result_type operator() (multi_point<T> const& multi_pt) const
{
return boost::geometry::is_valid(multi_pt, failure_);
}
template <typename T>
result_type operator() (multi_line_string<T> const& multi_line) const
{
return boost::geometry::is_valid(multi_line, failure_);
}
template <typename T>
result_type operator() (multi_polygon<T> const& multi_poly) const
{
return boost::geometry::is_valid(multi_poly, failure_);
}
};
template <typename T>
struct geometry_is_valid_string
{
using result_type = bool;
@ -176,19 +163,17 @@ struct geometry_is_valid_string
geometry_is_valid_string(std::string & message):
message_(message) {}
template <typename T>
result_type operator() (geometry<T> const& geom) const
{
return mapnik::util::apply_visitor(*this, geom);
}
result_type operator() (geometry_empty const& ) const
result_type operator() (geometry_empty<T> const& ) const
{
message_ = "Geometry is valid";
return true;
}
template <typename T>
result_type operator() (geometry_collection<T> const& collection) const
{
for (auto const& geom : collection)
@ -198,82 +183,78 @@ struct geometry_is_valid_string
return true;
}
template <typename T>
result_type operator() (point<T> const& pt) const
{
return boost::geometry::is_valid(pt, message_);
}
template <typename T>
result_type operator() (line_string<T> const& line) const
{
return boost::geometry::is_valid(line, message_);
}
template <typename T>
result_type operator() (polygon<T> const& poly) const
{
return boost::geometry::is_valid(poly, message_);
}
template <typename T>
result_type operator() (multi_point<T> const& multi_pt) const
{
return boost::geometry::is_valid(multi_pt, message_);
}
template <typename T>
result_type operator() (multi_line_string<T> const& multi_line) const
{
return boost::geometry::is_valid(multi_line, message_);
}
template <typename T>
result_type operator() (multi_polygon<T> const& multi_poly) const
{
return boost::geometry::is_valid(multi_poly, message_);
}
};
}
template <typename T>
inline bool is_valid(T const& geom)
{
return detail::geometry_is_valid() (geom);
using coord_type = typename T::coord_type;
return detail::geometry_is_valid<coord_type>() (geom);
}
template <typename T>
inline bool is_valid(mapnik::geometry::geometry<T> const& geom)
{
return util::apply_visitor(detail::geometry_is_valid(), geom);
return util::apply_visitor(detail::geometry_is_valid<T>(), geom);
}
template <typename T>
inline bool is_valid(T const& geom, boost::geometry::validity_failure_type & failure)
{
return detail::geometry_is_valid_reason(failure) (geom);
using coord_type = typename T::coord_type;
return detail::geometry_is_valid_reason<coord_type>(failure) (geom);
}
template <typename T>
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
boost::geometry::validity_failure_type & failure)
{
return util::apply_visitor(detail::geometry_is_valid_reason(failure), geom);
return util::apply_visitor(detail::geometry_is_valid_reason<T>(failure), geom);
}
template <typename T>
inline bool is_valid(T const& geom, std::string & message)
{
return detail::geometry_is_valid_string(message) (geom);
using coord_type = typename T::coord_type;
return detail::geometry_is_valid_string<coord_type>(message) (geom);
}
template <typename T>
inline bool is_valid(mapnik::geometry::geometry<T> const& geom,
std::string & message)
{
return util::apply_visitor(detail::geometry_is_valid_string(message), geom);
return util::apply_visitor(detail::geometry_is_valid_string<T>(message), geom);
}
}}

View file

@ -30,9 +30,10 @@ namespace geometry {
namespace detail {
geometry_empty reproject_internal(geometry_empty const&, proj_transform const&, unsigned int &)
template <typename T>
geometry_empty<T> reproject_internal(geometry_empty<T> const&, proj_transform const&, unsigned int &)
{
return geometry_empty();
return geometry_empty<T>();
}
template <typename T>
@ -162,7 +163,7 @@ geometry_collection<T> reproject_internal(geometry_collection<T> const & c, proj
{
geometry<T> new_g = reproject_copy(g, proj_trans, n_err);
if (!new_g.template is<geometry_empty>())
if (!new_g.template is<geometry_empty<T>>())
{
new_c.emplace_back(std::move(new_g));
}
@ -178,9 +179,9 @@ struct geom_reproj_copy_visitor
: proj_trans_(proj_trans),
n_err_(n_err) {}
geometry<T> operator() (geometry_empty const&) const
geometry<T> operator() (geometry_empty<T>) const
{
return geometry_empty();
return geometry_empty<T>();
}
geometry<T> operator() (point<T> const& p) const
@ -289,7 +290,8 @@ struct geom_reproj_visitor {
return mapnik::util::apply_visitor((*this), geom);
}
bool operator() (geometry_empty &) const { return true; }
template <typename T>
bool operator() (geometry_empty<T> &) const { return true; }
template <typename T>
bool operator() (point<T> & p) const
@ -332,7 +334,11 @@ struct geom_reproj_visitor {
template <typename T>
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>

View file

@ -28,24 +28,22 @@
namespace mapnik { namespace geometry { namespace detail {
//template <typename Transformer>
template <typename T>
struct geometry_to_path
{
geometry_to_path(path_type & p)
: p_(p) {}
template <typename T>
void operator() (geometry<T> const& geom) const
{
mapnik::util::apply_visitor(*this, geom);
}
void operator() (geometry_empty const&) const
void operator() (geometry_empty<T> const&) const
{
// no-op
}
// point
template <typename T>
void operator() (point<T> const& pt) const
{
//point pt_new;
@ -54,7 +52,6 @@ struct geometry_to_path
}
// line_string
template <typename T>
void operator() (line_string<T> const& line) const
{
bool first = true;
@ -68,7 +65,6 @@ struct geometry_to_path
}
// polygon
template <typename T>
void operator() (polygon<T> const& poly) const
{
// exterior
@ -112,7 +108,6 @@ struct geometry_to_path
}
// multi point
template <typename T>
void operator() (multi_point<T> const& multi_pt) const
{
for (auto const& pt : multi_pt)
@ -121,7 +116,6 @@ struct geometry_to_path
}
}
// multi_line_string
template <typename T>
void operator() (multi_line_string<T> const& multi_line) const
{
for (auto const& line : multi_line)
@ -131,7 +125,6 @@ struct geometry_to_path
}
// multi_polygon
template <typename T>
void operator() (multi_polygon<T> const& multi_poly) const
{
for (auto const& poly : multi_poly)
@ -139,8 +132,7 @@ struct geometry_to_path
(*this)(poly);
}
}
template <typename T>
// geometry_collection
void operator() (geometry_collection<T> const& collection) const
{
for (auto const& geom : collection)
@ -157,7 +149,8 @@ struct geometry_to_path
template <typename T>
void to_path(T const& geom, path_type & p)
{
detail::geometry_to_path func(p);
using coord_type = typename T::coord_type;
detail::geometry_to_path<coord_type> func(p);
func(geom);
}

View file

@ -103,9 +103,10 @@ struct geometry_transform
using result_type = geometry<V>;
geometry<V> operator() (geometry_empty const& empty) const
template <typename T>
geometry<V> operator() (geometry_empty<T> const& empty) const
{
return empty;
return geometry_empty<V>();
}
template <typename T>

View file

@ -29,56 +29,49 @@
namespace mapnik { namespace geometry { namespace detail {
template <typename T>
struct geometry_type
{
template <typename T>
mapnik::geometry::geometry_types operator () (T const& geom) const
mapnik::geometry::geometry_types operator () (mapnik::geometry::geometry<T> const& geom) const
{
return mapnik::util::apply_visitor(*this, geom);
}
mapnik::geometry::geometry_types operator() (geometry_empty const& ) const
mapnik::geometry::geometry_types operator() (geometry_empty<T> const& ) const
{
return mapnik::geometry::geometry_types::Unknown;
}
template <typename T>
mapnik::geometry::geometry_types operator () (mapnik::geometry::point<T> const&) const
{
return mapnik::geometry::geometry_types::Point;
}
template <typename T>
mapnik::geometry::geometry_types operator () (mapnik::geometry::line_string<T> const&) const
{
return mapnik::geometry::geometry_types::LineString;
}
template <typename T>
mapnik::geometry::geometry_types operator () (mapnik::geometry::polygon<T> const&) const
{
return mapnik::geometry::geometry_types::Polygon;
}
template <typename T>
mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_point<T> const&) const
{
return mapnik::geometry::geometry_types::MultiPoint;
}
template <typename T>
mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_line_string<T> const&) const
{
return mapnik::geometry::geometry_types::MultiLineString;
}
template <typename T>
mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_polygon<T> const&) const
{
return mapnik::geometry::geometry_types::MultiPolygon;
}
template <typename T>
mapnik::geometry::geometry_types operator () (mapnik::geometry::geometry_collection<T> const&) const
{
return mapnik::geometry::geometry_types::GeometryCollection;
@ -89,7 +82,8 @@ struct geometry_type
template <typename T>
static inline mapnik::geometry::geometry_types geometry_type(T const& geom)
{
return detail::geometry_type()(geom);
using coord_type = typename T::coord_type;
return detail::geometry_type<coord_type>()(geom);
}
}}

View file

@ -49,7 +49,7 @@ struct hit_test_visitor
y_(y),
tol_(tol) {}
bool operator() (geometry::geometry_empty const& ) const
bool operator() (geometry::geometry_empty<double> const& ) const
{
return false;
}

View file

@ -93,7 +93,7 @@ struct vector_markers_dispatch : util::noncopyable
protected:
static agg::trans_affine recenter(svg_path_ptr const& src)
{
coord2d center = src->bounding_box().center();
auto center = src->bounding_box().center();
return agg::trans_affine_translation(-center.x, -center.y);
}

View file

@ -41,7 +41,7 @@ public:
virtual ~memory_datasource();
virtual datasource::datasource_t type() const;
virtual featureset_ptr features(query const& q) const;
virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
virtual featureset_ptr features_at_point(geometry::point<double> const& pt, double tol = 0) const;
virtual box2d<double> envelope() const;
virtual boost::optional<datasource_geometry_t> get_geometry_type() const;
virtual layer_descriptor get_descriptor() const;

View file

@ -24,21 +24,20 @@
// stl
#include <cmath>
#include <mapnik/geometry/point.hpp>
namespace mapnik
{
struct rotation;
struct pixel_position
struct pixel_position : geometry::point<double>
{
double x;
double y;
pixel_position(double x_, double y_)
: x(x_),
y(y_) {}
pixel_position(double x, double y)
: geometry::point<double>(x, y) {}
pixel_position()
: x(0),
y(0) {}
: geometry::point<double>(0,0) {}
pixel_position operator+ (pixel_position const& other) const
{
return pixel_position(x + other.x, y + other.y);

View file

@ -35,13 +35,8 @@
#include <boost/numeric/conversion/cast.hpp>
#pragma GCC diagnostic pop
namespace mapnik {
namespace geometry {
template <typename T> struct point;
template <typename T> struct line_string;
}
class projection;
template <typename T> class box2d;

View file

@ -26,12 +26,13 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/util/noncopyable.hpp>
// stl
#include <vector>
namespace mapnik {
namespace geometry {
template <typename T> struct point;
template <typename T> struct line_string;
}
class projection;
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 forward (geometry::point<double> & p) const;
bool backward (geometry::point<double> & p) const;
unsigned int forward (geometry::line_string<double> & ls) const;
unsigned int backward (geometry::line_string<double> & ls) const;
unsigned int forward (std::vector<geometry::point<double>> & ls) const;
unsigned int backward (std::vector<geometry::point<double>> & ls) const;
bool forward (box2d<double> & box) const;
bool backward (box2d<double> & box) const;
bool forward (box2d<double> & box, int points) const;

View file

@ -56,8 +56,8 @@ void render_point_symbolizer(point_symbolizer const &sym,
value_bool ignore_placement = get<value_bool, keys::ignore_placement>(sym, feature, common.vars_);
point_placement_enum placement= get<point_placement_enum, keys::point_placement_type>(sym, feature, common.vars_);
box2d<double> const& bbox = mark->bounding_box();
coord2d center = bbox.center();
auto const& bbox = mark->bounding_box();
auto center = bbox.center();
agg::trans_affine tr;
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);

View file

@ -69,6 +69,7 @@ public:
using line_string_cref = std::reference_wrapper<geometry::line_string<double> const>;
using polygon_cref = std::reference_wrapper<geometry::polygon<double> const>;
using geometry_cref = util::variant<point_cref, line_string_cref, polygon_cref>;
// Using list instead of vector, because we delete random elements and need iterators to stay valid.
using geometry_container_type = std::list<geometry_cref>;
base_symbolizer_helper(symbolizer_base const& sym,
@ -110,6 +111,10 @@ protected:
evaluated_text_properties_ptr text_props_;
};
namespace geometry {
MAPNIK_DECL mapnik::box2d<double> envelope(mapnik::base_symbolizer_helper::geometry_cref const& geom);
}
// Helper object that does all the TextSymbolizer placement finding
// work except actually rendering the object.

View file

@ -42,7 +42,7 @@ namespace detail {
struct datasource_geometry_type
{
mapnik::datasource_geometry_t operator () (mapnik::geometry::geometry_empty const&) const
mapnik::datasource_geometry_t operator () (mapnik::geometry::geometry_empty<double> const&) const
{
return mapnik::datasource_geometry_t::Unknown;
}

View file

@ -238,7 +238,7 @@ struct geometry_to_wkb
return util::apply_visitor(*this, geom);
}
result_type operator() (geometry::geometry_empty const&) const
result_type operator() (geometry::geometry_empty<double> const&) const
{
return result_type();
}
@ -288,7 +288,7 @@ wkb_buffer_ptr multi_geom_wkb(MultiGeometry const& multi_geom, wkbByteOrder byte
wkb_buffer_ptr multi_wkb = std::make_unique<wkb_buffer>(multi_size);
wkb_stream ss(multi_wkb->buffer(), multi_wkb->size());
ss.write(reinterpret_cast<char*>(&byte_order),1);
write(ss, static_cast<int>(geometry::detail::geometry_type()(multi_geom)) , 4, byte_order);
write(ss, static_cast<int>(geometry::detail::geometry_type<double>()(multi_geom)) , 4, byte_order);
write(ss, multi_geom.size(), 4 ,byte_order);
for ( wkb_buffer_ptr const& wkb : wkb_cont)

View file

@ -24,7 +24,6 @@
#define MAPNIK_UTIL_SPATIAL_INDEX_HPP
//mapnik
#include <mapnik/coord.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/query.hpp>
#include <mapnik/geom_util.hpp>

View file

@ -32,8 +32,7 @@ namespace mapnik { namespace geometry {
template <typename T>
struct point_vertex_adapter
{
using coord_type = typename point<T>::coord_type;
using coord_type = T;
point_vertex_adapter(point<T> const& pt);
unsigned vertex(coord_type * x, coord_type * y) const;
void rewind(unsigned) const;
@ -45,20 +44,20 @@ struct point_vertex_adapter
template <typename T>
struct line_string_vertex_adapter
{
using coord_type = typename point<T>::coord_type;
using coord_type = T;
line_string_vertex_adapter(line_string<T> const& line);
unsigned vertex(coord_type * x, coord_type * y) const;
void rewind(unsigned) const;
geometry_types type () const;
line_string<T> const& line_;
mutable std::size_t current_index_;
const std::size_t end_index_;
const std::size_t end_index_;
};
template <typename T>
struct polygon_vertex_adapter
{
using coord_type = typename point<T>::coord_type;
using coord_type = T;
polygon_vertex_adapter(polygon<T> const& poly);
void rewind(unsigned) const;
unsigned vertex(coord_type * x, coord_type * y) const;
@ -75,7 +74,7 @@ private:
template <typename T>
struct ring_vertex_adapter
{
using coord_type = typename point<T>::coord_type;
using coord_type = T;
ring_vertex_adapter(linear_ring<T> const& ring);
void rewind(unsigned) const;
unsigned vertex(coord_type * x, coord_type * y) const;

View file

@ -39,7 +39,8 @@ struct vertex_processor
{
util::apply_visitor(*this, geom);
}
void operator() (geometry_empty const&) const
template <typename T1>
void operator() (geometry_empty<T1> const&) const
{
// no-op
}

View file

@ -24,7 +24,6 @@
#define MAPNIK_VIEW_TRANSFORM_HPP
// mapnik
#include <mapnik/coord.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/proj_transform.hpp>
@ -109,13 +108,13 @@ public:
*y = extent_.maxy() - (*y + (offset_y_ - offset_)) / sy_;
}
inline coord2d& forward(coord2d& c) const
inline geometry::point<double>& forward(geometry::point<double>& c) const
{
forward(&c.x, &c.y);
return c;
}
inline coord2d& backward(coord2d& c) const
inline geometry::point<double>& backward(geometry::point<double>& c) const
{
backward(&c.x, &c.y);
return c;

View file

@ -26,7 +26,7 @@
// mapnik
#include <mapnik/global.hpp> // for M_PI on windows
#include <mapnik/enumeration.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/point.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
@ -35,6 +35,7 @@
// stl
#include <cmath>
#include <vector>
namespace mapnik {
@ -93,9 +94,9 @@ static inline bool merc2lonlat(double * x, double * y , int point_count)
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;
else if (p.x < -180) p.x = -180;
@ -108,7 +109,7 @@ static inline bool lonlat2merc(geometry::line_string<double> & ls)
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)
{

View file

@ -79,7 +79,7 @@ wkt_generator_grammar<OutputIterator, Geometry>::wkt_generator_grammar()
<< (geometry_collection | empty[_1 = _a]))
|
(&uint_(geometry::geometry_types::Unknown)[_1 = _a]
<< lit("POINT EMPTY")) // special case for geometry_empty as mapnik::geometry::point<double> can't be empty
<< lit("POINT EMPTY")) // special case for geometry_empty<double> as mapnik::geometry::point<double> can't be empty
;
point = lit("POINT(") << point_coord << lit(")")

View file

@ -62,7 +62,7 @@ wkt_grammar<Iterator>::wkt_grammar()
// <point tagged text> ::= point <point text>
point_tagged_text = no_case[lit("POINT")]
>> (point_text[assign(_r1,_1)] | empty_set[assign(_r1,construct<geometry::geometry_empty>())])
>> (point_text[assign(_r1,_1)] | empty_set[assign(_r1,construct<geometry::geometry_empty<double>>())])
;
// <point text> ::= <empty set> | <left paren> <point> <right paren>
point_text = (lit("(") >> point >> lit(')'))

View file

@ -434,9 +434,9 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const
return mapnik::featureset_ptr();
}
mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::geometry::point<double> const& pt, double tol) const
{
mapnik::box2d<double> query_bbox(pt, pt);
mapnik::box2d<double> query_bbox(pt.x, pt.y, pt.x, pt.y);
query_bbox.pad(tol);
mapnik::query q(query_bbox);
std::vector<mapnik::attribute_descriptor> const& desc = desc_.get_descriptors();

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/value_types.hpp>
#include "csv_utils.hpp"
@ -81,7 +80,7 @@ public:
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::featureset_ptr features_at_point(mapnik::geometry::point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;

View file

@ -73,7 +73,7 @@ mapnik::feature_ptr csv_featureset::parse_feature(char const* beg, char const* e
{
auto values = csv_utils::parse_line(beg, end, separator_, quote_, headers_.size());
auto geom = csv_utils::extract_geometry(values, locator_);
if (!geom.is<mapnik::geometry::geometry_empty>())
if (!geom.is<mapnik::geometry::geometry_empty<double>>())
{
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_, ++feature_id_));
feature->set_geometry(std::move(geom));

View file

@ -90,7 +90,7 @@ mapnik::feature_ptr csv_index_featureset::parse_feature(char const* beg, char co
{
auto values = csv_utils::parse_line(beg, end, separator_, quote_, headers_.size());
auto geom = csv_utils::extract_geometry(values, locator_);
if (!geom.is<mapnik::geometry::geometry_empty>())
if (!geom.is<mapnik::geometry::geometry_empty<double>>())
{
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_, ++feature_id_));
feature->set_geometry(std::move(geom));

View file

@ -58,7 +58,7 @@ mapnik::feature_ptr csv_inline_featureset::parse_feature(std::string const& str)
auto const* end = start + str.size();
auto values = csv_utils::parse_line(start, end, separator_, quote_, headers_.size());
auto geom = csv_utils::extract_geometry(values, locator_);
if (!geom.is<mapnik::geometry::geometry_empty>())
if (!geom.is<mapnik::geometry::geometry_empty<double>>())
{
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_, ++feature_id_));
feature->set_geometry(std::move(geom));

View file

@ -406,7 +406,7 @@ void csv_file_parser::parse_csv_and_boxes(std::istream & csv_file, T & boxes)
}
auto geom = extract_geometry(values, locator_);
if (!geom.is<mapnik::geometry::geometry_empty>())
if (!geom.is<mapnik::geometry::geometry_empty<double>>())
{
auto box = mapnik::geometry::envelope(geom);
if (!extent_initialized_)

View file

@ -38,7 +38,7 @@ using mapnik::parameters;
DATASOURCE_PLUGIN(gdal_datasource)
using mapnik::box2d;
using mapnik::coord2d;
using mapnik::geometry::point;
using mapnik::query;
using mapnik::featureset_ptr;
using mapnik::layer_descriptor;
@ -238,7 +238,7 @@ featureset_ptr gdal_datasource::features(query const& q) const
nodata_tolerance_);
}
featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol) const
featureset_ptr gdal_datasource::features_at_point(mapnik::geometry::point<double> const& pt, double tol) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features_at_point");

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
// boost
@ -50,7 +49,7 @@ public:
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::featureset_ptr features_at_point(mapnik::geometry::point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;

View file

@ -630,7 +630,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
}
feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
feature_ptr gdal_featureset::get_feature_at_point(mapnik::geometry::point<double> const& pt)
{
CPLErr raster_io_error = CE_None;

View file

@ -33,7 +33,7 @@
class GDALDataset;
class GDALRasterBand;
using gdal_query = mapnik::util::variant<mapnik::query, mapnik::coord2d>;
using gdal_query = mapnik::util::variant<mapnik::query, mapnik::geometry::point<double>>;
class gdal_featureset : public mapnik::Featureset
{
@ -47,7 +47,7 @@ class gdal_featureset : public mapnik::Featureset
return featureset_.get_feature(q);
}
mapnik::feature_ptr operator() (mapnik::coord2d const& p) const
mapnik::feature_ptr operator() (mapnik::geometry::point<double> const& p) const
{
return featureset_.get_feature_at_point(p);
}
@ -72,7 +72,7 @@ public:
private:
mapnik::feature_ptr get_feature(mapnik::query const& q);
mapnik::feature_ptr get_feature_at_point(mapnik::coord2d const& p);
mapnik::feature_ptr get_feature_at_point(mapnik::geometry::point<double> const& p);
GDALDataset & dataset_;
mapnik::context_ptr ctx_;
int band_;

View file

@ -591,9 +591,9 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
return mapnik::featureset_ptr();
}
mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::geometry::point<double> const& pt, double tol) const
{
mapnik::box2d<double> query_bbox(pt, pt);
mapnik::box2d<double> query_bbox(pt.x, pt.y, pt.x, pt.y);
query_bbox.pad(tol);
mapnik::query q(query_bbox);
for (auto const& attr_info : desc_.get_descriptors())

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/unicode.hpp>
@ -84,7 +83,7 @@ public:
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::featureset_ptr features_at_point(mapnik::geometry::point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;

View file

@ -50,7 +50,7 @@ using mapnik::parameters;
DATASOURCE_PLUGIN(ogr_datasource)
using mapnik::box2d;
using mapnik::coord2d;
using mapnik::geometry::point;
using mapnik::query;
using mapnik::featureset_ptr;
using mapnik::layer_descriptor;
@ -563,7 +563,7 @@ featureset_ptr ogr_datasource::features(query const& q) const
return featureset_ptr();
}
featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const
featureset_ptr ogr_datasource::features_at_point(mapnik::geometry::point<double> const& pt, double tol) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features_at_point");
@ -594,7 +594,7 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol)
}
else
{
mapnik::box2d<double> bbox(pt, pt);
mapnik::box2d<double> bbox(pt.x, pt.y, pt.x, pt.y);
bbox.pad(tol);
return featureset_ptr(new ogr_featureset (ctx,
*layer,

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
// boost
@ -54,7 +53,7 @@ public:
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::featureset_ptr features_at_point(mapnik::geometry::point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;

View file

@ -1002,7 +1002,7 @@ featureset_ptr pgraster_datasource::features_with_context(query const& q,process
}
featureset_ptr pgraster_datasource::features_at_point(coord2d const& pt, double tol) const
featureset_ptr pgraster_datasource::features_at_point(mapnik::geometry::point<double> const& pt, double tol) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "pgraster_datasource::features_at_point");

View file

@ -33,7 +33,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/value_types.hpp>
@ -60,7 +59,7 @@ using mapnik::featureset_ptr;
using mapnik::feature_ptr;
using mapnik::query;
using mapnik::parameters;
using mapnik::coord2d;
using mapnik::geometry::point;
typedef std::shared_ptr< ConnectionManager::PoolType> CnxPool_ptr;
@ -83,7 +82,7 @@ public:
processor_context_ptr get_context(feature_style_context_map &) const;
featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const;
featureset_ptr features(query const& q) const;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
featureset_ptr features_at_point(mapnik::geometry::point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;

View file

@ -946,7 +946,7 @@ featureset_ptr postgis_datasource::features_with_context(query const& q,processo
}
featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double tol) const
featureset_ptr postgis_datasource::features_at_point(point<double> const& pt, double tol) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features_at_point");

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/value_types.hpp>
@ -58,7 +57,7 @@ using mapnik::featureset_ptr;
using mapnik::feature_ptr;
using mapnik::query;
using mapnik::parameters;
using mapnik::coord2d;
using mapnik::geometry::point;
using CnxPool_ptr = std::shared_ptr< ConnectionManager::PoolType>;
@ -72,7 +71,7 @@ public:
processor_context_ptr get_context(feature_style_context_map &) const;
featureset_ptr features_with_context(query const& q, processor_context_ptr ctx) const;
featureset_ptr features(query const& q) const;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
featureset_ptr features_at_point(point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;

View file

@ -37,7 +37,7 @@
using mapnik::layer_descriptor;
using mapnik::featureset_ptr;
using mapnik::query;
using mapnik::coord2d;
using mapnik::geometry::point;
using mapnik::datasource_exception;
using mapnik::datasource;
using mapnik::parameters;
@ -220,7 +220,7 @@ featureset_ptr raster_datasource::features(query const& q) const
}
}
featureset_ptr raster_datasource::features_at_point(coord2d const&, double tol) const
featureset_ptr raster_datasource::features_at_point(mapnik::geometry::point<double> const&, double tol) const
{
MAPNIK_LOG_WARN(raster) << "raster_datasource: feature_at_point not supported";

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
// boost
@ -49,7 +48,7 @@ public:
datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(const mapnik::query& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::featureset_ptr features_at_point(mapnik::geometry::point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;

View file

@ -258,7 +258,7 @@ featureset_ptr shape_datasource::features(query const& q) const
}
}
featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol) const
featureset_ptr shape_datasource::features_at_point(point<double> const& pt, double tol) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features_at_point");

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/value_types.hpp>
@ -48,7 +47,7 @@ using mapnik::parameters;
using mapnik::query;
using mapnik::featureset_ptr;
using mapnik::layer_descriptor;
using mapnik::coord2d;
using mapnik::geometry::point;
class shape_datasource : public datasource
{
@ -58,7 +57,7 @@ public:
datasource::datasource_t type() const;
static const char * name();
featureset_ptr features(query const& q) const;
featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
featureset_ptr features_at_point(point<double> const& pt, double tol = 0) const;
box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;

View file

@ -41,7 +41,7 @@
#include <boost/tokenizer.hpp>
using mapnik::box2d;
using mapnik::coord2d;
using mapnik::geometry::point;
using mapnik::query;
using mapnik::featureset_ptr;
using mapnik::layer_descriptor;
@ -554,7 +554,7 @@ featureset_ptr sqlite_datasource::features(query const& q) const
return featureset_ptr();
}
featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double tol) const
featureset_ptr sqlite_datasource::features_at_point(mapnik::geometry::point<double> const& pt, double tol) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::features_at_point");

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/wkb.hpp>
#include <mapnik/value_types.hpp>
@ -53,7 +52,7 @@ public:
datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::featureset_ptr features_at_point(mapnik::geometry::point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;

View file

@ -287,9 +287,9 @@ mapnik::featureset_ptr topojson_datasource::features(mapnik::query const& q) con
return mapnik::featureset_ptr();
}
mapnik::featureset_ptr topojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
mapnik::featureset_ptr topojson_datasource::features_at_point(mapnik::geometry::point<double> const& pt, double tol) const
{
mapnik::box2d<double> query_bbox(pt, pt);
mapnik::box2d<double> query_bbox(pt.x, pt.y, pt.x, pt.y);
query_bbox.pad(tol);
mapnik::query q(query_bbox);
for (auto const& attr_info : desc_.get_descriptors())

View file

@ -29,7 +29,6 @@
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/json/topology.hpp>
@ -64,7 +63,7 @@ public:
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::featureset_ptr features_at_point(mapnik::geometry::point<double> const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource_geometry_t> get_geometry_type() const;

View file

@ -395,7 +395,7 @@ struct agg_render_marker_visitor
renderer_base renb(pixf);
box2d<double> const& bbox = marker.get_data()->bounding_box();
coord<double,2> c = bbox.center();
auto c = bbox.center();
// center the svg marker on '0,0'
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
// apply symbol transformation to get to map space

View file

@ -26,6 +26,7 @@
namespace mapnik {
template class box2d<int>;
template class box2d<std::int64_t>;
template class box2d<float>;
template class box2d<double>;

View file

@ -228,8 +228,8 @@ struct cairo_render_marker_visitor
agg::trans_affine marker_tr = tr_;
if (recenter_)
{
coord<double,2> c = bbox.center();
marker_tr = agg::trans_affine_translation(-c.x,-c.y);
auto c = bbox.center();
marker_tr = agg::trans_affine_translation(-c.x, -c.y);
marker_tr *= tr_;
}
marker_tr *= agg::trans_affine_scaling(common_.scale_factor_);

View file

@ -29,7 +29,7 @@ namespace mapnik {
namespace geometry {
template MAPNIK_DECL geometry<double> reproject_copy(geometry<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
template MAPNIK_DECL geometry_empty reproject_copy(geometry_empty const& geom, proj_transform const& proj_trans, unsigned int & n_err);
template MAPNIK_DECL geometry_empty<double> reproject_copy(geometry_empty<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
template MAPNIK_DECL point<double> reproject_copy(point<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
template MAPNIK_DECL line_string<double> reproject_copy(line_string<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
template MAPNIK_DECL polygon<double> reproject_copy(polygon<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
@ -39,7 +39,7 @@ template MAPNIK_DECL multi_polygon<double> reproject_copy(multi_polygon<double>
template MAPNIK_DECL geometry_collection<double> reproject_copy(geometry_collection<double> const& geom, proj_transform const& proj_trans, unsigned int & n_err);
template MAPNIK_DECL geometry<double> reproject_copy(geometry<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
template MAPNIK_DECL geometry_empty reproject_copy(geometry_empty const& geom, projection const& source, projection const& dest, unsigned int & n_err);
template MAPNIK_DECL geometry_empty<double> reproject_copy(geometry_empty<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
template MAPNIK_DECL point<double> reproject_copy(point<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
template MAPNIK_DECL line_string<double> reproject_copy(line_string<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
template MAPNIK_DECL polygon<double> reproject_copy(polygon<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
@ -49,7 +49,7 @@ template MAPNIK_DECL multi_polygon<double> reproject_copy(multi_polygon<double>
template MAPNIK_DECL geometry_collection<double> reproject_copy(geometry_collection<double> const& geom, projection const& source, projection const& dest, unsigned int & n_err);
template MAPNIK_DECL bool reproject(geometry<double> & geom, proj_transform const& proj_trans);
template MAPNIK_DECL bool reproject(geometry_empty & geom, proj_transform const& proj_trans);
template MAPNIK_DECL bool reproject(geometry_empty<double> & geom, proj_transform const& proj_trans);
template MAPNIK_DECL bool reproject(point<double> & geom, proj_transform const& proj_trans);
template MAPNIK_DECL bool reproject(line_string<double> & geom, proj_transform const& proj_trans);
template MAPNIK_DECL bool reproject(polygon<double> & geom, proj_transform const& proj_trans);
@ -59,7 +59,7 @@ template MAPNIK_DECL bool reproject(multi_polygon<double> & geom, proj_transform
template MAPNIK_DECL bool reproject(geometry_collection<double> & geom, proj_transform const& proj_trans);
template MAPNIK_DECL bool reproject(geometry<double> & geom, projection const& source, projection const& dest);
template MAPNIK_DECL bool reproject(geometry_empty & geom, projection const& source, projection const& dest);
template MAPNIK_DECL bool reproject(geometry_empty<double> & geom, projection const& source, projection const& dest);
template MAPNIK_DECL bool reproject(point<double> & geom, projection const& source, projection const& dest);
template MAPNIK_DECL bool reproject(line_string<double> & geom, projection const& source, projection const& dest);
template MAPNIK_DECL bool reproject(polygon<double> & geom, projection const& source, projection const& dest);

View file

@ -163,8 +163,8 @@ struct grid_render_marker_visitor
ras_ptr_->reset();
box2d<double> const& bbox = marker.get_data()->bounding_box();
coord<double,2> c = bbox.center();
auto const& bbox = marker.get_data()->bounding_box();
auto c = bbox.center();
// center the svg marker on '0,0'
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
// apply symbol transformation to get to map space

View file

@ -41,6 +41,7 @@
#include <mapnik/text/font_library.hpp>
#include <mapnik/util/file_io.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/geometry.hpp>
// stl
#include <stdexcept>
@ -499,7 +500,7 @@ void Map::set_base_path(std::string const& base)
void Map::zoom(double factor)
{
coord2d center = current_extent_.center();
auto center = current_extent_.center();
double w = factor * current_extent_.width();
double h = factor * current_extent_.height();
current_extent_ = box2d<double>(center.x - 0.5 * w,
@ -729,7 +730,7 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const
throw std::runtime_error(s.str());
}
double tol = (map_ex.maxx() - map_ex.minx()) / static_cast<double>(width_) * 3;
featureset_ptr fs = ds->features_at_point(mapnik::coord2d(x,y), tol);
featureset_ptr fs = ds->features_at_point(mapnik::geometry::point<double>(x,y), tol);
MAPNIK_LOG_DEBUG(map) << "map: Query at point tol=" << tol << "(" << x << "," << y << ")";
if (fs)
{

View file

@ -121,7 +121,7 @@ featureset_ptr memory_datasource::features(const query& q) const
}
featureset_ptr memory_datasource::features_at_point(coord2d const& pt, double tol) const
featureset_ptr memory_datasource::features_at_point(geometry::point<double> const& pt, double tol) const
{
box2d<double> box = box2d<double>(pt.x, pt.y, pt.x, pt.y);
box.pad(tol);

View file

@ -25,7 +25,6 @@
#include <mapnik/box2d.hpp>
#include <mapnik/projection.hpp>
#include <mapnik/proj_transform.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/util/is_clockwise.hpp>
#ifdef MAPNIK_USE_PROJ4
@ -103,7 +102,7 @@ bool proj_transform::forward (geometry::point<double> & p) const
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();
if (size == 0) return 0;
@ -244,7 +243,7 @@ bool proj_transform::backward (geometry::point<double> & p) const
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();
if (size == 0) return 0;
@ -335,7 +334,7 @@ bool proj_transform::backward (box2d<double> & box) const
}
// Returns points in clockwise order. This allows us to do anti-meridian checks.
void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env, int points)
void envelope_points(std::vector<geometry::point<double>> & coords, box2d<double>& env, int points)
{
double width = env.width();
double height = env.height();
@ -353,21 +352,22 @@ void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env
double ystep = height / steps;
coords.resize(points);
for (int i=0; i<steps; i++) {
for (int i = 0; i < steps; ++i)
{
// top: left>right
coords[i] = coord<double, 2>(env.minx() + i * xstep, env.maxy());
coords[i] = geometry::point<double>(env.minx() + i * xstep, env.maxy());
// right: top>bottom
coords[i + steps] = coord<double, 2>(env.maxx(), env.maxy() - i * ystep);
coords[i + steps] = geometry::point<double>(env.maxx(), env.maxy() - i * ystep);
// bottom: right>left
coords[i + steps * 2] = coord<double, 2>(env.maxx() - i * xstep, env.miny());
coords[i + steps * 2] = geometry::point<double>(env.maxx() - i * xstep, env.miny());
// left: bottom>top
coords[i + steps * 3] = coord<double, 2>(env.minx(), env.miny() + i * ystep);
coords[i + steps * 3] = geometry::point<double>(env.minx(), env.miny() + i * ystep);
}
}
box2d<double> calculate_bbox(std::vector<coord<double,2> > & points) {
std::vector<coord<double,2> >::iterator it = points.begin();
std::vector<coord<double,2> >::iterator it_end = points.end();
box2d<double> calculate_bbox(std::vector<geometry::point<double> > & points) {
std::vector<geometry::point<double> >::iterator it = points.begin();
std::vector<geometry::point<double> >::iterator it_end = points.end();
box2d<double> env(*it, *(++it));
for (; it!=it_end; ++it) {
@ -393,15 +393,13 @@ bool proj_transform::backward(box2d<double>& env, int points) const
return backward(env);
}
std::vector<coord<double,2> > coords;
std::vector<geometry::point<double>> coords;
envelope_points(coords, env, points); // this is always clockwise
double z;
for (std::vector<coord<double,2> >::iterator it = coords.begin(); it!=coords.end(); ++it) {
z = 0;
if (!backward(it->x, it->y, z)) {
return false;
}
for (auto & pt : coords)
{
double z = 0;
if (!backward(pt.x, pt.y, z)) return false;
}
box2d<double> result = calculate_bbox(coords);
@ -432,15 +430,13 @@ bool proj_transform::forward(box2d<double>& env, int points) const
return forward(env);
}
std::vector<coord<double,2> > coords;
std::vector<geometry::point<double>> coords;
envelope_points(coords, env, points); // this is always clockwise
double z;
for (std::vector<coord<double,2> >::iterator it = coords.begin(); it!=coords.end(); ++it) {
z = 0;
if (!forward(it->x, it->y, z)) {
return false;
}
for (auto & pt : coords)
{
double z = 0;
if (!forward(pt.x, pt.y, z)) return false;
}
box2d<double> result = calculate_bbox(coords);

View file

@ -187,7 +187,7 @@ struct render_marker_symbolizer_visitor
box2d<double> const& bbox = mark.bounding_box();
mapnik::image_rgba8 const& marker = mark.get_data();
// - clamp sizes to > 4 pixels of interactivity
coord2d center = bbox.center();
auto center = bbox.center();
agg::trans_affine_translation recenter(-center.x, -center.y);
agg::trans_affine marker_trans = recenter * image_tr;
raster_dispatch_type rasterizer_dispatch(marker,

View file

@ -52,9 +52,9 @@ void render_pattern<image_rgba8>(rasterizer & ras,
using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>;
agg::scanline_u8 sl;
mapnik::box2d<double> const& bbox = marker.bounding_box() * tr;
mapnik::coord<double,2> c = bbox.center();
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
auto const& bbox = marker.bounding_box() * tr;
auto c = bbox.center();
agg::trans_affine mtx = agg::trans_affine_translation(-c.x, -c.y);
mtx.translate(0.5 * bbox.width(), 0.5 * bbox.height());
mtx = tr * mtx;

View file

@ -110,7 +110,7 @@ struct split_multi_geometries
split_multi_geometries(container_type & cont)
: cont_(cont) { }
void operator() (geometry::geometry_empty const&) const {}
void operator() (geometry::geometry_empty<double> const&) const {}
void operator() (geometry::multi_point<double> const& multi_pt) const
{
for ( auto const& pt : multi_pt )

View file

@ -82,7 +82,7 @@ public:
mapnik::geometry::geometry<double> read()
{
mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty();
mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty<double>();
// Read the metadata bytes, populating all the
// information about optional fields, extended (z/m) dimensions
// expansion factors and so on

View file

@ -119,7 +119,7 @@ public:
mapnik::geometry::geometry<double> read()
{
mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty();
mapnik::geometry::geometry<double> geom = mapnik::geometry::geometry_empty<double>();
int type = read_integer();
switch (type)
{

View file

@ -1,25 +1,9 @@
#include "catch.hpp"
#include <mapnik/coord.hpp>
#include <mapnik/box2d.hpp>
#include "agg_trans_affine.h"
TEST_CASE("box2d") {
SECTION("coord init") {
auto c = mapnik::coord2d(100, 100);
REQUIRE(c.x == 100);
REQUIRE(c.y == 100);
}
SECTION("coord multiplication") {
auto c = mapnik::coord2d(100, 100);
c *= 2;
REQUIRE(c.x == 200);
REQUIRE(c.y == 200);
}
SECTION("envelope init") {
auto e = mapnik::box2d<double>(100, 100, 200, 200);
@ -171,9 +155,9 @@ SECTION("mapnik::box2d intersects")
mapnik::box2d<double> b2(100.001,100,200,200);
CHECK(!b0.intersects(b2));
CHECK(!b2.intersects(b0));
// coord
CHECK(b0.intersects(mapnik::coord<double,2>(100,100)));
CHECK(!b0.intersects(mapnik::coord<double,2>(100.001,100)));
// geometry::point<T>
CHECK(b0.intersects(mapnik::geometry::point<double>(100,100)));
CHECK(!b0.intersects(mapnik::geometry::point<double>(100.001,100)));
}
SECTION("mapnik::box2d intersect")
@ -192,7 +176,7 @@ SECTION("mapnik::box2d re_center")
mapnik::box2d<double> b(0, 0, 100, 100);
b.re_center(0, 0);
CHECK(b == mapnik::box2d<double>(-50, -50, 50, 50));
b.re_center(mapnik::coord2d(50,50));
b.re_center(mapnik::geometry::point<double>(50,50));
CHECK(b == mapnik::box2d<double>(0, 0, 100, 100));
}

View file

@ -283,7 +283,8 @@ TEST_CASE("csv") {
CHECK(count_features(all_features(ds)) == 2);
auto fs = all_features(ds);
auto fs2 = ds->features_at_point(ds->envelope().center(),10000);
auto pt = ds->envelope().center();
auto fs2 = ds->features_at_point(pt, 10000);
REQUIRE(fs != nullptr);
auto feature = fs->next();
auto feature2 = fs2->next();

View file

@ -121,48 +121,53 @@ inline void require_attributes(mapnik::feature_ptr feature,
}
namespace detail {
struct feature_count {
template <typename T>
std::size_t operator()(T const &geom) const {
template <typename T>
struct feature_count
{
template <typename U>
std::size_t operator()(U const &geom) const
{
return mapnik::util::apply_visitor(*this, geom);
}
std::size_t operator()(mapnik::geometry::geometry_empty const &) const {
std::size_t operator()(mapnik::geometry::geometry_empty<T> const &) const
{
return 0;
}
template <typename T>
std::size_t operator()(mapnik::geometry::point<T> const &) const {
std::size_t operator()(mapnik::geometry::point<T> const &) const
{
return 1;
}
template <typename T>
std::size_t operator()(mapnik::geometry::line_string<T> const &) const {
std::size_t operator()(mapnik::geometry::line_string<T> const &) const
{
return 1;
}
template <typename T>
std::size_t operator()(mapnik::geometry::polygon<T> const &) const {
std::size_t operator()(mapnik::geometry::polygon<T> const &) const
{
return 1;
}
template <typename T>
std::size_t operator()(mapnik::geometry::multi_point<T> const &mp) const {
std::size_t operator()(mapnik::geometry::multi_point<T> const &mp) const
{
return mp.size();
}
template <typename T>
std::size_t operator()(mapnik::geometry::multi_line_string<T> const &mls) const {
std::size_t operator()(mapnik::geometry::multi_line_string<T> const &mls) const
{
return mls.size();
}
template <typename T>
std::size_t operator()(mapnik::geometry::multi_polygon<T> const &mp) const {
std::size_t operator()(mapnik::geometry::multi_polygon<T> const &mp) const
{
return mp.size();
}
template <typename T>
std::size_t operator()(mapnik::geometry::geometry_collection<T> const &col) const {
std::size_t operator()(mapnik::geometry::geometry_collection<T> const &col) const
{
std::size_t sum = 0;
for (auto const &geom : col) {
sum += operator()(geom);
@ -174,7 +179,7 @@ struct feature_count {
template <typename T>
inline std::size_t feature_count(mapnik::geometry::geometry<T> const &g) {
return detail::feature_count()(g);
return detail::feature_count<T>()(g);
}
inline void require_geometry(mapnik::feature_ptr feature,

View file

@ -284,7 +284,8 @@ TEST_CASE("geojson") {
query.add_property_name(field.get_name());
}
auto features = ds->features(query);
auto features2 = ds->features_at_point(ds->envelope().center(),0);
auto pt = ds->envelope().center();
auto features2 = ds->features_at_point(pt, 0);
REQUIRE(features != nullptr);
REQUIRE(features2 != nullptr);
auto feature = features->next();
@ -341,7 +342,8 @@ TEST_CASE("geojson") {
query.add_property_name(field.get_name());
}
auto features = ds->features(query);
auto features2 = ds->features_at_point(ds->envelope().center(),10);
auto pt = ds->envelope().center();
auto features2 = ds->features_at_point(pt, 10);
auto bounding_box = ds->envelope();
mapnik::box2d<double> bbox;
mapnik::value_integer count = 0;

View file

@ -207,7 +207,7 @@ TEST_CASE("postgis") {
auto ds = mapnik::datasource_cache::instance().create(params);
REQUIRE(ds != nullptr);
auto featureset = ds->features_at_point(mapnik::coord2d(1, 1));
auto featureset = ds->features_at_point(mapnik::geometry::point<double>(1, 1));
mapnik::feature_ptr feature;
while ((bool(feature = featureset->next()))) {
REQUIRE(feature->get(2).to_string() == feature->get("col_text").to_string());

View file

@ -1,4 +1,3 @@
#include "catch.hpp"
#include <mapnik/geometry_centroid.hpp>
@ -7,7 +6,7 @@ TEST_CASE("geometry centroid") {
SECTION("empty geometry") {
mapnik::geometry::geometry_empty geom;
mapnik::geometry::geometry_empty<double> geom;
mapnik::geometry::point<double> centroid;
REQUIRE(!mapnik::geometry::centroid(geom, centroid));
}

View file

@ -21,7 +21,7 @@ void envelope_test()
}
{
// Test empty geom
geometry<coord_type> geom = mapnik::geometry::geometry_empty();
geometry<coord_type> geom = mapnik::geometry::geometry_empty<coord_type>();
mapnik::box2d<coord_type> bbox = mapnik::geometry::envelope(geom);
REQUIRE_FALSE( bbox.valid() );
}

View file

@ -106,7 +106,8 @@ struct geometry_equal_visitor
REQUIRE(false);
}
void operator() (geometry_empty const&, geometry_empty const&) const
template <typename T>
void operator() (geometry_empty<T> const&, geometry_empty<T> const&) const
{
REQUIRE(true);
}
@ -119,7 +120,7 @@ struct geometry_equal_visitor
}
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())
{
@ -149,12 +150,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>
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>
void operator() (multi_line_string<T> const& mls1, multi_line_string<T> const& mls2) const
{

View file

@ -1,4 +1,3 @@
#include "catch.hpp"
#include <boost/version.hpp>
@ -11,7 +10,7 @@ TEST_CASE("geometry is_simple") {
#if BOOST_VERSION >= 105800
SECTION("point") {
mapnik::geometry::geometry_empty empty;
mapnik::geometry::geometry_empty<double> empty;
CHECK( mapnik::geometry::is_simple(empty) );
}

View file

@ -1,4 +1,3 @@
#include "catch.hpp"
#include <mapnik/geometry.hpp>
@ -11,7 +10,7 @@ TEST_CASE("geometry is_valid") {
SECTION("empty geometry") {
mapnik::geometry::geometry_empty empty;
mapnik::geometry::geometry_empty<double> empty;
CHECK( mapnik::geometry::is_valid(empty) );
std::string message;
CHECK( mapnik::geometry::is_valid(empty, message) );

View file

@ -1,4 +1,3 @@
#include "catch.hpp"
#include "geometry_equal.hpp"
@ -16,10 +15,10 @@ SECTION("test_projection_4326_3857 - Empty Geometry Object") {
mapnik::projection dest("+init=epsg:3857");
mapnik::proj_transform proj_trans(source, dest);
{
geometry_empty geom;
geometry_empty<double> geom;
unsigned int err = 0;
// Test Standard Transform
geometry_empty new_geom = reproject_copy(geom, proj_trans, err);
geometry_empty<double> new_geom = reproject_copy(geom, proj_trans, err);
REQUIRE(err == 0);
// Transform providing projections not transfrom
new_geom = reproject_copy(geom, source, dest, err);
@ -42,20 +41,20 @@ SECTION("test_projection_4326_3857 - Empty Geometry in Geometry Variant") {
mapnik::projection dest("+init=epsg:3857");
mapnik::proj_transform proj_trans(source, dest);
{
geometry<double> geom = geometry_empty();
geometry<double> geom = geometry_empty<double>();
unsigned int err = 0;
// Test Standard Transform
geometry<double> new_geom = reproject_copy(geom, proj_trans, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
// Transform providing projections not transfrom
new_geom = reproject_copy(geom, source, dest, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
// Transform providing projections in reverse
new_geom = reproject_copy(geom, dest, source, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
// Transform in place
REQUIRE(reproject(new_geom, proj_trans));
// Transform in place providing projections
@ -269,7 +268,7 @@ SECTION("test_projection_4326_3857 - Line_String Geometry Variant Object") {
// Reprojecting empty line string will return a geometry_empty
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
}
{
// Test Standard Transform
@ -443,7 +442,7 @@ SECTION("test_projection_4326_3857 - Polygon Geometry Variant Object") {
// Reprojecting empty poly will return a geometry_empty
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
}
{
// Test Standard Transform
@ -583,7 +582,7 @@ SECTION("test_projection_4326_3857 - Multi_Point Geometry Variant Object") {
// Reprojecting empty multi point will return a geometry_empty
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
}
{
// Test Standard Transform
@ -739,7 +738,7 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Variant Object")
// Reprojecting empty line string will return a geometry_empty
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
}
{
// Test Standard Transform
@ -921,7 +920,7 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Variant Object") {
// Reprojecting empty poly will return a geometry_empty
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
}
{
// Test Standard Transform
@ -1103,7 +1102,7 @@ SECTION("test_projection_4326_3857 - Geometry Collection Variant Object") {
// Reprojecting empty poly will return a geometry_empty
geometry<double> new_geom = reproject_copy(geom0, proj_trans1, err);
REQUIRE(err == 0);
REQUIRE(new_geom.is<geometry_empty>());
REQUIRE(new_geom.is<geometry_empty<double>>());
}
{
// Test Standard Transform

View file

@ -1,4 +1,3 @@
#include "catch.hpp"
#include <mapnik/geometry_is_empty.hpp>
@ -7,7 +6,7 @@ TEST_CASE("geometry has_empty") {
SECTION("empty geometry") {
mapnik::geometry::geometry_empty geom;
mapnik::geometry::geometry_empty<double> geom;
REQUIRE(!mapnik::geometry::has_empty(geom));
}
@ -19,7 +18,7 @@ SECTION("geometry collection") {
}
{
mapnik::geometry::geometry_collection<double> geom;
mapnik::geometry::geometry_empty geom1;
mapnik::geometry::geometry_empty<double> geom1;
geom.emplace_back(std::move(geom1));
REQUIRE(mapnik::geometry::has_empty(geom));
}

View file

@ -1,4 +1,3 @@
#include "catch.hpp"
#include <mapnik/geometry_is_empty.hpp>
@ -7,7 +6,7 @@ TEST_CASE("geometry is_empty") {
SECTION("empty geometry") {
mapnik::geometry::geometry_empty geom;
mapnik::geometry::geometry_empty<double> geom;
REQUIRE(mapnik::geometry::is_empty(geom));
}
@ -19,7 +18,7 @@ SECTION("geometry collection") {
}
{
mapnik::geometry::geometry_collection<double> geom;
mapnik::geometry::geometry_empty geom1;
mapnik::geometry::geometry_empty<double> geom1;
geom.emplace_back(std::move(geom1));
REQUIRE(!mapnik::geometry::is_empty(geom));
}

View file

@ -79,7 +79,7 @@ SECTION("wkb") {
geom = mapnik::geometry_utils::from_wkb((const char*)sp_invalid_blob,
sizeof(sp_invalid_blob) / sizeof(sp_invalid_blob[0]),
mapnik::wkbAuto);
REQUIRE(geom.is<mapnik::geometry::geometry_empty>()); // returns geometry_empty
REQUIRE(geom.is<mapnik::geometry::geometry_empty<double>>()); // returns geometry_empty
// sqlite generic wkb blob
@ -103,7 +103,7 @@ SECTION("wkb") {
geom = mapnik::geometry_utils::from_wkb((const char*)sq_invalid_blob,
sizeof(sq_invalid_blob) / sizeof(sq_invalid_blob[0]),
mapnik::wkbGeneric);
REQUIRE(geom.is<mapnik::geometry::geometry_empty>()); // returns geometry_empty
REQUIRE(geom.is<mapnik::geometry::geometry_empty<double>>()); // returns geometry_empty
}
catch (std::exception const& ex)

View file

@ -23,7 +23,7 @@ struct spatially_equal_visitor
{
using result_type = bool;
result_type operator() (mapnik::geometry::geometry_empty, mapnik::geometry::geometry_empty) const
result_type operator() (mapnik::geometry::geometry_empty<double>, mapnik::geometry::geometry_empty<double>) const
{
return true;
}

View file

@ -86,10 +86,10 @@ struct main_marker_visitor
pixfmt pixf(buf);
renderer_base renb(pixf);
mapnik::box2d<double> const& bbox = marker.get_data()->bounding_box();
mapnik::coord<double,2> c = bbox.center();
auto const& bbox = marker.get_data()->bounding_box();
auto c = bbox.center();
// center the svg marker on '0,0'
agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y);
agg::trans_affine mtx = agg::trans_affine_translation(-c.x, -c.y);
// render the marker at the center of the marker box
mtx.translate(0.5 * im.width(), 0.5 * im.height());