From 8dadfdb7cae1c2665101d843ddb2032fefca9f79 Mon Sep 17 00:00:00 2001 From: strk Date: Mon, 15 Sep 2014 16:09:56 +0000 Subject: [PATCH] Expose Geometry->normalize() method in PHP binding git-svn-id: http://svn.osgeo.org/geos/trunk@4004 5242fede-7e19-0410-aef8-94bd7d2200fb --- NEWS | 1 + php/geos.c | 23 +++++++++++++++++++++++ php/test/test.php | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index f7221ba5..b4403aa3 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ Changes in 3.5.0 - New things: - Voronoi API (#627) + - PHP: Geometry->normalize method - GEOS_USE_ONLY_R_API macro support (#695) ... diff --git a/php/geos.c b/php/geos.c index dbb73d43..aef1b31a 100644 --- a/php/geos.c +++ b/php/geos.c @@ -198,6 +198,7 @@ PHP_METHOD(Geometry, centroid); PHP_METHOD(Geometry, relate); PHP_METHOD(Geometry, relateBoundaryNodeRule); PHP_METHOD(Geometry, simplify); /* also does topology-preserving */ +PHP_METHOD(Geometry, normalize); PHP_METHOD(Geometry, extractUniquePoints); PHP_METHOD(Geometry, disjoint); PHP_METHOD(Geometry, touches); @@ -262,6 +263,7 @@ static zend_function_entry Geometry_methods[] = { PHP_ME(Geometry, relate, NULL, 0) PHP_ME(Geometry, relateBoundaryNodeRule, NULL, 0) PHP_ME(Geometry, simplify, NULL, 0) + PHP_ME(Geometry, normalize, NULL, 0) PHP_ME(Geometry, extractUniquePoints, NULL, 0) PHP_ME(Geometry, disjoint, NULL, 0) PHP_ME(Geometry, touches, NULL, 0) @@ -1008,6 +1010,27 @@ PHP_METHOD(Geometry, simplify) } /** + * GEOSGeometry GEOSGeometry::normalize() + */ +PHP_METHOD(Geometry, normalize) +{ + GEOSGeometry *this; + GEOSGeometry *ret; + + this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr); + + ret = GEOSGeom_clone(this); + + if ( ! ret ) RETURN_NULL(); + + GEOSNormalize(ret); /* exception should be gotten automatically */ + + /* return_value is a zval */ + object_init_ex(return_value, Geometry_ce_ptr); + setRelay(return_value, ret); +} + +/** * GEOSGeometry GEOSGeometry::extractUniquePoints() */ PHP_METHOD(Geometry, extractUniquePoints) diff --git a/php/test/test.php b/php/test/test.php index 14d00097..32cf8df5 100644 --- a/php/test/test.php +++ b/php/test/test.php @@ -2047,8 +2047,8 @@ MULTIPOINT( $b = $g->voronoiDiagram(); $this->assertEquals( -'GEOMETRYCOLLECTION (POLYGON ((50 200, 200 200, 200 50, 50 50, 50 200)), POLYGON ((-100 50, -100 200, 50 200, 50 50, -100 50)), POLYGON ((50 -100, -100 -100, -100 50, 50 50, 50 -100)), POLYGON ((200 50, 200 -100, 50 -100, 50 50, 200 50)))' - , $writer->write($b)); +'GEOMETRYCOLLECTION (POLYGON ((50 50, 50 200, 200 200, 200 50, 50 50)), POLYGON ((50 -100, 50 50, 200 50, 200 -100, 50 -100)), POLYGON ((-100 50, -100 200, 50 200, 50 50, -100 50)), POLYGON ((-100 -100, -100 50, 50 50, 50 -100, -100 -100)))' + , $writer->write($b->normalize())); $b = $g->voronoiDiagram(0, 1); $this->assertEquals( -- 2.11.4.GIT