Skip to content

🏠 Explode one-line address strings using Golang

License

Notifications You must be signed in to change notification settings

mattevans/abode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

abode 🏠

GoDoc Build Status Go Report Card license

  • Geocode one-line addresses.
  • Determine timezone information for a given address.
  • This package uses the Google Maps Web Services to geocode the address.
  • You will require the Geocoding API enabled, and optionally the [Timezone API] if you wish to also use Timezone().
  • Remember to set your GOOGLE_MAPS_API_KEY environment variable.

Installation

go get -u github.com/mattevans/abode

Example

Geocode an address:

addr := "193 Rogers Ave, Brooklyn, New York"

address, err := abode.ExplodeWithContext(ctx, addr)
if err != nil {
  return err
}

Returns...

abode.Address{
    AddressLine1:     "193 Rogers Avenue",
    AddressLine2:     "Brooklyn"
    AddressCity:      nil,
    AddressState:     "New York"
    AddressCountry:   "United States"
    AddressZip:       "11216"
    AddressLat:       40.6706073,
    AddressLng:       -73.9530182,
    FormattedAddress: "193 Rogers Ave, Brooklyn, NY 11216, USA",
}

Timezone information for an address:

addr := "193 Rogers Ave, Brooklyn, New York"

address, err := abode.Timezone(ctx, addr)
if err != nil {
  return err
}

Returns...

abode.Location{
    DstOffset:     0,
    RawOffset:     -17762,
    TimeZoneId:    "GMT-04:56:02",
    TimeZoneName:  "America/New_York"
}

Disclaimer

Ensure your end results are used in conjunction with a Google Map to avoid violating the Google Maps API Terms of Service.