-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty ID string in GTFS-RT data #20
Comments
I got this feed read into OpenTripPlanner by hacking its existing fuzzy trip matching code to work based on route_id alone. |
diff --git a/src/main/java/org/opentripplanner/updater/GtfsRealtimeFuzzyTripMatcher.java b/src/main/java/org/opentripplanner/updater/GtfsRealtimeFuzzyTripMatcher.java
index 81153d3..4e0c90b 100644
--- a/src/main/java/org/opentripplanner/updater/GtfsRealtimeFuzzyTripMatcher.java
+++ b/src/main/java/org/opentripplanner/updater/GtfsRealtimeFuzzyTripMatcher.java
@@ -29,19 +29,21 @@ public class GtfsRealtimeFuzzyTripMatcher {
}
public TripDescriptor match(String feedId, TripDescriptor trip) {
- if (trip.hasTripId()) {
+ System.err.println("Trying to match "+trip);
+ if (trip.hasTripId() && !"".equals(trip.getTripId())) {
// trip_id already exists
return trip;
}
- if (!trip.hasRouteId() || !trip.hasDirectionId() ||
- !trip.hasStartTime() || !trip.hasStartDate()) {
+ if (!trip.hasRouteId() ||
+ !trip.hasStartDate()) {
// Could not determine trip_id, returning original TripDescriptor
return trip;
AgencyAndId routeId = new AgencyAndId(feedId, trip.getRouteId());
- int time = StopTimeFieldMappingFactory.getStringAsSeconds(trip.getStartTime());
+ if (trip.hasStartTime()) time = StopTimeFieldMappingFactory.getStringAsSeconds(trip.getStartTime());
date = ServiceDate.parseString(trip.getStartDate());
@@ -52,7 +54,8 @@
}
- int direction = trip.getDirectionId();
+ if (trip.hasDirectionId()) direction = trip.getDirectionId();
Trip matchedTrip = getTrip(route, direction, time, date);
@@ -62,7 +65,7 @@ public class GtfsRealtimeFuzzyTripMatcher {
time += 24*60*60;
matchedTrip = getTrip(route, direction, time, date);
}
-
+// System.err.println("... matched trip "+matchedTrip);
if (matchedTrip == null) {
return trip;
}
@@ -76,14 +79,16 @@ public class GtfsRealtimeFuzzyTripMatcher {
int startTime, ServiceDate date) {
BitSet services = index.servicesRunning(date);
for (TripPattern pattern : index.patternsForRoute.get(route)) {
+// System.err.println("... matching "+pattern);
if (pattern.directionId != direction) continue;
for (TripTimes times : pattern.scheduledTimetable.tripTimes) {
- if (times.getScheduledDepartureTime(0) == startTime &&
+ if ((startTime == -1 || (times.getScheduledDepartureTime(0) == startTime)) &&
services.get(times.serviceCode)) {
return times.trip;
- }
+ } // else System.err.println("no "+date+" "+times.serviceCode);
}
}
+ System.err.println("Fuzzy match failed for "+route+" "+direction+" "+startTime+" "+date);
return null;
}
} |
Hi tuukka, Thanks for your reply. Indeed, these were my thoughts also, that given the data in the realtime gtfs feed, there would be no other way than to work on route_id alone. But surely this is not really the intention according to the specification, espescially since OTP also seems to assume that the trip_id is present. So I was wondering if the lacking trip_id is intentional, or if there are any plans to change this is in the future? |
And thank you very much for the code! |
@pietercolpaert Do you know about plans for this code? This issue is a duplicate of an issue that @brechtvdv fixed in the spring but I don't know if it was deployed: #18 |
@tuukka No real plans for this code at this moment: it's out there and will merge pull request and put it into production. @brechtvdv can you take a look at this issue please? |
Hi, |
Every time gtfs-rt runs, (a part of) calendar_dates.txt is read. (+/- 4 months) The empty strings are because the trip isn't found in the gtfs. Propably a bug with some routes.. |
Hi,
I am trying to read the real-time gtfs data in trip_updates.pb in OpenTripPlanner, but OpenTripPlanner is crashing due to the fact that there are no trip_id 's in the data. Here is a dump of trip_updates.pb:
Trip_id seems to be an empty string indeed. Is this intentional? If so, how can I determine what trip the update is about? I know the route_id is given, but OpenTripPlanner uses a different ID for trips and routes.
Thank you very much in advance!
The text was updated successfully, but these errors were encountered: