gtfs 4.15.7 → 4.15.8
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.
- package/dist/bin/gtfs-export.js +21 -9
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +7 -12
- package/dist/bin/gtfs-import.js.map +1 -1
- package/dist/bin/gtfsrealtime-update.js +2 -2
- package/dist/bin/gtfsrealtime-update.js.map +1 -1
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/dist/models/models.d.ts +7 -15
- package/dist/models/models.js +4 -8
- package/dist/models/models.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2410,7 +2410,7 @@ var tripUpdates = {
|
|
|
2410
2410
|
extension: "gtfs-realtime",
|
|
2411
2411
|
schema: [
|
|
2412
2412
|
{
|
|
2413
|
-
name: "
|
|
2413
|
+
name: "id",
|
|
2414
2414
|
type: "text",
|
|
2415
2415
|
required: true,
|
|
2416
2416
|
primary: true,
|
|
@@ -2574,7 +2574,7 @@ var vehiclePositions = {
|
|
|
2574
2574
|
extension: "gtfs-realtime",
|
|
2575
2575
|
schema: [
|
|
2576
2576
|
{
|
|
2577
|
-
name: "
|
|
2577
|
+
name: "id",
|
|
2578
2578
|
type: "text",
|
|
2579
2579
|
required: true,
|
|
2580
2580
|
primary: true,
|
|
@@ -2813,17 +2813,12 @@ var deadheadTimes = {
|
|
|
2813
2813
|
nonstandard: true,
|
|
2814
2814
|
extension: "ods",
|
|
2815
2815
|
schema: [
|
|
2816
|
-
{
|
|
2817
|
-
name: "id",
|
|
2818
|
-
type: "integer",
|
|
2819
|
-
primary: true,
|
|
2820
|
-
prefix: true
|
|
2821
|
-
},
|
|
2822
2816
|
{
|
|
2823
2817
|
name: "deadhead_id",
|
|
2824
2818
|
type: "text",
|
|
2825
2819
|
required: true,
|
|
2826
2820
|
index: true,
|
|
2821
|
+
primary: true,
|
|
2827
2822
|
prefix: true
|
|
2828
2823
|
},
|
|
2829
2824
|
{
|
|
@@ -2860,6 +2855,7 @@ var deadheadTimes = {
|
|
|
2860
2855
|
name: "location_sequence",
|
|
2861
2856
|
type: "integer",
|
|
2862
2857
|
required: true,
|
|
2858
|
+
primary: true,
|
|
2863
2859
|
min: 0,
|
|
2864
2860
|
index: true
|
|
2865
2861
|
},
|
|
@@ -3530,6 +3526,15 @@ function getDayOfWeekFromDate(date) {
|
|
|
3530
3526
|
}
|
|
3531
3527
|
return DAYS_OF_WEEK[dateObj.getDay()];
|
|
3532
3528
|
}
|
|
3529
|
+
function formatCurrency(value, currency) {
|
|
3530
|
+
const parts = new Intl.NumberFormat(void 0, {
|
|
3531
|
+
style: "currency",
|
|
3532
|
+
currency
|
|
3533
|
+
}).formatToParts(value);
|
|
3534
|
+
const integerPart = parts.find((part) => part.type === "integer")?.value ?? "0";
|
|
3535
|
+
const fractionPart = parts.find((part) => part.type === "fraction")?.value ?? "";
|
|
3536
|
+
return `${integerPart}${fractionPart !== "" ? `.${fractionPart}` : ""}`;
|
|
3537
|
+
}
|
|
3533
3538
|
|
|
3534
3539
|
// src/lib/import-gtfs-realtime.ts
|
|
3535
3540
|
function getNestedProperty(obj, defaultValue, path3) {
|
|
@@ -4037,12 +4042,11 @@ var importGtfsFiles = (db, task) => mapSeries2(
|
|
|
4037
4042
|
return;
|
|
4038
4043
|
}
|
|
4039
4044
|
task.log(`Importing - ${filename}\r`);
|
|
4040
|
-
const
|
|
4041
|
-
const placeholder = columns.map(({ name }) => `@${name}`).join(", ");
|
|
4045
|
+
const placeholder = model.schema.map(({ name }) => `@${name}`).join(", ");
|
|
4042
4046
|
const prefixedColumns = new Set(
|
|
4043
|
-
|
|
4047
|
+
model.schema.filter((column) => column.prefix).map((column) => column.name)
|
|
4044
4048
|
);
|
|
4045
|
-
const prepareStatement = `INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${model.filenameBase} (${
|
|
4049
|
+
const prepareStatement = `INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${model.filenameBase} (${model.schema.map((column) => column.name).join(", ")}) VALUES (${placeholder})`;
|
|
4046
4050
|
const insert = db.prepare(prepareStatement);
|
|
4047
4051
|
const insertLines = db.transaction((lines) => {
|
|
4048
4052
|
for (const [rowNumber, line] of Object.entries(lines)) {
|
|
@@ -4288,7 +4292,6 @@ var exportGtfs = async (initialConfig) => {
|
|
|
4288
4292
|
}
|
|
4289
4293
|
if (model.filenameExtension === "txt") {
|
|
4290
4294
|
const excludeColumns = [
|
|
4291
|
-
"id",
|
|
4292
4295
|
"arrival_timestamp",
|
|
4293
4296
|
"departure_timestamp",
|
|
4294
4297
|
"start_timestamp",
|
|
@@ -4307,6 +4310,14 @@ var exportGtfs = async (initialConfig) => {
|
|
|
4307
4310
|
if (!routesWithAgencyId || routesWithAgencyId.length === 0) {
|
|
4308
4311
|
excludeColumns.push("agency_id");
|
|
4309
4312
|
}
|
|
4313
|
+
} else if (model.filenameBase === "fare_attributes") {
|
|
4314
|
+
for (const line of lines) {
|
|
4315
|
+
line.price = formatCurrency(line.price, line.currency_type);
|
|
4316
|
+
}
|
|
4317
|
+
} else if (model.filenameBase === "fare_products") {
|
|
4318
|
+
for (const line of lines) {
|
|
4319
|
+
line.price = formatCurrency(line.amount, line.currency);
|
|
4320
|
+
}
|
|
4310
4321
|
}
|
|
4311
4322
|
const columns = without(
|
|
4312
4323
|
model.schema.map((column) => column.name),
|