geo

package
v0.0.0-...-a021e2d Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2017 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package geo provides the ability to calculate duration between two locations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnavailable is returned in cases where the underlying Google Maps API
	// did not return an error, but an unexpected response was received.
	ErrUnavailable = errors.New("duration unavailable")

	// ErrBadLocation is returned in cases where either the 'from' or 'to' address
	// could not be found.
	ErrBadLocation = errors.New("failed to find one of the provided locations")
)
View Source
var (
	// Drive indicates a driving TravelMode.
	Drive = TravelMode(maps.TravelModeDriving)
	// Walk indicates a walking TravelMode.
	Walk = TravelMode(maps.TravelModeWalking)
	// Bike indicates a Biking TravelMode.
	Bike = TravelMode(maps.TravelModeBicycling)
	// Transit indicates public transit as a TravelMode.
	Transit = TravelMode(maps.TravelModeTransit)
)

Functions

This section is empty.

Types

type Communicator

type Communicator interface {
	DistanceMatrix(context.Context, *maps.DistanceMatrixRequest) (*maps.DistanceMatrixResponse, error)
}

Communicator defines a type that can make requests to the Google Maps API.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router provides the ability to calculate travel duration between Routes.

func NewRouter

func NewRouter(apiKey string) (*Router, error)

NewRouter initializes and returns a Router with a Google Maps API key.

func (Router) CurrentLocation

func (r Router) CurrentLocation() (float64, float64, error)

CurrentLocation attempts to use Geolocation to return the Lat/Long of the system device based on it's IP Address.

func (Router) Duration

func (r Router) Duration(from, to string, tm TravelMode) (*time.Duration, error)

Duration returns the time it will take to travel between the From and To address.

type TravelMode

type TravelMode maps.Mode

TravelMode dictates the type of travel when determining the duration.

func (TravelMode) String

func (t TravelMode) String() string

String returns a user friendly string representation of a TravelMode.

Jump to

Keyboard shortcuts

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