Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,14 @@ The loading process goes through these phases:

1. **`downloading`** - Initializing database engine (0-2%)
2. **`creating_schema`** - Creating database tables (2-10%)
3. **`extracting`** - Extracting GTFS ZIP file (10-15%)
3. **`extracting`** - Loading and extracting GTFS ZIP file (10-15%)
4. **`inserting_data`** - Importing data from CSV files (15-85%)
5. **`creating_indexes`** - Building database indexes (85-95%)
6. **`analyzing`** - Optimizing query performance (95-99%)
7. **`complete`** - Load complete (100%)

**Note:** If `realtimeFeedUrls` are configured, GTFS-RT data will be fetched automatically after the load completes (but won't affect the progress percentage).

#### Web Worker Example

The progress callback is especially useful for web workers:
Expand Down Expand Up @@ -531,7 +533,7 @@ This library supports GTFS Realtime data (alerts, trip updates, and vehicle posi
#### Loading Realtime Data

```typescript
// Configure RT feed URLs (optional - can also pass directly to fetchRealtimeData)
// Configure RT feed URLs - data will be fetched automatically after GTFS load
const gtfs = await GtfsSqlJs.fromZip('https://example.com/gtfs.zip', {
realtimeFeedUrls: [
'https://example.com/gtfs-rt/alerts',
Expand All @@ -540,8 +542,9 @@ const gtfs = await GtfsSqlJs.fromZip('https://example.com/gtfs.zip', {
],
stalenessThreshold: 120 // seconds (default: 120)
});
// RT data is already loaded and ready to use!

// Fetch RT data (uses configured URLs or pass custom URLs)
// Or manually fetch RT data later (uses configured URLs or pass custom URLs)
await gtfs.fetchRealtimeData();

// Or fetch from specific URLs
Expand Down
9 changes: 8 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ var GtfsSqlJs = class _GtfsSqlJs {
rowsProcessed: 0,
totalRows: 0,
percentComplete: 10,
message: "Extracting GTFS ZIP file"
message: "Loading and extracting GTFS ZIP file"
});
const files = await loadGTFSZip(zipPath);
onProgress?.({
Expand Down Expand Up @@ -2086,6 +2086,13 @@ var GtfsSqlJs = class _GtfsSqlJs {
percentComplete: 100,
message: "GTFS data loaded successfully"
});
if (this.realtimeFeedUrls.length > 0) {
try {
await loadRealtimeData(this.db, this.realtimeFeedUrls);
} catch (error) {
console.warn("Failed to fetch initial realtime data:", error);
}
}
}
/**
* Initialize from existing database
Expand Down
2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion src/gtfs-sqljs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class GtfsSqlJs {
rowsProcessed: 0,
totalRows: 0,
percentComplete: 10,
message: 'Extracting GTFS ZIP file',
message: 'Loading and extracting GTFS ZIP file',
});

const files = await loadGTFSZip(zipPath);
Expand Down Expand Up @@ -288,6 +288,16 @@ export class GtfsSqlJs {
percentComplete: 100,
message: 'GTFS data loaded successfully',
});

// Auto-fetch realtime data if feed URLs are configured
if (this.realtimeFeedUrls.length > 0) {
try {
await loadRealtimeData(this.db, this.realtimeFeedUrls);
} catch (error) {
// Don't fail the entire load if RT data fetch fails
console.warn('Failed to fetch initial realtime data:', error);
}
}
}

/**
Expand Down