我正在尝试使用以下查询获取以米为单位的距离。但每次运行查询时,我都会收到以下错误:
错误的EventException:ORA-01428 ReasonORA-01428:OracleExecutionException:参数'1.00000000000000000000000000000000000001'超出范围
SELECT station,
name,
id,
a.latitude,
a.longitude,
h.latitude as a_latitude,
h.longitude as a_longitude,
(ACOS(COS(0.0174532925*(90-a.latitude))*COS(0.0174532925*(90-h.latitude))+SIN(0.0174532925*(90-a.latitude))*SIN(0.0174532925*(90-h.latitude))*COS(0.0174532925*(a.longitude- h.longitude)))*6371000)Distance_in_metres
FROM
address1 h,
ADDRESSES a
答案 0 :(得分:2)
如前所述,ACOS必须是[-1,1]。 此查询可能有效:
SELECT station,
name,
id,
a.latitude,
a.longitude,
h.latitude as a_latitude,
h.longitude as a_longitude,
ACOS(ROUND(COS(ACOS(-1)/180*(90-a.latitude))*COS(ACOS(-1)/180*(90-h.latitude))+SIN(ACOS(-1)/180*(90-a.latitude))*SIN(ACOS(-1)/180*(90-h.latitude))*COS(ACOS(-1)/180*(a.longitude-h.longitude)), 20)) * 6371000 as Distance_in_metres
FROM
address1 h,
ADDRESSES a
答案 1 :(得分:1)