Documentation ¶
Overview ¶
Package drive impliments an APi client for the 511.org Drive Time API (http://511.org/developer-resources_driving-times-api.asp)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the base interface for accessing the API
func New ¶
New returns a new API client configured to use the supplied APIKey. The client contacts 511.org over HTTPS, which is "safer" than HTTP, but since 511.org uses a certificate which is valid, just not for the hostname we're accessing we have to skip checks on the certificate itself.
func (Client) Destinations ¶
func (c Client) Destinations(fromOrigin int) (*Destinations, error)
Destinations return a list of all allowed Destinations given an Origin Node. This data is cached in the client for 1 hour. Since the data should not change regularly
type Destination ¶
type Destination struct { City string `xml:"city"` MainRoad string `xml:"mainRoad"` CrossRoad string `xml:"crossRoad"` Node int `xml:"node"` // contains filtered or unexported fields }
Destination represents the data structure of a single destination. It carries with it the Node ID for the origin from whence the list was requested for the purposes of the structures Traffic() method.
func (Destination) Traffic ¶
func (d Destination) Traffic() (*Traffic, error)
Traffic returns the traffic conditions between this Destination Node and its oprigin Node
type Destinations ¶
type Destinations struct { OriginNode int `xml:"originNode,attr"` Timestamp time.Time `xml:"timestamp,attr"` Destinations []Destination `xml:"destination"` // contains filtered or unexported fields }
Destinations represents the data returned from a 511.org request for destinations given a specific origin ID
func (Destinations) Get ¶
func (d Destinations) Get(ID int) (*Destination, error)
Get returns a specific Destination by its Node ID, or an error
type Origin ¶
type Origin struct { City string `xml:"city"` MainRoad string `xml:"mainRoad"` CrossRoad string `xml:"crossRoad"` Node int `xml:"node"` // contains filtered or unexported fields }
Origin represents the structure for a single origin returned from 511.org
func (Origin) Destinations ¶
func (o Origin) Destinations() (*Destinations, error)
Destinations returns the list of valid destinations for this specific origin
type Origins ¶
type Origins struct { CacheStamp time.Time `xml:"cachestamp,attr"` Origins []Origin `xml:"origin"` // contains filtered or unexported fields }
Origins represents the response structure returned when requesting a list of origins from 511.org
type Traffic ¶
type Traffic struct { Routes []struct { TravelTime int `xml:"currentTravelTime"` TypicalTravelTime int `xml:"typicalTravelTime"` Miles float64 `xml:"miles"` Segments []string `xml:"segments>segment>road"` Incidents []string `xml:"incidents>incident"` } `xml:"path"` }
Traffic represents the data structure returned from a 511.org pathlist (traffic conditions) API call