我尝试获取(-7.4379722 109.2442663)
和(-7.4201487 109.245204)
的距离两点
我正在使用此查询:
select st_distance(
st_geomfromtext('POINT(-7.4379722 109.2442663)'),
st_geomfromtext('POINT(-7.4201487 109.245204)')
)
并返回查询:
0.0178481493029382 meters
在Google上查找的是2,59 KM
https://i.stack.imgur.com/Rahrb.png
我该怎么办?
答案 0 :(得分:0)
必须先使用经度,然后再使用纬度来表示坐标。
如果使用经纬度几何来计算距离,则输出将以度为单位(这不是距离的理想单位)。相反,您可以使用使用米的地理数据类型
select st_distance(
st_geogfromtext('POINT( 109.2442663 -7.4379722)'),
st_geogfromtext('POINT( 109.245204 -7.4201487)')
);
st_distance
---------------
1973.86761798
(1 row)