From d1c406fcdffc7bad6f27e1258b74b6c1c3f1f0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 4 Jul 2024 15:22:39 +0800 Subject: [PATCH] 1 --- business/jxstore/cms/cms.go | 25 ++++++++++++++++++++++--- business/jxstore/cms/store.go | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 1ee139c28..1899407f7 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -601,7 +601,7 @@ func GetSToURidingDistance(sLng, sLat, uLng, uLat float64, orderId string) (step Lat: uLat, Lng: uLng, }) - if coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGCJ02, baidunavi.CoordSysBaiDu); err == nil { + 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 @@ -724,7 +724,8 @@ func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, dist Lng: uLng, }) - coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGCJ02, baidunavi.CoordSysBaiDu) + // 高德坐标转换成百度坐标 + coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGaoDe2Baidu) if err != nil || len(coords) <= model.NO { return nil, 0, 0, err } @@ -740,13 +741,31 @@ func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, dist 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 { - polyLineList = append(polyLineList, strings.Split(v.Path, ";")...) + polyLine = append(polyLine, strings.Split(v.Path, ";")...) } } + + polyLineList, err = baiDuCoord2Gaode(polyLine) return } + +// 美团只认识高德地图坐标点,的转一下 +func baiDuCoord2Gaode(baiduCoordinat []string) ([]string, error) { + coords, err := api.BaiDuNaviAPI.BatchCoordinateConvertBai2Gao(baiduCoordinat, baidunavi.CoordSysBaidu2Gaode) + if err != nil { + return nil, err + } + + gaoCoordinat := make([]string, 0, 0) + for _, v := range coords { + gaoCoordinat = append(gaoCoordinat, fmt.Sprintf("%.6f,%.6f", v.Lng, v.Lat)) + } + + return gaoCoordinat, nil +} diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 2dc44fe51..f22dc7aa4 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -699,7 +699,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa Lat: store.FloatLat, }) } - coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGCJ02, baidunavi.CoordSysBaiDu) + coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGaoDe2Baidu) if err == nil { for k, v := range batchItemList { store := v.(*StoreExt)