ST_NearestPoints function
The ST_NearestPoints function takes a curve or multicurve and a point as input parameters and returns the point on the curve or multicurve that is closest to the point that was specified as input.
If two or more such points are equidistant from the point that was specified as input, they are all returned.
If the curve or multicurve that was specified as input has Z or M coordinates, the Z or M coordinate of the resulting points are computed by interpolation on the specified curve or multicurve.
If the curve or point is empty, then an empty point is returned. If the curve or point that was specified as input is null , then null is returned.
This function can also be called as a method.
Syntax
Parameters
- curve
- A value of type ST_Curve, ST_MultiCurve, or one of their subtypes that represents the curve or multicurve to which the point closest to the point is returned.
- point
- A value of type ST_Point that represents the point from which the nearest point on the curve is to be found.
Return type
db2gse.ST_MultiPoint
Examples
The following examples illustrate the use of the ST_NearestPoint function. The following statements show how to set up the function path to use Spatial Extender functions, create a table, and use the ST_LineString function in the INSERT statement to create the linestring that is used in the examples.SET CURRENT FUNCTION PATH=CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_lines (id INTEGER, line ST_LineString)
INSERT INTO sample_lines (id, line)
VALUES (1, ST_LineString('linestring (0 10, 0 0, 10 0, 10 10)' , 0) )