forked from codingsince1985/geo-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeocoder.go
44 lines (38 loc) · 1.14 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
// 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(ctx context.Context, address string) (*Location, error)
ReverseGeocode(ctx context.Context, 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
}
// Logger is an implementation of StdLogger that geo uses to log its messages.
var Logger StdLogger = log.New(io.Discard, "[Geo]", log.LstdFlags)
// StdLogger is a interface for logging libraries.
type StdLogger interface {
Printf(string, ...interface{})
}