[geos-commits] r3045 - in trunk/php: . test
svn_geos at osgeo.org
svn_geos at osgeo.org
Sun Jun 20 20:44:38 EDT 2010
Author: strk
Date: 2010-06-21 00:44:38 +0000 (Mon, 21 Jun 2010)
New Revision: 3045
Modified:
trunk/php/geos.c
trunk/php/test/test.php
Log:
getGeometryN
Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c 2010-06-21 00:06:07 UTC (rev 3044)
+++ trunk/php/geos.c 2010-06-21 00:44:38 UTC (rev 3045)
@@ -205,6 +205,7 @@
PHP_METHOD(Geometry, getSRID);
PHP_METHOD(Geometry, setSRID);
PHP_METHOD(Geometry, numGeometries);
+PHP_METHOD(Geometry, getGeometryN);
static function_entry Geometry_methods[] = {
PHP_ME(Geometry, __construct, NULL, 0)
@@ -244,6 +245,7 @@
PHP_ME(Geometry, getSRID, NULL, 0)
PHP_ME(Geometry, setSRID, NULL, 0)
PHP_ME(Geometry, numGeometries, NULL, 0)
+ PHP_ME(Geometry, getGeometryN, NULL, 0)
{NULL, NULL, NULL}
};
@@ -1557,8 +1559,34 @@
RETURN_LONG(ret);
}
+/**
+ * GEOSGeometry GEOSGeometry::getGeometryN()
+ */
+PHP_METHOD(Geometry, getGeometryN)
+{
+ GEOSGeometry *geom;
+ const GEOSGeometry *c;
+ GEOSGeometry *cc;
+ long int num;
+ geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
+ &num) == FAILURE) {
+ RETURN_NULL();
+ }
+
+ c = GEOSGetGeometryN(geom, num);
+ if ( ! c ) RETURN_NULL(); /* should get an exception first */
+ cc = GEOSGeom_clone(c);
+ if ( ! cc ) RETURN_NULL(); /* should get an exception first */
+
+ object_init_ex(return_value, Geometry_ce_ptr);
+ setRelay(return_value, cc);
+}
+
+
+
/* ------ Initialization / Deinitialization / Meta ------------------ */
/* per-module initialization */
Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php 2010-06-21 00:06:07 UTC (rev 3044)
+++ trunk/php/test/test.php 2010-06-21 00:44:38 UTC (rev 3045)
@@ -1341,4 +1341,18 @@
$this->assertEquals(6, $g->numGeometries());
}
+ public function testGeometry_getGeometryN()
+ {
+ $reader = new GEOSWKTReader();
+
+ $g = $reader->read('POINT(0 0)');
+ $c = $g->getGeometryN(0);
+ $this->assertTrue( $g->equalsExact($c) );
+
+ $g = $reader->read('MULTIPOINT (0 1, 2 3)');
+ $this->assertEquals($reader->read('POINT(0 1)'), $g->getGeometryN(0));
+ $this->assertEquals($reader->read('POINT(2 3)'), $g->getGeometryN(1));
+
+ }
+
}
More information about the geos-commits
mailing list