Documentation Home
MySQL 8.0 参考手册  / 第 12 章函数和运算符  / 12.17空间分析函数  / 12.17.7 几何属性函数  /  12.17.7.3 LineString 和 MultiLineString 属性函数

12.17.7.3 LineString 和 MultiLineString 属性函数

ALineStringPoint值组成。您可以提取 a 的特定点LineString,计算它包含的点数,或获取它的长度。

本节中的一些函数也适用于 MultiLineString值。

  • EndPoint(ls)

    ST_EndPoint()并且 EndPoint()是同义词。有关详细信息,请参阅 的说明 ST_EndPoint()

    EndPoint()已弃用;希望在未来的 MySQL 版本中将其删除。改用 ST_EndPoint()

  • GLength(ls)

    GLength()是一个非标准名称。对应OpenGIS ST_Length()功能。(有一个现有的 SQL 函数 Length()可以计算字符串值的长度。)

    GLength()已弃用;希望在未来的 MySQL 版本中将其删除。改用 ST_Length()

  • IsClosed(ls)

    ST_IsClosed()并且 IsClosed()是同义词。有关详细信息,请参阅 的说明 ST_IsClosed()

    IsClosed()已弃用;希望在未来的 MySQL 版本中将其删除。改用 ST_IsClosed()

  • NumPoints(ls)

    ST_NumPoints()并且 NumPoints()是同义词。有关详细信息,请参阅 的说明 ST_NumPoints()

    NumPoints()已弃用;希望在未来的 MySQL 版本中将其删除。改用 ST_NumPoints()

  • PointN(ls, N)

    ST_PointN()并且 PointN()是同义词。有关详细信息,请参阅 的说明 ST_PointN()

    PointN()已弃用;希望在未来的 MySQL 版本中将其删除。改用 ST_PointN()

  • ST_EndPoint(ls)

    返回值 Point的端点。如果参数是 或 空几何,则返回值为。 LineStringlsNULLNULL

    mysql> SET @ls = 'LineString(1 1,2 2,3 3)';
    mysql> SELECT ST_AsText(ST_EndPoint(ST_GeomFromText(@ls)));
    +----------------------------------------------+
    | ST_AsText(ST_EndPoint(ST_GeomFromText(@ls))) |
    +----------------------------------------------+
    | POINT(3 3)                                   |
    +----------------------------------------------+

    ST_EndPoint()并且 EndPoint()是同义词。

  • ST_IsClosed(ls)

    对于LineStringvalue lsST_IsClosed()如果闭合则返回 1 ls(即它 ST_StartPoint()ST_EndPoint()值相同)。如果参数是NULL或 空几何,则返回值为NULL

    对于MultiLineStringvalue lsST_IsClosed()如果关闭则返回 1 ls(也就是说, 对于每个in , theST_StartPoint()和 的ST_EndPoint()值都相同)。 LineStringls

    ST_IsClosed()ls如果未关闭 则返回 0 。

    mysql> SET @ls1 = 'LineString(1 1,2 2,3 3,2 2)';
    mysql> SET @ls2 = 'LineString(1 1,2 2,3 3,1 1)';
    
    mysql> SELECT ST_IsClosed(ST_GeomFromText(@ls1));
    +------------------------------------+
    | ST_IsClosed(ST_GeomFromText(@ls1)) |
    +------------------------------------+
    |                                  0 |
    +------------------------------------+
    
    mysql> SELECT ST_IsClosed(ST_GeomFromText(@ls2));
    +------------------------------------+
    | ST_IsClosed(ST_GeomFromText(@ls2)) |
    +------------------------------------+
    |                                  1 |
    +------------------------------------+
    
    mysql> SET @ls3 = 'MultiLineString((1 1,2 2,3 3),(4 4,5 5))';
    
    mysql> SELECT ST_IsClosed(ST_GeomFromText(@ls3));
    +------------------------------------+
    | ST_IsClosed(ST_GeomFromText(@ls3)) |
    +------------------------------------+
    |                                  0 |
    +------------------------------------+

    ST_IsClosed()并且 IsClosed()是同义词。

  • ST_Length(ls)

    Returns a double-precision number indicating the length of the LineString or MultiLineString value ls in its associated spatial reference system. The length of a MultiLineString value is equal to the sum of the lengths of its elements. If the argument is NULL or an empty geometry, the return value is NULL.

    mysql> SET @ls = 'LineString(1 1,2 2,3 3)';
    mysql> SELECT ST_Length(ST_GeomFromText(@ls));
    +---------------------------------+
    | ST_Length(ST_GeomFromText(@ls)) |
    +---------------------------------+
    |              2.8284271247461903 |
    +---------------------------------+
    
    mysql> SET @mls = 'MultiLineString((1 1,2 2,3 3),(4 4,5 5))';
    mysql> SELECT ST_Length(ST_GeomFromText(@mls));
    +----------------------------------+
    | ST_Length(ST_GeomFromText(@mls)) |
    +----------------------------------+
    |                4.242640687119286 |
    +----------------------------------+

    ST_Length() should be used in preference to GLength(), which has a nonstandard name.

  • ST_NumPoints(ls)

    Returns the number of Point objects in the LineString value ls. If the argument is NULL or an empty geometry, the return value is NULL.

    mysql> SET @ls = 'LineString(1 1,2 2,3 3)';
    mysql> SELECT ST_NumPoints(ST_GeomFromText(@ls));
    +------------------------------------+
    | ST_NumPoints(ST_GeomFromText(@ls)) |
    +------------------------------------+
    |                                  3 |
    +------------------------------------+

    ST_NumPoints() and NumPoints() are synonyms.

  • ST_PointN(ls, N)

    Returns the N-th Point in the Linestring value ls. Points are numbered beginning with 1. If any argument is NULL or the geometry argument is an empty geometry, the return value is NULL.

    mysql> SET @ls = 'LineString(1 1,2 2,3 3)';
    mysql> SELECT ST_AsText(ST_PointN(ST_GeomFromText(@ls),2));
    +----------------------------------------------+
    | ST_AsText(ST_PointN(ST_GeomFromText(@ls),2)) |
    +----------------------------------------------+
    | POINT(2 2)                                   |
    +----------------------------------------------+

    ST_PointN() and PointN() are synonyms.

  • ST_StartPoint(ls)

    Returns the Point that is the start point of the LineString value ls. If the argument is NULL or an empty geometry, the return value is NULL.

    mysql> SET @ls = 'LineString(1 1,2 2,3 3)';
    mysql> SELECT ST_AsText(ST_StartPoint(ST_GeomFromText(@ls)));
    +------------------------------------------------+
    | ST_AsText(ST_StartPoint(ST_GeomFromText(@ls))) |
    +------------------------------------------------+
    | POINT(1 1)                                     |
    +------------------------------------------------+

    ST_StartPoint() and StartPoint() are synonyms.

  • StartPoint(ls)

    ST_StartPoint() and StartPoint() are synonyms. For more information, see the description of ST_StartPoint().

    StartPoint() is deprecated; expect it to be removed in a future MySQL release. Use ST_StartPoint() instead.