(ctx context.Context, fileRef blob.Ref)
| 1493 | } |
| 1494 | |
| 1495 | func (x *Index) GetFileLocation(ctx context.Context, fileRef blob.Ref) (camtypes.Location, error) { |
| 1496 | if x.corpus != nil { |
| 1497 | lat, long, ok := x.corpus.FileLatLong(fileRef) |
| 1498 | if !ok { |
| 1499 | return camtypes.Location{}, os.ErrNotExist |
| 1500 | } |
| 1501 | // TODO(mpl): Brad says to move this check lower, in corpus func and/or when building corpus from index rows. |
| 1502 | if math.IsNaN(long) || math.IsNaN(lat) { |
| 1503 | return camtypes.Location{}, fmt.Errorf("latitude or longitude in corpus for %v is NaN. Reindex to fix it", fileRef) |
| 1504 | } |
| 1505 | return camtypes.Location{Latitude: lat, Longitude: long}, nil |
| 1506 | } |
| 1507 | fi, err := x.GetFileInfo(ctx, fileRef) |
| 1508 | if err != nil { |
| 1509 | return camtypes.Location{}, err |
| 1510 | } |
| 1511 | it := x.queryPrefixString(keyEXIFGPS.Key(fi.WholeRef.String())) |
| 1512 | defer closeIterator(it, &err) |
| 1513 | if !it.Next() { |
| 1514 | return camtypes.Location{}, os.ErrNotExist |
| 1515 | } |
| 1516 | |
| 1517 | var lat, long float64 |
| 1518 | key, v := it.Key(), it.Value() |
| 1519 | pipe := strings.Index(v, "|") |
| 1520 | if pipe < 0 { |
| 1521 | return camtypes.Location{}, fmt.Errorf("index: bogus key %q = %q", key, v) |
| 1522 | } |
| 1523 | lat, err = strconv.ParseFloat(v[:pipe], 64) |
| 1524 | if err != nil { |
| 1525 | return camtypes.Location{}, fmt.Errorf("index: bogus value at position 0 in key %q = %q", key, v) |
| 1526 | } |
| 1527 | long, err = strconv.ParseFloat(v[pipe+1:], 64) |
| 1528 | if err != nil { |
| 1529 | return camtypes.Location{}, fmt.Errorf("index: bogus value at position 1 in key %q = %q", key, v) |
| 1530 | } |
| 1531 | if math.IsNaN(long) || math.IsNaN(lat) { |
| 1532 | return camtypes.Location{}, fmt.Errorf("latitude or longitude in index for %v is NaN. Reindex to fix it", fileRef) |
| 1533 | } |
| 1534 | return camtypes.Location{Latitude: lat, Longitude: long}, nil |
| 1535 | } |
| 1536 | |
| 1537 | func (x *Index) EdgesTo(ref blob.Ref, opts *camtypes.EdgesToOpts) (edges []*camtypes.Edge, err error) { |
| 1538 | it := x.queryPrefix(keyEdgeBackward, ref) |
nothing calls this directly
no test coverage detected