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

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Nov 30 12:30:15 PST 2015


Author: strk
Date: 2015-11-30 12:30:15 -0800 (Mon, 30 Nov 2015)
New Revision: 4124

Added:
   trunk/tests/unit/capi/GEOSMinimumWidthTest.cpp
Removed:
   trunk/tests/unit/capi/GEOSMinimumDiameterTest.cpp
Modified:
   trunk/NEWS
   trunk/capi/geos_c.cpp
   trunk/capi/geos_c.h.in
   trunk/capi/geos_ts_c.cpp
   trunk/tests/unit/Makefile.am
Log:
Rename GEOSMinimumDiameter to GEOSMinimumWidth, add docs

Patch by Nyall Dawson

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2015-11-30 12:01:42 UTC (rev 4123)
+++ trunk/NEWS	2015-11-30 20:30:15 UTC (rev 4124)
@@ -4,7 +4,7 @@
 - New things:
   - CAPI: GEOSGeom_setPrecision (#713) - PHP: Geometry->setPrecision
   - CAPI: GEOSGeom_getPrecision - PHP: Geometry->getPrecision
-  - CAPI: GEOSMinimumRotatedRectangle and GEOSMinimumDiameter
+  - CAPI: GEOSMinimumRotatedRectangle and GEOSMinimumWidth
     (#729, Nyall Dawson)
 - Improvements:
   - ...

Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp	2015-11-30 12:01:42 UTC (rev 4123)
+++ trunk/capi/geos_c.cpp	2015-11-30 20:30:15 UTC (rev 4124)
@@ -443,9 +443,9 @@
 }
 
 Geometry *
-GEOSMinimumDiameter(const Geometry *g)
+GEOSMinimumWidth(const Geometry *g)
 {
-    return GEOSMinimumDiameter_r( handle, g );
+    return GEOSMinimumWidth_r( handle, g );
 }
 
 Geometry *

Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in	2015-11-30 12:01:42 UTC (rev 4123)
+++ trunk/capi/geos_c.h.in	2015-11-30 20:30:15 UTC (rev 4124)
@@ -538,10 +538,24 @@
                                                  const GEOSGeometry* g2);
 extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
                                                const GEOSGeometry* g);
+
+/* Returns the minimum rotated rectangular POLYGON which encloses the input geometry. The rectangle
+ * has width equal to the minimum diameter, and a longer length. If the convex hill of the input is
+ * degenerate (a line or point) a LINESTRING or POINT is returned. The minimum rotated rectangle can
+ * be used as an extremely generalized representation for the given geometry.
+ */
 extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t handle,
                                                const GEOSGeometry* g);
-extern GEOSGeometry GEOS_DLL *GEOSMinimumDiameter_r(GEOSContextHandle_t handle,
+
+/* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
+ * The minimum diameter is defined to be the width of the smallest band that
+ * contains the geometry, where a band is a strip of the plane defined
+ * by two parallel lines. This can be thought of as the smallest hole that the geometry
+ * can be moved through, with a single rotation.
+ */
+extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth_r(GEOSContextHandle_t handle,
                                                const GEOSGeometry* g);
+
 extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
                                                const GEOSGeometry* g1,
                                                const GEOSGeometry* g2);
@@ -1452,8 +1466,22 @@
 extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g);
 extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
 extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g);
+
+/* Returns the minimum rotated rectangular POLYGON which encloses the input geometry. The rectangle
+ * has width equal to the minimum diameter, and a longer length. If the convex hill of the input is
+ * degenerate (a line or point) a LINESTRING or POINT is returned. The minimum rotated rectangle can
+ * be used as an extremely generalized representation for the given geometry.
+ */
 extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle(const GEOSGeometry* g);
-extern GEOSGeometry GEOS_DLL *GEOSMinimumDiameter(const GEOSGeometry* g);
+
+/* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
+ * The minimum diameter is defined to be the width of the smallest band that
+ * contains the geometry, where a band is a strip of the plane defined
+ * by two parallel lines. This can be thought of as the smallest hole that the geometry
+ * can be moved through, with a single rotation.
+ */
+extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth(const GEOSGeometry* g);
+
 extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
 extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
 extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g);

Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp	2015-11-30 12:01:42 UTC (rev 4123)
+++ trunk/capi/geos_ts_c.cpp	2015-11-30 20:30:15 UTC (rev 4124)
@@ -2044,7 +2044,7 @@
 }
 
 Geometry *
-GEOSMinimumDiameter_r(GEOSContextHandle_t extHandle, const Geometry *g)
+GEOSMinimumWidth_r(GEOSContextHandle_t extHandle, const Geometry *g)
 {
     if ( 0 == extHandle )
     {

Modified: trunk/tests/unit/Makefile.am
===================================================================
--- trunk/tests/unit/Makefile.am	2015-11-30 12:01:42 UTC (rev 4123)
+++ trunk/tests/unit/Makefile.am	2015-11-30 20:30:15 UTC (rev 4124)
@@ -132,7 +132,7 @@
 	capi/GEOSIntersectsTest.cpp \
 	capi/GEOSIntersectionTest.cpp \
 	capi/GEOSMinimumRectangleTest.cpp \
-	capi/GEOSMinimumDiameterTest.cpp \
+	capi/GEOSMinimumWidthTest.cpp \
 	capi/GEOSNearestPointsTest.cpp \
 	capi/GEOSWithinTest.cpp \
 	capi/GEOSSimplifyTest.cpp \

Deleted: trunk/tests/unit/capi/GEOSMinimumDiameterTest.cpp
===================================================================
--- trunk/tests/unit/capi/GEOSMinimumDiameterTest.cpp	2015-11-30 12:01:42 UTC (rev 4123)
+++ trunk/tests/unit/capi/GEOSMinimumDiameterTest.cpp	2015-11-30 20:30:15 UTC (rev 4124)
@@ -1,83 +0,0 @@
-//
-// Test Suite for C-API GEOSMinimumDiameter
-#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_capigeosminimumdiameter_data
-    {
-        GEOSGeometry* input_;
-        GEOSWKTWriter* wktw_;
-        char* wkt_;
-
-        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_capigeosminimumdiameter_data()
-            : input_(0), wkt_(0)
-        {
-            initGEOS(notice, notice);
-            wktw_ = GEOSWKTWriter_create();
-            GEOSWKTWriter_setTrim(wktw_, 1);
-            GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
-        }
-
-        ~test_capigeosminimumdiameter_data()
-        {
-            GEOSGeom_destroy(input_);
-            input_ = 0;
-            GEOSWKTWriter_destroy(wktw_);
-            GEOSFree(wkt_);
-            wkt_ = 0;
-            finishGEOS();
-        }
-
-    };
-
-    typedef test_group<test_capigeosminimumdiameter_data> group;
-    typedef group::object object;
-
-    group test_capigeosminimumdiameter_group("capi::GEOSMinimumDiameter");
-
-    //
-    // Test Cases
-    //
-
-    template<>
-    template<>
-    void object::test<1>()
-    {
-        input_ = GEOSGeomFromWKT("POLYGON ((0 0, 0 15, 5 10, 5 0, 0 0))");
-        ensure( 0 != input_ );
-
-        GEOSGeometry* output = GEOSMinimumDiameter(input_);
-        ensure( 0 != output );
-        ensure( 0 == GEOSisEmpty(output) );
-
-        wkt_ = GEOSWKTWriter_write(wktw_, output);
-        ensure_equals(std::string(wkt_), std::string( "LINESTRING (0 0, 5 0)"));
-
-        GEOSGeom_destroy(output);
-    }
-
-} // namespace tut

Copied: trunk/tests/unit/capi/GEOSMinimumWidthTest.cpp (from rev 4123, trunk/tests/unit/capi/GEOSMinimumDiameterTest.cpp)
===================================================================
--- trunk/tests/unit/capi/GEOSMinimumWidthTest.cpp	                        (rev 0)
+++ trunk/tests/unit/capi/GEOSMinimumWidthTest.cpp	2015-11-30 20:30:15 UTC (rev 4124)
@@ -0,0 +1,83 @@
+//
+// Test Suite for C-API GEOSMinimumWidth
+#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_capigeosminimumwidth_data
+    {
+        GEOSGeometry* input_;
+        GEOSWKTWriter* wktw_;
+        char* wkt_;
+
+        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_capigeosminimumwidth_data()
+            : input_(0), wkt_(0)
+        {
+            initGEOS(notice, notice);
+            wktw_ = GEOSWKTWriter_create();
+            GEOSWKTWriter_setTrim(wktw_, 1);
+            GEOSWKTWriter_setRoundingPrecision(wktw_, 8);
+        }
+
+        ~test_capigeosminimumwidth_data()
+        {
+            GEOSGeom_destroy(input_);
+            input_ = 0;
+            GEOSWKTWriter_destroy(wktw_);
+            GEOSFree(wkt_);
+            wkt_ = 0;
+            finishGEOS();
+        }
+
+    };
+
+    typedef test_group<test_capigeosminimumwidth_data> group;
+    typedef group::object object;
+
+    group test_capigeosminimumwidth_group("capi::GEOSMinimumWidth");
+
+    //
+    // Test Cases
+    //
+
+    template<>
+    template<>
+    void object::test<1>()
+    {
+        input_ = GEOSGeomFromWKT("POLYGON ((0 0, 0 15, 5 10, 5 0, 0 0))");
+        ensure( 0 != input_ );
+
+        GEOSGeometry* output = GEOSMinimumWidth(input_);
+        ensure( 0 != output );
+        ensure( 0 == GEOSisEmpty(output) );
+
+        wkt_ = GEOSWKTWriter_write(wktw_, output);
+        ensure_equals(std::string(wkt_), std::string( "LINESTRING (0 0, 5 0)"));
+
+        GEOSGeom_destroy(output);
+    }
+
+} // namespace tut



More information about the geos-commits mailing list