Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.
/ bahn.rb Public archive

Show public transportation options from the Deutsche Bahn

License

Notifications You must be signed in to change notification settings

swoker/bahn.rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Load connections for public transportation from the m.bahn.de website.

This is under heavy development. Don't expect a working solution!

Example

require 'bahn.rb'

agent =  Bahn::Agent.new
routes = agent.get_routes(
	"Düsseldorf reisholz s bahn", 	# start address or station
	"Düsseldorf, Heerdter Sandberg 40 ",	# target address or station
	:include_coords => true, # include coordinates of stations
	:limit => 1,	# how many connections?
	:start_type => :station, # :station or :address
	:target_type => :address # :station or :address
	)
# output the connection info
routes.each {|route| route.parts.each {|part| puts part } }

# or with Geocoder
routes = agent.get_routes(
	Geocoder.search("Düsseldorf reisholz s bahn").first, 	# start address or station
	Geocoder.search("Düsseldorf, Heerdter Sandberg 40").first,	# target address or station
	:include_coords => true, # include coordinates of stations
	:limit => 1	# how many connections?
	# you don't need start- and target-type with geocoder :)
	)
# output the connection info
routes.each {|route| route.parts.each {|part| puts part } }

How to help

Feel free to implement some additions, refactor and create a pull request! ... and create tests of course ;)

About

Show public transportation options from the Deutsche Bahn

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages