zoukankan      html  css  js  c++  java
  • Lua 计算两个GPS坐标点之间的距离


    local EARTH_RADIUS = 6378.137
    local function rad(d)
      return d * math.pi / 180.0
    end

    local function getDistance(lat1,lng1,lat2,lng2)
      local radLat1 = rad(lat1)
      local radLat2 = rad(lat2)
      local a = radLat1 - radLat2
      local b = rad(lng1) - rad(lng2)
      local s = 2 * math.asin(math.sqrt(math.pow(math.sin(a/2),2) +
      math.cos(radLat1)*math.cos(radLat2)*math.pow(math.sin(b/2),2)))
      s = s * EARTH_RADIUS
      return s*1000 -- 单位米
    end

  • 相关阅读:
    request相关
    C#请求接口
    qml_base
    web
    entry
    listbox
    Canvas
    pickle
    c#枚举
    数据结构——树
  • 原文地址:https://www.cnblogs.com/xilanglang/p/6697892.html
Copyright © 2011-2022 走看看