GeoPHP

GEOS Integration

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 automatic performance improvements.

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:

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:

Performance Improvements

Below are some simple performance tests that I ran using both a large set of roads (2MB of JSON), and a really simple polygon. For the polygon, I looped the test 3000 times to get an average.

The results are number of seconds to complete the operation (lower is better). As you can see installing the geos-php extension at least doubles performance and can, in some cases, lead to a 10x improvement in performance.