1
SELECT P.ID, P.LOC,P.GEOM.GET_WKT() WKT FROM MY_TEST P;

id     loc          wkt
----------------------------------------------
1   thalassery  POINT (75.489292 11.753003)
2   pilakool    POINT (75.495129 11.743255)
3   gopalapet   POINT (75.502338 11.736532)
4   mahe        POINT (75.536327 11.700562)
5   vadakara    POINT (75.598297 11.621928)
6   kannur      POINT (75.38475 11.873712)

 SELECT
     C.LOC loc1, 
     D.LOC loc2,
     SDO_GEOM.SDO_DISTANCE(C.GEOM, D.GEOM, .005,'unit=km') AS SDO_DISTANCE
FROM MY_TEST C,
     MY_TEST D
ORDER BY 1, 2;  --which results 18.7476695068002 as the distance between id 1 and id 5

在此处输入图像描述

但是我在使用 sdo_nn 函数时得到了不同的输出:

SELECT 
     C.LOC,
     D.LOC,
     SDO_NN_DISTANCE(1) AS SDO_NN_DISTANCE
FROM MY_TEST C,
     MY_TEST D
WHERE 
 sdo_nn(c.geom, d.geom,1)='TRUE'-- getting only 0 result sets on using 'UNIT=KM' parameter.
ORDER BY 1,2;

在此处输入图像描述

谢谢你的帮助:)

4

1 回答 1

0

您必须指定单位“UNIT=KM”:

SELECT 
     C.LOC,
     D.LOC,
     SDO_NN_DISTANCE(1) AS SDO_NN_DISTANCE
FROM MY_TEST C,
     MY_TEST D
WHERE 
 sdo_nn(c.geom, d.geom,'UNIT=KM',1)='TRUE'
ORDER BY 1,2;
于 2020-11-13T11:40:28.390 回答