Notices


Reply
Thread Tools
otsaloma's Avatar
Posts: 141 | Thanked: 1,530 times | Joined on May 2011 @ Finland
#1


Pan Transit is an application for Sailfish OS to view departures from public transport stops. It is designed to support multiple different providers (i.e. cities/regions). Currently supported are Helsinki Region Transport (HSL), Finnish Transport Agency, Transport for London and ASEAG in Aachen, Germany.

The dynamic plugin architecture should make it fairly easy for anyone with basic Python programming skills to add support for a new region. Providers only need to make API calls and transform that data to a format that Pan Transit understands and can display in its standard UI. Documentation is available at GitHub.

Please note that I do not plan to write providers for different regions myself, but will review and accept contributions from the community. Also, moderate suggestions to generalise the UI will be considered, but for very particular use cases, you might still be better of writing your own stand-alone app.

Download at OpenRepos or the Jolla store.

Source code and issue tracker at GitHub. Translations at Transifex.

Donations appreciated: paypal.me/otsaloma








Last edited by otsaloma; 2017-12-04 at 21:48.
 

The Following 11 Users Say Thank You to otsaloma For This Useful Post:
Posts: 68 | Thanked: 147 times | Joined on Dec 2016
#2
Dear otsaloma,

I am currently working on a provider for pan transit but have some issues with setting it up. As you wrote in the README on github, I debugged the code using on my PC using the python scripts (where it gives correct results, IMHO). However, after copying the files to "/home/nemo/.local/share/harbour-pan-transit/providers" and selecting the new provider in the settings the search is not given results.

Is there a way to debug this from within the app or making it more verbose? What steps would you recommend?

Thanks!

Edit: I now found out that I need to start pan transit via "/usr/bin/sailfish-qml harbour-pan-transit" which gives me the python output.
Now, I could fix one bug such that I can now search for stops, but whenever I want to see the departures of that stop none are listed (I made my python script a little bit verbose and can see that data exists). Is there a way to make pan transit more verbose to see whats going on there?

Edit2: I created a fork (sorry for the horrible code and the fact that it currently needs python3-requests). I would be very glad if you could have a look at it.

Last edited by bomo; 2017-09-24 at 18:46.
 

The Following User Says Thank You to bomo For This Useful Post:
otsaloma's Avatar
Posts: 141 | Thanked: 1,530 times | Joined on May 2011 @ Finland
#3
Originally Posted by bomo View Post
Edit2: I created a fork (sorry for the horrible code and the fact that it currently needs python3-requests). I would be very glad if you could have a look at it.
I'll take a look.

Requests is not cool indeed, but for testing, what's the easiest way for me to get requests on the device?
 

The Following User Says Thank You to otsaloma For This Useful Post:
Posts: 68 | Thanked: 147 times | Joined on Dec 2016
#4
Sorry that I forgot so important information, please search e.g. for "Uniklinik" or "Bushof".
 

The Following User Says Thank You to bomo For This Useful Post:
otsaloma's Avatar
Posts: 141 | Thanked: 1,530 times | Joined on May 2011 @ Finland
#5
Divide the times by 1000. The ones returned by the API seem to be milliseconds, we need seconds. I don't really know what exactly happens when you feed the formatting and filtering functions milliseconds, but correcting that seemed to fix it, I saw departures.
 

The Following User Says Thank You to otsaloma For This Useful Post:
Posts: 68 | Thanked: 147 times | Joined on Dec 2016
#6
Originally Posted by otsaloma View Post
Divide the times by 1000. The ones returned by the API seem to be milliseconds, we need seconds. I don't really know what exactly happens when you feed the formatting and filtering functions milliseconds, but correcting that seemed to fix it, I saw departures.
Thanks!! Is there anything in the code (apart from requests) that I need to change before it can be included on your builds?

For find_nearby I don't have an implementation because I don't know how to get it from the API. Would it be possible to remove this option depending on the selected provider ?

Last edited by bomo; 2017-09-25 at 06:39.
 

The Following User Says Thank You to bomo For This Useful Post:
Posts: 68 | Thanked: 147 times | Joined on Dec 2016
#7
I am currently trying to get rid of request but I'm (again) struggling with pan.http.post et. al.

The current requests code looks like (in find_departures):

request = requests.get(baseurl.format(url_i), params = parameter)
print(request.text)
and gives (for provider.find_departures([100636]) ):
[4,"2.0",1506365354592]
[3,"1@2017-09-20.14:18:29"]
[1,"Hainbuchenstraße","100636","",0,50.77811,6.0626 ,20,"33","33",1,"Vaals Busstation","Vaals Busstation","340","25000319020001",1506366480000]
[1,"Hainbuchenstraße","100636","",0,50.77811,6.0626 ,15,"33","33",1,"Aachen Fuchserde","Aachen Fuchserde","519","25000080013001",1506367166000]
[1,"Hainbuchenstraße","100636","",0,50.77811,6.0626 ,20,"33","33",1,"Vaals Busstation","Vaals Busstation","382","25000230013001",1506368220000]
[1,"Hainbuchenstraße","100636","",0,50.77811,6.0626 ,15,"33","33",1,"Aachen Fuchserde","Aachen Fuchserde","340","25000319021001",1506368760000]
[1,"Hainbuchenstraße","100636","",0,50.77811,6.0626 ,20,"33","33",1,"Vaals Busstation","Vaals Busstation","293","25000317023001",1506370020000]
[1,"Hainbuchenstraße","100636","",0,50.77811,6.0626 ,15,"33","33",1,"Aachen Fuchserde","Aachen Fuchserde","0","25000230014001",1506370560000]
[1,"Hainbuchenstraße","100636","",0,50.77811,6.0626 ,20,"33","33",1,"Vaals Busstation","Vaals Busstation","0","25000316023001",1506371820000]
[1,"Hainbuchenstraße","100636","",0,50.77811,6.0626 ,15,"33","33",1,"Aachen Fuchserde","Aachen Fuchserde","0","25000317024001",1506372360000]
The pan.http part looks like (in find_departures)

parameter = {'ReturnList': returnlist, 'StopID': ','.join(map(str, stops)) }
body = urllib.parse.urlencode(parameter)
request = pan.http.post_json(baseurl.format(url_i), body)
print(request)

and gives (for provider.find_departures([100636]) ):
POST http://ivu.aseag.de/interfaces/ura/instant_V2
Establishing connection to ivu.aseag.de
[4, '2.0', 1506365172212]
To me it looks like I only get the first row if I use pan.http.post or pan.http.post_json or am I doing something wrong?
 

The Following User Says Thank You to bomo For This Useful Post:
otsaloma's Avatar
Posts: 141 | Thanked: 1,530 times | Joined on May 2011 @ Finland
#8
Originally Posted by bomo View Post
Is there anything in the code (apart from requests) that I need to change before it can be included on your builds?
Please adhere to PEP8, the Python style guide and the existing code base style. Four spaces for indentation, max. 79 characters per line, double quotes for strings. After that you can file a pull request on GitHub, once I see the final code, there might some details to iron out before merging, but it's better to discuss that on GitHub, where I can comment on parts of the code.

Originally Posted by bomo View Post
For find_nearby I don't have an implementation because I don't know how to get it from the API. Would it be possible to remove this option depending on the selected provider ?
That's all right, just have find_nearby_stops return a blank list. I'm unlikely to conditionally remove it from the UI, because I think almost all providers do support a nearby search.

Originally Posted by bomo View Post
I am currently trying to get rid of request but I'm (again) struggling with pan.http.post
Why are you using post? Use get!

https://developer.mozilla.org/en-US/...b/HTTP/Methods

What you likely want is

Code:
# For API endpoints that return JSON:
result = pan.http.get_json(url)

# For API endpoints that return text:
result = pan.http.get(url, encoding="utf_8")
Please take a look at the TfL provider code for an example. The essential parts of the code are very brief and should be understandable. It also shows how to constuct URLs (format_url) and how to quote search strings (urllib.parse.quote).

https://github.com/otsaloma/pan-tran...oviders/tfl.py
 

The Following 2 Users Say Thank You to otsaloma For This Useful Post:
Posts: 68 | Thanked: 147 times | Joined on Dec 2016
#9
Are you planning to support routing / journey planning also within pan transit?
 

The Following User Says Thank You to bomo For This Useful Post:
otsaloma's Avatar
Posts: 141 | Thanked: 1,530 times | Joined on May 2011 @ Finland
#10
Originally Posted by bomo View Post
Are you planning to support routing / journey planning also within pan transit?
While it would be nice to have routing in the same app, I don't want to duplicate code -- we already have routing in Poor Maps with a similar Python plugin interface. If want to see how it works, take a look at the Digitransit router, which is a Finnish (esp. Helsinki) public transport router.

https://github.com/otsaloma/poor-map...master/routers
 

The Following User Says Thank You to otsaloma For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 21:59.