Comments (12)
Good catch. Most GTFS files have only one agency so this hasn't come up until now.
Currently, in node-gtfs you get to specify an agency_key
per file. One solution would be to use this plus the agency_id
from agencies.txt, so maybe you end up with something like metronorth_2
and metronorth_3
for agency_keys.
I'd be happy to take a pull request, or else I can get around to making an update to support this- let me know if this is something you'd like to work on.
from node-gtfs.
Hey @brendannee,
Great, I'd be happy to take a stab at it. I'll start looking at making the change tonight!
from node-gtfs.
Any updates on this?
Stumbled upon this problem too and would like to get it to work.
from node-gtfs.
It seems agency_id should be added to the applicable functions. Agency_key is an arbitrary value, while agency_id is a valid value within the Agency model and used to relate Agency to Routes.
However, agency_key is still needed to differentiate transit "sets" (as represented by individual GTFS zip files).
For example:
getAgency: function(agency_key, agency_id, cb) {
/*
* Returns an agency
*/
getAgency: function(agency_key, agency_id, cb) {
Agency.findOne({
agency_key: agency_key,
agency_id: agency_id
}, cb);
},
and:
getRoutesByAgency: function(agency_key, agency_id, cb) {
/*
* Returns an array of routes for the `~~agency_key~~agency_id` specified
*/
getRoutesByAgency: function(agency_key, agency_id, cb) {
Route.find({
agency_key: agency_key,
agency_id: agency_id
}, cb);
},
Only functions related to the actual Agency would need to be changed, so they represent the true Agency rather than the arbitrary key. Other than those above, I see these two:
getFeedInfo
getTimetablesByAgency
Of course, agency_id would be empty string in most cases... so, you might want to do something like getAgenciesByDistance()
:
/*
* Returns an agency
*/
getAgency: function(agency_key, agency_id, cb) {
if(_.isFunction(agency_id)) {
cb = agency_id;
agency_id = ''; // default is empty string
}
Agency.findOne({
agency_key: agency_key,
agency_id: agency_id
}, cb);
},
from node-gtfs.
@brendannee Can you provide some context into why agency_key
exists rather than just using the agency id provided by the feed? I like @leanne63 solution to this problem.
from node-gtfs.
@dfairaizl The agency_id
field, per the GTFS specification, only exists in a feed's agency.txt
and routes.txt
files.
The agency_id
also may not be unique between multiple feeds (illustrated by the fact that most feeds' agency_id
values are empty).
The agency_key
associated with the feed via node-gtfs' config.js
file provides a simple mechanism to maintain a separation between data for multiple feeds.
from node-gtfs.
maintain a separation between data for multiple feeds
Ahhh yes that makes perfect sense now. @leanne63 Did you already implement this functionality?
from node-gtfs.
I had begun working on it, @dfairaizl, when you started this thread. I was waiting to see if @brendannee had a preference, based on your question, as to how to work it. Otherwise, I can have a PR ready by tomorrow.
from node-gtfs.
If there is no preference @leanne63 you can go ahead and submit your PR for this bug.
from node-gtfs.
I'm running the tests provided with gtfs-node. They're failing because the test agency has only one agency, but that agency DOES have an agency_id
.
Noting @brendannee quote:
Most GTFS files have only one agency so this hasn't come up until now.
which makes sense, as files with a single agency should have an empty string in the agency_id
field.
So, question: are we safe assuming a default empty string for the agency_id
? (if so, we probably want to change the test data for that assumption.)
Or, shall I create new functions that require an agency_id
to be passed?
from node-gtfs.
Also, just for reference, these are the functions I'm toying with:
getAgency
- modify to accept agency_id
or default to empty string
getAgenciesByKey
- add this function to allow search by key, regardless of ID
getFeedInfo
- modify to accept agency_id
or default to empty string
getFeedInfoByKey
- add this function to allow search by key, regardless of ID
getRoutesByAgency
- modify to accept agency_id
or default to empty string
or add for specificity:
getRoutesByAgencyId
getRoutesByAgencyKey
Technically, anything that says "agency" should be referencing an agency_id
along with an agency_key
.
Anything regarding the agency_key
is really related to the "feed" (the set of files in a given grouping of GTFS zip).
For example, TransitFeeds' Metro North Railroad http://transitfeeds.com/p/mta/87 feed
/agency_key
equivalent is "mta/87"
where the GTFS Data Exchange's http://www.gtfs-data-exchange.com/agency/metro-north-railroad equivalent is 'metro-north-railroad'.
(Someone was trying to get a standard feed_id
moving forward for GTFS providers a couple of years ago. As far as I can tell, it has not been officially implemented.)
from node-gtfs.
I accepted and merged the a pull request that should solve this issue.
Check it out and let me know if there is anything else that should be updated.
https://github.com/brendannee/node-gtfs/releases/tag/0.4.0
Pull requests welcome!
from node-gtfs.
Related Issues (20)
- Can I use the command line for query operations? HOT 6
- 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 4
- Changing internal maxInsertVariables has significant impact on total import time HOT 5
- 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 9
- occupancyStatus from vehicle_positions HOT 6
- Persistent trip_updates when running getStopTimeUpdates HOT 13
- Deleting the db to avoid id collisions HOT 3
- Propagate RT delays to missing stop_sequences HOT 6
- updateGtfsRealtime doesn't work if one URL is down HOT 2
- Disable clean stale GTFS-Realtime data by default HOT 12
- Zip File Containing Multiple GTFS Static Zip Files HOT 3
- import.js throws an error because attribution_id is missing but the spec says it's optional HOT 3
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.