List<List<PointAndIndex>> possibleAssignments, ShapePoints shapePoints,
UTMProjection projection, List<XYPoint> projectedShapePoints) {
if (possibleAssignments.size() >= 2) {
PointAndIndex first = possibleAssignments.get(0).get(0);
PointAndIndex second = possibleAssignments.get(1).get(0);
if (first.distanceAlongShape > second.distanceAlongShape) {
StopTimeEntryImpl firstStopTime = stopTimes.get(0);
_log.warn("snapping first stop time id=" + firstStopTime.getId()
+ " to start of shape");
XYPoint point = projectedShapePoints.get(0);
StopEntryImpl stop = firstStopTime.getStop();
XYPoint stopPoint = projection.forward(stop.getStopLocation());
double d = stopPoint.getDistance(point);
possibleAssignments.get(0).add(new PointAndIndex(point, 0, d, 0.0));
}
int n = possibleAssignments.size();
PointAndIndex prev = possibleAssignments.get(n - 2).get(0);
PointAndIndex last = possibleAssignments.get(n - 1).get(0);
if (prev.distanceAlongShape > last.distanceAlongShape) {
}
}
if (possibleAssignments.size() > 0) {
/**
* We snap the last stop to the end of the shape and add it to the set of
* possible assignments. In the worst case, it will be a higher-scoring
* assignment and ignored, but it can help in cases where the stop was
* weirdly assigned.
*/
PointAndIndex lastSnapped = getLastStopSnappedToEndOfShape(stopTimes,
shapePoints, projection, projectedShapePoints);
possibleAssignments.get(possibleAssignments.size() - 1).add(lastSnapped);
}
}