ST_3DDWithin — Tests if two 3D geometries are within a given 3D distance
boolean ST_3DDWithin(geometry
g1, geometry
g2, double precision
distance_of_srid);
Returns true if the 3D distance between two geometry values is no larger than
distance distance_of_srid.
The distance is specified in units defined by the spatial reference system of the geometries.
For this function to make sense
the source geometries must be in the same coordinate system (have the same SRID).
|
|
|
This function automatically includes a bounding box comparison that makes use of any spatial indexes that are available on the geometries. |
This function supports 3d and will not drop the z-index.
This function supports Polyhedral surfaces.
This method implements the SQL/MM specification.
SQL-MM ?
Availability: 2.0.0
Compare the same transformed point and line in both 3D and 2D. The 3D test fails because the Z difference matters even though the 2D footprints are close enough.
WITH sample AS (
SELECT ST_Transform('SRID=4326;POINT(-72.1235 42.3521 4)'::geometry, 2163) AS input_point,
ST_Transform(
'SRID=4326;LINESTRING(-72.1260 42.45 15,-72.123 42.1546 20)'::geometry,
2163
) AS input_line
)
SELECT ST_3DDWithin(input_point, input_line, 126.8) AS within_dist_3d,
ST_DWithin(input_point, input_line, 126.8) AS within_dist_2d,
input_point AS input_point,
input_line AS input_line
FROM sample;
-[ RECORD 1 ]--+---------------------------------------------------------------------------------------------------------------------------------- within_dist_3d | f within_dist_2d | t input_point | POINT Z (-11774128.9 5237160.2 4) input_line | LINESTRING Z (-11774339.5 5243556.8 15,-11773706.7 5215256.3 20)