Tests whether all points on two 3D geometry objects fall within a specified distance of each other.
Syntax
boolean ST_3DDFullyWithin(geometry g1, geometry g2, double precision distance)Parameters
| Parameter | Type | Description |
|---|---|---|
g1 | geometry | The first geometry object. |
g2 | geometry | The second geometry object. |
distance | double precision | The maximum allowed distance. The unit is determined by the spatial reference system (SRS) of the geometry objects. |
Description
ST_3DDFullyWithin returns true if the 3D distance between every pair of points on g1 and g2 is less than distance. If any two points are farther apart than distance, the function returns false.
Both geometry objects must use the same coordinate projection and have the same spatial reference identifier (SRID). The distance unit is defined by their spatial reference system.
The function automatically uses all available indexes when comparing the bounding boxes of the two geometry objects. It preserves z coordinates and supports polyhedral surfaces.
Example
The following example compares ST_3DDWithin and ST_3DDFullyWithin on the same geometry pair to illustrate the semantic difference. ST_3DDWithin returns true because the closest points on the two line segments are within distance 2. ST_3DDFullyWithin returns false because not all point pairs fall within distance 2.
-- Compare minimum-distance within (ST_3DDWithin) vs. fully-within (ST_3DDFullyWithin)
SELECT
ST_3DDWithin(g1, g2, 2) AS within,
ST_3DDFullyWithin(g1, g2, 2) AS fully_within
FROM (
SELECT
'LINESTRING(0 1 0, 1 1 0)'::geometry AS g1,
'LINESTRING(0 0 0, 0 -1 0)'::geometry AS g2
) AS test;Output:
within | fully_within
--------+--------------
t | f
(1 row)See also
ST_3DDWithin — Returns
trueif the minimum 3D distance between two geometries does not exceed the threshold.