gtfs 4.15.3 → 4.15.5
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/README.md +2 -2
- package/dist/bin/gtfs-export.js +14 -10
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +20 -26
- package/dist/bin/gtfs-import.js.map +1 -1
- package/dist/bin/gtfsrealtime-update.js +14 -21
- package/dist/bin/gtfsrealtime-update.js.map +1 -1
- package/dist/index.js +48 -57
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/bin/gtfs-import.js
CHANGED
|
@@ -3793,6 +3793,9 @@ var importGtfsFiles = (db, task) => mapSeries2(
|
|
|
3793
3793
|
task.log(`Importing - ${filename}\r`);
|
|
3794
3794
|
const columns = model.schema.filter((column) => column.name !== "id");
|
|
3795
3795
|
const placeholder = columns.map(({ name }) => `@${name}`).join(", ");
|
|
3796
|
+
const prefixedColumns = new Set(
|
|
3797
|
+
columns.filter((col) => col.prefix).map((col) => col.name)
|
|
3798
|
+
);
|
|
3796
3799
|
const prepareStatement = `INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${model.filenameBase} (${columns.map((column) => column.name).join(", ")}) VALUES (${placeholder})`;
|
|
3797
3800
|
const insert = db.prepare(prepareStatement);
|
|
3798
3801
|
const insertLines = db.transaction((lines) => {
|
|
@@ -3806,7 +3809,7 @@ var importGtfsFiles = (db, task) => mapSeries2(
|
|
|
3806
3809
|
line
|
|
3807
3810
|
).map(([columnName, value]) => [
|
|
3808
3811
|
columnName,
|
|
3809
|
-
|
|
3812
|
+
prefixedColumns.has(columnName) && value !== null ? `${task.prefix}${value}` : value
|
|
3810
3813
|
])
|
|
3811
3814
|
);
|
|
3812
3815
|
insert.run(prefixedLine);
|
|
@@ -3905,13 +3908,10 @@ async function importGtfs(initialConfig) {
|
|
|
3905
3908
|
timer.start();
|
|
3906
3909
|
const config = setDefaultConfig(initialConfig);
|
|
3907
3910
|
validateConfigForImport(config);
|
|
3908
|
-
const log2 = log(config);
|
|
3909
|
-
const logError2 = logError(config);
|
|
3910
|
-
const logWarning2 = logWarning(config);
|
|
3911
3911
|
try {
|
|
3912
3912
|
const db = openDb(config);
|
|
3913
3913
|
const agencyCount = config.agencies.length;
|
|
3914
|
-
|
|
3914
|
+
log(config)(
|
|
3915
3915
|
`Starting GTFS import for ${pluralize2("file", agencyCount, true)} using SQLite database at ${config.sqlitePath}`
|
|
3916
3916
|
);
|
|
3917
3917
|
createGtfsTables(db);
|
|
@@ -3935,9 +3935,9 @@ async function importGtfs(initialConfig) {
|
|
|
3935
3935
|
sqlitePath: config.sqlitePath,
|
|
3936
3936
|
prefix: agency2.prefix,
|
|
3937
3937
|
currentTimestamp: Math.floor(Date.now() / 1e3),
|
|
3938
|
-
log:
|
|
3939
|
-
logWarning:
|
|
3940
|
-
logError:
|
|
3938
|
+
log: log(config),
|
|
3939
|
+
logWarning: logWarning(config),
|
|
3940
|
+
logError: logError(config)
|
|
3941
3941
|
};
|
|
3942
3942
|
if (task.url) {
|
|
3943
3943
|
await downloadGtfsFiles(task);
|
|
@@ -3947,36 +3947,30 @@ async function importGtfs(initialConfig) {
|
|
|
3947
3947
|
await updateGtfsRealtimeData(task);
|
|
3948
3948
|
await rm2(tempPath, { recursive: true });
|
|
3949
3949
|
} catch (error) {
|
|
3950
|
-
|
|
3950
|
+
if (config.ignoreErrors) {
|
|
3951
|
+
logError(config)(error.message);
|
|
3952
|
+
} else {
|
|
3953
|
+
throw error;
|
|
3954
|
+
}
|
|
3951
3955
|
}
|
|
3952
3956
|
});
|
|
3953
|
-
|
|
3957
|
+
log(config)(`Creating DB indexes`);
|
|
3954
3958
|
createGtfsIndexes(db);
|
|
3955
3959
|
const seconds = Math.round(timer.time() / 1e3);
|
|
3956
3960
|
timer.stop();
|
|
3957
|
-
|
|
3961
|
+
log(config)(
|
|
3958
3962
|
`Completed GTFS import for ${pluralize2("agency", agencyCount, true)} in ${seconds} seconds
|
|
3959
3963
|
`
|
|
3960
3964
|
);
|
|
3961
3965
|
} catch (error) {
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
}
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
logError2(error.message);
|
|
3968
|
-
} else {
|
|
3966
|
+
if (error?.code === "SQLITE_CANTOPEN") {
|
|
3967
|
+
logError(config)(
|
|
3968
|
+
`Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists or remove \`sqlitePath\` from config.json.`
|
|
3969
|
+
);
|
|
3970
|
+
}
|
|
3969
3971
|
throw error;
|
|
3970
3972
|
}
|
|
3971
3973
|
}
|
|
3972
|
-
function handleDatabaseError(error, config, logError2) {
|
|
3973
|
-
if (error?.code === "SQLITE_CANTOPEN") {
|
|
3974
|
-
logError2(
|
|
3975
|
-
`Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists or remove \`sqlitePath\` from config.json.`
|
|
3976
|
-
);
|
|
3977
|
-
}
|
|
3978
|
-
throw error;
|
|
3979
|
-
}
|
|
3980
3974
|
|
|
3981
3975
|
// src/lib/export.ts
|
|
3982
3976
|
import { without, compact as compact2 } from "lodash-es";
|