gtfs 4.14.1 → 4.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -299,6 +299,143 @@ var stopTimeUpdates = {
299
299
  ]
300
300
  };
301
301
 
302
+ // src/models/gtfs-realtime/vehicle-positions.ts
303
+ var vehiclePositions = {
304
+ filenameBase: "vehicle_positions",
305
+ extension: "gtfs-realtime",
306
+ schema: [
307
+ {
308
+ name: "update_id",
309
+ type: "text",
310
+ required: true,
311
+ primary: true,
312
+ index: true,
313
+ source: "id"
314
+ },
315
+ {
316
+ name: "bearing",
317
+ type: "real",
318
+ source: "vehicle.position.bearing",
319
+ default: null
320
+ },
321
+ {
322
+ name: "latitude",
323
+ type: "real",
324
+ min: -90,
325
+ max: 90,
326
+ source: "vehicle.position.latitude",
327
+ default: null
328
+ },
329
+ {
330
+ name: "longitude",
331
+ type: "real",
332
+ source: "vehicle.position.longitude",
333
+ min: -180,
334
+ max: 180,
335
+ default: null
336
+ },
337
+ {
338
+ name: "speed",
339
+ type: "real",
340
+ min: 0,
341
+ source: "vehicle.position.speed",
342
+ default: null
343
+ },
344
+ {
345
+ name: "current_stop_sequence",
346
+ type: "integer",
347
+ source: "vehicle.currentStopSequence",
348
+ default: null
349
+ },
350
+ {
351
+ name: "trip_id",
352
+ type: "text",
353
+ index: true,
354
+ source: "vehicle.trip.tripId",
355
+ default: null
356
+ },
357
+ {
358
+ name: "trip_start_date",
359
+ type: "text",
360
+ index: true,
361
+ source: "vehicle.trip.startDate",
362
+ default: null
363
+ },
364
+ {
365
+ name: "trip_start_time",
366
+ type: "text",
367
+ index: true,
368
+ source: "vehicle.trip.startTime",
369
+ default: null
370
+ },
371
+ {
372
+ name: "congestion_level",
373
+ type: "text",
374
+ source: "vehicle.congestionLevel",
375
+ default: null
376
+ },
377
+ {
378
+ name: "occupancy_status",
379
+ type: "text",
380
+ source: "vehicle.occupancyStatus",
381
+ default: null
382
+ },
383
+ {
384
+ name: "occupancy_percentage",
385
+ type: "integer",
386
+ source: "vehicle.occupancyPercentage",
387
+ default: null
388
+ },
389
+ {
390
+ name: "vehicle_stop_status",
391
+ type: "text",
392
+ source: "vehicle.vehicleStopStatus",
393
+ default: null
394
+ },
395
+ {
396
+ name: "vehicle_id",
397
+ type: "text",
398
+ index: true,
399
+ source: "vehicle.vehicle.id",
400
+ default: null
401
+ },
402
+ {
403
+ name: "vehicle_label",
404
+ type: "text",
405
+ source: "vehicle.vehicle.label",
406
+ default: null
407
+ },
408
+ {
409
+ name: "vehicle_license_plate",
410
+ type: "text",
411
+ source: "vehicle.vehicle.licensePlate",
412
+ default: null
413
+ },
414
+ {
415
+ name: "vehicle_wheelchair_accessible",
416
+ type: "text",
417
+ source: "vehicle.vehicle.wheelchairAccessible",
418
+ default: null
419
+ },
420
+ {
421
+ name: "timestamp",
422
+ type: "text",
423
+ source: "vehicle.timestamp",
424
+ default: null
425
+ },
426
+ {
427
+ name: "created_timestamp",
428
+ type: "integer",
429
+ required: true
430
+ },
431
+ {
432
+ name: "expiration_timestamp",
433
+ type: "integer",
434
+ required: true
435
+ }
436
+ ]
437
+ };
438
+
302
439
  // src/models/gtfs-realtime/service-alerts.ts
303
440
  var serviceAlerts = {
304
441
  filenameBase: "service_alerts",
@@ -671,12 +808,12 @@ var updateRealtimeData = async (task) => {
671
808
  task.log(`Download successful`);
672
809
  let totalLineCount = 0;
673
810
  for (const entity of gtfsRealtimeData.entity) {
674
- const fieldValues = tripUpdates.schema.map(
811
+ const fieldValues = vehiclePositions.schema.map(
675
812
  (column) => prepareRealtimeValue(entity, column, task)
676
813
  );
677
814
  try {
678
815
  db.prepare(
679
- `REPLACE INTO ${tripUpdates.filenameBase} (${tripUpdates.schema.map((column) => column.name).join(", ")}) VALUES (${fieldValues.join(", ")})`
816
+ `REPLACE INTO ${vehiclePositions.filenameBase} (${vehiclePositions.schema.map((column) => column.name).join(", ")}) VALUES (${fieldValues.join(", ")})`
680
817
  ).run();
681
818
  } catch (error) {
682
819
  task.logWarning("Import error: " + error.message);
@@ -706,19 +843,27 @@ async function updateGtfsRealtime(initialConfig) {
706
843
  deleteExpiredRealtimeData(config);
707
844
  await Promise.all(
708
845
  config.agencies.map(async (agency2) => {
709
- const task = {
710
- realtimeAlerts: agency2.realtimeAlerts,
711
- realtimeTripUpdates: agency2.realtimeTripUpdates,
712
- realtimeVehiclePositions: agency2.realtimeVehiclePositions,
713
- downloadTimeout: config.downloadTimeout,
714
- gtfsRealtimeExpirationSeconds: config.gtfsRealtimeExpirationSeconds,
715
- sqlitePath: config.sqlitePath,
716
- currentTimestamp: Math.floor(Date.now() / 1e3),
717
- log: log2,
718
- logWarning: logWarning2,
719
- logError: logError2
720
- };
721
- await updateRealtimeData(task);
846
+ try {
847
+ const task = {
848
+ realtimeAlerts: agency2.realtimeAlerts,
849
+ realtimeTripUpdates: agency2.realtimeTripUpdates,
850
+ realtimeVehiclePositions: agency2.realtimeVehiclePositions,
851
+ downloadTimeout: config.downloadTimeout,
852
+ gtfsRealtimeExpirationSeconds: config.gtfsRealtimeExpirationSeconds,
853
+ sqlitePath: config.sqlitePath,
854
+ currentTimestamp: Math.floor(Date.now() / 1e3),
855
+ log: log2,
856
+ logWarning: logWarning2,
857
+ logError: logError2
858
+ };
859
+ await updateRealtimeData(task);
860
+ } catch (error) {
861
+ if (config.ignoreErrors) {
862
+ logError2(error.message);
863
+ } else {
864
+ throw error;
865
+ }
866
+ }
722
867
  })
723
868
  );
724
869
  log2(