ST_DistanceToPoint function

The ST_DistanceToPoint function takes a curve or multi-curve geometry and a point geometry as input parameters and returns the distance along the curve geometry to the specified point.

This function can also be called as a method.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_DistanceToPoint(curve-geometry,point-geometry )

Parameter

curve-geometry
A value of type ST_Curve or ST_MultiCurve or one of its subtypes that represents the geometry to process.
point-geometry
A value of type ST_Point that is a point along the specified curve.

Return type

DOUBLE

Examples

The following SQL statement creates the SAMPLE_GEOMETRIES table with two columns. The ID column uniquely identifies each row. The GEOMETRY ST_LineString column stores sample geometries.
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse 
CREATE TABLE sample_geometries(id INTEGER, geometry ST_LINESTRING)
The following SQL statement inserts two rows into the SAMPLE_GEOMETRIES table.
INSERT INTO sample_geometries(id, geometry)
VALUES
 (1,ST_LineString('LINESTRING ZM(0 0 0 0, 10 100 1000 10000)',1)),
 (2,ST_LineString('LINESTRING ZM(10 100 1000 10000, 0 0 0 0)',1))
The following SELECT statement and the corresponding result set shows how to use the ST_DistanceToPoint function to find the distance to the point at the location (1.5, 15.0).
SELECT ID, 
  DECIMAL(ST_DistanceToPoint(geometry,ST_Point(1.5,15.0,1)),10,5) AS DISTANCE
FROM sample_geometries

ID          DISTANCE    
----------- ------------
          1     15.07481
          2     85.42394

  2 record(s) selected.