Reittiopas
DESCRIPTION
Reittiopas is a Ruby library for accessing the Reittiopas Developer API.
Requires an account to the service that can be requested through the account request page.
SYNOPSIS
require 'reittiopas'
reittiopas = Reittiopas.new(:username => 'myuser', :password => 'lolcats')
Geocoding
Search for location by keyword tee.
location = reittiopas.location('tee').first
puts "#{location}, #{location.city}"
puts "http://maps.google.com/maps?q=#{URI.escape location.coordinates[:wgs]}"
=> Teeripuisto, Helsinki
=> http://maps.google.com/maps?q=60.2528,%2025.02051
Reverse geocoding
Search for a location by KKJ coordinates.
location = reittiopas.location(:x => 2546445, :y => 6675512).first
puts "#{location}, #{location.city}"
=> Otakaari 9, Espoo
Routing
Search for routes between two locations: show 3 routes and do not use metro.
from = reittiopas.locations('mannerheimintie 5').first
to = reittiopas.location('kallion kirjasto').first
routes = reittiopas.routing(from, to, {"show" => 3, "use_metro" => 0})
routes.each do |route|
puts "#{route.distance} #{route.time}"
puts "Lines: "
route.lines.each do |line|
puts "#{line.code} starts from: #{line.stops.first.code}"
end
end
Options for routing are passed to Reittiopas. See Reittiopas developer API for the possible options.
INSTALLATION
gem install reittiopas
or to use latest upstream:
git clone git://github.com/raneksi/reittiopas.git
cd reittiopas
rake newb
rake install_gem
REQUIREMENTS
- Nokogiri
- Addressable
TODO
- Support for determining the closest stop within radius
LICENSE
(The MIT License)
Copyright (c) 2010 - 2011:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.