0.4.1 • Published 1 month ago

oepnv-nuremberg v0.4.1

Weekly downloads
16
License
AGPL-3.0
Repository
github
Last release
1 month ago

oepnv-nuremberg

A wrapper for multiple datapoints from VAG and VGN.
Serves stations and depatures with extra information, so you not only know when your next bus is comming but also if it has air conditioning.
Stations also include if they are barrier-free, this if important for disabled people.
It can scrape VAG webpage to get current events, like a elevator malfunction in realtime.

Updating

Version: 0.0.1 to 0.0.5 Compatible
Version: 0.0.5 to 0.1.0 Not compatible, a lot was rewritten
Version: 0.1.2 to 0.2.0 Not compatible, abfahrten output now contains more info

Functions and todo list

  • Departures based on Ids (Also VAG StopIDs, like "PL" for ID 704)
  • Departures based on GPS
  • Stops based on names
  • Stops based on GPS
  • Get Trips
  • Get Trip
  • ? Get elevator malfunctions
  • ? Get current timetable changes
  • Turn (part of) adress into list of near stops
  • Turn GPS into Adress
  • Get routes from stop to stop
  • Get routes to anything. IDs, Stopnames, Adresses, GPS
  • Misc functions

    • Calculate travle time between 2 stops from a Trip Object

Usage

NodeJS 18.0 or higher

A working example is Test.js

Usage:

const vgn_wrapper = require('./index');

const vgn = new vgn_wrapper.openvgn();

(async function (){
 try {
   const Output = await vgn.getStops('Luitpoldhain', {limit: 1});
   console.log(Output);
 } catch (e) {
   console.log(e)
 }
})();

Methods

getStops

This will get you all known data about a stop.

ParametersDefinitionDefault ValuePossible Value
limitMax amount of stops returned-Number
getStops('Plärrer', {limit: 1});

getStopsbygps

This will list all stops in a given radius.

ParametersDefinitionDefault ValuePossible Value
limitMax amount of stops returned-Number
distanceMax distance to given GPS Position500 mNumber
sortSort your stops by distance or alphabeticallydistancedistance/alphabetically
getStopsbygps('49.45015694', '11.083455', {limit: 3, distance: 200, sort: 'distance'});

getDepartures

This will list all departures from a given stop.

ParametersDefinitionDefault ValuePossible Value
ProductOnly return departures of one or multiple products-Ubahn,Bus,Tram,Sbahn
TimeSpanReturn departures until that time-Number
TimeDelayLook for now + x in minutes-Number
LimitCountMax amount of departures returned-Number
getDepartures('704', {Product: "ubahn", TimeSpan: 10, TimeDelay: 445, LimitCount: 10})
//Or
getDepartures('PL', {Product: "ubahn", TimeSpan: 10, TimeDelay: 445, LimitCount: 10})

getDeparturesbygps

This will list all stops with departure data in a given radius.

ParametersDefinitionDefault ValuePossible Value
limitMax amount of stops returned-Number
distanceMax distance to given GPS Position500 mNumber
sortSort your stops by distance or alphabeticallydistancedistance/alphabetically
ProductOnly return departures of one or multiple products-Ubahn,Bus,Tram,Sbahn
TimeSpanReturn departures until that time-Number
TimeDelayLook for now + x in minutes-Number
LimitCountMax amount of departures returned-Number
getDeparturesbygps('49.4480881582118', '11.0647882822154', {Product: "ubahn", TimeSpan: 10, TimeDelay: 45, LimitCount: 2, limit: 5, distance: 200, sort: 'Distance'})

getTrip

This will display all stations that the product has and will pass from start to finish.
You can get the number (Fahrtnummer) from a getDepartures call.

ParametersDefinitionDefault ValuePossible Value
ProductOnly return departures of one or multiple products-Ubahn,Bus,Tram
getTrip(1000917, {Product: "ubahn"})

getTrips

This will list all trips of the given product (Ubahn, Tram, Bus) in a given timespan.

ParametersDefinitionDefault ValuePossible Value
TimeSpanReturn departures until that time-Number
getTrips("Ubahn", {timespan: 10})

calculateTripTime and calculateActualTripTime

This will calculate the time it takes to travel from one stop to another.

calculateTripTime(getTripResponse, "LS", "704") // Returns difference in seconds acourting to the timetable
calculateActualTripTime(getTripResponse, "LS", "704") // Returns difference in seconds acourting to the actual time

getVagWebpageDisturbances (BETA)

This method is very unstable because the webpage is very complicated.
This will return a object based on the current webpage.
The object might not have all the keys, its generated only by the current content!

{
  "schedule_changes": {
    "U-Bahn": [{...},{...}],
    "Bus": [{...},{...}],
    "Tram": [{...},{...}]
  },
  "disturbances": {
    "Aufzugsstörungen": [{...},{...}],
    "U-Bahn": [{...},{...}],
    "Bus": [{...},{...}],
    "Tram": [{...},{...}]
  },
  "Meta": {
    "Timestamp": Timestamp,
    "RequestTime": Number,
    "ParseTime": Number,
    "URL": 'https://www.vag.de/fahrplan/fahrplanaenderungen-stoerungen'
  }
}
getVagWebpageDisturbances()

reverseGeocode

This method will return the closest adress to the given GPS Position.

reverseGeocode('49.4480881582118', '11.0647882822154')

More info

"Tram Steighöhen" | Tram platform heights

platform heightsNumber in dataExplanation
15 cm bis 25 cm rise1barrier-free
15 cm bis 25 cm rise2not barrier-free
15 cm bis 25 cm rise3not barrier-free
Tilt change platform4not barrier-free
Crossing up to 3cm high5not barrier-free
No Platrom at all6not barrier-free

Where is the data comming from?

Departures and stops are comming from the official VAG API endpoint
URL: https://opendata.vag.de/
License: Creative Commons Attribution 4.0 Int.

Elevator disruptions and timetable deviations are comming from here
URL: https://www.vag.de/fahrplan/fahrplanaenderungen-stoerungen
License: Unknown

Bus numbers from external companys are from nahverkehr-franken.de
URL: https://www.nahverkehr-franken.de
License: Unknown

0.4.1

1 month ago

0.3.3

2 months ago

0.3.2

2 months ago

0.3.1

2 months ago

0.3.0

2 months ago

0.2.9

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.8

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago