[geos-commits] r3264 - in trunk/tests/unit: . capi

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Mar 4 11:31:07 EST 2011


Author: strk
Date: 2011-03-04 08:31:07 -0800 (Fri, 04 Mar 2011)
New Revision: 3264

Added:
   trunk/tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp
Modified:
   trunk/tests/unit/Makefile.am
Log:
GEOSRelateBoundaryNodeRule test, ticket #399 [RT-SIGTA]

Modified: trunk/tests/unit/Makefile.am
===================================================================
--- trunk/tests/unit/Makefile.am	2011-03-04 16:30:55 UTC (rev 3263)
+++ trunk/tests/unit/Makefile.am	2011-03-04 16:31:07 UTC (rev 3264)
@@ -106,6 +106,7 @@
 	capi/GEOSLineString_PointTest.cpp \
 	capi/GEOSSnapTest.cpp \
 	capi/GEOSSharedPathsTest.cpp \
+	capi/GEOSRelateBoundaryNodeRuleTest.cpp \
 	capi/GEOSRelatePatternMatchTest.cpp \
 	capi/GEOSUnaryUnionTest.cpp \
 	capi/GEOSisValidDetailTest.cpp

Added: trunk/tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp
===================================================================
--- trunk/tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp	                        (rev 0)
+++ trunk/tests/unit/capi/GEOSRelateBoundaryNodeRuleTest.cpp	2011-03-04 16:31:07 UTC (rev 3264)
@@ -0,0 +1,149 @@
+// $Id$
+// 
+// Test Suite for C-API GEOSRelateBoundaryNodeRule
+
+#include <tut.hpp>
+// geos
+#include <geos_c.h>
+// std
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+
+namespace tut
+{
+    //
+    // Test Group
+    //
+
+    // Common data used in test cases.
+    struct test_capigeosrelateboundarynoderule_data
+    {
+        GEOSGeometry* geom1_;
+        GEOSGeometry* geom2_;
+	char* pat_;
+
+        static void notice(const char *fmt, ...)
+        {
+            std::fprintf( stdout, "NOTICE: ");
+
+            va_list ap;
+            va_start(ap, fmt);
+            std::vfprintf(stdout, fmt, ap);
+            va_end(ap);
+        
+            std::fprintf(stdout, "\n");
+        }
+
+        test_capigeosrelateboundarynoderule_data()
+            : geom1_(0), geom2_(0), pat_(0)
+        {
+            initGEOS(notice, notice);
+        }       
+
+        ~test_capigeosrelateboundarynoderule_data()
+        {
+            GEOSGeom_destroy(geom1_);
+            GEOSGeom_destroy(geom2_);
+            GEOSFree(pat_);
+            finishGEOS();
+        }
+
+    };
+
+    typedef test_group<test_capigeosrelateboundarynoderule_data> group;
+    typedef group::object object;
+
+    group test_capigeosrelateboundarynoderule_group("capi::GEOSRelateBoundaryNodeRule");
+
+    //
+    // Test Cases
+    //
+
+    // Closed line touching open line on endpoint with OGC rule
+    template<>
+    template<>
+    void object::test<1>()
+    {
+        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
+        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
+        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_OGC);
+	ensure_equals(std::string(pat_), std::string("F01FFF102"));
+    }
+
+    // Closed line touching open line on endpoint with MOD2 rule
+    template<>
+    template<>
+    void object::test<2>()
+    {
+        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
+        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
+        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_, GEOSRELATE_BNR_MOD2);
+	ensure_equals(std::string(pat_), std::string("F01FFF102"));
+    }
+
+    // Closed line touching open line on endpoint with ENDPOINT rule
+    template<>
+    template<>
+    void object::test<3>()
+    {
+        geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, 10 10, 0 0)");
+        geom2_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 -10)");
+        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+		GEOSRELATE_BNR_ENDPOINT);
+	ensure_equals(std::string(pat_), std::string("FF1F0F102"));
+    }
+
+    // Noded multiline touching line on node , MOD2 rule
+    template<>
+    template<>
+    void object::test<4>()
+    {
+        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+		GEOSRELATE_BNR_MOD2);
+	ensure_equals(std::string(pat_), std::string("F01FF0102"));
+    }
+
+    // Noded multiline touching line on node , ENDPOINT rule
+    template<>
+    template<>
+    void object::test<5>()
+    {
+        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+		GEOSRELATE_BNR_ENDPOINT);
+	ensure_equals(std::string(pat_), std::string("FF1F00102"));
+    }
+
+    // Noded multiline touching line on node , MULTIVALENT ENDPOINT rule
+    // NOTE: the single line has no boundary !
+    template<>
+    template<>
+    void object::test<6>()
+    {
+        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+		GEOSRELATE_BNR_MULTIVALENT_ENDPOINT);
+	ensure_equals(std::string(pat_), std::string("0F1FFF1F2"));
+    }
+
+    // Noded multiline touching line on node , MONOVALENT ENDPOINT rule
+    template<>
+    template<>
+    void object::test<7>()
+    {
+        geom1_ = GEOSGeomFromWKT("MULTILINESTRING((0 0, 10 0),(10 0, 10 10))");
+        geom2_ = GEOSGeomFromWKT("LINESTRING(10 0, 10 -10)");
+        pat_ = GEOSRelateBoundaryNodeRule(geom1_, geom2_,
+		GEOSRELATE_BNR_MONOVALENT_ENDPOINT);
+	ensure_equals(std::string(pat_), std::string("F01FF0102"));
+    }
+
+
+
+} // namespace tut
+



More information about the geos-commits mailing list