MCPcopy Create free account
hub / github.com/perkeep/perkeep / Predicate

Method Predicate

pkg/search/predicate.go:645–672  ·  view source on GitHub ↗
(ctx context.Context, args []string)

Source from the content-addressed store, hash-verified

643}
644
645func (l location) Predicate(ctx context.Context, args []string) (*Constraint, error) {
646 where := args[0]
647 coords := strings.Split(where, ",")
648 if len(coords) != 4 {
649 return nil, fmt.Errorf("got %d coordinates for location area, expected 4", len(coords))
650 }
651 asFloat := make([]float64, 4)
652 for k, v := range coords {
653 coo, err := strconv.ParseFloat(v, 64)
654 if err != nil {
655 return nil, fmt.Errorf("could not convert location area coordinate as a float: %v", err)
656 }
657 asFloat[k] = coo
658 }
659 rects := []geocode.Rect{
660 {
661 NorthEast: geocode.LatLong{
662 Lat: asFloat[0],
663 Long: asFloat[3],
664 },
665 SouthWest: geocode.LatLong{
666 Lat: asFloat[2],
667 Long: asFloat[1],
668 },
669 },
670 }
671 return locationPredicate(ctx, rects)
672}
673
674type hasLocation struct {
675 matchEqual

Callers

nothing calls this directly

Calls 1

locationPredicateFunction · 0.85

Tested by

no test coverage detected