added operators +,-,*,/
This commit is contained in:
parent
78f2b64f5c
commit
1988181bd7
2 changed files with 47 additions and 1 deletions
|
@ -27,12 +27,18 @@
|
|||
|
||||
// stl
|
||||
#include <iomanip>
|
||||
// boost
|
||||
#include <boost/operators.hpp>
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/coord.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
template <class T> class MAPNIK_DECL Envelope
|
||||
template <typename T> class MAPNIK_DECL Envelope
|
||||
: boost::addable<Envelope<T>,
|
||||
boost::subtractable<Envelope<T>,
|
||||
boost::dividable2<Envelope<T>, T,
|
||||
boost::multipliable2<Envelope<T>, T > > > >
|
||||
{
|
||||
public:
|
||||
typedef Envelope<T> EnvelopeType;
|
||||
|
@ -68,6 +74,12 @@ namespace mapnik {
|
|||
bool operator==(const EnvelopeType &other) const;
|
||||
void re_center(T cx,T cy);
|
||||
void init(T x0,T y0,T x1,T y1);
|
||||
|
||||
// define some operators
|
||||
EnvelopeType& operator+=(EnvelopeType const& other);
|
||||
EnvelopeType& operator-=(EnvelopeType const& other);
|
||||
EnvelopeType& operator*=(T);
|
||||
EnvelopeType& operator/=(T);
|
||||
};
|
||||
|
||||
template <class charT,class traits,class T>
|
||||
|
|
|
@ -223,7 +223,41 @@ namespace mapnik
|
|||
miny_=y1;maxy_=y0;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Envelope<T>& Envelope<T>::operator+=(Envelope<T> const& other)
|
||||
{
|
||||
expand_to_include(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Envelope<T>& Envelope<T>::operator-=(Envelope<T> const& other)
|
||||
{
|
||||
// not sure what to do here. intersect?
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Envelope<T>& Envelope<T>::operator*=(T t)
|
||||
{
|
||||
minx_ *= t;
|
||||
miny_ *= t;
|
||||
maxx_ *= t;
|
||||
maxy_ *= t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Envelope<T>& Envelope<T>::operator/=(T t)
|
||||
{
|
||||
minx_ /= t;
|
||||
miny_ /= t;
|
||||
maxx_ /= t;
|
||||
maxy_ /= t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template class Envelope<int>;
|
||||
template class Envelope<double>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue