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.
require 'reittiopas' reittiopas = Reittiopas.new(:username => 'myuser', :password => 'lolcats')
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
maps.google.com/maps?q=60.2528,%2025.02051
Search for a location by KKJ coordinates.
location = reittiopas.location(:x => 2546445, :y => 6675512).first puts "#{location}, #{location.city}"
Otakaari 9, Espoo
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.
gem install reittiopas
or for the latest git:
git clone git://github.com/raneksi/reittiopas.git cd reittiopas rake newb rake install_gem
-
Support for determining the closest stop within radius
-
Routing
(The MIT License)
Copyright © 2010 Raine Virta
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.