Skip to content
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

PredAccuracyPrediction says in comment directionId can be null as not always provided. #14

Open
scrudden opened this issue Aug 20, 2015 · 2 comments

Comments

@scrudden
Copy link
Contributor

A null direction stops the handleArrivalDeparture method of PredictionAccuracyModule matching an arrivalDeparture event to a PredAccuracyPrediction in memory. The map key includes direction.

PredictionKey key = new PredictionKey(arrivalDeparture.getVehicleId(), 
                arrivalDeparture.getDirectionId(), arrivalDeparture.getStopId());
        List<PredAccuracyPrediction> predsList = predictionMap.get(key);

Not sure on the solution but for me I did this in the new GTFSRealtimePredictionAccuracyModule I am working on. This is similar to what is done in NextBusPredictionAccuracyModule.

String direction=null;

                         if(update.getTrip().hasDirectionId())
                                direction=""+update.getTrip().getDirectionId();

                            if (update.getTrip() != null) {
                                Trip trip = dbConfig.getTrip(update.getTrip().getTripId());
                                if (trip != null) {
                                    direction = trip.getDirectionId();
                                } else {
                                    logger.error("Got tripTag={} but no such trip in "
                                            + "the configuration.", update.getTrip().getTripId());
                                }
                            }

@skibu
Copy link
Member

skibu commented Aug 21, 2015

I don't fully understand this issue. It appears that when an element, such as direction ID, for a PredictionKey is null that the key should still be OK. The key won't match if a non-null value is used in one place and a null value is used elsewhere. But if the direction ID is consistent then it seems that it should work fine.

So what exactly were you experiencing? Did the system not find a corresponding prediction for an arrival/departure due to the direction ID not being consistent? Or were you getting a problem such as a null pointer exception?

@scrudden
Copy link
Contributor Author

Hi Mike,
The former (The system did not find a corresponding prediction). The GTFS feed I have has a direction in trip.txt but the GTFS-rt feed does not. So this meant I need to look up the database to find the direction of the trip. This is as was done in the NextBusPredictionAccuracyModule.

The GTFS-rt spec says about direction id

"Caution: this field is still experimental, and subject to change. It may be formally adopted in the future."

I am looking into this further.

Cheers,

Sean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants