[geos-commits] r3266 - in trunk/php: . test
svn_geos at osgeo.org
svn_geos at osgeo.org
Fri Mar 4 12:05:45 EST 2011
Author: strk
Date: 2011-03-04 09:05:44 -0800 (Fri, 04 Mar 2011)
New Revision: 3266
Modified:
trunk/php/geos.c
trunk/php/test/test.php
Log:
PHP: add relateBoundaryNodeRule method to GEOSGeometry object
Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c 2011-03-04 16:38:16 UTC (rev 3265)
+++ trunk/php/geos.c 2011-03-04 17:05:44 UTC (rev 3266)
@@ -188,6 +188,7 @@
PHP_METHOD(Geometry, pointOnSurface);
PHP_METHOD(Geometry, centroid);
PHP_METHOD(Geometry, relate);
+PHP_METHOD(Geometry, relateBoundaryNodeRule);
PHP_METHOD(Geometry, simplify); /* also does topology-preserving */
PHP_METHOD(Geometry, extractUniquePoints);
PHP_METHOD(Geometry, disjoint);
@@ -247,6 +248,7 @@
PHP_ME(Geometry, pointOnSurface, NULL, 0)
PHP_ME(Geometry, centroid, NULL, 0)
PHP_ME(Geometry, relate, NULL, 0)
+ PHP_ME(Geometry, relateBoundaryNodeRule, NULL, 0)
PHP_ME(Geometry, simplify, NULL, 0)
PHP_ME(Geometry, extractUniquePoints, NULL, 0)
PHP_ME(Geometry, disjoint, NULL, 0)
@@ -837,6 +839,36 @@
}
/**
+ * GEOSGeometry::relateBoundaryNodeRule(otherGeom, rule)
+ */
+PHP_METHOD(Geometry, relateBoundaryNodeRule)
+{
+ GEOSGeometry *this;
+ GEOSGeometry *other;
+ zval *zobj;
+ char* pat;
+ long int bnr = GEOSRELATE_BNR_OGC;
+ char* retStr;
+
+ this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ol",
+ &zobj, &bnr) == FAILURE)
+ {
+ RETURN_NULL();
+ }
+
+ other = getRelay(zobj, Geometry_ce_ptr);
+
+ /* we'll compute it */
+ pat = GEOSRelateBoundaryNodeRule(this, other, bnr);
+ if ( ! pat ) RETURN_NULL(); /* should get an exception first */
+ retStr = estrdup(pat);
+ GEOSFree(pat);
+ RETURN_STRING(retStr, 0);
+}
+
+/**
* GEOSGeometry GEOSGeometry::simplify(tolerance)
* GEOSGeometry GEOSGeometry::simplify(tolerance, preserveTopology)
*/
@@ -2542,6 +2574,19 @@
GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE,
CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("GEOSRELATE_BNR_MOD2", GEOSRELATE_BNR_MOD2,
+ CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("GEOSRELATE_BNR_OGC", GEOSRELATE_BNR_OGC,
+ CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("GEOSRELATE_BNR_ENDPOINT", GEOSRELATE_BNR_ENDPOINT,
+ CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("GEOSRELATE_BNR_MULTIVALENT_ENDPOINT",
+ GEOSRELATE_BNR_MULTIVALENT_ENDPOINT,
+ CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("GEOSRELATE_BNR_MONOVALENT_ENDPOINT",
+ GEOSRELATE_BNR_MONOVALENT_ENDPOINT,
+ CONST_CS|CONST_PERSISTENT);
+
return SUCCESS;
}
Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php 2011-03-04 16:38:16 UTC (rev 3265)
+++ trunk/php/test/test.php 2011-03-04 17:05:44 UTC (rev 3266)
@@ -35,6 +35,12 @@
$this->assertEquals(7, GEOS_GEOMETRYCOLLECTION);
$this->assertEquals(1, GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE);
+
+ $this->assertEquals(1, GEOSRELATE_BNR_MOD2);
+ $this->assertEquals(1, GEOSRELATE_BNR_OGC);
+ $this->assertEquals(2, GEOSRELATE_BNR_ENDPOINT);
+ $this->assertEquals(3, GEOSRELATE_BNR_MULTIVALENT_ENDPOINT);
+ $this->assertEquals(4, GEOSRELATE_BNR_MONOVALENT_ENDPOINT);
}
public function testWKTReader__construct()
@@ -1007,6 +1013,23 @@
}
+ public function testGeometry_relateBoundaryNodeRule()
+ {
+ $reader = new GEOSWKTReader();
+ $writer = new GEOSWKTWriter();
+ $writer->setRoundingPrecision(0);
+
+ $g = $reader->read('LINESTRING(0 0, 2 4, 5 5, 0 0)');
+ $g2 = $reader->read('POINT(0 0)');
+
+ $ret = $g->relateBoundaryNodeRule($g2, GEOSRELATE_BNR_OGC);
+ $this->assertEquals('0F1FFFFF2', $ret);
+
+ $ret = $g->relateBoundaryNodeRule($g2, GEOSRELATE_BNR_ENDPOINT);
+ $this->assertEquals('FF10FFFF2', $ret);
+
+ }
+
public function testGeometry_polygonize()
{
$reader = new GEOSWKTReader();
@@ -2157,5 +2180,4 @@
$this->assertFalse(GEOSRelateMatch('0FFFFFFF2', '0FFFFFFFF'));
}
-
}
More information about the geos-commits
mailing list