[geos-commits] r2919 - in trunk: . capi

svn_geos at osgeo.org svn_geos at osgeo.org
Sun Feb 21 12:05:42 EST 2010


Author: strk
Date: 2010-02-21 12:05:41 -0500 (Sun, 21 Feb 2010)
New Revision: 2919

Modified:
   trunk/NEWS
   trunk/capi/geos_c.h.in
   trunk/capi/geos_ts_c.cpp
Log:
Allow GEOSGetGeometryN calls against single geometries


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2010-02-21 16:27:46 UTC (rev 2918)
+++ trunk/NEWS	2010-02-21 17:05:41 UTC (rev 2919)
@@ -6,6 +6,7 @@
   - CAPI: GEOSGeom_createEmptyPoint_r, GEOSGeom_createEmptyLineString_r
           GEOSGeom_createEmptyPolygon_r, GEOSGeom_createEmptyCollection_r
   - CAPI: GEOSGeom_extractUniquePoints_r
+  - CAPI: GEOSGetGeometryN support for single geometries
 
 Changes in 3.2.0 
 

Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in	2010-02-21 16:27:46 UTC (rev 2918)
+++ trunk/capi/geos_c.h.in	2010-02-21 17:05:41 UTC (rev 2919)
@@ -770,9 +770,12 @@
                                            const GEOSGeometry* g);
 
 /*
- * Return NULL on exception, Geometry must be a Collection.
+ * Return NULL on exception.
  * Returned object is a pointer to internal storage:
  * it must NOT be destroyed directly.
+ * Up to GEOS 3.2.0 the input geometry must be a Collection, in
+ * later version it doesn't matter (getGeometryN(0) for a single will
+ * return the input).
  */
 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n);
 

Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp	2010-02-21 16:27:46 UTC (rev 2918)
+++ trunk/capi/geos_ts_c.cpp	2010-02-21 17:05:41 UTC (rev 2919)
@@ -2067,14 +2067,7 @@
 
     try
     {
-        using geos::geom::GeometryCollection;
-        const GeometryCollection *gc = dynamic_cast<const GeometryCollection *>(g1);
-        if ( ! gc )
-        {
-            handle->ERROR_MESSAGE("Argument is not a GeometryCollection");
-            return NULL;
-        }
-        return gc->getGeometryN(n);
+        return g1->getGeometryN(n);
     }
     catch (const std::exception &e)
     {



More information about the geos-commits mailing list