This commit is contained in:
邹宗楠
2024-07-29 08:50:21 +08:00
parent 2dbdace45c
commit 5edbd4dd49
3 changed files with 102 additions and 143 deletions

View File

@@ -2,7 +2,6 @@ package cms
import (
"fmt"
"git.rosy.net.cn/jx-callback/globals"
"math"
"reflect"
"regexp"
@@ -759,41 +758,10 @@ func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, dist
}
}
polyLineList = utils.BaiDuCoord2Gaode2(polyLine)
// 百度坐标转高德坐标
polyLineList = jxutils.BaiDuCoord2Gaode2(polyLine)
if len(polyLineList) == 0 || polyLineList == nil {
polyLineList = polyLine
}
return
}
// 美团只认识高德地图坐标点,的转一下
func baiDuCoord2Gaode(baiduCoordinat []string) ([]string, error) {
count := len(baiduCoordinat) / 100
if i := len(baiduCoordinat) % 100; i != 0 {
count += 1
}
gaoCoordinat := make([]string, 0, 0)
for i := 1; i <= count; i++ {
var discordant = make([]string, 0, 0)
if i == count {
discordant = append(discordant, baiduCoordinat[(i-1)*100:]...)
} else {
discordant = append(discordant, baiduCoordinat[(i-1)*100:i*100]...)
}
coords, err := api.BaiDuNaviAPI.BatchCoordinateConvertBai2Gao(discordant, baidunavi.CoordSysBaidu2Gaode)
if err != nil {
globals.SugarLogger.Debugf("百度坐标转换异常:%v", err)
break
}
for _, v := range coords {
gaoCoordinat = append(gaoCoordinat, fmt.Sprintf("%.6f,%.6f", v.Lng, v.Lat))
}
}
if len(gaoCoordinat) == 0 || len(gaoCoordinat) != len(baiduCoordinat) {
}
return gaoCoordinat, nil
}