Interactive Demo
+Exploring Car Jaune GTFS data (Martinique, France)
+Loading GTFS data...
+diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..10736a0 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,60 @@ +name: Deploy Website to GitHub Pages + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'npm' + + - name: Install root dependencies + run: npm ci + + - name: Build gtfs-sqljs package + run: npm run build + + - name: Install website dependencies + working-directory: ./website + run: npm ci + + - name: Build website + working-directory: ./website + run: npm run build + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: './website/dist' + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/website/demo.html b/website/demo.html new file mode 100644 index 0000000..3551b22 --- /dev/null +++ b/website/demo.html @@ -0,0 +1,77 @@ + + +
+ + +Exploring Car Jaune GTFS data (Martinique, France)
+Loading GTFS data...
+No calendar data available
'; + return; + } + + const html = calendars.map(cal => { + const days = ['M', 'T', 'W', 'T', 'F', 'S', 'S']; + const values = [ + cal.monday, + cal.tuesday, + cal.wednesday, + cal.thursday, + cal.friday, + cal.saturday, + cal.sunday + ]; + + const daysHtml = days.map((day, i) => + `+ ${formatDate(cal.start_date)} - ${formatDate(cal.end_date)} +
+No routes found
'; + return; + } + + const html = routes.map(route => { + const bgColor = route.route_color ? `#${route.route_color}` : '#64748b'; + const textColor = route.route_text_color ? `#${route.route_text_color}` : getContrastColor(bgColor); + + return ` +No trips found for this route
'; + tripsSectionEl.style.display = 'block'; + selectedRouteNameEl.textContent = routeName; + return; + } + + // Render trips + const html = trips.map(trip => { + const headsign = trip.trip_headsign || 'No headsign'; + const direction = trip.direction_id !== undefined ? `Direction ${trip.direction_id}` : ''; + const service = trip.service_id; + + return ` +No stop times found for this trip
'; + stopTimesSectionEl.style.display = 'block'; + selectedTripNameEl.textContent = tripName; + return; + } + + // Render stop times with stop names + const html = stopTimes.map(st => { + const stop = gtfs.getStopById(st.stop_id); + const stopName = stop ? stop.stop_name : st.stop_id; + + return ` +Load GTFS data into sql.js SQLite database for querying in browser and Node.js
+ +Works in both browser and Node.js environments
+Load GTFS data directly from ZIP files (URL or local path)
+Query stops, routes, trips, calendars with efficient SQLite indexes
+Export databases to ArrayBuffer for persistence
+Full TypeScript support with comprehensive GTFS types
+77+ tests covering all features with real GTFS data
+npm install gtfs-sqljs sql.js
+ import { GtfsSqlJs } from 'gtfs-sqljs';
+
+// Load from ZIP file
+const gtfs = await GtfsSqlJs.fromZip('https://example.com/gtfs.zip');
+
+// Get all routes
+const routes = gtfs.getAllRoutes();
+
+// Get stops for a trip
+const stops = gtfs.getStopsByTrip('trip_id');
+
+// Get active trips for a date
+const trips = gtfs.getTripsByDate('20240115');
+
+// Clean up
+gtfs.close();
+ getStopById(stopId) - Get stop by IDgetStopByCode(stopCode) - Get stop by codesearchStopsByName(name, limit?) - Search stops by namegetStopsByTrip(tripId) - Get stops for a trip (ordered)getAllStops(limit?) - Get all stopsgetRouteById(routeId) - Get route by IDgetAllRoutes(limit?) - Get all routesgetRoutesByAgency(agencyId) - Get routes by agencygetActiveServiceIds(date) - Get active services for a date (YYYYMMDD)getCalendarByServiceId(serviceId) - Get calendar by service IDgetCalendarDates(serviceId) - Get calendar date exceptionsgetTripById(tripId) - Get trip by IDgetTripsByRoute(routeId) - Get trips for a routegetTripsByDate(date) - Get all trips for a dategetTripsByRouteAndDate(routeId, date) - Get trips for route and dategetTripsByRouteAndDateAndDirection(routeId, date, directionId) - Filter by directiongetStopTimesByTrip(tripId) - Get stop times for a tripgetStopTimesByStop(stopId, limit?) - Get stop times for a stopgetStopTimesForStopRouteAndDate(stopId, routeId, date, directionId?) - Complex filteringexport() - Export database to ArrayBuffergetDatabase() - Get direct access to sql.js databaseclose() - Close database connectionMIT License
+