Returns the length measurement of the ST_Curve value. The result is measured in the units specified by the unit-name parameter.
curve-expression.ST_Length([ unit-name])
Name | Type | Description |
---|---|---|
unit-name |
VARCHAR(128) |
The units in which the length should be computed. Defaults to the unit of the spatial reference system. The unit name must match the UNIT_NAME column of a row in the ST_UNITS_OF_MEASURE view where UNIT_TYPE is 'LINEAR'. |
DOUBLE If the curve is an empty set, returns NULL. Otherwise, returns the length of the curve in the specified units.
The ST_Length method returns the length of a curve in the units identified by the unit-name parameter. If the curve is empty, then NULL is returned.
If the curve contains Z values, these are not considered when computing the length of the geometry.
If the curve-expression is an empty geometry (ST_IsEmpty()=1), then this method returns NULL.
By default, ST_Length uses the original format for a geometry, if it is available. Otherwise, the internal format is used. For more information about internal and original formats, see STORAGE FORMAT clause, CREATE SPATIAL REFERENCE SYSTEM statement.
SQL/MM (ISO/IEC 13249-3: 2006) 7.1.2
The following example returns the result 2
.
SELECT NEW ST_LineString( 'LineString(1 0, 1 1, 2 1)' ).ST_Length() |
The following example creates a circularstring representing a half-circle and uses ST_Length to find the length of the geometry, returning the value PI.
SELECT NEW ST_CircularString( 'CircularString( 0 0, 1 1, 2 0 )' ).ST_Length() |
The following example creates a linestring representing a path from Halifax, NS
to Waterloo, ON, Canada and uses ST_Length to find the length of the path in metres,
returning the result 1361967.76789
.
SELECT NEW ST_LineString( 'LineString( -63.573566 44.646244, -80.522372 43.465187 )', 4326 ) .ST_Length() |
The following example creates an empty linestring and uses ST_Length to find the length of the geometry. The example returns NULL.
begin declare @curve ST_Curve; set @curve = NEW ST_LineString('LineString EMPTY'); SELECT @curve.ST_Length('metre'); end |
The following example creates a linestring and an example unit of measure (example_unit_halfmetre). The ST_Length method finds the length of the geometry in this unit of measure, returning the value 4.0.
begin declare @curve ST_Curve; CREATE SPATIAL UNIT OF MEASURE IF NOT EXISTS "example_unit_halfmetre" TYPE LINEAR CONVERT USING .5; set @curve = NEW ST_LineString( 'LineString(1 0, 1 1, 2 1)' ) ; SELECT @curve.ST_Length('example_unit_halfmetre'); end |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |