[geos-commits] r3260 - in trunk/tests/xmltester: . tests/general

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Mar 2 08:45:22 EST 2011


Author: strk
Date: 2011-03-02 05:45:22 -0800 (Wed, 02 Mar 2011)
New Revision: 3260

Added:
   trunk/tests/xmltester/tests/general/TestDistance.xml
Modified:
   trunk/tests/xmltester/Makefile.am
   trunk/tests/xmltester/XMLTester.cpp
Log:
Add support for "distance" op in XMLTester, and import JTS TestDistance.xml

Modified: trunk/tests/xmltester/Makefile.am
===================================================================
--- trunk/tests/xmltester/Makefile.am	2011-03-02 13:45:13 UTC (rev 3259)
+++ trunk/tests/xmltester/Makefile.am	2011-03-02 13:45:22 UTC (rev 3260)
@@ -35,6 +35,7 @@
 	$(srcdir)/tests/general/TestCentroid.xml \
 	$(srcdir)/tests/general/TestConvexHull.xml \
 	$(srcdir)/tests/general/TestConvexHull-big.xml \
+	$(srcdir)/tests/general/TestDistance.xml \
 	$(srcdir)/tests/general/TestFunctionAAPrec.xml \
 	$(srcdir)/tests/general/TestFunctionAA.xml \
 	$(srcdir)/tests/general/TestFunctionLAPrec.xml \

Modified: trunk/tests/xmltester/XMLTester.cpp
===================================================================
--- trunk/tests/xmltester/XMLTester.cpp	2011-03-02 13:45:13 UTC (rev 3259)
+++ trunk/tests/xmltester/XMLTester.cpp	2011-03-02 13:45:22 UTC (rev 3260)
@@ -1359,7 +1359,25 @@
 			expected_result=opRes;
 
 		}
+		else if (opName=="distance")
+		{
+			char* rest;
+			double distE = std::strtod(opRes.c_str(), &rest);
+			if ( rest == opRes.c_str() )
+			{
+				throw std::runtime_error("malformed testcase: missing expected result in 'distance' op");
+			}
 
+			geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
+			geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
+			double distO = g1->distance(g2);
+			std::stringstream ss; ss << distO; 
+			actual_result = ss.str();
+
+			// TODO: Use a tolerance ?
+			success = ( distO == distE ) ? 1 : 0;
+		}
+
 		else
 		{
 			std::cerr << *curr_file << ":";

Added: trunk/tests/xmltester/tests/general/TestDistance.xml
===================================================================
--- trunk/tests/xmltester/tests/general/TestDistance.xml	                        (rev 0)
+++ trunk/tests/xmltester/tests/general/TestDistance.xml	2011-03-02 13:45:22 UTC (rev 3260)
@@ -0,0 +1,60 @@
+<run>
+  <precisionModel scale="1.0" offsetx="0.0" offsety="0.0"/>
+
+<case>
+  <desc>PeP - point to an empty point</desc>
+  <a>    POINT(10 10)  </a>
+  <b>    POINT EMPTY  </b>
+<test><op name="distance" arg1="A" arg2="B">    0.0   </op></test>
+</case>
+
+<case>
+  <desc>PP - point to point</desc>
+  <a>    POINT(10 10)  </a>
+  <b>    POINT (10 0)  </b>
+<test><op name="distance" arg1="A" arg2="B">    10.0   </op></test>
+</case>
+
+<case>
+  <desc>LL - line to line</desc>
+  <a>    LINESTRING (0 0, 0 10)  </a>
+  <b>    LINESTRING (10 0, 10 10)  </b>
+<test><op name="distance" arg1="A" arg2="B">    10.0   </op></test>
+</case>
+
+<case>
+  <desc>PA - point inside polygon</desc>
+  <a>    POINT (240 160)  </a>
+  <b>    POLYGON ((100 260, 340 180, 100 60, 180 160, 100 260))  </b>
+<test><op name="distance" arg1="A" arg2="B" >    0.0   </op></test>
+</case>
+
+<case>
+  <desc>LL - crossing linestrings</desc>
+  <a>    LINESTRING (40 300, 280 220, 60 160, 140 60)  </a>
+  <b>    LINESTRING (140 360, 260 280, 240 120, 120 160)  </b>
+<test><op name="distance" arg1="A" arg2="B" >    0.0   </op></test>
+</case>
+
+<case>
+  <desc>AA - overlapping polygons</desc>
+  <a>    POLYGON ((60 260, 260 180, 100 60, 60 160, 60 260))  </a>
+  <b>    POLYGON ((220 280, 120 160, 300 60, 360 220, 220 280))  </b>
+<test><op name="distance" arg1="A" arg2="B" >    0.0   </op></test>
+</case>
+
+<case>
+  <desc>AA - disjoint polygons</desc>
+  <a>    POLYGON ((100 320, 60 120, 240 180, 200 260, 100 320))  </a>
+  <b>    POLYGON ((420 320, 280 260, 400 100, 420 320))  </b>
+<test><op name="distance" arg1="A" arg2="B" >   71.55417527999327  </op></test>
+</case>
+
+<case>
+  <desc>mAmA - overlapping multipolygons</desc>
+  <a>    MULTIPOLYGON (((40 240, 160 320, 40 380, 40 240)),   ((100 240, 240 60, 40 40, 100 240)))  </a>
+  <b>    MULTIPOLYGON (((220 280, 120 160, 300 60, 360 220, 220 280)),   ((240 380, 280 300, 420 340, 240 380)))  </b>
+<test><op name="distance" arg1="A" arg2="B" >    0.0   </op></test>
+</case>
+
+</run>



More information about the geos-commits mailing list