From 6632e35aec16e0736274efefefa6a749b78ef347 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Sat, 6 Nov 2021 22:12:20 +0100 Subject: [PATCH 1/2] Add isRing() to GeometryEngine --- src/Engine/DatabaseEngine.php | 11 +++++++++++ src/Engine/GEOSEngine.php | 10 ++++++++++ src/Engine/GeometryEngine.php | 14 ++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/Engine/DatabaseEngine.php b/src/Engine/DatabaseEngine.php index 0e192f9..d08a31b 100644 --- a/src/Engine/DatabaseEngine.php +++ b/src/Engine/DatabaseEngine.php @@ -4,6 +4,7 @@ namespace Brick\Geo\Engine; +use Brick\Geo\Curve; use Brick\Geo\Exception\GeometryEngineException; use Brick\Geo\Geometry; use Brick\Geo\Point; @@ -331,6 +332,16 @@ public function isSimple(Geometry $g) : bool return $this->queryBoolean('ST_IsSimple', $g); } + public function isRing(Curve $curve) : bool + { + try { + return $this->queryBoolean('ST_IsRing', $curve); + } catch (GeometryEngineException $e) { + // Not all RDBMS (hello, MySQL) support ST_IsRing(), but we have an easy fallback + return $this->isClosed($curve) && $this->isSimple($curve); + } + } + public function equals(Geometry $a, Geometry $b) : bool { return $this->queryBoolean('ST_Equals', $a, $b); diff --git a/src/Engine/GEOSEngine.php b/src/Engine/GEOSEngine.php index f90545b..994d37a 100644 --- a/src/Engine/GEOSEngine.php +++ b/src/Engine/GEOSEngine.php @@ -4,6 +4,7 @@ namespace Brick\Geo\Engine; +use Brick\Geo\Curve; use Brick\Geo\Exception\GeometryEngineException; use Brick\Geo\IO\EWKBReader; use Brick\Geo\IO\EWKBWriter; @@ -188,6 +189,15 @@ public function isSimple(Geometry $g) : bool } } + public function isRing(Curve $curve) : bool + { + try { + return $this->toGEOS($curve)->isRing(); + } catch (\Exception $e) { + throw GeometryEngineException::operationNotSupportedByEngine($e); + } + } + public function equals(Geometry $a, Geometry $b) : bool { try { diff --git a/src/Engine/GeometryEngine.php b/src/Engine/GeometryEngine.php index aa26ee6..f2c58b8 100644 --- a/src/Engine/GeometryEngine.php +++ b/src/Engine/GeometryEngine.php @@ -157,6 +157,20 @@ public function isClosed(Geometry $g) : bool; */ public function isSimple(Geometry $g) : bool; + /** + * Returns true if the curve is a ring, i.e. if it is both closed and simple. + * + * The curve is closed if its start point is equal to its end point. + * The curve is simple if it does not pass through the same point more than once. + * + * @param Curve $curve The curve. + * + * @return bool Whether the curve is a ring. + * + * @throws GeometryEngineException If the operation is not supported by the engine. + */ + public function isRing(Curve $curve) : bool; + /** * Returns true if the given geometries represent the same geometry. * From bba12f82ef5cb4b313aeb6df8fd2db26680fb634 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Sat, 6 Nov 2021 20:10:29 +0100 Subject: [PATCH 2/2] Remove GeometryEngineRegistry --- CHANGELOG.md | 83 +++++++++++++ README.md | 16 +-- phpunit-bootstrap.php | 3 +- src/Curve.php | 20 ++-- src/Engine/DatabaseEngine.php | 4 +- src/Engine/GEOSEngine.php | 4 +- src/Engine/GeometryEngine.php | 89 ++++++++++---- src/Engine/GeometryEngineRegistry.php | 45 ------- src/Geometry.php | 164 +++++++++++++++++--------- src/MultiCurve.php | 14 ++- src/MultiSurface.php | 14 ++- src/Point.php | 10 +- src/PolyhedralSurface.php | 14 ++- src/Proxy/PointProxy.php | 9 -- src/Surface.php | 14 ++- tests/AbstractTestCase.php | 25 ++-- tests/CurveTest.php | 15 ++- tests/GeometryTest.php | 114 +++++++++--------- tests/MultiCurveTest.php | 9 +- tests/MultiSurfaceTest.php | 14 +-- tests/PointTest.php | 4 +- tests/SurfaceTest.php | 14 +-- 22 files changed, 425 insertions(+), 273 deletions(-) delete mode 100644 src/Engine/GeometryEngineRegistry.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eab274..3d35665 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,88 @@ # Changelog +## Unreleased + +💥 **Breaking changes** + +The global `GeometryEngineRegistry` is gone. All convenience methods that rely on the `GeometryEngine` are deprecated, and need the `GeometryEngine` to be passed explicitly as an extra argument. +You should now explicitly call the `GeometryEngine`, that you can get injected with your dependency injection container. + +For example, the following call: + +```php +$lineString->length(); +``` + +Should be replaced with: + +```php +$geometryEngine->length($lineString); +``` + +You can still call it this way for now: + +```php +$lineString->length($geometryEngine); +``` + +But this behaviour is deprecated and will be removed in a future version. + +**Detail of breaking changes** + +The following class has been removed: + +- `GeometryEngineRegistry` + +The following method has been added: + +- `GeometryEngine::isRing()` + +The following method signatures have been changed: + +- `GeometryEngine::boundingPolygons()` + +The following methods have been deprecated, and now need an extra `GeometryEngine` parameter: + +- `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()` + ## [0.7.1](https://github.com/brick/geo/releases/tag/0.7.1) - 2021-11-06 🐛 **Fixes** diff --git a/README.md b/README.md index 464e5e2..ed4fc91 100644 --- a/README.md +++ b/README.md @@ -77,11 +77,10 @@ Following is a step-by-step guide for all possible configurations: - Use this bootstrap code in your project: ```php - use Brick\Geo\Engine\GeometryEngineRegistry; use Brick\Geo\Engine\PDOEngine; $pdo = new PDO('mysql:host=localhost', 'root', ''); - GeometryEngineRegistry::set(new PDOEngine($pdo)); + $geometryEngine = new PDOEngine($pdo); ``` Update the code with your own connection parameters, or use an existing `PDO` connection if you have one (recommended). @@ -109,11 +108,10 @@ Just ensure that your MariaDB version is `5.5` or greater. - Use this bootstrap code in your project: ```php - use Brick\Geo\Engine\GeometryEngineRegistry; use Brick\Geo\Engine\PDOEngine; $pdo = new PDO('pgsql:host=localhost', 'postgres', ''); - GeometryEngineRegistry::set(new PDOEngine($pdo)); + $geometryEngine = new PDOEngine($pdo); ``` Update the code with your own connection parameters, or use an existing `PDO` connection if you have one (recommended). @@ -149,12 +147,11 @@ all you need to do is create an additional in-memory SQLite3 database just to po - Use this bootstrap code in your project: ```php - use Brick\Geo\Engine\GeometryEngineRegistry; use Brick\Geo\Engine\SQLite3Engine; $sqlite3 = new SQLite3(':memory:'); $sqlite3->loadExtension('mod_spatialite.so'); - GeometryEngineRegistry::set(new SQLite3Engine($sqlite3)); + $geometryEngine = new SQLite3Engine($sqlite3); ``` - Depending on the functions you use, you will probably need to initialize the spatial metadata by running this query: @@ -181,10 +178,9 @@ In this example we have created an in-memory database for our GIS calculations, - Use this bootstrap code in your project: ```php - use Brick\Geo\Engine\GeometryEngineRegistry; use Brick\Geo\Engine\GEOSEngine; - GeometryEngineRegistry::set(new GEOSEngine()); + $geometryEngine = new GEOSEngine(); ``` @@ -238,9 +234,9 @@ Example use Brick\Geo\Polygon; $polygon = Polygon::fromText('POLYGON ((0 0, 0 3, 3 3, 0 0))'); -echo $polygon->area(); // 4.5 +echo $geometryEngine->area($polygon); // 4.5 -$centroid = $polygon->centroid(); +$centroid = $geometryEngine->centroid($polygon); echo $centroid->asText(); // POINT (1 2) ``` diff --git a/phpunit-bootstrap.php b/phpunit-bootstrap.php index 5de80d3..55fa914 100644 --- a/phpunit-bootstrap.php +++ b/phpunit-bootstrap.php @@ -1,6 +1,5 @@ length()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function length() : float + public function length(GeometryEngine $geometryEngine) : float { - return GeometryEngineRegistry::get()->length($this); + return $geometryEngine->length($this); } /** @@ -56,13 +58,15 @@ abstract public function endPoint() : Point; * * The curve is closed if `startPoint()` == `endPoint()`. * + * @deprecated Please use `$geometryEngine->isClosed()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function isClosed() : bool + public function isClosed(GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->isClosed($this); + return $geometryEngine->isClosed($this); } /** @@ -73,12 +77,14 @@ public function isClosed() : bool * The curve is closed if its start point is equal to its end point. * The curve is simple if it does not pass through the same point more than once. * + * @deprecated Please use `$geometryEngine->isRing()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function isRing() : bool + public function isRing(GeometryEngine $geometryEngine) : bool { - return $this->isClosed() && $this->isSimple(); + return $geometryEngine->isRing($this); } } diff --git a/src/Engine/DatabaseEngine.php b/src/Engine/DatabaseEngine.php index d08a31b..82c818e 100644 --- a/src/Engine/DatabaseEngine.php +++ b/src/Engine/DatabaseEngine.php @@ -7,7 +7,9 @@ use Brick\Geo\Curve; use Brick\Geo\Exception\GeometryEngineException; use Brick\Geo\Geometry; +use Brick\Geo\MultiPolygon; use Brick\Geo\Point; +use Brick\Geo\Polygon; use Brick\Geo\Proxy; /** @@ -422,7 +424,7 @@ public function maxDistance(Geometry $a, Geometry $b) : float return $this->queryFloat('ST_MaxDistance', $a, $b); } - public function boundingPolygons(Geometry $g) : Geometry + public function boundingPolygons(Polygon $p) : MultiPolygon { throw GeometryEngineException::unimplementedMethod(__METHOD__); } diff --git a/src/Engine/GEOSEngine.php b/src/Engine/GEOSEngine.php index 994d37a..6eb3fb4 100644 --- a/src/Engine/GEOSEngine.php +++ b/src/Engine/GEOSEngine.php @@ -9,7 +9,9 @@ use Brick\Geo\IO\EWKBReader; use Brick\Geo\IO\EWKBWriter; use Brick\Geo\Geometry; +use Brick\Geo\MultiPolygon; use Brick\Geo\Point; +use Brick\Geo\Polygon; use GEOSWKBReader; use GEOSWKBWriter; use GEOSWKTReader; @@ -358,7 +360,7 @@ public function maxDistance(Geometry $a, Geometry $b) : float throw GeometryEngineException::unimplementedMethod(__METHOD__); } - public function boundingPolygons(Geometry $g) : Geometry + public function boundingPolygons(Polygon $p) : MultiPolygon { throw GeometryEngineException::unimplementedMethod(__METHOD__); } diff --git a/src/Engine/GeometryEngine.php b/src/Engine/GeometryEngine.php index f2c58b8..b8c4f6f 100644 --- a/src/Engine/GeometryEngine.php +++ b/src/Engine/GeometryEngine.php @@ -8,8 +8,10 @@ use Brick\Geo\Geometry; use Brick\Geo\Exception\GeometryEngineException; use Brick\Geo\MultiCurve; +use Brick\Geo\MultiPolygon; use Brick\Geo\MultiSurface; use Brick\Geo\Point; +use Brick\Geo\Polygon; use Brick\Geo\Surface; /** @@ -18,7 +20,7 @@ interface GeometryEngine { /** - * Returns a geometry that represents the point set union of the geometries. + * Returns a geometry that represents the union of the geometries. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -44,6 +46,13 @@ public function difference(Geometry $a, Geometry $b) : Geometry; /** * Returns a geometry representing the bounding box of the supplied geometry. * + * The polygon is defined by the corner points of the bounding box + * [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)]. + * Minimums for Z and M may be added. The simplest representation of an Envelope + * is as two direct positions, one containing all the minimums, and another all + * the maximums. In some cases, this coordinate will be outside the range of + * validity for the Spatial Reference System. + * * @param Geometry $g The geometry. * * @return Geometry The envelope of the geometry. @@ -55,6 +64,8 @@ public function envelope(Geometry $g) : Geometry; /** * Returns the length of a Curve or MultiCurve in its associated spatial reference. * + * The length of a MultiCurve is equal to the sum of the lengths of the element Curves. + * * @param Curve|MultiCurve $g The geometry. * * @return float The length of the geometry. @@ -90,7 +101,7 @@ public function area(Geometry $g) : float; public function azimuth(Point $observer, Point $subject) : float; /** - * Returns the geometric center of a Geometry. + * Returns the geometric center of a geometry, or equivalently, the center of mass of the geometry as a Point. * * @param Geometry $g The geometry. * @@ -114,6 +125,9 @@ public function pointOnSurface(Geometry $g) : Geometry; /** * Returns the closure of the combinatorial boundary of a Geometry. * + * Because the result of this function is a closure, and hence topologically closed, + * the resulting boundary can be represented using representational Geometry primitives. + * * @param Geometry $g The geometry. * * @return Geometry The boundary of the geometry. @@ -123,7 +137,7 @@ public function pointOnSurface(Geometry $g) : Geometry; public function boundary(Geometry $g) : Geometry; /** - * Checks whether a geometry is valid, as defined by the OGC specification. + * Returns true if the geometry is valid, as defined by the OGC specification. * * For example, a polygon with self-intersecting rings is invalid. * @@ -138,6 +152,9 @@ public function isValid(Geometry $g) : bool; /** * Returns true if the geometry is closed. * + * A Curve is closed if its start point is equal to its end point. + * A MultiCurve is considered closed if each element curve is closed. + * * @param Geometry $g The geometry. * * @return bool Whether the geometry is closed. @@ -172,7 +189,7 @@ public function isSimple(Geometry $g) : bool; public function isRing(Curve $curve) : bool; /** - * Returns true if the given geometries represent the same geometry. + * Returns true if the given geometries are spatially equal. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -184,9 +201,10 @@ public function isRing(Curve $curve) : bool; public function equals(Geometry $a, Geometry $b) : bool; /** - * Returns true if the given geometries do not spatially intersect. + * Returns true if the given geometries are spatially disjoint. * - * Geometries spatially intersect if they share any portion of space. + * The geometries are disjoint if they do not share any space together. + * This is the opposite of `intersects()`. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -201,6 +219,7 @@ public function disjoint(Geometry $a, Geometry $b) : bool; * Returns true if the given geometries spatially intersect. * * Geometries spatially intersect if they share any portion of space. + * This is the opposite of `disjoint()`. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -212,7 +231,9 @@ public function disjoint(Geometry $a, Geometry $b) : bool; public function intersects(Geometry $a, Geometry $b) : bool; /** - * Returns true if the geometries have at least one point in common, but their interiors do not intersect. + * Returns true if the geometries spatially touch each other. + * + * The geometries touch if they have at least one point in common, but their interiors do not intersect. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -224,7 +245,9 @@ public function intersects(Geometry $a, Geometry $b) : bool; public function touches(Geometry $a, Geometry $b) : bool; /** - * Returns true if the supplied geometries have some, but not all, interior points in common. + * Returns true if the supplied geometries spatially cross each other. + * + * The geometries cross if they have some, but not all, interior points in common. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -238,6 +261,8 @@ public function crosses(Geometry $a, Geometry $b) : bool; /** * Returns true if the geometry $a is completely inside geometry $b. * + * This is the inverse of `contains()`: `within($a, $b) == contains($b, $a)`. + * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. * @@ -248,11 +273,13 @@ public function crosses(Geometry $a, Geometry $b) : bool; public function within(Geometry $a, Geometry $b) : bool; /** - * Returns true if `$a` contains `$b`. + * Returns true if `$a` spatially contains `$b`. * * `$a` contains `$b` if and only if no points of `$b` lie in the exterior of `$a`, * and at least one point of the interior of `$b` lies in the interior of `$a`. * + * This is the inverse of `within()`: `$a->contains($b) == $b->within($a)`. + * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. * @@ -263,7 +290,7 @@ public function within(Geometry $a, Geometry $b) : bool; public function contains(Geometry $a, Geometry $b) : bool; /** - * Returns true if the two geometries overlap. + * Returns true if the two geometries spatially overlap. * * The geometries overlap if they share space, are of the same dimension, * but are not completely contained by each other. @@ -280,8 +307,12 @@ public function overlaps(Geometry $a, Geometry $b) : bool; /** * Returns true if `$a` is spatially related to `$b`. * - * Tests for intersections between the Interior, Boundary and Exterior - * of the two geometries as specified by the values in the intersectionMatrixPattern. + * This method tests for intersections between the interior, boundary and exterior of the + * two geometries as specified by the values in the DE-9IM matrix pattern. + * + * This is especially useful for testing compound checks of intersection, crosses, etc. in one step. + * + * @see http://en.wikipedia.org/wiki/DE-9IM * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -319,9 +350,13 @@ public function locateAlong(Geometry $g, float $mValue) : Geometry; public function locateBetween(Geometry $g, float $mStart, float $mEnd) : Geometry; /** - * Returns the 2-dimensional cartesian minimum distance between two geometries in projected units. + * Returns the shortest distance between any two points in the two geometries. * - * The distance is based on spatial ref. + * The distance is calculated in the spatial reference system of + * this geometry. Because the geometries are closed, it is + * possible to find a point on each geometry involved, such + * that the distance between these 2 points is the returned distance + * between their geometries. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -335,6 +370,11 @@ public function distance(Geometry $a, Geometry $b) : float; /** * Returns a geometry that represents all points whose distance from this Geometry is <= distance. * + * Calculations are in the spatial reference system of this geometry. + * Because of the limitations of linear interpolation, there will often be + * some relatively small error in this distance, but it should be near the + * resolution of the coordinates used. + * * @param Geometry $g The geometry. * @param float $distance The buffer distance. * @@ -345,7 +385,11 @@ public function distance(Geometry $a, Geometry $b) : float; public function buffer(Geometry $g, float $distance) : Geometry; /** - * Returns the minimum convex geometry that encloses all geometries within the set. + * Returns a geometry that represents the convex hull of this geometry. + * + * The convex hull of a geometry represents the minimum convex geometry that encloses all geometries within the set. + * One can think of the convex hull as the geometry you get by wrapping an elastic band around a set of geometries. + * This is different from a concave hull which is analogous to shrink-wrapping your geometries. * * @param Geometry $g The geometry. * @@ -356,7 +400,7 @@ public function buffer(Geometry $g, float $distance) : Geometry; public function convexHull(Geometry $g) : Geometry; /** - * Returns a geometry that represents the shared portion of `$a` and `$b`. + * Returns a geometry that represents the shared portion of the given geometries. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -368,7 +412,10 @@ public function convexHull(Geometry $g) : Geometry; public function intersection(Geometry $a, Geometry $b) : Geometry; /** - * Returns a geometry that represents the portions of `$a` and `$b` that do not intersect. + * Returns a geometry that represents the symmetric difference of the given geometries. + * + * The result is a geometry that represents the portions of the two geometries that do not intersect. + * It is called a symmetric difference because `$a->symDifference($b) == $b->symDifference($a)`. * * @param Geometry $a The first geometry. * @param Geometry $b The second geometry. @@ -392,7 +439,7 @@ public function symDifference(Geometry $a, Geometry $b) : Geometry; public function snapToGrid(Geometry $g, float $size) : Geometry; /** - * Returns a "simplified" version of the given geometry using the Douglas-Peucker algorithm. + * Returns a simplified version of the given geometry using the Douglas-Peucker algorithm. * * @param Geometry $g The geometry. * @param float $tolerance The tolerance. @@ -418,13 +465,13 @@ public function maxDistance(Geometry $a, Geometry $b) : float; /** * Returns the collection of polygons that bounds the given polygon 'p' for any polygon 'p' in the surface. * - * @param Geometry $g + * @param Polygon $p * - * @return Geometry + * @return MultiPolygon * * @throws GeometryEngineException If the operation is not supported by the engine. */ - public function boundingPolygons(Geometry $g) : Geometry; + public function boundingPolygons(Polygon $p) : MultiPolygon; /** * Returns a new geometry with its coordinates transformed to a different spatial reference system. diff --git a/src/Engine/GeometryEngineRegistry.php b/src/Engine/GeometryEngineRegistry.php deleted file mode 100644 index c3b09ec..0000000 --- a/src/Engine/GeometryEngineRegistry.php +++ /dev/null @@ -1,45 +0,0 @@ -envelope()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function envelope() : Geometry + public function envelope(GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->envelope($this); + return $geometryEngine->envelope($this); } /** @@ -248,13 +250,15 @@ public function isEmpty() : bool * * For example, a polygon with self-intersecting rings is invalid. * + * @deprecated Please use `$geometryEngine->isValid()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function isValid() : bool + public function isValid(GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->isValid($this); + return $geometryEngine->isValid($this); } /** @@ -263,13 +267,15 @@ public function isValid() : bool * A geometry is simple if it has no anomalous geometric points, * such as self intersection or self tangency. * + * @deprecated Please use `$geometryEngine->isSimple()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function isSimple() : bool + public function isSimple(GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->isSimple($this); + return $geometryEngine->isSimple($this); } /** @@ -294,13 +300,15 @@ public function isMeasured() : bool * Because the result of this function is a closure, and hence topologically closed, * the resulting boundary can be represented using representational Geometry primitives. * + * @deprecated Please use `$geometryEngine->boundary()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function boundary() : Geometry + public function boundary(GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->boundary($this); + return $geometryEngine->boundary($this); } /** @@ -308,25 +316,29 @@ public function boundary() : Geometry * * Some geometry engines only support this method on surfaces. * + * @deprecated Please use `$geometryEngine->centroid()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function centroid() : Point + public function centroid(GeometryEngine $geometryEngine) : Point { - return GeometryEngineRegistry::get()->centroid($this); + return $geometryEngine->centroid($this); } /** * Returns whether this geometry is spatially equal to another geometry. * + * @deprecated Please use `$geometryEngine->equals()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function equals(Geometry $geometry) : bool + public function equals(Geometry $geometry, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->equals($this, $geometry); + return $geometryEngine->equals($this, $geometry); } /** @@ -335,13 +347,15 @@ public function equals(Geometry $geometry) : bool * The geometries are disjoint if they do not share any space together. * This is the opposite of `intersects()`. * + * @deprecated Please use `$geometryEngine->disjoint()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function disjoint(Geometry $geometry) : bool + public function disjoint(Geometry $geometry, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->disjoint($this, $geometry); + return $geometryEngine->disjoint($this, $geometry); } /** @@ -350,13 +364,15 @@ public function disjoint(Geometry $geometry) : bool * The geometries intersect if they share any portion of space. * This is the opposite of `disjoint()`. * + * @deprecated Please use `$geometryEngine->intersects()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function intersects(Geometry $geometry) : bool + public function intersects(Geometry $geometry, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->intersects($this, $geometry); + return $geometryEngine->intersects($this, $geometry); } /** @@ -364,13 +380,15 @@ public function intersects(Geometry $geometry) : bool * * The geometries touch if they have at least one point in common, but their interiors do not intersect. * + * @deprecated Please use `$geometryEngine->touches()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function touches(Geometry $geometry) : bool + public function touches(Geometry $geometry, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->touches($this, $geometry); + return $geometryEngine->touches($this, $geometry); } /** @@ -378,13 +396,15 @@ public function touches(Geometry $geometry) : bool * * The geometries cross if they have some, but not all, interior points in common. * + * @deprecated Please use `$geometryEngine->crosses()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function crosses(Geometry $geometry) : bool + public function crosses(Geometry $geometry, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->crosses($this, $geometry); + return $geometryEngine->crosses($this, $geometry); } /** @@ -392,13 +412,15 @@ public function crosses(Geometry $geometry) : bool * * This is the inverse of `contains()`: `$a->within($b) == $b->contains($a)`. * + * @deprecated Please use `$geometryEngine->within()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function within(Geometry $geometry) : bool + public function within(Geometry $geometry, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->within($this, $geometry); + return $geometryEngine->within($this, $geometry); } /** @@ -406,13 +428,15 @@ public function within(Geometry $geometry) : bool * * This is the inverse of `within()`: `$a->contains($b) == $b->within($a)`. * + * @deprecated Please use `$geometryEngine->contains()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function contains(Geometry $geometry) : bool + public function contains(Geometry $geometry, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->contains($this, $geometry); + return $geometryEngine->contains($this, $geometry); } /** @@ -420,13 +444,15 @@ public function contains(Geometry $geometry) : bool * * The geometries overlap if they share space, but are not completely contained by each other. * + * @deprecated Please use `$geometryEngine->overlaps()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function overlaps(Geometry $geometry) : bool + public function overlaps(Geometry $geometry, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->overlaps($this, $geometry); + return $geometryEngine->overlaps($this, $geometry); } /** @@ -439,37 +465,43 @@ public function overlaps(Geometry $geometry) : bool * * @see http://en.wikipedia.org/wiki/DE-9IM * + * @deprecated Please use `$geometryEngine->relate()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function relate(Geometry $geometry, string $matrix) : bool + public function relate(Geometry $geometry, string $matrix, GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->relate($this, $geometry, $matrix); + return $geometryEngine->relate($this, $geometry, $matrix); } /** * Returns a derived geometry collection value that matches the specified m coordinate value. * + * @deprecated Please use `$geometryEngine->locateAlong()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function locateAlong(float $mValue) : Geometry + public function locateAlong(float $mValue, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->locateAlong($this, $mValue); + return $geometryEngine->locateAlong($this, $mValue); } /** * Returns a derived geometry collection value that matches the specified range of m coordinate values inclusively. * + * @deprecated Please use `$geometryEngine->locateBetween()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function locateBetween(float $mStart, float $mEnd) : Geometry + public function locateBetween(float $mStart, float $mEnd, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->locateBetween($this, $mStart, $mEnd); + return $geometryEngine->locateBetween($this, $mStart, $mEnd); } /** @@ -481,13 +513,15 @@ public function locateBetween(float $mStart, float $mEnd) : Geometry * that the distance between these 2 points is the returned distance * between their geometries. * + * @deprecated Please use `$geometryEngine->distance()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function distance(Geometry $geometry) : float + public function distance(Geometry $geometry, GeometryEngine $geometryEngine) : float { - return GeometryEngineRegistry::get()->distance($this, $geometry); + return $geometryEngine->distance($this, $geometry); } /** @@ -499,13 +533,15 @@ public function distance(Geometry $geometry) : float * some relatively small error in this distance, but it should be near the * resolution of the coordinates used. * + * @deprecated Please use `$geometryEngine->buffer()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function buffer(float $distance) : Geometry + public function buffer(float $distance, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->buffer($this, $distance); + return $geometryEngine->buffer($this, $distance); } /** @@ -515,13 +551,15 @@ public function buffer(float $distance) : Geometry * One can think of the convex hull as the geometry you get by wrapping an elastic band around a set of geometries. * This is different from a concave hull which is analogous to shrink-wrapping your geometries. * + * @deprecated Please use `$geometryEngine->convexHull()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function convexHull() : Geometry + public function convexHull(GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->convexHull($this); + return $geometryEngine->convexHull($this); } /** @@ -529,37 +567,43 @@ public function convexHull() : Geometry * * The intersection is the shared portion of the two geometries. * + * @deprecated Please use `$geometryEngine->intersection()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function intersection(Geometry $geometry) : Geometry + public function intersection(Geometry $geometry, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->intersection($this, $geometry); + return $geometryEngine->intersection($this, $geometry); } /** * Returns a geometry that represents the union of this geometry and another geometry. * + * @deprecated Please use `$geometryEngine->union()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function union(Geometry $geometry) : Geometry + public function union(Geometry $geometry, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->union($this, $geometry); + return $geometryEngine->union($this, $geometry); } /** * Returns a geometry that represents the difference of this geometry and another geometry. * + * @deprecated Please use `$geometryEngine->difference()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function difference(Geometry $geometry) : Geometry + public function difference(Geometry $geometry, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->difference($this, $geometry); + return $geometryEngine->difference($this, $geometry); } /** @@ -568,61 +612,71 @@ public function difference(Geometry $geometry) : Geometry * The result is a geometry that represents the portions of the two geometries that do not intersect. * It is called a symmetric difference because `$a->symDifference($b) == $b->symDifference($a)`. * + * @deprecated Please use `$geometryEngine->symDifference()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function symDifference(Geometry $geometry) : Geometry + public function symDifference(Geometry $geometry, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->symDifference($this, $geometry); + return $geometryEngine->symDifference($this, $geometry); } /** * Snap all points of this geometry to a regular grid. * + * @deprecated Please use `$geometryEngine->snapToGrid()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function snapToGrid(float $size) : Geometry + public function snapToGrid(float $size, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->snapToGrid($this, $size); + return $geometryEngine->snapToGrid($this, $size); } /** * Returns a simplified version of this geometry using the Douglas-Peucker algorithm. * + * @deprecated Please use `$geometryEngine->simplify()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function simplify(float $tolerance) : Geometry + public function simplify(float $tolerance, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->simplify($this, $tolerance); + return $geometryEngine->simplify($this, $tolerance); } /** * Returns the 2-dimensional largest distance between two geometries in projected units. * + * @deprecated Please use `$geometryEngine->maxDistance()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function maxDistance(Geometry $geometry) : float + public function maxDistance(Geometry $geometry, GeometryEngine $geometryEngine) : float { - return GeometryEngineRegistry::get()->maxDistance($this, $geometry); + return $geometryEngine->maxDistance($this, $geometry); } /** * Returns a new geometry with its coordinates transformed to a different spatial reference system. * + * @deprecated Please use `$geometryEngine->transform()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function transform(int $srid) : Geometry + public function transform(int $srid, GeometryEngine $geometryEngine) : Geometry { - return GeometryEngineRegistry::get()->transform($this, $srid); + return $geometryEngine->transform($this, $srid); } /** diff --git a/src/MultiCurve.php b/src/MultiCurve.php index 4caff1f..15c59fc 100644 --- a/src/MultiCurve.php +++ b/src/MultiCurve.php @@ -4,7 +4,7 @@ namespace Brick\Geo; -use Brick\Geo\Engine\GeometryEngineRegistry; +use Brick\Geo\Engine\GeometryEngine; use Brick\Geo\Exception\GeometryEngineException; /** @@ -33,13 +33,15 @@ abstract class MultiCurve extends GeometryCollection * * The MultiCurve is considered closed if each element curve is closed. * + * @deprecated Please use `$geometryEngine->isClosed()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function isClosed() : bool + public function isClosed(GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->isClosed($this); + return $geometryEngine->isClosed($this); } /** @@ -47,12 +49,14 @@ public function isClosed() : bool * * The length is equal to the sum of the lengths of the element Curves. * + * @deprecated Please use `$geometryEngine->length()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function length() : float + public function length(GeometryEngine $geometryEngine) : float { - return GeometryEngineRegistry::get()->length($this); + return $geometryEngine->length($this); } } diff --git a/src/MultiSurface.php b/src/MultiSurface.php index 1430395..85a708d 100644 --- a/src/MultiSurface.php +++ b/src/MultiSurface.php @@ -4,7 +4,7 @@ namespace Brick\Geo; -use Brick\Geo\Engine\GeometryEngineRegistry; +use Brick\Geo\Engine\GeometryEngine; use Brick\Geo\Exception\GeometryEngineException; /** @@ -28,18 +28,22 @@ abstract class MultiSurface extends GeometryCollection /** * Returns the area of this MultiSurface, as measured in the spatial reference system of this MultiSurface. * + * @deprecated Please use `$geometryEngine->area()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function area() : float + public function area(GeometryEngine $geometryEngine) : float { - return GeometryEngineRegistry::get()->area($this); + return $geometryEngine->area($this); } /** * Returns a Point guaranteed to be on this MultiSurface. * + * @deprecated Please use `$geometryEngine->pointOnSurface()`. + * * @noproxy * * @psalm-suppress LessSpecificReturnStatement @@ -47,8 +51,8 @@ public function area() : float * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function pointOnSurface() : Point + public function pointOnSurface(GeometryEngine $geometryEngine) : Point { - return GeometryEngineRegistry::get()->pointOnSurface($this); + return $geometryEngine->pointOnSurface($this); } } diff --git a/src/Point.php b/src/Point.php index eedd3f3..53d4246 100644 --- a/src/Point.php +++ b/src/Point.php @@ -5,7 +5,7 @@ namespace Brick\Geo; use ArrayIterator; -use Brick\Geo\Engine\GeometryEngineRegistry; +use Brick\Geo\Engine\GeometryEngine; use Brick\Geo\Exception\GeometryEngineException; use Brick\Geo\Exception\InvalidGeometryException; @@ -338,6 +338,10 @@ public function getIterator() : ArrayIterator * The azimuth is an angle measured from the north, and is positive clockwise: * North = 0; East = π/2; South = π; West = 3π/2. * + * @deprecated Please use `$geometryEngine->azimuth()`. + * + * @noproxy + * * @param Point $subject Point representing subject of observation. * * @return float Azimuth of the subject relative to the observer. @@ -345,8 +349,8 @@ public function getIterator() : ArrayIterator * @throws GeometryEngineException If the operation is not supported by the engine. * @throws GeometryEngineException If observer and subject locations are coincident. */ - public function azimuth(Point $subject) : float + public function azimuth(Point $subject, GeometryEngine $geometryEngine) : float { - return GeometryEngineRegistry::get()->azimuth($this, $subject); + return $geometryEngine->azimuth($this, $subject); } } diff --git a/src/PolyhedralSurface.php b/src/PolyhedralSurface.php index 69245e4..e946c78 100644 --- a/src/PolyhedralSurface.php +++ b/src/PolyhedralSurface.php @@ -5,7 +5,7 @@ namespace Brick\Geo; use ArrayIterator; -use Brick\Geo\Engine\GeometryEngineRegistry; +use Brick\Geo\Engine\GeometryEngine; use Brick\Geo\Exception\GeometryEngineException; use Brick\Geo\Exception\CoordinateSystemException; use Brick\Geo\Exception\NoSuchGeometryException; @@ -113,6 +113,8 @@ public function patches() : array /** * Returns the collection of polygons in this surface that bounds the given polygon 'p' for any polygon 'p' in the surface. * + * @deprecated Please use `$geometryEngine->boundingPolygons()`. + * * @noproxy * * @psalm-suppress LessSpecificReturnStatement @@ -120,19 +122,21 @@ public function patches() : array * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function boundingPolygons(Polygon $p) : MultiPolygon + public function boundingPolygons(Polygon $p, GeometryEngine $geometryEngine) : MultiPolygon { - return GeometryEngineRegistry::get()->boundingPolygons($p); + return $geometryEngine->boundingPolygons($p); } /** + * @deprecated Please use `$geometryEngine->isClosed()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function isClosed() : bool + public function isClosed(GeometryEngine $geometryEngine) : bool { - return GeometryEngineRegistry::get()->isClosed($this); + return $geometryEngine->isClosed($this); } /** diff --git a/src/Proxy/PointProxy.php b/src/Proxy/PointProxy.php index de20a28..31c0df8 100644 --- a/src/Proxy/PointProxy.php +++ b/src/Proxy/PointProxy.php @@ -231,15 +231,6 @@ public function getIterator() : \ArrayIterator return $this->proxyGeometry->getIterator(); } - public function azimuth(\Brick\Geo\Point $subject) : float - { - if ($this->proxyGeometry === null) { - $this->load(); - } - - return $this->proxyGeometry->azimuth($subject); - } - public function coordinateDimension() : int { if ($this->proxyGeometry === null) { diff --git a/src/Surface.php b/src/Surface.php index 0fc79f8..30380dc 100644 --- a/src/Surface.php +++ b/src/Surface.php @@ -4,7 +4,7 @@ namespace Brick\Geo; -use Brick\Geo\Engine\GeometryEngineRegistry; +use Brick\Geo\Engine\GeometryEngine; use Brick\Geo\Exception\GeometryEngineException; /** @@ -39,18 +39,22 @@ public function dimension() : int /** * Returns the area of this Surface, as measured in the spatial reference system of this Surface. * + * @deprecated Please use `$geometryEngine->area()`. + * * @noproxy * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function area() : float + public function area(GeometryEngine $geometryEngine) : float { - return GeometryEngineRegistry::get()->area($this); + return $geometryEngine->area($this); } /** * Returns a Point guaranteed to be on this Surface. * + * @deprecated Please use `$geometryEngine->pointOnSurface()`. + * * @noproxy * * @psalm-suppress LessSpecificReturnStatement @@ -58,8 +62,8 @@ public function area() : float * * @throws GeometryEngineException If the operation is not supported by the geometry engine. */ - public function pointOnSurface() : Point + public function pointOnSurface(GeometryEngine $geometryEngine) : Point { - return GeometryEngineRegistry::get()->pointOnSurface($this); + return $geometryEngine->pointOnSurface($this); } } diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 07af9c4..cd0d945 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -4,8 +4,8 @@ namespace Brick\Geo\Tests; +use Brick\Geo\Engine\GeometryEngine; use Brick\Geo\Exception\GeometryEngineException; -use Brick\Geo\Engine\GeometryEngineRegistry; use Brick\Geo\Engine\GEOSEngine; use Brick\Geo\Engine\PDOEngine; use Brick\Geo\Engine\SQLite3Engine; @@ -33,16 +33,13 @@ */ class AbstractTestCase extends TestCase { - /** - * Marks the current test as requiring a geometry engine to be set. - * - * If no engine is set, the test will be skipped. - */ - final protected function requiresGeometryEngine() : void + final protected function getGeometryEngine(): GeometryEngine { - if (! GeometryEngineRegistry::has()) { + if (! isset($GLOBALS['GEOMETRY_ENGINE'])) { self::markTestSkipped('This test requires a geometry engine to be set.'); } + + return $GLOBALS['GEOMETRY_ENGINE']; } final protected function isMySQL(?string $operatorAndVersion = null) : bool @@ -65,7 +62,7 @@ final protected function isPostGIS() : bool */ final protected function isSpatiaLite(?string $operatorAndVersion = null) : bool { - $engine = GeometryEngineRegistry::get(); + $engine = $this->getGeometryEngine(); if ($engine instanceof SQLite3Engine) { if ($operatorAndVersion === null) { @@ -85,7 +82,7 @@ final protected function isSpatiaLite(?string $operatorAndVersion = null) : bool */ final protected function isGEOS(?string $operatorAndVersion = null) : bool { - $engine = GeometryEngineRegistry::get(); + $engine = $this->getGeometryEngine(); if ($engine instanceof GEOSEngine) { if ($operatorAndVersion === null) { @@ -221,7 +218,9 @@ final protected function assertGeometryEquals(Geometry $expected, Geometry $actu self::assertSame($expected->geometryType(), $actual->geometryType()); - self::assertTrue($actual->equals($expected), 'Failed asserting that two geometries are spatially equal.' + $geometryEngine = $this->getGeometryEngine(); + + self::assertTrue($geometryEngine->equals($actual, $expected), 'Failed asserting that two geometries are spatially equal.' . "\n---Expected" . "\n+++Actual" . "\n@@ @@" @@ -550,7 +549,7 @@ private function isVersion(string $version, string $operatorAndVersion) : bool private function isPDODriver(string $name) : bool { - $engine = GeometryEngineRegistry::get(); + $engine = $this->getGeometryEngine(); if ($engine instanceof PDOEngine) { if ($engine->getPDO()->getAttribute(\PDO::ATTR_DRIVER_NAME) === $name) { @@ -566,7 +565,7 @@ private function isPDODriver(string $name) : bool */ private function isMySQLorMariaDB(bool $testMariaDB, ?string $operatorAndVersion = null) : bool { - $engine = GeometryEngineRegistry::get(); + $engine = $this->getGeometryEngine(); if ($engine instanceof PDOEngine) { $pdo = $engine->getPDO(); diff --git a/tests/CurveTest.php b/tests/CurveTest.php index 7e346c2..c715f02 100644 --- a/tests/CurveTest.php +++ b/tests/CurveTest.php @@ -20,14 +20,13 @@ class CurveTest extends AbstractTestCase */ public function testLength(string $curve, float $length) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $curve = Curve::fromText($curve); $this->skipIfUnsupportedGeometry($curve); - $actualLength = $curve->length(); + $actualLength = $curve->length($geometryEngine); - self::assertIsFloat($actualLength); self::assertEqualsWithDelta($length, $actualLength, 0.002); } @@ -132,12 +131,12 @@ public function providerEmptyCurve() : array */ public function testIsClosed(string $curve, bool $isClosed) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $curve = Curve::fromText($curve); $this->skipIfUnsupportedGeometry($curve); - self::assertSame($isClosed, $curve->isClosed()); + self::assertSame($isClosed, $curve->isClosed($geometryEngine)); } public function providerIsClosed() : array @@ -171,17 +170,17 @@ public function providerIsClosed() : array */ public function testIsRing(string $curve, bool $isRing) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $curve = Curve::fromText($curve); $this->skipIfUnsupportedGeometry($curve); - if ($curve->isClosed() && $this->isMariaDB('< 10.1.4')) { + if ($curve->isClosed($geometryEngine) && $this->isMariaDB('< 10.1.4')) { // @see https://mariadb.atlassian.net/browse/MDEV-7510 self::markTestSkipped('A bug in MariaDB returns the wrong result.'); } - self::assertSame($isRing, $curve->isRing()); + self::assertSame($isRing, $curve->isRing($geometryEngine)); } public function providerIsRing() : array diff --git a/tests/GeometryTest.php b/tests/GeometryTest.php index dd73dd0..43c2783 100644 --- a/tests/GeometryTest.php +++ b/tests/GeometryTest.php @@ -300,12 +300,12 @@ public function providerSRID() : array */ public function testEnvelope(string $geometry, string $envelope) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry = Geometry::fromText($geometry); $envelope = Geometry::fromText($envelope); - $this->assertGeometryEquals($envelope, $geometry->envelope()); + $this->assertGeometryEquals($envelope, $geometry->envelope($geometryEngine)); } public function providerEnvelope() : array @@ -349,7 +349,7 @@ public function providerIsEmpty() : array */ public function testIsValid(string $geometry, bool $isValid) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isMySQL('< 5.7.6-m16') || $this->isMariaDB('>= 10.0')) { $this->expectException(GeometryEngineException::class); @@ -359,7 +359,7 @@ public function testIsValid(string $geometry, bool $isValid) : void $this->skipIfUnsupportedGeometry($geometry); - self::assertSame($isValid, $geometry->isValid()); + self::assertSame($isValid, $geometry->isValid($geometryEngine)); } public function providerIsValid() : array @@ -382,11 +382,11 @@ public function providerIsValid() : array */ public function testIsSimple(string $geometry, bool $isSimple) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry = Geometry::fromText($geometry); $this->skipIfUnsupportedGeometry($geometry); - self::assertSame($isSimple, $geometry->isSimple()); + self::assertSame($isSimple, $geometry->isSimple($geometryEngine)); } public function providerIsSimple() : array @@ -446,7 +446,7 @@ public function providerDimensionality() : array */ public function testBoundary(string $geometry, string $boundary) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry = Geometry::fromText($geometry); @@ -462,7 +462,7 @@ public function testBoundary(string $geometry, string $boundary) : void $this->expectException(GeometryEngineException::class); } - self::assertSame($boundary, $geometry->boundary()->asText()); + self::assertSame($boundary, $geometry->boundary($geometryEngine)->asText()); } public function providerBoundary() : array @@ -487,13 +487,13 @@ public function providerBoundary() : array */ public function testCentroid(string $geometry, float $centroidX, float $centroidY, array $supportedEngines) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $this->requireEngine($supportedEngines); $geometry = Geometry::fromText($geometry); - $centroid = $geometry->centroid(); + $centroid = $geometry->centroid($geometryEngine); $this->assertEqualsWithDelta($centroidX, $centroid->x(), 0.001); $this->assertEqualsWithDelta($centroidY, $centroid->y(), 0.001); @@ -518,7 +518,7 @@ public function providerCentroid() : array */ public function testEquals(string $geometry1, string $geometry2, bool $equals) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); @@ -526,7 +526,7 @@ public function testEquals(string $geometry1, string $geometry2, bool $equals) : $this->skipIfUnsupportedGeometry($geometry1); $this->skipIfUnsupportedGeometry($geometry2); - self::assertSame($equals, $geometry1->equals($geometry2)); + self::assertSame($equals, $geometry1->equals($geometry2, $geometryEngine)); } public function providerEquals() : array @@ -557,14 +557,14 @@ public function providerEquals() : array */ public function testDisjoint(string $geometry1, string $geometry2, bool $disjoint) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); $this->skipIfUnsupportedByEngine($geometry1, $geometry2, 'disjoint'); - self::assertSame($disjoint, $geometry1->disjoint($geometry2)); + self::assertSame($disjoint, $geometry1->disjoint($geometry2, $geometryEngine)); } public function providerDisjoint() : array @@ -588,14 +588,14 @@ public function providerDisjoint() : array */ public function testIntersects(string $geometry1, string $geometry2, bool $intersects) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); $this->skipIfUnsupportedByEngine($geometry1, $geometry2, 'intersects'); - self::assertSame($intersects, $geometry1->intersects($geometry2)); + self::assertSame($intersects, $geometry1->intersects($geometry2, $geometryEngine)); } public function providerIntersects() : array @@ -619,14 +619,14 @@ public function providerIntersects() : array */ public function testTouches(string $geometry1, string $geometry2, bool $touches) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); $this->skipIfUnsupportedByEngine($geometry1, $geometry2, 'touches'); - self::assertSame($touches, $geometry1->touches($geometry2)); + self::assertSame($touches, $geometry1->touches($geometry2, $geometryEngine)); } public function providerTouches() : array @@ -652,14 +652,14 @@ public function providerTouches() : array */ public function testCrosses(string $geometry1, string $geometry2, bool $crosses) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); $this->skipIfUnsupportedByEngine($geometry1, $geometry2, 'crosses'); - self::assertSame($crosses, $geometry1->crosses($geometry2)); + self::assertSame($crosses, $geometry1->crosses($geometry2, $geometryEngine)); } public function providerCrosses() : array @@ -685,12 +685,12 @@ public function providerCrosses() : array */ public function testWithin(string $geometry1, string $geometry2, bool $within) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); - self::assertSame($within, $geometry1->within($geometry2)); + self::assertSame($within, $geometry1->within($geometry2, $geometryEngine)); } public function providerWithin() : array @@ -713,12 +713,12 @@ public function providerWithin() : array */ public function testContains(string $geometry1, string $geometry2, bool $contains) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); - self::assertSame($contains, $geometry1->contains($geometry2)); + self::assertSame($contains, $geometry1->contains($geometry2, $geometryEngine)); } public function providerContains() : array @@ -741,12 +741,12 @@ public function providerContains() : array */ public function testOverlaps(string $geometry1, string $geometry2, bool $overlaps) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); - self::assertSame($overlaps, $geometry1->overlaps($geometry2)); + self::assertSame($overlaps, $geometry1->overlaps($geometry2, $geometryEngine)); } public function providerOverlaps() : array @@ -767,7 +767,7 @@ public function providerOverlaps() : array */ public function testRelate(string $geometry1, string $geometry2, string $matrix, bool $relate) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isMySQL() || $this->isMariaDB('< 10.1.2')) { $this->expectException(GeometryEngineException::class); @@ -776,7 +776,7 @@ public function testRelate(string $geometry1, string $geometry2, string $matrix, $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); - self::assertSame($relate, $geometry1->relate($geometry2, $matrix)); + self::assertSame($relate, $geometry1->relate($geometry2, $matrix, $geometryEngine)); } public function providerRelate() : array @@ -798,13 +798,13 @@ public function providerRelate() : array */ public function testLocateAlong(string $geometry, float $measure, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isGEOS() || $this->isMySQL() || $this->isMariaDB()) { $this->expectException(GeometryEngineException::class); } - self::assertSame($result, Geometry::fromText($geometry)->locateAlong($measure)->asText()); + self::assertSame($result, Geometry::fromText($geometry)->locateAlong($measure, $geometryEngine)->asText()); } public function providerLocateAlong() : array @@ -825,13 +825,13 @@ public function providerLocateAlong() : array */ public function testLocateBetween(string $geometry, float $mStart, float $mEnd, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isGEOS() || $this->isMySQL() || $this->isMariaDB()) { $this->expectException(GeometryEngineException::class); } - self::assertSame($result, Geometry::fromText($geometry)->locateBetween($mStart, $mEnd)->asText()); + self::assertSame($result, Geometry::fromText($geometry)->locateBetween($mStart, $mEnd, $geometryEngine)->asText()); } public function providerLocateBetween() : array @@ -851,12 +851,12 @@ public function providerLocateBetween() : array */ public function testDistance(string $geometry1, string $geometry2, float $distance) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); - self::assertSame($distance, $geometry1->distance($geometry2)); + self::assertSame($distance, $geometry1->distance($geometry2, $geometryEngine)); } public function providerDistance() : array @@ -875,19 +875,19 @@ public function providerDistance() : array */ public function testBuffer(string $geometry, float $distance) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry = Geometry::fromText($geometry); - $buffer = $geometry->buffer($distance); + $buffer = $geometry->buffer($distance, $geometryEngine); self::assertInstanceOf(Polygon::class, $buffer); - self::assertTrue($buffer->contains($geometry)); + self::assertTrue($buffer->contains($geometry, $geometryEngine)); /** @var Polygon $buffer */ $ring = $buffer->exteriorRing(); for ($n = 1; $n <= $ring->numPoints(); $n++) { - self::assertEqualsWithDelta($distance, $ring->pointN($n)->distance($geometry), 0.001); + self::assertEqualsWithDelta($distance, $ring->pointN($n)->distance($geometry, $geometryEngine), 0.001); } } @@ -908,7 +908,7 @@ public function providerBuffer() : array */ public function testConvexHull(string $geometry, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isMySQL('< 5.7.6-m16') || $this->isMariaDB('< 10.1.2')) { $this->expectException(GeometryEngineException::class); @@ -917,7 +917,7 @@ public function testConvexHull(string $geometry, string $result) : void $geometry = Geometry::fromText($geometry); $result = Geometry::fromText($result); - $this->assertGeometryEquals($result, $geometry->convexHull()); + $this->assertGeometryEquals($result, $geometry->convexHull($geometryEngine)); } public function providerConvexHull() : array @@ -938,7 +938,7 @@ public function providerConvexHull() : array */ public function testIntersection(string $geometry1, string $geometry2, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); @@ -946,7 +946,7 @@ public function testIntersection(string $geometry1, string $geometry2, string $r $this->skipIfUnsupportedByEngine($geometry1, $geometry2, 'intersection'); - $this->assertGeometryEquals($result, $geometry1->intersection($geometry2)); + $this->assertGeometryEquals($result, $geometry1->intersection($geometry2, $geometryEngine)); } public function providerIntersection() : array @@ -966,7 +966,7 @@ public function providerIntersection() : array */ public function testUnion(string $geometry1, string $geometry2, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); @@ -975,7 +975,7 @@ public function testUnion(string $geometry1, string $geometry2, string $result) $this->skipIfUnsupportedGeometry($geometry1); $this->skipIfUnsupportedGeometry($geometry2); - $union = $geometry1->union($geometry2); + $union = $geometry1->union($geometry2, $geometryEngine); if ($union->asText() === $result->asText()) { // GEOS does not consider POINT EMPTY to be equal to another POINT EMPTY; @@ -986,7 +986,7 @@ public function testUnion(string $geometry1, string $geometry2, string $result) } self::assertSame($result->geometryType(), $union->geometryType()); - self::assertTrue($union->equals($result)); + self::assertTrue($union->equals($result, $geometryEngine)); } public function providerUnion() : array @@ -1008,7 +1008,7 @@ public function providerUnion() : array */ public function testDifference(string $geometry1, string $geometry2, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isMySQL('< 5.7')) { self::markTestSkipped('MySQL 5.6 difference() implementation is very buggy and should not be used.'); @@ -1018,7 +1018,7 @@ public function testDifference(string $geometry1, string $geometry2, string $res $geometry2 = Geometry::fromText($geometry2); $result = Geometry::fromText($result); - $difference = $geometry1->difference($geometry2); + $difference = $geometry1->difference($geometry2, $geometryEngine); $this->assertGeometryEquals($result, $difference); } @@ -1039,13 +1039,13 @@ public function providerDifference() : array */ public function testSymDifference(string $geometry1, string $geometry2, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); $result = Geometry::fromText($result); - $difference = $geometry1->symDifference($geometry2); + $difference = $geometry1->symDifference($geometry2, $geometryEngine); $this->assertGeometryEquals($result, $difference); } @@ -1066,7 +1066,7 @@ public function providerSymDifference() : array */ public function testSnapToGrid(string $geometry, float $size, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isGEOS() || $this->isMySQL() || $this->isMariaDB()) { $this->expectException(GeometryEngineException::class); @@ -1075,7 +1075,7 @@ public function testSnapToGrid(string $geometry, float $size, string $result) : $geometry = Geometry::fromText($geometry); $result = Geometry::fromText($result); - $snapToGrid = $geometry->snapToGrid($size); + $snapToGrid = $geometry->snapToGrid($size, $geometryEngine); $this->assertGeometryEquals($result, $snapToGrid); } @@ -1099,7 +1099,7 @@ public function providerSnapToGrid() : array */ public function testSimplify(string$geometry, float $tolerance, string $result) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isMySQL('< 5.7.6-m16') || $this->isMariaDB('>= 10.0') || $this->isSpatiaLite('< 4.1.0')) { $this->expectException(GeometryEngineException::class); @@ -1108,7 +1108,7 @@ public function testSimplify(string$geometry, float $tolerance, string $result) $geometry = Geometry::fromText($geometry); $result = Geometry::fromText($result); - $this->assertGeometryEquals($result, $geometry->simplify($tolerance)); + $this->assertGeometryEquals($result, $geometry->simplify($tolerance, $geometryEngine)); } public function providerSimplify() : array @@ -1128,7 +1128,7 @@ public function providerSimplify() : array */ public function testMaxDistance(string $geometry1, string $geometry2, float $maxDistance) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isGEOS() || $this->isMySQL() || $this->isMariaDB() || $this->isSpatiaLite()) { $this->expectException(GeometryEngineException::class); @@ -1137,7 +1137,7 @@ public function testMaxDistance(string $geometry1, string $geometry2, float $max $geometry1 = Geometry::fromText($geometry1); $geometry2 = Geometry::fromText($geometry2); - self::assertSame($maxDistance, $geometry1->maxDistance($geometry2)); + self::assertSame($maxDistance, $geometry1->maxDistance($geometry2, $geometryEngine)); } public function providerMaxDistance() : array @@ -1154,7 +1154,7 @@ public function providerMaxDistance() : array */ public function testTransform(string $originalWKT, int $originalSRID, int $targetSRID, string $expectedWKT) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isGEOS()) { $this->expectException(GeometryEngineException::class); @@ -1165,7 +1165,7 @@ public function testTransform(string $originalWKT, int $originalSRID, int $targe $originalGeometry = Geometry::fromText($originalWKT, $originalSRID); $expectedGeometry = Geometry::fromText($expectedWKT, $targetSRID); - $transformedGeometry = $originalGeometry->transform($targetSRID); + $transformedGeometry = $originalGeometry->transform($targetSRID, $geometryEngine); $this->assertGeometryEqualsWithDelta($expectedGeometry, $transformedGeometry, 0.0000001); } diff --git a/tests/MultiCurveTest.php b/tests/MultiCurveTest.php index bcbb023..b2fbd3b 100644 --- a/tests/MultiCurveTest.php +++ b/tests/MultiCurveTest.php @@ -64,14 +64,13 @@ public function providerInvalidFromBinary() : array */ public function testLength(string $curve, float $length) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $curve = MultiCurve::fromText($curve); $this->skipIfUnsupportedGeometry($curve); - $actualLength = $curve->length(); + $actualLength = $curve->length($geometryEngine); - self::assertIsFloat($actualLength); self::assertEqualsWithDelta($length, $actualLength, 0.001); } @@ -95,7 +94,7 @@ public function providerLength() : array */ public function testIsClosed(string $curve, bool $isClosed) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $curve = MultiCurve::fromText($curve); $this->skipIfUnsupportedGeometry($curve); @@ -105,7 +104,7 @@ public function testIsClosed(string $curve, bool $isClosed) : void $this->expectException(GeometryEngineException::class); } - self::assertSame($isClosed, $curve->isClosed()); + self::assertSame($isClosed, $curve->isClosed($geometryEngine)); } public function providerIsClosed() : array diff --git a/tests/MultiSurfaceTest.php b/tests/MultiSurfaceTest.php index df8de75..aeaed7b 100644 --- a/tests/MultiSurfaceTest.php +++ b/tests/MultiSurfaceTest.php @@ -65,12 +65,12 @@ public function providerInvalidFromBinary() : array */ public function testArea(string $multiSurface, float $area) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $multiSurface = MultiSurface::fromText($multiSurface); $this->skipIfUnsupportedGeometry($multiSurface); - $actualArea = $multiSurface->area(); + $actualArea = $multiSurface->area($geometryEngine); self::assertEqualsWithDelta($area, $actualArea, 0.001); } @@ -94,11 +94,11 @@ public function providerArea() : array */ public function testCentroid(string $multiMultiSurface, string $centroid) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $multiSurface = MultiSurface::fromText($multiMultiSurface); $this->skipIfUnsupportedGeometry($multiSurface); - $this->assertWktEquals($multiSurface->centroid(), $centroid); + $this->assertWktEquals($multiSurface->centroid($geometryEngine), $centroid); } public function providerCentroid() : array @@ -117,7 +117,7 @@ public function providerCentroid() : array */ public function testPointOnSurface(string $multiMultiSurface) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isMySQL() || $this->isMariaDB('< 10.1.2')) { // MySQL and older MariaDB do not support ST_PointOnSurface() @@ -127,10 +127,10 @@ public function testPointOnSurface(string $multiMultiSurface) : void $multiSurface = MultiSurface::fromText($multiMultiSurface); $this->skipIfUnsupportedGeometry($multiSurface); - $pointOnSurface = $multiSurface->pointOnSurface(); + $pointOnSurface = $multiSurface->pointOnSurface($geometryEngine); self::assertInstanceOf(Point::class, $pointOnSurface); - self::assertTrue($multiSurface->contains($pointOnSurface)); + self::assertTrue($multiSurface->contains($pointOnSurface, $geometryEngine)); } public function providerPointOnSurface() : array diff --git a/tests/PointTest.php b/tests/PointTest.php index cd32fbc..aa54fd4 100644 --- a/tests/PointTest.php +++ b/tests/PointTest.php @@ -188,7 +188,7 @@ public function providerToArrayAndInterfaces() : array */ public function testAzimuth(string $observerWkt, string $subjectWkt, ?float $azimuthExpected): void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if (! $this->isPostGIS()) { $this->expectException(GeometryEngineException::class); @@ -201,7 +201,7 @@ public function testAzimuth(string $observerWkt, string $subjectWkt, ?float $azi $this->expectException(GeometryEngineException::class); } - $azimuthActual = $observer->azimuth($subject); + $azimuthActual = $observer->azimuth($subject, $geometryEngine); self::assertEqualsWithDelta($azimuthExpected, $azimuthActual, 0.001); } diff --git a/tests/SurfaceTest.php b/tests/SurfaceTest.php index 5e4f664..5d861bd 100644 --- a/tests/SurfaceTest.php +++ b/tests/SurfaceTest.php @@ -21,12 +21,12 @@ class SurfaceTest extends AbstractTestCase */ public function testArea(string $surface, float $area) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $surface = Surface::fromText($surface); $this->skipIfUnsupportedGeometry($surface); - $actualArea = $surface->area(); + $actualArea = $surface->area($geometryEngine); self::assertIsFloat($actualArea); self::assertEqualsWithDelta($area, $actualArea, 0.001); @@ -53,11 +53,11 @@ public function providerArea() : array */ public function testCentroid(string $surface, string $centroid) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); $surface = Surface::fromText($surface); $this->skipIfUnsupportedGeometry($surface); - $this->assertWktEquals($surface->centroid(), $centroid); + $this->assertWktEquals($surface->centroid($geometryEngine), $centroid); } public function providerCentroid() : array @@ -77,7 +77,7 @@ public function providerCentroid() : array */ public function testPointOnSurface(string $surface) : void { - $this->requiresGeometryEngine(); + $geometryEngine = $this->getGeometryEngine(); if ($this->isMySQL() || $this->isMariaDB('< 10.1.2')) { // MySQL and older MariaDB do not support ST_PointOnSurface() @@ -87,10 +87,10 @@ public function testPointOnSurface(string $surface) : void $surface = Surface::fromText($surface); $this->skipIfUnsupportedGeometry($surface); - $pointOnSurface = $surface->pointOnSurface(); + $pointOnSurface = $surface->pointOnSurface($geometryEngine); self::assertInstanceOf(Point::class, $pointOnSurface); - self::assertTrue($surface->contains($pointOnSurface)); + self::assertTrue($surface->contains($pointOnSurface, $geometryEngine)); } public function providerPointOnSurface() : array