[geos-commits] r3133 - in trunk: src/operation/sharedpaths tests/unit/operation/sharedpaths

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Nov 29 04:34:52 EST 2010


Author: strk
Date: 2010-11-29 01:34:52 -0800 (Mon, 29 Nov 2010)
New Revision: 3133

Modified:
   trunk/src/operation/sharedpaths/SharedPathsOp.cpp
   trunk/tests/unit/operation/sharedpaths/SharedPathsOpTest.cpp
Log:
Test equal lines

Modified: trunk/src/operation/sharedpaths/SharedPathsOp.cpp
===================================================================
--- trunk/src/operation/sharedpaths/SharedPathsOp.cpp	2010-11-29 09:34:41 UTC (rev 3132)
+++ trunk/src/operation/sharedpaths/SharedPathsOp.cpp	2010-11-29 09:34:52 UTC (rev 3133)
@@ -105,11 +105,16 @@
   std::auto_ptr<Geometry> full ( OverlayOp::overlayOp(
     &_g1, &_g2, OverlayOp::opINTERSECTION) );
 
+  // NOTE: intersection of equal lines yelds splitted lines, 
+  //       should we sew them back ?
+
   for (size_t i=0, n=full->getNumGeometries(); i<n; ++i)
   {
     const Geometry* sub = full->getGeometryN(i);
     const LineString* path = dynamic_cast<const LineString*>(sub);
     if ( path ) { 
+      // NOTE: we're making a copy here, wouldn't be needed
+      //       for a simple predicate
       to.push_back(_gf.createLineString(*path).release());
     }
   }

Modified: trunk/tests/unit/operation/sharedpaths/SharedPathsOpTest.cpp
===================================================================
--- trunk/tests/unit/operation/sharedpaths/SharedPathsOpTest.cpp	2010-11-29 09:34:41 UTC (rev 3132)
+++ trunk/tests/unit/operation/sharedpaths/SharedPathsOpTest.cpp	2010-11-29 09:34:52 UTC (rev 3133)
@@ -288,5 +288,39 @@
     ensure(forwDir.empty());
   }
 
+  // line-line (equals, forward)
+  template<> template<>
+  void object::test<16>()
+  {
+    GeomPtr g0(wktreader.read("LINESTRING(0 0, 5 10, 10 10)"));
+    GeomPtr g1(wktreader.read("LINESTRING(0 0, 5 10, 10 10)"));
+
+    forwDir.clear(); backDir.clear();
+    SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
+    ensure_equals(forwDir.size(), 2u);
+    ensure_equals(wktwriter.write(forwDir[0]), "LINESTRING (0 0, 5 10)"); 
+    ensure_equals(wktwriter.write(forwDir[1]), "LINESTRING (5 10, 10 10)");
+    SharedPathsOp::clearEdges(forwDir);
+
+    ensure(backDir.empty());
+  }
+
+  // line-line (equals, backward)
+  template<> template<>
+  void object::test<17>()
+  {
+    GeomPtr g0(wktreader.read("LINESTRING( 0  0, 5 10, 10 10)"));
+    GeomPtr g1(wktreader.read("LINESTRING(10 10, 5 10,  0  0)"));
+
+    forwDir.clear(); backDir.clear();
+    SharedPathsOp::sharedPathsOp(*g0, *g1, forwDir, backDir);
+    ensure_equals(backDir.size(), 2u);
+    ensure_equals(wktwriter.write(backDir[0]), "LINESTRING (0 0, 5 10)"); 
+    ensure_equals(wktwriter.write(backDir[1]), "LINESTRING (5 10, 10 10)");
+    SharedPathsOp::clearEdges(backDir);
+
+    ensure(forwDir.empty());
+  }
+
 } // namespace tut
 



More information about the geos-commits mailing list