Lat Lon Distance Calculation query in Oracle

*爱你&永不变心* 提交于 2020-01-11 07:07:20

问题


I have a Oracle 11g DB. I store Latitude and Longitudes (for lets say stores or shops). Now i need a query which will calculate the distance between the shops and my location(which i will provide in the query). I have done this earlier in MySQL, but in Oracle there is no Radians function. So i need work aronud in Oracle SQL.

Help Appreciated. Thank You.


回答1:


Create a function that converts degrees to radians:

CREATE OR REPLACE FUNCTION degree_to_radian(p_degree IN NUMBER)
   RETURN NUMBER IS
BEGIN
   RETURN p_degree / 57.2957795;
END degree_to_radian;



回答2:


or even more precise:

RETURN p_degree /(180/ACOS(-1));


来源:https://stackoverflow.com/questions/20236676/lat-lon-distance-calculation-query-in-oracle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!