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

Sandro Santilli strk at kbt.io
Tue Jul 19 11:26:21 PDT 2016


Author: strk
Date: 2016-07-19 11:26:20 -0700 (Tue, 19 Jul 2016)
New Revision: 4237

Removed:
   trunk/php/Makefile.am
   trunk/php/README
   trunk/php/TODO
   trunk/php/geos.c
   trunk/php/php_geos.h
   trunk/php/test/Makefile.am
   trunk/php/test/crashme.php
   trunk/php/test/test.php
Modified:
   trunk/.gitignore
   trunk/Makefile.am
   trunk/NEWS
   trunk/README.md
   trunk/configure.ac
Log:
Remove PHP bindings, leave refs to separate repository

Closes #765

Modified: trunk/.gitignore
===================================================================
--- trunk/.gitignore	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/.gitignore	2016-07-19 18:26:20 UTC (rev 4237)
@@ -56,7 +56,6 @@
 doc/example
 include/config.h
 include/config.h.in
-php/test/phpunit
 authors.git
 !/docker/**/README
 !/docker/**/Makefile

Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/Makefile.am	2016-07-19 18:26:20 UTC (rev 4237)
@@ -14,7 +14,6 @@
     doc     \
     macros  \
     swig    \
-    php     \
     tests   \
     tools
 

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/NEWS	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,9 +1,12 @@
 Changes in 3.6.0
 2015-MM-DD
 
+- Important / Breaking Changes:
+  - The PHP binding moved to its own repository:
+    http://git.osgeo.org/gogs/geos/php-geos (#765)
 - New things:
   - CAPI: GEOSGeom_setPrecision (#713) - PHP: Geometry->setPrecision
-  - CAPI: GEOSGeom_getPrecision - PHP: Geometry->getPrecision
+  - CAPI: GEOSGeom_getPrecision
   - CAPI: GEOSMinimumRotatedRectangle and GEOSMinimumWidth
     (#729, Nyall Dawson)
   - CAPI: GEOSSTRtree_nearest (#768, Dan Baston)
@@ -36,15 +39,15 @@
 2013-08-25
 
 - Bug fixes / improvements
-  - Use a double for PrecisionModel scale, avoiding overflows 
+  - Use a double for PrecisionModel scale, avoiding overflows
     should fix 32-bit regression failures (#652)
   - isnan workaround OS detection missing NetBSD, DragonFly, Sun nuance (#650)
   - Do not distribute platform.h and version.h, but install both (#601)
-  - Non-standard ChangeLog file in 3.4.0 and 3.4.1 releases (#654) 
+  - Non-standard ChangeLog file in 3.4.0 and 3.4.1 releases (#654)
   - new travis bot (#657)
   - accept multiple Nan representations (#656)
-		
 
+
 Changes in 3.4.1
 2013-08-17
 
@@ -70,7 +73,7 @@
 
 - C++ API changes:
   - New noding::GeometryNoder class
-  - Added BufferOp::setSingleSided 
+  - Added BufferOp::setSingleSided
   - Signature of most functions taking a Label changed to take it
     by reference rather than pointer.
   - Signature of most functions taking an IntersectionMatrix changed
@@ -78,13 +81,13 @@
   - GraphComponent::label is now a Label value (from a pointer)
   - NodedSegmentString takes ownership of CoordinateSenuence now
   - io::Writer's toString() returns by const ref, write() takes a const ref
-  - Unify prototypes of WKTReader and WKBReader constructor (#310) 
-  - GeometryCollection::computeEnvelopInternal and 
+  - Unify prototypes of WKTReader and WKBReader constructor (#310)
+  - GeometryCollection::computeEnvelopInternal and
     GeometryCollection::compareToSameClass are marked virtual (#478)
-  
+
 - Bug fixes / improvements
-  - A point interpolated from a line does not always intersect 
-    the same line (#323) 
+  - A point interpolated from a line does not always intersect
+    the same line (#323)
   - Port ConvexHull robustness fix from JTS-1.13 (#457)
   - Improve Overlay robustness by reducing input precision on topology
     exception and by refusing to accept unnoded output (#459)
@@ -98,7 +101,7 @@
   - Fix EMPTY return from single-point lines and zero-length polygons (#612)
   - CMakeLists.txt, tools/geos_svn_revision_cmake.h.in: Add
 	  geos_svn_revision.h generator to CMake config (#643)
-	- Makefile.vc 'clean' step leaks obj files (#607) 
+	- Makefile.vc 'clean' step leaks obj files (#607)
 
 Changes in 3.3.9
 2013-09-04
@@ -115,7 +118,7 @@
     - Fix bug in HotPixel constructor (#635)
     - Fix install location of linearref headers (#624)
     - Fix multi-geometry constructor to drop SRID from components (#583)
-  
+
 Changes in 3.3.8
 2013-02-28
 
@@ -126,7 +129,7 @@
     - Fix centroid computation for collections with empty components (#582)
 
 Changes in 3.3.7
-2013-01-22 
+2013-01-22
 
 - Bug fixes / improvements
     - Fix abort in RightmostEdgeFinder (#605)
@@ -225,10 +228,10 @@
           the polygonizer
   - CAPI: GEOSOrientationIndex
   - CAPI: GEOSSharedPaths to find shared paths and their orientation
-  - CAPI: GEOSSnap 
-  - CAPI: GEOSRelatePatternMatch 
-  - CAPI: GEOSCovers, GEOSCoveredBy (#396) 
-  - CAPI: GEOSRelateBoundaryNodeRule (#399) 
+  - CAPI: GEOSSnap
+  - CAPI: GEOSRelatePatternMatch
+  - CAPI: GEOSCovers, GEOSCoveredBy (#396)
+  - CAPI: GEOSRelateBoundaryNodeRule (#399)
   - CAPI: GEOSGeom_getCoordinateDimension() (#311)
   - CAPI: GEOSWKTWriter_setOutputDimension, GEOSWKTWriter_setOld3D (#292)
   -  PHP: new PHP5 bindings based on CAPI
@@ -251,13 +254,13 @@
   - Fix NodedSegmentString to handle zero-length line segments correctly
     (via safeOctant)
   - Fixed buffer OffsetCurveSetBuilder to handle "flat" rings correctly
-  - Added illegal state check in LineSegment::pointAlongOffset() 
+  - Added illegal state check in LineSegment::pointAlongOffset()
   - Improved performance of RectangleIntersects by always using
     segment-scanning and refining SegmentIntersectionTester
   - Reduce memory use in PreparedGeometry predicates (#342)
   - Fix infinite loop in RobustDeterminant with nan/inf input (#357)
 
-Changes in 3.2.0 
+Changes in 3.2.0
 2009-12-14
 
 - Add Single-sided buffer operation
@@ -279,7 +282,7 @@
 
 - PreparedGeometry operations for very fast predicate testing.
   - Intersects()
-  - Covers() 
+  - Covers()
   - CoveredBy()
   - ContainsProperly()
 - Easier builds under MSVC and OpenSolaris
@@ -306,7 +309,7 @@
 	- Added GEOSSimplify() and GEOSTopologyPreserveSimplify()
 	  to the C API
 	- Added closed ring checks in IsValidOp
-	- Multi-input support in XMLTester 
+	- Multi-input support in XMLTester
 	- HEXWKB I/O
 	- Envelope(string) ctor
 	- Ruby interface
@@ -355,7 +358,7 @@
 	  contains() ops
 	- Inlined all planarGraphComponent class
 	- More iterators returning methods and inlining in planargraph.
-	- Obsoleted toInternalGeometry/fromInternalGeometry 
+	- Obsoleted toInternalGeometry/fromInternalGeometry
 	- Improved buffering speed and robustness by using Snap Rounding
 
 - Semantic changes
@@ -401,7 +404,7 @@
 	  result of overlaying polygons containing touching holes (#13)
 	- Fixed integer conversion bug
 	- Fixed PointLocator handling of LinearRings
-	- Added missing ::clone() methods for Multi* geoms 
+	- Added missing ::clone() methods for Multi* geoms
 
 - (Partial) Detailed list of changes:
 	- Changed SegmentNode to contain a *real* Coordinate (not a pointer)
@@ -425,7 +428,7 @@
 	- CoordinateSequence API changes:
 		- point index and size related functions
 	  	  use unsigned int rather then int
-	- Changed EdgeEndStar to maintain a single container for EdgeEnds 
+	- Changed EdgeEndStar to maintain a single container for EdgeEnds
 	- Changed PlanarGraph::addEdges to take a const vector by ref
 	  rathern then a non-const vector by pointer
 	- Changed EdgeList::addAll to take a const vector by ref
@@ -450,17 +453,17 @@
 
 - Support for MingW builds
 - Bugfix in Polygonizer chocking on invalid LineString inputs
-- CAPI: small leak removed in GEOSHasZ() 
+- CAPI: small leak removed in GEOSHasZ()
 
 Changes in 2.2.0
 
 - Performance improvement in OverlayOp::insertUniqueEdge()
 - CoordinateSequence copy removal in EdgeRing
-- Minor memory allocation improvements 
+- Minor memory allocation improvements
 - Higher dimensions interface for CoordinateSequence
 - Added getCoordinatesRO for Point class
 - NEW WKB IO
-- NEW Simplified and stabler C API 
+- NEW Simplified and stabler C API
 
 Changes in 2.1.4
 

Modified: trunk/README.md
===================================================================
--- trunk/README.md	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/README.md	2016-07-19 18:26:20 UTC (rev 4237)
@@ -94,10 +94,10 @@
 
     ./configure ... --enable-ruby
 
-PHP bindings are fully supported. To build, use the `--enable-php` option
-when configuring:
+Since version 3.6.0 PHP bindings are not included in the core
+library anymore but available as a separate project:
 
-    ./configure ... --enable-php
+    https://git.osgeo.org/gogs/geos/php-geos
 
 Since version 3.0, the Python bindings are unsupported. Recommended options:
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/configure.ac	2016-07-19 18:26:20 UTC (rev 4237)
@@ -130,7 +130,7 @@
 fi
 
 dnl --------------------------------------------------------------------
-dnl - Append default C++ and C flags 
+dnl - Append default C++ and C flags
 dnl --------------------------------------------------------------------
 
 dnl In order for AC_LIBTOOL_COMPILER_OPTION to use
@@ -138,10 +138,10 @@
 dnl It is likely a bug in the libtool macro file to
 dnl require AC_LIBTOOL_LANG_CXX_CONFIG in *addition*
 dnl to AC_LANG(CXX) or AC_LANG_PUSH(CXX)/AC_LANG_POP()
-dnl 
+dnl
 AC_LIBTOOL_LANG_CXX_CONFIG
 
-# Set default AM_CXXFLAGS and AM_CFLAGS 
+# Set default AM_CXXFLAGS and AM_CFLAGS
 # -pedantic: ISO does not support long long
 # we add -Wno-long-long to avoid those messages
 WARNFLAGS=""
@@ -256,31 +256,17 @@
 )
 
 dnl --------------------------------------------------------------------
-dnl - check whether php is required for the build
+dnl - check for swig if python or ruby are enabled
 dnl --------------------------------------------------------------------
 
-AC_ARG_ENABLE([php], [  --enable-php    Enable build of php module],
-	[case "${enableval}" in
-		yes) use_php=true ;;
-		no)  use_php=false ;;
-		*) AC_MSG_ERROR(bad value ${enableval} for --enable-php) ;;
-	esac],
-	[use_php=false]
-)
-
-
-dnl --------------------------------------------------------------------
-dnl - check for swig if python, ruby or php are enabled
-dnl --------------------------------------------------------------------
-
 use_swig=false
 if test x"$use_python" = xtrue ||
    test x"$use_ruby" = xtrue; then
   AC_PROG_SWIG(1.3.28)
   if test x"$SWIG" != "x"; then
-    SWIG_ENABLE_CXX	
-    AC_SUBST(SWIG)           
-    use_swig=true 
+    SWIG_ENABLE_CXX
+    AC_SUBST(SWIG)
+    use_swig=true
   else
     use_python=false
     use_ruby=false
@@ -294,14 +280,14 @@
 dnl --------------------------------------------------------------------
 
 if test x"$use_python" = xtrue; then
-	dnl Check for Python 
-  AM_PATH_PYTHON	
+	dnl Check for Python
+  AM_PATH_PYTHON
   SWIG_PYTHON
 
 	if test x"$PYTHON" = "x"; then
 		use_python=false
 	fi
-	
+
 	AC_SUBST(PYTHON)
 	AC_SUBST(SWIG_PYTHON_CPPFLAGS)
 	AC_SUBST(SWIG_PYTHON_OPT)
@@ -314,7 +300,7 @@
 dnl --------------------------------------------------------------------
 
 if test x"$use_ruby" = xtrue; then
-	dnl Check for Ruby 
+	dnl Check for Ruby
 	AC_RUBY_DEVEL
 
 	if test x"$RUBY" = x; then
@@ -325,32 +311,6 @@
 AM_CONDITIONAL(ENABLE_RUBY, [ test x"$use_ruby" = xtrue ])
 
 dnl --------------------------------------------------------------------
-dnl - check for php if enabled
-dnl --------------------------------------------------------------------
-
-if test x"$use_php" = xtrue; then
-	dnl Check for PHP 
-	AC_PATH_PROG(PHP_CONFIG, php-config)
-
-	if test x"$PHP_CONFIG" = x; then
-		AC_MSG_WARN([php-config not found, php support disabled])
-		use_php=false
-	else
-
-		dnl TODO: check for version, we want PHP5 dev files
-
-		AC_PATH_PROG(PHP, php) dnl for unit testing
-		AC_PATH_PROG(PHPUNIT, phpunit) dnl for unit testing
-	fi
-
-
-fi
-AM_CONDITIONAL(ENABLE_PHP, [ test x"$use_php" = xtrue ])
-AM_CONDITIONAL(HAVE_PHP, [ test x"$PHP" != x ])
-AM_CONDITIONAL(HAVE_PHP_UNIT, [ test x"$PHPUNIT" != x ])
-
-
-dnl --------------------------------------------------------------------
 dnl - do operating-system specific things
 dnl --------------------------------------------------------------------
 
@@ -383,7 +343,7 @@
 esac
 
 dnl --------------------------------------------------------------------
-dnl - check for boost 
+dnl - check for boost
 dnl --------------------------------------------------------------------
 
 dnl -- AX_BOOST(1.32)
@@ -414,13 +374,13 @@
 dnl output stuff ----------------------------------------------------------
 
 AC_OUTPUT([
-	Makefile 
+	Makefile
 	capi/Makefile
 	capi/geos_c.h
 	doc/Doxyfile
 	doc/Makefile
 	macros/Makefile
-	src/Makefile 
+	src/Makefile
 	src/algorithm/Makefile
 	src/algorithm/locate/Makefile
 	src/algorithm/distance/Makefile
@@ -506,8 +466,6 @@
 	swig/python/tests/Makefile
 	swig/ruby/Makefile
 	swig/ruby/test/Makefile
-	php/Makefile
-	php/test/Makefile
 	tests/Makefile
 	tests/bigtest/Makefile
 	tests/unit/Makefile
@@ -529,13 +487,4 @@
 echo "Python bindings: $use_python"
 echo "Ruby bindings: $use_ruby"
 
-echo "PHP bindings: $use_php"
-if test x"$use_php" = xtrue; then
- echo " PHP: $PHP"
- echo " PHPUNIT: $PHPUNIT"
- if test x"$PHP" = x -o x"$PHPUNIT" = x; then
-   AC_MSG_WARN([PHP Unit testing disabled (missing PHP or PHPUNIT)])
- fi
-fi
-
 dnl -- echo "---------------------------------------"

Deleted: trunk/php/Makefile.am
===================================================================
--- trunk/php/Makefile.am	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/php/Makefile.am	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,62 +0,0 @@
-#######################################################################
-# 
-#    GEOS - Geometry Engine Open Source
-#    http://trac.osgeo.org/geos
-#
-#    Copyright (C) 2010 Sandro Santilli <strk at keybit.net>
-#
-#    This library is free software; you can redistribute it and/or
-#    modify it under the terms of the GNU Lesser General Public
-#    License as published by the Free Software Foundation; either
-#    version 2.1 of the License, or (at your option) any later version.
-#
-#    This library is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#    Lesser General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program; if not, write to the Free Software
-#    Foundation, Inc., 51 Franklin St, Fifth Floor,
-#    Boston, MA  02110-1301  USA
-#
-#######################################################################
-
-
-if ENABLE_PHP
-
-SUBDIRS = . test
-
-EXTRA_DIST = README 
-
-pkglib_LTLIBRARIES = geos.la
-
-geos_la_SOURCES = geos.c php_geos.h
-
-geos_la_LIBADD =  $(top_builddir)/capi/libgeos_c.la 
-
-# TODO: check if -no-undefined should be added
-geos_la_LDFLAGS = -module -avoid-version
-
-# -std is an attempt to fix interpretation
-# of Zend headers, failing with -ansi.
-#
-# As of gcc (Ubuntu 4.3.2-1ubuntu12) 4.3.2
-# you need -std=gnu99
-# while on OpenSuse's plain gcc 4.3.2 -std=c99 is fine
-# (argh)
-#
-geos_la_CFLAGS = $(AM_CFLAGS) -std=gnu99
-
-# TODO: drop conditionals from geos.c and let it bound to current code
-geos_la_CPPFLAGS = $(AM_CPPFLAGS) \
-	`$(PHP_CONFIG) --includes` \
-	-DCOMPILE_DL_GEOS \
-	-I$(top_builddir)/capi \
-	-I$(top_srcdir)/include
-
-install: all
-	$(INSTALL) -d "$(DESTDIR)"/`$(PHP_CONFIG) --extension-dir`
-	$(INSTALL) -m 755 .libs/geos.so "$(DESTDIR)"/`php-config --extension-dir`
-
-endif

Deleted: trunk/php/README
===================================================================
--- trunk/php/README	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/php/README	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,48 +0,0 @@
-PHP module for GEOS
-===================
-
-  Date: Fri Jun 18 15:52:57 CEST 2010
-  Author: Sandro Santilli <strk at keybit.net>
-
-The code in this directory provides a PHP module to
-make use of functionalities of the GEOS library.
-The bindings are linked to the C-API, for betters stability.
-
-REQUIREMENTS
-------------
-
-You need php5 development tools, often found in
-packages named something like 'php5-dev'. 
-
-BUILD
------
-
-Just add --enable-php to your GEOS configure line
-and run 'make'.
-
-TESTING
--------
-
-Automated testing should be executed on 'make check'
-togheter with the rest of the GEOS testsuite.
-You can still run 'make check' from this dir for
-localized (php-only) testing.
-
-Note that you'll need phpunit installed for this to work.
-To install:
-
-  sudo pear install --force --alldeps phpunit/phpunit
-
-INSTALL
--------
-
-As root (or owner with write access to the directory
-returned by php-config --extension-dir),
-run 'make install'
-
-USAGE
------
-
- ... TODO ...
- (reference some automatically built doc?)
-

Deleted: trunk/php/TODO
===================================================================
--- trunk/php/TODO	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/php/TODO	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,11 +0,0 @@
-In order of priority
-
-- Find a way to have GEOSGeometry contents shown on var_dump
-- Documentation !! (doxygen-based?)
-- Add WKBReader::read and WKBWriter::write (binary strings required)
-- Use the re-entrant C-API interface
-- Add interface for algorithms (Orientation Index) ?
-- Add interfaces for prepared geometries ?
-- Add interfaces for STRTree ?
-- Add interfaces for GEOSCoordSeq ?
-- Add Geometry Constructors ?

Deleted: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/php/geos.c	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,2987 +0,0 @@
-/***********************************************************************
- * 
- *    GEOS - Geometry Engine Open Source
- *    http://trac.osgeo.org/geos
- *
- *    Copyright (C) 2010 Sandro Santilli <strk at keybit.net>
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation; either
- *    version 2.1 of the License, or (at your option) any later version.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU General Public License
- *    along with this program; if not, write to the Free Software
- *    Foundation, Inc., 51 Franklin St, Fifth Floor,
- *    Boston, MA  02110-1301  USA
- *
- ***********************************************************************/
-
-/* PHP stuff */
-#include "php.h"
-#include "ext/standard/info.h" /* for php_info_... */
-#include "Zend/zend_exceptions.h" /* for zend_throw_exception_object */
-
-/* GEOS stuff */
-#include "geos_c.h"
-
-/* Own stuff */
-#include "php_geos.h"
-
-PHP_MINIT_FUNCTION(geos);
-PHP_MSHUTDOWN_FUNCTION(geos);
-PHP_RINIT_FUNCTION(geos);
-PHP_RSHUTDOWN_FUNCTION(geos);
-PHP_MINFO_FUNCTION(geos);
-PHP_FUNCTION(GEOSVersion);
-PHP_FUNCTION(GEOSPolygonize);
-PHP_FUNCTION(GEOSLineMerge);
-PHP_FUNCTION(GEOSSharedPaths);
-PHP_FUNCTION(GEOSRelateMatch);
-
-#if PHP_VERSION_ID < 50399 
-#define zend_function_entry function_entry
-#endif
-
-static zend_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}
-};
-
-zend_module_entry geos_module_entry = {
-    STANDARD_MODULE_HEADER,
-    PHP_GEOS_EXTNAME,
-    geos_functions,
-    PHP_MINIT(geos),              /* module init function */
-    PHP_MSHUTDOWN(geos),          /* module shutdown function */
-    PHP_RINIT(geos),              /* request init function */
-    PHP_RSHUTDOWN(geos),          /* request shutdown function */
-    PHP_MINFO(geos),              /* module info function */
-    PHP_GEOS_VERSION,
-    STANDARD_MODULE_PROPERTIES
-};
-
-#ifdef COMPILE_DL_GEOS
-ZEND_GET_MODULE(geos)
-#endif
-
-/* -- Utility functions ---------------------- */
-
-static void noticeHandler(const char *fmt, ...)
-{
-    TSRMLS_FETCH();
-    char message[256];
-    va_list args;
-    va_start(args, fmt);
-    vsnprintf(message, sizeof(message) - 1, fmt, args);
-    va_end(args);
-
-    php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s", message);
-}
-
-static void errorHandler(const char *fmt, ...)
-{
-    TSRMLS_FETCH();
-    char message[256];
-    va_list args;
-    va_start(args, fmt);
-    vsnprintf(message, sizeof(message) - 1, fmt, args);
-    va_end(args);
-
-    /* TODO: use a GEOSException ? */
-    zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C),
-        1 TSRMLS_CC, "%s", message); 
-
-}
-
-typedef struct Proxy_t {
-    zend_object std;
-    void* relay;
-} Proxy;
-
-static void 
-setRelay(zval* val, void* obj) {
-    TSRMLS_FETCH();
-    Proxy* proxy = (Proxy*)zend_object_store_get_object(val TSRMLS_CC);
-    proxy->relay = obj;
-}
-
-static inline void *
-getRelay(zval* val, zend_class_entry* ce) {
-    TSRMLS_FETCH();
-    Proxy *proxy =  (Proxy*)zend_object_store_get_object(val TSRMLS_CC);
-    if ( proxy->std.ce != ce ) {
-        php_error_docref(NULL TSRMLS_CC, E_ERROR,
-            "Relay object is not an %s", ce->name);
-    }
-    if ( ! proxy->relay ) {
-        php_error_docref(NULL TSRMLS_CC, E_ERROR,
-            "Relay object for object of type %s is not set", ce->name);
-    }
-    return proxy->relay;
-}
-
-static long getZvalAsLong(zval* val)
-{
-    long ret;
-    zval tmp;
-
-    tmp = *val;
-    zval_copy_ctor(&tmp);
-    convert_to_long(&tmp);
-    ret = Z_LVAL(tmp);
-    zval_dtor(&tmp);
-    return ret;
-}
-
-static long getZvalAsDouble(zval* val)
-{
-    double ret;
-    zval tmp;
-
-    tmp = *val;
-    zval_copy_ctor(&tmp);
-    convert_to_double(&tmp);
-    ret = Z_DVAL(tmp);
-    zval_dtor(&tmp);
-    return ret;
-}
-
-static zend_object_value
-Gen_create_obj (zend_class_entry *type,
-    zend_objects_free_object_storage_t st, zend_object_handlers* handlers)
-{
-    TSRMLS_FETCH();
-    zend_object_value retval;
-
-    Proxy *obj = (Proxy *)emalloc(sizeof(Proxy));
-    memset(obj, 0, sizeof(Proxy));
-    obj->std.ce = type;
-
-    ALLOC_HASHTABLE(obj->std.properties);
-    zend_hash_init(obj->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-#if PHP_VERSION_ID < 50399 
-    zend_hash_copy(obj->std.properties, &type->default_properties,
-        (copy_ctor_func_t)zval_add_ref, NULL, sizeof(zval *));
-#else
-    object_properties_init(&(obj->std), type);
-#endif
-
-    retval.handle = zend_objects_store_put(obj, NULL, st, NULL TSRMLS_CC);
-    retval.handlers = handlers;
-
-    return retval;
-}
-
-
-/* -- class GEOSGeometry -------------------- */
-
-PHP_METHOD(Geometry, __construct);
-PHP_METHOD(Geometry, __toString);
-PHP_METHOD(Geometry, project);
-PHP_METHOD(Geometry, interpolate);
-PHP_METHOD(Geometry, buffer);
-PHP_METHOD(Geometry, offsetCurve);
-PHP_METHOD(Geometry, envelope);
-PHP_METHOD(Geometry, intersection);
-PHP_METHOD(Geometry, convexHull);
-PHP_METHOD(Geometry, difference);
-PHP_METHOD(Geometry, symDifference);
-PHP_METHOD(Geometry, boundary);
-PHP_METHOD(Geometry, union); /* also does union cascaded */
-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, normalize);
-PHP_METHOD(Geometry, setPrecision);
-PHP_METHOD(Geometry, getPrecision);
-PHP_METHOD(Geometry, extractUniquePoints); 
-PHP_METHOD(Geometry, disjoint);
-PHP_METHOD(Geometry, touches);
-PHP_METHOD(Geometry, intersects);
-PHP_METHOD(Geometry, crosses);
-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);
-PHP_METHOD(Geometry, checkValidity);
-PHP_METHOD(Geometry, isSimple);
-PHP_METHOD(Geometry, isRing);
-PHP_METHOD(Geometry, hasZ);
-PHP_METHOD(Geometry, isClosed);
-PHP_METHOD(Geometry, typeName);
-PHP_METHOD(Geometry, typeId);
-PHP_METHOD(Geometry, getSRID);
-PHP_METHOD(Geometry, setSRID);
-PHP_METHOD(Geometry, numGeometries);
-PHP_METHOD(Geometry, geometryN);
-PHP_METHOD(Geometry, numInteriorRings);
-PHP_METHOD(Geometry, numPoints);
-PHP_METHOD(Geometry, getX);
-PHP_METHOD(Geometry, getY);
-PHP_METHOD(Geometry, interiorRingN);
-PHP_METHOD(Geometry, exteriorRing);
-PHP_METHOD(Geometry, numCoordinates);
-PHP_METHOD(Geometry, dimension);
-PHP_METHOD(Geometry, coordinateDimension);
-PHP_METHOD(Geometry, pointN);
-PHP_METHOD(Geometry, startPoint);
-PHP_METHOD(Geometry, endPoint);
-PHP_METHOD(Geometry, area);
-PHP_METHOD(Geometry, length);
-PHP_METHOD(Geometry, distance);
-PHP_METHOD(Geometry, hausdorffDistance);
-PHP_METHOD(Geometry, snapTo);
-PHP_METHOD(Geometry, node);
-PHP_METHOD(Geometry, delaunayTriangulation);
-PHP_METHOD(Geometry, voronoiDiagram);
-PHP_METHOD(Geometry, clipByRect);
-
-static zend_function_entry Geometry_methods[] = {
-    PHP_ME(Geometry, __construct, NULL, 0)
-    PHP_ME(Geometry, __toString, NULL, 0)
-    PHP_ME(Geometry, project, NULL, 0)
-    PHP_ME(Geometry, interpolate, NULL, 0)
-    PHP_ME(Geometry, buffer, NULL, 0)
-    PHP_ME(Geometry, offsetCurve, NULL, 0)
-    PHP_ME(Geometry, envelope, NULL, 0)
-    PHP_ME(Geometry, intersection, NULL, 0)
-    PHP_ME(Geometry, convexHull, NULL, 0)
-    PHP_ME(Geometry, difference, NULL, 0)
-    PHP_ME(Geometry, symDifference, NULL, 0)
-    PHP_ME(Geometry, boundary, NULL, 0)
-    PHP_ME(Geometry, union, NULL, 0)
-    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, normalize, NULL, 0)
-    PHP_ME(Geometry, setPrecision, NULL, 0)
-    PHP_ME(Geometry, getPrecision, NULL, 0)
-    PHP_ME(Geometry, extractUniquePoints, NULL, 0)
-    PHP_ME(Geometry, disjoint, NULL, 0)
-    PHP_ME(Geometry, touches, NULL, 0)
-    PHP_ME(Geometry, intersects, NULL, 0)
-    PHP_ME(Geometry, crosses, NULL, 0)
-    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)
-    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, typeName, NULL, 0)
-    PHP_ME(Geometry, typeId, NULL, 0)
-    PHP_ME(Geometry, getSRID, NULL, 0)
-    PHP_ME(Geometry, setSRID, NULL, 0)
-    PHP_ME(Geometry, numGeometries, NULL, 0)
-    PHP_ME(Geometry, geometryN, NULL, 0)
-    PHP_ME(Geometry, numInteriorRings, NULL, 0)
-    PHP_ME(Geometry, numPoints, NULL, 0)
-    PHP_ME(Geometry, getX, NULL, 0)
-    PHP_ME(Geometry, getY, NULL, 0)
-    PHP_ME(Geometry, interiorRingN, NULL, 0)
-    PHP_ME(Geometry, exteriorRing, NULL, 0)
-    PHP_ME(Geometry, numCoordinates, NULL, 0)
-    PHP_ME(Geometry, dimension, NULL, 0)
-    PHP_ME(Geometry, coordinateDimension, NULL, 0)
-    PHP_ME(Geometry, pointN, NULL, 0)
-    PHP_ME(Geometry, startPoint, NULL, 0)
-    PHP_ME(Geometry, endPoint, NULL, 0)
-    PHP_ME(Geometry, area, NULL, 0)
-    PHP_ME(Geometry, length, NULL, 0)
-    PHP_ME(Geometry, distance, NULL, 0)
-    PHP_ME(Geometry, hausdorffDistance, NULL, 0)
-    PHP_ME(Geometry, snapTo, NULL, 0)
-    PHP_ME(Geometry, node, NULL, 0)
-    PHP_ME(Geometry, delaunayTriangulation, NULL, 0)
-    PHP_ME(Geometry, voronoiDiagram, NULL, 0)
-    PHP_ME(Geometry, clipByRect, NULL, 0)
-    {NULL, NULL, NULL}
-};
-
-static zend_class_entry *Geometry_ce_ptr;
-
-static zend_object_handlers Geometry_object_handlers;
-
-/* Geometry serializer */
-
-static GEOSWKBWriter* Geometry_serializer = 0;
-
-static GEOSWKBWriter* getGeometrySerializer()
-{
-    if ( ! Geometry_serializer ) {
-        Geometry_serializer = GEOSWKBWriter_create();
-        GEOSWKBWriter_setIncludeSRID(Geometry_serializer, 1);
-        GEOSWKBWriter_setOutputDimension(Geometry_serializer, 3);
-    }
-    return Geometry_serializer;
-}
-
-static void delGeometrySerializer()
-{
-    if ( Geometry_serializer ) {
-        GEOSWKBWriter_destroy(Geometry_serializer);
-    }
-}
-
-/* Geometry deserializer */
-
-static GEOSWKBReader* Geometry_deserializer = 0;
-
-static GEOSWKBReader* getGeometryDeserializer()
-{
-    if ( ! Geometry_deserializer ) {
-        Geometry_deserializer = GEOSWKBReader_create();
-    }
-    return Geometry_deserializer;
-}
-
-static void delGeometryDeserializer()
-{
-    if ( Geometry_deserializer ) {
-        GEOSWKBReader_destroy(Geometry_deserializer);
-    }
-}
-
-/* Serializer function for GEOSGeometry */
-
-static int
-Geometry_serialize(zval *object, unsigned char **buffer, zend_uint *buf_len,
-        zend_serialize_data *data TSRMLS_DC)
-{
-    GEOSWKBWriter *serializer;
-    GEOSGeometry *geom;
-    char* ret;
-    size_t retsize;
-
-
-    serializer = getGeometrySerializer();
-    geom = (GEOSGeometry*)getRelay(object, Geometry_ce_ptr);
-
-    /* NOTE: we might be fine using binary here */
-    ret = (char*)GEOSWKBWriter_writeHEX(serializer, geom, &retsize);
-    /* we'll probably get an exception if ret is null */
-    if ( ! ret ) return FAILURE;
-
-    *buffer = (unsigned char*)estrndup(ret, retsize);
-    GEOSFree(ret);
-
-    *buf_len = retsize;
-
-    return SUCCESS; 
-}
-
-static int
-Geometry_deserialize(zval **object, zend_class_entry *ce, const unsigned char *buf,
-        zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC)
-{
-    GEOSWKBReader* deserializer;
-    GEOSGeometry* geom;
-
-    deserializer = getGeometryDeserializer();
-    geom = GEOSWKBReader_readHEX(deserializer, buf, buf_len);
-
-    /* TODO: check zend_class_entry being what we expect! */
-    if ( ce != Geometry_ce_ptr ) {
-        php_error_docref(NULL TSRMLS_CC, E_ERROR,
-                "Geometry_deserialize called with unexpected zend_class_entry");
-        return FAILURE;
-    }
-    object_init_ex(*object, ce);
-    setRelay(*object, geom);
-
-    return SUCCESS;
-}
-
-/*
- * Push components of the given geometry
- * to the given array zval.
- * Components geometries are cloned.
- * NOTE: collection components are not descended into
- */
-static void
-dumpGeometry(GEOSGeometry* g, zval* array)
-{
-    TSRMLS_FETCH();
-    int ngeoms, i;
-
-    /*
-    MAKE_STD_ZVAL(array);
-    array_init(array);
-    */
-
-    ngeoms = GEOSGetNumGeometries(g);
-    for (i=0; i<ngeoms; ++i)
-    {
-        zval *tmp;
-        GEOSGeometry* cc;
-        const GEOSGeometry* c = GEOSGetGeometryN(g, i);
-        if ( ! c ) continue; /* should get an exception */
-        /* we _need_ to clone as this one is owned by 'g' */
-        cc = GEOSGeom_clone(c);
-        if ( ! cc ) continue; /* should get an exception */
-
-        MAKE_STD_ZVAL(tmp);
-        object_init_ex(tmp, Geometry_ce_ptr);
-        setRelay(tmp, cc);
-        add_next_index_zval(array, tmp); 
-    }
-}
-
-
-static void
-Geometry_dtor (void *object TSRMLS_DC)
-{
-    Proxy *obj = (Proxy *)object;
-    GEOSGeom_destroy((GEOSGeometry*)obj->relay);
-
-    zend_hash_destroy(obj->std.properties);
-    FREE_HASHTABLE(obj->std.properties);
-
-    efree(obj);
-}
-
-static zend_object_value
-Geometry_create_obj (zend_class_entry *type TSRMLS_DC)
-{
-    return Gen_create_obj(type, Geometry_dtor, &Geometry_object_handlers);
-}
-
-
-PHP_METHOD(Geometry, __construct)
-{
-    php_error_docref(NULL TSRMLS_CC, E_ERROR,
-            "GEOSGeometry can't be constructed using new, check WKTReader");
-
-}
-
-PHP_METHOD(Geometry, __toString)
-{
-    GEOSGeometry *geom;
-    GEOSWKTWriter *writer;
-    char *wkt;
-    char *ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-    writer = GEOSWKTWriter_create();
-    /* NOTE: if we get an exception before reaching
-     *       GEOSWKTWriter_destory below we'll be leaking memory.
-     *       One fix could be storing the object in a refcounted
-     *       zval.
-     */
-    GEOSWKTWriter_setTrim(writer, 1);
-
-    wkt = GEOSWKTWriter_write(writer, geom);
-    /* we'll probably get an exception if wkt is null */
-    if ( ! wkt ) RETURN_NULL();
-
-    GEOSWKTWriter_destroy(writer);
-    
-
-    ret = estrdup(wkt);
-    GEOSFree(wkt);
-
-    RETURN_STRING(ret, 0);
-}
-
-PHP_METHOD(Geometry, project)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    zval *zobj;
-    zend_bool normalized = 0;
-    double ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|b", &zobj,
-            &normalized) == FAILURE) {
-        RETURN_NULL();
-    }
-    other = getRelay(zobj, Geometry_ce_ptr);
-
-    if ( normalized ) {
-        ret = GEOSProjectNormalized(this, other);
-    } else {
-        ret = GEOSProject(this, other);
-    }
-    if ( ret < 0 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_DOUBLE(ret);
-}
-
-PHP_METHOD(Geometry, interpolate)
-{
-    GEOSGeometry *this;
-    double dist;
-    GEOSGeometry *ret;
-    zend_bool normalized = 0;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|b",
-            &dist, &normalized) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    if ( normalized ) {
-        ret = GEOSInterpolateNormalized(this, dist);
-    } else {
-        ret = GEOSInterpolate(this, dist);
-    }
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry::buffer(dist, [<styleArray>])
- *
- * styleArray keys supported:
- *  'quad_segs'
- *       Type: int 
- *       Number of segments used to approximate
- *       a quarter circle (defaults to 8).
- *  'endcap'
- *       Type: long
- *       Endcap style (defaults to GEOSBUF_CAP_ROUND)
- *  'join'
- *       Type: long
- *       Join style (defaults to GEOSBUF_JOIN_ROUND)
- *  'mitre_limit'
- *       Type: double
- *       mitre ratio limit (only affects joins with GEOSBUF_JOIN_MITRE style)
- *       'miter_limit' is also accepted as a synonym for 'mitre_limit'.
- *  'single_sided'
- *       Type: bool
- *       If true buffer lines only on one side, so that the input line
- *       will be a portion of the boundary of the returned polygon.
- *       Only applies to lineal input. Defaults to false.
- */
-PHP_METHOD(Geometry, buffer)
-{
-    GEOSGeometry *this;
-    double dist;
-    GEOSGeometry *ret;
-    GEOSBufferParams *params;
-    static const double default_mitreLimit = 5.0;
-    static const int default_endCapStyle = GEOSBUF_CAP_ROUND;
-    static const int default_joinStyle = GEOSBUF_JOIN_ROUND;
-    static const int default_quadSegs = 8;
-    long int quadSegs = default_quadSegs;
-    long int endCapStyle = default_endCapStyle;
-    long int joinStyle = default_joinStyle;
-    double mitreLimit = default_mitreLimit;
-    long singleSided = 0;
-    zval *style_val = NULL;
-    zval **data;
-    HashTable *style;
-    char *key;
-    ulong index;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|a",
-            &dist, &style_val) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    params = GEOSBufferParams_create();
-
-    if ( style_val )
-    {
-        style = HASH_OF(style_val);
-        while(zend_hash_get_current_key(style, &key, &index, 0)
-              == HASH_KEY_IS_STRING)
-        {
-            if(!strcmp(key, "quad_segs"))
-            {
-                zend_hash_get_current_data(style, (void**)&data);
-                quadSegs = getZvalAsLong(*data);
-                GEOSBufferParams_setQuadrantSegments(params, quadSegs);
-            }
-            else if(!strcmp(key, "endcap"))
-            {
-                zend_hash_get_current_data(style, (void**)&data);
-                endCapStyle = getZvalAsLong(*data);
-                GEOSBufferParams_setEndCapStyle(params, endCapStyle);
-            }
-            else if(!strcmp(key, "join"))
-            {
-                zend_hash_get_current_data(style, (void**)&data);
-                joinStyle = getZvalAsLong(*data);
-                GEOSBufferParams_setJoinStyle(params, joinStyle);
-            }
-            else if(!strcmp(key, "mitre_limit"))
-            {
-                zend_hash_get_current_data(style, (void**)&data);
-                mitreLimit = getZvalAsDouble(*data);
-                GEOSBufferParams_setMitreLimit(params, mitreLimit);
-            }
-            else if(!strcmp(key, "single_sided"))
-            {
-                zend_hash_get_current_data(style, (void**)&data);
-                singleSided = getZvalAsLong(*data);
-                GEOSBufferParams_setSingleSided(params, singleSided);
-            }
-
-            zend_hash_move_forward(style);
-        }
-    }
-
-    ret = GEOSBufferWithParams(this, params, dist);
-    GEOSBufferParams_destroy(params);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry::offsetCurve(dist, [<styleArray>])
- *
- * styleArray keys supported:
- *  'quad_segs'
- *       Type: int 
- *       Number of segments used to approximate
- *       a quarter circle (defaults to 8).
- *  'join'
- *       Type: long
- *       Join style (defaults to GEOSBUF_JOIN_ROUND)
- *  'mitre_limit'
- *       Type: double
- *       mitre ratio limit (only affects joins with GEOSBUF_JOIN_MITRE style)
- *       'miter_limit' is also accepted as a synonym for 'mitre_limit'.
- */
-PHP_METHOD(Geometry, offsetCurve)
-{
-    GEOSGeometry *this;
-    double dist;
-    GEOSGeometry *ret;
-    static const double default_mitreLimit = 5.0;
-    static const int default_joinStyle = GEOSBUF_JOIN_ROUND;
-    static const int default_quadSegs = 8;
-    long int quadSegs = default_quadSegs;
-    long int joinStyle = default_joinStyle;
-    double mitreLimit = default_mitreLimit;
-    zval *style_val = NULL;
-    zval **data;
-    HashTable *style;
-    char *key;
-    ulong index;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|a",
-            &dist, &style_val) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    if ( style_val )
-    {
-        style = HASH_OF(style_val);
-        while(zend_hash_get_current_key(style, &key, &index, 0)
-              == HASH_KEY_IS_STRING)
-        {
-            if(!strcmp(key, "quad_segs"))
-            {
-                zend_hash_get_current_data(style, (void**)&data);
-                quadSegs = getZvalAsLong(*data);
-            }
-            else if(!strcmp(key, "join"))
-            {
-                zend_hash_get_current_data(style, (void**)&data);
-                joinStyle = getZvalAsLong(*data);
-            }
-            else if(!strcmp(key, "mitre_limit"))
-            {
-                zend_hash_get_current_data(style, (void**)&data);
-                mitreLimit = getZvalAsDouble(*data);
-            }
-
-            zend_hash_move_forward(style);
-        }
-    }
-
-    ret = GEOSOffsetCurve(this, dist, quadSegs, joinStyle, mitreLimit);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-PHP_METHOD(Geometry, envelope)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSEnvelope(this);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-PHP_METHOD(Geometry, intersection)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    GEOSGeometry *ret;
-    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 = GEOSIntersection(this, other);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry GEOSGeometry::clipByRect(xmin,ymin,xmax,ymax)
- */
-PHP_METHOD(Geometry, clipByRect)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-    double xmin,ymin,xmax,ymax;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd",
-            &xmin, &ymin, &xmax, &ymax) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    ret = GEOSClipByRect(this, xmin, ymin, xmax, ymax);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-PHP_METHOD(Geometry, convexHull)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSConvexHull(this);
-    if ( ret == NULL ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-PHP_METHOD(Geometry, difference)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    GEOSGeometry *ret;
-    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 = GEOSDifference(this, other);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-PHP_METHOD(Geometry, symDifference)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    GEOSGeometry *ret;
-    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 = GEOSSymDifference(this, other);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-PHP_METHOD(Geometry, boundary)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSBoundary(this);
-    if ( ret == NULL ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry::union(otherGeom)
- * GEOSGeometry::union()
- */
-PHP_METHOD(Geometry, union)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    GEOSGeometry *ret;
-    zval *zobj = NULL;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|o", &zobj)
-            == FAILURE) {
-        RETURN_NULL();
-    }
-
-    if ( zobj ) {
-        other = getRelay(zobj, Geometry_ce_ptr);
-        ret = GEOSUnion(this, other);
-    } else {
-        ret = GEOSUnaryUnion(this);
-    }
-
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry::pointOnSurface()
- */
-PHP_METHOD(Geometry, pointOnSurface)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSPointOnSurface(this);
-    if ( ret == NULL ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry::centroid()
- */
-PHP_METHOD(Geometry, centroid)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGetCentroid(this);
-    if ( ret == NULL ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry::relate(otherGeom)
- * GEOSGeometry::relate(otherGeom, pattern)
- */
-PHP_METHOD(Geometry, relate)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    zval *zobj;
-    char* pat = NULL;
-    int patlen;
-    int retInt;
-    zend_bool retBool;
-    char* retStr;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|s",
-        &zobj, &pat, &patlen) == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    other = getRelay(zobj, Geometry_ce_ptr);
-
-    if ( ! pat ) {
-        /* we'll compute it */
-        pat = GEOSRelate(this, other);
-        if ( ! pat ) RETURN_NULL(); /* should get an exception first */
-        retStr = estrdup(pat);
-        GEOSFree(pat);
-        RETURN_STRING(retStr, 0);
-    } else {
-        retInt = GEOSRelatePattern(this, other, pat);
-        if ( retInt == 2 ) RETURN_NULL(); /* should get an exception first */
-        retBool = retInt;
-        RETURN_BOOL(retBool);
-    }
-
-}
-
-/**
- * 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)
- */
-PHP_METHOD(Geometry, simplify)
-{
-    GEOSGeometry *this;
-    double tolerance;
-    zend_bool preserveTopology = 0;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|b",
-            &tolerance, &preserveTopology) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    if ( preserveTopology ) {
-        ret = GEOSTopologyPreserveSimplify(this, tolerance);
-    } else {
-        ret = GEOSSimplify(this, tolerance);
-    }
-
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry GEOSGeometry::setPrecision(gridsize, [flags])
- */
-PHP_METHOD(Geometry, setPrecision)
-{
-    GEOSGeometry *this;
-    double gridSize;
-    long int flags = 0;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|l",
-            &gridSize, &flags) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    ret = GEOSGeom_setPrecision(this, gridSize, flags);
-
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * double GEOSGeometry::getPrecision()
- */
-PHP_METHOD(Geometry, getPrecision)
-{
-    GEOSGeometry *geom;
-    double prec;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    prec = GEOSGeom_getPrecision(geom);
-    if ( prec < 0 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_DOUBLE(prec);
-}
-
-/**
- * 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)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGeom_extractUniquePoints(this);
-    if ( ret == NULL ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * bool GEOSGeometry::disjoint(GEOSGeometry)
- */
-PHP_METHOD(Geometry, disjoint)
-{
-    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 = GEOSDisjoint(this, other);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * bool GEOSGeometry::touches(GEOSGeometry)
- */
-PHP_METHOD(Geometry, touches)
-{
-    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 = GEOSTouches(this, other);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * bool GEOSGeometry::intersects(GEOSGeometry)
- */
-PHP_METHOD(Geometry, intersects)
-{
-    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 = GEOSIntersects(this, other);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * bool GEOSGeometry::crosses(GEOSGeometry)
- */
-PHP_METHOD(Geometry, crosses)
-{
-    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 = GEOSCrosses(this, other);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * bool GEOSGeometry::within(GEOSGeometry)
- */
-PHP_METHOD(Geometry, within)
-{
-    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 = GEOSWithin(this, other);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * bool GEOSGeometry::contains(GEOSGeometry)
- */
-PHP_METHOD(Geometry, contains)
-{
-    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 = GEOSContains(this, other);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * bool GEOSGeometry::overlaps(GEOSGeometry)
- */
-PHP_METHOD(Geometry, overlaps)
-{
-    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 = GEOSOverlaps(this, other);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * 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)
-{
-    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 = GEOSEquals(this, other);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * bool GEOSGeometry::equalsExact(GEOSGeometry)
- * bool GEOSGeometry::equalsExact(GEOSGeometry, double tolerance)
- */
-PHP_METHOD(Geometry, equalsExact)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    int ret;
-    double tolerance = 0;
-    zend_bool retBool;
-    zval *zobj;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|d",
-        &zobj, &tolerance) == FAILURE) {
-        RETURN_NULL();
-    }
-    other = getRelay(zobj, Geometry_ce_ptr);
-
-    ret = GEOSEqualsExact(this, other, tolerance);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * bool GEOSGeometry::isEmpty()
- */
-PHP_METHOD(Geometry, isEmpty)
-{
-    GEOSGeometry *this;
-    int ret;
-    zend_bool retBool;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSisEmpty(this);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    retBool = ret;
-    RETURN_BOOL(retBool);
-}
-
-/**
- * array GEOSGeometry::checkValidity()
- */
-PHP_METHOD(Geometry, checkValidity)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *location = NULL;
-    int ret;
-    char *reason = NULL;
-    zend_bool retBool;
-    char *reasonVal = NULL;
-    zval *locationVal = NULL;
-    long int flags = 0;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l",
-        &flags) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    ret = GEOSisValidDetail(this, flags, &reason, &location);
-    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
-
-    if ( reason ) {
-        reasonVal = estrdup(reason);
-        GEOSFree(reason);
-    }
-
-    if ( location ) {
-        MAKE_STD_ZVAL(locationVal);
-        object_init_ex(locationVal, Geometry_ce_ptr);
-        setRelay(locationVal, location);
-    }
-
-    retBool = ret;
-
-    /* return value is an array */
-    array_init(return_value);
-    add_assoc_bool(return_value, "valid", retBool); 
-    if ( reasonVal ) add_assoc_string(return_value, "reason", reasonVal, 0); 
-    if ( locationVal ) add_assoc_zval(return_value, "location", locationVal); 
-
-}
-
-/**
- * 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);
-}
-
-/**
- * string GEOSGeometry::typeName()
- */
-PHP_METHOD(Geometry, typeName)
-{
-    GEOSGeometry *this;
-    char *typ;
-    char *typVal;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    /* TODO: define constant strings instead... */
-
-    typ = GEOSGeomType(this);
-    if ( ! typ ) RETURN_NULL(); /* should get an exception first */
-
-    typVal = estrdup(typ);
-    GEOSFree(typ);
-
-    RETURN_STRING(typVal, 0);
-}
-
-/**
- * long GEOSGeometry::typeId()
- */
-PHP_METHOD(Geometry, typeId)
-{
-    GEOSGeometry *this;
-    long typ;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    /* TODO: define constant strings instead... */
-
-    typ = GEOSGeomTypeId(this);
-    if ( typ == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_LONG(typ);
-}
-
-/**
- * long GEOSGeometry::getSRID()
- */
-PHP_METHOD(Geometry, getSRID)
-{
-    GEOSGeometry *geom;
-    long int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGetSRID(geom);
-
-    RETURN_LONG(ret);
-}
-
-/**
- * void GEOSGeometry::setSRID(long)
- */
-PHP_METHOD(Geometry, setSRID)
-{
-    GEOSGeometry *geom;
-    long int srid;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
-        &srid) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    GEOSSetSRID(geom, srid);
-}
-
-/**
- * long GEOSGeometry::numGeometries()
- */
-PHP_METHOD(Geometry, numGeometries)
-{
-    GEOSGeometry *geom;
-    long int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGetNumGeometries(geom);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_LONG(ret);
-}
-
-/**
- * GEOSGeometry GEOSGeometry::geometryN()
- */
-PHP_METHOD(Geometry, geometryN)
-{
-    GEOSGeometry *geom;
-    const GEOSGeometry *c;
-    GEOSGeometry *cc;
-    long int num;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
-        &num) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    if ( num >= GEOSGetNumGeometries(geom) ) RETURN_NULL(); 
-    c = GEOSGetGeometryN(geom, num);
-    if ( ! c ) RETURN_NULL(); /* should get an exception first */
-    cc = GEOSGeom_clone(c);
-    if ( ! cc ) RETURN_NULL(); /* should get an exception first */
-
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, cc);
-}
-
-/**
- * long GEOSGeometry::numInteriorRings()
- */
-PHP_METHOD(Geometry, numInteriorRings)
-{
-    GEOSGeometry *geom;
-    long int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGetNumInteriorRings(geom);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_LONG(ret);
-}
-
-/**
- * long GEOSGeometry::numPoints()
- */
-PHP_METHOD(Geometry, numPoints)
-{
-    GEOSGeometry *geom;
-    long int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGeomGetNumPoints(geom);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_LONG(ret);
-}
-
-/**
- * double GEOSGeometry::getX()
- */
-PHP_METHOD(Geometry, getX)
-{
-    GEOSGeometry *geom;
-    int ret;
-    double x;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGeomGetX(geom, &x);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_DOUBLE(x);
-}
-
-/**
- * double GEOSGeometry::getY()
- */
-PHP_METHOD(Geometry, getY)
-{
-    GEOSGeometry *geom;
-    int ret;
-    double y;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGeomGetY(geom, &y);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_DOUBLE(y);
-}
-
-/**
- * GEOSGeometry GEOSGeometry::interiorRingN()
- */
-PHP_METHOD(Geometry, interiorRingN)
-{
-    GEOSGeometry *geom;
-    const GEOSGeometry *c;
-    GEOSGeometry *cc;
-    long int num;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
-        &num) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    if ( num >= GEOSGetNumInteriorRings(geom) ) RETURN_NULL(); 
-    c = GEOSGetInteriorRingN(geom, num);
-    if ( ! c ) RETURN_NULL(); /* should get an exception first */
-    cc = GEOSGeom_clone(c);
-    if ( ! cc ) RETURN_NULL(); /* should get an exception first */
-
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, cc);
-}
-
-/**
- * GEOSGeometry GEOSGeometry::exteriorRing()
- */
-PHP_METHOD(Geometry, exteriorRing)
-{
-    GEOSGeometry *geom;
-    const GEOSGeometry *c;
-    GEOSGeometry *cc;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    c = GEOSGetExteriorRing(geom);
-    if ( ! c ) RETURN_NULL(); /* should get an exception first */
-    cc = GEOSGeom_clone(c);
-    if ( ! cc ) RETURN_NULL(); /* should get an exception first */
-
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, cc);
-}
-
-/**
- * long GEOSGeometry::numCoordinates()
- */
-PHP_METHOD(Geometry, numCoordinates)
-{
-    GEOSGeometry *geom;
-    long int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGetNumCoordinates(geom);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_LONG(ret);
-}
-
-/**
- * long GEOSGeometry::dimension()
- * 0:puntual 1:lineal 2:areal
- */
-PHP_METHOD(Geometry, dimension)
-{
-    GEOSGeometry *geom;
-    long int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGeom_getDimensions(geom);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_LONG(ret);
-}
-
-/**
- * long GEOSGeometry::coordinateDimension()
- */
-PHP_METHOD(Geometry, coordinateDimension)
-{
-    GEOSGeometry *geom;
-    long int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSGeom_getCoordinateDimension(geom);
-    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_LONG(ret);
-}
-
-/**
- * GEOSGeometry GEOSGeometry::pointN()
- */
-PHP_METHOD(Geometry, pointN)
-{
-    GEOSGeometry *geom;
-    GEOSGeometry *c;
-    long int num;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
-        &num) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    if ( num >= GEOSGeomGetNumPoints(geom) ) RETURN_NULL(); 
-    c = GEOSGeomGetPointN(geom, num);
-    if ( ! c ) RETURN_NULL(); /* should get an exception first */
-
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, c);
-}
-
-/**
- * GEOSGeometry GEOSGeometry::startPoint()
- */
-PHP_METHOD(Geometry, startPoint)
-{
-    GEOSGeometry *geom;
-    GEOSGeometry *c;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    c = GEOSGeomGetStartPoint(geom);
-    if ( ! c ) RETURN_NULL(); /* should get an exception first */
-
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, c);
-}
-
-/**
- * GEOSGeometry GEOSGeometry::endPoint()
- */
-PHP_METHOD(Geometry, endPoint)
-{
-    GEOSGeometry *geom;
-    GEOSGeometry *c;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    c = GEOSGeomGetEndPoint(geom);
-    if ( ! c ) RETURN_NULL(); /* should get an exception first */
-
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, c);
-}
-
-/**
- * double GEOSGeometry::area()
- */
-PHP_METHOD(Geometry, area)
-{
-    GEOSGeometry *geom;
-    double area;
-    int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSArea(geom, &area);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_DOUBLE(area);
-}
-
-/**
- * double GEOSGeometry::length()
- */
-PHP_METHOD(Geometry, length)
-{
-    GEOSGeometry *geom;
-    double length;
-    int ret;
-
-    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSLength(geom, &length);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_DOUBLE(length);
-}
-
-/**
- * double GEOSGeometry::distance(GEOSGeometry)
- */
-PHP_METHOD(Geometry, distance)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    zval *zobj;
-    double dist;
-    int ret;
-
-    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 = GEOSDistance(this, other, &dist);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_DOUBLE(dist);
-}
-
-/**
- * double GEOSGeometry::hausdorffDistance(GEOSGeometry)
- */
-PHP_METHOD(Geometry, hausdorffDistance)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    zval *zobj;
-    double dist;
-    int ret;
-
-    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 = GEOSHausdorffDistance(this, other, &dist);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    RETURN_DOUBLE(dist);
-}
-
-PHP_METHOD(Geometry, snapTo)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *other;
-    GEOSGeometry *ret;
-    double tolerance;
-    zval *zobj;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "od", &zobj,
-            &tolerance) == FAILURE) {
-        RETURN_NULL();
-    }
-    other = getRelay(zobj, Geometry_ce_ptr);
-
-    ret = GEOSSnap(this, other, tolerance);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-PHP_METHOD(Geometry, node)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    ret = GEOSNode(this);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-
-
-/* -- class GEOSWKTReader -------------------- */
-
-PHP_METHOD(WKTReader, __construct);
-PHP_METHOD(WKTReader, read);
-
-static zend_function_entry WKTReader_methods[] = {
-    PHP_ME(WKTReader, __construct, NULL, 0)
-    PHP_ME(WKTReader, read, NULL, 0)
-    {NULL, NULL, NULL}
-};
-
-static zend_class_entry *WKTReader_ce_ptr;
-
-static zend_object_handlers WKTReader_object_handlers;
-
-static void
-WKTReader_dtor (void *object TSRMLS_DC)
-{
-    Proxy *obj = (Proxy *)object;
-    GEOSWKTReader_destroy((GEOSWKTReader*)obj->relay);
-
-    zend_hash_destroy(obj->std.properties);
-    FREE_HASHTABLE(obj->std.properties);
-
-    efree(obj);
-}
-
-static zend_object_value
-WKTReader_create_obj (zend_class_entry *type TSRMLS_DC)
-{
-    return Gen_create_obj(type, WKTReader_dtor, &WKTReader_object_handlers);
-}
-
-
-PHP_METHOD(WKTReader, __construct)
-{
-    GEOSWKTReader* obj;
-    zval *object = getThis();
-
-    obj = GEOSWKTReader_create();
-    if ( ! obj ) {
-        php_error_docref(NULL TSRMLS_CC, E_ERROR,
-                "GEOSWKTReader_create() failed (didn't initGEOS?)");
-    }
-
-    setRelay(object, obj);
-}
-
-PHP_METHOD(WKTReader, read)
-{
-    GEOSWKTReader *reader;
-    GEOSGeometry *geom;
-    char* wkt;
-    int wktlen;
-
-    reader = (GEOSWKTReader*)getRelay(getThis(), WKTReader_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
-        &wkt, &wktlen) == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    geom = GEOSWKTReader_read(reader, wkt);
-    /* we'll probably get an exception if geom is null */
-    if ( ! geom ) RETURN_NULL();
- 
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, geom);
-
-}
-
-/* -- class GEOSWKTWriter -------------------- */
-
-PHP_METHOD(WKTWriter, __construct);
-PHP_METHOD(WKTWriter, write);
-PHP_METHOD(WKTWriter, setTrim);
-PHP_METHOD(WKTWriter, setRoundingPrecision);
-PHP_METHOD(WKTWriter, setOutputDimension);
-PHP_METHOD(WKTWriter, getOutputDimension);
-PHP_METHOD(WKTWriter, setOld3D);
-
-static zend_function_entry WKTWriter_methods[] = {
-    PHP_ME(WKTWriter, __construct, NULL, 0)
-    PHP_ME(WKTWriter, write, NULL, 0)
-    PHP_ME(WKTWriter, setTrim, NULL, 0)
-    PHP_ME(WKTWriter, setRoundingPrecision, NULL, 0)
-    PHP_ME(WKTWriter, setOutputDimension, NULL, 0)
-    PHP_ME(WKTWriter, getOutputDimension, NULL, 0)
-    PHP_ME(WKTWriter, setOld3D, NULL, 0)
-    {NULL, NULL, NULL}
-};
-
-static zend_class_entry *WKTWriter_ce_ptr;
-
-static zend_object_handlers WKTWriter_object_handlers;
-
-static void
-WKTWriter_dtor (void *object TSRMLS_DC)
-{
-    Proxy *obj = (Proxy *)object;
-    GEOSWKTWriter_destroy((GEOSWKTWriter*)obj->relay);
-
-    zend_hash_destroy(obj->std.properties);
-    FREE_HASHTABLE(obj->std.properties);
-
-    efree(obj);
-}
-
-static zend_object_value
-WKTWriter_create_obj (zend_class_entry *type TSRMLS_DC)
-{
-    return Gen_create_obj(type, WKTWriter_dtor, &WKTWriter_object_handlers);
-}
-
-PHP_METHOD(WKTWriter, __construct)
-{
-    GEOSWKTWriter* obj;
-    zval *object = getThis();
-
-    obj = GEOSWKTWriter_create();
-    if ( ! obj ) {
-        php_error_docref(NULL TSRMLS_CC, E_ERROR,
-                "GEOSWKTWriter_create() failed (didn't initGEOS?)");
-    }
-
-    setRelay(object, obj);
-}
-
-PHP_METHOD(WKTWriter, write)
-{
-    GEOSWKTWriter *writer;
-    zval *zobj;
-    GEOSGeometry *geom;
-    char* wkt;
-    char* retstr;
-
-    writer = (GEOSWKTWriter*)getRelay(getThis(), WKTWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zobj)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    geom = getRelay(zobj, Geometry_ce_ptr);
-
-    wkt = GEOSWKTWriter_write(writer, geom);
-    /* we'll probably get an exception if wkt is null */
-    if ( ! wkt ) RETURN_NULL();
-
-    retstr = estrdup(wkt);
-    GEOSFree(wkt);
-
-    RETURN_STRING(retstr, 0);
-}
-
-PHP_METHOD(WKTWriter, setTrim)
-{
-    GEOSWKTWriter *writer;
-    zend_bool trimval;
-    char trim;
-
-    writer = (GEOSWKTWriter*)getRelay(getThis(), WKTWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &trimval)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    trim = trimval;
-    GEOSWKTWriter_setTrim(writer, trim);
-}
-
-PHP_METHOD(WKTWriter, setRoundingPrecision)
-{
-    GEOSWKTWriter *writer;
-    long int prec;
-
-    writer = (GEOSWKTWriter*)getRelay(getThis(), WKTWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prec)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    GEOSWKTWriter_setRoundingPrecision(writer, prec);
-}
-
-/**
- * void GEOSWKTWriter::setOutputDimension()
- */
-PHP_METHOD(WKTWriter, setOutputDimension)
-{
-    GEOSWKTWriter *writer;
-    long int dim;
-
-    writer = (GEOSWKTWriter*)getRelay(getThis(), WKTWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &dim)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    GEOSWKTWriter_setOutputDimension(writer, dim);
-}
-
-/**
- * long GEOSWKTWriter::getOutputDimension()
- */
-PHP_METHOD(WKTWriter, getOutputDimension)
-{
-    GEOSWKTWriter *writer;
-    long int ret;
-
-    writer = (GEOSWKTWriter*)getRelay(getThis(), WKTWriter_ce_ptr);
-
-    ret = GEOSWKTWriter_getOutputDimension(writer);
-
-    RETURN_LONG(ret);
-}
-
-PHP_METHOD(WKTWriter, setOld3D)
-{
-    GEOSWKTWriter *writer;
-    zend_bool bval;
-    int val;
-
-    writer = (GEOSWKTWriter*)getRelay(getThis(), WKTWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &bval)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    val = bval;
-    GEOSWKTWriter_setOld3D(writer, val);
-}
-
-/* -- class GEOSWKBWriter -------------------- */
-
-PHP_METHOD(WKBWriter, __construct);
-PHP_METHOD(WKBWriter, getOutputDimension);
-PHP_METHOD(WKBWriter, setOutputDimension);
-PHP_METHOD(WKBWriter, getByteOrder);
-PHP_METHOD(WKBWriter, setByteOrder);
-PHP_METHOD(WKBWriter, setIncludeSRID);
-PHP_METHOD(WKBWriter, getIncludeSRID);
-PHP_METHOD(WKBWriter, write);
-PHP_METHOD(WKBWriter, writeHEX);
-
-static zend_function_entry WKBWriter_methods[] = {
-    PHP_ME(WKBWriter, __construct, NULL, 0)
-    PHP_ME(WKBWriter, getOutputDimension, NULL, 0)
-    PHP_ME(WKBWriter, setOutputDimension, NULL, 0)
-    PHP_ME(WKBWriter, getByteOrder, NULL, 0)
-    PHP_ME(WKBWriter, setByteOrder, NULL, 0)
-    PHP_ME(WKBWriter, getIncludeSRID, NULL, 0)
-    PHP_ME(WKBWriter, setIncludeSRID, NULL, 0)
-    PHP_ME(WKBWriter, write, NULL, 0)
-    PHP_ME(WKBWriter, writeHEX, NULL, 0)
-    {NULL, NULL, NULL}
-};
-
-static zend_class_entry *WKBWriter_ce_ptr;
-
-static zend_object_handlers WKBWriter_object_handlers;
-
-static void
-WKBWriter_dtor (void *object TSRMLS_DC)
-{
-    Proxy *obj = (Proxy *)object;
-    GEOSWKBWriter_destroy((GEOSWKBWriter*)obj->relay);
-
-    zend_hash_destroy(obj->std.properties);
-    FREE_HASHTABLE(obj->std.properties);
-
-    efree(obj);
-}
-
-static zend_object_value
-WKBWriter_create_obj (zend_class_entry *type TSRMLS_DC)
-{
-    return Gen_create_obj(type, WKBWriter_dtor, &WKBWriter_object_handlers);
-}
-
-/**
- * GEOSWKBWriter w = new GEOSWKBWriter()
- */
-PHP_METHOD(WKBWriter, __construct)
-{
-    GEOSWKBWriter* obj;
-    zval *object = getThis();
-
-    obj = GEOSWKBWriter_create();
-    if ( ! obj ) {
-        php_error_docref(NULL TSRMLS_CC, E_ERROR,
-                "GEOSWKBWriter_create() failed (didn't initGEOS?)");
-    }
-
-    setRelay(object, obj);
-}
-
-/**
- * long GEOSWKBWriter::getOutputDimension();
- */
-PHP_METHOD(WKBWriter, getOutputDimension)
-{
-    GEOSWKBWriter *writer;
-    long int ret;
-
-    writer = (GEOSWKBWriter*)getRelay(getThis(), WKBWriter_ce_ptr);
-
-    ret = GEOSWKBWriter_getOutputDimension(writer);
-
-    RETURN_LONG(ret);
-}
-
-/**
- * void GEOSWKBWriter::setOutputDimension(dims);
- */
-PHP_METHOD(WKBWriter, setOutputDimension)
-{
-    GEOSWKBWriter *writer;
-    long int dim;
-
-    writer = (GEOSWKBWriter*)getRelay(getThis(), WKBWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &dim)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    GEOSWKBWriter_setOutputDimension(writer, dim);
-
-}
-
-/**
- * string GEOSWKBWriter::write(GEOSGeometry)
- */
-PHP_METHOD(WKBWriter, write)
-{
-    GEOSWKBWriter *writer;
-    zval *zobj;
-    GEOSGeometry *geom;
-    char *ret;
-    size_t retsize;
-    char* retstr;
-
-    writer = (GEOSWKBWriter*)getRelay(getThis(), WKBWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zobj)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    geom = getRelay(zobj, Geometry_ce_ptr);
-
-    ret = (char*)GEOSWKBWriter_write(writer, geom, &retsize);
-    /* we'll probably get an exception if ret is null */
-    if ( ! ret ) RETURN_NULL();
-
-    retstr = estrndup(ret, retsize);
-    GEOSFree(ret);
-
-    RETURN_STRINGL(retstr, retsize, 0);
-}
-
-/**
- * string GEOSWKBWriter::writeHEX(GEOSGeometry)
- */
-PHP_METHOD(WKBWriter, writeHEX)
-{
-    GEOSWKBWriter *writer;
-    zval *zobj;
-    GEOSGeometry *geom;
-    char *ret;
-    size_t retsize; /* useless... */
-    char* retstr;
-
-    writer = (GEOSWKBWriter*)getRelay(getThis(), WKBWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zobj)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    geom = getRelay(zobj, Geometry_ce_ptr);
-
-    ret = (char*)GEOSWKBWriter_writeHEX(writer, geom, &retsize);
-    /* we'll probably get an exception if ret is null */
-    if ( ! ret ) RETURN_NULL();
-
-    retstr = estrndup(ret, retsize);
-    GEOSFree(ret);
-
-    RETURN_STRING(retstr, 0);
-}
-
-/**
- * long GEOSWKBWriter::getByteOrder();
- */
-PHP_METHOD(WKBWriter, getByteOrder)
-{
-    GEOSWKBWriter *writer;
-    long int ret;
-
-    writer = (GEOSWKBWriter*)getRelay(getThis(), WKBWriter_ce_ptr);
-
-    ret = GEOSWKBWriter_getByteOrder(writer);
-
-    RETURN_LONG(ret);
-}
-
-/**
- * void GEOSWKBWriter::setByteOrder(dims);
- */
-PHP_METHOD(WKBWriter, setByteOrder)
-{
-    GEOSWKBWriter *writer;
-    long int dim;
-
-    writer = (GEOSWKBWriter*)getRelay(getThis(), WKBWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &dim)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    GEOSWKBWriter_setByteOrder(writer, dim);
-
-}
-
-/**
- * bool GEOSWKBWriter::getIncludeSRID();
- */
-PHP_METHOD(WKBWriter, getIncludeSRID)
-{
-    GEOSWKBWriter *writer;
-    int ret;
-    zend_bool retBool;
-
-    writer = (GEOSWKBWriter*)getRelay(getThis(), WKBWriter_ce_ptr);
-
-    ret = GEOSWKBWriter_getIncludeSRID(writer);
-    retBool = ret;
-
-    RETURN_BOOL(retBool);
-}
-
-/**
- * void GEOSWKBWriter::setIncludeSRID(bool);
- */
-PHP_METHOD(WKBWriter, setIncludeSRID)
-{
-    GEOSWKBWriter *writer;
-    int inc;
-    zend_bool incVal;
-
-    writer = (GEOSWKBWriter*)getRelay(getThis(), WKBWriter_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &incVal)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    inc = incVal;
-    GEOSWKBWriter_setIncludeSRID(writer, inc);
-}
-
-/* -- class GEOSWKBReader -------------------- */
-
-PHP_METHOD(WKBReader, __construct);
-PHP_METHOD(WKBReader, read);
-PHP_METHOD(WKBReader, readHEX);
-
-static zend_function_entry WKBReader_methods[] = {
-    PHP_ME(WKBReader, __construct, NULL, 0)
-    PHP_ME(WKBReader, read, NULL, 0)
-    PHP_ME(WKBReader, readHEX, NULL, 0)
-    {NULL, NULL, NULL}
-};
-
-static zend_class_entry *WKBReader_ce_ptr;
-
-static zend_object_handlers WKBReader_object_handlers;
-
-static void
-WKBReader_dtor (void *object TSRMLS_DC)
-{
-    Proxy *obj = (Proxy *)object;
-    GEOSWKBReader_destroy((GEOSWKBReader*)obj->relay);
-
-    zend_hash_destroy(obj->std.properties);
-    FREE_HASHTABLE(obj->std.properties);
-
-    efree(obj);
-}
-
-static zend_object_value
-WKBReader_create_obj (zend_class_entry *type TSRMLS_DC)
-{
-    return Gen_create_obj(type, WKBReader_dtor, &WKBReader_object_handlers);
-}
-
-
-PHP_METHOD(WKBReader, __construct)
-{
-    GEOSWKBReader* obj;
-    zval *object = getThis();
-
-    obj = GEOSWKBReader_create();
-    if ( ! obj ) {
-        php_error_docref(NULL TSRMLS_CC, E_ERROR,
-                "GEOSWKBReader_create() failed (didn't initGEOS?)");
-    }
-
-    setRelay(object, obj);
-}
-
-PHP_METHOD(WKBReader, read)
-{
-    GEOSWKBReader *reader;
-    GEOSGeometry *geom;
-    unsigned char* wkb;
-    int wkblen;
-
-    reader = (GEOSWKBReader*)getRelay(getThis(), WKBReader_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
-        &wkb, &wkblen) == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    geom = GEOSWKBReader_read(reader, wkb, wkblen);
-    /* we'll probably get an exception if geom is null */
-    if ( ! geom ) RETURN_NULL();
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, geom);
-
-}
-
-PHP_METHOD(WKBReader, readHEX)
-{
-    GEOSWKBReader *reader;
-    GEOSGeometry *geom;
-    unsigned char* wkb;
-    int wkblen;
-
-    reader = (GEOSWKBReader*)getRelay(getThis(), WKBReader_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
-        &wkb, &wkblen) == FAILURE)
-    {
-        RETURN_NULL();
-    }
-
-    geom = GEOSWKBReader_readHEX(reader, wkb, wkblen);
-    /* we'll probably get an exception if geom is null */
-    if ( ! geom ) RETURN_NULL();
- 
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, geom);
-
-}
-
-
-/* -- Free functions ------------------------- */
-
-/**
- * string GEOSVersion()
- */
-PHP_FUNCTION(GEOSVersion)
-{
-    char *str;
-
-    str = estrdup(GEOSversion());
-    RETURN_STRING(str, 0);
-}
-
-/**
- * array GEOSPolygonize(GEOSGeometry $geom)
- *
- * The returned array contains the following elements:
- *
- *  - 'rings'
- *      Type: array of GEOSGeometry 
- *      Rings that can be formed by the costituent
- *      linework of geometry.
- *  - 'cut_edges' (optional)
- *      Type: array of GEOSGeometry 
- *      Edges which are connected at both ends but
- *      which do not form part of polygon.
- *  - 'dangles'
- *      Type: array of GEOSGeometry 
- *      Edges which have one or both ends which are
- *      not incident on another edge endpoint
- *  - 'invalid_rings' 
- *      Type: array of GEOSGeometry
- *      Edges which form rings which are invalid
- *      (e.g. the component lines contain a self-intersection)
- *
- */
-PHP_FUNCTION(GEOSPolygonize)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *rings;
-    GEOSGeometry *cut_edges;
-    GEOSGeometry *dangles;
-    GEOSGeometry *invalid_rings;
-    zval *array_elem;
-    zval *zobj;
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zobj)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-    this = getRelay(zobj, Geometry_ce_ptr);
-
-    rings = GEOSPolygonize_full(this, &cut_edges, &dangles, &invalid_rings);
-    if ( ! rings ) RETURN_NULL(); /* should get an exception first */
-
-    /* return value should be an array */
-    array_init(return_value);
-
-    MAKE_STD_ZVAL(array_elem);
-    array_init(array_elem);
-    dumpGeometry(rings, array_elem);
-    GEOSGeom_destroy(rings);
-    add_assoc_zval(return_value, "rings", array_elem); 
-
-    MAKE_STD_ZVAL(array_elem);
-    array_init(array_elem);
-    dumpGeometry(cut_edges, array_elem);
-    GEOSGeom_destroy(cut_edges);
-    add_assoc_zval(return_value, "cut_edges", array_elem);
-
-    MAKE_STD_ZVAL(array_elem);
-    array_init(array_elem);
-    dumpGeometry(dangles, array_elem);
-    GEOSGeom_destroy(dangles);
-    add_assoc_zval(return_value, "dangles", array_elem);
-
-    MAKE_STD_ZVAL(array_elem);
-    array_init(array_elem);
-    dumpGeometry(invalid_rings, array_elem);
-    GEOSGeom_destroy(invalid_rings);
-    add_assoc_zval(return_value, "invalid_rings", array_elem);
-
-}
-
-/**
- * array GEOSLineMerge(GEOSGeometry $geom)
- */
-PHP_FUNCTION(GEOSLineMerge)
-{
-    GEOSGeometry *geom_in;
-    GEOSGeometry *geom_out;
-    zval *zobj;
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zobj)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-    geom_in = getRelay(zobj, Geometry_ce_ptr);
-
-    geom_out = GEOSLineMerge(geom_in);
-    if ( ! geom_out ) RETURN_NULL(); /* should get an exception first */
-
-    /* return value should be an array */
-    array_init(return_value);
-    dumpGeometry(geom_out, return_value);
-    GEOSGeom_destroy(geom_out);
-}
-
-/**
- * GEOSGeometry GEOSSharedPaths(GEOSGeometry $geom1, GEOSGeometry *geom2)
- */
-PHP_FUNCTION(GEOSSharedPaths)
-{
-    GEOSGeometry *geom_in_1;
-    GEOSGeometry *geom_in_2;
-    GEOSGeometry *geom_out;
-    zval *zobj1, *zobj2;
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oo", &zobj1, &zobj2)
-        == FAILURE)
-    {
-        RETURN_NULL();
-    }
-    geom_in_1 = getRelay(zobj1, Geometry_ce_ptr);
-    geom_in_2 = getRelay(zobj2, Geometry_ce_ptr);
-
-    geom_out = GEOSSharedPaths(geom_in_1, geom_in_2);
-    if ( ! geom_out ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, geom_out);
-}
-
-/**
- * GEOSGeometry::delaunayTriangulation([<tolerance>], [<onlyEdges>])
- *
- *  'tolerance'
- *       Type: double
- *       snapping tolerance to use for improved robustness
- *  'onlyEdges'
- *       Type: boolean
- *       if true will return a MULTILINESTRING, otherwise (the default)
- *       it will return a GEOMETRYCOLLECTION containing triangular POLYGONs.
- */
-PHP_METHOD(Geometry, delaunayTriangulation)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-    double tolerance = 0.0;
-    zend_bool edgeonly = 0;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|db",
-            &tolerance, &edgeonly) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    ret = GEOSDelaunayTriangulation(this, tolerance, edgeonly ? 1 : 0);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * GEOSGeometry::voronoiDiagram([<tolerance>], [<onlyEdges>], [<extent>])
- *
- *  'tolerance'
- *       Type: double
- *       snapping tolerance to use for improved robustness
- *  'onlyEdges'
- *       Type: boolean
- *       if true will return a MULTILINESTRING, otherwise (the default)
- *       it will return a GEOMETRYCOLLECTION containing POLYGONs.
- *  'extent'
- *       Type: geometry
- *       Clip returned diagram by the extent of the given geometry
- */
-PHP_METHOD(Geometry, voronoiDiagram)
-{
-    GEOSGeometry *this;
-    GEOSGeometry *ret;
-    zval *zobj = 0;
-    GEOSGeometry *env = 0;
-    double tolerance = 0.0;
-    zend_bool edgeonly = 0;
-
-    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
-
-    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|dbo",
-            &tolerance, &edgeonly, &zobj) == FAILURE) {
-        RETURN_NULL();
-    }
-
-    if ( zobj ) env = getRelay(zobj, Geometry_ce_ptr);
-    ret = GEOSVoronoiDiagram(this, env, tolerance, edgeonly ? 1 : 0);
-    if ( ! ret ) RETURN_NULL(); /* should get an exception first */
-
-    /* return_value is a zval */
-    object_init_ex(return_value, Geometry_ce_ptr);
-    setRelay(return_value, ret);
-}
-
-/**
- * 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 */
-PHP_MINIT_FUNCTION(geos)
-{
-    zend_class_entry ce;
-
-    /* WKTReader */
-    INIT_CLASS_ENTRY(ce, "GEOSWKTReader", WKTReader_methods);
-    WKTReader_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
-    WKTReader_ce_ptr->create_object = WKTReader_create_obj;
-    memcpy(&WKTReader_object_handlers,
-        zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-    WKTReader_object_handlers.clone_obj = NULL;
-
-    /* WKTWriter */
-    INIT_CLASS_ENTRY(ce, "GEOSWKTWriter", WKTWriter_methods);
-    WKTWriter_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
-    WKTWriter_ce_ptr->create_object = WKTWriter_create_obj;
-    memcpy(&WKTWriter_object_handlers,
-        zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-    WKTWriter_object_handlers.clone_obj = NULL;
-
-    /* Geometry */
-    INIT_CLASS_ENTRY(ce, "GEOSGeometry", Geometry_methods);
-    Geometry_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
-    Geometry_ce_ptr->create_object = Geometry_create_obj;
-    memcpy(&Geometry_object_handlers,
-        zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-    Geometry_object_handlers.clone_obj = NULL;
-    /* Geometry serialization */
-    Geometry_ce_ptr->serialize = Geometry_serialize;
-    Geometry_ce_ptr->unserialize = Geometry_deserialize;
-
-    /* WKBWriter */
-    INIT_CLASS_ENTRY(ce, "GEOSWKBWriter", WKBWriter_methods);
-    WKBWriter_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
-    WKBWriter_ce_ptr->create_object = WKBWriter_create_obj;
-    memcpy(&WKBWriter_object_handlers,
-        zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-    WKBWriter_object_handlers.clone_obj = NULL;
-
-    /* WKBReader */
-    INIT_CLASS_ENTRY(ce, "GEOSWKBReader", WKBReader_methods);
-    WKBReader_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
-    WKBReader_ce_ptr->create_object = WKBReader_create_obj;
-    memcpy(&WKBReader_object_handlers,
-        zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-    WKBReader_object_handlers.clone_obj = NULL;
-
-
-    /* Constants */
-    REGISTER_LONG_CONSTANT("GEOSBUF_CAP_ROUND",  GEOSBUF_CAP_ROUND,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOSBUF_CAP_FLAT",   GEOSBUF_CAP_FLAT,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOSBUF_CAP_SQUARE", GEOSBUF_CAP_SQUARE,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOSBUF_JOIN_ROUND", GEOSBUF_JOIN_ROUND,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOSBUF_JOIN_MITRE", GEOSBUF_JOIN_MITRE,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOSBUF_JOIN_BEVEL", GEOSBUF_JOIN_BEVEL,
-        CONST_CS|CONST_PERSISTENT);
-
-    REGISTER_LONG_CONSTANT("GEOS_POINT", GEOS_POINT,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOS_LINESTRING", GEOS_LINESTRING,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOS_LINEARRING", GEOS_LINEARRING,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOS_POLYGON", GEOS_POLYGON,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOS_MULTIPOINT", GEOS_MULTIPOINT,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOS_MULTILINESTRING", GEOS_MULTILINESTRING,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOS_MULTIPOLYGON", GEOS_MULTIPOLYGON,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOS_GEOMETRYCOLLECTION", GEOS_GEOMETRYCOLLECTION,
-        CONST_CS|CONST_PERSISTENT);
-
-    REGISTER_LONG_CONSTANT("GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE",
-        GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE,
-        CONST_CS|CONST_PERSISTENT);
-
-    REGISTER_LONG_CONSTANT("GEOS_PREC_NO_TOPO", GEOS_PREC_NO_TOPO,
-        CONST_CS|CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("GEOS_PREC_KEEP_COLLAPSED", GEOS_PREC_NO_TOPO,
-        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;
-}
-
-/* per-module shutdown */
-PHP_MSHUTDOWN_FUNCTION(geos)
-{
-    delGeometrySerializer();
-    delGeometryDeserializer();
-    return SUCCESS;
-}
-
-/* per-request initialization */
-PHP_RINIT_FUNCTION(geos)
-{
-    initGEOS(noticeHandler, errorHandler);
-    return SUCCESS;
-}
-
-/* pre-request destruction */
-PHP_RSHUTDOWN_FUNCTION(geos)
-{
-    finishGEOS();
-    return SUCCESS;
-}
-
-/* module info */
-PHP_MINFO_FUNCTION(geos)
-{
-    php_info_print_table_start();
-    php_info_print_table_row(2,
-        "GEOS - Geometry Engine Open Source", "enabled");
-    php_info_print_table_row(2,
-        "Version", PHP_GEOS_VERSION);
-    php_info_print_table_end();
-}
-

Deleted: trunk/php/php_geos.h
===================================================================
--- trunk/php/php_geos.h	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/php/php_geos.h	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,41 +0,0 @@
-/***********************************************************************
- * 
- *    GEOS - Geometry Engine Open Source
- *    http://trac.osgeo.org/geos
- *
- *    Copyright (C) 2010 Sandro Santilli <strk at keybit.net>
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation; either
- *    version 2.1 of the License, or (at your option) any later version.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU General Public License
- *    along with this program; if not, write to the Free Software
- *    Foundation, Inc., 51 Franklin St, Fifth Floor,
- *    Boston, MA  02110-1301  USA
- *
- ***********************************************************************/
-
-#ifndef PHP_GEOS_H
-#define PHP_GEOS_H
-
-/* TODO: generate from ./configure ? */
-#define PHP_GEOS_VERSION "0.0"
-#define PHP_GEOS_EXTNAME "geos"
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif 
-
-#include "php.h"
-
-extern zend_module_entry geos_module_entry;
-#define phpext_geos_ptr &geos_module_entry;
-
-#endif /* PHP_GEOS_H */

Deleted: trunk/php/test/Makefile.am
===================================================================
--- trunk/php/test/Makefile.am	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/php/test/Makefile.am	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,52 +0,0 @@
-#######################################################################
-# 
-#    GEOS - Geometry Engine Open Source
-#    http://trac.osgeo.org/geos
-#
-#    Copyright (C) 2010 Sandro Santilli <strk at keybit.net>
-#
-#    This library is free software; you can redistribute it and/or
-#    modify it under the terms of the GNU Lesser General Public
-#    License as published by the Free Software Foundation; either
-#    version 2.1 of the License, or (at your option) any later version.
-#
-#    This library is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#    Lesser General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program; if not, write to the Free Software
-#    Foundation, Inc., 51 Franklin St, Fifth Floor,
-#    Boston, MA  02110-1301  USA
-#
-#######################################################################
-
-EXTRA_DIST = test.php crashme.php
-
-abs_topbuilddir=`cd $(top_builddir); pwd`
-abs_srcdir=`cd $(srcdir); pwd`
-
-if HAVE_PHP
-
-PHPOPTS = -n -d enable_dl=On -d extension_dir=$(abs_topbuilddir)/php/.libs
-
-crashtest:
-	$(PHP) $(PHPOPTS) $(abs_srcdir)/crashme.php
-
-if HAVE_PHP_UNIT
-
-TESTS = phpunit
-
-phpunit: test.php 
-	echo "#!/bin/sh" > $@ 
-	echo "$(PHP) $(PHPOPTS) $(PHPUNIT) test $(abs_srcdir)/test.php $$@" >> $@
-	chmod +x $@
-
-clean-local:
-	rm -f phpunit
-
-
-endif
-
-endif

Deleted: trunk/php/test/crashme.php
===================================================================
--- trunk/php/test/crashme.php	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/php/test/crashme.php	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,25 +0,0 @@
-<?php
-
-# 
-# This file contains code attempting to segfault the extension
-#
-# Run with:
-# php -n -d enable_dl=On -d extension_dir=.. test.php
-#
-
-dl("geos.so");
-
-class Point extends GEOSWKTReader {
-    public function __construct()
-    {
-        parent::__construct();
-    }
-    public function test() {    
-        return GEOSGeometry::numGeometries();
-    }
-};
-
-$p = new Point();
-$p->test();
-
-

Deleted: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php	2016-07-19 18:26:07 UTC (rev 4236)
+++ trunk/php/test/test.php	2016-07-19 18:26:20 UTC (rev 4237)
@@ -1,2423 +0,0 @@
-<?php 
-
-# Run with:
-# php -n -d enable_dl=On -d extension_dir=.. test.php
-
-dl("geos.so");
-
-if ( version_compare(PHPUnit_Runner_Version::id(), '3.6') < 0 )
-    require_once 'PHPUnit/Framework.php';
-
-# hex2bin for PHP < 5.4
-# https://gist.github.com/mcrumley/5672621
-if (!function_exists('hex2bin')) {
-  function hex2bin($str) {
-    $map = array(
-      '00'=>"\x00", '10'=>"\x10", '20'=>"\x20", '30'=>"\x30", '40'=>"\x40", '50'=>"\x50", '60'=>"\x60", '70'=>"\x70",
-      '01'=>"\x01", '11'=>"\x11", '21'=>"\x21", '31'=>"\x31", '41'=>"\x41", '51'=>"\x51", '61'=>"\x61", '71'=>"\x71",
-      '02'=>"\x02", '12'=>"\x12", '22'=>"\x22", '32'=>"\x32", '42'=>"\x42", '52'=>"\x52", '62'=>"\x62", '72'=>"\x72",
-      '03'=>"\x03", '13'=>"\x13", '23'=>"\x23", '33'=>"\x33", '43'=>"\x43", '53'=>"\x53", '63'=>"\x63", '73'=>"\x73",
-      '04'=>"\x04", '14'=>"\x14", '24'=>"\x24", '34'=>"\x34", '44'=>"\x44", '54'=>"\x54", '64'=>"\x64", '74'=>"\x74",
-      '05'=>"\x05", '15'=>"\x15", '25'=>"\x25", '35'=>"\x35", '45'=>"\x45", '55'=>"\x55", '65'=>"\x65", '75'=>"\x75",
-      '06'=>"\x06", '16'=>"\x16", '26'=>"\x26", '36'=>"\x36", '46'=>"\x46", '56'=>"\x56", '66'=>"\x66", '76'=>"\x76",
-      '07'=>"\x07", '17'=>"\x17", '27'=>"\x27", '37'=>"\x37", '47'=>"\x47", '57'=>"\x57", '67'=>"\x67", '77'=>"\x77",
-      '08'=>"\x08", '18'=>"\x18", '28'=>"\x28", '38'=>"\x38", '48'=>"\x48", '58'=>"\x58", '68'=>"\x68", '78'=>"\x78",
-      '09'=>"\x09", '19'=>"\x19", '29'=>"\x29", '39'=>"\x39", '49'=>"\x49", '59'=>"\x59", '69'=>"\x69", '79'=>"\x79",
-      '0a'=>"\x0a", '1a'=>"\x1a", '2a'=>"\x2a", '3a'=>"\x3a", '4a'=>"\x4a", '5a'=>"\x5a", '6a'=>"\x6a", '7a'=>"\x7a",
-      '0b'=>"\x0b", '1b'=>"\x1b", '2b'=>"\x2b", '3b'=>"\x3b", '4b'=>"\x4b", '5b'=>"\x5b", '6b'=>"\x6b", '7b'=>"\x7b",
-      '0c'=>"\x0c", '1c'=>"\x1c", '2c'=>"\x2c", '3c'=>"\x3c", '4c'=>"\x4c", '5c'=>"\x5c", '6c'=>"\x6c", '7c'=>"\x7c",
-      '0d'=>"\x0d", '1d'=>"\x1d", '2d'=>"\x2d", '3d'=>"\x3d", '4d'=>"\x4d", '5d'=>"\x5d", '6d'=>"\x6d", '7d'=>"\x7d",
-      '0e'=>"\x0e", '1e'=>"\x1e", '2e'=>"\x2e", '3e'=>"\x3e", '4e'=>"\x4e", '5e'=>"\x5e", '6e'=>"\x6e", '7e'=>"\x7e",
-      '0f'=>"\x0f", '1f'=>"\x1f", '2f'=>"\x2f", '3f'=>"\x3f", '4f'=>"\x4f", '5f'=>"\x5f", '6f'=>"\x6f", '7f'=>"\x7f",
-
-      '80'=>"\x80", '90'=>"\x90", 'a0'=>"\xa0", 'b0'=>"\xb0", 'c0'=>"\xc0", 'd0'=>"\xd0", 'e0'=>"\xe0", 'f0'=>"\xf0",
-      '81'=>"\x81", '91'=>"\x91", 'a1'=>"\xa1", 'b1'=>"\xb1", 'c1'=>"\xc1", 'd1'=>"\xd1", 'e1'=>"\xe1", 'f1'=>"\xf1",
-      '82'=>"\x82", '92'=>"\x92", 'a2'=>"\xa2", 'b2'=>"\xb2", 'c2'=>"\xc2", 'd2'=>"\xd2", 'e2'=>"\xe2", 'f2'=>"\xf2",
-      '83'=>"\x83", '93'=>"\x93", 'a3'=>"\xa3", 'b3'=>"\xb3", 'c3'=>"\xc3", 'd3'=>"\xd3", 'e3'=>"\xe3", 'f3'=>"\xf3",
-      '84'=>"\x84", '94'=>"\x94", 'a4'=>"\xa4", 'b4'=>"\xb4", 'c4'=>"\xc4", 'd4'=>"\xd4", 'e4'=>"\xe4", 'f4'=>"\xf4",
-      '85'=>"\x85", '95'=>"\x95", 'a5'=>"\xa5", 'b5'=>"\xb5", 'c5'=>"\xc5", 'd5'=>"\xd5", 'e5'=>"\xe5", 'f5'=>"\xf5",
-      '86'=>"\x86", '96'=>"\x96", 'a6'=>"\xa6", 'b6'=>"\xb6", 'c6'=>"\xc6", 'd6'=>"\xd6", 'e6'=>"\xe6", 'f6'=>"\xf6",
-      '87'=>"\x87", '97'=>"\x97", 'a7'=>"\xa7", 'b7'=>"\xb7", 'c7'=>"\xc7", 'd7'=>"\xd7", 'e7'=>"\xe7", 'f7'=>"\xf7",
-      '88'=>"\x88", '98'=>"\x98", 'a8'=>"\xa8", 'b8'=>"\xb8", 'c8'=>"\xc8", 'd8'=>"\xd8", 'e8'=>"\xe8", 'f8'=>"\xf8",
-      '89'=>"\x89", '99'=>"\x99", 'a9'=>"\xa9", 'b9'=>"\xb9", 'c9'=>"\xc9", 'd9'=>"\xd9", 'e9'=>"\xe9", 'f9'=>"\xf9",
-      '8a'=>"\x8a", '9a'=>"\x9a", 'aa'=>"\xaa", 'ba'=>"\xba", 'ca'=>"\xca", 'da'=>"\xda", 'ea'=>"\xea", 'fa'=>"\xfa",
-      '8b'=>"\x8b", '9b'=>"\x9b", 'ab'=>"\xab", 'bb'=>"\xbb", 'cb'=>"\xcb", 'db'=>"\xdb", 'eb'=>"\xeb", 'fb'=>"\xfb",
-      '8c'=>"\x8c", '9c'=>"\x9c", 'ac'=>"\xac", 'bc'=>"\xbc", 'cc'=>"\xcc", 'dc'=>"\xdc", 'ec'=>"\xec", 'fc'=>"\xfc",
-      '8d'=>"\x8d", '9d'=>"\x9d", 'ad'=>"\xad", 'bd'=>"\xbd", 'cd'=>"\xcd", 'dd'=>"\xdd", 'ed'=>"\xed", 'fd'=>"\xfd",
-      '8e'=>"\x8e", '9e'=>"\x9e", 'ae'=>"\xae", 'be'=>"\xbe", 'ce'=>"\xce", 'de'=>"\xde", 'ee'=>"\xee", 'fe'=>"\xfe",
-      '8f'=>"\x8f", '9f'=>"\x9f", 'af'=>"\xaf", 'bf'=>"\xbf", 'cf'=>"\xcf", 'df'=>"\xdf", 'ef'=>"\xef", 'ff'=>"\xff",
-    );
-    $strlen = strlen($str);
-    if ($strlen % 2 !== 0) {
-      user_error('Hexadecimal input string must have an even length', E_USER_WARNING);
-      return false;
-    }
-    if (strspn($str, '0123456789ABCDEFabcdef') !== $strlen) {
-      return false;
-    }
-    return strtr(strtolower($str), $map);
-  }
-}
-
-
-class test extends PHPUnit_Framework_TestCase
-{
-    # This method override is needed to support phpunit < 3.5 (Ubuntu 10.04 ships 3.4)
-    static public function assertType($x, $y)
-    {
-        #global $phpunit_version;
-        if ( version_compare(PHPUnit_Runner_Version::id(), '3.5') < 0 )
-            return PHPUnit_Framework_TestCase::assertType($x, $y);
-        else return PHPUnit_Framework_TestCase::assertInternalType($x, $y);
-    }
-
-    public function testGEOSVersion()
-    {
-        $this->assertContains('-CAPI-', GEOSVersion());
-    }
-
-    public function testConstants()
-    {
-        $this->assertEquals(1, GEOSBUF_CAP_ROUND);
-        $this->assertEquals(2, GEOSBUF_CAP_FLAT);
-        $this->assertEquals(3, GEOSBUF_CAP_SQUARE);
-
-        $this->assertEquals(1, GEOSBUF_JOIN_ROUND);
-        $this->assertEquals(2, GEOSBUF_JOIN_MITRE);
-        $this->assertEquals(3, GEOSBUF_JOIN_BEVEL);
-
-        $this->assertEquals(0, GEOS_POINT);
-        $this->assertEquals(1, GEOS_LINESTRING);
-        $this->assertEquals(2, GEOS_LINEARRING);
-        $this->assertEquals(3, GEOS_POLYGON);
-        $this->assertEquals(4, GEOS_MULTIPOINT);
-        $this->assertEquals(5, GEOS_MULTILINESTRING);
-        $this->assertEquals(6, GEOS_MULTIPOLYGON);
-        $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()
-    {
-        $reader = new GEOSWKTReader();
-        $this->assertNotNull($reader);
-    }
-
-    public function testWKTReader_read()
-    {
-        $reader = new GEOSWKTReader();
-
-        /* Good WKT */
-        $geom = $reader->read('POINT(0 0)');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('POINT(0 0 0)');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('POINT Z (0 0 0)');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('POINT EMPTY');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('MULTIPOINT(0 0 1, 2 3 4)');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('MULTIPOINT Z (0 0 1, 2 3 4)');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('MULTIPOINT((0 0), (2 3))');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('MULTIPOINT EMPTY');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('LINESTRING(0 0 1, 2 3 4)');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('LINESTRING EMPTY');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('MULTILINESTRING((0 0 1, 2 3 4),
-                                               (10 10 2, 3 4 5))');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('MULTILINESTRING Z ((0 0 1, 2 3 4),
-                                               (10 10 2, 3 4 5))');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('POLYGON EMPTY');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('MULTIPOLYGON(
-                                ((0 0, 1 0, 1 1, 0 1, 0 0)),
-                                ((10 10, 10 14, 14 14, 14 10, 10 10),
-                                    (11 11, 11 12, 12 12, 12 11, 11 11))
-                               )');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('MULTIPOLYGON EMPTY');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('GEOMETRYCOLLECTION(
-                MULTIPOLYGON(
-                 ((0 0, 1 0, 1 1, 0 1, 0 0)),
-                 ((10 10, 10 14, 14 14, 14 10, 10 10),
-                  (11 11, 11 12, 12 12, 12 11, 11 11))
-                ),
-                POLYGON((0 0, 1 0, 1 1, 0 1, 0 0)),
-                MULTILINESTRING((0 0, 2 3), (10 10, 3 4)),
-                LINESTRING(0 0, 2 3),
-                MULTIPOINT(0 0, 2 3),
-                POINT(9 0)
-        )');
-        $this->assertNotNull($geom);
-        $geom = $reader->read('GEOMETRYCOLLECTION EMPTY');
-        $this->assertNotNull($geom);
-
-        /* BOGUS WKT */
-        try {
-            $reader->read("MULTIDOT(0 1 2 3)");
-            $this->assertTrue(FALSE); # this is just to fail if we get here
-        } catch (Exception $e) {
-            $this->assertContains('ParseException', $e->getMessage());
-        }
-
-        /* BOGUS call (#448) */
-        try {
-        	  $reader->read();
-            $this->assertTrue(FALSE); # this is just to fail if we get here
-        } catch (Exception $e) {
-            $this->assertContains('expects exactly 1 parameter',
-                                  $e->getMessage());
-        }
-    }
-
-    public function testWKTWriter__construct()
-    {
-        $writer = new GEOSWKTWriter();
-        $this->assertNotNull($writer);
-    }
-
-    public function testWKTWriter_write()
-    {
-        $writer = new GEOSWKTWriter();
-        $reader = new GEOSWKTReader();
-
-        try {
-            $writer->write(1);
-            $this->assertTrue(FALSE); # this is just to fail if we get here
-        } catch (Exception $e) {
-            $this->assertContains('expects parameter 1', $e->getMessage());
-        }
-
-        $g = $reader->read('POINT(6 7)');
-
-        $this->assertEquals('POINT (6.0000000000000000 7.0000000000000000)',
-            $writer->write($g));
-    }
-
-    public function testWKTWriter_setTrim()
-    {
-        $writer = new GEOSWKTWriter();
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(6 7)');
-        $this->assertNotNull($g);
-
-        $writer->setTrim(TRUE);
-        $this->assertEquals('POINT (6 7)',
-            $writer->write($g));
-
-        $writer->setTrim(FALSE);
-        $this->assertEquals('POINT (6.0000000000000000 7.0000000000000000)',
-            $writer->write($g));
-
-    }
-
-    public function testWKT_roundTrip()
-    {
-        $r = new GEOSWKTReader();
-        $w = new GEOSWKTWriter();
-        $w->setTrim(TRUE);
-
-        $in[] = 'POINT (0 0)';
-        $in[] = 'POINT EMPTY';
-        $in[] = 'MULTIPOINT (0 1, 2 3)';
-        $in[] = 'MULTIPOINT EMPTY';
-        $in[] = 'LINESTRING (0 0, 2 3)';
-        $in[] = 'LINESTRING EMPTY';
-        $in[] = 'MULTILINESTRING ((0 1, 2 3), (10 10, 3 4))';
-        $in[] = 'MULTILINESTRING EMPTY';
-        $in[] = 'POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))';
-        $in[] = 'POLYGON EMPTY';
-        $in[] = 'MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((10 10, 10 14, 14 14, 14 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11)))';
-        $in[] = 'MULTIPOLYGON EMPTY';
-        $in[] = 'GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((10 10, 10 14, 14 14, 14 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11))), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)), LINESTRING (0 0, 2 3), MULTIPOINT (0 0, 2 3), POINT (9 0))';
-        $in[] = 'GEOMETRYCOLLECTION EMPTY';
-
-        foreach ($in as $i) {
-            $this->assertEquals($i, $w->write($r->read($i)));
-        }
-
-    }
-
-    public function testWKTWriter_setRoundingPrecision()
-    {
-        $writer = new GEOSWKTWriter();
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(6.123456 7.123456)');
-
-        $this->assertEquals('POINT (6.1234560000000000 7.1234560000000000)',
-            $writer->write($g));
-
-        $writer->setRoundingPrecision(2);
-        $this->assertEquals('POINT (6.12 7.12)', $writer->write($g));
-
-        $writer->setRoundingPrecision(5); /* rounds */
-        $this->assertEquals('POINT (6.12346 7.12346)', $writer->write($g));
-
-        $writer->setRoundingPrecision(1);
-        $this->assertEquals('POINT (6.1 7.1)', $writer->write($g));
-
-        $writer->setRoundingPrecision(0);
-        $this->assertEquals('POINT (6 7)', $writer->write($g));
-
-    }
-
-    public function testWKTWriter_getOutputDimension()
-    {
-        $writer = new GEOSWKTWriter();
-        $this->assertEquals(2, $writer->getOutputDimension());
-    }
-
-    public function testWKTWriter_setOutputDimension()
-    {
-        $reader = new GEOSWKTReader();
-        $g3d = $reader->read('POINT(1 2 3)');
-        $g2d = $reader->read('POINT(3 2)');
-
-        $writer = new GEOSWKTWriter();
-        $writer->setTrim(TRUE);
-
-        # Only 2d by default
-        $this->assertEquals('POINT (1 2)', $writer->write($g3d));
-
-        # 3d if requested _and_ available
-        $writer->setOutputDimension(3);
-        $this->assertEquals('POINT Z (1 2 3)', $writer->write($g3d));
-        $this->assertEquals('POINT (3 2)', $writer->write($g2d));
-
-        # 1 is invalid
-        try {
-            $writer->setOutputDimension(1);
-            $this->assertTrue(FALSE);
-        } catch (Exception $e) {
-            $this->assertContains('must be 2 or 3', $e->getMessage());
-        }
-
-        # 4 is invalid
-        try {
-            $writer->setOutputDimension(4);
-            $this->assertTrue(FALSE);
-        } catch (Exception $e) {
-            $this->assertContains('must be 2 or 3', $e->getMessage());
-        }
-
-    }
-
-    public function testWKTWriter_setOld3D()
-    {
-        $reader = new GEOSWKTReader();
-        $g3d = $reader->read('POINT(1 2 3)');
-
-        $writer = new GEOSWKTWriter();
-        $writer->setTrim(TRUE);
-
-        # New 3d WKT by default
-        $writer->setOutputDimension(3);
-        $this->assertEquals('POINT Z (1 2 3)', $writer->write($g3d));
-
-        # Switch to old
-        $writer->setOld3D(TRUE);
-        $this->assertEquals('POINT (1 2 3)', $writer->write($g3d));
-
-        # Old3d flag is not reset when changing dimensions
-        $writer->setOutputDimension(2);
-        $this->assertEquals('POINT (1 2)', $writer->write($g3d));
-        $writer->setOutputDimension(3);
-        $this->assertEquals('POINT (1 2 3)', $writer->write($g3d));
-
-        # Likewise, dimensions spec is not reset when changing old3d flag
-        $writer->setOld3D(FALSE);
-        $this->assertEquals('POINT Z (1 2 3)', $writer->write($g3d));
-
-    }
-
-    public function testGeometry_serialization()
-    {
-        $reader = new GEOSWKTReader();
-
-        $writer = new GEOSWKTWriter();
-        $writer->setTrim(TRUE);
-        $writer->setOutputDimension(3);
-
-        $g = $reader->read('POINT(6 7 8)');
-        $g->setSRID(54);
-
-        $a = array('geom' => $g, 'name' => 'test geometry');
-        $srl = serialize($a);
-        $a2 = unserialize($srl);
-
-        $this->assertEquals('POINT Z (6 7 8)', $writer->write($a['geom']));
-
-    }
-
-    public function testGeometry_project()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(1 2)');
-        $g2 = $reader->read('POINT(3 4)');
-
-        /* The method only accept lineal geometries */
-        try {
-            $prj = $g->project($g2);
-            $this->assertTrue(FALSE); # this is just to fail if we get here
-        } catch (Exception $e) {
-            $this->assertContains('lineal', $e->getMessage());
-        }
-
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-
-        $g2 = $reader->read('POINT(0 0)');
-        $prj = $g->project($g2);
-        $this->assertEquals(0, $prj);
-        $prj = $g->project($g2, TRUE);
-        $this->assertEquals(0, $prj);
-
-        $g2 = $reader->read('POINT(10 0)');
-        $prj = $g->project($g2);
-        $this->assertEquals(10, $prj);
-        $prj = $g->project($g2, TRUE);
-        $this->assertEquals(1, $prj);
-
-        $g2 = $reader->read('POINT(5 0)');
-        $prj = $g->project($g2);
-        $this->assertEquals(5, $prj);
-        $prj = $g->project($g2, TRUE);
-        $this->assertEquals(0.5, $prj);
-
-        $g = $reader->read('MULTILINESTRING((0 0, 10 0),(20 10, 20 20))');
-
-        $g2 = $reader->read('POINT(20 0)');
-        $prj = $g->project($g2);
-        $this->assertEquals(10, $prj);
-        $prj = $g->project($g2, TRUE);
-        $this->assertEquals(0.5, $prj);
-
-        $g2 = $reader->read('POINT(20 5)');
-        $prj = $g->project($g2);
-        $this->assertEquals(10, $prj);
-        $prj = $g->project($g2, TRUE);
-        $this->assertEquals(0.5, $prj);
-
-
-    }
-
-    public function testGeometry_interpolate()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setTrim(TRUE);
-
-        /* The method only accept LineString geometries */
-        $g = $reader->read('POINT(1 2)');
-        try {
-            $prj = $g->interpolate(0);
-            $this->assertTrue(FALSE); # this is just to fail if we get here
-        } catch (Exception $e) {
-            $this->assertContains('LineString', $e->getMessage());
-        }
-
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-
-        $prj = $g->interpolate(0);
-        $this->assertNotNull($prj);
-        $this->assertEquals('POINT (0 0)', $writer->write($prj));
-        $prj = $g->interpolate(0, TRUE);
-        $this->assertNotNull($prj);
-        $this->assertEquals('POINT (0 0)', $writer->write($prj));
-
-        $prj = $g->interpolate(5);
-        $this->assertNotNull($prj);
-        $this->assertEquals('POINT (5 0)', $writer->write($prj));
-        $prj = $g->interpolate(0.5, TRUE);
-        $this->assertNotNull($prj);
-        $this->assertEquals('POINT (5 0)', $writer->write($prj));
-
-        /* return closest on longer distance */
-        $prj = $g->interpolate(20);
-        $this->assertNotNull($prj);
-        $this->assertEquals('POINT (10 0)', $writer->write($prj));
-        $prj = $g->interpolate(2, TRUE);
-        $this->assertNotNull($prj);
-        $this->assertEquals('POINT (10 0)', $writer->write($prj));
-    
-    }
-
-    public function testGeometry_buffer()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POINT(0 0)');
-        $b = $g->buffer(0);
-        $this->assertEquals('POLYGON EMPTY', $writer->write($b));
-
-        $b = $g->buffer(10);
-        $this->assertEquals(
-'POLYGON ((10 0, 10 -2, 9 -4, 8 -6, 7 -7, 6 -8, 4 -9, 2 -10, 0 -10, -2 -10, -4 -9, -6 -8, -7 -7, -8 -6, -9 -4, -10 -2, -10 -0, -10 2, -9 4, -8 6, -7 7, -6 8, -4 9, -2 10, -0 10, 2 10, 4 9, 6 8, 7 7, 8 6, 9 4, 10 2, 10 0))'
-            , $writer->write($b));
-
-        # One segment per quadrant
-        $b = $g->buffer(10, array('quad_segs' => 1));
-        $this->assertEquals(
-'POLYGON ((10 0, 0 -10, -10 -0, -0 10, 10 0))'
-            , $writer->write($b));
-
-        /* End cap styles */
-
-        $g = $reader->read('LINESTRING(0 0, 100 0)');
-
-        $b = $g->buffer(10, array(
-            'quad_segs' => 1,
-            'endcap' => GEOSBUF_CAP_ROUND
-        ));
-        $this->assertEquals(
-'POLYGON ((100 10, 110 0, 100 -10, 0 -10, -10 0, 0 10, 100 10))'
-            , $writer->write($b));
-
-        $b = $g->buffer(10, array(
-            'quad_segs' => 1,
-            'endcap' => GEOSBUF_CAP_FLAT
-        ));
-        $this->assertEquals(
-'POLYGON ((100 10, 100 -10, 0 -10, 0 10, 100 10))'
-            , $writer->write($b));
-
-        $b = $g->buffer(10, array(
-            'quad_segs' => 1,
-            'endcap' => GEOSBUF_CAP_SQUARE
-        ));
-        $this->assertEquals(
-'POLYGON ((100 10, 110 10, 110 -10, 0 -10, -10 -10, -10 10, 100 10))'
-            , $writer->write($b));
-
-        /* Join styles */
-
-        $g = $reader->read('LINESTRING(0 0, 100 0, 100 100)');
-
-        $b = $g->buffer(10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_ROUND
-        ));
-        $this->assertEquals(
-'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 110 0, 107 -7, 100 -10, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))'
-            , $writer->write($b));
-
-        $b = $g->buffer(10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_BEVEL
-        ));
-        $this->assertEquals(
-'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 110 0, 100 -10, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))'
-            , $writer->write($b));
-
-        $b = $g->buffer(10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_MITRE
-        ));
-        $this->assertEquals(
-'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 110 -10, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))'
-            , $writer->write($b));
-
-        $b = $g->buffer(10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_MITRE,
-            'mitre_limit' => 1.0
-        ));
-        $this->assertEquals(
-'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 109 -5, 105 -9, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))'
-            , $writer->write($b));
-
-        /* Check that elements of the passed style array are not
-         * type-converted (buffer op will need to type-convert
-         * internally)
-         */
-        $ary = array('a' => 1);
-
-        $myStyle = array(
-            'quad_segs' => "a string",
-            'join' => "1",
-            'endcap' => $ary,
-            'mitre_limit' => 2 /* an int.. */
-        );
-        $this->assertEquals('string', gettype($myStyle['quad_segs']));
-        $this->assertEquals('string', gettype($myStyle['join']));
-        $this->assertEquals('array', gettype($myStyle['endcap']));
-        $this->assertEquals('integer', gettype($myStyle['mitre_limit']));
-        $b = $g->buffer(10, $myStyle);
-        $this->assertEquals('string', gettype($myStyle['quad_segs']));
-        $this->assertEquals('string', gettype($myStyle['join']));
-        $this->assertEquals('array', gettype($myStyle['endcap']));
-        $this->assertEquals('integer', gettype($myStyle['mitre_limit']));
-
-        /* Single-sided buffering */
-
-        $g = $reader->read('LINESTRING(0 0, 100 0)');
-
-        $b = $g->buffer(10, array(
-            'single_sided' => true
-        ));
-        $this->assertEquals(
-'POLYGON ((100 0, 0 0, 0 10, 100 10, 100 0))'
-            , $writer->write($b));
-
-        $b = $g->buffer(-10, array(
-            'single_sided' => true
-        ));
-        $this->assertEquals(
-'POLYGON ((0 0, 100 0, 100 -10, 0 -10, 0 0))'
-            , $writer->write($b));
-
-    }
-
-    public function testGeometry_offsetCurve()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-
-        /* Join styles */
-
-        $g = $reader->read('LINESTRING(0 0, 100 0, 100 100)');
-
-	/* left, round join */
-        $b = $g->offsetCurve(10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_ROUND
-        ));
-        $this->assertEquals(
-'LINESTRING (0 10, 90 10, 90 100)'
-            , $writer->write($b));
-
-	/* right, round join */
-        $b = $g->offsetCurve(-10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_ROUND
-        ));
-        $this->assertEquals(
-'LINESTRING (110 100, 110 0, 107 -7, 100 -10, 0 -10)'
-            , $writer->write($b));
-
-	/* left, bevel join */
-        $b = $g->offsetCurve(10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_BEVEL
-        ));
-        $this->assertEquals(
-'LINESTRING (0 10, 90 10, 90 100)'
-            , $writer->write($b));
-
-	/* right, bevel join */
-        $b = $g->offsetCurve(-10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_BEVEL
-        ));
-        $this->assertEquals(
-'LINESTRING (110 100, 110 0, 100 -10, 0 -10)'
-            , $writer->write($b));
-
-	/* left, mitre join */
-        $b = $g->offsetCurve(10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_MITRE
-        ));
-        $this->assertEquals(
-'LINESTRING (0 10, 90 10, 90 100)'
-            , $writer->write($b));
-
-	/* right, mitre join */
-        $b = $g->offsetCurve(-10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_MITRE
-        ));
-        $this->assertEquals(
-'LINESTRING (110 100, 110 -10, 0 -10)'
-            , $writer->write($b));
-
-	/* right, mitre join limited */
-        $b = $g->offsetCurve(-10, array(
-            'quad_segs' => 2,
-            'join' => GEOSBUF_JOIN_MITRE,
-            'mitre_limit' => 1.0
-        ));
-        $this->assertEquals(
-'LINESTRING (110 100, 109 -5, 105 -9, 0 -10)'
-            , $writer->write($b));
-
-    }
-
-    public function testGeometry_envelope()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POINT(0 0)');
-        $b = $g->envelope();
-        $this->assertEquals(
-'POINT (0 0)'
-            , $writer->write($b));
-
-        $g = $reader->read('LINESTRING(0 0, 10 10)');
-        $b = $g->envelope();
-        $this->assertEquals(
-'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'
-            , $writer->write($b));
-
-    }
-
-    public function testGeometry_intersection()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        /* POINT - POINT */
-        $g = $reader->read('POINT(0 0)');
-        $g2 = $reader->read('POINT(0 0)');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'POINT (0 0)'
-            , $writer->write($gi));
-        $g2 = $reader->read('POINT(1 0)');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'GEOMETRYCOLLECTION EMPTY'
-            , $writer->write($gi));
-
-        /* POINT - LINE */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $g2 = $reader->read('POINT(5 0)');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'POINT (5 0)'
-            , $writer->write($gi));
-        $g2 = $reader->read('POINT(12 0)');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'GEOMETRYCOLLECTION EMPTY'
-            , $writer->write($gi));
-
-        /* LINE - LINE */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $g2 = $reader->read('LINESTRING(5 -10, 5 10)');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'POINT (5 0)'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(5 0, 20 0)');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'LINESTRING (5 0, 10 0)'
-            , $writer->write($gi));
-
-        /* LINE - POLY */
-        $g = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
-        $g2 = $reader->read('LINESTRING(5 -10, 5 10)');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'LINESTRING (5 0, 5 10)'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(10 0, 20 0)');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'POINT (10 0)'
-            , $writer->write($gi));
-
-        /* POLY - POLY */
-        $g = $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))');
-        $gi = $g->intersection($g2);
-        $this->assertTrue($gi->equals($reader->read(
-'POLYGON ((10 5, 10 0, 5 0, 5 5, 10 5))'
-            )));
-        $g2 = $reader->read('POLYGON((10 0, 20 0, 20 -5, 10 -5, 10 0))');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'POINT (10 0)'
-            , $writer->write($gi));
-        $g2 = $reader->read('POLYGON((8 0, 20 0, 20 -5, 10 -5, 8 0))');
-        $gi = $g->intersection($g2);
-        $this->assertEquals( 'LINESTRING (8 0, 10 0)'
-            , $writer->write($gi));
-    }
-
-    public function testGeometry_clipByRect()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        /* POINT */
-        $g = $reader->read('POINT(0 0)');
-        $gi = $g->clipByRect(-1,-1,1,1);
-        $this->assertEquals( 'POINT (0 0)'
-            , $writer->write($gi));
-        $gi = $g->clipByRect(1,1,2,2);
-        $this->assertEquals( 'GEOMETRYCOLLECTION EMPTY'
-            , $writer->write($gi));
-
-        /* LINE */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $gi = $g->clipByRect(1,-1,2,1);
-        $this->assertEquals( 'LINESTRING (1 0, 2 0)'
-            , $writer->write($gi));
-
-        /* POLY */
-        $g = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
-        $gi = $g->clipByRect(1,1,5,5);
-        $this->assertEquals( 'POLYGON ((1 1, 1 5, 5 5, 5 1, 1 1))'
-            , $writer->write($gi));
-        $gi = $g->clipByRect(-1,-1,5,5);
-        $this->assertEquals( 'POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))'
-            , $writer->write($gi));
-
-    }
-
-    public function testGeometry_convexHull()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POINT(0 0)');
-        $b = $g->convexHull();
-        $this->assertEquals(
-'POINT (0 0)'
-            , $writer->write($b));
-
-        $g = $reader->read('LINESTRING(0 0, 10 10)');
-        $b = $g->convexHull();
-        $this->assertEquals(
-'LINESTRING (0 0, 10 10)'
-            , $writer->write($b));
-
-        $g = $reader->read('POLYGON((0 0, 0 10, 5 5, 10 10, 10 0, 0 0))');
-        $b = $g->convexHull();
-        $this->assertEquals(
-'POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))'
-            , $writer->write($b));
-
-    }
-
-    public function testGeometry_difference()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        /* POINT - POINT */
-        $g = $reader->read('POINT(0 0)');
-        $g2 = $reader->read('POINT(0 0)');
-        $gi = $g->difference($g2);
-        $this->assertEquals( 'GEOMETRYCOLLECTION EMPTY'
-            , $writer->write($gi));
-        $g2 = $reader->read('POINT(1 0)');
-        $gi = $g->difference($g2);
-        $this->assertEquals( 'POINT (0 0)'
-            , $writer->write($gi));
-
-        /* LINE - POINT */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $g2 = $reader->read('POINT(5 0)');
-        $gi = $g->difference($g2);
-        $this->assertEquals('LINESTRING (0 0, 10 0)'
-            , $writer->write($gi));
-
-        /* POINT - LINE */
-        $g = $reader->read('POINT(5 0)');
-        $g2 = $reader->read('LINESTRING(0 0, 10 0)');
-        $gi = $g->difference($g2);
-        $this->assertEquals('GEOMETRYCOLLECTION EMPTY'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(0 1, 10 1)');
-        $gi = $g->difference($g2);
-        $this->assertEquals( 'POINT (5 0)'
-            , $writer->write($gi));
-
-        /* LINE - LINE */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $g2 = $reader->read('LINESTRING(5 -10, 5 10)');
-        $gi = $g->difference($g2);
-        $this->assertEquals( 'MULTILINESTRING ((0 0, 5 0), (5 0, 10 0))'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(5 0, 20 0)');
-        $gi = $g->difference($g2);
-        $this->assertEquals( 'LINESTRING (0 0, 5 0)'
-            , $writer->write($gi));
-
-        /* POLY - LINE */
-        $g = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
-        $g2 = $reader->read('LINESTRING(5 -10, 5 10)');
-        $gi = $g->difference($g2);
-        $this->assertEquals(
-'POLYGON ((5 0, 0 0, 0 10, 5 10, 10 10, 10 0, 5 0))'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(10 0, 20 0)');
-        $gi = $g->difference($g2);
-        $this->assertEquals(
-'POLYGON ((10 0, 0 0, 0 10, 10 10, 10 0))'
-            , $writer->write($gi));
-
-        /* POLY - POLY */
-        $g = $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))');
-        $gi = $g->difference($g2);
-        $this->assertEquals(
-'POLYGON ((5 0, 0 0, 0 10, 10 10, 10 5, 5 5, 5 0))'
-            , $writer->write($gi));
-    }
-
-    public function testGeometry_symdifference()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        /* POINT - POINT */
-        $g = $reader->read('POINT(0 0)');
-        $g2 = $reader->read('POINT(0 0)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals( 'GEOMETRYCOLLECTION EMPTY'
-            , $writer->write($gi));
-        $g2 = $reader->read('POINT(1 0)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals( 'MULTIPOINT (0 0, 1 0)'
-            , $writer->write($gi));
-
-        /* LINE - POINT */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $g2 = $reader->read('POINT(5 0)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals('LINESTRING (0 0, 10 0)'
-            , $writer->write($gi));
-
-        /* POINT - LINE */
-        $g = $reader->read('POINT(5 0)');
-        $g2 = $reader->read('LINESTRING(0 0, 10 0)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals( 'LINESTRING (0 0, 10 0)'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(0 1, 10 1)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (POINT (5 0), LINESTRING (0 1, 10 1))'
-            , $writer->write($gi));
-
-        /* LINE - LINE */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $g2 = $reader->read('LINESTRING(5 -10, 5 10)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals(
-'MULTILINESTRING ((0 0, 5 0), (5 0, 10 0), (5 -10, 5 0), (5 0, 5 10))'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(5 0, 20 0)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals(
-'MULTILINESTRING ((0 0, 5 0), (10 0, 20 0))'
-            , $writer->write($gi));
-
-        /* POLY - LINE */
-        $g = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
-        $g2 = $reader->read('LINESTRING(5 -10, 5 10)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (LINESTRING (5 -10, 5 0), POLYGON ((5 0, 0 0, 0 10, 5 10, 10 10, 10 0, 5 0)))'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(10 0, 20 0)');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (LINESTRING (10 0, 20 0), POLYGON ((10 0, 0 0, 0 10, 10 10, 10 0)))'
-            , $writer->write($gi));
-
-        /* POLY - POLY */
-        $g = $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))');
-        $gi = $g->symDifference($g2);
-        $this->assertEquals(
-'MULTIPOLYGON (((5 0, 0 0, 0 10, 10 10, 10 5, 5 5, 5 0)), ((5 0, 10 0, 10 5, 15 5, 15 -5, 5 -5, 5 0)))'
-            , $writer->write($gi));
-    }
-
-    public function testGeometry_boundary()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POINT(0 0)');
-        $b = $g->boundary();
-        $this->assertEquals(
-'GEOMETRYCOLLECTION EMPTY'
-            , $writer->write($b));
-
-        $g = $reader->read('LINESTRING(0 0, 10 10)');
-        $b = $g->boundary();
-        $this->assertEquals(
-'MULTIPOINT (0 0, 10 10)'
-            , $writer->write($b));
-
-        $g = $reader->read(
-'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),( 5 5, 5 6, 6 6, 6 5, 5 5))');
-        $b = $g->boundary();
-        $this->assertEquals(
-'MULTILINESTRING ((0 0, 10 0, 10 10, 0 10, 0 0), (5 5, 5 6, 6 6, 6 5, 5 5))'
-            , $writer->write($b));
-
-    }
-
-    public function testGeometry_union()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        /* POINT - POINT */
-        $g = $reader->read('POINT(0 0)');
-        $g2 = $reader->read('POINT(0 0)');
-        $gi = $g->union($g2);
-        $this->assertEquals( 'POINT (0 0)'
-            , $writer->write($gi));
-        $g2 = $reader->read('POINT(1 0)');
-        $gi = $g->union($g2);
-        $this->assertEquals( 'MULTIPOINT (0 0, 1 0)'
-            , $writer->write($gi));
-
-        /* LINE - POINT */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $g2 = $reader->read('POINT(5 0)');
-        $gi = $g->union($g2);
-        $this->assertEquals('LINESTRING (0 0, 10 0)'
-            , $writer->write($gi));
-
-        /* POINT - LINE */
-        $g = $reader->read('POINT(5 0)');
-        $g2 = $reader->read('LINESTRING(0 0, 10 0)');
-        $gi = $g->union($g2);
-        $this->assertEquals( 'LINESTRING (0 0, 10 0)'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(0 1, 10 1)');
-        $gi = $g->union($g2);
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (POINT (5 0), LINESTRING (0 1, 10 1))'
-            , $writer->write($gi));
-
-        /* LINE - LINE */
-        $g = $reader->read('LINESTRING(0 0, 10 0)');
-        $g2 = $reader->read('LINESTRING(5 -10, 5 10)');
-        $gi = $g->union($g2);
-        $this->assertEquals(
-'MULTILINESTRING ((0 0, 5 0), (5 0, 10 0), (5 -10, 5 0), (5 0, 5 10))'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(5 0, 20 0)');
-        $gi = $g->union($g2);
-        $this->assertEquals(
-'MULTILINESTRING ((0 0, 5 0), (5 0, 10 0), (10 0, 20 0))'
-            , $writer->write($gi));
-
-        /* POLY - LINE */
-        $g = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
-        $g2 = $reader->read('LINESTRING(5 -10, 5 10)');
-        $gi = $g->union($g2);
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (LINESTRING (5 -10, 5 0), POLYGON ((5 0, 0 0, 0 10, 5 10, 10 10, 10 0, 5 0)))'
-            , $writer->write($gi));
-        $g2 = $reader->read('LINESTRING(10 0, 20 0)');
-        $gi = $g->union($g2);
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (LINESTRING (10 0, 20 0), POLYGON ((10 0, 0 0, 0 10, 10 10, 10 0)))'
-            , $writer->write($gi));
-
-        /* POLY - POLY */
-        $g = $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))');
-        $gi = $g->union($g2);
-        $this->assertEquals(
-'POLYGON ((5 0, 0 0, 0 10, 10 10, 10 5, 15 5, 15 -5, 5 -5, 5 0))'
-            , $writer->write($gi));
-    }
-
-    public function testGeometry_unaryunion()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('MULTIPOLYGON(
-                 ((0 0, 1 0, 1 1, 0 1, 0 0)),
-                 ((10 10, 10 14, 14 14, 14 10, 10 10),
-                  (11 11, 11 12, 12 12, 12 11, 11 11)),
-                 ((0 0, 11 0, 11 11, 0 11, 0 0))
-                ))');
-
-        $gu = $g->union();
-        $this->assertEquals(
-'POLYGON ((1 0, 0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0), (11 11, 12 11, 12 12, 11 12, 11 11))'
-            , $writer->write($gu));
-
-        $g = $reader->read('MULTILINESTRING(
-                 (0 0, 1 0, 1 1, 0 1, 0 0),
-                 (10 10, 10 14, 14 14, 14 10, 10 10),
-                  (11 11, 11 12, 12 12, 12 11, 11 11),
-                 (0 0, 11 0, 11 11, 0 11, 0 0)
-                )');
-
-        $gu = $g->union();
-        $this->assertEquals(
-'MULTILINESTRING ((0 0, 1 0), (1 0, 1 1, 0 1), (0 1, 0 0), (1 0, 11 0, 11 10), (11 10, 11 11), (11 11, 10 11), (10 11, 0 11, 0 1), (11 11, 11 12, 12 12, 12 11, 11 11), (10 10, 10 11), (10 11, 10 14, 14 14, 14 10, 11 10), (11 10, 10 10))'
-            , $writer->write($gu));
-
-        $g = $reader->read('MULTIPOINT(
-                 0 0, 1 0, 1 1, 0 1, 0 0,
-                 10 10, 10 14, 14 14, 14 10, 10 10,
-                  11 11, 11 12, 12 12, 12 11, 11 11,
-                 0 0, 11 0, 11 11, 0 11, 0 0
-                )');
-
-        $gu = $g->union();
-        $this->assertEquals(
-'MULTIPOINT (0 0, 0 1, 0 11, 1 0, 1 1, 10 10, 10 14, 11 0, 11 11, 11 12, 12 11, 12 12, 14 10, 14 14)'
-            , $writer->write($gu));
-
-        $g = $reader->read('GEOMETRYCOLLECTION(
-MULTIPOLYGON(
-                 ((0 0, 1 0, 1 1, 0 1, 0 0)),
-                 ((10 10, 10 14, 14 14, 14 10, 10 10),
-                  (11 11, 11 12, 12 12, 12 11, 11 11)),
-                 ((0 0, 11 0, 11 11, 0 11, 0 0))
-                ),
-MULTILINESTRING(
-                 (0 0, 1 0, 1 1, 0 1, 0 0),
-                 (10 10, 10 14, 14 14, 14 10, 10 10),
-                  (11 11, 11 12, 12 12, 12 11, 11 11),
-                 (0 0, 11 0, 11 11, 0 11, 0 0),(-8 8, -8 6)
-                ),
-MULTIPOINT(
-                 0 0, 1 0, 1 1, 0 1, 0 0,
-                 10 10, 10 14, 14 14, 14 10, 10 10,
-                  11 11, 11 12, 12 12, 12 11, 11 11,
-                 0 0, 11 0, 11 11, 0 11, 0 0, -10 -10
-                ))');
-
-        $gu = $g->union();
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (POINT (-10 -10), LINESTRING (-8 8, -8 6), POLYGON ((1 0, 0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0), (11 12, 11 11, 12 11, 12 12, 11 12)))'
-            , $writer->write($gu));
-
-
-    }
-
-    public function testGeometry_pointOnSurface()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POINT(0 0)');
-        $b = $g->pointOnSurface();
-        $this->assertEquals(
-'POINT (0 0)'
-            , $writer->write($b));
-
-        $g = $reader->read('LINESTRING(0 0, 5 5, 10 10)');
-        $b = $g->pointOnSurface();
-        $this->assertEquals(
-'POINT (5 5)'
-            , $writer->write($b));
-
-        $g = $reader->read('POLYGON((0 0, 0 10, 5 5, 10 10, 10 0, 0 0))');
-        $b = $g->pointOnSurface();
-        $this->assertEquals(
-'POINT (1 8)'
-            , $writer->write($b));
-    }
-
-    public function testGeometry_centroid()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POINT(0 0)');
-        $b = $g->centroid();
-        $this->assertEquals(
-'POINT (0 0)'
-            , $writer->write($b));
-
-        $g = $reader->read('LINESTRING(0 0, 10 10)');
-        $b = $g->centroid();
-        $this->assertEquals(
-'POINT (5 5)'
-            , $writer->write($b));
-
-        $g = $reader->read('POLYGON((0 0, 0 10, 5 5, 10 10, 10 0, 0 0))');
-        $b = $g->centroid();
-        $this->assertEquals(
-'POINT (5 4)'
-            , $writer->write($b));
-    }
-
-    public function testGeometry_relate()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POINT(0 0)');
-        $g2 = $reader->read('POINT(0 0)');
-        $ret = $g->relate($g2);
-        $this->assertEquals('0FFFFFFF2', $ret);
-        $ret = $g->relate($g2, '0FFFFFFF2');
-        $this->assertEquals(TRUE, $ret);
-        $ret = $g->relate($g2, '0*******T');
-        $this->assertEquals(TRUE, $ret);
-        $ret = $g->relate($g2, '0*******1');
-        $this->assertEquals(FALSE, $ret);
-
-        $g = $reader->read('POINT(0 0)');
-        $g2 = $reader->read('POINT(1 0)');
-        $ret = $g->relate($g2);
-        $this->assertEquals('FF0FFF0F2', $ret);
-        $ret = $g->relate($g2, 'FF0FFF0F2');
-        $this->assertEquals(TRUE, $ret);
-        $ret = $g->relate($g2, 'F*******2');
-        $this->assertEquals(TRUE, $ret);
-        $ret = $g->relate($g2, 'T*******2');
-        $this->assertEquals(FALSE, $ret);
-
-        $g = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))');
-        $g2 = $reader->read('POINT(1 0)');
-        $ret = $g->relate($g2);
-        $this->assertEquals('FF20F1FF2', $ret);
-        $ret = $g->relate($g2, 'FF20F1FF2');
-        $this->assertEquals(TRUE, $ret);
-        $ret = $g->relate($g2, 'F****T**T');
-        $this->assertEquals(TRUE, $ret);
-        $ret = $g->relate($g2, 'T*******2');
-        $this->assertEquals(FALSE, $ret);
-
-    }
-
-    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();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('GEOMETRYCOLLECTION(
-            LINESTRING(0 0, 10 10),
-            LINESTRING(185 221, 100 100),
-            LINESTRING(185 221, 88 275, 180 316),
-            LINESTRING(185 221, 292 281, 180 316),
-            LINESTRING(189 98, 83 187, 185 221),
-            LINESTRING(189 98, 325 168, 185 221))
-            )');
-
-        $g2 = $reader->read('POINT(0 0)');
-
-        $ret = GEOSPolygonize($g);
-
-        $this->assertEquals('array', gettype($ret));
-        $this->assertEquals('array', gettype($ret['rings']));
-        $this->assertEquals('array', gettype($ret['cut_edges']));
-        $this->assertEquals('array', gettype($ret['dangles']));
-        $this->assertEquals('array', gettype($ret['invalid_rings']));
-
-        $this->assertEquals(2, count($ret['rings']));
-        $this->assertEquals(
-'POLYGON ((185 221, 88 275, 180 316, 292 281, 185 221))' # JTS-confirmed!
-            , $writer->write($ret['rings'][0]));
-        $this->assertEquals(
-'POLYGON ((189 98, 83 187, 185 221, 325 168, 189 98))' # JTS-confirmed !
-            , $writer->write($ret['rings'][1]));
-
-        $this->assertEquals(0, count($ret['cut_edges']));
-
-        $this->assertEquals(0, count($ret['invalid_rings']));
-
-        /*
-         * FIXME: the duplicated dangle (0 0, 10 10) is unexpected
-         */
-
-        $this->assertEquals(2, count($ret['dangles']));
-        $this->assertEquals(
-'LINESTRING (185 221, 100 100)' # JTS-confirmed !
-            , $writer->write($ret['dangles'][0]));
-        $this->assertEquals(
-'LINESTRING (0 0, 10 10)' # JTS-confirmed !
-            , $writer->write($ret['dangles'][1]));
-
-
-        ###########################################################
-
-        $g = $g->union($g2); /* Now make sure linestrings are noded */
-
-        $ret = GEOSPolygonize($g);
-
-        $this->assertEquals('array', gettype($ret));
-        $this->assertEquals('array', gettype($ret['rings']));
-        $this->assertEquals('array', gettype($ret['cut_edges']));
-        $this->assertEquals('array', gettype($ret['dangles']));
-        $this->assertEquals('array', gettype($ret['invalid_rings']));
-
-        $this->assertEquals(2, count($ret['dangles']));
-        $this->assertEquals(
-'LINESTRING (132 146, 100 100)'
-            , $writer->write($ret['dangles'][0]));
-        $this->assertEquals(
-'LINESTRING (0 0, 10 10)'
-            , $writer->write($ret['dangles'][1]));
-
-        $this->assertEquals(0, count($ret['invalid_rings']));
-
-	// TODO: test a polygonize run with cut lines and invalid_rings
-
-    }
-
-    public function testGeometry_lineMerge()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('MULTILINESTRING(
-            (0 0, 10 10),
-            (10 10, 10 0),
-            (5 0, 10 0),
-            (5 -5, 5 0)
-            )');
-
-        $ret = GEOSLineMerge($g);
-
-        $this->assertEquals('array', gettype($ret));
-        $this->assertEquals('1', count($ret));
-
-        $this->assertEquals(
-'LINESTRING (0 0, 10 10, 10 0, 5 0, 5 -5)'
-            , $writer->write($ret[0]));
-
-    }
-
-    public function testGeometry_sharedPaths()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        /* LINE - LINE */
-        $g1 = $reader->read('LINESTRING(0 0, 50 0)');
-        $g2 = $reader->read('MULTILINESTRING((5 0, 15 0),(40 0, 30 0))');
-        $gs = GEOSSharedPaths($g1, $g2);
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (MULTILINESTRING ((5 0, 15 0)), MULTILINESTRING ((30 0, 40 0)))'
-            , $writer->write($gs));
-    }
-
-    public function testGeometry_simplify()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('LINESTRING(0 0, 3 4, 5 10, 10 0, 10 9, 5 11, 0 9)');
-        $gs = $g->simplify(2);
-        $this->assertEquals( 'LINESTRING (0 0, 5 10, 10 0, 10 9, 0 9)'
-            , $writer->write($gs));
-        $gs = $g->simplify(2, TRUE);
-        $this->assertEquals( 'LINESTRING (0 0, 5 10, 10 0, 10 9, 5 11, 0 9)'
-            , $writer->write($gs));
-    }
-
-    public function testGeometry_setPrecision()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('LINESTRING(0 0, 3 4, 5 10, 10 0, 10 9, 5 11, 0 9)');
-        $g = $g->setPrecision(2);
-        $this->assertEquals(
-            'LINESTRING (0 0, 4 4, 6 10, 10 0, 10 10, 6 12, 0 10)'
-            , $writer->write($g));
-        $this->assertEquals($g->getPrecision(), 2);
-
-        $g = $g->setPrecision(0);
-        $this->assertEquals(
-            'LINESTRING (0 0, 4 4, 6 10, 10 0, 10 10, 6 12, 0 10)'
-            , $writer->write($g));
-        $this->assertEquals($g->getPrecision(), 0);
-
-        $g = $g->setPrecision(8);
-        $this->assertEquals(
-            'LINESTRING (0 0, 8 8, 8 0, 8 8, 8 16, 0 8)'
-            , $writer->write($g));
-        $this->assertEquals($g->getPrecision(), 8);
-
-        $g = $g->setPrecision(10);
-        $this->assertEquals(
-            'LINESTRING (0 0, 10 10, 10 0, 10 10, 10 20, 0 10)'
-            , $writer->write($g));
-        $this->assertEquals($g->getPrecision(), 10);
-
-        $g = $g->setPrecision(20);
-        $this->assertEquals(
-            'LINESTRING (0 0, 20 20, 20 0, 20 20, 0 20)'
-            , $writer->write($g));
-        $this->assertEquals($g->getPrecision(), 20);
-
-        $g = $reader->read('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))');
-        $g = $g->setPrecision(20);
-        $this->assertEquals(
-            'POLYGON EMPTY'
-            , $writer->write($g));
-        $this->assertEquals($g->getPrecision(), 20);
-    }
-
-    public function testGeometry_extractUniquePoints()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read(
-    'GEOMETRYCOLLECTION (
-        MULTIPOLYGON (
-            ((0 0, 1 0, 1 1, 0 1, 0 0)),
-            ((10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11))
-        ),
-        POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)),
-        MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)),
-        LINESTRING (0 0, 2 3),
-        MULTIPOINT (0 0, 2 3),
-        POINT (9 0),
-        POINT(1 0)),
-        LINESTRING EMPTY
-');
-
-        $gs = $g->extractUniquePoints();
-        if ( ! $gs ) RETURN_NULL(); /* should get an exception before */
-
-        $this->assertEquals( 
-'MULTIPOINT (0 0, 1 0, 1 1, 0 1, 10 10, 10 14, 14 14, 14 10, 11 11, 11 12, 12 12, 12 11, 2 3, 3 4, 9 0)'
-            , $writer->write($gs));
-    }
-
-    public function testGeometry_relationalOps()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g1 = $reader->read('POINT(0 0)');
-        $g2 = $reader->read('POINT(0 0)');
-
-        $this->assertFalse( $g1->disjoint($g2) );
-        $this->assertFalse( $g1->touches($g2) ); /* no bounds, can't touch */
-        $this->assertTrue( $g1->intersects($g2) );
-        $this->assertFalse( $g1->crosses($g2) );
-        $this->assertTrue( $g1->within($g2) );
-        $this->assertTrue( $g1->contains($g2) );
-        $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)');
-
-        $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, 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)');
-
-        $this->assertFalse( $g1->disjoint($g2) );
-        $this->assertFalse( $g1->touches($g2) ); 
-        $this->assertTrue( $g1->intersects($g2) );
-        $this->assertFalse( $g1->crosses($g2) );
-        $this->assertTrue( $g1->within($g2) );
-        $this->assertFalse( $g1->contains($g2) );
-        $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)');
-
-        $this->assertFalse( $g1->disjoint($g2) );
-        $this->assertFalse( $g1->touches($g2) ); 
-        $this->assertTrue( $g1->intersects($g2) );
-        $this->assertTrue( $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->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)');
-
-        $this->assertFalse( $g1->disjoint($g2) );
-        $this->assertFalse( $g1->touches($g2) ); 
-        $this->assertTrue( $g1->intersects($g2) );
-        $this->assertFalse( $g1->crosses($g2) );
-        $this->assertFalse( $g1->within($g2) );
-        $this->assertFalse( $g1->contains($g2) );
-        $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)');
-
-        $this->assertFalse( $g1->disjoint($g2) );
-        $this->assertFalse( $g1->touches($g2) ); 
-        $this->assertTrue( $g1->intersects($g2) );
-        $this->assertFalse( $g1->crosses($g2) );
-        $this->assertTrue( $g1->within($g2) );
-        $this->assertTrue( $g1->contains($g2) );
-        $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))');
-
-        $this->assertFalse( $g1->disjoint($g2) );
-        $this->assertFalse( $g1->touches($g2) ); 
-        $this->assertTrue( $g1->intersects($g2) );
-        $this->assertFalse( $g1->crosses($g2) );
-        $this->assertFalse( $g1->within($g2) );
-        $this->assertFalse( $g1->contains($g2) );
-        $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)');
-
-        $this->assertTrue( $g1->disjoint($g2) );
-        $this->assertFalse( $g1->touches($g2) ); 
-        $this->assertFalse( $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->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()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g1 = $reader->read('POINT(0 0)');
-        $this->assertFalse( $g1->isEmpty() );
-
-        $g1 = $reader->read('POINT EMPTY');
-        $this->assertTrue( $g1->isEmpty() );
-
-        $g1 = $reader->read('LINESTRING(0 0, 10 0)');
-        $this->assertFalse( $g1->isEmpty() );
-
-        $g1 = $reader->read('LINESTRING EMPTY');
-        $this->assertTrue( $g1->isEmpty() );
-
-        $g1 = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 0))');
-        $this->assertFalse( $g1->isEmpty() );
-
-        $g1 = $reader->read('POLYGON EMPTY');
-        $this->assertTrue( $g1->isEmpty() );
-
-        $g1 = $reader->read('GEOMETRYCOLLECTION(POINT(0 0))');
-        $this->assertFalse( $g1->isEmpty() );
-
-        $g1 = $reader->read('GEOMETRYCOLLECTION EMPTY');
-        $this->assertTrue( $g1->isEmpty() );
-    }
-
-    public function testGeometry_checkValidity()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POINT(0 0)');
-        $val = $g->checkValidity();
-        $this->assertType( 'array', $val );
-        $this->assertTrue( $val['valid'] );
-        $this->assertFalse( isset($val['reason']) );
-        $this->assertFalse( isset($val['location']) );
-
-        $g = $reader->read('POINT(0 NaN)');
-        $val = $g->checkValidity();
-        $this->assertType( 'array', $val );
-        $this->assertFalse( $val['valid'] );
-        $this->assertEquals( 'Invalid Coordinate', $val['reason'] );
-        $this->assertEquals( 'POINT (0 nan)',
-            $writer->write($val['location']) );
-
-        $g = $reader->read(
-           'POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))'
-        );
-        $val = $g->checkValidity();
-        $this->assertType( 'array', $val );
-        $this->assertFalse( $val['valid'] );
-        $this->assertEquals( 'Ring Self-intersection', $val['reason'] );
-        $this->assertEquals( 'POINT (0 0)',
-            $writer->write($val['location']) );
-
-        $g = $reader->read(
-           'POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))'
-        );
-        $flags = GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE;
-        $val = $g->checkValidity($flags);
-        $this->assertType( 'array', $val );
-        $this->assertTrue( $val['valid'] );
-        $this->assertFalse( isset($val['reason']) );
-        $this->assertFalse( isset($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() );
-    }
-
-    public function testGeometry_type()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(0 0)');
-        $this->assertEquals('Point', $g->typeName());
-        $this->assertEquals(GEOS_POINT, $g->typeId());
-
-        $g = $reader->read('MULTIPOINT (0 1, 2 3)');
-        $this->assertEquals('MultiPoint', $g->typeName());
-        $this->assertEquals(GEOS_MULTIPOINT, $g->typeId());
-
-        $g = $reader->read('LINESTRING (0 0, 2 3)');
-        $this->assertEquals('LineString', $g->typeName());
-        $this->assertEquals(GEOS_LINESTRING, $g->typeId());
-
-        $g = $reader->read('MULTILINESTRING ((0 1, 2 3), (10 10, 3 4))');
-        $this->assertEquals('MultiLineString', $g->typeName());
-        $this->assertEquals(GEOS_MULTILINESTRING, $g->typeId());
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertEquals('Polygon', $g->typeName());
-        $this->assertEquals(GEOS_POLYGON, $g->typeId());
-
-        $g = $reader->read('MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((10 10, 10 14, 14 14, 14 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11)))');
-        $this->assertEquals('MultiPolygon', $g->typeName());
-        $this->assertEquals(GEOS_MULTIPOLYGON, $g->typeId());
-
-        $g = $reader->read('GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((10 10, 10 14, 14 14, 14 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11))), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)), LINESTRING (0 0, 2 3), MULTIPOINT (0 0, 2 3), POINT (9 0))');
-        $this->assertEquals('GeometryCollection', $g->typeName());
-        $this->assertEquals(GEOS_GEOMETRYCOLLECTION, $g->typeId());
-    }
-
-    public function testGeometry_srid()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(0 0)');
-        $this->assertEquals(0, $g->getSRID());
-        $g->setSRID(2);
-        $this->assertEquals(2, $g->getSRID());
-    }
-
-    public function testGeometry_numGeometries()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(0 0)');
-        $this->assertEquals(1, $g->numGeometries());
-
-        $g = $reader->read('MULTIPOINT (0 1, 2 3)');
-        $this->assertEquals(2, $g->numGeometries());
-
-        $g = $reader->read('LINESTRING (0 0, 2 3)');
-        $this->assertEquals(1, $g->numGeometries());
-
-        $g = $reader->read('MULTILINESTRING ((0 1, 2 3), (10 10, 3 4))');
-        $this->assertEquals(2, $g->numGeometries());
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertEquals(1, $g->numGeometries());
-
-        $g = $reader->read('MULTIPOLYGON (
-            ((0 0, 1 0, 1 1, 0 1, 0 0)),
-            ((10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11)))');
-        $this->assertEquals(2, $g->numGeometries());
-
-        $g = $reader->read('GEOMETRYCOLLECTION (
-            MULTIPOLYGON (
-                ((0 0, 1 0, 1 1, 0 1, 0 0)),
-                ((10 10, 10 14, 14 14, 14 10, 10 10),
-                    (11 11, 11 12, 12 12, 12 11, 11 11))
-            ),
-            POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)),
-            MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)),
-            LINESTRING (0 0, 2 3),
-            MULTIPOINT (0 0, 2 3),
-            POINT (9 0))');
-        $this->assertEquals(6, $g->numGeometries());
-    }
-
-    public function testGeometry_geometryN()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(0 0)');
-        $c = $g->geometryN(0);
-        $this->assertTrue( $g->equalsExact($c) );
-
-        $g = $reader->read('MULTIPOINT (0 1, 2 3)');
-        $this->assertEquals($reader->read('POINT(0 1)'), $g->geometryN(0));
-        $this->assertEquals($reader->read('POINT(2 3)'), $g->geometryN(1));
-
-        $c = $g->geometryN(2);
-        $this->assertNull( $c );
-
-    }
-
-    public function testGeometry_numInteriorRings()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertEquals(0, $g->numInteriorRings());
-
-        $g = $reader->read('POLYGON (
-            (10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11))');
-        $this->assertEquals(1, $g->numInteriorRings());
-
-        $g = $reader->read('POLYGON (
-            (10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11),
-                (13 11, 13 12, 13.5 12, 13.5 11, 13 11))');
-        $this->assertEquals(2, $g->numInteriorRings());
-
-        $g = $reader->read('POINT (0 0)');
-        try {
-            $g->numInteriorRings();
-            $this->assertTrue( FALSE );
-        } catch (Exception $e) {
-            $this->assertContains( 'Polygon', $e->getMessage() );
-        }
-
-    }
-
-    public function testGeometry_numPoints()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('LINESTRING (0 0, 1 0, 1 1, 0 1)');
-        $this->assertEquals(4, $g->numPoints());
-
-        $g = $reader->read('POINT (0 0)');
-        try {
-            $g->numPoints();
-            $this->assertTrue( FALSE );
-        } catch (Exception $e) {
-            $this->assertContains( 'LineString', $e->getMessage() );
-        }
-
-    }
-
-    public function testGeometry_getXY()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT (1 2)');
-        $this->assertEquals(1, $g->getX());
-        $this->assertEquals(2, $g->getY());
-
-        $g = $reader->read('LINESTRING (0 0, 1 1)');
-        try {
-            $g->getX();
-            $this->assertTrue( FALSE );
-        } catch (Exception $e) {
-            $this->assertContains( 'Point', $e->getMessage() );
-        }
-
-        try {
-            $g->getY();
-            $this->assertTrue( FALSE );
-        } catch (Exception $e) {
-            $this->assertContains( 'Point', $e->getMessage() );
-        }
-
-    }
-
-    public function testGeometry_interiorRingN()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POLYGON (
-            (10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11))');
-        $r = $g->interiorRingN(0);
-        $this->assertEquals('LINEARRING (11 11, 11 12, 12 12, 12 11, 11 11)',
-            $writer->write($r) );
-
-        $g = $reader->read('POLYGON (
-            (10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11),
-                (13 11, 13 12, 13.5 12, 13.5 11, 13 11))');
-        $r = $g->interiorRingN(0);
-        $this->assertEquals('LINEARRING (11 11, 11 12, 12 12, 12 11, 11 11)',
-            $writer->write($r) );
-        $r = $g->interiorRingN(1);
-        $this->assertEquals('LINEARRING (13 11, 13 12, 14 12, 14 11, 13 11)',
-            $writer->write($r) );
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertNull($g->interiorRingN(0));
-
-        $g = $reader->read('POINT (0 0)');
-        try {
-            $g->interiorRingN(0);
-            $this->assertTrue( FALSE );
-        } catch (Exception $e) {
-            $this->assertContains( 'Polygon', $e->getMessage() );
-        }
-
-    }
-
-    public function testGeometry_exteriorRing()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POLYGON (
-            (10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11))');
-        $r = $g->exteriorRing();
-        $this->assertEquals('LINEARRING (10 10, 10 14, 14 14, 14 10, 10 10)',
-            $writer->write($r) );
-
-        $g = $reader->read('POINT (0 0)');
-        try {
-            $g->exteriorRing(0);
-            $this->assertTrue( FALSE );
-        } catch (Exception $e) {
-            $this->assertContains( 'Polygon', $e->getMessage() );
-        }
-
-    }
-
-    public function testGeometry_numCoordinates()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(0 0)');
-        $this->assertEquals(1, $g->numCoordinates());
-
-        $g = $reader->read('MULTIPOINT (0 1, 2 3)');
-        $this->assertEquals(2, $g->numCoordinates());
-
-        $g = $reader->read('LINESTRING (0 0, 2 3)');
-        $this->assertEquals(2, $g->numCoordinates());
-
-        $g = $reader->read('MULTILINESTRING ((0 1, 2 3), (10 10, 3 4))');
-        $this->assertEquals(4, $g->numCoordinates());
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertEquals(5, $g->numCoordinates());
-
-        $g = $reader->read('MULTIPOLYGON (
-            ((0 0, 1 0, 1 1, 0 1, 0 0)),
-            ((10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11)))');
-        $this->assertEquals(15, $g->numCoordinates());
-
-        $g = $reader->read('GEOMETRYCOLLECTION (
-            MULTIPOLYGON (
-                ((0 0, 1 0, 1 1, 0 1, 0 0)),
-                ((10 10, 10 14, 14 14, 14 10, 10 10),
-                    (11 11, 11 12, 12 12, 12 11, 11 11))
-            ),
-            POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)),
-            MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)),
-            LINESTRING (0 0, 2 3),
-            MULTIPOINT (0 0, 2 3),
-            POINT (9 0))');
-        $this->assertEquals(29, $g->numCoordinates());
-    }
-
-    public function testGeometry_dimension()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(0 0)');
-        $this->assertEquals(0, $g->dimension());
-
-        $g = $reader->read('MULTIPOINT (0 1, 2 3)');
-        $this->assertEquals(0, $g->dimension());
-
-        $g = $reader->read('LINESTRING (0 0, 2 3)');
-        $this->assertEquals(1, $g->dimension());
-
-        $g = $reader->read('MULTILINESTRING ((0 1, 2 3), (10 10, 3 4))');
-        $this->assertEquals(1, $g->dimension());
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertEquals(2, $g->dimension());
-
-        $g = $reader->read('MULTIPOLYGON (
-            ((0 0, 1 0, 1 1, 0 1, 0 0)),
-            ((10 10, 10 14, 14 14, 14 10, 10 10),
-                (11 11, 11 12, 12 12, 12 11, 11 11)))');
-        $this->assertEquals(2, $g->dimension());
-
-        $g = $reader->read('GEOMETRYCOLLECTION (
-            MULTIPOLYGON (
-                ((0 0, 1 0, 1 1, 0 1, 0 0)),
-                ((10 10, 10 14, 14 14, 14 10, 10 10),
-                    (11 11, 11 12, 12 12, 12 11, 11 11))
-            ),
-            POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)),
-            MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)),
-            LINESTRING (0 0, 2 3),
-            MULTIPOINT (0 0, 2 3),
-            POINT (9 0))');
-        $this->assertEquals(2, $g->dimension());
-    }
-
-    public function testGeometry_coordinateDimension()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POINT(0 0)');
-        $this->assertEquals(2, $g->coordinateDimension());
-
-        $g = $reader->read('POINT(0 0 0)');
-        $this->assertEquals(3, $g->coordinateDimension());
-
-    }
-
-    public function testGeometry_pointN()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('LINESTRING (10 10, 10 14, 14 14, 14 10)');
-        $this->assertEquals('POINT (10 10)', $writer->write($g->pointN(0)) );
-        $this->assertEquals('POINT (10 14)', $writer->write($g->pointN(1)) );
-        $this->assertEquals('POINT (14 14)', $writer->write($g->pointN(2)) );
-        $this->assertEquals('POINT (14 10)', $writer->write($g->pointN(3)) );
-        $this->assertNull( $g->pointN(4) );
-
-        $g = $reader->read('LINEARRING (11 11, 11 12, 12 11, 11 11)');
-        $this->assertEquals('POINT (11 11)', $writer->write($g->pointN(0)) );
-        $this->assertEquals('POINT (11 12)', $writer->write($g->pointN(1)) );
-        $this->assertEquals('POINT (12 11)', $writer->write($g->pointN(2)) );
-        $this->assertEquals('POINT (11 11)', $writer->write($g->pointN(3)) );
-
-        $g = $reader->read('POINT (0 0)');
-        try {
-            $g->pointN(0);
-            $this->assertTrue( FALSE );
-        } catch (Exception $e) {
-            $this->assertContains( 'LineString', $e->getMessage() );
-        }
-
-    }
-
-    public function testGeometry_startendPoint()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('LINESTRING (10 10, 10 14, 14 14, 14 10)');
-        $this->assertEquals('POINT (10 10)', $writer->write($g->startPoint()) );
-        $this->assertEquals('POINT (14 10)', $writer->write($g->endPoint()) );
-        $this->assertNull( $g->pointN(4) );
-
-        $g = $reader->read('LINEARRING (11 11, 11 12, 12 11, 11 11)');
-        $this->assertEquals('POINT (11 11)', $writer->write($g->startPoint()) );
-        $this->assertEquals('POINT (11 11)', $writer->write($g->endPoint()) );
-
-        $g = $reader->read('POINT (0 0)');
-        try {
-            $g->pointN(0);
-            $this->assertTrue( FALSE );
-        } catch (Exception $e) {
-            $this->assertContains( 'LineString', $e->getMessage() );
-        }
-
-    }
-
-    public function testGeometry_area()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertEquals( 1.0, $g->area() );
-
-        $g = $reader->read('POINT (0 0)');
-        $this->assertEquals( 0.0, $g->area() );
-
-        $g = $reader->read('LINESTRING (0 0 , 10 0)');
-        $this->assertEquals( 0.0, $g->area() );
-
-    }
-
-    public function testGeometry_length()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-        $this->assertEquals( 4.0, $g->length() );
-
-        $g = $reader->read('POINT (0 0)');
-        $this->assertEquals( 0.0, $g->length() );
-
-        $g = $reader->read('LINESTRING (0 0 , 10 0)');
-        $this->assertEquals( 10.0, $g->length() );
-
-    }
-
-    public function testGeometry_distance()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-
-        $g2 = $reader->read('POINT(0.5 0.5)');
-        $this->assertEquals( 0.0, $g->distance($g2) );
-
-        $g2 = $reader->read('POINT (-1 0)');
-        $this->assertEquals( 1.0, $g->distance($g2) );
-
-        $g2 = $reader->read('LINESTRING (3 0 , 10 0)');
-        $this->assertEquals( 2.0, $g->distance($g2) );
-
-    }
-
-    public function testGeometry_hausdorffDistance()
-    {
-        $reader = new GEOSWKTReader();
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-
-        $g2 = $reader->read('POINT(0 10)');
-        $this->assertEquals( 10.0, round($g->hausdorffDistance($g2)) );
-
-        $g2 = $reader->read('POINT (-1 0)');
-        $this->assertEquals( 2.0, round($g->hausdorffDistance($g2)) );
-
-        $g2 = $reader->read('LINESTRING (3 0 , 10 0)');
-        $this->assertEquals( 9.0, round($g->hausdorffDistance($g2)) );
-
-    }
-
-    public function testGeometry_delaunayTriangulation()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-
-        $b = $g->delaunayTriangulation();
-        $this->assertEquals(
-'GEOMETRYCOLLECTION (POLYGON ((0 1, 0 0, 1 0, 0 1)), POLYGON ((0 1, 1 0, 1 1, 0 1)))'
-            , $writer->write($b));
-
-        $b = $g->delaunayTriangulation(0,true);
-        $this->assertEquals(
-'MULTILINESTRING ((0 1, 1 1), (0 0, 0 1), (0 0, 1 0), (1 0, 1 1), (0 1, 1 0))'
-            , $writer->write($b));
-
-    }
-
-    public function testGeometry_voronoiDiagram()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setRoundingPrecision(0);
-
-        $g = $reader->read('MULTIPOINT(0 0, 100 0, 100 100, 0 100)');
-
-        $b = $g->voronoiDiagram();
-        $this->assertEquals(
-'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(
-'MULTILINESTRING ((50 50, 200 50), (50 50, 50 200), (50 -100, 50 50), (-100 50, 50 50))'
-            , $writer->write($b->normalize()));
-
-        $b = $g->voronoiDiagram(0, 1, $g->buffer(1000));
-        $this->assertEquals(
-'MULTILINESTRING ((50 50, 1100 50), (50 50, 50 1100), (50 -1000, 50 50), (-1000 50, 50 50))'
-            , $writer->write($b->normalize()));
-
-    }
-
-    public function testGeometry_snapTo()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setTrim(true);
-
-        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
-
-        $g2 = $reader->read('POINT(0.1 0)');
-
-        $snapped = $g->snapTo($g2, 0);
-        $this->assertEquals('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'
-            , $writer->write($snapped) );
-
-        $snapped = $g->snapTo($g2, 0.5);
-        $this->assertEquals('POLYGON ((0.1 0, 1 0, 1 1, 0 1, 0.1 0))'
-            , $writer->write($snapped) );
-    }
-
-    public function testGeometry_node()
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKTWriter();
-        $writer->setTrim(true);
-
-        $g = $reader->read('LINESTRING(0 0, 10 0, 5 -5, 5 5)');
-
-        $noded = $g->node();
-        $this->assertEquals('MULTILINESTRING ((0 0, 5 0), (5 0, 10 0, 5 -5, 5 0), (5 0, 5 5))'
-            , $writer->write($noded) );
-
-    }
-
-    public function testWKBWriter__construct()
-    {
-        $writer = new GEOSWKBWriter();
-        $this->assertNotNull($writer);
-    }
-
-    public function testWKBWriter_getOutputDimension()
-    {
-        $writer = new GEOSWKBWriter();
-        $this->assertEquals(2, $writer->getOutputDimension());
-    }
-
-    public function testWKBWriter_setOutputDimension()
-    {
-        $writer = new GEOSWKBWriter();
-        $writer->setOutputDimension(3);
-        $this->assertEquals(3, $writer->getOutputDimension());
-        $writer->setOutputDimension(2);
-        $this->assertEquals(2, $writer->getOutputDimension());
-
-        # 1 is invalid
-        try {
-            $writer->setOutputDimension(1);
-            $this->assertTrue(FALSE);
-        } catch (Exception $e) {
-            $this->assertContains('must be 2 or 3', $e->getMessage());
-        }
-
-        # 4 is invalid
-        try {
-            $writer->setOutputDimension(4);
-            $this->assertTrue(FALSE);
-        } catch (Exception $e) {
-            $this->assertContains('must be 2 or 3', $e->getMessage());
-        }
-    }
-
-    public function testWKBWriter_getsetByteOrder()
-    {
-        $writer = new GEOSWKBWriter();
-
-        /* Machine-dependent */
-        $bo = $writer->getByteOrder();
-
-        $obo = $bo ? 0 : 1;
-        $writer->setByteOrder($obo);
-        $this->assertEquals($obo, $writer->getByteOrder());
-
-        # Anything different from 0 (BIG_ENDIAN) or 1 (LITTLE_ENDIAN)
-        # is invalid
-        try {
-            $writer->setByteOrder(5);
-            $this->assertTrue(FALSE);
-        } catch (Exception $e) {
-            $this->assertContains('LITTLE (1) or BIG (0)', $e->getMessage());
-        }
-    }
-
-    public function testWKBWriter_getsetIncludeSRID()
-    {
-        $writer = new GEOSWKBWriter();
-
-        $this->assertEquals(FALSE, $writer->getIncludeSRID());
-        $writer->setIncludeSRID(TRUE);
-        $this->assertEquals(TRUE, $writer->getIncludeSRID());
-        $writer->setIncludeSRID(FALSE);
-        $this->assertEquals(FALSE, $writer->getIncludeSRID());
-    }
-
-    /**
-     * @dataProvider providerWKBWriter_write
-     *
-     * @param integer $byteOrder       The byte order: 0 for BIG endian, 1 for LITTLE endian.
-     * @param integer $inputDimension  The input dimension: 2 or 3.
-     * @param integer $outputDimension The output dimension: 2 or 3.
-     * @param boolean $includeSrid     Whether to include the SRID in the output.
-     * @param string  $wkb             The expected HEX WKB output.
-     */
-    public function testWKBWriter_write($byteOrder, $inputDimension, $outputDimension, $includeSrid, $wkb)
-    {
-        $reader = new GEOSWKTReader();
-        $writer = new GEOSWKBWriter();
-
-        $writer->setByteOrder($byteOrder);
-        $writer->setOutputDimension($outputDimension);
-        $writer->setIncludeSRID($includeSrid);
-
-        if ($inputDimension === 3) {
-            $g = $reader->read('POINT(6 7 8)');
-            $g->setSRID(53);
-        } else {
-            $g = $reader->read('POINT(6 7)');
-            $g->setSRID(43);
-        }
-
-        $this->assertSame(hex2bin($wkb), $writer->write($g));
-        $this->assertSame($wkb, $writer->writeHEX($g));
-    }
-
-    public function providerWKBWriter_write()
-    {
-        return array(
-            // 2D input
-            array(1, 2, 2, false, '010100000000000000000018400000000000001C40'),        // 2D LITTLE endian
-            array(1, 2, 2, true, '01010000202B00000000000000000018400000000000001C40'), // 2D LITTLE endian + SRID
-            array(0, 2, 2, false, '00000000014018000000000000401C000000000000'),        // 2D BIG endian
-            array(0, 2, 2, true, '00200000010000002B4018000000000000401C000000000000'), // 2D BIG endian + SRID
-            array(1, 2, 3, false, '010100000000000000000018400000000000001C40'),        // 3D LITTLE endian
-            array(1, 2, 3, true, '01010000202B00000000000000000018400000000000001C40'), // 3D LITTLE endian + SRID
-            array(0, 2, 3, false, '00000000014018000000000000401C000000000000'),        // 3D BIG endian
-            array(0, 2, 3, true, '00200000010000002B4018000000000000401C000000000000'), // 3D BIG endian + SRID
-
-            // 3D input
-            array(1, 3, 2, false, '010100000000000000000018400000000000001C40'),                        // 2D LITTLE endian
-            array(1, 3, 2, true, '01010000203500000000000000000018400000000000001C40'),                 // 2D LITTLE endian + SRID
-            array(0, 3, 2, false, '00000000014018000000000000401C000000000000'),                        // 2D BIG endian
-            array(0, 3, 2, true, '0020000001000000354018000000000000401C000000000000'),                 // 2D BIG endian + SRID
-            array(1, 3, 3, false, '010100008000000000000018400000000000001C400000000000002040'),        // 3D LITTLE endian
-            array(1, 3, 3, true, '01010000A03500000000000000000018400000000000001C400000000000002040'), // 3D LITTLE endian + SRID
-            array(0, 3, 3, false, '00800000014018000000000000401C0000000000004020000000000000'),        // 3D BIG endian
-            array(0, 3, 3, true, '00A0000001000000354018000000000000401C0000000000004020000000000000'), // 3D BIG endian + SRID
-        );
-    }
-
-    /**
-     * @expectedException \Exception
-     * @expectedExceptionMessage expects parameter 1
-     */
-    public function testInvalidWriteThrowsException()
-    {
-        $writer = new GEOSWKBWriter();
-        $writer->write(1);
-    }
-
-    /**
-     * @expectedException \Exception
-     * @expectedExceptionMessage expects parameter 1
-     */
-    public function testInvalidWriteHEXThrowsException()
-    {
-        $writer = new GEOSWKBWriter();
-        $writer->writeHEX(1);
-    }
-
-    public function testWKBReader__construct()
-    {
-        $reader = new GEOSWKBReader();
-        $this->assertNotNull($reader);
-    }
-
-    /**
-     * @dataProvider providerWKBReader_read
-     *
-     * @param string  $wkb  The WKB to read.
-     * @param boolean $is3D Whether the geometry is 3D (true) or 2D (false).
-     * @param integer $srid The expected result SRID.
-     */
-    public function testWKBReader_read($wkb, $is3D, $srid)
-    {
-        $reader = new GEOSWKBReader();
-
-        $writer = new GEOSWKTWriter();
-        $writer->setTrim(TRUE);
-        $writer->setOutputDimension(3);
-
-        $wkt = $is3D ? 'POINT Z (6 7 8)' : 'POINT (6 7)';
-
-        $g = $reader->read(hex2bin($wkb));
-        $this->assertSame($wkt, $writer->write($g));
-        $this->assertSame($srid, $g->getSRID());
-
-        $g = $reader->readHEX($wkb);
-        $this->assertSame($wkt, $writer->write($g));
-        $this->assertSame($srid, $g->getSRID());
-    }
-
-    public function providerWKBReader_read()
-    {
-        return array(
-            array('010100000000000000000018400000000000001C40',                         false,  0), // 2D LITTLE endian,
-            array('00000000014018000000000000401C000000000000',                         false,  0), // 2D BIG endian,
-            array('01010000202B00000000000000000018400000000000001C40',                 false, 43), // 2D LITTLE endian + SRID
-            array('00200000010000002B4018000000000000401C000000000000',                 false, 43), // 2D BIG endian + SRID,
-            array('010100008000000000000018400000000000001C400000000000002040',         true,   0), // 3D LITTLE endian
-            array('01010000A03500000000000000000018400000000000001C400000000000002040', true,  53), // 3D LITTLE endian + SRID
-            array('00800000014018000000000000401C0000000000004020000000000000',         true,   0), // 3D BIG endian
-            array('00A0000001000000354018000000000000401C0000000000004020000000000000', true,  53), // 3D BIG endian + SRID
-        );
-    }
-
-    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