All Projects → kiliankoe → dvbjs

kiliankoe / dvbjs

Licence: other
🚊 Query Dresden's public transport system for current bus- and tramstop data in node

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to dvbjs

dvbpy
🚋 Query Dresden's public transport system for current bus- and tramstop data in python
Stars: ✭ 38 (+0%)
Mutual labels:  public-transportation, dvb, vvo, dresden
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
European Transport Modules
[DISCONTINUED in favour of public-transport-operators] Collection of european transport JavaScript modules.
Stars: ✭ 9 (-76.32%)
Mutual labels:  public-transportation
Transportr
Free Public Transport Assistant without Ads or Tracking
Stars: ✭ 678 (+1684.21%)
Mutual labels:  public-transportation
Onebusaway Application Modules
The core OneBusAway application suite.
Stars: ✭ 174 (+357.89%)
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
mobivoc
A vocabulary for future-oriented mobility solutions and value-added services supporting them.
Stars: ✭ 27 (-28.95%)
Mutual labels:  public-transportation
Busrouter Sg
BusRouter SG: Singapore Bus Routes Explorer
Stars: ✭ 238 (+526.32%)
Mutual labels:  public-transportation
Gtfs To Html
Build human readable transit timetables as HTML or PDF from GTFS.
Stars: ✭ 119 (+213.16%)
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
Bookingapi
A simple API to book tickets for public transport in Switzerland.
Stars: ✭ 15 (-60.53%)
Mutual labels:  public-transportation
Vbb Modules
List of JavaScript modules for Berlin & Brandenburg public transport.
Stars: ✭ 47 (+23.68%)
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
Prague Public Transport
Gives you times of the next trams around your location in Prague.
Stars: ✭ 11 (-71.05%)
Mutual labels:  public-transportation
european-transport-operators
NOT UP-TO-DATE ANYMORE, UNMAINTAINED. CHECK european-transport-feeds INSTEAD. List of european long-distance transport operators, available API endpoints, GTFS feeds and client modules.
Stars: ✭ 47 (+23.68%)
Mutual labels:  public-transportation
Transit
This Python module polls transit agencies for real-time bus arrival predictions.
Stars: ✭ 6 (-84.21%)
Mutual labels:  public-transportation
spuf-314
a Web Application prototype for public transportation, serving a RESTful API to find Stations, Bus, Metro and Tramway's Lines, while also computing the best multimodal path between two stations or addresses
Stars: ✭ 22 (-42.11%)
Mutual labels:  public-transportation
kiel-live
This app allows you to view live updates of bus arrivals.
Stars: ✭ 20 (-47.37%)
Mutual labels:  public-transportation
coronavirus-dresden
Collects official SARS-CoV-2 infection statistics published by the city of Dresden.
Stars: ✭ 19 (-50%)
Mutual labels:  dresden
osmot
Preprocessor for make public transit maps from Openstreetmap data
Stars: ✭ 14 (-63.16%)
Mutual labels:  public-transportation

dvbjs

travis-ci Coverage Status code style: prettier npmversion Downloads

NPM

This is an unofficial node module, giving you a few options to query Dresden's public transport system for current bus- and tramstop data.

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

Getting Started

Install the module using npm or yarn

$ npm install dvbjs
or
$ yarn add dvbjs

and require it in your project

import * as dvb from "dvbjs";

HTTP request are handled by axios that supports all modern browsers. See packages/react-example for a browser departure monitor example.

Example Usage

Find stops by name

import * as dvb from "dvbjs"; // OR const dvb = require("dvbjs");

dvb.findStop("zellesch").then((data) => {
  console.dir({ data }, { depth: 7, maxArrayLength: 2 });
});
{
  data: [
    {
      city: 'Dresden',
      coords: [ 13.745859050200034, 51.0283698098441 ],
      name: 'Zellescher Weg',
      id: '33000312',
      type: 'Stop'
    },
    {
      city: 'Clausthal-Zellerfeld',
      coords: [ 10.347333308428196, 51.80899839555576 ],
      name: 'Eschenbacher Straße',
      id: '26005221',
      type: 'Stop'
    }
  ]
}

Monitor a single stop

import * as dvb from "dvbjs"; // OR const dvb = require("dvbjs");

const stopID = "33000037"; // Postplatz
const timeOffset = 5;
const numResults = 2;

dvb.monitor(stopID, timeOffset, numResults).then((data) => {
  console.dir(data, { depth: 7, maxArrayLength: 2 });
});
[
  {
    arrivalTime: 2019-10-07T21:04:00.000Z,
    scheduledTime: 2019-10-07T21:04:00.000Z,
    id: 'voe:11001: :R:j19',
    line: '1',
    direction: 'Prohlis',
    platform: { name: '1', type: 'Platform' },
    arrivalTimeRelative: 4,
    scheduledTimeRelative: 4,
    delayTime: 0,
    state: 'InTime',
    mode: {
      title: 'Straßenbahn',
      name: 'Tram',
      iconUrl: 'https://www.dvb.de/assets/img/trans-icon/transport-tram.svg'
    },
    diva: { number: 11001, network: 'voe' }
  },
  {
    arrivalTime: 2019-10-07T21:15:00.000Z,
    scheduledTime: 2019-10-07T21:15:00.000Z,
    id: 'voe:11002: :R:j19',
    line: '2',
    direction: 'Kleinzschachwitz',
    platform: { name: '1', type: 'Platform' },
    arrivalTimeRelative: 15,
    scheduledTimeRelative: 15,
    delayTime: 0,
    state: 'InTime',
    mode: {
      title: 'Straßenbahn',
      name: 'Tram',
      iconUrl: 'https://www.dvb.de/assets/img/trans-icon/transport-tram.svg'
    },
    diva: { number: 11002, network: 'voe' }
  }
]

Find routes

import * as dvb from "dvbjs"; // OR const dvb = require("dvbjs");

const origin = "33000742"; // Helmholtzstraße
const destination = "33000037"; // Postplatz
const startTime = new Date();
const isArrivalTime = false;

dvb.route(origin, destination, startTime, isArrivalTime).then((data) => {
  console.dir(data, { depth: 7, maxArrayLength: 2 });
});
{
  origin: {
    id: '33000742',
    name: 'Helmholtzstraße',
    city: 'Dresden',
    coords: [ 13.725468471273134, 51.0255443264448 ]
  },
  destination: {
    id: '33000037',
    name: 'Postplatz',
    city: 'Dresden',
    coords: [ 13.733966669186017, 51.05081442107084 ]
  },
  trips: [
    {
      nodes: [
        {
          stops: [
            {
              id: '33000742',
              name: 'Helmholtzstraße',
              city: 'Dresden',
              type: 'Stop',
              platform: undefined,
              coords: [ 13.725468471273134, 51.0255443264448 ],
              arrival: 2019-10-07T21:12:00.000Z,
              departure: 2019-10-07T21:12:00.000Z
            },
            {
              id: '33000135',
              name: 'Plauen Nöthnitzer Straße',
              city: 'Dresden',
              type: 'Stop',
              platform: { name: '1', type: 'Platform' },
              coords: [ 13.716492082528102, 51.02796893475141 ],
              arrival: 2019-10-07T21:24:00.000Z,
              departure: 2019-10-07T21:24:00.000Z
            }
          ],
          departure: {
            id: '33000742',
            name: 'Helmholtzstraße',
            city: 'Dresden',
            platform: undefined,
            time: 2019-10-07T21:12:00.000Z,
            coords: [ 13.725468471273134, 51.0255443264448 ],
            type: 'Stop'
          },
          arrival: {
            id: '33000135',
            name: 'Plauen Nöthnitzer Straße',
            city: 'Dresden',
            platform: { name: '1', type: 'Platform' },
            time: 2019-10-07T21:24:00.000Z,
            coords: [ 13.716492082528102, 51.02796893475141 ],
            type: 'Stop'
          },
          mode: {
            title: 'Fussweg',
            name: 'Footpath',
            iconUrl: 'https://m.dvb.de/img/walk.svg'
          },
          line: 'Fussweg',
          direction: '',
          diva: undefined,
          duration: 12,
          path: [
            [ 13.725468471273134, 51.0255443264448 ],
            [ 13.725454558079187, 51.025553521653286 ],
            ... 47 more items
          ]
        },
        {
          stops: [
            {
              id: '33000135',
              name: 'Plauen Nöthnitzer Straße',
              city: 'Dresden',
              type: 'Stop',
              platform: { name: '1', type: 'Platform' },
              coords: [ 13.716492082528102, 51.02796893475141 ],
              arrival: 2019-10-07T21:24:00.000Z,
              departure: 2019-10-07T21:24:00.000Z
            },
            {
              id: '33000134',
              name: 'Münchner Platz',
              city: 'Dresden',
              type: 'Stop',
              platform: { name: '1', type: 'Platform' },
              coords: [ 13.721883037345886, 51.02995723597058 ],
              arrival: 2019-10-07T21:25:00.000Z,
              departure: 2019-10-07T21:25:00.000Z
            },
            ... 6 more items
          ],
          departure: {
            id: '33000135',
            name: 'Plauen Nöthnitzer Straße',
            city: 'Dresden',
            platform: { name: '1', type: 'Platform' },
            time: 2019-10-07T21:24:00.000Z,
            coords: [ 13.716492082528102, 51.02796893475141 ],
            type: 'Stop'
          },
          arrival: {
            id: '33000005',
            name: 'Pirnaischer Platz',
            city: 'Dresden',
            platform: { name: '4', type: 'Platform' },
            time: 2019-10-07T21:33:00.000Z,
            coords: [ 13.743735436306865, 51.04888908670104 ],
            type: 'Stop'
          },
          mode: {
            title: 'Straßenbahn',
            name: 'Tram',
            iconUrl: 'https://www.dvb.de/assets/img/trans-icon/transport-tram.svg'
          },
          line: '3',
          direction: 'Bf. Neustadt',
          diva: { number: 11003, network: 'voe' },
          duration: 9,
          path: [
            [ 13.71646358720785, 51.02796935341722 ],
            [ 13.71649241447995, 51.02797791957738 ],
            ... 56 more items
          ]
        },
        ... 2 more items
      ],
      departure: {
        id: '33000742',
        name: 'Helmholtzstraße',
        city: 'Dresden',
        platform: undefined,
        time: 2019-10-07T21:12:00.000Z,
        coords: [ 13.725468471273134, 51.0255443264448 ],
        type: 'Stop'
      },
      arrival: {
        id: '33000037',
        name: 'Postplatz',
        city: 'Dresden',
        platform: { name: '2', type: 'Platform' },
        time: 2019-10-07T21:39:00.000Z,
        coords: [ 13.733966669186017, 51.05081442107084 ],
        type: 'Stop'
      },
      duration: 27,
      interchanges: 1
    },
    {
      nodes: [
        {
          stops: [
            {
              id: '33000742',
              name: 'Helmholtzstraße',
              city: 'Dresden',
              type: 'Stop',
              platform: undefined,
              coords: [ 13.725468471273134, 51.0255443264448 ],
              arrival: 2019-10-07T21:23:00.000Z,
              departure: 2019-10-07T21:23:00.000Z
            },
            {
              id: '33000135',
              name: 'Plauen Nöthnitzer Straße',
              city: 'Dresden',
              type: 'Stop',
              platform: { name: '1', type: 'Platform' },
              coords: [ 13.716492082528102, 51.02796893475141 ],
              arrival: 2019-10-07T21:35:00.000Z,
              departure: 2019-10-07T21:35:00.000Z
            }
          ],
          departure: {
            id: '33000742',
            name: 'Helmholtzstraße',
            city: 'Dresden',
            platform: undefined,
            time: 2019-10-07T21:23:00.000Z,
            coords: [ 13.725468471273134, 51.0255443264448 ],
            type: 'Stop'
          },
          arrival: {
            id: '33000135',
            name: 'Plauen Nöthnitzer Straße',
            city: 'Dresden',
            platform: { name: '1', type: 'Platform' },
            time: 2019-10-07T21:35:00.000Z,
            coords: [ 13.716492082528102, 51.02796893475141 ],
            type: 'Stop'
          },
          mode: {
            title: 'Fussweg',
            name: 'Footpath',
            iconUrl: 'https://m.dvb.de/img/walk.svg'
          },
          line: 'Fussweg',
          direction: '',
          diva: undefined,
          duration: 12,
          path: [
            [ 13.725468471273134, 51.0255443264448 ],
            [ 13.725454558079187, 51.025553521653286 ],
            ... 47 more items
          ]
        },
        {
          stops: [
            {
              id: '33000135',
              name: 'Plauen Nöthnitzer Straße',
              city: 'Dresden',
              type: 'Stop',
              platform: { name: '1', type: 'Platform' },
              coords: [ 13.716492082528102, 51.02796893475141 ],
              arrival: 2019-10-07T21:35:00.000Z,
              departure: 2019-10-07T21:35:00.000Z
            },
            {
              id: '33000134',
              name: 'Münchner Platz',
              city: 'Dresden',
              type: 'Stop',
              platform: { name: '1', type: 'Platform' },
              coords: [ 13.721883037345886, 51.02995723597058 ],
              arrival: 2019-10-07T21:36:00.000Z,
              departure: 2019-10-07T21:36:00.000Z
            },
            ... 6 more items
          ],
          departure: {
            id: '33000135',
            name: 'Plauen Nöthnitzer Straße',
            city: 'Dresden',
            platform: { name: '1', type: 'Platform' },
            time: 2019-10-07T21:35:00.000Z,
            coords: [ 13.716492082528102, 51.02796893475141 ],
            type: 'Stop'
          },
          arrival: {
            id: '33000005',
            name: 'Pirnaischer Platz',
            city: 'Dresden',
            platform: { name: '4', type: 'Platform' },
            time: 2019-10-07T21:44:00.000Z,
            coords: [ 13.743735436306865, 51.04888908670104 ],
            type: 'Stop'
          },
          mode: {
            title: 'Straßenbahn',
            name: 'Tram',
            iconUrl: 'https://www.dvb.de/assets/img/trans-icon/transport-tram.svg'
          },
          line: '3',
          direction: 'Wilder Mann',
          diva: { number: 11003, network: 'voe' },
          duration: 9,
          path: [
            [ 13.71646358720785, 51.02796935341722 ],
            [ 13.71649241447995, 51.02797791957738 ],
            ... 56 more items
          ]
        },
        ... 2 more items
      ],
      departure: {
        id: '33000742',
        name: 'Helmholtzstraße',
        city: 'Dresden',
        platform: undefined,
        time: 2019-10-07T21:23:00.000Z,
        coords: [ 13.725468471273134, 51.0255443264448 ],
        type: 'Stop'
      },
      arrival: {
        id: '33000037',
        name: 'Postplatz',
        city: 'Dresden',
        platform: { name: '2', type: 'Platform' },
        time: 2019-10-07T21:53:00.000Z,
        coords: [ 13.733966669186017, 51.05081442107084 ],
        type: 'Stop'
      },
      duration: 30,
      interchanges: 1
    },
    ... 2 more items
  ]
}

API Documentation

Table of contents

index.ts

Functions

coords

Find the coordinates for a given POI id.

function coords(id: string, timeout: number = 5000): Promise<number[]>;

Parameters

Name Type Default value Description
id string the POI ID
timeout number 5000 the timeout of the request

Return type

Promise<number[] | undefined>


findAddress

Lookup address and nearby stops by coordinate.

function findAddress(lng: number, lat: number, timeout: number = 5000): Promise<IAddress>;

Parameters

Name Type Default value Description
lng number longitude of the coordinate
lat number latitude of the coordinate
timeout number 5000 the timeout of the request

Return type

Promise<IAddress | undefined>


findPOI

Search for POI in the network of the DVB.

function findPOI(searchString: string, timeout: number = 5000): Promise<IPoint[]>;

Parameters

Name Type Default value Description
searchString string the name of the stop
timeout number 5000 the timeout of the request

Return type

Promise<IPoint[]>


findStop

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

function findStop(searchString: string, timeout: number = 5000): Promise<IPoint[]>;

Parameters

Name Type Default value Description
searchString string the name of the stop
timeout number 5000 the timeout of the request

Return type

Promise<IPoint[]>


lines

get a list of availible tram/bus lines for a stop.

function lines(stopID: string, timeout: number = 5000): Promise<ILine[]>;

Parameters

Name Type Default value Description
stopID string the stop ID
timeout number 5000 the timeout of the request

Return type

Promise<ILine[]>


monitor

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

function monitor(stopID: string, offset: number = 0, amount: number = 0, timeout: number = 5000): Promise<IMonitor[]>;

Parameters

Name Type Default value Description
stopID string ID of the stop
offset number 0 how many minutes in the future, 0 for now
amount number 0 number of results
timeout number 5000 the timeout of the request

Return type

Promise<IMonitor[]>


pins

Search for different kinds of POIs inside a given bounding box.

function pins(swlng: number, swlat: number, nelng: number, nelat: number, pinTypes: PIN_TYPE[] = [PIN_TYPE.stop], timeout: number = 5000): Promise<IPin[]>;

Parameters

Name Type Default value Description
swlng number the longitude of the south west coordinate
swlat number the latitude of the south west coordinate
nelng number the longitude of the north east coordinate
nelat number the latitude of the north east coordinate
pinTypes PIN_TYPE[] [PIN_TYPE.stop] array of pin types
timeout number 5000 the timeout of the request

Return type

Promise<IPin[]>


route

Query the server for possible routes from one stop to another.

function route(originID: string, destinationID: string, time: Date = new Date(), isArrivalTime: boolean = true, timeout: number = 15000): Promise<IRoute>;

Parameters

Name Type Default value Description
originID string the id of the origin stop
destinationID string the id of the destination stop
time Date new Date() starting at what time
isArrivalTime boolean true is time the arrival time
timeout number 15000 the timeout of the request

Return type

Promise<IRoute>

Interfaces

IDiva
interface IDiva {
    number: number;
    network?: string;
}

Properties

Name Type Optional
number number false
network string true

IPlatform
interface IPlatform {
    name: string;
    type: string;
}

Properties

Name Type Optional
name string false
type string false

IPin
  • The id for PIN_TYPE.platform is always an empty string.
  • PIN_TYPE.platform conatins platform_nr.
  • PIN_TYPE.stop contains connections.
  • PIN_TYPE.parkandride contains info.
interface IPin {
    id: string;
    type: PIN_TYPE;
    name: string;
    coords: Array<number>;
    platformNr?: string;
    connections?: IConnection[];
    info?: string;
}

Properties

Name Type Optional
id string false
type PIN_TYPE false
name string false
coords Array false
platformNr string true
connections IConnection[] true
info string true

IConnection
interface IConnection {
    line: string;
    mode?: IMode;
}

Properties

Name Type Optional
line string false
mode IMode true

IMode
interface IMode {
    title: string;
    name: string;
    iconUrl?: string;
}

Properties

Name Type Optional
title string false
name string false
iconUrl string true

IAddress
interface IAddress extends IPoint {
    stops: IPoint[];
}

Extends

IPoint

Properties

Name Type Optional
stops IPoint[] false

ILine
interface ILine {
    name: string;
    mode?: IMode;
    diva?: IDiva;
    directions: string[];
}

Properties

Name Type Optional
name string false
mode IMode true
diva IDiva true
directions string[] false

IMonitor
interface IMonitor {
    arrivalTime: Date;
    scheduledTime: Date;
    id: string;
    line: string;
    direction: string;
    platform?: IPlatform;
    arrivalTimeRelative: number;
    scheduledTimeRelative: number;
    delayTime: number;
    state: string;
    mode?: IMode;
    diva?: IDiva;
}

Properties

Name Type Optional
arrivalTime Date false
scheduledTime Date false
id string false
line string false
direction string false
platform IPlatform true
arrivalTimeRelative number false
scheduledTimeRelative number false
delayTime number false
state string false
mode IMode true
diva IDiva true

ILocation
interface ILocation {
    id: string;
    name: string;
    city: string;
    coords: Array<number>;
}

Properties

Name Type Optional
id string false
name string false
city string false
coords Array false

IPoint
interface IPoint extends ILocation {
    type: POI_TYPE;
}

Extends

ILocation

Properties

Name Type Optional
type POI_TYPE false

IStop
interface IStop extends ILocation {
    type: string;
    platform?: IPlatform;
    arrival: Date;
    departure: Date;
}

Extends

ILocation

Properties

Name Type Optional
type string false
platform IPlatform true
arrival Date false
departure Date false

IStopLocation
interface IStopLocation extends ILocation {
    platform?: IPlatform;
    time: Date;
    type: string;
}

Extends

ILocation

Properties

Name Type Optional
platform IPlatform true
time Date false
type string false

INode
interface INode {
    stops: IStop[];
    departure?: IStopLocation;
    arrival?: IStopLocation;
    mode?: IMode;
    line: string;
    direction: string;
    diva?: IDiva;
    duration: number;
    path: Array<number>[];
}

Properties

Name Type Optional
stops IStop[] false
departure IStopLocation true
arrival IStopLocation true
mode IMode true
line string false
direction string false
diva IDiva true
duration number false
path Array[] false

ITrip
interface ITrip {
    departure?: IStopLocation;
    arrival?: IStopLocation;
    duration: number;
    interchanges: number;
    nodes: INode[];
}

Properties

Name Type Optional
departure IStopLocation true
arrival IStopLocation true
duration number false
interchanges number false
nodes INode[] false

IRoute
interface IRoute {
    origin?: ILocation;
    destination?: ILocation;
    trips: ITrip[];
}

Properties

Name Type Optional
origin ILocation true
destination ILocation true
trips ITrip[] false

Types

coord

WGS84 coordinates [lng, lat]

type coord = number[];

Type

number[]

Enums

POI_TYPE
enum POI_TYPE {
     Address = "Address",
     Coords = "Coords",
     POI = "POI",
     Stop = "Stop"
}

Members

Name Value
Address "Address"
Coords "Coords"
POI "POI"
Stop "Stop"

PIN_TYPE
enum PIN_TYPE {
     stop = "stop",
     platform = "platform",
     poi = "poi",
     rentabike = "rentabike",
     ticketmachine = "ticketmachine",
     carsharing = "carsharing",
     parkandride = "parkandride",
     unknown = "unknown"
}

Members

Name Value
stop "stop"
platform "platform"
poi "poi"
rentabike "rentabike"
ticketmachine "ticketmachine"
carsharing "carsharing"
parkandride "parkandride"
unknown "unknown"
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].