FahrplanDatenGarten / pyhafas

A python client for the HAFAS (HaCon Fahrplan Auskunfts System)
https://pyhafas.readthedocs.io
MIT License
46 stars 19 forks source link

Coordinate to Coordinate routing for HAFAS #40

Open 1Maxnet1 opened 8 months ago

1Maxnet1 commented 8 months ago

Do you know whether it is possible to have a routing request from one coordinate to another? So instead of providing start and destination as a station, providing a geo-point?

sn0opy commented 7 months ago

You could have a look at #42. It should makes things easier to calculate a journey between two geo points.

1Maxnet1 commented 7 months ago

You could have a look at #42. It should makes things easier to calculate a journey between two geo points.

Thanks a lot! However this seems not to be suiting my use-case. The aim would be to compare HAFAS to e.g. a MOTIS or OTP Server. And they can do intermodal routing (aka having two Geo-Points and let the server decide to which stop I should go or even drive by bike). The nearby request can be used to implement this "by hand" but would require a lot of post-processing. So the questions arises if the HFAS servers can already to that natively (which would allow for a fair comparison).

Nevertheless I really appreciate your contribution :)

sn0opy commented 7 months ago

I was looking into it a bit deeper, since the frontends provide a button to locate the closest station via GPS (or any alternative, that provides latitude and longitude). It looks like you always have to do some sort for request inbetween. The standard frontends seem to use the LocMatch request for that, which is already implemented via locations() but requires some slight updates for x/y coordinates to work

1Maxnet1 commented 5 months ago

I was looking into it a bit deeper, since the frontends provide a button to locate the closest station via GPS (or any alternative, that provides latitude and longitude). It looks like you always have to do some sort for request inbetween. The standard frontends seem to use the LocMatch request for that, which is already implemented via locations() but requires some slight updates for x/y coordinates to work

Thanks for the ideas, I chatted with @derhuerst , who claims that there is also a support for requests including GeoPoints (maybe not for all instances though). When I find some time, I will double check the implementation of https://invent.kde.org/libraries/kpublictransport and whether they support it. Then we might get the required info to implement it for pyhafas as well.

derhuerst commented 4 months ago

In hafas-client, the equivalent implementation is here:

https://github.com/public-transport/hafas-client/blob/6.3.0/index.js#L116-L117 https://github.com/public-transport/hafas-client/blob/6.3.0/format/location.js#L12-L14 https://github.com/public-transport/hafas-client/blob/6.3.0/format/address.js#L9-L22

Years ago, when I implemented this, it seemed like HAFAS expects an address (O parameter) – which I'd assume they usually expect to be a street name –, but AFAIR you can put anything in there, as long as the field is present, because the coordinates are the key pieces of information.