Comments (6)
Great question.
After importing your GTFS, you can use sqlite3
from the command line to execute queries.
sqlite3 /tmp/gtfs "select * from trips;" ".exit"
Would it be useful to have a command within the GTFS library to do this? Like:
gtfs query "select * from trips;"
from node-gtfs.
I'm sorry I didn't make my question clear, but still thank you for your answer, which is also very helpful to me.
Below is the detailed description of my question:
I am using Windows, and I want to test the query methods and query efficiency of node-gtfs. However, I don't have a specific project, so I choose to implement this library with the command line. I hope I can use the command line to implement the Query Methods mentioned in the documentation, such as getRoutes() and getStops(), etc.
Do I need to write a js file and run it from the command line?
from node-gtfs.
Thanks for clarifying.
You are correct that in order to use the query methods from the command line, you'll need to make a js file that implements them.
You can see some small example scripts here: https://github.com/blinktaginc/node-gtfs#examples
You'll need to create a package.json file and install 'gtfs' from npm too.
Let me know how it goes.
from node-gtfs.
Thanks a lot!
I'll have a try and show the results here.
from node-gtfs.
It works!
I created a getStops.js file and a config.json file under the gtfs folder.
The code of getStops.js is as follows:
import { openDb, getStops } from '../gtfs/index.js';
import { readFile } from 'fs/promises';
const config = JSON.parse(await readFile(new URL('./config.json', import.meta.url)));
const db = openDb(config);
const stops = getStops(
{
stop_id: [
'1622',
'5182'
]
}
);
console.log(stops);
Then I ran the command:
node getStops.js
The results are printed like this:
[
{
stop_id: '1622',
stop_code: '1014',
stop_name: 'Pacheco Blvd + Arthur Rd',
tts_stop_name: null,
stop_desc: null,
stop_lat: 38.00626,
stop_lon: -122.090569,
zone_id: null,
stop_url: null,
location_type: 0,
parent_station: null,
stop_timezone: null,
wheelchair_boarding: 2,
level_id: null,
platform_code: null
},
{
stop_id: '5182',
stop_code: '1162',
stop_name: 'Lafayette BART',
tts_stop_name: null,
stop_desc: null,
stop_lat: 37.893571,
stop_lon: -122.125128,
zone_id: null,
stop_url: null,
location_type: 0,
parent_station: null,
stop_timezone: null,
wheelchair_boarding: 2,
level_id: null,
platform_code: null
}
]
from node-gtfs.
That is great - thanks for sharing your working code.
from node-gtfs.
Related Issues (20)
- transfers.txt default transfer_type HOT 2
- Typescript Support for node-gtfs HOT 4
- Package GTFS states MongoDB, Github States MySQL HOT 3
- Cannot use multiple databases at once HOT 2
- GTFS Fares V2 HOT 1
- GTFS Fares V2 Leg rules amount HOT 4
- [Feature Request] Create option to ignore SSL validation HOT 3
- GTFS-R TripDescriptor HOT 5
- Working with Docker Database locked HOT 4
- Dropping/Clearing database HOT 1
- Deployment on errors HOT 5
- Invalid default csv parser option "relax" in import script. HOT 2
- Performance improvements HOT 4
- Possible performance improvement: DuckDB HOT 3
- Changing internal maxInsertVariables has significant impact on total import time HOT 4
- Agency_id defined in agency.txt but not in routes.txt results in invalid GTFS export HOT 1
- Edge deployment and SQLite HOT 4
- Not running with Deno HOT 7
- occupancyStatus from vehicle_positions HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-gtfs.