Skip to content

Commit c23ece6

Browse files
dimrocChimeraCoder
authored andcommitted
Differentiate between GeoSearch PlaceResult and Tweet Place
Signed-off-by: aditya <[email protected]>
1 parent 329d257 commit c23ece6

File tree

2 files changed

+88
-53
lines changed

2 files changed

+88
-53
lines changed

geosearch.go

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package anaconda
2+
3+
import "net/url"
4+
5+
type GeoSearchResult struct {
6+
Result struct {
7+
Places []struct {
8+
ID string `json:"id"`
9+
URL string `json:"url"`
10+
PlaceType string `json:"place_type"`
11+
Name string `json:"name"`
12+
FullName string `json:"full_name"`
13+
CountryCode string `json:"country_code"`
14+
Country string `json:"country"`
15+
ContainedWithin []struct {
16+
ID string `json:"id"`
17+
URL string `json:"url"`
18+
PlaceType string `json:"place_type"`
19+
Name string `json:"name"`
20+
FullName string `json:"full_name"`
21+
CountryCode string `json:"country_code"`
22+
Country string `json:"country"`
23+
Centroid []float64 `json:"centroid"`
24+
BoundingBox struct {
25+
Type string `json:"type"`
26+
Coordinates [][][]float64 `json:"coordinates"`
27+
} `json:"bounding_box"`
28+
Attributes struct {
29+
} `json:"attributes"`
30+
} `json:"contained_within"`
31+
Centroid []float64 `json:"centroid"`
32+
BoundingBox struct {
33+
Type string `json:"type"`
34+
Coordinates [][][]float64 `json:"coordinates"`
35+
} `json:"bounding_box"`
36+
Attributes struct {
37+
} `json:"attributes"`
38+
} `json:"places"`
39+
} `json:"result"`
40+
Query struct {
41+
URL string `json:"url"`
42+
Type string `json:"type"`
43+
Params struct {
44+
Accuracy float64 `json:"accuracy"`
45+
Granularity string `json:"granularity"`
46+
Query string `json:"query"`
47+
Autocomplete bool `json:"autocomplete"`
48+
TrimPlace bool `json:"trim_place"`
49+
} `json:"params"`
50+
} `json:"query"`
51+
}
52+
53+
func (a TwitterApi) GeoSearch(v url.Values) (c GeoSearchResult, err error) {
54+
response_ch := make(chan response)
55+
a.queryQueue <- query{BaseUrl + "/geo/search.json", v, &c, _GET, response_ch}
56+
return c, (<-response_ch).err
57+
}

place.go

+31-53
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,35 @@
11
package anaconda
22

3-
import "net/url"
4-
53
type Place struct {
6-
Result struct {
7-
Places []struct {
8-
ID string `json:"id"`
9-
URL string `json:"url"`
10-
PlaceType string `json:"place_type"`
11-
Name string `json:"name"`
12-
FullName string `json:"full_name"`
13-
CountryCode string `json:"country_code"`
14-
Country string `json:"country"`
15-
ContainedWithin []struct {
16-
ID string `json:"id"`
17-
URL string `json:"url"`
18-
PlaceType string `json:"place_type"`
19-
Name string `json:"name"`
20-
FullName string `json:"full_name"`
21-
CountryCode string `json:"country_code"`
22-
Country string `json:"country"`
23-
Centroid []float64 `json:"centroid"`
24-
BoundingBox struct {
25-
Type string `json:"type"`
26-
Coordinates [][][]float64 `json:"coordinates"`
27-
} `json:"bounding_box"`
28-
Attributes struct {
29-
} `json:"attributes"`
30-
} `json:"contained_within"`
31-
Centroid []float64 `json:"centroid"`
32-
BoundingBox struct {
33-
Type string `json:"type"`
34-
Coordinates [][][]float64 `json:"coordinates"`
35-
} `json:"bounding_box"`
36-
Attributes struct {
37-
} `json:"attributes"`
38-
} `json:"places"`
39-
} `json:"result"`
40-
Query struct {
41-
URL string `json:"url"`
42-
Type string `json:"type"`
43-
Params struct {
44-
Accuracy float64 `json:"accuracy"`
45-
Granularity string `json:"granularity"`
46-
Query string `json:"query"`
47-
Autocomplete bool `json:"autocomplete"`
48-
TrimPlace bool `json:"trim_place"`
49-
} `json:"params"`
50-
} `json:"query"`
51-
}
52-
53-
func (a TwitterApi) GeoSearch(v url.Values) (c Place, err error) {
54-
response_ch := make(chan response)
55-
a.queryQueue <- query{BaseUrl + "/geo/search.json", v, &c, _GET, response_ch}
56-
return c, (<-response_ch).err
4+
Attributes map[string]string `json:"attributes"`
5+
BoundingBox struct {
6+
Coordinates [][][]float64 `json:"coordinates"`
7+
Type string `json:"type"`
8+
} `json:"bounding_box"`
9+
ContainedWithin []struct {
10+
Attributes map[string]string `json:"attributes"`
11+
BoundingBox struct {
12+
Coordinates [][][]float64 `json:"coordinates"`
13+
Type string `json:"type"`
14+
} `json:"bounding_box"`
15+
Country string `json:"country"`
16+
CountryCode string `json:"country_code"`
17+
FullName string `json:"full_name"`
18+
ID string `json:"id"`
19+
Name string `json:"name"`
20+
PlaceType string `json:"place_type"`
21+
URL string `json:"url"`
22+
} `json:"contained_within"`
23+
Country string `json:"country"`
24+
CountryCode string `json:"country_code"`
25+
FullName string `json:"full_name"`
26+
Geometry struct {
27+
Coordinates [][][]float64 `json:"coordinates"`
28+
Type string `json:"type"`
29+
} `json:"geometry"`
30+
ID string `json:"id"`
31+
Name string `json:"name"`
32+
PlaceType string `json:"place_type"`
33+
Polylines []string `json:"polylines"`
34+
URL string `json:"url"`
5735
}

0 commit comments

Comments
 (0)