Skip to content

nzherald/nzta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NZTA

Work in Progress

You will need to request an API username and password from NZTA by completing this form:

https://www.nzta.govt.nz/traffic-and-travel-information/infoconnect-section-page/infoconnect-access/

Installation

Add this line to your application's Gemfile:

gem 'nzta'

And then execute:

$ bundle

Or install it yourself as:

$ gem install nzta

Usage

Either set environment variables NZTA_API_USERNAME and NZTA_API_PASSWORD and initialize the client with no arguments:

  client = NZTA::Client.new

or pass them through to the initialiser:

  client = NZTA::Client.new(username: 'abc', password: 'xyz')

To get an overview of traffic conditions:

  client.traffic_conditions

Which returns broad measures of congestion ('Free flow', 'Moderate', 'Heavy').

The segment APIs give you more granular data, such as the speed of traffic moving on that segment and average occupancy of each vehicle.

The key Auckland segments have an id of 5

  client.segments(5)

If you would like to map these segments you can receive a GeoJSON representation with:

  client.segment_geojson(5)

Example output: http://bl.ocks.org/d/be62de78f8c14230f2d95bf987363a44

Work in progress

  client.treis

Currently the XML representation of the TREIS endpoint. WIP.

Auckland Traffic Segments

Development

If you clone this repository you can experiment with adding a .env file with your NZTA credentials and run bin/console

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

  1. Fork it ( https://github.com/nzherald/nzta/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Ruby gem for the NZTA InfoConnect API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published