mysql函数计算两点之间的距离

     1:计算距离

mysql空间函数汇总_ununie的博客-CSDN博客_mysql空间函数名称描述1ST_StartPoint()LineString的起始点2ST_EndPoint()LineString的终点3ST_Transform()变换几何的坐标4ST_GeoHash()产生geohash值5ST_LongFromGeoHash()从geohash值...https://blog.csdn.net/ununie/article/details/101014849
  select
*,
ST_Distance_Sphere(ST_GeomFromText('POINT(114.28345822284 22.6916483239028)'),ST_GeomFromText(CONCAT('POINT(',c_gcj02_lng,' ',c_gcj02_lat,')'))) as distance
from lgq_um_event where data_source!='wg' and c_source_name='视频智能抓拍案件' and community_area_name='南约'
     2:计算距离
SELECT
    *,
    ROUND(
        6378.138 * 2 * ASIN(
            SQRT(
                POW(
                    SIN(
                        (
                            22.694473691335844 * PI() / 180 - c_wgs84_lat * PI() / 180
                        ) / 2
                    ),
                    2
                ) + COS(22.694473691335844 * PI() / 180) * COS(c_wgs84_lat * PI() / 180) * POW(
                    SIN(
                        (
                            114.27862657654101 * PI() / 180 - c_wgs84_lng * PI() / 180
                        ) / 2
                    ),
                    2
                )
            )
        ) * 1000
    ) AS juli
FROM
    lgq_um_event where  data_source = 'wg'
ORDER BY
    juli desc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值