Inspired by Carmen, Ausburbs provides data for all suburbs across Australia. In additional to suburb names and postcodes, it also includes the latitudes and longitudes of each suburb.
Just include it in your Gemfile:
gem 'ausburbs'
The interface is pretty simple and works as follows:
Ausburbs.state_names
# returns ['ACT', 'NSW', 'NT', 'QLD', 'SA', 'TAS', 'VIC', 'WA']
Ausburbs.states
# returns a list of Ausburb::State objects
Ausburbs.states.first.name # => 'ACT'
Ausburbs.states.last.suburbs.count # => 1762
Ausburbs.state('NSW')
# returns an Ausburb::State object
Ausburbs.state('ACT').suburbs.count # => 136
Each Ausburb::Suburb object has a name
, postcode
, state
,
latitude
and longitude
parameter.
suburb = Ausburbs.state('NSW').suburbs.first
suburb.name # => "SYDNEY"
suburb.postcode # => "1001"
suburb.state # => "NSW"
suburb.latitude # => -33.764883
suburb.longitude # => 151.268071
As always, pull requests are always welcome. If you have any issues or feature requests, please open an issue.