Merge "search: has:location works on images and permanodes"

This commit is contained in:
Brad Fitzpatrick 2014-06-15 17:52:01 +00:00 committed by Gerrit Code Review
commit a0caaa3bec
3 changed files with 31 additions and 40 deletions

View File

@ -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),
},
},
@ -590,19 +596,7 @@ var parseExpTests = []parserTestCase{
{
in: "has:location",
want: &Constraint{
Permanode: &PermanodeConstraint{
Attr: "camliContent",
ValueInSet: &Constraint{
File: &FileConstraint{
IsImage: true,
Location: &LocationConstraint{
Any: true,
},
},
},
},
},
want: hasLocationC,
},
{

View File

@ -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

View File

@ -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,
},
}