[geos-commits] r3330 - in trunk: include/geos/geomgraph src/geomgraph

svn_geos at osgeo.org svn_geos at osgeo.org
Fri May 6 14:51:30 EDT 2011


Author: strk
Date: 2011-05-06 11:51:30 -0700 (Fri, 06 May 2011)
New Revision: 3330

Modified:
   trunk/include/geos/geomgraph/EdgeIntersection.h
   trunk/include/geos/geomgraph/EdgeIntersectionList.h
   trunk/src/geomgraph/EdgeIntersection.cpp
   trunk/src/geomgraph/EdgeIntersectionList.cpp
Log:
Output operator for EdgeIntersection and EdgeIntersectionList

Modified: trunk/include/geos/geomgraph/EdgeIntersection.h
===================================================================
--- trunk/include/geos/geomgraph/EdgeIntersection.h	2011-05-06 18:51:19 UTC (rev 3329)
+++ trunk/include/geos/geomgraph/EdgeIntersection.h	2011-05-06 18:51:30 UTC (rev 3330)
@@ -96,6 +96,7 @@
 	}
 };
 
+std::ostream& operator<< (std::ostream&, const EdgeIntersection&);
 
 } // namespace geos.geomgraph
 } // namespace geos

Modified: trunk/include/geos/geomgraph/EdgeIntersectionList.h
===================================================================
--- trunk/include/geos/geomgraph/EdgeIntersectionList.h	2011-05-06 18:51:19 UTC (rev 3329)
+++ trunk/include/geos/geomgraph/EdgeIntersectionList.h	2011-05-06 18:51:30 UTC (rev 3330)
@@ -107,6 +107,8 @@
 
 };
 
+std::ostream& operator<< (std::ostream&, const EdgeIntersectionList&);
+
 } // namespace geos.geomgraph
 } // namespace geos
 

Modified: trunk/src/geomgraph/EdgeIntersection.cpp
===================================================================
--- trunk/src/geomgraph/EdgeIntersection.cpp	2011-05-06 18:51:19 UTC (rev 3329)
+++ trunk/src/geomgraph/EdgeIntersection.cpp	2011-05-06 18:51:30 UTC (rev 3330)
@@ -65,11 +65,18 @@
 EdgeIntersection::print() const
 {
 	ostringstream s;
-	s<<coord.toString()<<" seg#="<<segmentIndex<<" dist="<<dist;
+	s << *this;
 	return s.str();
 
 }
 
+std::ostream&
+operator<< (std::ostream&os, const EdgeIntersection& e)
+{
+	os << e.coord << " seg#=" << e.segmentIndex << " dist=" << e.dist;
+	return os;
+}
+
 int
 EdgeIntersection::compareTo(const EdgeIntersection *other) const
 {

Modified: trunk/src/geomgraph/EdgeIntersectionList.cpp
===================================================================
--- trunk/src/geomgraph/EdgeIntersectionList.cpp	2011-05-06 18:51:19 UTC (rev 3329)
+++ trunk/src/geomgraph/EdgeIntersectionList.cpp	2011-05-06 18:51:30 UTC (rev 3330)
@@ -26,6 +26,7 @@
 #include <geos/geom/CoordinateArraySequence.h> // shouldn't be using this
 #include <geos/geom/Coordinate.h>
 
+#include <sstream>
 #include <string>
 #include <vector>
 #include <set>
@@ -179,15 +180,23 @@
 string
 EdgeIntersectionList::print() const
 {
-	string out="Intersections: ";
-	EdgeIntersectionList::const_iterator it=begin(), endIt=end();
-	for (; it!=endIt; ++it) {
-		EdgeIntersection *ei=*it;
-		out+=ei->print();
-	}
-	return out;
+	std::stringstream ss;
+  ss << *this;
+  return ss.str();
 }
 
+std::ostream&
+operator<< (std::ostream&os, const EdgeIntersectionList& e)
+{
+  os << "Intersections: ";
+  EdgeIntersectionList::const_iterator it=e.begin(), endIt=e.end();
+  for (; it!=endIt; ++it) {
+    EdgeIntersection *ei=*it;
+    os << *ei << endl;
+  }
+  return os;
+}
+
 } // namespace geos.geomgraph
 } // namespace
 



More information about the geos-commits mailing list