我已经在我的表格中添加了一个地理列(MICROSOFT SQL SERVER)并在其中插入了地理点数据(4326)。 现在,我可以使用以下查询计算特定点的所有点的距离:
DECLARE @X geography = geography::Point(0, 0 , 4326);
SELECT TOP(4) *, LOCATION.STDistance(@
FROM [ADDRESS] A
WHERE A.LOCATION IS NOT NULL
ORDER BY LOCATION.STDistance(@X) ASC
它有效。但是我想使用欧几里德距离公式来计算距离:sqrt((y1-y2)^ 2 +(x1-x2)^ 2))并且如果它是x和y位置则希望有两个单独的列可能的。
答案 0 :(得分:2)
谢谢Rup :) 我将类型从地理位置更改为几何,SRID为0!
UPDATE [ADDRESS]
SET LOCATION = geometry::Point(1, 1, 0)
WHERE ADDRESSCODE = 4
DECLARE @X geometry = geometry::Point(0, 0 , 0)
SELECT TOP(4) *, LOCATION.STDistance(@X)
FROM [ADDRESS] A
WHERE LOCATION IS NOT NULL
ORDER BY LOCATION.STDistance(@X) ASC