! format func EarthDistance params from lat, lng1... to lng1, lat1...

This commit is contained in:
gazebo
2019-01-25 11:41:33 +08:00
parent 367fff9321
commit f3b7a0e84e
3 changed files with 5 additions and 5 deletions

View File

@@ -132,7 +132,7 @@ func ConvertDistanceToLogLat(lng, lat, distance, angle float64) (newLng, newLat
}
// 返回结果单元为公里
func EarthDistance(lat1, lng1, lat2, lng2 float64) float64 {
func EarthDistance(lng1, lat1, lng2, lat2 float64) float64 {
radius := 6378.137
rad := math.Pi / 180.0
lat1 = lat1 * rad

View File

@@ -6,9 +6,9 @@ import (
)
func TestEarthDistance(t *testing.T) {
lat1, lng1 := 32.060255, 118.796877
lat2, lng2 := 39.904211, 116.407395
distance := EarthDistance(lat1, lng1, lat2, lng2)
lng1, lat1 := 118.796877, 32.060255
lng2, lat2 := 116.407395, 39.904211
distance := EarthDistance(lng1, lat1, lng2, lat2)
fmt.Print(distance)
}

View File

@@ -55,7 +55,7 @@ func CalculateOrderDeliveryFee(order *model.GoodsOrder, billTime time.Time, db o
lng2, lat2, _ := jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
var distanceAddFee, weightAddFee, timeAddFee int64
distance := jxutils.EarthDistance(lat, lng, lat2, lng2) * 1.4
distance := jxutils.EarthDistance(lng, lat, lng2, lat2) * 1.4
if distance < 3 {
} else if distance < 5 {
distanceAddFee = jxutils.StandardPrice2Int(math.Ceil(distance - 3))