Documentation
¶
Overview ¶
Package geocode is a simple interface to github.com/kellydunn/golang-geo.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCacheMiss = errors.New("cache miss")
ErrCacheMiss is returned by Cache.Load when a query string is not cached yet.
Functions ¶
Types ¶
type Geocoder ¶
Geocoder looks up geographical locations.
func Cache ¶
func Cache(gc Geocoder, qc QueryCache) Geocoder
Cache returns a geocoder that caches results from gc.
func Delay ¶
Delay returns a Geocoder that delays requests sent to gc.
It ensures requests are at least d apart.
func Google ¶
Google returns a geocoder using the Google geocode API.
The apikey argument may be empty.
func LatLong ¶
LatLong returns a geocoder that simply decodes strings with latitude and longitude values.
It calls gc when not nil and it cannot decode the latitude and longitude.
func OpenLocationCode ¶
OpenLocationCode returns a Geocoder that understands Open Location Codes.
It uses gc to find the reference of short open location codes, and to decode query strings that are not location codes.
type QueryCache ¶
type QueryCache interface { Load(query string) (Result, error) Store(query string, res Result, err error) error Close() error }
QueryCache caches geocode results.
func LevelDB ¶
func LevelDB(path string) (QueryCache, error)
LevelDB returns a QueryCache stored at path.
type Result ¶
type Result struct {
// Lat, Long is the most relevant position (when available)
// or the centre of the boundary rectangle.
Lat, Long float64
// boundary rectangle
North float64
East float64
South float64
West float64
}
Result is a geocode result.