[geos-commits] r3250 - in trunk: . php php/test
svn_geos at osgeo.org
svn_geos at osgeo.org
Mon Feb 28 06:43:11 EST 2011
Author: strk
Date: 2011-02-28 03:43:11 -0800 (Mon, 28 Feb 2011)
New Revision: 3250
Modified:
trunk/NEWS
trunk/php/geos.c
trunk/php/test/test.php
Log:
Expose and test covers/coveredBy to PHP binding
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2011-02-28 11:32:25 UTC (rev 3249)
+++ trunk/NEWS 2011-02-28 11:43:11 UTC (rev 3250)
@@ -16,6 +16,7 @@
- CAPI: GEOSSharedPaths to find shared paths and their orientation
- CAPI: GEOSSnap
- CAPI: GEOSRelatePatternMatch
+ - CAPI: GEOSCovers, GEOSCoveredBy (#396)
- PHP: new PHP5 bindings based on CAPI
- C++ API changes:
- Geometry inheritance chain changed to introduce Puntal, Lineal
Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c 2011-02-28 11:32:25 UTC (rev 3249)
+++ trunk/php/geos.c 2011-02-28 11:43:11 UTC (rev 3250)
@@ -197,6 +197,8 @@
PHP_METHOD(Geometry, within);
PHP_METHOD(Geometry, contains);
PHP_METHOD(Geometry, overlaps);
+PHP_METHOD(Geometry, covers);
+PHP_METHOD(Geometry, coveredBy);
PHP_METHOD(Geometry, equals);
PHP_METHOD(Geometry, equalsExact);
PHP_METHOD(Geometry, isEmpty);
@@ -254,6 +256,8 @@
PHP_ME(Geometry, within, NULL, 0)
PHP_ME(Geometry, contains, NULL, 0)
PHP_ME(Geometry, overlaps, NULL, 0)
+ PHP_ME(Geometry, covers, NULL, 0)
+ PHP_ME(Geometry, coveredBy, NULL, 0)
PHP_ME(Geometry, equals, NULL, 0)
PHP_ME(Geometry, equalsExact, NULL, 0)
PHP_ME(Geometry, isEmpty, NULL, 0)
@@ -1071,6 +1075,60 @@
}
/**
+ * bool GEOSGeometry::covers(GEOSGeometry)
+ */
+PHP_METHOD(Geometry, covers)
+{
+ GEOSGeometry *this;
+ GEOSGeometry *other;
+ int ret;
+ zend_bool retBool;
+ zval *zobj;
+
+ this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zobj)
+ == FAILURE) {
+ RETURN_NULL();
+ }
+ other = getRelay(zobj, Geometry_ce_ptr);
+
+ ret = GEOSCovers(this, other);
+ if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
+
+ /* return_value is a zval */
+ retBool = ret;
+ RETURN_BOOL(retBool);
+}
+
+/**
+ * bool GEOSGeometry::coveredBy(GEOSGeometry)
+ */
+PHP_METHOD(Geometry, coveredBy)
+{
+ GEOSGeometry *this;
+ GEOSGeometry *other;
+ int ret;
+ zend_bool retBool;
+ zval *zobj;
+
+ this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zobj)
+ == FAILURE) {
+ RETURN_NULL();
+ }
+ other = getRelay(zobj, Geometry_ce_ptr);
+
+ ret = GEOSCoveredBy(this, other);
+ if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
+
+ /* return_value is a zval */
+ retBool = ret;
+ RETURN_BOOL(retBool);
+}
+
+/**
* bool GEOSGeometry::equals(GEOSGeometry)
*/
PHP_METHOD(Geometry, equals)
Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php 2011-02-28 11:32:25 UTC (rev 3249)
+++ trunk/php/test/test.php 2011-02-28 11:43:11 UTC (rev 3250)
@@ -1185,6 +1185,8 @@
$this->assertFalse( $g1->overlaps($g2) );
$this->assertTrue( $g1->equals($g2) );
$this->assertTrue( $g1->equalsExact($g2) );
+ $this->assertTrue( $g1->covers($g2) );
+ $this->assertTrue( $g1->coveredBy($g2) );
$g1 = $reader->read('POINT(0 0)');
$g2 = $reader->read('LINESTRING(0 0, 10 0)');
@@ -1198,6 +1200,8 @@
$this->assertFalse( $g1->overlaps($g2) );
$this->assertFalse( $g1->equals($g2) );
$this->assertFalse( $g1->equalsExact($g2, 10) );
+ $this->assertFalse( $g1->covers($g2) );
+ $this->assertTrue( $g1->coveredBy($g2) );
$g1 = $reader->read('POINT(5 0)');
$g2 = $reader->read('LINESTRING(0 0, 10 0)');
@@ -1211,6 +1215,8 @@
$this->assertFalse( $g1->overlaps($g2) );
$this->assertFalse( $g1->equals($g2) );
$this->assertFalse( $g1->equalsExact($g2, 10) );
+ $this->assertFalse( $g1->covers($g2) );
+ $this->assertTrue( $g1->coveredBy($g2) );
$g1 = $reader->read('LINESTRING(5 -5, 5 5)');
$g2 = $reader->read('LINESTRING(0 0, 10 0)');
@@ -1224,6 +1230,8 @@
$this->assertFalse( $g1->overlaps($g2) );
$this->assertFalse( $g1->equals($g2) );
$this->assertFalse( $g1->equalsExact($g2, 1) );
+ $this->assertFalse( $g1->covers($g2) );
+ $this->assertFalse( $g1->coveredBy($g2) );
$g1 = $reader->read('LINESTRING(5 0, 15 0)');
$g2 = $reader->read('LINESTRING(0 0, 10 0)');
@@ -1237,6 +1245,8 @@
$this->assertTrue( $g1->overlaps($g2) );
$this->assertFalse( $g1->equals($g2) );
$this->assertFalse( $g1->equalsExact($g2, 1) );
+ $this->assertFalse( $g1->covers($g2) );
+ $this->assertFalse( $g1->coveredBy($g2) );
$g1 = $reader->read('LINESTRING(0 0, 5 0, 10 0)');
$g2 = $reader->read('LINESTRING(0 0, 10 0)');
@@ -1250,6 +1260,8 @@
$this->assertFalse( $g1->overlaps($g2) );
$this->assertTrue( $g1->equals($g2) );
$this->assertFalse( $g1->equalsExact($g2, 1) );
+ $this->assertTrue( $g1->covers($g2) );
+ $this->assertTrue( $g1->coveredBy($g2) );
$g1 = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
$g2 = $reader->read('POLYGON((5 -5, 5 5, 15 5, 15 -5, 5 -5))');
@@ -1263,6 +1275,8 @@
$this->assertTrue( $g1->overlaps($g2) );
$this->assertFalse( $g1->equals($g2) );
$this->assertFalse( $g1->equalsExact($g2, 1) );
+ $this->assertFalse( $g1->covers($g2) );
+ $this->assertFalse( $g1->coveredBy($g2) );
$g1 = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
$g2 = $reader->read('POINT(15 15)');
@@ -1276,7 +1290,24 @@
$this->assertFalse( $g1->overlaps($g2) );
$this->assertFalse( $g1->equals($g2) );
$this->assertFalse( $g1->equalsExact($g2, 1) );
+ $this->assertFalse( $g1->covers($g2) );
+ $this->assertFalse( $g1->coveredBy($g2) );
+ $g1 = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
+ $g2 = $reader->read('POINT(5 0)');
+
+ $this->assertFalse( $g1->disjoint($g2) );
+ $this->assertTrue( $g1->touches($g2) );
+ $this->assertTrue( $g1->intersects($g2) );
+ $this->assertFalse( $g1->crosses($g2) );
+ $this->assertFalse( $g1->within($g2) );
+ $this->assertFalse( $g1->contains($g2) );
+ $this->assertFalse( $g1->overlaps($g2) );
+ $this->assertFalse( $g1->equals($g2) );
+ $this->assertFalse( $g1->equalsExact($g2, 1) );
+ $this->assertTrue( $g1->covers($g2) );
+ $this->assertFalse( $g1->coveredBy($g2) );
+
}
public function testGeometry_isEmpty()
More information about the geos-commits
mailing list