[geos-commits] r3040 - in trunk/php: . test
svn_geos at osgeo.org
svn_geos at osgeo.org
Sun Jun 20 19:35:53 EDT 2010
Author: strk
Date: 2010-06-20 23:35:53 +0000 (Sun, 20 Jun 2010)
New Revision: 3040
Modified:
trunk/php/geos.c
trunk/php/test/test.php
Log:
isSimple, isRing, hasZ, isClosed
Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c 2010-06-20 22:59:31 UTC (rev 3039)
+++ trunk/php/geos.c 2010-06-20 23:35:53 UTC (rev 3040)
@@ -196,6 +196,10 @@
PHP_METHOD(Geometry, equalsExact);
PHP_METHOD(Geometry, isEmpty);
PHP_METHOD(Geometry, checkValidity);
+PHP_METHOD(Geometry, isSimple);
+PHP_METHOD(Geometry, isRing);
+PHP_METHOD(Geometry, hasZ);
+PHP_METHOD(Geometry, isClosed);
PHP_METHOD(Geometry, numGeometries);
@@ -228,6 +232,10 @@
PHP_ME(Geometry, equalsExact, NULL, 0)
PHP_ME(Geometry, isEmpty, NULL, 0)
PHP_ME(Geometry, checkValidity, NULL, 0)
+ PHP_ME(Geometry, isSimple, NULL, 0)
+ PHP_ME(Geometry, isRing, NULL, 0)
+ PHP_ME(Geometry, hasZ, NULL, 0)
+ PHP_ME(Geometry, isClosed, NULL, 0)
PHP_ME(Geometry, numGeometries, NULL, 0)
{NULL, NULL, NULL}
@@ -1391,7 +1399,83 @@
}
+/**
+ * bool GEOSGeometry::isSimple()
+ */
+PHP_METHOD(Geometry, isSimple)
+{
+ GEOSGeometry *this;
+ int ret;
+ zend_bool retBool;
+ this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+ ret = GEOSisSimple(this);
+ if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
+
+ /* return_value is a zval */
+ retBool = ret;
+ RETURN_BOOL(retBool);
+}
+
+/**
+ * bool GEOSGeometry::isRing()
+ */
+PHP_METHOD(Geometry, isRing)
+{
+ GEOSGeometry *this;
+ int ret;
+ zend_bool retBool;
+
+ this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+ ret = GEOSisRing(this);
+ if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
+
+ /* return_value is a zval */
+ retBool = ret;
+ RETURN_BOOL(retBool);
+}
+
+/**
+ * bool GEOSGeometry::hasZ()
+ */
+PHP_METHOD(Geometry, hasZ)
+{
+ GEOSGeometry *this;
+ int ret;
+ zend_bool retBool;
+
+ this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+ ret = GEOSHasZ(this);
+ if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
+
+ /* return_value is a zval */
+ retBool = ret;
+ RETURN_BOOL(retBool);
+}
+
+/**
+ * bool GEOSGeometry::isClosed()
+ */
+PHP_METHOD(Geometry, isClosed)
+{
+ GEOSGeometry *this;
+ int ret;
+ zend_bool retBool;
+
+ this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+ ret = GEOSisClosed(this);
+ 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-06-20 22:59:31 UTC (rev 3039)
+++ trunk/php/test/test.php 2010-06-20 23:35:53 UTC (rev 3040)
@@ -1189,4 +1189,63 @@
$this->assertEquals( 'POINT (0 nan)',
$writer->write($val['location']) );
}
+
+ public function testGeometry_isSimple()
+ {
+ $reader = new GEOSWKTReader();
+
+ $g = $reader->read('POINT(0 0)');
+ $this->assertTrue( $g->isSimple() );
+
+ $g = $reader->read('LINESTRING(0 0, 10 0)');
+ $this->assertTrue( $g->isSimple() );
+
+ $g = $reader->read('LINESTRING(0 0, 10 0, 5 5, 5 -5)');
+ $this->assertFalse( $g->isSimple() );
+ }
+
+ public function testGeometry_isRing()
+ {
+ $reader = new GEOSWKTReader();
+
+ $g = $reader->read('POINT(0 0)');
+ $this->assertFalse( $g->isRing() );
+
+ $g = $reader->read('LINESTRING(0 0, 10 0, 5 5, 5 -5)');
+ $this->assertFalse( $g->isRing() );
+
+ $g = $reader->read('LINESTRING(0 0, 10 0, 5 5, 0 0)');
+ $this->assertTrue( $g->isRing() );
+ }
+
+ public function testGeometry_hasZ()
+ {
+ $reader = new GEOSWKTReader();
+
+ $g = $reader->read('POINT(0 0)');
+ $this->assertFalse( $g->hasZ() );
+
+ $g = $reader->read('POINT(0 0 0)');
+ $this->assertTrue( $g->hasZ() );
+
+ }
+
+ public function testGeometry_isClosed()
+ {
+ $reader = new GEOSWKTReader();
+
+ $g = $reader->read('POINT(0 0)');
+ try {
+ $this->assertFalse( $g->isClosed() );
+ $this->assertTrue(FALSE);
+ } catch (Exception $e) {
+ $this->assertContains('LineString', $e->getMessage());
+ }
+
+ $g = $reader->read('LINESTRING(0 0, 10 0, 5 5, 5 -5)');
+ $this->assertFalse( $g->isClosed() );
+
+ $g = $reader->read('LINESTRING(0 0, 10 0, 5 5, 0 0)');
+ $this->assertTrue( $g->isClosed() );
+ }
}
More information about the geos-commits
mailing list