[geos-commits] [SCM] GEOS branch master updated. 93f1a02f00e2a4714ac8658523ed89f352a9ac7f

git at osgeo.org git at osgeo.org
Fri Nov 30 12:34:17 PST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, master has been updated
       via  93f1a02f00e2a4714ac8658523ed89f352a9ac7f (commit)
      from  ee833c55b1c1466ea44fe2adbde451b486b57392 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 93f1a02f00e2a4714ac8658523ed89f352a9ac7f
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Nov 30 12:33:48 2018 -0800

    Add TestMinimumClearance.xml to test set and
    update the XMLTester to support "minclearance" and
    "minclearanceline" tests

diff --git a/tests/xmltester/CMakeLists.txt b/tests/xmltester/CMakeLists.txt
index f9004ab..2de1ffd 100644
--- a/tests/xmltester/CMakeLists.txt
+++ b/tests/xmltester/CMakeLists.txt
@@ -81,6 +81,7 @@ if(GEOS_ENABLE_TESTS)
     ${XMLTESTS_DIR}/general/TestFunctionPLPrec.xml
     ${XMLTESTS_DIR}/general/TestFunctionPP.xml
     ${XMLTESTS_DIR}/general/TestInteriorPoint.xml
+    ${XMLTESTS_DIR}/general/TestMinimumClearance.xml
     ${XMLTESTS_DIR}/general/TestPreparedPointPredicate.xml
     ${XMLTESTS_DIR}/general/TestPreparedPolygonPredicate.xml
     ${XMLTESTS_DIR}/general/TestPreparedPredicatesWithGeometryCollection.xml
diff --git a/tests/xmltester/Makefile.am b/tests/xmltester/Makefile.am
index 5a01f1b..a882f1e 100644
--- a/tests/xmltester/Makefile.am
+++ b/tests/xmltester/Makefile.am
@@ -49,6 +49,7 @@ SAFE_XMLTESTS= \
 	$(srcdir)/tests/general/TestFunctionPLPrec.xml \
 	$(srcdir)/tests/general/TestFunctionPP.xml \
 	$(srcdir)/tests/general/TestInteriorPoint.xml \
+	$(srcdir)/tests/general/TestMinimumClearance.xml \
   $(srcdir)/tests/general/TestPreparedPointPredicate.xml \
   $(srcdir)/tests/general/TestPreparedPolygonPredicate.xml \
   $(srcdir)/tests/general/TestPreparedPredicatesWithGeometryCollection.xml \
diff --git a/tests/xmltester/XMLTester.cpp b/tests/xmltester/XMLTester.cpp
index 6be7a4d..60733c0 100644
--- a/tests/xmltester/XMLTester.cpp
+++ b/tests/xmltester/XMLTester.cpp
@@ -40,6 +40,7 @@
 #include <geos/operation/buffer/BufferBuilder.h>
 #include <geos/operation/buffer/BufferParameters.h>
 #include <geos/operation/buffer/BufferOp.h>
+#include <geos/precision/MinimumClearance.h>
 #include <geos/util.h>
 #include <geos/util/Interrupt.h>
 //#include <geos/geomgraph.h>
@@ -1544,6 +1545,49 @@ XMLTester::parseTest(const tinyxml2::XMLNode* node)
             // TODO: Use a tolerance ?
             success = ( distO == distE ) ? 1 : 0;
         }
+        else if (opName=="minclearance")
+        {
+            char* rest;
+            double minclearanceE = std::strtod(opRes.c_str(), &rest);
+            if ( rest == opRes.c_str() )
+            {
+                throw std::runtime_error("malformed testcase: missing expected result in 'minclearance' op");
+            }
+
+            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
+            precision::MinimumClearance mc(g1);
+
+            double minclearanceO = mc.getDistance();
+            std::stringstream ss;
+            ss << minclearanceO;
+            actual_result = ss.str();
+
+            // Hack for Inf/1.7976931348623157E308 comparison
+            if (minclearanceO > 1.7976931348623157E308)
+                minclearanceO = 1.7976931348623157E308;
+
+            // TODO: Use a tolerance ?
+            success = ( minclearanceO == minclearanceE ) ? 1 : 0;
+        }
+        else if (opName=="minclearanceline")
+        {
+
+            double tol = 0.0000001;
+            GeomPtr lineE(parseGeometry(opRes, "expected"));
+            if (!lineE)
+            {
+                throw std::runtime_error("malformed testcase: missing expected result in 'minclearanceline' op");
+            }
+
+            geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
+            precision::MinimumClearance mc(g1);
+            std::unique_ptr<geom::Geometry> lineO = mc.getLine();
+            lineO.get()->normalize();
+            lineE.get()->normalize();
+
+            actual_result=printGeom(lineO.get());
+            success = lineE.get()->equalsExact(lineO.get(), tol) ? 1 : 0;
+        }
 
         else
         {
diff --git a/tests/xmltester/tests/general/TestMinimumClearance.xml b/tests/xmltester/tests/general/TestMinimumClearance.xml
new file mode 100644
index 0000000..d770180
--- /dev/null
+++ b/tests/xmltester/tests/general/TestMinimumClearance.xml
@@ -0,0 +1,89 @@
+<run>
+  <precisionModel type="FLOATING" />
+
+<case>
+  <desc>P - empty point</desc>
+  <a>    POINT EMPTY </a>
+<test><op name="minClearance" arg1='A' >  1.7976931348623157E308	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING EMPTY </op></test>
+</case>
+
+<case>
+  <desc>P - single point</desc>
+  <a>    POINT (100 100) </a>
+<test><op name="minClearance" arg1='A' >  1.7976931348623157E308	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING EMPTY </op></test>
+</case>
+
+<case>
+  <desc>mP - points</desc>
+  <a>    MULTIPOINT ( (100 100), (10 100) ) </a>
+<test><op name="minClearance" arg1='A' >  90	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING (100 100, 10 100) </op></test>
+</case>
+
+<case>
+  <desc>mP - two identical points</desc>
+  <a>    MULTIPOINT ( (100 100), (100 100) ) </a>
+<test><op name="minClearance" arg1='A' >  1.7976931348623157E308	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING EMPTY </op></test>
+</case>
+
+<case>
+  <desc>mP - points</desc>
+  <a>    MULTIPOINT ((100 100), (10 100), (30 100)) </a>
+<test><op name="minClearance" arg1='A' >  20	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING (10 100, 30 100) </op></test>
+</case>
+
+<case>
+  <desc>L - linestring</desc>
+  <a>    LINESTRING (100 100, 200 100, 200 200, 150 150) </a>
+<test><op name="minClearance" arg1='A' >  50	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING (150 150, 150 100)	</op></test>
+</case>
+
+<case>
+  <desc>L - empty linestring</desc>
+  <a>    LINESTRING EMPTY </a>
+<test><op name="minClearance" arg1='A' >  1.7976931348623157E308	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING EMPTY	</op></test>
+</case>
+
+<case>
+  <desc>ML - linestring</desc>
+  <a>    MULTILINESTRING ((100 100, 200 100, 200 200, 150 150), 
+  (100 200, 150 170)) </a>
+<test><op name="minClearance" arg1='A' >  14.142135623730951	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING (150 170, 160 160) </op></test>
+</case>
+
+<case>
+  <desc>A - empty polygon</desc>
+  <a>    POLYGON EMPTY </a>
+<test><op name="minClearance" arg1='A' >  1.7976931348623157E308	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING EMPTY </op></test>
+</case>
+
+<case>
+  <desc>A - single polygon #1</desc>
+  <a>    POLYGON ((100 100, 300 100, 200 200, 100 100)) </a>
+<test><op name="minClearance" arg1='A' >  100	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING (200 200, 200 100) </op></test>
+</case>
+
+<case>
+  <desc>A - single polygon #2</desc>
+  <a>    POLYGON ((300 400, 100 350, 250 320, 50 250, 298 200, 50 150, 150 100, 300 50, 300 50, 300 50, 300 400)) </a>
+<test><op name="minClearance" arg1='A' >  2	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING (298 200, 300 200) </op></test>
+</case>
+
+<case>
+  <desc>mA - multiple polygons</desc>
+  <a>    MULTIPOLYGON (((100 100, 300 100, 200 200, 100 100)), ((150 250, 250 250, 200 220, 150 250))) </a>
+<test><op name="minClearance" arg1='A' >  20	</op></test>
+<test><op name="minClearanceLine" arg1='A' >  LINESTRING (200 200, 200 220) </op></test>
+</case>
+
+</run>

-----------------------------------------------------------------------

Summary of changes:
 tests/xmltester/CMakeLists.txt                     |  1 +
 tests/xmltester/Makefile.am                        |  1 +
 tests/xmltester/XMLTester.cpp                      | 44 +++++++++++
 .../tests/general/TestMinimumClearance.xml         | 89 ++++++++++++++++++++++
 4 files changed, 135 insertions(+)
 create mode 100644 tests/xmltester/tests/general/TestMinimumClearance.xml


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list