All Products
Search
Document Center

ApsaraDB RDS:ST_CurveRecognize

Last Updated:Sep 08, 2023

This topic describes the ST_CurveRecognize function. This function recognizes a curve of a trajectory and the curvature radius.

Syntax

  • Syntax 1

    SETOF trpeak ST_CurveRecognize (trajectory traj, float8 radius_threshold, float8 angle_threshold, float8 angle_compress_threshold default 0);
  • Syntax 2

    SETOF trpeak ST_CurveRecognize (trajectory traj, float8 radius_threshold, float8 angle_threshold, float8 expansion_radius1, float8 expansion_radius2,float8 angle_compress_threshold default 0);

Parameters

Parameter

Description

traj

The original trajectory.

radius_threshold

The curvature radius that is specified to recognize the center point of a curve.

The function recognizes all consecutive points of a curve whose curvature radius is smaller than the value of the radius_threshold parameter, and then selects the point with the smallest curvature radius from these points as the center point of the curve.

angle_threshold

The rotation angle. If the rotation angle of the boundary point on the curve is smaller than the value of this parameter, the boundary point is removed. As a result, the curve is divided into two parts at the removed boundary point. This ensures that the rotation angle of all points on each part of the divided curve is greater than the value of this parameter.

expansion_radius1

The curvature radius of the curve at a point.

expansion_radius2

The average curvature radius of the curve from the specified point to the center point.

angle_compress_threshold

If the rotation angle of the curve at a point is less than the value of this parameter, sampling is not performed. This reduces the sampling density to prevent the curve from being unrecognizable due to excess sampling.

Response parameters:

Parameter

Description

loc

The center point of the curve, which indicates the serial number of the turning point on the trajectory.

For example, if the loc parameter is set to n, the center point of the curve is the (n + 1)th turning point of the trajectory.

height

The curvature radius of the center point on the curve. A positive value indicates a clockwise curvature, and a negative value indicates a counterclockwise curvature.

startloc

The start point of the curve.

endloc

The end point of the curve.

Description

The following list describes the implementation of curve recognition:

  1. The function recognizes all consecutive points of a curve whose curvature radius is smaller than the value of the radius_threshold parameter, and then selects the point with the smallest curvature radius from these points as the center point of the curve.

  2. The function selects the adjacent center points of the curves on the trajectory as the points of a trajectory based on the expansion_radius1 and expansion_radius2 parameters. The selected points must meet the following requirements:

    1. The curvature radius of each point is smaller than the value of the expansion_radius1 parameter.

    2. The average curvature radius of the curve from the specified point to the center point is smaller than the value of the expansion_radius2 parameter.

    Note

    If you do not specify the expansion_radius1 and expansion_radius2 parameters, you can use Syntax 1. In this case, the default settings expansion_radius1 = radius_threshold * 2 and expansion_radius2 = radius_threshold * 4 are used.

  3. The function determines whether to remove the boundary point of the curve based on the value of the angle_threshold parameter. This ensures that the rotation angle of the boundary point on the curve is greater than the value of the angle_threshold parameter. If the rotation angle of the original boundary point on the curve is greater than the specified threshold, the boundary of the curve is expanded towards both sides. If the rotation angle of the original boundary point on the curve is smaller than the specified threshold, the boundary of the curve shrinks towards the interior of the hull.

Examples

SELECT (ST_CurveRecognize('{"trajectory":{"version":1,"type":"STPOINT","leafcount":16,"start_time":"2000-01-01 00:00:00","end_time":"2000-01-16 00:00:00","spatial":"LINESTRING(0 0,1 1,2 2,4 3,3 4,5 7,8 8,7 4,0 0,1 1,2 2,4 3,3 4,5 7,8 8,7 4)","timeline":["2000-01-01 00:00:00","2000-01-02 00:00:00","2000-01-03 00:00:00","2000-01-04 00:00:00","2000-01-05 00:00:00","2000-01-06 00:00:00","2000-01-07 00:00:00","2000-01-08 00:00:00","2000-01-09 00:00:00","2000-01-10 00:00:00","2000-01-11 00:00:00","2000-01-12 00:00:00","2000-01-13 00:00:00","2000-01-14 00:00:00","2000-01-15 00:00:00","2000-01-16 00:00:00"]}}', 15, 1)).*;
 loc |       height        | startloc | endloc
-----+---------------------+----------+--------
   2 |    5.70087712549569 |        2 |      2
   4 |  2.1023796041628637 |        4 |      8
  10 |    5.70087712549569 |       10 |     10
  12 |  2.1023796041628637 |       12 |     15
   3 | -1.1785113019775793 |        3 |      3
  11 | -1.1785113019775793 |       11 |     11
(6 rows)