1
This commit is contained in:
@@ -2,7 +2,9 @@ package baidunavi
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -192,6 +194,7 @@ func (a *API) AccessAPI(apiStr string, params map[string]interface{}) (retVal in
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// BatchCoordinateConvert 坐标转换
|
||||
func (a *API) BatchCoordinateConvert(coords []*Coordinate, fromCoordSys, toCoordSys int) (outCoords []*Coordinate, err error) {
|
||||
if fromCoordSys == toCoordSys {
|
||||
return coords, nil
|
||||
@@ -244,22 +247,25 @@ func (a *API) DirectionLiteRide(coords []*Coordinate) (retVal interface{}, err e
|
||||
// 发起请求
|
||||
request, err := url.Parse(prodURL2 + "/" + apiStr + "?" + params.Encode())
|
||||
if nil != err {
|
||||
fmt.Printf("host error: %v", err)
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err1 := http.Get(request.String())
|
||||
fmt.Printf("url: %s\n", request.String())
|
||||
defer resp.Body.Close()
|
||||
if err1 != nil {
|
||||
fmt.Printf("request error: %v", err1)
|
||||
return
|
||||
return nil, err1
|
||||
}
|
||||
body, err2 := ioutil.ReadAll(resp.Body)
|
||||
if err2 != nil {
|
||||
fmt.Printf("response error: %v", err2)
|
||||
return nil, err2
|
||||
}
|
||||
result := string(body)
|
||||
|
||||
path := &RiderPath{}
|
||||
if err := json.Unmarshal([]byte(result), path); err != nil {
|
||||
return result, nil
|
||||
}
|
||||
globals.SugarLogger.Debugf("=======path := %s", utils.Format4Output(path, false))
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user