diff --git a/bg_operators.cpp b/bg_operators.cpp index 64a4527d2..a0e037ff0 100644 --- a/bg_operators.cpp +++ b/bg_operators.cpp @@ -171,75 +171,3 @@ multi_polygon_type_fp operator+(const multi_polygon_type_fp& lhs, const ring_typ multi_polygon_type_fp rhs_mp{polygon_type_fp{rhs}}; return lhs + rhs_mp; } - -// It's not great to insert definitions into the bg namespace but they -// are useful for sorting and maps. - -namespace boost { namespace geometry { namespace model { namespace d2 { - -template -bool operator<( - const boost::geometry::model::d2::point_xy& x, - const boost::geometry::model::d2::point_xy& y) { - return std::tie(x.x(), x.y()) < std::tie(y.x(), y.y()); -} - -template bool operator<(const point_type_fp&, const point_type_fp&); -template bool operator<(const ::point_type&, const ::point_type&); - -template -boost::geometry::model::d2::point_xy operator-( - const boost::geometry::model::d2::point_xy& lhs, - const boost::geometry::model::d2::point_xy& rhs) { - return {lhs.x()-rhs.x(), lhs.y()-rhs.y()}; -} - -template point_type_fp operator-(const point_type_fp&, const point_type_fp&); - -template -boost::geometry::model::d2::point_xy operator+( - const boost::geometry::model::d2::point_xy& lhs, - const boost::geometry::model::d2::point_xy& rhs) { - return {lhs.x()+rhs.x(), lhs.y()+rhs.y()}; -} - -template point_type_fp operator+(const point_type_fp&, const point_type_fp&); - -template -boost::geometry::model::d2::point_xy operator/( - const boost::geometry::model::d2::point_xy& lhs, - const S& rhs) { - return {lhs.x()/static_cast(rhs), lhs.y()/static_cast(rhs)}; -} - -template point_type_fp operator/(const point_type_fp&, const double&); -template point_type_fp operator/(const point_type_fp&, const int&); - -template -boost::geometry::model::d2::point_xy operator*( - const boost::geometry::model::d2::point_xy& lhs, - const S& rhs) { - return {lhs.x()*static_cast(rhs), lhs.y()*static_cast(rhs)}; -} - -template point_type_fp operator*(const point_type_fp&, const double&); - -template -bool operator==( - const boost::geometry::model::d2::point_xy& x, - const boost::geometry::model::d2::point_xy& y) { - return std::tie(x.x(), x.y()) == std::tie(y.x(), y.y()); -} - -template bool operator==(const point_type_fp&, const point_type_fp&); - -template -bool operator!=( - const boost::geometry::model::d2::point_xy& x, - const boost::geometry::model::d2::point_xy& y) { - return std::tie(x.x(), x.y()) != std::tie(y.x(), y.y()); -} - -template bool operator!=(const point_type_fp&, const point_type_fp&); - -}}}} // namespace boost::geometry::model::d2 diff --git a/bg_operators.hpp b/bg_operators.hpp index bd2ecc280..2ca469d1f 100644 --- a/bg_operators.hpp +++ b/bg_operators.hpp @@ -53,52 +53,66 @@ bg::model::multi_polygon operator+(const bg::model::multi_polygo namespace boost { namespace geometry { namespace model { namespace d2 { template -bool operator<( +extern inline bool operator<( const boost::geometry::model::d2::point_xy& x, - const boost::geometry::model::d2::point_xy& y); + const boost::geometry::model::d2::point_xy& y) { + return std::tie(x.x(), x.y()) < std::tie(y.x(), y.y()); +} template -boost::geometry::model::d2::point_xy operator-( +extern inline boost::geometry::model::d2::point_xy operator-( const boost::geometry::model::d2::point_xy& lhs, - const boost::geometry::model::d2::point_xy& rhs); + const boost::geometry::model::d2::point_xy& rhs) { + return {lhs.x()-rhs.x(), lhs.y()-rhs.y()}; +} template -boost::geometry::model::d2::point_xy operator+( +extern inline boost::geometry::model::d2::point_xy operator+( const boost::geometry::model::d2::point_xy& lhs, - const boost::geometry::model::d2::point_xy& rhs); + const boost::geometry::model::d2::point_xy& rhs) { + return {lhs.x()+rhs.x(), lhs.y()+rhs.y()}; +} template -boost::geometry::model::d2::point_xy operator/( +extern inline boost::geometry::model::d2::point_xy operator/( const boost::geometry::model::d2::point_xy& lhs, - const S& rhs); + const S& rhs) { + return {lhs.x()/static_cast(rhs), lhs.y()/static_cast(rhs)}; +} template -boost::geometry::model::d2::point_xy operator*( +extern inline boost::geometry::model::d2::point_xy operator*( const boost::geometry::model::d2::point_xy& lhs, - const S& rhs); - -static inline point_type_fp floor(const point_type_fp& a) { - return point_type_fp(std::floor(a.x()), std::floor(a.y())); + const S& rhs) { + return {lhs.x()*static_cast(rhs), lhs.y()*static_cast(rhs)}; } template -bool operator==( +extern inline bool operator==( const boost::geometry::model::d2::point_xy& x, - const boost::geometry::model::d2::point_xy& y); + const boost::geometry::model::d2::point_xy& y) { + return std::tie(x.x(), x.y()) == std::tie(y.x(), y.y()); +} template -bool operator!=( +extern inline bool operator!=( const boost::geometry::model::d2::point_xy& x, - const boost::geometry::model::d2::point_xy& y); + const boost::geometry::model::d2::point_xy& y) { + return std::tie(x.x(), x.y()) != std::tie(y.x(), y.y()); +} + +extern inline point_type_fp floor(const point_type_fp& a) { + return point_type_fp(std::floor(a.x()), std::floor(a.y())); +} template -static std::ostream& operator<<(std::ostream& out, const bg::model::d2::point_xy& t) { +extern inline std::ostream& operator<<(std::ostream& out, const bg::model::d2::point_xy& t) { out << bg::wkt(t); return out; } template -static std::ostream& operator<<(std::ostream& out, const bg::model::linestring& t) { +extern inline std::ostream& operator<<(std::ostream& out, const bg::model::linestring& t) { out << bg::wkt(t); return out; }