Testing GEOS 3.3 PHP bindings

For PHP there has been an lack of GIS geometry functions libraries, like JTS provides for Java or GEOS for C.

Well, GEOS? GEOS provides Python bindings and with the upcoming release 3.3 there will be PHP bindings available! You can already try them using the code directly out of the SVN repository of GEOS which I will show you here.

What's needed

We will do some checking out and compiling, so let's make sure we have everything we need. I do this on a Ubuntu 10.04 as well as an 10.10 box, so I'll just give you the packages to install, this should work as well using Debian. For other distros, you have to adapt:

Getting the code

GEOS uses the SVN repository hosted by the fine folks of OSGeo, so let's check out using a straight-forward

$ svn checkout http://svn.osgeo.org/geos/trunk geos-svn

In order to make all tests run ok, you will need to patch the php/test.php file using the patch provided at this ticket first. Not anymore as of R3169.

The next steps are to prepare and configure the build and then \"make\" the build. The first two steps:

$ cd geos-svn
$ ./autogen.sh
$ ./configure --enable-php

For the actual compiling I don't use make && make install directly, but prefer check­in­stall in order to get a nice manageable deb package.

$ sudo checkinstall

Check­in­stall will ask you a number of questions, which mostly you can answer with yes. So create default set of package docs and enter \"GEOS 3.3 with PHP bindings.\" as the de­scrip­tion.

The other important thing to change is the version number which defaults to svn, but I prefer a more verbose 3.3-svn-20110126 (or whatever date it is...)

Then, let's check­in­stall do the compiling and the installing (that's why the sudo is needed...)

After build work

The last thing to enable the GEOS extension in PHP is to create a /etc/php5/conf.d/geos.ini file with the following content:

; GEOS extension
extension=geos.so