All Products
Search
Document Center

PolarDB:ST_CurvatureRadius

Last Updated:Mar 28, 2026

Returns the rotation radius at each intermediate point of a trajectory as an array of double precision values. A smaller radius indicates a sharper curve; straight-line and stationary segments return Infinity.

Syntax

double precision[] ST_CurvatureRadius(trajectory traj, boolean hasdirection DEFAULT false)

Parameters

ParameterTypeDefaultDescription
trajtrajectoryThe trajectory object.
hasdirectionbooleanfalseSpecifies whether to include the direction of rotation. When true, a counterclockwise turn returns a negative radius. When false (default), all radii are positive.

Return value behavior

For a trajectory with n points, the function evaluates the n − 2 intermediate points (all points except the first and last) and returns one radius value per intermediate point.

Segment typeReturned value
Curved segmentRadius of the curve (positive, or signed if hasdirection is true)
Straight-line segmentInfinity
Stationary point (duplicate coordinate)Infinity

Examples

All examples use ST_MakeTrajectory to construct a trajectory from a WKT LINESTRING, then call ST_CurvatureRadius on the result.

Example 1: One sharp turn and two straight segments

-- 5-point path: sharp left turn at point 2, then two collinear segments
SELECT ST_CurvatureRadius(ST_MakeTrajectory('LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8)'));

Result:

  st_curvatureradius
-----------------------
 {5,Infinity,Infinity}

Point 2 is a 90° turn (radius = 5). Points 3 and 4 are collinear (straight segment → Infinity). Points 4 and 5 are identical (stationary → Infinity).

Example 2: Closed loop with two symmetric turns

-- 8-point closed loop: sharp turn at point 2, straight middle, sharp turn at point 7
SELECT ST_CurvatureRadius(ST_MakeTrajectory('LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0)'));

Result:

            st_curvatureradius
-------------------------------------------
 {5,Infinity,Infinity,Infinity,Infinity,5}

Points 3–5 are collinear (straight middle segment → Infinity). The two turns at points 2 and 7 are symmetric (radius = 5 each).

Example 3: Same loop with signed direction

-- hasdirection=true: counterclockwise turn returns a negative radius
SELECT ST_CurvatureRadius(ST_MakeTrajectory('LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0)'), true);

Result:

             st_curvatureradius
--------------------------------------------
 {5,Infinity,Infinity,Infinity,Infinity,-5}

With hasdirection=true, a counterclockwise turn returns a negative radius. The last turn (point 7) returns −5.

Example 4: Extended loop with an additional curved segment

-- 10-point path: two original turns plus a short curved tail
SELECT ST_CurvatureRadius(ST_MakeTrajectory('LINESTRING(0 0, 0 8, 6 8, 12 8, 12 8, 6 8, 0 8, 0 0, 0 4, 3 4)'), true);

Result:

                st_curvatureradius
--------------------------------------------------
 {5,Infinity,Infinity,Infinity,Infinity,-5,0,2.5}

Usage notes

  • The returned array has exactly n − 2 elements, where n is the number of points in the trajectory.

  • The smaller the rotation radius, the sharper the curve.