OpendataCH / Transport

Swiss public transport API
http://transport.opendata.ch/
MIT License
241 stars 50 forks source link

Connections from lat/lon? #170

Closed samkass closed 7 years ago

samkass commented 7 years ago

I'm trying to use this API with a little app that gets the current location in lat/lon and a destination in lat/lon and gets the public transportation options between them. The Location endpoint supports lat/lon, but near as I can figure out, Connections endpoint only supports stations and addresses? I can't even enter "8942 Oberrieden" as an address (I get a null), i have to go down to the street level.

My workaround is to geocode each lat/lon into the nearest street address, format it in a way the API accepts addresses, and send them. I'm sure the server just geocodes it back again, but I don't see another option.

Am I missing something in the API? Is there no way to specify from/to in coordinates?

helbling commented 7 years ago

This should work at least in the beta branch, just provide lat,lon wherever you would write a stop or address: http://transport-beta.opendata.ch/examples/connections.php?from=47.230432%2C8.837132&to=Effretikon&datetime=

samkass commented 7 years ago

Ah, thank you, that works great on the beta site. It does not work on the non-beta site, but I guess that shouldn't be a problem soon.