[geos-commits] r3043 - in trunk/php: . test

svn_geos at osgeo.org svn_geos at osgeo.org
Sun Jun 20 20:01:46 EDT 2010


Author: strk
Date: 2010-06-21 00:01:46 +0000 (Mon, 21 Jun 2010)
New Revision: 3043

Modified:
   trunk/php/geos.c
   trunk/php/test/test.php
Log:
getSRID, setSRID


Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2010-06-20 23:53:46 UTC (rev 3042)
+++ trunk/php/geos.c	2010-06-21 00:01:46 UTC (rev 3043)
@@ -202,7 +202,8 @@
 PHP_METHOD(Geometry, isClosed);
 PHP_METHOD(Geometry, typeName);
 PHP_METHOD(Geometry, typeId);
-
+PHP_METHOD(Geometry, getSRID);
+PHP_METHOD(Geometry, setSRID);
 PHP_METHOD(Geometry, numGeometries);
 
 static function_entry Geometry_methods[] = {
@@ -240,7 +241,8 @@
     PHP_ME(Geometry, isClosed, NULL, 0)
     PHP_ME(Geometry, typeName, NULL, 0)
     PHP_ME(Geometry, typeId, NULL, 0)
-
+    PHP_ME(Geometry, getSRID, NULL, 0)
+    PHP_ME(Geometry, setSRID, NULL, 0)
     PHP_ME(Geometry, numGeometries, NULL, 0)
     {NULL, NULL, NULL}
 };
@@ -339,19 +341,6 @@
     RETURN_STRING(ret, 0);
 }
 
-PHP_METHOD(Geometry, numGeometries)
-{
-    GEOSGeometry *geom;
-    long int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGetNumGeometries(geom);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_LONG(ret);
-}
-
 PHP_METHOD(Geometry, project)
 {
     GEOSGeometry *this;
@@ -1519,7 +1508,57 @@
     RETURN_LONG(typ);
 }
 
+/**
+ * long GEOSGeometry::getSRID()
+ */
+PHP_METHOD(Geometry, getSRID)
+{
+    GEOSGeometry *geom;
+    long int ret;
 
+    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+    ret = GEOSGetSRID(geom);
+
+    RETURN_LONG(ret);
+}
+
+/**
+ * void GEOSGeometry::setSRID(long)
+ */
+PHP_METHOD(Geometry, setSRID)
+{
+    GEOSGeometry *geom;
+    long int srid;
+
+    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
+        &srid) == FAILURE) {
+        RETURN_NULL();
+    }
+
+    GEOSSetSRID(geom, srid);
+}
+
+/**
+ * long GEOSGeometry::numGeometries()
+ */
+PHP_METHOD(Geometry, numGeometries)
+{
+    GEOSGeometry *geom;
+    long int ret;
+
+    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+    ret = GEOSGetNumGeometries(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-20 23:53:46 UTC (rev 3042)
+++ trunk/php/test/test.php	2010-06-21 00:01:46 UTC (rev 3043)
@@ -1292,4 +1292,14 @@
         $this->assertEquals(GEOS_GEOMETRYCOLLECTION, $g->typeId());
     }
 
+    public function testGeometry_srid()
+    {
+        $reader = new GEOSWKTReader();
+
+        $g = $reader->read('POINT(0 0)');
+        $this->assertEquals(0, $g->getSRID());
+        $g->setSRID(2);
+        $this->assertEquals(2, $g->getSRID());
+    }
+
 }



More information about the geos-commits mailing list