mirror of https://github.com/perkeep/perkeep.git
Merge "search: has:location works on images and permanodes"
This commit is contained in:
commit
a0caaa3bec
|
@ -61,6 +61,22 @@ var attrgorunC = &Constraint{
|
|||
},
|
||||
}
|
||||
|
||||
var hasLocationC = orConst(&Constraint{
|
||||
Permanode: &PermanodeConstraint{
|
||||
Attr: "camliContent",
|
||||
ValueInSet: &Constraint{
|
||||
File: &FileConstraint{
|
||||
IsImage: true,
|
||||
Location: &LocationConstraint{Any: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, &Constraint{
|
||||
Permanode: &PermanodeConstraint{
|
||||
Location: &LocationConstraint{Any: true},
|
||||
},
|
||||
})
|
||||
|
||||
var parseExpressionTests = []struct {
|
||||
name string
|
||||
in string
|
||||
|
@ -263,17 +279,7 @@ var parseExpressionTests = []struct {
|
|||
{
|
||||
in: "has:location",
|
||||
want: &SearchQuery{
|
||||
Constraint: andConst(skiphiddenC, &Constraint{
|
||||
Permanode: &PermanodeConstraint{
|
||||
Attr: "camliContent",
|
||||
ValueInSet: &Constraint{
|
||||
File: &FileConstraint{
|
||||
IsImage: true,
|
||||
Location: &LocationConstraint{Any: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
Constraint: andConst(skiphiddenC, hasLocationC),
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -589,20 +595,8 @@ var parseExpTests = []parserTestCase{
|
|||
},
|
||||
|
||||
{
|
||||
in: "has:location",
|
||||
want: &Constraint{
|
||||
Permanode: &PermanodeConstraint{
|
||||
Attr: "camliContent",
|
||||
ValueInSet: &Constraint{
|
||||
File: &FileConstraint{
|
||||
IsImage: true,
|
||||
Location: &LocationConstraint{
|
||||
Any: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
in: "has:location",
|
||||
want: hasLocationC,
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -485,7 +485,7 @@ func newLocation() keyword {
|
|||
}
|
||||
|
||||
func (l location) Description() string {
|
||||
return "uses the EXIF GPS fields to match images having a location near\n" +
|
||||
return "matches images and permanodes having a location near\n" +
|
||||
"the specified location. Locations are resolved using\n" +
|
||||
"maps.googleapis.com. For example: loc:\"new york, new york\" "
|
||||
}
|
||||
|
@ -535,18 +535,25 @@ func newHasLocation() keyword {
|
|||
}
|
||||
|
||||
func (h hasLocation) Description() string {
|
||||
return "image has a location (GPSLatitude and GPSLongitude can be\n" +
|
||||
return "matches images and permanodes that have a location (GPSLatitude and GPSLongitude can be\n" +
|
||||
"retrieved from the image's EXIF tags)."
|
||||
}
|
||||
|
||||
func (h hasLocation) Predicate(ctx *context.Context, args []string) (*Constraint, error) {
|
||||
c := permOfFile(&FileConstraint{
|
||||
fileLoc := permOfFile(&FileConstraint{
|
||||
IsImage: true,
|
||||
Location: &LocationConstraint{
|
||||
Any: true,
|
||||
},
|
||||
})
|
||||
return c, nil
|
||||
permLoc := &Constraint{
|
||||
Permanode: &PermanodeConstraint{
|
||||
Location: &LocationConstraint{
|
||||
Any: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
return orConst(fileLoc, permLoc), nil
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
|
|
@ -493,17 +493,7 @@ var keywordTests = []keywordTestcase{
|
|||
|
||||
{
|
||||
object: newHasLocation(),
|
||||
want: &Constraint{
|
||||
Permanode: &PermanodeConstraint{
|
||||
Attr: "camliContent",
|
||||
ValueInSet: &Constraint{
|
||||
File: &FileConstraint{
|
||||
IsImage: true,
|
||||
Location: &LocationConstraint{Any: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: hasLocationC,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue