将所有地图改为腾讯地图
This commit is contained in:
@@ -1,20 +1,5 @@
|
||||
package baidunavi
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
signKey = "sn"
|
||||
resultKey = "result"
|
||||
@@ -33,6 +18,11 @@ const (
|
||||
StatusCodeExceedConcurrentQuota = 402 // 当前并发量已经超过约定并发配额,并且服务总并发量也已经超过设定的总并发配额,限制访问
|
||||
)
|
||||
|
||||
//bd09ll表示百度经纬度坐标,
|
||||
//bd09mc表示百度墨卡托坐标,
|
||||
//gcj02表示经过国测局加密的坐标,
|
||||
//wgs84表示gps获取的坐标,
|
||||
|
||||
const (
|
||||
CoordSysWGS84 = 1 // GPS设备获取的角度坐标,WGS84坐标
|
||||
CoordSysGCJ02 = 3 // google地图、soso地图、aliyun地图、mapabc地图和amap地图所用坐标,国测局(GCJ02)坐标
|
||||
@@ -42,6 +32,7 @@ const (
|
||||
CoordSysBaidu2Gaode = "5" // 百度坐标转高德坐标
|
||||
)
|
||||
|
||||
/*
|
||||
const (
|
||||
MaxCoordsConvBatchSize = 100
|
||||
)
|
||||
@@ -163,39 +154,6 @@ func genGetURL(baseURL, apiStr string, params map[string]interface{}) string {
|
||||
return baseURL + queryString
|
||||
}
|
||||
|
||||
/*func (a *API) AccessAPI(apiStr string, params map[string]interface{}) (retVal interface{}, err error) {
|
||||
apiStr += "/"
|
||||
params2 := utils.MergeMaps(utils.Params2Map("ak", a.ak, "output", "json"), params)
|
||||
params2[signKey] = a.signParams(apiStr, params2)
|
||||
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
//request, _ := http.NewRequest(http.MethodGet, genGetURL(prodURL, apiStr, params2), nil)
|
||||
request, _ := http.NewRequest(http.MethodGet, genGetURL(prodURL2, apiStr, params2), nil)
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||
if jsonResult1 == nil {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||
}
|
||||
status := int(utils.MustInterface2Int64(jsonResult1["status"]))
|
||||
if status == StatusCodeSuccess {
|
||||
retVal = jsonResult1[resultKey]
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
}
|
||||
newErr := utils.NewErrorIntCode(utils.Interface2String(jsonResult1["message"]), status)
|
||||
if _, ok := exceedLimitCodes[status]; ok {
|
||||
return platformapi.ErrLevelRecoverableErr, newErr
|
||||
} else if _, ok := canRetryCodes[status]; ok {
|
||||
return platformapi.ErrLevelRecoverableErr, newErr
|
||||
} else {
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
}
|
||||
})
|
||||
return retVal, err
|
||||
}*/
|
||||
|
||||
func (a *API) AccessAPI2(apiStr string, param url.Values) (retVal map[string]interface{}, err error) {
|
||||
|
||||
for _, v := range BaiduAKList {
|
||||
@@ -229,29 +187,6 @@ func (a *API) AccessAPI2(apiStr string, param url.Values) (retVal map[string]int
|
||||
return nil, errors.New("所有百度应用额度均用完")
|
||||
}
|
||||
|
||||
// BatchCoordinateConvert 坐标转换
|
||||
//func (a *API) BatchCoordinateConvert(coords []*Coordinate, fromCoordSys, toCoordSys int) (outCoords []*Coordinate, err error) {
|
||||
// if fromCoordSys == toCoordSys {
|
||||
// return coords, nil
|
||||
// }
|
||||
// var coordsStrList []string
|
||||
// for _, v := range coords {
|
||||
// coordsStrList = append(coordsStrList, fmt.Sprintf("%.6f,%.6f", v.Lng, v.Lat))
|
||||
// }
|
||||
//
|
||||
// params := url.Values{
|
||||
// "coords": []string{strings.Join(coordsStrList, ";")},
|
||||
// "from": []string{utils.Int2Str(fromCoordSys)},
|
||||
// "to": []string{utils.Int2Str(toCoordSys)},
|
||||
// }
|
||||
//
|
||||
// result, err := a.AccessAPI2("geoconv/v1/", params)
|
||||
// if err == nil {
|
||||
// err = utils.Map2StructByJson(result[resultKey], &outCoords, false)
|
||||
// }
|
||||
// return outCoords, err
|
||||
//}
|
||||
|
||||
// BatchCoordinateConvert 坐标转换
|
||||
func (a *API) BatchCoordinateConvert(coords []*Coordinate, changeType string) (outCoords []*Coordinate, err error) {
|
||||
var coordsStrList []string
|
||||
@@ -273,20 +208,6 @@ func (a *API) BatchCoordinateConvert(coords []*Coordinate, changeType string) (o
|
||||
return outCoords, err
|
||||
}
|
||||
|
||||
// BatchCoordinateConvertBai2Gao 百度转高德
|
||||
func (a *API) BatchCoordinateConvertBai2Gao(coords []string, changeType string) (outCoords []*Coordinate, err error) {
|
||||
params := url.Values{
|
||||
"coords": []string{strings.Join(coords, ";")},
|
||||
"model": []string{changeType}, // 1:高德转百度 5:百度转高德
|
||||
}
|
||||
|
||||
result, err := a.AccessAPI2("geoconv/v2/", params)
|
||||
if err == nil {
|
||||
err = utils.Map2StructByJson(result[resultKey], &outCoords, false)
|
||||
}
|
||||
return outCoords, err
|
||||
}
|
||||
|
||||
// DirectionLiteRide 获取骑行距离
|
||||
func (a *API) DirectionLiteRide(coords []*Coordinate) (retVal interface{}, err error) {
|
||||
var (
|
||||
@@ -309,3 +230,4 @@ func (a *API) DirectionLiteRide(coords []*Coordinate) (retVal interface{}, err e
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user