1.0.3 • Published 4 years ago
ztm v1.0.3
This library offers some utility functions and allows for easier interaction with the ZTM Gdańsk API.
Installation
npm i ztmUsage
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 namestopName: string - stop namestopShortName: string - unique id of the stop (in ZTM | ZKM)stopDesc: string - ZTM stop namesubName: string - optional (the same asstopCodeonly for ZTM)date: Date - date of the last data updatezoneId: number - town/community unique idzoneName: string - town/community namevirtual: 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 validstopLat: number - stop latitudestopLon: 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 whenstatusequals "REALTIME"estimatedTime: Date - estimated departure timeheadsign: string - trip destinationrouteId: numberscheduledTripStartTime: DatetripId: numberstatus: string - "REALTIME" | "SCHEDULED"theoreticalTime: Date - scheduled departure timetimestamp: Date - timestamp used for calculating estimated valuestrip: number - internaltripIdvehicleCode: number | null - set only whenstatusequals "REALTIME"vehicleId: number | null - internal id, set only whenstatusequals "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 lastlatandlonupdate (generally delay is around 20s)routeShortName: string - vehicle numbertripId: numberheadsign: string - vehicle destinationvehicleCode: string - unique vehicle code (visible on the vehicle's side)vehicleService: string - vehicle service idvehicleId: numberspeed: number - vehicle velocity in km/hdirection: number - geographic direction in range of 0-315, with steps by 45 (0 - north, 315 - north-west)delay: number - delay in secondsscheduledTripStartTime: Datelat: number - vehicle latitudelon: number - vehicle longitudegpsQuality: number - 0 - no GPS signal, 1-3 - GPS signal strength
- Returned objects have the same properties as the corresponding
whereparam - All dates are in ISO-8601 (UTC)