geo

package module
v0.0.0-...-b5694e1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GoogleAPIKey = ""

Functions

func SetGoogleAPIKey

func SetGoogleAPIKey(newAPIKey string)

func SetGoogleGeocodeURL

func SetGoogleGeocodeURL(newGeocodeURL string)

Note: In the next major revision (1.0.0), it is planned

That Geocoders should adhere to the `geo.Geocoder`
interface and provide versioning of APIs accordingly.

Sets the base URL for the Google Geocoding API.

Types

type Geocoder

type Geocoder interface {
	Geocode(query string) (*Point, error)
	ReverseGeocode(p *Point) (string, error)
}

This interface describes a Geocoder, which provides the ability to Geocode and Reverse Geocode geographic points of interest. Geocoding should accept a string that represents a street address, and returns a pointer to a Point that most closely identifies it. Reverse geocoding should accept a pointer to a Point, and return the street address that most closely represents it.

type GoogleGeocoder

type GoogleGeocoder struct {
	HttpClient *http.Client
}

This struct contains all the funcitonality of interacting with the Google Maps Geocoding Service

func (*GoogleGeocoder) Geocode

func (g *GoogleGeocoder) Geocode(address string) (*Point, error)

Geocode: Geocodes the passed in query string and returns a pointer to a new Point struct. Returns an error if the underlying request cannot complete.

func (*GoogleGeocoder) Request

func (g *GoogleGeocoder) Request(params string) ([]byte, error)

Request Issues a request to the google geocoding service and forwards the passed in params string as a URL-encoded entity. Returns an array of byes as a result, or an error if one occurs during the process. Note: Since this is an arbitrary request, you are responsible for passing in your API key if you want one.

func (*GoogleGeocoder) ReverseGeocode

func (g *GoogleGeocoder) ReverseGeocode(p *Point) (string, error)

ReverseGeocode: Reverse geocodes the pointer to a Point struct and returns the first address that matches or returns an error if the underlying request cannot complete.

Jump to

Keyboard shortcuts

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