Skip to content
phayes edited this page Apr 15, 2011 · 15 revisions

GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS). This includes all the OpenGIS Simple Features for SQL spatial predicate functions and spatial operators. GeoPHP transparently integrates GEOS. If geoPHP detects that GEOS is installed it will automatically start using it - you don't need to do anything. When GEOS is installed, a bunch of additional geometry methods become available (detailed in the API Reference).

When you install GEOS you also get some pretty awesome Performance Improvements

You can learn more about GEOS on it's website at http://trac.osgeo.org/geos

Integration

You don't need to do anything special to integrate GEOS, just install it. However, if you want to make use of special GEOS functions that are not part of OpenGIS Standard (there aren't many), then you need to call them explicitly. Lucky for you, this is easy to do. Example:

$geos_geom = $foo->geos();
$geos_result = $bar->geos()->relateBoundaryNodeRule($geos_geom);
// Put it back into a geoPHP geometry
$geometry = geoPHP::geosToGeometry($geos_result);

However, it's unlikely that you will need to do this since most methods are cleanly wrapped and can be called directly from a geoPHP geometry.

Installation

To install GEOS with it's PHP extension, you need to compile it from source. This may sound scary, but it's really quite easy! Various instructions on installing GEOS (with the requisite PHP extension) can be found here:

Clone this wiki locally