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;
谢谢你的帮助:)