use of org.onebusaway.admin.service.bundle.hastus.xml.PttPlaceInfo in project onebusaway-application-modules by camsys.
the class HastusGtfsFactory method processSchedules.
private void processSchedules() throws IOException, SAXException, ParseException {
_midnight = _dateParse.parse("2000-01-01T00:00:00.000");
List<PublicTimeTable> timetables = processScheduleDirectory(_scheduleInputPath, new ArrayList<PublicTimeTable>());
logger.header(csv("schedules"), "booking_id,schedule_type,place_id,trip_sequence,trip_id,route_id,service_id,route_variation,stop_sequence,shape_id,trip_direction,direction_name");
int timetableSize = timetables.size();
for (PublicTimeTable timetable : timetables) {
int directionIndex = 0;
if (timetable == null || timetable.getPlaceInfos() == null)
continue;
for (PttPlaceInfo placeInfo : timetable.getPlaceInfos()) {
Map<String, Integer> timepointPositions = getTimepointPositions(placeInfo);
for (PttTrip pttTrip : placeInfo.getTrips()) {
String tripIdRaw = timetable.getBookingIdentifier() + "-" + placeInfo.getScheduleType() + "-" + placeInfo.getId() + "-" + pttTrip.getSequence();
AgencyAndId tripId = id(tripIdRaw);
Route route = getRoute(timetable, placeInfo, pttTrip);
AgencyAndId serviceId = getServiceId(timetable, placeInfo);
String routeVariation = getRouteVariationForPlaceInfo(placeInfo);
String stopSequenceId = constructSequenceId(pttTrip.getRouteId(), routeVariation, placeInfo.getScheduleType());
AgencyAndId shapeId = id(stopSequenceId);
RouteStopSequence stopSequence = _stopSequences.get(stopSequenceId);
if (stopSequence == null) {
_log.info("unknown stop sequence: " + stopSequenceId);
continue;
}
Trip trip = new Trip();
trip.setId(tripId);
trip.setDirectionId(constructDirectionId(directionIndex, timetableSize, shapeId));
trip.setRoute(route);
trip.setServiceId(serviceId);
trip.setShapeId(shapeId);
trip.setTripHeadsign(placeInfo.getDirectionName());
logger.log(csv("schedules"), timetable.getBookingIdentifier(), placeInfo.getScheduleType(), placeInfo.getId(), pttTrip.getSequence(), tripId, route.getId(), serviceId, routeVariation, stopSequenceId, shapeId, trip.getDirectionId(), placeInfo.getDirectionName());
_dao.saveEntity(trip);
processStopTimesForTrip(timepointPositions, pttTrip, tripIdRaw, stopSequence, trip);
}
}
directionIndex++;
}
// Remove timepoints from stops.
for (AgencyAndId timepointId : _timepointIds) {
_log.info("Removing timepoint " + timepointId.toString());
Stop notReallyAStop = _dao.getStopForId(timepointId);
_dao.removeEntity(notReallyAStop);
}
}
Aggregations