brick/geo
brick/geo is a PHP geometry library for working with points, lines, polygons, and other shapes. Provides common spatial operations, parsing/formatting, and robust value objects to model geo data cleanly in applications and services.
🐛 Bug fixes
withRoundedCoordinates()with*() proxy methods using variadic parameters were broken💥 Breaking changes
The case of the following class names and namespaces has changed:
GEOSEngine => GeosEnginePDOEngine => PdoEngineSQLite3Engine => Sqlite3EngineRemoveZMProjector => RemoveZmProjectorSRIDProjector => SridProjectorSwapXYProjector => SwapXyProjectorTIN => TinGeometryIOException => GeometryIoExceptionIO\EWKBReader => Io\EwkbReaderIO\EWKBWriter => Io\EwkbWriterIO\EWKTReader => Io\EwktReaderIO\EWKTWriter => Io\EwktWriterIO\WKBReader => Io\WkbReaderIO\WKBWriter => Io\WkbWriterIO\WKTReader => Io\WktReaderIO\WKTWriter => Io\WktWriterIO\GeoJSONReader => Io\GeoJsonReaderIO\GeoJSONWriter => Io\GeoJsonWriterIO\GeoJSON\Feature => Io\GeoJson\FeatureIO\GeoJSON\FeatureCollection => Io\GeoJson\FeatureCollectionThe following breaking changes will only affect you if you're writing your own geometry engine:
GeometryEngine interface has a new method: concaveHull()DatabaseEngine::executeQuery() implementations must now accept bool parametersDatabaseEngine::getParameterPlaceholder() signature has changed to accept bool parametersDatabaseEngine::queryGeometry() is now finalThe following breaking changes may only affect you if you're writing your own engine or geometry classes:
GeometryException constructor signature has changedGeometry has a new method: withRoundedCoordinates()✨ New features
GeosOpEngine uses the geosop binary to perform geometry operationsGeometryEngine::concaveHull()Geometry method: withRoundedCoordinates()✨ Improvements
GeometryEngine methods are now properly documented with [@throws](https://github.com/throws) GeometryEngineException🐛 Bug fixes
WktParser and EwktParser now accept both MULTIPOINT (1 2, 3 4) and MULTIPOINT((1 2), (3 4)) syntaxes;
this notably fixes interoperability issues with PostGIS💥 Breaking changes
GeometryEngine has 2 new methods: lineInterpolatePoint(), lineInterpolatePoints()BoundingBox's constructor is now private, use BoundingBox::new() to create a new instanceCompoundCurve can now only contain LineString and CircularString instances; nested CompoundCurve instances are forbiddenGeometry no longer implements Countable and IteratorAggregate; subclasses implement these interfaces as needed, with proper typesSQLite3Exception class has been removedGeometryEngineException::operationNotSupportedByEngine() method has been removedfinal:
BoundingBoxCoordinateSystemGEOSEnginePDOEngineSQLite3EngineCoordinateSystemExceptionEmptyGeometryExceptionGeometryEngineExceptionGeometryIOExceptionInvalidGeometryExceptionNoSuchGeometryExceptionUnexpectedGeometryExceptionEWKBReaderEWKBWriterEWKTReaderEWKTWriterGeoJSONReaderGeoJSONWriterWKBReaderWKBWriterWKTReaderWKTWriter[@internal](https://github.com/internal), and are no longer part of the public API:
Attribute\NoProxyEngine\GeometryParameterIO\AbstractWKBReaderIO\AbstractWKBWriterIO\AbstractWKTReaderIO\AbstractWKTWriterIO\EWKBToolsIO\EWKTParserIO\WKBBufferIO\WKBByteOrderIO\WKBGeometryHeaderIO\WKBToolsIO\WKTParser🗑️ Deprecations
[@final](https://github.com/final), and will be made final in a future version:
CircularStringCompoundCurveCurvePolygonLineStringMultiLineStringMultiPointMultiPolygonPointTINTriangle✨ New features
GeometryEngine::lineInterpolatePoint(), lineInterpolatePoints() (#55 by @arminwinkt)✨ Improvements
Geometry::toArray() methodsPDOEngine and SQLite3Engine now wrap all underlying exceptions in a GeometryEngineExceptionGeometryEngineException now includes the original exception message🐛 Bug fixes
PDOEngine could be left modified when an exception occurswith*() methods🐛 Bug fixes
GeoJSONWriter erroneously refused to write MultiPoint, MultiLineString and MultiPolygon nested inside GeometryCollection (#53)✨ New features
GeoJSONWriter constructor now has a $lenient flag to allow nested GeometryCollection objects✨ Improvements
GeoJSONReaderGeoJSONWriter when the bbox attribute is not requested✨ New features
CircularString::withAddedPoints()CompoundCurve::withAddedCurves()CurvePolygon::withExteriorRing(), withInteriorRings(), withAddedInteriorRings()GeometryCollection::withAddedGeometries()LineString::withAddedPoints()Polygon::withExteriorRing(), withInteriorRings(), withAddedInteriorRings()PolyhedralSurface::withAddedPatches()🐛 Bug fixes
BoundingBox would get its immutability violated by setting a coordinate system✨ New features
RoundCoordinatesProjector💥 Breaking changes
GeometryEngine has a new method: split()GeometryEngine::boundingPolygons() has been removed✨ New features
GeometryEngine::split()💥 Breaking changes
8.1GeometryEngine has a new method: makeValid()AbstractWKBWriter::setByteOrder() now accepts a WKBByteOrder enum instead of a WKBTools::*_ENDIAN constantWKBTools::BIG_ENDIAN and WKBTools::LITTLE_ENDIAN have been removedWKBTools::checkByteOrder() has been removed✨ New features
GeometryEngine::makeValid()💥 Breaking changes
[@internal](https://github.com/internal) and considered an implementation detail. This means that they are no longer part of the public API and can change at any time. This means that you should always type-hint against the base class and not the proxy.Point constructor now throws an exception when passing NaN or infinite coordinates.GeometryEngine::pointOnSurface() now returns Point instead of Geometry.🐛 Bug fixes
Geometry::withSRID() now properly propagates the SRID to all sub-geometries. Previously, only the top-level geometry was updated.Point constructor would error when destructuring an associative array.✨ New features
Projector API to reproject geometry coordinates.Polygon::rings()Geometry::isIdenticalTo()✨ Improvements
GeometryCollection::geometryN() is now properly documented with generics.✨ Improvements
composer.json💥 Breaking changes
Minimum PHP version is now 8.0.
The global GeometryEngineRegistry is gone. All convenience methods that rely on the GeometryEngineRegistry have been removed.
You should now explicitly call the GeometryEngine, that you can get injected with your dependency injection container.
For example, the following call:
$lineString->length();
Should be replaced with:
$geometryEngine->length($lineString);
Detail of breaking changes
The following class has been removed:
GeometryEngineRegistryThe following method has been added:
GeometryEngine::isRing()The following method signatures have been changed:
GeometryEngine::boundingPolygons()The following deprecated methods have been removed:
Curve::isClosed()Curve::isRing()Curve::length()Geometry::boundary()Geometry::buffer()Geometry::centroid()Geometry::contains()Geometry::convexHull()Geometry::crosses()Geometry::difference()Geometry::disjoint()Geometry::distance()Geometry::equals()Geometry::envelope()Geometry::intersection()Geometry::intersects()Geometry::isSimple()Geometry::isValid()Geometry::locateAlong()Geometry::locateBetween()Geometry::maxDistance()Geometry::overlaps()Geometry::relate()Geometry::simplify()Geometry::snapToGrid()Geometry::symDifference()Geometry::touches()Geometry::transform()Geometry::union()Geometry::within()MultiCurve::isClosed()MultiCurve::length()MultiSurface::area()MultiSurface::pointOnSurface()Point::azimuth()PolyhedralSurface::boundingPolygons()PolyhedralSurface::isClosed()Surface::area()Surface::pointOnSurface()The following change only affects you if you implement a custom DatabaseEngine:
DatabaseEngine::getParameterPlaceholder() has changed💥 Non-breaking changes
DatabaseEngine::getParameterPlaceholder(mixed $parameter): stringGeometryEngine::length(Curve|MultiCurve $g): floatGeometryEngine::area(Surface|MultiSurface $g): floatGeometryEngine::pointOnSurface(Surface|MultiSurface $g): Geometry🐛 Fixes
🗑️ Deprecations
The GeometryEngineRegistry class has been deprecated. All convenience methods on Geometry classes that rely on the
GeometryEngineRegistry are deprecated, and will be removed in version 0.8.
You should now explicitly call the GeometryEngine, that you can get injected with your dependency injection container.
Deprecated methods:
Curve::isClosed()Curve::isRing()Curve::length()Geometry::boundary()Geometry::buffer()Geometry::centroid()Geometry::contains()Geometry::convexHull()Geometry::crosses()Geometry::difference()Geometry::disjoint()Geometry::distance()Geometry::equals()Geometry::envelope()Geometry::intersection()Geometry::intersects()Geometry::isSimple()Geometry::isValid()Geometry::locateAlong()Geometry::locateBetween()Geometry::maxDistance()Geometry::overlaps()Geometry::relate()Geometry::simplify()Geometry::snapToGrid()Geometry::symDifference()Geometry::touches()Geometry::transform()Geometry::union()Geometry::within()MultiCurve::isClosed()MultiCurve::length()MultiSurface::area()MultiSurface::pointOnSurface()Point::azimuth()PolyhedralSurface::boundingPolygons()PolyhedralSurface::isClosed()Surface::area()Surface::pointOnSurface()🐛 Fixes
💥 Breaking change
The Doctrine mapping types & functions have been moved to a separate package.
If you don't use these, you don't need to do anything to upgrade.
If you use them, just require the brick/geo-doctrine package in addition to brick/geo.
🐛 Fixes
GeometryCollection on MySQL 8 using DatabaseEngine (#33)🐛 Fixes
🐛 Fixes
✨ New features
Feature and FeatureCollection in GeoJSONReader and GeoJSONWriterbbox attribute in GeoJSONWriterGeometry::transform() transforms Geometry coordinates to a new SRIDGeometry::toXY() returns a new Geometry with no Z and M coordinatesGeometry::withoutZ() returns a new Geometry with the Z coordinate removedGeometry::withoutM() returns a new Geometry with the M coordinate removedGeometry::getBoundingBox() returns the south-west and north-east bounds of a GeometryCoordinateSystem::isEqualTo() compares against another CoordinateSystem🐛 Fixes
✨ Improvements
DatabaseEngine💥 BC breaks
CoordinateSystemException::sridMix()CoordinateSystemException::dimensionalityMix()The following breaks only affect you if you use the GeoJSON reader/writer:
GeoJSONReader now instantiates Features and FeatureCollections as Feature and FeatureCollection objects, instead of Geometry and GeometryCollection objectsGeoJSONWriter will now write GeometryCollections as GeometryCollection type, instead of FeatureCollectionThe following breaks will only affect you if you're writing your own geometry engine, or your own WKB reader:
AbstractWKBReader::readGeometryHeader() signature was changedWKBReader::read() signature was changedGeometryEngine has a new transform() methodProxyInterface has a new isProxyBinary() method🐛 Fixes
💥 BC breaks
Note: these breaks will likely not affect you, unless you're writing your own geometry engine.
DatabaseEngine::$useProxy is now private, and must be provided through a parent constructor call.DatabaseEngine::executeQuery(), when provided with geometry data, now takes GeometryParameter objects instead of Geometry objects directly.✨ New features
Point::azimuth() (#17) thanks to @Kolyunyacentroid() is now available on the root Geometry class (#20) thanks to @Kolyunya🐛 Fixes
💥 BC breaks
Note: these breaks will likely not affect you, unless you're writing your own geometry engine or WK(B|T) parser.
GeometryEngine interface adds an azimuth() methodGeometryEngine::centroid() now returns PointWKTParser / EWKTParser are now protectedWBKBuffer::readDoubles()'s $count parameter is now typed✨ New features
0.4💥 Breaking changes
EarthDistanceFunction has been removedEarth distance calculations should be delegated to the geometry engine, that should be able to handle geographic computations; MySQL 8, for example, supports calculating distances in meters between two SRID 4326 points.
Deprecations
Doctrine function EarthDistanceFunction is now deprecated, and will be removed in 0.3.0.
Improvements
This version extends compatibility to brick/reflection version 0.3.
New methods
Geometry::withSRID()CoordinateSystem::withSRID()These methods return a copy of the original object, with the SRID altered.
New method: Geometry::swapXY()
This methods returns a copy of the Geometry, with X and Y coordinates swapped. It is useful when needing to convert geometries from Lat, Lng to Lng, Lat and conversely.
Improvements to GeoJSON reader and writer classes:
GeoJSONReader can now be lenient with documents containing wrong case types, such as POINT instead of Point:$reader = new GeoJSONReader(true); // case-insensitive
GeoJSONWriter can now pretty-print the JSON output:$writer = new GeoJSONWriter(true); // pretty-print
This version adds support for importing from and exporting to GeoJSON:
Brick\Geo\IO\GeoJSONReaderBrick\Geo\IO\GeoJSONWriterThanks @michaelcurry 👍
Fixed a potential Error when an Exception is expected in WKBReader and EWKBReader.
Minimum PHP version is now 7.1.
First beta release.
How can I help you explore Laravel packages today?