- move some funcs from controller to jxutils.
This commit is contained in:
@@ -8,8 +8,11 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -101,3 +104,38 @@ func EarthDistance(lat1, lng1, lat2, lng2 float64) float64 {
|
||||
dist := math.Acos(math.Sin(lat1)*math.Sin(lat2) + math.Cos(lat1)*math.Cos(lat2)*math.Cos(theta))
|
||||
return dist * radius
|
||||
}
|
||||
|
||||
func StandardCoordinate2Int(value float64) int {
|
||||
return int(math.Round(value * 1000000))
|
||||
}
|
||||
|
||||
func IntCoordinate2Standard(value int) float64 {
|
||||
return float64(value) / 1000000
|
||||
}
|
||||
|
||||
func IntCoordinate2MarsStandard(gpsLng, gpsLat int, coordinateType int) (marsLng, marsLat float64, err error) {
|
||||
marsLng = IntCoordinate2Standard(gpsLng)
|
||||
marsLat = IntCoordinate2Standard(gpsLat)
|
||||
coordSys := ""
|
||||
switch coordinateType {
|
||||
case model.CoordinateTypeGPS:
|
||||
coordSys = autonavi.CoordSysGPS
|
||||
case model.CoordinateTypeMars:
|
||||
coordSys = autonavi.CoordSysAutonavi
|
||||
case model.CoordinateTypeBaiDu:
|
||||
coordSys = autonavi.CoordSysBaidu
|
||||
case model.CoordinateTypeMapbar:
|
||||
coordSys = autonavi.CoordSysMapbar
|
||||
default:
|
||||
globals.SugarLogger.Errorf("known coordinate type:%d", coordinateType)
|
||||
}
|
||||
return api.AutonaviAPI.CoordinateConvert(marsLng, marsLat, coordSys)
|
||||
}
|
||||
|
||||
func IntPrice2Standard(value int64) float64 {
|
||||
return float64(value) / 100
|
||||
}
|
||||
|
||||
func StandardPrice2Int(value float64) int64 {
|
||||
return int64(math.Round(value * 100))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user