[Oracle]计算地表两点之间的距离

--创建存储过程point_diatance

create or replace procedure point_distance  Authid Current_User is

--定义变量

net1        float;

net2        float;

net3        int;

net4        int;

net5        int;

lata        float;

lona        float;

latb        float;

lonb        float;

net6        float;

net7        float;

net8        float;

net9        float;

net10       float;

net11       float;

net12       float;

net13       float;

begin

for net3 in 1..49

loop --开始循环

for net4 in 1..49

loop

--从aa_point表格中读取经纬度

select latitude into lata from  AA_POINT where point_id = net3;

select longtitude into lona from  AA_POINT where point_id = net3;

select latitude into latb from  AA_POINT where point_id = net4;

select longtitude into lonb from  AA_POINT where point_id = net4;

--开始计算过程--核心公式

net6 := sin(lata);

net7 := sin(latb);

net8 := cos(lona-lonb);

net9 := cos(lata);

net10 := cos(latb);

net11:= net6 * net7 * net8 + net9 * net10;

if net11 >= 1 then net12 := acos(0.999);

else if  net11 <= -1 then net12 := acos(-0.999);

else  net12 := acos(net11);

end if;

end if;

net2 := 6371.004 * net12 * 3.1415926/180;

--net1 := sin(lata)*sin(latb)*cos(lona-lonb)+cos(lata)*cos(latb);

--net2 := 6371.004*acos(net1)*3.1415926/180;

--输出计算结果到aa_distance表格

update aa_distance set point_1=net3,point_2=net4,distance=net2

where id_number = net5;

end loop;

end loop;--结束循环

commit;--提交任务

end  point_distance;

时间: 2024-08-24 20:34:01

[Oracle]计算地表两点之间的距离的相关文章

mysql计算经纬度两点之间的距离(转载)

DELIMITER $$DROP FUNCTION IF EXISTS `fun_distance`$$ CREATE FUNCTION `fun_distance`(lat1 float,lng1 float,lat2 float,lng2 float) RETURNS floatBEGINset @num=2 * 6378137*ASIN(SQRT(POW(SIN(PI()*(lat1-(lat2))/360),2)+ COS(PI()*lat1/180)*COS(lat2*PI()/180

计算openlayers两点之间的距离

distanceTo: function(point) { var distance = 0.0; if ((this.x != null) && (this.y != null) && (point != null) && (point.x != null) && (point.y != null)) { var dx2 = Math.pow(this.x - point.x, 2); var dy2 = Math.pow(this.y -

利用结构类型的相关知识计算两点之间的距离

#include<stdio.h>#include<stdlib.h>#include<math.h> struct point{ /*点的结构类型名*/ float x; /*横坐标*/ float y; /*纵坐标*/ }; struct point readPoint(); /*函数原型声明*/float distance(struct point p1,struct point p2);/*主函数*/ int main(void){ struct point a

2D和3D空间中计算两点之间的距离

自己在做游戏的忘记了Unity帮我们提供计算两点之间的距离,在百度搜索了下. 原来有一个公式自己就写了一个方法O(∩_∩)O~,到僵尸到达某一个点之后就向另一个奔跑过去 /// <summary> /// 3维中如何计算两点之间的距离 /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// &l

openlayer3计算两点之间的距离

openlayer3计算两点之间的距离 对应的openlayers的版本为3.7. 主要用的接口是ol.Sphere.haversineDistance([x1,y1],[x2,y2]): 4326坐标系中计算两点距离的方式为: var wgs84Sphere = new ol.Sphere(6378137); wgs84Sphere.haversineDistance(C1,C2); 示例为: var wgs84Sphere = new ol.Sphere(6378137); wgs84Sph

使用友元函数计算两点之间的距离

#include <iostream> #include <cmath> using namespace std; class CPoint//点类 { private: double x;//横坐标 double y;//纵坐标 public: //使用初始化表初始化数据成员 CPoint(double xx=0,double yy=0):x(xx),y(yy){} //定义友元函数用于计算两点之间的距离 friend double Distance(CPoint &p1

sql server2008根据经纬度计算两点之间的距离

--通过经纬度计算两点之间的距离 create FUNCTION [dbo].[fnGetDistanceNew] --LatBegin 开始经度 --LngBegin 开始维度 --29.490295,106.486654,29.615467, 106.581515 (@LatBegin1 varchar(128), @LngBegin1 varchar(128),@location varchar(128)) Returns real AS BEGIN --转换location字段,防止字段

利用JS实现的根据经纬度计算地球上两点之间的距离

最近用到了根据经纬度计算地球表面两点间距离的公式,然后就用JS实现了一下. 计算地球表面两点间的距离大概有两种办法. 第一种是默认地球是一个光滑的球面,然后计算任意两点间的距离,这个距离叫做大圆距离(The Great Circle Distance). 公式如下: 使用JS来实现为: var EARTH_RADIUS = 6378137.0;    //单位M    var PI = Math.PI;        function getRad(d){        return d*PI/

计算GPS两点间的距离[单位为:米]

/**     * 计算GPS两点间的距离[单位为:米]     * @param center GPS当前数据(LonLat对象表示,LonLat.lon表示经度,LonLat.lat表示纬度)     * @param turnPoint 转向点经纬度对象     * @return     */    private double gpsDistance( LonLat center, LonLat turnPoint )    {        double distance = 0;