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

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Dec 22 04:42:40 EST 2010


Author: strk
Date: 2010-12-22 01:42:40 -0800 (Wed, 22 Dec 2010)
New Revision: 3162

Modified:
   trunk/.gitignore
   trunk/php/geos.c
   trunk/php/test/test.php
Log:
Expose GEOSRelateMatch to PHP api.

Modified: trunk/.gitignore
===================================================================
--- trunk/.gitignore	2010-12-21 08:55:29 UTC (rev 3161)
+++ trunk/.gitignore	2010-12-22 09:42:40 UTC (rev 3162)
@@ -44,3 +44,4 @@
 doc/example
 include/config.h
 include/config.h.in
+php/test/phpunit

Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2010-12-21 08:55:29 UTC (rev 3161)
+++ trunk/php/geos.c	2010-12-22 09:42:40 UTC (rev 3162)
@@ -42,12 +42,14 @@
 PHP_FUNCTION(GEOSPolygonize);
 PHP_FUNCTION(GEOSLineMerge);
 PHP_FUNCTION(GEOSSharedPaths);
+PHP_FUNCTION(GEOSRelateMatch);
 
 static function_entry geos_functions[] = {
     PHP_FE(GEOSVersion, NULL)
     PHP_FE(GEOSPolygonize, NULL)
     PHP_FE(GEOSLineMerge, NULL)
     PHP_FE(GEOSSharedPaths, NULL)
+    PHP_FE(GEOSRelateMatch, NULL)
     {NULL, NULL, NULL}
 };
 
@@ -2364,6 +2366,32 @@
     setRelay(return_value, geom_out);
 }
 
+/**
+ * bool GEOSRelateMatch(string matrix, string pattern)
+ */
+PHP_FUNCTION(GEOSRelateMatch)
+{
+    char* mat = NULL;
+    int matlen;
+    char* pat = NULL;
+    int patlen;
+    int ret;
+    zend_bool retBool;
+
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+        &mat, &matlen, &pat, &patlen) == FAILURE)
+    {
+        RETURN_NULL();
+    }
+
+    ret = GEOSRelatePatternMatch(mat, pat);
+    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
+
+    /* return_value is a zval */
+    retBool = ret;
+    RETURN_BOOL(retBool);
+}
+
 /* ------ Initialization / Deinitialization / Meta ------------------ */
 
 /* per-module initialization */

Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php	2010-12-21 08:55:29 UTC (rev 3161)
+++ trunk/php/test/test.php	2010-12-22 09:42:40 UTC (rev 3162)
@@ -2046,4 +2046,13 @@
 
     }
 
+    public function testGEOSRelateMatch()
+    {
+        $this->assertTrue(GEOSRelateMatch('0FFFFFFF2', '0FFFFFFF2'));
+        $this->assertTrue(GEOSRelateMatch('0FFFFFFF2', '0FFFFFFF*'));
+        $this->assertTrue(GEOSRelateMatch('0FFFFFFF2', 'TFFFFFFF2'));
+        $this->assertFalse(GEOSRelateMatch('0FFFFFFF2', '0FFFFFFFF'));
+    }
+
+
 }



More information about the geos-commits mailing list