mirror of https://github.com/perkeep/perkeep.git
Merge "internal/geocode: change Lookup behavior wrt to AltLookupFn"
This commit is contained in:
commit
11dfa3850d
|
@ -49,11 +49,11 @@ type Rect struct {
|
|||
|
||||
// AltLookupFn provides alternative geocode lookup in tests.
|
||||
//
|
||||
// If AltLookupFn is not nil, Lookup calls AltLookupFn first,
|
||||
// and returns the results unless it is (nil, nil).
|
||||
// If AltLookupFn is not nil, Lookup returns the results of
|
||||
// the AltLookupFn call.
|
||||
//
|
||||
// Lookup performs its standard lookup using its cache
|
||||
// and the Google geocoding serice if AltLookupFn is nil,
|
||||
// and the Google geocoding service if AltLookupFn is nil,
|
||||
// or it returns (nil, nil) for the address being looked up.
|
||||
//
|
||||
// It's up to the caller to change AltLookupFn only
|
||||
|
@ -99,10 +99,7 @@ var ErrNoGoogleKey = errors.New("geocode: geocoding is not configured; see https
|
|||
// implementation is the Google geocoding service.
|
||||
func Lookup(ctx context.Context, address string) ([]Rect, error) {
|
||||
if AltLookupFn != nil {
|
||||
r, err := AltLookupFn(ctx, address)
|
||||
if r != nil || err != nil {
|
||||
return r, err
|
||||
}
|
||||
return AltLookupFn(ctx, address)
|
||||
}
|
||||
|
||||
mu.RLock()
|
||||
|
|
|
@ -48,3 +48,5 @@ func (s *Handler) ExportGetPermanodeLocation(ctx context.Context, permaNode blob
|
|||
func ExportBestByLocation(res *SearchResult, loc map[blob.Ref]camtypes.Location, limit int) {
|
||||
bestByLocation(res, loc, limit)
|
||||
}
|
||||
|
||||
var ExportUitdamLC = uitdamLC
|
||||
|
|
|
@ -1904,6 +1904,7 @@ func init() {
|
|||
cacheGeo("mexico", 32.7187629, -86.7105711, 14.5345486, -118.3649292)
|
||||
cacheGeo("brazil", 5.2717863, -29.3448224, -33.7506241, -73.98281709999999)
|
||||
cacheGeo("argentina", -21.7810459, -53.6374811, -55.05727899999999, -73.56036019999999)
|
||||
cacheGeo("Uitdam", ExportUitdamLC.North, ExportUitdamLC.East, ExportUitdamLC.South, ExportUitdamLC.West)
|
||||
|
||||
geocode.AltLookupFn = func(ctx context.Context, addr string) ([]geocode.Rect, error) {
|
||||
r, ok := altLocCache[addr]
|
||||
|
|
Loading…
Reference in New Issue