Pre-General Availability Draft: 2017-07-17
A LineString consists of
Point values. You can extract particular
points of a LineString, count the number of
points that it contains, or obtain its length.
Some functions in this section also work for
MultiLineString values.
Returns the
Pointthat is the endpoint of theLineStringvaluels.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) | +----------------------------------------------+For a
LineStringvaluels,ST_IsClosed()returns 1 iflsis closed (that is, itsST_StartPoint()andST_EndPoint()values are the same).For a
MultiLineStringvaluels,ST_IsClosed()returns 1 iflsis closed (that is, theST_StartPoint()andST_EndPoint()values are the same for eachLineStringinls).ST_IsClosed()returns 0 iflsis not closed, andNULLiflsisNULL.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 | +------------------------------------+Returns a double-precision number indicating the length of the
LineStringorMultiLineStringvaluelsin its associated spatial reference. The length of aMultiLineStringvalue is equal to the sum of the lengths of its elements.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 | +----------------------------------+Returns the number of
Pointobjects in theLineStringvaluels.mysql> SET @ls = 'LineString(1 1,2 2,3 3)'; mysql> SELECT ST_NumPoints(ST_GeomFromText(@ls)); +------------------------------------+ | ST_NumPoints(ST_GeomFromText(@ls)) | +------------------------------------+ | 3 | +------------------------------------+Returns the
N-thPointin theLinestringvaluels. Points are numbered beginning with 1.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) | +----------------------------------------------+Returns the
Pointthat is the start point of theLineStringvaluels.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) | +------------------------------------------------+