-
-
Notifications
You must be signed in to change notification settings - Fork 56
feat(#305): add support for PostGIS measurement, overlay and geometry processing functions #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1e372dd
feat(#305): add support for PostGIS measurement, overlay and geometry…
martin-georgiev 44f1f7f
no message
martin-georgiev fd81371
no message
martin-georgiev 16258ad
add unit tests
martin-georgiev fc6c285
no message
martin-georgiev 9cfe5f3
Merge branch 'main' into new-postgis-functions-2
martin-georgiev 92b3fa3
no message
martin-georgiev 39e0412
no message
martin-georgiev f3c30f0
integration tests
martin-georgiev 3805780
no message
martin-georgiev f4aa12a
no message
martin-georgiev 13ee267
no message
martin-georgiev 9d2d952
no message
martin-georgiev ce6f90f
no message
martin-georgiev 8a1b637
no message
martin-georgiev dd79042
no message
martin-georgiev 2ceba28
no message
martin-georgiev 99cd11c
no message
martin-georgiev 5a6d3ef
no message
martin-georgiev fef6689
no message
martin-georgiev 2fd901f
no message
martin-georgiev 1167c01
no message
martin-georgiev d35a98b
no message
martin-georgiev 56f2290
no message
martin-georgiev 1fe919e
no message
martin-georgiev c88e421
no message
martin-georgiev c4ce574
no message
martin-georgiev 2d01b14
no message
martin-georgiev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_3DDistance.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_3DDistance() function. | ||
| * | ||
| * Returns the 3D distance between two geometries. | ||
| * For geometry type, the units are in the units of the spatial reference system. | ||
| * | ||
| * @see https://postgis.net/docs/ST_3DDistance.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_3DDISTANCE(g1.geometry, g2.geometry) FROM Entity g1, Entity g2" | ||
| * Returns numeric 3D distance value. | ||
| */ | ||
| class ST_3DDistance extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_3DDistance(%s, %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_3DLength.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_3DLength() function. | ||
| * | ||
| * Returns the 3D length of the geometry if it is a LineString or MultiLineString. | ||
| * For areal geometries, the 3D perimeter is returned. | ||
| * | ||
| * @see https://postgis.net/docs/ST_3DLength.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_3DLENGTH(g.geometry) FROM Entity g" | ||
| * Returns numeric 3D length value. | ||
| */ | ||
| class ST_3DLength extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_3DLength(%s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_3DPerimeter.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_3DPerimeter() function. | ||
| * | ||
| * Returns the 3D perimeter of the geometry if it is a polygon or multi-polygon. | ||
| * For non-areal geometries, 0 is returned. | ||
| * | ||
| * @see https://postgis.net/docs/ST_3DPerimeter.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_3DPERIMETER(g.geometry) FROM Entity g" | ||
| * Returns numeric 3D perimeter value. | ||
| */ | ||
| class ST_3DPerimeter extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_3DPerimeter(%s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_Area.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_Area() function. | ||
| * | ||
| * Returns the area of the geometry if it is a polygon or multi-polygon. | ||
| * For non-areal geometries, 0 is returned. | ||
| * | ||
| * @see https://postgis.net/docs/ST_Area.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_AREA(g.geometry) FROM Entity g" | ||
| * Returns numeric area value. | ||
| */ | ||
| class ST_Area extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_Area(%s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_Azimuth.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_Azimuth() function. | ||
| * | ||
| * Returns the azimuth between two points. | ||
| * Azimuth is the angle in radians from north (0) clockwise. | ||
| * | ||
| * @see https://postgis.net/docs/ST_Azimuth.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_AZIMUTH(g.geometry1, g.geometry2) FROM Entity g" | ||
| * Returns azimuth angle in radians. | ||
| */ | ||
| class ST_Azimuth extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_Azimuth(%s, %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_Boundary.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_Boundary() function. | ||
| * | ||
| * Returns the boundary of a geometry. | ||
| * For point geometries, the boundary is empty. | ||
| * For line geometries, the boundary consists of the endpoints. | ||
| * For polygon geometries, the boundary is the outer ring. | ||
| * | ||
martin-georgiev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @see https://postgis.net/docs/ST_Boundary.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_BOUNDARY(g.geometry) FROM Entity g" | ||
| * Returns geometry representing the boundary. | ||
| */ | ||
| class ST_Boundary extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_Boundary(%s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_Buffer.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_Buffer() function. | ||
| * | ||
| * Returns a geometry that represents all points whose distance from the input geometry | ||
| * is less than or equal to the distance parameter. | ||
| * | ||
| * @see https://postgis.net/docs/ST_Buffer.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_BUFFER(g.geometry, 10) FROM Entity g" | ||
| * Returns buffered geometry. | ||
| */ | ||
| class ST_Buffer extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_Buffer(%s, %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('Literal'); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_Centroid.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_Centroid() function. | ||
| * | ||
| * Returns the geometric center of a geometry. | ||
| * For point geometries, the centroid is the point itself. | ||
| * For line geometries, the centroid is the midpoint. | ||
| * For polygon geometries, the centroid is the center of mass. | ||
| * | ||
| * @see https://postgis.net/docs/ST_Centroid.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_CENTROID(g.geometry) FROM Entity g" | ||
| * Returns point geometry representing the centroid. | ||
| */ | ||
| class ST_Centroid extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_Centroid(%s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_ClipByBox2D.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_ClipByBox2D() function. | ||
| * | ||
| * Clips a geometry by a 2D box. | ||
| * Returns the portion of the input geometry that falls within the specified box. | ||
| * | ||
| * @see https://postgis.net/docs/ST_ClipByBox2D.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_CLIPBYBOX2D(g.geometry, ST_Envelope(g.geometry)) FROM Entity g" | ||
| * Returns clipped geometry. | ||
| */ | ||
| class ST_ClipByBox2D extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_ClipByBox2D(%s, %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_Collect.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_Collect() function. | ||
| * | ||
| * Collects geometries into a geometry collection. | ||
| * Useful for grouping multiple geometries together. | ||
| * | ||
| * @see https://postgis.net/docs/ST_Collect.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_COLLECT(g.geometry1, g.geometry2) FROM Entity g" | ||
| * Returns geometry collection. | ||
| */ | ||
| class ST_Collect extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_Collect(%s, %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_CollectionExtract.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_CollectionExtract() function. | ||
| * | ||
| * Extracts a specific type from a geometry collection. | ||
| * Returns a collection containing only geometries of the specified type. | ||
| * | ||
| * @see https://postgis.net/docs/ST_CollectionExtract.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_COLLECTIONEXTRACT(g.geometry, 1) FROM Entity g" | ||
| * Returns collection with extracted geometry type. | ||
| */ | ||
| class ST_CollectionExtract extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_CollectionExtract(%s, %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('Literal'); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_CollectionHomogenize.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS; | ||
|
|
||
| use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BaseFunction; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS ST_CollectionHomogenize() function. | ||
| * | ||
| * Homogenizes a geometry collection. | ||
| * Returns the simplest representation of the collection. | ||
| * | ||
| * @see https://postgis.net/docs/ST_CollectionHomogenize.html | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ST_COLLECTIONHOMOGENIZE(g.geometry) FROM Entity g" | ||
| * Returns homogenized geometry. | ||
| */ | ||
| class ST_CollectionHomogenize extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('ST_CollectionHomogenize(%s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.