1.0.3 • Published 2 years ago

ztm v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

build codecov downloads license

This library offers some utility functions and allows for easier interaction with the ZTM Gdańsk API.

Installation

npm i ztm

Usage

import ztm from 'ztm';

const stops = await ztm.stops({ stopId: 1337 });

Methods

stops(where?: Object)

Fetch all stops (filtered by properties in where)

@param where

  • stopId: number - unique id of the stop (in Tricity)
  • stopCode: string - used to identify stops with the same name
  • stopName: string - stop name
  • stopShortName: string - unique id of the stop (in ZTM | ZKM)
  • stopDesc: string - ZTM stop name
  • subName: string - optional (the same as stopCode only for ZTM)
  • date: Date - date of the last data update
  • zoneId: number - town/community unique id
  • zoneName: string - town/community name
  • virtual: number - flag used to determine whether stop is not intended for passengers (1 - yes, 0 - no)
  • nonpassenger: number - flag used to determine whether stop is intended for passengers (1 - yes, 0 - no)
  • depot: number - flag used to determine whether stop is a depot (1 - yes, 0 - no)
  • ticketZoneBorder: number - flag used to determine whether stop is a ticket zone border (1 - yes, 0 - no)
  • onDemand: number - flag used to determine whether stop is on demand (1 - yes, 0 - no)
  • activationDate: Date - date since stop data has been valid
  • stopLat: number - stop latitude
  • stopLon: number - stop longitude

nearStops(latitude: number, longitude: number, where?: Object, distance: number)

Fetch all stops in specified radius

@param latitude Starting point latitude

@param longitude Starting point longitude

@param where, the same as for stops

@param distance Search radius (in meters). Default: 500m


stopVehicles(stopId: number, where? Object)

Fetch all vehicles for the stop

@param stopId

@param where

  • id: string - vehicle id ('T' + tripId + 'R' + routeId)
  • delayInSeconds: number | null - set only when status equals "REALTIME"
  • estimatedTime: Date - estimated departure time
  • headsign: string - trip destination
  • routeId: number
  • scheduledTripStartTime: Date
  • tripId: number
  • status: string - "REALTIME" | "SCHEDULED"
  • theoreticalTime: Date - scheduled departure time
  • timestamp: Date - timestamp used for calculating estimated values
  • trip: number - internal tripId
  • vehicleCode: number | null - set only when status equals "REALTIME"
  • vehicleId: number | null - internal id, set only when status equals "REALTIME"
  • vehicleService: string - vehicle service id

stopsVehicles(stopIds: number[], where? Object)

Fetch all vehicles for multiple stops

@param stopIds

@param where, the same as for stopVehicles


activeVehicles(where?: Object)

Fetch all vehicles currently en route

@param where

  • generated: Date - timestamp of last lat and lon update (generally delay is around 20s)
  • routeShortName: string - vehicle number
  • tripId: number
  • headsign: string - vehicle destination
  • vehicleCode: string - unique vehicle code (visible on the vehicle's side)
  • vehicleService: string - vehicle service id
  • vehicleId: number
  • speed: number - vehicle velocity in km/h
  • direction: number - geographic direction in range of 0-315, with steps by 45 (0 - north, 315 - north-west)
  • delay: number - delay in seconds
  • scheduledTripStartTime: Date
  • lat: number - vehicle latitude
  • lon: number - vehicle longitude
  • gpsQuality: number - 0 - no GPS signal, 1-3 - GPS signal strength

  • Returned objects have the same properties as the corresponding where param
  • All dates are in ISO-8601 (UTC)
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

1.0.0

2 years ago