CREATE DEFINER=`root`@`%` FUNCTION `latlon`(lat1 DOUBLE,lon1 DOUBLE,lat2 DOUBLE,lon2 DOUBLE) RETURNS varchar(200) CHARSET utf8mb4
begin
return ROUND(
        6378.138 * 2 * ASIN(
            SQRT(
                POW(
                    SIN(
                        (
                            lat1 * PI() / 180 - lat2 * PI() / 180
                        ) / 2
                    ),
                    2
                ) + COS(lat1 * PI() / 180) * COS(lat2 * PI() / 180) * POW(
                    SIN(
                        (
                            lon1 * PI() / 180 - lon2 * PI() / 180
                        ) / 2
                    ),
                    2
                )
            )
        ) * 1000
    );
end

 

相关文章:

  • 2021-12-10
  • 2021-12-29
  • 2022-12-23
  • 2022-01-07
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案