geocode

package
v0.0.0-...-bb15e6e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package geocode handles mapping user-entered locations into lat/long polygons.

Index

Constants

This section is empty.

Variables

View Source
var AltLookupFn func(ctx context.Context, address string) ([]Rect, error)

AltLookupFn provides alternative geocode lookup in tests.

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 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 when Lookup is not being called.

View Source
var ErrNoGoogleKey = errors.New("geocode: Google API key not configured, using OpenStreetMap; see https://perkeep.org/doc/geocoding")

Functions

func GetAPIKey

func GetAPIKey() (string, error)

GetAPIKey returns the Google geocoding API key stored in the Perkeep configuration directory as google-geocode.key.

func GetAPIKeyPath

func GetAPIKeyPath() (string, error)

GetAPIKeyPath returns the file path to the Google geocoding API key.

Types

type LatLong

type LatLong struct {
	Lat  float64 `json:"lat"`
	Long float64 `json:"lng"`
}

type Rect

type Rect struct {
	NorthEast LatLong `json:"northeast"`
	SouthWest LatLong `json:"southwest"`
}

func Lookup

func Lookup(ctx context.Context, address string) ([]Rect, error)

Lookup returns rectangles for the given address. Currently the only implementation is the Google geocoding service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL