/
photo_search_geo.go
94 lines (82 loc) Β· 2.75 KB
/
photo_search_geo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package form
import "time"
// PhotoSearchGeo represents search form fields for "/api/v1/geo".
type PhotoSearchGeo struct {
Query string `form:"q"`
Type string `form:"type"`
Path string `form:"path"`
Folder string `form:"folder"` // Alias for Path
Name string `form:"name"`
Title string `form:"title"`
Before time.Time `form:"before" time_format:"2006-01-02"`
After time.Time `form:"after" time_format:"2006-01-02"`
Favorite bool `form:"favorite"`
Video bool `form:"video"`
Photo bool `form:"photo"`
Raw bool `form:"raw"`
Live bool `form:"live"`
Scan bool `form:"scan"`
Panorama bool `form:"panorama"`
Archived bool `form:"archived"`
Public bool `form:"public"`
Private bool `form:"private"`
Review bool `form:"review"`
Quality int `form:"quality"`
Faces string `form:"faces"` // Find or exclude faces if detected.
Lat float32 `form:"lat"`
Lng float32 `form:"lng"`
S2 string `form:"s2"`
Olc string `form:"olc"`
Dist uint `form:"dist"`
Face string `form:"face"` // UIDs
Subject string `form:"subject"` // UIDs
Person string `form:"person"` // Alias for Subject
Subjects string `form:"subjects"` // Text
People string `form:"people"` // Alias for Subjects
Keywords string `form:"keywords"`
Album string `form:"album"`
Albums string `form:"albums"`
Country string `form:"country"`
Year string `form:"year"` // Moments
Month string `form:"month"` // Moments
Day string `form:"day"` // Moments
Color string `form:"color"`
Camera int `form:"camera"`
Lens int `form:"lens"`
}
// GetQuery returns the query parameter as string.
func (f *PhotoSearchGeo) GetQuery() string {
return f.Query
}
// SetQuery sets the query parameter.
func (f *PhotoSearchGeo) SetQuery(q string) {
f.Query = q
}
// ParseQueryString parses the query parameter if possible.
func (f *PhotoSearchGeo) ParseQueryString() error {
err := ParseQueryString(f)
if f.Path == "" && f.Folder != "" {
f.Path = f.Folder
f.Folder = ""
}
if f.Subject == "" && f.Person != "" {
f.Subject = f.Person
f.Person = ""
}
if f.Subjects == "" && f.People != "" {
f.Subjects = f.People
f.People = ""
}
return err
}
// Serialize returns a string containing non-empty fields and values of a struct.
func (f *PhotoSearchGeo) Serialize() string {
return Serialize(f, false)
}
// SerializeAll returns a string containing all non-empty fields and values of a struct.
func (f *PhotoSearchGeo) SerializeAll() string {
return Serialize(f, true)
}
func NewGeoSearch(query string) PhotoSearchGeo {
return PhotoSearchGeo{Query: query}
}