今天给大家分享计算地球上两个坐标点之间里程不同数据库版本的脚本。
1、SQLServer脚本
- –-计算地球上两个坐标点(经度,纬度)之间距离sql函数
- CREATE FUNCTION [dbo].[fnGetDistance](@LatBegin REAL, @LngBegin REAL,
- @LatEnd REAL, @LngEnd REAL)
- RETURNS FLOAT
- AS
- BEGIN
- –-距离(千米)
- DECLARE @Distance REAL
- DECLARE @EARTH_RADIUS REAL
- SET @EARTH_RADIUS = 6378.137
- DECLARE @RadLatBegin REAL,@RadLatEnd REAL,@RadLatDiff REAL,@RadLngDiff REAL
- SET @RadLatBegin = @LatBegin *PI()/180.0
- SET @RadLatEnd = @LatEnd *PI()/180.0
- SET @RadLatDiff = @RadLatBegin - @RadLatEnd
- SET @RadLngDiff = @LngBegin *PI()/180.0 - @LngEnd *PI()/180.0
- SET @Distance = 2 *ASIN(SQRT(POWER(SIN(@RadLatDiff/2), 2)
- +COS(@RadLatBegin)*COS(@RadLatEnd)*POWER(SIN(@RadLngDiff/2), 2)))
- SET @Distance = @Distance * @EARTH_RADIUS
- RETURN @Distance
- END
- --使用方法如下:
- SELECT dbo.fnGetDistance(25,30,12.56,15.5) ;
2、MySQl脚本
- –-计算地球上两个坐标点(经度,纬度)之间距离sql函数
- CREATE FUNCTION [dbo].[fnGetDistance](@LatBegin REAL, @LngBegin REAL,
- @LatEnd REAL, @LngEnd REAL)
- RETURNS FLOAT
- AS
- BEGIN
- –-距离(千米)
- DECLARE @Distance REAL
- DECLARE @EARTH_RADIUS REAL
- SET @EARTH_RADIUS = 6378.137
- DECLARE @RadLatBegin REAL,@RadLatEnd REAL,@RadLatDiff REAL,@RadLngDiff REAL
- SET @RadLatBegin = @LatBegin *PI()/180.0
- SET @RadLatEnd = @LatEnd *PI()/180.0
- SET @RadLatDiff = @RadLatBegin - @RadLatEnd
- SET @RadLngDiff = @LngBegin *PI()/180.0 - @LngEnd *PI()/180.0
- SET @Distance = 2 *ASIN(SQRT(POWER(SIN(@RadLatDiff/2), 2)
- +COS(@RadLatBegin)*COS(@RadLatEnd)*POWER(SIN(@RadLngDiff/2), 2)))
- SET @Distance = @Distance * @EARTH_RADIUS
- RETURN @Distance
- END
- --使用方法如下:
- SELECT dbo.fnGetDistance(25,30,12.56,15.5) ;
3、Orcale脚本
- CREATE OR REPLACE FUNCTION GetDistance
- (lat1 number, lng1 number,lat2 number,lng2 number)
- RETURN NUMBER is
- earth_padius number := 6378.137;
- radLat1 number := Radian(lat1);
- radLat2 number := Radian(lat2);
- a number := radLat1 - radLat2;
- b number := Radian(lng1) - Radian(lng2);
- s number := 0;
- begin
- s := 2 *
- Asin(Sqrt(power(sin(a / 2), 2) +
- cos(radLat1) * cos(radLat2) * power(sin(b / 2), 2)));
- s := s * earth_padius;
- s := Round(s * 10000) / 10000;
- return s;
- end;
- --使用方法
- select GetDistance(25,30,12.56,15.5) from dual
idea官方推送了2020.2.4版本的更新,那么大家最关心的问题来了,之前激活idea202...
问题:我们在做flex的开发中,如果用到别人搭建好的框架,而别人的server名称往...
大家好,我是狂聊君。 今天来聊一聊 Mysql 缓存池原理。 提纲附上,话不多说,直...
本文转载自微信公众号「SH的全栈笔记」,作者SH。转载本文请联系SH的全栈笔记公...
本文转载自微信公众号「SQL数据库」,作者丶平凡世界 。转载本文请联系开发公众...
前言 项目开发中不管是前台还是后台都会遇到烦人的null,数据库表中字段允许空值...
来源:DeepenStudy 漏洞文件:js.asp % Dimoblog setoblog=newclass_sys oblog.a...
本文实例讲述了AJAX+Servlet实现的数据处理显示功能。分享给大家供大家参考,具...
在Flash Player 10.1及以上版本中,adobe新增了全局错误处理程序UncaughtErrorEv...
CKeditor,以前叫FCKeditor,已经使用过好多年了,功能自然没的说。最近升级到3....