2006-03-31 12:32:02 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
2005-06-14 17:06:59 +02:00
|
|
|
*
|
2006-03-31 12:32:02 +02:00
|
|
|
* Copyright (C) 2006 Artem Pavlenko
|
2005-06-14 17:06:59 +02:00
|
|
|
*
|
2006-03-31 12:32:02 +02:00
|
|
|
* 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,
|
2005-06-14 17:06:59 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2006-03-31 12:32:02 +02:00
|
|
|
* 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
|
2005-06-14 17:06:59 +02:00
|
|
|
*
|
2006-03-31 12:32:02 +02:00
|
|
|
*****************************************************************************/
|
2005-06-14 17:06:59 +02:00
|
|
|
|
|
|
|
//$Id: envelope.hpp 39 2005-04-10 20:39:53Z pavlenko $
|
|
|
|
|
|
|
|
#ifndef ENVELOPE_HPP
|
|
|
|
#define ENVELOPE_HPP
|
|
|
|
|
2006-03-22 16:52:29 +01:00
|
|
|
#include "config.hpp"
|
2006-08-20 20:49:22 +02:00
|
|
|
#include <iomanip>
|
2005-06-14 17:06:59 +02:00
|
|
|
#include "coord.hpp"
|
|
|
|
|
|
|
|
namespace mapnik
|
|
|
|
{
|
|
|
|
|
2006-03-22 16:52:29 +01:00
|
|
|
template <class T> class MAPNIK_DECL Envelope
|
2005-06-14 17:06:59 +02:00
|
|
|
{
|
|
|
|
public:
|
2006-08-20 20:49:22 +02:00
|
|
|
typedef Envelope<T> EnvelopeType;
|
2005-06-14 17:06:59 +02:00
|
|
|
private:
|
2006-08-20 20:49:22 +02:00
|
|
|
T minx_;
|
|
|
|
T miny_;
|
|
|
|
T maxx_;
|
|
|
|
T maxy_;
|
2005-06-14 17:06:59 +02:00
|
|
|
public:
|
2006-08-20 20:49:22 +02:00
|
|
|
Envelope();
|
|
|
|
Envelope(T minx,T miny,T maxx,T maxy);
|
|
|
|
Envelope(const coord<T,2>& c0,const coord<T,2>& c1);
|
|
|
|
Envelope(const EnvelopeType& rhs);
|
|
|
|
T minx() const;
|
|
|
|
T miny() const;
|
|
|
|
T maxx() const;
|
|
|
|
T maxy() const;
|
|
|
|
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(const coord<T,2>& c);
|
|
|
|
void expand_to_include(const EnvelopeType& other);
|
|
|
|
bool contains(const coord<T,2> &c) const;
|
|
|
|
bool contains(T x,T y) const;
|
|
|
|
bool contains(const EnvelopeType &other) const;
|
|
|
|
bool intersects(const coord<T,2> &c) const;
|
|
|
|
bool intersects(T x,T y) const;
|
|
|
|
bool intersects(const EnvelopeType &other) const;
|
|
|
|
EnvelopeType intersect(const EnvelopeType& other) const;
|
|
|
|
bool operator==(const EnvelopeType &other) const;
|
|
|
|
void re_center(T cx,T cy);
|
|
|
|
void init(T x0,T y0,T x1,T y1);
|
2005-06-14 17:06:59 +02:00
|
|
|
};
|
2005-08-31 21:43:37 +02:00
|
|
|
|
2005-06-14 17:06:59 +02:00
|
|
|
template <class charT,class traits,class T>
|
|
|
|
inline std::basic_ostream<charT,traits>&
|
|
|
|
operator << (std::basic_ostream<charT,traits>& out,
|
2006-08-20 20:49:22 +02:00
|
|
|
const Envelope<T>& e)
|
2005-06-14 17:06:59 +02:00
|
|
|
{
|
|
|
|
std::basic_ostringstream<charT,traits> s;
|
|
|
|
s.copyfmt(out);
|
|
|
|
s.width(0);
|
2006-08-20 20:49:22 +02:00
|
|
|
s <<"Envelope(" << std::setprecision(16)
|
|
|
|
<< e.minx() << "," << e.miny() <<","
|
|
|
|
<< e.maxx() << "," << e.maxy() <<")";
|
2005-06-14 17:06:59 +02:00
|
|
|
out << s.str();
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // ENVELOPE_HPP
|