ST_LineLocatePoint¶
Returns the location of the closest point on a LineString as a fraction of its total length.
Usage¶
double ST_LineLocatePoint(geomA: geometry, geomB: geometry)
double ST_LineLocatePoint(geogA: geography, geogB: geography)
Arguments¶
- geogA (geography): Input geography
- geogB (geography): Input geography
- geomA (geometry): Input geometry
- geomB (geometry): Input geometry
Description¶
Returns a double between 0 and 1, representing the location of the closest point on the LineString as a fraction of its total 2D length. The first argument must be a LineString. For geometry, the fraction is computed using 2D Cartesian distance. For geography, the fraction is computed based on spherical interpolation between vertices.
Examples¶
SELECT ST_LineLocatePoint(
ST_GeomFromText('LINESTRING (0 0, 0 1)'),
ST_GeomFromText('POINT (0 0.5)')
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_linelocatepoint(st_geomfromtext(Utf8("LINESTRING (0 0, 0 1)")),st_geomfro │
│ mtext(Utf8("POINT (0 0.5)")))… │
╞══════════════════════════════════════════════════════════════════════════════╡
│ 0.5 │
└──────────────────────────────────────────────────────────────────────────────┘
SELECT ST_LineLocatePoint(
ST_GeogFromWKT('LINESTRING (0 0, 1 1, 2 2)'),
ST_GeogFromWKT('POINT (1 1)')
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_linelocatepoint(st_geogfromwkt(Utf8("LINESTRING (0 0, 1 1, 2 2)")),st_geo │
│ gfromwkt(Utf8("POINT (1 1)")))… │
╞══════════════════════════════════════════════════════════════════════════════╡
│ 0.5000380781430777 │
└──────────────────────────────────────────────────────────────────────────────┘