使用腾讯地图,百度和高德不在使用
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"math"
|
||||
"reflect"
|
||||
"regexp"
|
||||
@@ -10,8 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils/errlist"
|
||||
@@ -230,11 +229,11 @@ func UpdatePlace(ctx *jxcontext.Context, placeCode int, payload map[string]inter
|
||||
}
|
||||
|
||||
func GetCoordinateDistrictCode(ctx *jxcontext.Context, lng, lat float64) (code int, err error) {
|
||||
return api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat), nil
|
||||
return api.TencentMapAPI.GetCoordinateDistrictCode(lng, lat), nil
|
||||
}
|
||||
|
||||
func GetCoordinateCityInfo(ctx *jxcontext.Context, lng, lat float64) (name string, err error) {
|
||||
name, _ = api.AutonaviAPI.GetCoordinateCityInfo(lng, lat)
|
||||
name, _ = api.TencentMapAPI.GetCoordinateCityInfo(lng, lat)
|
||||
return name, err
|
||||
}
|
||||
|
||||
@@ -593,19 +592,18 @@ func GetCityBankBranches(ctx *jxcontext.Context, cityCode int, bankCode string)
|
||||
|
||||
// GetSToURidingDistance 获取商家与用户间步行距离
|
||||
func GetSToURidingDistance(sLng, sLat, uLng, uLat float64, orderId string) (stepInfo interface{}, err error) {
|
||||
var coords []*baidunavi.Coordinate
|
||||
coords = append(coords, &baidunavi.Coordinate{
|
||||
Lng: sLng,
|
||||
Lat: sLat,
|
||||
}, &baidunavi.Coordinate{
|
||||
Lat: uLat,
|
||||
Lng: uLng,
|
||||
coordList, err := api.TencentMapAPI.TencentCoordinateChange(&tencent_map.TencentCoordinateChangeReq{
|
||||
Locations: fmt.Sprintf("%.6f,%.6f;%.6f,%.6f", sLat, sLng, uLat, uLng),
|
||||
Type: tencent_map.CoordinateChangeTypeBaidu,
|
||||
})
|
||||
if coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGaoDe2Baidu); err == nil {
|
||||
if len(coords) > 0 {
|
||||
if stepInfo, err = api.BaiDuNaviAPI.DirectionLiteRide(coords); err == nil {
|
||||
return stepInfo, nil
|
||||
}
|
||||
|
||||
if err == nil && len(coordList) == 2 {
|
||||
param := &tencent_map.TencentCyclingPlanningReq{
|
||||
From: fmt.Sprintf("%s,%s", coordList[0].Lat, coordList[0].Lng),
|
||||
To: fmt.Sprintf("%s,%s", coordList[1].Lat, coordList[1].Lng),
|
||||
}
|
||||
if stepInfo, err = api.TencentMapAPI.WalkingDistance(param); err == nil {
|
||||
return stepInfo, nil
|
||||
}
|
||||
}
|
||||
return 0, err
|
||||
@@ -722,7 +720,7 @@ func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (way
|
||||
// GetCyclingLine 获取骑行路线
|
||||
func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, distance, duration int64, err error) {
|
||||
// 百度
|
||||
var coords []*baidunavi.Coordinate
|
||||
/*var coords []*baidunavi.Coordinate
|
||||
coords = append(coords, &baidunavi.Coordinate{
|
||||
Lng: sLng,
|
||||
Lat: sLat,
|
||||
@@ -732,36 +730,13 @@ func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, dist
|
||||
})
|
||||
|
||||
// 高德坐标转换成百度坐标
|
||||
coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGaoDe2Baidu)
|
||||
coords, err = api.TencentMapAPI.TencentCoordinateChange(coords, baidunavi.CoordSysGaoDe2Baidu)
|
||||
if err != nil || len(coords) <= model.NO {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
data, err := api.BaiDuNaviAPI.DirectionLiteRide(coords)
|
||||
if err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
if data == "" {
|
||||
return nil, 0, 0, fmt.Errorf("获取骑行规划路线错误")
|
||||
}
|
||||
path := &baidunavi.RiderPath{}
|
||||
if err := utils.Map2StructByJson(data, path, false); err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
|
||||
polyLine := make([]string, 0, 0)
|
||||
if path != nil && len(path.Routes) != 0 {
|
||||
distance = int64(path.Routes[0].Distance) // 距离
|
||||
duration = int64(path.Routes[0].Duration) // 时间
|
||||
|
||||
for _, v := range path.Routes[0].Steps {
|
||||
polyLine = append(polyLine, strings.Split(v.Path, ";")...)
|
||||
}
|
||||
}
|
||||
|
||||
// 百度坐标转高德坐标
|
||||
polyLineList = jxutils.BaiDuCoord2Gaode2(polyLine)
|
||||
if len(polyLineList) == 0 || polyLineList == nil {
|
||||
polyLineList = polyLine
|
||||
}
|
||||
}*/
|
||||
distance, duration, polyLineList, err = api.TencentMapAPI.TencentCyclingPlanning(&tencent_map.TencentCyclingPlanningReq{
|
||||
From: fmt.Sprintf("%.6f,%.6f", sLat, sLng),
|
||||
To: fmt.Sprintf("%.6f,%.6f", uLat, uLng),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user