ST_ISVALID (Azure Cosmos DB)ST_ISVALID (Azure Cosmos DB)

返回一个布尔值,指示指定的 GeoJSON 点、多边形或 LineString 表达式是否有效。Returns a Boolean value indicating whether the specified GeoJSON Point, Polygon, or LineString expression is valid.

语法Syntax

ST_ISVALID(<spatial_expr>)  

参数Arguments

spatial_exprspatial_expr
是 GeoJSON 点、多边形或 LineString 表达式。Is a GeoJSON Point, Polygon, or LineString expression.

返回类型Return types

返回一个布尔表达式。Returns a Boolean expression.

示例Examples

以下示例介绍了如何使用 ST_VALID 检查点是否有效。The following example shows how to check if a point is valid using ST_VALID.

例如,由于此点具有一个不在有效值范围 [-90,90] 内的纬度值,因此查询返回 false。For example, this point has a latitude value that's not in the valid range of values [-90, 90], so the query returns false.

对于多边形,GeoJSON 规范要求提供的最后一个坐标対应该与第一个坐标对相同,才能创建一个闭合形状。For polygons, the GeoJSON specification requires that the last coordinate pair provided should be the same as the first, to create a closed shape. 多边形内的点必须以逆时针顺序指定。Points within a polygon must be specified in counter-clockwise order. 以顺时针顺序指定的多边形表示其中的区域倒转。A polygon specified in clockwise order represents the inverse of the region within it.

SELECT ST_ISVALID({ "type": "Point", "coordinates": [31.9, -132.8] }) AS b 

下面是结果集:Here is the result set.

[{ "b": false }]  

后续步骤Next steps