[geos-commits] r3596 - trunk/include/geos/noding

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Apr 5 10:23:15 EDT 2012


Author: strk
Date: 2012-04-05 07:23:15 -0700 (Thu, 05 Apr 2012)
New Revision: 3596

Modified:
   trunk/include/geos/noding/NodedSegmentString.h
Log:
Generalize NodedSegmentString::getNodedSubstrings

Modified: trunk/include/geos/noding/NodedSegmentString.h
===================================================================
--- trunk/include/geos/noding/NodedSegmentString.h	2012-04-05 14:14:41 UTC (rev 3595)
+++ trunk/include/geos/noding/NodedSegmentString.h	2012-04-05 14:23:15 UTC (rev 3596)
@@ -58,18 +58,26 @@
 {
 public:
 
-    static void getNodedSubstrings(SegmentString::ConstVect* segStrings,
+    // TODO: provide a templated method using an output iterator
+    template <class II>
+    static void getNodedSubstrings(II from, II too_far, 
         SegmentString::NonConstVect* resultEdgelist)
     {
-        for (ConstVect::size_type i=0, n=segStrings->size(); i<n; i++)
+        for (II i=from; i != too_far; ++i)
         {
-            NodedSegmentString const* nss = 
-                static_cast<NodedSegmentString const*>((*segStrings)[i]);
-
-            const_cast<NodedSegmentString*>(nss)->getNodeList().addSplitEdges( resultEdgelist);
+            NodedSegmentString * nss = dynamic_cast<NodedSegmentString*>(*i);
+            assert(nss);
+            nss->getNodeList().addSplitEdges(resultEdgelist);
         }
     }
 
+    template <class C>
+    static void getNodedSubstrings(C *segStrings,
+        SegmentString::NonConstVect* resultEdgelist)
+    {
+        getNodedSubstrings(segStrings->begin(), segStrings->end(), resultEdgelist);
+    }
+
 	static void getNodedSubstrings(const SegmentString::NonConstVect& segStrings,
 			SegmentString::NonConstVect* resultEdgeList);
 



More information about the geos-commits mailing list