[prev in list] [next in list] [prev in thread] [next in thread] 

List:       geos-commits
Subject:    [geos-commits] r3054 - in trunk/php: . test
From:       svn_geos () osgeo ! org
Date:       2010-06-21 1:49:22
Message-ID: 20100621014922.5D4053906E0 () trac ! osgeo ! org
[Download RAW message or body]

Author: strk
Date: 2010-06-21 01:49:22 +0000 (Mon, 21 Jun 2010)
New Revision: 3054

Modified:
   trunk/php/geos.c
   trunk/php/test/test.php
Log:
coordinateDimension()

Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2010-06-21 01:46:52 UTC (rev 3053)
+++ trunk/php/geos.c	2010-06-21 01:49:22 UTC (rev 3054)
@@ -214,6 +214,7 @@
 PHP_METHOD(Geometry, exteriorRing);
 PHP_METHOD(Geometry, numCoordinates);
 PHP_METHOD(Geometry, dimension);
+PHP_METHOD(Geometry, coordinateDimension);
 
 static function_entry Geometry_methods[] = {
     PHP_ME(Geometry, __construct, NULL, 0)
@@ -262,6 +263,7 @@
     PHP_ME(Geometry, exteriorRing, NULL, 0)
     PHP_ME(Geometry, numCoordinates, NULL, 0)
     PHP_ME(Geometry, dimension, NULL, 0)
+    PHP_ME(Geometry, coordinateDimension, NULL, 0)
     {NULL, NULL, NULL}
 };
 
@@ -1746,7 +1748,23 @@
     RETURN_LONG(ret);
 }
 
+/**
+ * long GEOSGeometry::coordinateDimension()
+ */
+PHP_METHOD(Geometry, coordinateDimension)
+{
+    GEOSGeometry *geom;
+    long int ret;
 
+    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+    ret = GEOSGeom_getCoordinateDimension(geom);
+    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
+
+    RETURN_LONG(ret);
+}
+
+
 /* ------ Initialization / Deinitialization / Meta ------------------ */
 
 /* per-module initialization */

Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php	2010-06-21 01:46:52 UTC (rev 3053)
+++ trunk/php/test/test.php	2010-06-21 01:49:22 UTC (rev 3054)
@@ -1566,4 +1566,16 @@
         $this->assertEquals(2, $g->dimension());
     }
 
+    public function testGeometry_coordinateDimension()
+    {
+        $reader = new GEOSWKTReader();
+
+        $g = $reader->read('POINT(0 0)');
+        $this->assertEquals(2, $g->coordinateDimension());
+
+        $g = $reader->read('POINT(0 0 0)');
+        $this->assertEquals(3, $g->coordinateDimension());
+
+    }
+
 }

_______________________________________________
geos-commits mailing list
geos-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic