增加地址解析

This commit is contained in:
yuguojian
2025-07-17 17:16:49 +08:00
parent aee7202752
commit d0d264d1e7
3 changed files with 189 additions and 73 deletions

View File

@@ -2,6 +2,7 @@ package gps_tool
import (
"log"
"reflect"
"testing"
)
@@ -25,7 +26,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test1",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 113.419152,
@@ -37,7 +37,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test2",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 110.165223,
@@ -48,7 +47,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test2",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 115.928973,
@@ -60,7 +58,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test3",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 107.397284,
@@ -72,7 +69,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test4",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 115.929015,
@@ -84,7 +80,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test5",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 115.929100,
@@ -96,7 +91,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test6",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 126.587051,
@@ -108,7 +102,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test7",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 126.595051,
@@ -120,7 +113,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test8",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 125.342693,
@@ -132,7 +124,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test9",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 112.485550,
@@ -144,7 +135,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test10",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 115.928821,
@@ -156,7 +146,6 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
name: "test11",
fields: fields{
AppCode: "",
Host: "https://jmgeocode.market.alicloudapi.com",
},
args: args{
longitude: 115.928821,
@@ -166,12 +155,55 @@ func TestAnNaQiGpsClient_GetGpsInfo(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
n := &AnNaQiGpsClient{
AppCode: tt.fields.AppCode,
Host: tt.fields.Host,
}
n := NewAnNaQiGpsClient(tt.fields.AppCode)
gotRes, err := n.GetGpsInfo(tt.args.longitude, tt.args.latitude)
log.Println(gotRes, err)
})
}
}
func TestAnNaQiGpsClient_GetLocation(t *testing.T) {
type fields struct {
AppCode string
Host string
}
type args struct {
city string
region string
address string
}
tests := []struct {
name string
fields fields
args args
wantRes *[]Geocode
wantErr bool
}{
{
name: "奥园城市天地",
fields: fields{
AppCode: "",
},
args: args{
city: "广州",
region: "番禺",
address: "奥园城市天地9区2栋",
},
wantRes: nil,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
n := NewAnNaQiGpsClient(tt.fields.AppCode)
gotRes, err := n.GetLocation(tt.args.city, tt.args.region, tt.args.address)
if (err != nil) != tt.wantErr {
t.Errorf("GetLocation() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotRes, tt.wantRes) {
t.Errorf("GetLocation() gotRes = %v, want %v", gotRes, tt.wantRes)
}
})
}
}