All Projects â†’ kiliankoe â†’ dvbpy

kiliankoe / dvbpy

Licence: MIT license
🚋 Query Dresden's public transport system for current bus- and tramstop data in python

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to dvbpy

DVB
🚆 Query Dresden's public transport system for current bus- and tramstop data in swift
Stars: ✭ 22 (-42.11%)
Mutual labels:  public-transportation, dvb, vvo, dresden
dvbjs
🚊 Query Dresden's public transport system for current bus- and tramstop data in node
Stars: ✭ 38 (+0%)
Mutual labels:  public-transportation, dvb, vvo, dresden
Node Gtfs
Import GTFS transit data into SQLite and query routes, stops, times, fares and more.
Stars: ✭ 323 (+750%)
Mutual labels:  public-transportation
Busrouter Sg
BusRouter SG: Singapore Bus Routes Explorer
Stars: ✭ 238 (+526.32%)
Mutual labels:  public-transportation
Bookingapi
A simple API to book tickets for public transport in Switzerland.
Stars: ✭ 15 (-60.53%)
Mutual labels:  public-transportation
Onebusaway Android
The official Android/Fire Phone app for OneBusAway
Stars: ✭ 388 (+921.05%)
Mutual labels:  public-transportation
Vbb Modules
List of JavaScript modules for Berlin & Brandenburg public transport.
Stars: ✭ 47 (+23.68%)
Mutual labels:  public-transportation
Public Transport Enabler
Unleash public transport data in your Java project.
Stars: ✭ 264 (+594.74%)
Mutual labels:  public-transportation
osmot
Preprocessor for make public transit maps from Openstreetmap data
Stars: ✭ 14 (-63.16%)
Mutual labels:  public-transportation
Aseag Python
Das sollte mal zu einer vernünftigen API-Implementation werden, ist derzeit aber einfach nur ein Client
Stars: ✭ 11 (-71.05%)
Mutual labels:  public-transportation
Onebusaway Application Modules
The core OneBusAway application suite.
Stars: ✭ 174 (+357.89%)
Mutual labels:  public-transportation
Prague Public Transport
Gives you times of the next trams around your location in Prague.
Stars: ✭ 11 (-71.05%)
Mutual labels:  public-transportation
Transportr
Free Public Transport Assistant without Ads or Tracking
Stars: ✭ 678 (+1684.21%)
Mutual labels:  public-transportation
Friendly Public Transport Format
A format for APIs, libraries and datasets containing and working with public transport data.
Stars: ✭ 69 (+81.58%)
Mutual labels:  public-transportation
Navitia
The open source software to build cool stuff with locomotion
Stars: ✭ 352 (+826.32%)
Mutual labels:  public-transportation
mobivoc
A vocabulary for future-oriented mobility solutions and value-added services supporting them.
Stars: ✭ 27 (-28.95%)
Mutual labels:  public-transportation
Graphhopper
Open source routing engine for OpenStreetMap. Use it as Java library or standalone web server.
Stars: ✭ 3,457 (+8997.37%)
Mutual labels:  public-transportation
Openmetromaps
Main repository for OpenMetroMaps
Stars: ✭ 27 (-28.95%)
Mutual labels:  public-transportation
European Transport Modules
[DISCONTINUED in favour of public-transport-operators] Collection of european transport JavaScript modules.
Stars: ✭ 9 (-76.32%)
Mutual labels:  public-transportation
node-dvbtee
MPEG2 transport stream parser for Node.js with support for television broadcast PSIP tables and descriptors
Stars: ✭ 24 (-36.84%)
Mutual labels:  dvb

dvbpy

An unofficial python module giving you a few options to query a collection of publicly accessible API methods for Dresden's public transport system.

Want something like this for another language, look no further 🙂

The documentation is located here.

Get dvbpy from PyPi :)

pip install dvb

And then just import it.

import dvb

Monitor a single stop

Monitor a single stop to see every bus or tram leaving this stop after the specified time offset.

import dvb

stop = 'Helmholtzstraße'
time_offset = 0 # how many minutes in the future, 0 for now
num_results = 2
city = 'Dresden'

dvb.monitor(stop, time_offset, num_results, city)
[{
    'line': '85',
    'direction': 'Striesen',
    'arrival': 5
},
{
    'line': '85',
    'direction': 'Löbtau Süd',
    'arrival': 7
}]

You can also call monitor() without city, num_results or time_offset. City will default to Dresden.

Find routes

Query the server for possible routes from one stop to another. Returns multiple possible trips, the bus-/tramlines to be taken, the single stops, their arrival and departure times and their GPS coordinates.

import dvb
import time

origin = 'Zellescher Weg'
city_origin = 'Dresden'
destination = 'Postplatz'
city_destination = 'Dresden'
time = int(time.time()) # a unix timestamp is wanted here
deparr = 'dep'  # set to 'arr' for arrival time, 'dep' for departure time

dvb.route(origin, destination, city_origin, city_destination, time, deparr)
{
    'trips': [{
        'interchange': 0,
        'nodes': [{
            'line': '11',
            'mode': 'Straßenbahn',
            'direction': 'Dresden Bühlau Ullersdorfer Platz',
            'path': [
                [13.745754, 51.02816],
                [13.745848, 51.028393],
                ...
            ],
            'departure': {
                'time': '18:01',
                'stop': 'Zellescher Weg',
                'coords': '13745754,51028160'
            },
            'arrival': {
                'time': '18:14',
                'stop': 'Postplatz',
                'coords': '13733717,51050544'
            }
        }],
        'duration': '00:13',
        'departure': '18:01',
        'arrival': '18:14'
    },
    ...
    }],
    'origin': 'Dresden, Zellescher Weg',
    'destination': 'Dresden, Postplatz'
}

Everything besides origin and destination is optional and only needs to be included if necessary. City for origin and destination defaults to Dresden, time to now and is handled as the departure time.

The path property contains a list consisting of all the coordinates describing the path of this node. Useful for example if you want to draw it on a map.

If you use recommendations for interchanges, each of the nodes (except the last one)in every trip will have a recommendation field. The field will tell where you should enter this route to get an optimal interchange experience. This is of course only if there are any interchanges. The positions are 0 for front, 1 for middle and 2 for back. If there are no recommendations available None is returned.

Find stops by name

Search for a single stop in the network of the DVB.

import dvb

dvb.find('zellesch')
[{
    'name': 'Zellescher Weg',
    'city': 'Dresden',
    'coords': [51.028366, 13.745847]
}]

The fields city and coords are optional as they are not available for every stop. So don't forget to check for their existence first.

[stop for stop in dvb.find('Post') if 'city' in stop if stop['city'] == 'Dresden']

Find other POIs with coordinates

Search for all kinds of POIs inside a given square.

import dvb

southwest_lat = 51.04120
southwest_lng = 13.70106
northeast_lat = 51.04615
northeast_lng = 13.71368

pintypes = 'stop'
# can be poi, platform, rentabike, ticketmachine, parkandride, carsharing or stop

dvb.pins(southwest_lat, southwest_lng, northeast_lat, northeast_lng, pintypes)

pintypes defaults to 'stop' if no other input is given.

[
   {
      "connections":"1:7~8~9~10~11~12",
      "coords":{
         "lat":51.04373256804444,
         "lng":13.70625638110702
      },
      "id":33000143,
      "name":"Saxoniastraße"
   },
   {
      "connections":"2:61~90",
      "coords":{
         "lat":51.04159705545878,
         "lng":13.7053650905211
      },
      "id":33000700,
      "name":"Ebertplatz"
   },
   {
      "connections":"1:6~7~8~9~10~11~12#2:61~63~90~A#3:333",
      "coords":{
         "lat":51.04372841952444,
         "lng":13.703461228676069
      },
      "id":33000144,
      "name":"Tharandter Straße"
   }, ...
]

Look up coordinates for POI

Find the coordinates for a given POI id.

import dvb

dvb.poi_coords(33000755)
{'lat': 51.018745307424005, 'lng': 13.758700156062707}

Address for coordinates - WIP

Look up the address for a given set of coordinates.

import dvb

lat = 51.04373
lng = 13.70320

dvb.address(lat, lng)
{
    'city': u'Dresden',
    'address': u'Kesselsdorfer Straße 1'
}

Other stuff

Stop names in queries are very forgiving. As long as the server sees it as a unique hit, it'll work. 'Helmholtzstraße' finds the same data as 'helmholtzstrasse', 'Nürnberger Platz' = 'nuernbergerplatz' etc.

One last note, be sure not to run whatever it is you're building from inside the network of the TU Dresden. Calls to dvb.route() and dvb.find() will time out. This is unfortunately expected behavior as API calls from these IP ranges are blocked.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].