Skip to content

Commit

Permalink
force GTFS-API FeedSource to use long unique feed ID.
Browse files Browse the repository at this point in the history
Also added some comments.
  • Loading branch information
abyrd committed Sep 25, 2017
1 parent a4d7f4f commit b30df9e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/com/conveyal/gtfs/api/ApiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,22 @@ public static FeedSource registerFeedSource (Function<GTFSFeed, String> idGenera

public static FeedSource getFeedSource (String id) throws Exception {
FeedSource f = cache.get(id);
// When constructed, the FeedSource object sets its ID to the short FeedId of that feed.
// We overwrite it here with the longer complete feed unique ID that was used to fetch the feed.
// This is a complete hack of a "solution" but seems to get the API working.
// The core problem appears to be an assumption in the GTFS cache classes that the GTFS object
// alone contains all required information, while in fact we need the longer unique ID.
f.id = id;
registeredFeedSources.add(id);
return f;
}

/** convenience function to get a feed source without throwing checked exceptions, for example for use in lambdas */
/** Convenience function to get a feed source without throwing checked exceptions, for example for use in lambdas */
public static FeedSource getFeedSourceWithoutExceptions (String id) {
try {
FeedSource f = cache.get(id);
registeredFeedSources.add(id);
return f;
return getFeedSource(id);
} catch (Exception e) {
LOG.error("Error retriveving from cache feed " + id, e);
LOG.error("Error retrieving from cache feed " + id, e);
return null;
}
}
Expand Down

0 comments on commit b30df9e

Please sign in to comment.