zoukankan      html  css  js  c++  java
  • 地图计算计算距离

    经纬度计算距离

    sql(计算结果默认单位为米,这里保留一位小数)

    #关联查询当被关联表有指定条件时,会导致主表查询结果不正确
    select u.name,a.area,a.lat,a.lon,a.is_main,(st_distance (point (a.lat,a.lon),point(120.218405,30.251983) ) * 111195) AS distance
    from user u 
    left join addr a on a.user_id=u.id
    where a.is_main=1
    
    #建议使用
    select u.name,(select round(st_distance (point(120.218405,30.251983),point (lat,lon) ) * 111195,1) from addr where user_id=u.id) AS distance

    获取地图经纬度(纬度(lat)在前经度在后(lon))

    http://api.map.baidu.com/lbsapi/getpoint/index.html

    存储

    谷歌建议存储decimal(10,6)

    只需要精确到小数点后7位,精度就是1CM,因此,数据库保存经纬度采用 decimal(10,7) 即可

    说明:经纬度计算距离实际会略小于位移

  • 相关阅读:
    React——from
    React——条件渲染
    React——event
    React——组件
    React——JSX
    flask_mail使用
    flask开发restful api
    mysql limit和offset用法
    flask打包安装文件
    flask-sqlalchemy使用及数据迁移
  • 原文地址:https://www.cnblogs.com/huay/p/13605133.html
Copyright © 2011-2022 走看看