@Override public String toString() { return convertToString(this); }
@Override public String toString() { return convertToString(this); }
private String id(String agencyId, String id) { return AgencyAndId.convertToString(new AgencyAndId(agencyId, id)); } }
/**** * Consequence ****/ private List<SituationConsequenceBean> getConsequencesAsBeans( ServiceAlertRecord serviceAlert) { if (serviceAlert.getConsequences().size() == 0) return null; List<SituationConsequenceBean> beans = new ArrayList<SituationConsequenceBean>(); for (ServiceAlertSituationConsequenceClause consequence : serviceAlert.getConsequences()) { SituationConsequenceBean bean = new SituationConsequenceBean(); if (consequence.getEffect() != null) bean.setEffect(consequence.getEffect()); if (consequence.getDetourPath() != null) bean.setDetourPath(consequence.getDetourPath()); if (consequence.getDetourStopIds().size() != 0) { List<String> stopIds = new ArrayList<String>(); for (String stopId : consequence.getDetourStopIds()) { AgencyAndId id = ServiceAlertLibrary.agencyAndId(serviceAlert.getAgencyId(), stopId); stopIds.add(AgencyAndId.convertToString(id)); } bean.setDetourStopIds(stopIds); } beans.add(bean); } return beans; }
stopIdToPredictionRecordMap.put(AgencyAndId.convertToString(tpr.getTimepointId()), tpr);
stopTimeUpdate.setStopId(AgencyAndId.convertToString(tpr.getTimepointId())); stopTimeUpdate.setScheduleRelationship(com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED); stopTimeUpdate.setStopId(AgencyAndId.convertToString(stop.getId())); stopTimeUpdate.setStopSequence(nextStopTime.getSequence()); stopTimeUpdate.setScheduleRelationship(com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SCHEDULED); tripDescriptor.setRouteId(AgencyAndId.convertToString(routeId)); tripDescriptor.setScheduleRelationship(ScheduleRelationship.SCHEDULED); tripDescriptor.setStartDate(startDate); tripDescriptor.setTripId(AgencyAndId.convertToString(tripId)); tripUpdate.setTrip(tripDescriptor); vehicleDescriptor.setId(AgencyAndId.convertToString(vehicleId)); tripUpdate.setVehicle(vehicleDescriptor);
@Override public FeedMessage getVehiclePositions() { FeedMessage.Builder feedMessage = createFeedWithDefaultHeader(); List<VehicleStatus> statuses = _vehicleStatusService.getAllVehicleStatuses(); for (VehicleStatus status : statuses) { VehicleLocationRecord record = status.getRecord(); VehiclePosition.Builder vehiclePosition = VehiclePosition.newBuilder(); if (record.isCurrentLocationSet()) { Position.Builder position = Position.newBuilder(); position.setLatitude((float) record.getCurrentLocationLat()); position.setLongitude((float) record.getCurrentLocationLon()); vehiclePosition.setPosition(position); } VehicleDescriptor.Builder vehicleDescriptor = VehicleDescriptor.newBuilder(); vehicleDescriptor.setId(AgencyAndId.convertToString(record.getVehicleId())); vehiclePosition.setVehicle(vehicleDescriptor); if (record.getTimeOfLocationUpdate() != 0) vehiclePosition.setTimestamp(record.getTimeOfLocationUpdate() / 1000); else vehiclePosition.setTimestamp(record.getTimeOfRecord() / 1000); /** * TODO: Block? Trip? */ FeedEntity.Builder feedEntity = FeedEntity.newBuilder(); feedEntity.setVehicle(vehiclePosition); feedEntity.setId(vehicleDescriptor.getId()); feedMessage.addEntity(feedEntity); } return feedMessage.build(); }