[geos-commits] r3233 - in trunk: . include/geos/noding src/noding tests/unit/noding

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Feb 23 04:37:10 EST 2011


Author: strk
Date: 2011-02-23 01:37:10 -0800 (Wed, 23 Feb 2011)
New Revision: 3233

Modified:
   trunk/NEWS
   trunk/include/geos/noding/NodedSegmentString.h
   trunk/src/noding/NodedSegmentString.cpp
   trunk/tests/unit/noding/NodedSegmentStringTest.cpp
Log:
Fix NodedSegmentString to handle zero-length line segments correctly (via safeOctant)

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2011-02-22 21:22:19 UTC (rev 3232)
+++ trunk/NEWS	2011-02-23 09:37:10 UTC (rev 3233)
@@ -32,6 +32,8 @@
   - Fix duplicated dangles returned by Polygonizer
   - Fix SnapIfNeededOverlayOp to throw the originating exception
   - Fixed LineMerger to skip lines with only a single unique coordinate
+  - Fix NodedSegmentString to handle zero-length line segments correctly
+    (via safeOctant)
 
 Changes in 3.2.0 
 2009-12-14

Modified: trunk/include/geos/noding/NodedSegmentString.h
===================================================================
--- trunk/include/geos/noding/NodedSegmentString.h	2011-02-22 21:22:19 UTC (rev 3232)
+++ trunk/include/geos/noding/NodedSegmentString.h	2011-02-23 09:37:10 UTC (rev 3233)
@@ -4,7 +4,9 @@
  * GEOS - Geometry Engine Open Source
  * http://geos.refractions.net
  *
+ * Copyright (C) 2011 Sandro Santilli <strk at keybit.net>
  * Copyright (C) 2006 Refractions Research Inc.
+ * Copyright (C) 2001-2002 Vivid Solutions Inc.
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
@@ -14,7 +16,7 @@
  *
  **********************************************************************
  *
- * Last port: noding/NodedSegmentString.java rev. 1.2 (JTS-1.9)
+ * Last port: noding/NodedSegmentString.java r320 (JTS-1.12)
  *
  **********************************************************************/
 
@@ -190,6 +192,8 @@
 
 	geom::CoordinateSequence *pts;
 
+	static int safeOctant(const geom::Coordinate& p0, const geom::Coordinate& p1);
+
 };
 
 } // namespace geos::noding

Modified: trunk/src/noding/NodedSegmentString.cpp
===================================================================
--- trunk/src/noding/NodedSegmentString.cpp	2011-02-22 21:22:19 UTC (rev 3232)
+++ trunk/src/noding/NodedSegmentString.cpp	2011-02-23 09:37:10 UTC (rev 3233)
@@ -4,6 +4,8 @@
  * GEOS - Geometry Engine Open Source
  * http://geos.refractions.net
  *
+ * Copyright (C) 2011 Sandro Santilli <strk at keybit.net>
+ * Copyright (C) 2006 Refractions Research Inc.
  * Copyright (C) 2001-2002 Vivid Solutions Inc.
  *
  * This is free software; you can redistribute and/or modify it under
@@ -13,7 +15,7 @@
  *
  **********************************************************************
  *
- * Last port: noding/NodedSegmentString.java rev. 1.2 (JTS-1.9)
+ * Last port: noding/NodedSegmentString.java r320 (JTS-1.12)
  *
  **********************************************************************/
 
@@ -40,13 +42,22 @@
 	return nodeList;
 }
 
+/*static private*/
+int
+NodedSegmentString::safeOctant(const Coordinate& p0, const Coordinate& p1) 
+{
+  if ( p0.equals2D(p1) ) return 0;
+	return Octant::octant(p0, p1);
+}
 
+
 /*public*/
 int
 NodedSegmentString::getSegmentOctant(unsigned int index) const
 {
 	if (index >= size() - 1) return -1;
-	return Octant::octant(getCoordinate(index), getCoordinate(index+1));
+	return safeOctant(getCoordinate(index), getCoordinate(index+1));
+	//return Octant::octant(getCoordinate(index), getCoordinate(index+1));
 }
 
 /*public*/

Modified: trunk/tests/unit/noding/NodedSegmentStringTest.cpp
===================================================================
--- trunk/tests/unit/noding/NodedSegmentStringTest.cpp	2011-02-22 21:22:19 UTC (rev 3232)
+++ trunk/tests/unit/noding/NodedSegmentStringTest.cpp	2011-02-23 09:37:10 UTC (rev 3233)
@@ -93,17 +93,7 @@
 
         ensure_equals(ss->getNodeList().size(), 0u);
 
-        // this would throw an exception
-        bool octant_failed=false;
-        try
-        {
-            ss->getSegmentOctant(0);
-        }
-        catch (...)
-        {
-            octant_failed=true;
-        }
-        ensure(octant_failed);
+        ensure_equals(ss->getSegmentOctant(0), 0);
     }
 
     // test constructor with 2 different points



More information about the geos-commits mailing list