[geos-commits] r3258 - in trunk: include/geos/operation/valid src/operation/valid tests/xmltester/tests/general

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Mar 2 08:13:50 EST 2011


Author: strk
Date: 2011-03-02 05:13:50 -0800 (Wed, 02 Mar 2011)
New Revision: 3258

Modified:
   trunk/include/geos/operation/valid/IsValidOp.h
   trunk/src/operation/valid/IsValidOp.cpp
   trunk/tests/xmltester/tests/general/TestValid.xml
Log:
Sync IsValidOp and related XML testcase to JTS-1.12

Modified: trunk/include/geos/operation/valid/IsValidOp.h
===================================================================
--- trunk/include/geos/operation/valid/IsValidOp.h	2011-03-02 12:46:57 UTC (rev 3257)
+++ trunk/include/geos/operation/valid/IsValidOp.h	2011-03-02 13:13:50 UTC (rev 3258)
@@ -15,7 +15,7 @@
  *
  **********************************************************************
  *
- * Last port: operation/valid/IsValidOp.java rev. 38 (JTS-1.11+)
+ * Last port: operation/valid/IsValidOp.java r335 (JTS-1.12)
  *
  **********************************************************************/
 
@@ -214,6 +214,14 @@
 	 */
 	static bool isValid(const geom::Coordinate &coord);
 
+	/**
+	 * Tests whether a {@link Geometry} is valid.
+	 * 
+	 * @param geom the Geometry to test
+	 * @return true if the geometry is valid
+	 */
+	static bool isValid(const geom::Geometry &geom);
+
 	IsValidOp(const geom::Geometry *geom)
 		:
 		parentGeometry(geom),

Modified: trunk/src/operation/valid/IsValidOp.cpp
===================================================================
--- trunk/src/operation/valid/IsValidOp.cpp	2011-03-02 12:46:57 UTC (rev 3257)
+++ trunk/src/operation/valid/IsValidOp.cpp	2011-03-02 13:13:50 UTC (rev 3258)
@@ -16,7 +16,7 @@
  *
  **********************************************************************
  *
- * Last port: operation/valid/IsValidOp.java rev. 38 (JTS-1.11+)
+ * Last port: operation/valid/IsValidOp.java r335 (JTS-1.12)
  *
  **********************************************************************/
 
@@ -90,14 +90,7 @@
 	return validErr==NULL;
 }
 
-/*
- * Checks whether a coordinate is valid for processing.
- * Coordinates are valid iff their x and y coordinates are in the
- * range of the floating point representation.
- *
- * @param coord the coordinate to validate
- * @return <code>true</code> if the coordinate is valid
- */
+/* static public */
 bool
 IsValidOp::isValid(const Coordinate &coord)
 {
@@ -106,6 +99,14 @@
 	return true;
 }
 
+/* static public */
+bool
+IsValidOp::isValid(const Geometry &g)
+{
+  IsValidOp op(&g);
+	return op.isValid();
+}
+
 TopologyValidationError *
 IsValidOp::getValidationError()
 {

Modified: trunk/tests/xmltester/tests/general/TestValid.xml
===================================================================
--- trunk/tests/xmltester/tests/general/TestValid.xml	2011-03-02 12:46:57 UTC (rev 3257)
+++ trunk/tests/xmltester/tests/general/TestValid.xml	2011-03-02 13:13:50 UTC (rev 3258)
@@ -22,17 +22,37 @@
       <a>
     POINT(10 10)
   </a>
-      <test>
-         <op name="isValid" arg1="A">
-    true
-  </op>
-      </test>
+      <test>         <op name="isValid" arg1="A">    true  </op>      </test>
    </case>
 
    <case>
+      <desc>P - empty point</desc>
+      <a>
+    POINT EMPTY
+  </a>
+      <test>         <op name="isValid" arg1="A">    true  </op>      </test>
+   </case>
+
+   <case>
+      <desc>P - point with invalid X ordinate</desc>
+      <a>
+    POINT(NaN 10)
+  </a>
+      <test>         <op name="isValid" arg1="A">    false  </op>      </test>
+   </case>
+
+   <case>
+      <desc>P - point with invalid Y ordinate</desc>
+      <a>
+    POINT(10 NaN)
+  </a>
+      <test>         <op name="isValid" arg1="A">    false  </op>      </test>
+   </case>
+
+   <case>
       <desc>mP - no repeated points</desc>
       <a>
-    MULTIPOINT(10 10, 20 20, 30 30)
+    MULTIPOINT((10 10), (20 20), (30 30))
   </a>
       <test>
          <op name="isValid" arg1="A">    true  </op>
@@ -42,7 +62,7 @@
    <case>
       <desc>P - repeated points</desc>
       <a>
-    MULTIPOINT(10 10, 20 20, 30 30, 10 10)
+    MULTIPOINT((10 10), (20 20), (30 30), (10 10))
   </a>
       <test>
          <op name="isValid" arg1="A">    true  </op>
@@ -60,6 +80,16 @@
    </case>
 
    <case>
+      <desc>L - invalid ordinate</desc>
+      <a>
+LINESTRING (40 180, 120 120, 140 200, 200 140, NaN 200)
+  </a>
+      <test>
+         <op name="isValid" arg1="A">    false  </op>
+      </test>
+   </case>
+
+   <case>
       <desc>L - repeated points</desc>
       <a>
 LINESTRING (40 180, 120 120, 140 200, 140 200, 200 140, 240 200)
@@ -76,6 +106,14 @@
          <op name="isValid" arg1="A">      false      </op>
       </test>
    </case>
+   
+   <case>
+      <desc>mL - MultiLinestring with two identical points in first component</desc>
+      <a>MULTILINESTRING((1 1, 0 0), (0 0, 0 0))</a>
+      <test>
+         <op name="isValid" arg1="A">      false      </op>
+      </test>
+   </case>
 
    <case>
       <desc>mL - MultiLinestring with two identical points in second component</desc>
@@ -102,6 +140,14 @@
    </case>
 
    <case>
+      <desc>A - polygon with invalid point </desc>
+      <a>POLYGON ((0 0, 10 NaN, 20 0, 0 10, 0 0))</a>
+      <test>
+         <op name="isValid" arg1="A"> false </op>
+      </test>
+   </case>
+
+   <case>
       <desc>A - polygon with repeated point </desc>
       <a>POLYGON ((107 246, 107 246, 250 285, 294 137, 151 90, 15 125, 157 174, 107 246))</a>
       <test>



More information about the geos-commits mailing list