跳到主要内容
版本:Latest-3.2

ST_Distance_Sphere

功能

计算地球两点之间的球面距离,单位是「米」。

语法

ST_Distance_Sphere(x_lng, x_lat, y_lng, y_lat)

参数说明

x_lng: X 点的经度,支持的数据类型为 DOUBLE。

x_lat: X 点的纬度,支持的数据类型为 DOUBLE。

y_lng: Y 点的经度,支持的数据类型为 DOUBLE。

y_lat: Y 点的纬度,支持的数据类型为 DOUBLE。

返回值说明

返回值的数据类型为 DOUBLE。

示例

MySQL > select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219);
+----------------------------------------------------------------------------+
| st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) |
+----------------------------------------------------------------------------+
| 7336.913554999592 |
+----------------------------------------------------------------------------+