zoukankan      html  css  js  c++  java
  • mysql函数计算地表两点间距离

    DELIMITER $$
    
    CREATE FUNCTION `test`.`getDistance`(LatBegin FLOAT(10,4), LngBegin FLOAT(10,4), LatEnd FLOAT(10,4), LngEnd FLOAT(10,4))RETURNS FLOAT(10,4)
        BEGIN
    	DECLARE Distance FLOAT(10,4) DEFAULT 0.0000;
    	DECLARE EARTH_RADIUS FLOAT(10,4) DEFAULT 0.0000;
    	DECLARE RadLatBegin FLOAT(10,4);
    	DECLARE RadLatEnd FLOAT(10,4);
    	DECLARE RadLatDiff FLOAT(10,4);
    	DECLARE RadLngDiff FLOAT(10,4);
    	SET EARTH_RADIUS = 6378.137;
    	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;
    	-- SET @Distance = Round(@Distance * 10000) / 10000  
    	RETURN Distance;
    
        END$$
    
    DELIMITER ;
    

      

  • 相关阅读:
    跨域资源共享 CORS 详解
    C# 每月第一天和最后一天
    jexus http to https
    ASP.NET MVC 路由学习
    jexus
    centos7 添加开机启动项
    jexus docker
    HTTP2.0新特性
    jexus配置支持Owin
    Autofac Named命名和Key Service服务
  • 原文地址:https://www.cnblogs.com/jenqz/p/4673906.html
Copyright © 2011-2022 走看看