SELECT t.coords, t2.coords,
ST_Distance(ST_GeogFromText('SRID=4326;POINT(-115.83225 44.18711)'), ST_GeogFromText('SRID=4326;POINT(-105.83225 54.18711)')) AS d1,
ST_Distance(ST_Point(t.coords[2], t.coords[1]), ST_Point(t2.coords[2], t2.coords[1])) AS d2
FROM locations
INNER JOIN locations t2 ON t2.id = 1
WHERE t.id = 2;
t.coords = "{44.18711,-115.83225}"
和t2.coords = "{54.18711,-105.83225}"
d1
以1326899.86792105
和d2
作为14.142135623731
返回。
为什么?谢谢!
答案 0 :(得分:0)
似乎我必须将ST_Point
转换为geography
类型,然后才有效。