use of org.onebusaway.admin.service.bundle.hastus.xml.PublicTimeTable in project onebusaway-application-modules by camsys.
the class HastusGtfsFactory method processSchedule.
private PublicTimeTable processSchedule(File path) throws IOException, SAXException {
Digester digester = new Digester();
digester.addObjectCreate("PublicTimeTable", PublicTimeTable.class);
digester.addBeanPropertySetter("PublicTimeTable/VehicleSchedule/BookingIdentifier", "bookingIdentifier");
digester.addBeanPropertySetter("PublicTimeTable/VehicleSchedule/Type", "type");
digester.addBeanPropertySetter("PublicTimeTable/VehicleSchedule/Scenario", "scenario");
digester.addObjectCreate("PublicTimeTable/Route", PttRoute.class);
digester.addBeanPropertySetter("PublicTimeTable/Route/Identifier", "id");
digester.addBeanPropertySetter("PublicTimeTable/Route/Description", "description");
digester.addBeanPropertySetter("PublicTimeTable/Route/PublicIdentifier", "publicId");
digester.addBeanPropertySetter("PublicTimeTable/Route/FirstDirectionName", "firstDirectionName");
digester.addBeanPropertySetter("PublicTimeTable/Route/SecondDirectionName", "secondDirectionName");
digester.addSetNext("PublicTimeTable/Route", "addRoute");
digester.addObjectCreate("PublicTimeTable/PttPlaceInfo", PttPlaceInfo.class);
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/Identifier", "id");
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/Description", "description");
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/ScheduleType", "scheduleType");
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/DirectionName", "directionName");
digester.addSetNext("PublicTimeTable/PttPlaceInfo", "addPlaceInfo");
digester.addObjectCreate("PublicTimeTable/PttPlaceInfo/Trip", PttTrip.class);
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/Trip/RouteIdentifier", "routeId");
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/Trip/SequenceNo", "sequence");
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/Trip/trp_route_public", "routePublicId");
digester.addSetNext("PublicTimeTable/PttPlaceInfo/Trip", "addTrip");
digester.addObjectCreate("PublicTimeTable/PttPlaceInfo/Trip/TimingPoint", PttTimingPoint.class);
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/Trip/TimingPoint/PositionInPattern", "positionInPattern");
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/Trip/TimingPoint/PassingTime", "passingTime");
digester.addSetNext("PublicTimeTable/PttPlaceInfo/Trip/TimingPoint", "addTimingPoint");
digester.addObjectCreate("PublicTimeTable/PttPlaceInfo/PttPlaceInfoPlace", PttPlaceInfoPlace.class);
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/PttPlaceInfoPlace/PositionInPattern", "positionInPattern");
digester.addBeanPropertySetter("PublicTimeTable/PttPlaceInfo/PttPlaceInfoPlace/PlaceIdentifier", "id");
digester.addSetNext("PublicTimeTable/PttPlaceInfo/PttPlaceInfoPlace", "addPlace");
return (PublicTimeTable) digester.parse(path);
}
use of org.onebusaway.admin.service.bundle.hastus.xml.PublicTimeTable 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);
}
}
use of org.onebusaway.admin.service.bundle.hastus.xml.PublicTimeTable in project onebusaway-application-modules by camsys.
the class HastusGtfsFactory method processScheduleDirectory.
private List<PublicTimeTable> processScheduleDirectory(File path, List<PublicTimeTable> results) throws IOException, SAXException {
if (path.isFile() && path.getName().endsWith(".xml")) {
PublicTimeTable timetable = processSchedule(path);
results.add(timetable);
} else if (path.isDirectory()) {
for (File file : path.listFiles()) processScheduleDirectory(file, results);
}
return results;
}
Aggregations