You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md
+76-19Lines changed: 76 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@
16
16
-**Arrays/JSON**: Use `CONTAINS`, `IS_CONTAINED_BY`, `OVERLAPS` for array and JSON operations
17
17
-**Spatial**: Use `SPATIAL_CONTAINS`, `SPATIAL_CONTAINED_BY` for explicit spatial bounding box operations
18
18
-**Text**: Use `REGEXP`, `IREGEXP` for pattern matching
19
-
-**Boolean operators**: All spatial operators return boolean values and **shall be used with `= TRUE` or `= FALSE` in DQL**
19
+
-**Boolean operators**: All spatial operators return boolean values and **should be used with `= TRUE` or `= FALSE` in DQL**
20
20
21
21
## General Operators
22
22
@@ -60,22 +60,22 @@
60
60
61
61
### Bounding Box Operators
62
62
63
-
These operators work with geometry and geography bounding boxes. All return boolean values and **shall be used with `= TRUE` or `= FALSE` in DQL**.
63
+
These operators work with geometry and geography bounding boxes. All return boolean values and **should be used with `= TRUE` or `= FALSE` in DQL**.
64
64
65
65
| PostgreSQL operator | Register for DQL as | Description | Implemented by |
66
66
|---|---|---|---|
67
-
| &< | OVERLAPS_LEFT | Returns TRUE if A's bounding box overlaps or is to the left of B's |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\OverlapsLeft`|
68
-
| &> | OVERLAPS_RIGHT | Returns TRUE if A's bounding box overlaps or is to the right of B's |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\OverlapsRight`|
69
-
| << | STRICTLY_LEFT | Returns TRUE if A's bounding box is strictly to the left of B's |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\StrictlyLeft`|
70
-
| >> | STRICTLY_RIGHT | Returns TRUE if A's bounding box is strictly to the right of B's |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\StrictlyRight`|
71
-
| @ | SPATIAL_CONTAINED_BY | Returns TRUE if A's bounding box is contained by B's (**spatial version**) |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\SpatialContainedBy`|
| &< | OVERLAPS_LEFT | Returns TRUE if A's bounding box overlaps or is to the left of B's |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\OverlapsLeft`|
68
+
| &> | OVERLAPS_RIGHT | Returns TRUE if A's bounding box overlaps or is to the right of B's |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\OverlapsRight`|
69
+
| << | STRICTLY_LEFT | Returns TRUE if A's bounding box is strictly to the left of B's |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\StrictlyLeft`|
70
+
| >> | STRICTLY_RIGHT | Returns TRUE if A's bounding box is strictly to the right of B's |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\StrictlyRight`|
71
+
| @ | SPATIAL_CONTAINED_BY | Returns TRUE if A's bounding box is contained by B's (**spatial version**) |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\SpatialContainedBy`|
@@ -95,12 +95,12 @@ These operators calculate distances between geometries. All return numeric value
95
95
96
96
| PostgreSQL operator | Register for DQL as | Description | Implemented by |
97
97
|---|---|---|---|
98
-
| <-> | GEOMETRY_DISTANCE | Returns the 2D distance between A and B geometries |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\GeometryDistance`|
98
+
| <-> | GEOMETRY_DISTANCE | Returns the 2D distance between A and B geometries |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\GeometryDistance`|
|\|=\|| TRAJECTORY_DISTANCE | Returns distance between trajectories at closest point of approach |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TrajectoryDistance`|
101
-
| <#> | BOUNDING_BOX_DISTANCE | Returns the 2D distance between A and B bounding boxes |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\BoundingBoxDistance`|
102
-
| <<->> | ND_CENTROID_DISTANCE | Returns n-D distance between centroids of bounding boxes |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\NDimensionalCentroidDistance`|
103
-
| <<#>> | ND_BOUNDING_BOX_DISTANCE | Returns the n-D distance between A and B bounding boxes |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\NDimensionalBoundingBoxDistance`|
100
+
|\|=\|| TRAJECTORY_DISTANCE | Returns distance between trajectories at closest point of approach |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\TrajectoryDistance`|
101
+
| <#> | BOUNDING_BOX_DISTANCE | Returns the 2D distance between A and B bounding boxes |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\BoundingBoxDistance`|
102
+
| <<->> | ND_CENTROID_DISTANCE | Returns n-D distance between centroids of bounding boxes |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\NDimensionalCentroidDistance`|
103
+
| <<#>> | ND_BOUNDING_BOX_DISTANCE | Returns the n-D distance between A and B bounding boxes |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\NDimensionalBoundingBoxDistance`|
104
104
105
105
**Usage Examples:**
106
106
```sql
@@ -224,6 +224,63 @@ SELECT ND_CENTROID_DISTANCE(e.geometry3d1, e.geometry3d2) as distance FROM Entit
These functions determine spatial relationships between geometries. Most return boolean values and **should be used with `= TRUE` or `= FALSE` in DQL**, but there are exceptions: `ST_Relate(geom, geom)` returns text (intersection matrix) and `ST_LineCrossingDirection` returns integer (crossing behavior).
230
+
231
+
| PostgreSQL functions | Register for DQL as | Description | Implemented by |
232
+
|---|---|---|---|
233
+
| ST_3DDWithin | ST_3DDWITHIN | Tests if two 3D geometries are within a given 3D distance |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_3DDWithin`|
234
+
| ST_3DDFullyWithin | ST_3DDFULLYWITHIN | Tests if two 3D geometries are entirely within a given 3D distance |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_3DDFullyWithin`|
235
+
| ST_3DIntersects | ST_3DINTERSECTS | Tests if two geometries spatially intersect in 3D |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_3DIntersects`|
236
+
| ST_Contains | ST_CONTAINS | Tests if every point of B lies in A, and their interiors have a point in common |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Contains`|
237
+
| ST_ContainsProperly | ST_CONTAINSPROPERLY | Tests if every point of B lies in the interior of A |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_ContainsProperly`|
238
+
| ST_CoveredBy | ST_COVEREDBY | Tests if every point of A lies in B |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_CoveredBy`|
239
+
| ST_Covers | ST_COVERS | Tests if every point of B lies in A |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Covers`|
240
+
| ST_Crosses | ST_CROSSES | Tests if two geometries have some, but not all, interior points in common |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Crosses`|
241
+
| ST_DFullyWithin | ST_DFULLYWITHIN | Tests if a geometry is entirely inside a distance of another |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_DFullyWithin`|
242
+
| ST_Disjoint | ST_DISJOINT | Tests if two geometries have no points in common |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Disjoint`|
243
+
| ST_DWithin | ST_DWITHIN | Tests if two geometries are within a given distance |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_DWithin`|
244
+
| ST_Equals | ST_EQUALS | Tests if two geometries include the same set of points |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Equals`|
245
+
| ST_Intersects | ST_INTERSECTS | Tests if two geometries intersect (they have at least one point in common) |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Intersects`|
246
+
| ST_LineCrossingDirection | ST_LINECROSSINGDIRECTION | Returns a number indicating the crossing behavior of two LineStrings |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_LineCrossingDirection`|
247
+
| ST_OrderingEquals | ST_ORDERINGEQUALS | Tests if two geometries represent the same geometry and have points in the same directional order |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_OrderingEquals`|
248
+
| ST_Overlaps | ST_OVERLAPS | Tests if two geometries have the same dimension and intersect, but each has at least one point not in the other |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Overlaps`|
249
+
| ST_PointInsideCircle | ST_POINTINSIDECIRCLE | Tests if a point geometry is inside a circle defined by a center and radius |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_PointInsideCircle`|
250
+
| ST_Relate | ST_RELATE | Tests if two geometries have a topological relationship matching an Intersection Matrix pattern, or computes their Intersection Matrix |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Relate`|
251
+
| ST_RelateMatch | ST_RELATEMATCH | Tests if a DE-9IM Intersection Matrix matches an Intersection Matrix pattern |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_RelateMatch`|
252
+
| ST_Touches | ST_TOUCHES | Tests if two geometries have at least one point in common, but their interiors do not intersect |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Touches`|
253
+
| ST_Within | ST_WITHIN | Tests if every point of A lies in B, and their interiors have a point in common |`MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS\ST_Within`|
254
+
255
+
**Usage Examples:**
256
+
```sql
257
+
-- Test if geometries intersect
258
+
SELECT e FROM Entity e WHERE ST_Intersects(e.geometry, 'POINT(0 0)') = TRUE
259
+
260
+
-- Test if one geometry contains another
261
+
SELECT e FROM Entity e WHERE ST_Contains(e.polygon, e.point) = TRUE
262
+
263
+
-- Test if geometries are within a distance
264
+
SELECT e FROM Entity e WHERE ST_DWithin(e.geometry, 'POINT(0 0)', 1000) = TRUE
265
+
266
+
-- Test topological relationships with intersection matrix
267
+
SELECT e FROM Entity e WHERE ST_Relate(e.geometry1, e.geometry2, 'T*T***T**') = TRUE
268
+
269
+
-- Test if point is inside circle
270
+
SELECT e FROM Entity e WHERE ST_PointInsideCircle(e.point, 0, 0, 1000) = TRUE
271
+
```
272
+
273
+
**📝 Notes:**
274
+
-`ST_Relate` is a variadic function that accepts 2 or 3 arguments:
275
+
- With 2 arguments: returns text (intersection matrix)
276
+
- With 3 arguments: returns boolean (relationship test)
277
+
-`ST_LineCrossingDirection` returns an integer (0, 1, -1, or 2) indicating crossing behavior:
278
+
-`0`: No crossing
279
+
-`1`: Left to right crossing
280
+
-`-1`: Right to left crossing
281
+
-`2`: Multiple crossings
282
+
- All other functions return boolean values and should be used with `= TRUE` or `= FALSE` in DQL
0 commit comments