''' <summary> ''' 換算兩個經緯度的距離(公里) ''' </summary> ''' <param name="lat_a">緯度1</param> ''' <param name="lng_a">經度1</param> ''' <param name="lat_b">緯度2</param> ''' <param name="lng_b">經度2</param> ''' <returns></returns> ''' <remarks></remarks>
Private Function gps2km(ByVal lat_a As Double, ByVal lng_a As Double, ByVal lat_b As Double, ByVal lng_b As Double) As Double Dim EARTH_RADIUS As Double = 6378.137 Dim radLat1 As Double = (lat_a * Math.PI / 180.0) Dim radLat2 As Double = (lat_b * Math.PI / 180.0) Dim a As Double = radLat1 - radLat2 Dim b As Double = (lng_a - lng_b) * Math.PI / 180.0 Dim s As Double = 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 s = Math.Round(s * 10000) / 10000 Return s End Function
沒有留言:
張貼留言