Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
将几何转换为多线串值。
geometry-expression.ST_ToMultiLine()
ST_MultiLineString 如果 geometry-expression 的类型为 ST_MultiLineString,则返回 geometry-expression。如果 geometry-expression 为仅包含线的几何集合,则返回包含 geometry-expression 的元素的多线串对象。如果 geometry-expression 的类型为 ST_LineString,则返回包含一个元素(即 geometry-expression)的多线串值。如果 geometry-expression 为空集,则返回类型为 ST_MultiCurve 的空集。否则,将抛出一个异常条件。
结果的空间参照系标识符与 geometry-expression 的空间参照系标识符相同。
如果已知 geometry-expression 为一个 ST_MultiLineString 值,则使用 TREAT( geometry-expression AS ST_MultiLineString ) 方法要比使用 ST_ToMultiLine 方法更为有效。
缺省情况下,如果几何的原始格式可用,ST_ToMultiLine 将使用该格式。否则使用内部格式。有关内部和原始格式的详细信息,请参见STORAGE FORMAT 子句,CREATE SPATIAL REFERENCE SYSTEM 语句。
SQL/MM (ISO/IEC 13249-3: 2006) 5.1.33
以下示例将返回错误,因为 Shape 列的类型为 ST_Geometry,而 ST_Geometry 不支持 ST_Length 方法。
SELECT Shape.ST_Length() FROM SpatialShapes WHERE ShapeID = 29
以下示例使用 ST_ToMultiLine 将 Shape 列表达式的类型更改为 ST_MultiLineString。此示例同样适用于 Shape 值类型为 ST_LineString 的 ShapeID 5。ST_Length 返回结果 [4.236068]。
4.236068
SELECT Shape.ST_ToMultiLine().ST_Length() FROM SpatialShapes WHERE ShapeID = 29
在此情况下,已知 Shape 列值的类型为 ST_MultiLineString,因此可以使用 TREAT 有效地更改表达式的类型。此示例不适用于 Shape 值类型为 ST_LineString 的 ShapeID 5。ST_Length 返回结果 [4.236068]。
SELECT TREAT( Shape AS ST_MultiLineString ).ST_Length() FROM SpatialShapes WHERE ShapeID = 29