将所有地图改为腾讯地图
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
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,40 +1,5 @@
|
||||
package baidunavi
|
||||
|
||||
// RiderPath 骑行路线
|
||||
//type RiderPath struct {
|
||||
// Status int `json:"status"` // 状态码 0-成功,1-服务器内部错误,2-参数无效,7-无结果返回
|
||||
// Message string `json:"message"` // 状态码对应的信息
|
||||
// Result struct {
|
||||
// RiderResult
|
||||
// Routes []struct {
|
||||
// Distance int `json:"distance"` // 距离米
|
||||
// Duration int `json:"duration"` // 时间秒
|
||||
// Steps []struct {
|
||||
// Distance int `json:"distance"`
|
||||
// Duration int `json:"duration"`
|
||||
// Direction int `json:"direction"`
|
||||
// TurnType string `json:"turn_type"`
|
||||
// Name string `json:"name"`
|
||||
// Instruction string `json:"instruction"`
|
||||
// RestrictionsInfo string `json:"restrictions_info"`
|
||||
// Path string `json:"path"`
|
||||
// StartLocation RiderCoordinate `json:"start_location"`
|
||||
// EndLocation RiderCoordinate `json:"end_location"`
|
||||
// } `json:"steps"`
|
||||
// } `json:"routes"`
|
||||
// } `json:"result"`
|
||||
//}
|
||||
//
|
||||
//type RiderResult struct {
|
||||
// Origin RiderCoordinate `json:"origin"` // 起点经纬度
|
||||
// Destination RiderCoordinate `json:"destination"` // 终点经纬度
|
||||
//}
|
||||
//
|
||||
//type RiderCoordinate struct {
|
||||
// Lng float64 `json:"lng"` // 经度
|
||||
// Lat float64 `json:"lat"` // 纬度
|
||||
//}
|
||||
|
||||
type RiderPath struct {
|
||||
Destination struct {
|
||||
Lat float64 `json:"lat"`
|
||||
|
||||
@@ -1354,13 +1354,6 @@ var cc []string = []string{
|
||||
"104.05971492107,30.624174347628",
|
||||
}
|
||||
|
||||
func TestBatchCoordinateConvertBai2Gao(t *testing.T) {
|
||||
fmt.Println(len(cc))
|
||||
result, err := api.BatchCoordinateConvertBai2Gao(cc[0:100], "5")
|
||||
fmt.Println(err)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// 1290 104.00734814129,30.660267081943
|
||||
func TestName(t *testing.T) {
|
||||
var bd_lng = 104.00734814129
|
||||
|
||||
Reference in New Issue
Block a user