8
8
}
9
9
10
10
GeocodeAddressOptions struct {
11
- Longitude float64
12
11
Latitude float64
12
+ Longitude float64
13
13
OSMTag string
14
14
Language string
15
+ Foramt string
15
16
Limit int
16
17
}
17
18
19
+ GeocodeIPOptions struct {
20
+ Foramt string
21
+ }
22
+
18
23
GeocodeReverseOptions struct {
19
- Limit int
24
+ Foramt string
25
+ Limit int
20
26
}
21
27
22
28
GeocodeGeometry struct {
@@ -36,16 +42,21 @@ type (
36
42
}
37
43
)
38
44
39
- func (g * Geocode ) Address (location string , options GeocodeAddressOptions ) (* GeocodeResponse , * APIError ) {
45
+ func (g * Geocode ) Address (location string ) (* GeocodeResponse , * APIError ) {
46
+ return g .AddressWithOptions (location , GeocodeAddressOptions {})
47
+ }
48
+
49
+ func (g * Geocode ) AddressWithOptions (location string , options GeocodeAddressOptions ) (* GeocodeResponse , * APIError ) {
40
50
res := new (GeocodeResponse )
41
51
err := new (APIError )
42
52
r , e := g .resty .R ().
43
53
SetQueryParams (map [string ]string {
44
54
"location" : location ,
45
- "longitude" : strconv .FormatFloat (options .Longitude , 'f' , - 1 , 64 ),
46
55
"latitude" : strconv .FormatFloat (options .Latitude , 'f' , - 1 , 64 ),
56
+ "longitude" : strconv .FormatFloat (options .Longitude , 'f' , - 1 , 64 ),
47
57
"osm_tag" : options .OSMTag ,
48
58
"language" : options .Language ,
59
+ "foramt" : options .Foramt ,
49
60
"limit" : strconv .Itoa (options .Limit ),
50
61
}).
51
62
SetResult (res ).
@@ -63,11 +74,16 @@ func (g *Geocode) Address(location string, options GeocodeAddressOptions) (*Geoc
63
74
}
64
75
65
76
func (g * Geocode ) IP (ip string ) (* GeocodeResponse , * APIError ) {
77
+ return g .IPWithOptions (ip , GeocodeIPOptions {})
78
+ }
79
+
80
+ func (g * Geocode ) IPWithOptions (ip string , options GeocodeIPOptions ) (* GeocodeResponse , * APIError ) {
66
81
res := new (GeocodeResponse )
67
82
err := new (APIError )
68
83
r , e := g .resty .R ().
69
84
SetQueryParams (map [string ]string {
70
- "ip" : ip ,
85
+ "ip" : ip ,
86
+ "foramt" : options .Foramt ,
71
87
}).
72
88
SetResult (res ).
73
89
SetError (err ).
@@ -83,13 +99,18 @@ func (g *Geocode) IP(ip string) (*GeocodeResponse, *APIError) {
83
99
return res , nil
84
100
}
85
101
86
- func (g * Geocode ) Reverse (longitude , latitude float64 , options GeocodeReverseOptions ) (* GeocodeResponse , * APIError ) {
102
+ func (g * Geocode ) Reverse (latitude , longitude float64 ) (* GeocodeResponse , * APIError ) {
103
+ return g .ReverseWithOptions (latitude , longitude , GeocodeReverseOptions {})
104
+ }
105
+
106
+ func (g * Geocode ) ReverseWithOptions (latitude , longitude float64 , options GeocodeReverseOptions ) (* GeocodeResponse , * APIError ) {
87
107
res := new (GeocodeResponse )
88
108
err := new (APIError )
89
109
r , e := g .resty .R ().
90
110
SetQueryParams (map [string ]string {
91
- "longitude" : strconv .FormatFloat (longitude , 'f' , - 1 , 64 ),
92
111
"latitude" : strconv .FormatFloat (latitude , 'f' , - 1 , 64 ),
112
+ "longitude" : strconv .FormatFloat (longitude , 'f' , - 1 , 64 ),
113
+ "foramt" : options .Foramt ,
93
114
"limit" : strconv .Itoa (options .Limit ),
94
115
}).
95
116
SetResult (res ).
0 commit comments