GeogFromText和Point之间的PostGIS ST_Distance差异

时间:2016-06-11 20:48:26

标签: postgis

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}"

d11326899.86792105d2作为14.142135623731返回。

为什么?谢谢!

1 个答案:

答案 0 :(得分:0)

似乎我必须将ST_Point转换为geography类型,然后才有效。