-
Notifications
You must be signed in to change notification settings - Fork 69
/
geocoder.go
48 lines (41 loc) · 1.35 KB
/
geocoder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Package geo is a generic framework to develop geocode/reverse geocode clients
package geo
import (
"context"
"io"
"log"
)
// Geocoder can look up (lat, long) by address and address by (lat, long)
type Geocoder interface {
Geocode(address string) (*Location, error)
GeocodeWithContext(ctx context.Context, address string) (*Location, error)
ReverseGeocode(lat, lng float64) (*Address, error)
}
// Location is the output of Geocode
type Location struct {
Lat, Lng float64
}
// Address is returned by ReverseGeocode.
// This is a structured representation of an address, including its flat representation
type Address struct {
FormattedAddress string
Street string
HouseNumber string
Suburb string
Postcode string
State string
StateCode string
StateDistrict string
County string
Country string
CountryCode string
City string
}
// ErrLogger is an implementation of StdLogger that geo uses to log its error messages.
var ErrLogger StdLogger = log.New(io.Discard, "[Geo][Err]", log.LstdFlags)
// DebugLogger is an implementation of StdLogger that geo uses to log its debug messages.
var DebugLogger StdLogger = log.New(io.Discard, "[Geo][Debug]", log.LstdFlags)
// StdLogger is a interface for logging libraries.
type StdLogger interface {
Printf(string, ...interface{})
}