From 9bb20ce685e837cd85dc70aad024ef274a787e10 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 24 Mar 2016 14:50:46 +0000 Subject: [PATCH] box2d - expose value_type typedef + init(x, y) convinient method --- include/mapnik/box2d.hpp | 4 +++- src/box2d.cpp | 36 ++++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index d63908b8a..fe1822018 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -50,7 +50,8 @@ template class MAPNIK_DECL box2d boost::multipliable2, T > > > > { public: - using box2d_type = box2d; + using value_type = T; + using box2d_type = box2d; private: T minx_; T miny_; @@ -99,6 +100,7 @@ public: void re_center(T cx,T cy); void re_center(coord 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); bool from_string(std::string const& str); diff --git a/src/box2d.cpp b/src/box2d.cpp index 8e532d308..7d54233f0 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -299,33 +299,43 @@ void box2d::re_center(coord const& c) } template -void box2d::init(T x0,T y0,T x1,T y1) +void box2d::init(T x0, T y0, T x1, T y1) { - if (x0 +void box2d::init(T x, T y) +{ + init(x, y, x, y); +} + template void box2d::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()); + 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 @@ -337,7 +347,6 @@ void box2d::pad(T padding) maxy_ += padding; } - template bool box2d::from_string(std::string const& str) { @@ -346,8 +355,7 @@ bool box2d::from_string(std::string const& str) boost::spirit::ascii::space_type space; bool r = boost::spirit::qi::phrase_parse(str.begin(), str.end(), - double_ >> -lit(',') >> double_ >> -lit(',') - >> double_ >> -lit(',') >> double_, + double_ >> -lit(',') >> double_ >> -lit(',') >> double_ >> -lit(',') >> double_, space, *this); return r;