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

Latest commit

 

History

History
35 lines (30 loc) · 1.22 KB

README.md

File metadata and controls

35 lines (30 loc) · 1.22 KB

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 ;)