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

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Apr 27 03:01:25 EDT 2012


Author: strk
Date: 2012-04-27 00:01:25 -0700 (Fri, 27 Apr 2012)
New Revision: 3615

Modified:
   trunk/NEWS
   trunk/php/geos.c
   trunk/php/test/test.php
Log:
Expose GEOSNode to PHP api

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2012-04-12 09:07:02 UTC (rev 3614)
+++ trunk/NEWS	2012-04-27 07:01:25 UTC (rev 3615)
@@ -2,7 +2,7 @@
 ????-??-??
 
 - New things:
-  - CAPI: GEOSNode (#496)
+  - CAPI: GEOSNode (#496) - PHP: Geometry->node
   - GeometryPrecisionReducer class
 - C++ API changes:
   - New noding::GeometryNoder class

Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2012-04-12 09:07:02 UTC (rev 3614)
+++ trunk/php/geos.c	2012-04-27 07:01:25 UTC (rev 3615)
@@ -232,6 +232,7 @@
 PHP_METHOD(Geometry, distance);
 PHP_METHOD(Geometry, hausdorffDistance);
 PHP_METHOD(Geometry, snapTo);
+PHP_METHOD(Geometry, node);
 
 static function_entry Geometry_methods[] = {
     PHP_ME(Geometry, __construct, NULL, 0)
@@ -293,6 +294,7 @@
     PHP_ME(Geometry, distance, NULL, 0)
     PHP_ME(Geometry, hausdorffDistance, NULL, 0)
     PHP_ME(Geometry, snapTo, NULL, 0)
+    PHP_ME(Geometry, node, NULL, 0)
     {NULL, NULL, NULL}
 };
 
@@ -1899,8 +1901,23 @@
     setRelay(return_value, ret);
 }
 
+PHP_METHOD(Geometry, node)
+{
+    GEOSGeometry *this;
+    GEOSGeometry *ret;
 
+    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
 
+    ret = GEOSNode(this);
+    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
+
+    /* return_value is a zval */
+    object_init_ex(return_value, Geometry_ce_ptr);
+    setRelay(return_value, ret);
+}
+
+
+
 /* -- class GEOSWKTReader -------------------- */
 
 PHP_METHOD(WKTReader, __construct);

Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php	2012-04-12 09:07:02 UTC (rev 3614)
+++ trunk/php/test/test.php	2012-04-27 07:01:25 UTC (rev 3615)
@@ -2026,6 +2026,20 @@
             , $writer->write($snapped) );
     }
 
+    public function testGeometry_node()
+    {
+        $reader = new GEOSWKTReader();
+        $writer = new GEOSWKTWriter();
+        $writer->setTrim(true);
+
+        $g = $reader->read('LINESTRING(0 0, 10 0, 5 -5, 5 5)');
+
+        $noded = $g->node();
+        $this->assertEquals('MULTILINESTRING ((0 0, 5 0), (5 0, 10 0, 5 -5, 5 0), (5 0, 5 5))'
+            , $writer->write($noded) );
+
+    }
+
     public function testWKBWriter__construct()
     {
         $writer = new GEOSWKBWriter();



More information about the geos-commits mailing list