From 648f7e7659c0a7358e8cf13940b7a155eafbec5a Mon Sep 17 00:00:00 2001 From: Yohann Berthon Date: Mon, 16 Sep 2024 16:39:06 +0200 Subject: [PATCH 1/3] Add support of ST_LineFromEncodedPolyline --- .../MagellanGeometryConstructorFunctions.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Database/PostgisFunctions/MagellanGeometryConstructorFunctions.php b/src/Database/PostgisFunctions/MagellanGeometryConstructorFunctions.php index 1f35d40..5e3833e 100644 --- a/src/Database/PostgisFunctions/MagellanGeometryConstructorFunctions.php +++ b/src/Database/PostgisFunctions/MagellanGeometryConstructorFunctions.php @@ -29,4 +29,15 @@ public static function collect($geometryArrayOrSet): MagellanGeometryExpression { return MagellanBaseExpression::geometry('ST_Collect', [GeoParam::wrap($geometryArrayOrSet)]); } + + /** + * Creates a LineString from an Encoded Polyline string. + * + * + * @see https://postgis.net/docs/ST_LineFromEncodedPolyline.html + */ + public static function lineFromEncodedPolyline(string|Expression|\Closure $polyline, float|Expression|\Closure|null $precision = null): MagellanGeometryExpression + { + return MagellanBaseExpression::geometry('ST_LineFromEncodedPolyline', [$polyline, $precision]); + } } From 0380b3b3be6e49df4284b6d9b770bab0fce439dc Mon Sep 17 00:00:00 2001 From: Yohann Berthon Date: Tue, 17 Sep 2024 09:53:29 +0200 Subject: [PATCH 2/3] Fix Expression type --- .../PostgisFunctions/MagellanGeometryConstructorFunctions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Database/PostgisFunctions/MagellanGeometryConstructorFunctions.php b/src/Database/PostgisFunctions/MagellanGeometryConstructorFunctions.php index 5e3833e..c44a179 100644 --- a/src/Database/PostgisFunctions/MagellanGeometryConstructorFunctions.php +++ b/src/Database/PostgisFunctions/MagellanGeometryConstructorFunctions.php @@ -5,6 +5,7 @@ use Clickbar\Magellan\Database\MagellanExpressions\GeoParam; use Clickbar\Magellan\Database\MagellanExpressions\MagellanBaseExpression; use Clickbar\Magellan\Database\MagellanExpressions\MagellanGeometryExpression; +use Illuminate\Database\Query\Expression; trait MagellanGeometryConstructorFunctions { From 71466551d1e1b299bc2cd29fb622f66d0cc7f524 Mon Sep 17 00:00:00 2001 From: Yohann Berthon Date: Tue, 17 Sep 2024 09:54:27 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1cdd92..234d835 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added +- PostGIS ST_LineFromEncodedPolyline support + ## [1.6.1](https://github.com/clickbar/laravel-magellan/tree/1.6.1) - 2024-08-08 ### Improved