ST_DISTANCE (Azure Cosmos DB)ST_DISTANCE (Azure Cosmos DB)
适用于:
SQL API
返回两个 GeoJSON Point、Polygon、MultiPolygon 或 LineString 表达式之间的距离。Returns the distance between the two GeoJSON Point, Polygon, MultiPolygon or LineString expressions. 若要了解详细信息,请参阅地理空间和 GeoJSON 位置数据一文。To learn more, see the Geospatial and GeoJSON location data article.
语法Syntax
ST_DISTANCE (<spatial_expr>, <spatial_expr>)
参数Arguments
spatial_exprspatial_expr
是任何有效的 GeoJSON 点、多边形或 LineString 对象表达式。Is any valid GeoJSON Point, Polygon, or LineString object expression.
返回类型Return types
返回包含距离的一个数字表达式。Returns a numeric expression containing the distance. 这是根据默认参考系统以米为单位表示的。This is expressed in meters for the default reference system.
示例Examples
以下示例演示了如何使用 ST_DISTANCE
内置函数返回与指定位置的距离在 30 公里内的所有家族文档。The following example shows how to return all family documents that are within 30 km of the specified location using the ST_DISTANCE
built-in function. 上获取。.
SELECT f.id
FROM Families f
WHERE ST_DISTANCE(f.location, {'type': 'Point', 'coordinates':[31.9, -4.8]}) < 30000
下面是结果集。Here is the result set.
[{
"id": "WakefieldFamily"
}]
备注Remarks
此系统函数将从地理空间索引中获益。This system function will benefit from a geospatial index.