Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Pan Transit

    Reply
    Page 1 of 2 | 1   2   | Next
    otsaloma | # 1 | 2017-02-15, 23:03 | Report



    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








    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by otsaloma; 2017-12-04 at 21:48.
    The Following 11 Users Say Thank You to otsaloma For This Useful Post:
    dcaliste, eekkelund, iceskateclog, Jordi, juiceme, klinglerware, mosen, OVK, P@t, pichlo, santeira

     
    bomo | # 2 | 2017-09-24, 16:54 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by bomo; 2017-09-24 at 18:46.
    The Following User Says Thank You to bomo For This Useful Post:
    juiceme

     
    otsaloma | # 3 | 2017-09-24, 19:08 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to otsaloma For This Useful Post:
    juiceme

     
    bomo | # 4 | 2017-09-24, 19:10 | Report

    Sorry that I forgot so important information, please search e.g. for "Uniklinik" or "Bushof".

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to bomo For This Useful Post:
    juiceme

     
    otsaloma | # 5 | 2017-09-24, 22:48 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to otsaloma For This Useful Post:
    juiceme

     
    bomo | # 6 | 2017-09-25, 06:31 | Report

    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 ?

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by bomo; 2017-09-25 at 06:39.
    The Following User Says Thank You to bomo For This Useful Post:
    juiceme

     
    bomo | # 7 | 2017-09-25, 18:51 | Report

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

    Originally Posted by
    request = requests.get(baseurl.format(url_i), params = parameter)
    print(request.text)
    and gives (for provider.find_departures([100636]) ):
    Originally Posted by
    [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)

    Originally Posted by
    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]) ):
    Originally Posted by
    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?

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to bomo For This Useful Post:
    juiceme

     
    otsaloma | # 8 | 2017-09-25, 19:52 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to otsaloma For This Useful Post:
    juiceme, sicelo

     
    bomo | # 9 | 2017-10-06, 14:15 | Report

    Are you planning to support routing / journey planning also within pan transit?

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to bomo For This Useful Post:
    juiceme

     
    otsaloma | # 10 | 2017-10-06, 18:29 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to otsaloma For This Useful Post:
    juiceme

     
    Page 1 of 2 | 1   2   | Next
vBulletin® Version 3.8.8
Normal Logout