-
-
Notifications
You must be signed in to change notification settings - Fork 56
feat(#305): add support for PostGIS operators #430
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 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c4b4609
feat(#305): add support for PostGIS operators
martin-georgiev 7356f88
feat(#305): add support for PostGIS operators
martin-georgiev e040f11
no message
martin-georgiev 5a5ea0e
no message
martin-georgiev 1ba0201
no message
martin-georgiev da0b210
no message
martin-georgiev c4fda7b
no message
martin-georgiev 82415dc
Merge branch 'main' into postgis-operators
martin-georgiev 9192d5f
no message
martin-georgiev 001d36c
no message
martin-georgiev ffafedd
no message
martin-georgiev 2195454
no message
martin-georgiev 819f87a
no message
martin-georgiev 3382b7c
no message
martin-georgiev 6e044dc
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
24 changes: 24 additions & 0 deletions
24
fixtures/MartinGeorgiev/Doctrine/Entity/ContainsGeometries.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,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Fixtures\MartinGeorgiev\Doctrine\Entity; | ||
|
|
||
| use Doctrine\ORM\Mapping as ORM; | ||
| use MartinGeorgiev\Doctrine\DBAL\Types\ValueObject\WktSpatialData; | ||
|
|
||
| #[ORM\Entity()] | ||
| class ContainsGeometries extends Entity | ||
| { | ||
| #[ORM\Column(type: 'geometry')] | ||
| public WktSpatialData $geometry1; | ||
|
|
||
| #[ORM\Column(type: 'geometry')] | ||
| public WktSpatialData $geometry2; | ||
|
|
||
| #[ORM\Column(type: 'geography')] | ||
| public WktSpatialData $geography1; | ||
|
|
||
| #[ORM\Column(type: 'geography')] | ||
| public WktSpatialData $geography2; | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BoundingBoxDistance.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,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS 2D bounding box distance operator (using <#>). | ||
| * | ||
| * Returns the 2D distance between A and B bounding boxes. | ||
| * This is useful for index-based distance queries. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Distance | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT BOUNDING_BOX_DISTANCE(g1.geometry, g2.geometry) FROM Entity g1, Entity g2" | ||
| * Returns numeric distance value. | ||
| */ | ||
| class BoundingBoxDistance extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s <#> %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GeometryDistance.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,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS 2D distance between geometries operator (using <->). | ||
| * | ||
| * Returns the 2D distance between A and B geometries. | ||
| * This is different from the existing Distance class which uses <@> for point distance. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Distance | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT GEOMETRY_DISTANCE(g1.geometry, g2.geometry) FROM Entity g1, Entity g2" | ||
| * Returns numeric distance value. | ||
| */ | ||
| class GeometryDistance extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s <-> %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/NDimensionalBoundingBoxDistance.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,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS n-D bounding box distance operator (using <<#>>). | ||
| * | ||
| * Returns the n-D distance between A and B bounding boxes. | ||
| * This operator works with multi-dimensional geometries. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Distance | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ND_BOUNDING_BOX_DISTANCE(g1.geometry, g2.geometry) FROM Entity g1, Entity g2" | ||
| * Returns numeric distance value. | ||
| */ | ||
| class NDimensionalBoundingBoxDistance extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s <<#>> %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/NDimensionalCentroidDistance.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,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS n-D centroid distance operator (using <<->>). | ||
| * | ||
| * Returns the n-D distance between the centroids of A and B bounding boxes. | ||
| * This operator works with multi-dimensional geometries. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Distance | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL: "SELECT ND_CENTROID_DISTANCE(g1.geometry, g2.geometry) FROM Entity g1, Entity g2" | ||
| * Returns numeric distance value. | ||
| */ | ||
| class NDimensionalCentroidDistance extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s <<->> %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/NDimensionalOverlaps.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,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS n-dimensional bounding box intersects operator (using &&&). | ||
| * | ||
| * Returns TRUE if A's n-D bounding box intersects B's n-D bounding box. | ||
| * This operator works with 3D and higher dimensional geometries. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Geometry | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL with boolean comparison: "WHERE ND_OVERLAPS(g1.geometry, g2.geometry) = TRUE" | ||
| * Returns boolean, must be used with "= TRUE" or "= FALSE" in DQL. | ||
| */ | ||
| class NDimensionalOverlaps extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s &&& %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/OverlapsAbove.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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS bounding box overlaps or is above operator (using |&>). | ||
| * | ||
| * Returns TRUE if A's bounding box overlaps or is above B's. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Geometry | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL with boolean comparison: "WHERE OVERLAPS_ABOVE(g1.geometry, g2.geometry) = TRUE" | ||
| * Returns boolean, must be used with "= TRUE" or "= FALSE" in DQL. | ||
| */ | ||
| class OverlapsAbove extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s |&> %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/OverlapsBelow.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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS bounding box overlaps or is below operator (using &<|). | ||
| * | ||
| * Returns TRUE if A's bounding box overlaps or is below B's. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Geometry | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL with boolean comparison: "WHERE OVERLAPS_BELOW(g1.geometry, g2.geometry) = TRUE" | ||
| * Returns boolean, must be used with "= TRUE" or "= FALSE" in DQL. | ||
| */ | ||
| class OverlapsBelow extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s &<| %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/OverlapsLeft.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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS bounding box overlaps or is to the left operator (using &<). | ||
| * | ||
| * Returns TRUE if A's bounding box overlaps or is to the left of B's. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Geometry | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL with boolean comparison: "WHERE OVERLAPS_LEFT(g1.geometry, g2.geometry) = TRUE" | ||
| * Returns boolean, must be used with "= TRUE" or "= FALSE" in DQL. | ||
| */ | ||
| class OverlapsLeft extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s &< %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/OverlapsRight.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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS bounding box overlaps or is to the right operator (using &>). | ||
| * | ||
| * Returns TRUE if A's bounding box overlaps or is to the right of B's. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Geometry | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL with boolean comparison: "WHERE OVERLAPS_RIGHT(g1.geometry, g2.geometry) = TRUE" | ||
| * Returns boolean, must be used with "= TRUE" or "= FALSE" in DQL. | ||
| */ | ||
| class OverlapsRight extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s &> %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/StrictlyAbove.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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS bounding box strictly above operator (using |>>). | ||
| * | ||
| * Returns TRUE if A's bounding box is strictly above B's. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Geometry | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL with boolean comparison: "WHERE STRICTLY_ABOVE(g1.geometry, g2.geometry) = TRUE" | ||
| * Returns boolean, must be used with "= TRUE" or "= FALSE" in DQL. | ||
| */ | ||
| class StrictlyAbove extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s |>> %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/StrictlyBelow.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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS bounding box strictly below operator (using <<|). | ||
| * | ||
| * Returns TRUE if A's bounding box is strictly below B's. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Geometry | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL with boolean comparison: "WHERE STRICTLY_BELOW(g1.geometry, g2.geometry) = TRUE" | ||
| * Returns boolean, must be used with "= TRUE" or "= FALSE" in DQL. | ||
| */ | ||
| class StrictlyBelow extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s <<| %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/StrictlyLeft.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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions; | ||
|
|
||
| /** | ||
| * Implementation of PostGIS bounding box strictly to the left operator (using <<). | ||
| * | ||
| * Returns TRUE if A's bounding box is strictly to the left of B's. | ||
| * | ||
| * @see https://postgis.net/docs/reference.html#Operators_Geometry | ||
| * @since 3.5 | ||
| * | ||
| * @author Martin Georgiev <martin.georgiev@gmail.com> | ||
| * | ||
| * @example Using it in DQL with boolean comparison: "WHERE STRICTLY_LEFT(g1.geometry, g2.geometry) = TRUE" | ||
| * Returns boolean, must be used with "= TRUE" or "= FALSE" in DQL. | ||
| */ | ||
| class StrictlyLeft extends BaseFunction | ||
| { | ||
| protected function customizeFunction(): void | ||
| { | ||
| $this->setFunctionPrototype('(%s << %s)'); | ||
| $this->addNodeMapping('StringPrimary'); | ||
| $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.