ST_DISTANCE (Azure Cosmos DB)ST_DISTANCE (Azure Cosmos DB)

返回两个 GeoJSON 点、多边形或 LineString 表达式之间的距离。Returns the distance between the two GeoJSON Point, Polygon, or LineString expressions.

语法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"  
}]  

后续步骤Next steps