Oracle计算高德地图两点间距离

2021/4/12 19:27:01

本文主要是介绍Oracle计算高德地图两点间距离,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

入参:经度,纬度,机构id

create or replace function F_GET_POD(latb  in float,
                                     lonb  in float,
                                     prm_orgid in number) return float is
  Result float;
  net2   float;
  lata float;
  lona float;
  d2  float;
  d3  float;
  d4  float;
  d5  float;
  d6  float;
  d7  float;
  d8  float;
  d9  float;
  d10 float;
  d11 float;
  d12 float;
  d13 float;
  d14 float;
  array10 float;
  array11 float;
  array12 float;
  array20 float;
  array21 float;
  array22 float;
begin
  select substr(DTZB, 1, INSTR(DTZB, ',', 1) - 1) into lata from  TAORG_EXTEND where ORGID=prm_orgid;
        select substr(DTZB, INSTR(DTZB, ',', 1) + 1) into lona from  TAORG_EXTEND where ORGID=prm_orgid;
        --开始计算过程--核心公式
        d2 := lata * 0.01745329251994329;
        d3 := lona * 0.01745329251994329;
        d4 := latb * 0.01745329251994329;
        d5 := lonb * 0.01745329251994329;
        d6  := sin(d2);
        d7  := sin(d3);
        d8  := cos(d2);
        d9  := cos(d3);
        d10 := sin(d4);
        d11 := sin(d5);
        d12 := cos(d4);
        d13 := cos(d5);
        array10 := (d9 * d8);
        array11 := (d9 * d6);
        array12 :=  d7;
        array20 := (d13 * d12);
        array21 := (d13 * d10);
        array22 :=  d11;
        d14 := sqrt((array10 - array20) * (array10 - array20)
             + (array11 - array21) * (array11 - array21)
             + (array12 - array22) * (array12 - array22));
        net2 := asin(d14 / 2.0) * 12742001.579854401
        if net2<1000 then
          Result:=net2;
        else
          Result:=net2/1000;
  return(Result);
end F_GET_POD;
--注:函数可以在sql查询中直接输出,select F_GET_POD(latb,lonb,prm_orgid) from biao where tiaojian;


这篇关于Oracle计算高德地图两点间距离的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程