假设我在LAT / LOT中引用了两个位置
来自:lat 51.504870000000004, lng -0.21533000000000002
收件人:lat 51.50475, lng -0.21571
它们之间的距离是0.02949062526738975 KM。 舍入距离为0.03公里。
private fun calculatesDistance(from: Coordinate, to: Coordinate): Double {
return if ((from.lat == to.lat) && (from.lng == to.lng)) {
Double.MIN_VALUE
} else {
val theta = from.lng - to.lng
var dist = sin(Math.toRadians(from.lat)) * sin(Math.toRadians(to.lat)) + cos(Math.toRadians(from.lat)) * cos(Math.toRadians(to.lat)) * cos(Math.toRadians(theta))
dist = acos(dist)
dist = Math.toDegrees(dist)
dist *= 60 * 1.1515
dist *= 1.609344
dist
}
}
我正在使用以下代码计算该距离。根据网站geodatasource
我想通过插入仪表输入来缩短两者之间的距离。有人为此工作过吗,或者您可以帮我吗?
例如,如果我输入一个10米的输入,那么在应用这10米以继续计算到目的地时,我必须知道我在LAT和LONG中的位置。