// the find
mjaschen/phpgeo
Simple Yet Powerful Geo Library for PHP
phpgeo is a PHP library for geographic coordinates. It covers points on different ellipsoids, distance and bearing calculations (Haversine or Vincenty), polylines and polygons, point-in-polygon checks, and Ramer-Douglas-Peucker simplification. It suits PHP backends that need geodesy math without a GIS stack such as PostGIS or GEOS.
Distance calculation is swappable: Coordinate::getDistance() takes the calculator as an argument, so moving from Haversine (fast, spherical) to Vincenty (ellipsoidal, more precise) is a one-argument change at the call site. The regression tests live under tests/Regression/Github/ and are named after the GitHub issues they pin, so old bugs stay pinned. The upgrade section lists each breaking change with the action to take, and the PHP compatibility matrix says which release lines still get security fixes.
The README admits that Polygon::contains() gives wrong results for polygons with points on both sides of the 180/-180 meridian, and the library does not normalise those polygons for you. Vincenty can fail to converge for nearly antipodal points and throws NotConvergingException (the exception class is in the source tree), so any code that runs it on arbitrary pairs needs to catch that. Nothing in the README mentions a spatial index, so expect containment checks and simplification to cost time linear in the number of edges on every query. The simplify example also uses Simplify without a use line and imports Vincenty without using it, which suggests the snippets were not run as written.