Skip to content

Commit

Permalink
Add output operator for geom::Envelope class
Browse files Browse the repository at this point in the history
  • Loading branch information
strk committed Jun 30, 2017
1 parent 8d171e4 commit 281e59f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/geos/geom/Envelope.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <string>
#include <vector>
#include <ostream> // for operator<<
#include <memory>

namespace geos {
Expand Down Expand Up @@ -54,6 +55,8 @@ class GEOS_DLL Envelope {

public:

friend std::ostream& operator<< (std::ostream& os, const Envelope& cl);

typedef std::auto_ptr<Envelope> AutoPtr;

/** \brief
Expand Down Expand Up @@ -490,6 +493,9 @@ class GEOS_DLL Envelope {
/// Checks if two Envelopes are equal (2D only check)
GEOS_DLL bool operator==(const Envelope& a, const Envelope& b);

/// Output operator
GEOS_DLL std::ostream& operator<< (std::ostream& os, const Envelope& o);

} // namespace geos::geom
} // namespace geos

Expand Down
11 changes: 10 additions & 1 deletion src/geom/Envelope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,21 @@ Envelope::equals(const Envelope* other) const
other->getMaxY() == maxy;
}

/* public */
std::ostream& operator<< (std::ostream& os, const Envelope& o)
{
os << "Env[" << o.minx << ":" << o.maxx << ","
<< o.miny << ":" << o.maxy << "]";
return os;
}


/*public*/
string
Envelope::toString() const
{
ostringstream s;
s<<"Env["<<minx<<":"<<maxx<<","<<miny<<":"<<maxy<<"]";
s<<*this;
return s.str();
}

Expand Down

0 comments on commit 281e59f

Please sign in to comment.