String vehicleId = ""; if (entity.getTripUpdate().hasVehicle() && entity.getTripUpdate().getVehicle().hasId()) { vehicleId = entity.getTripUpdate().getVehicle().getId(); String vehicleId = entity.getVehicle().getVehicle().getId(); String tripId = ""; if (entity.getVehicle().hasTrip() && entity.getVehicle().getTrip().hasTripId()) {
if (tu.hasVehicle() && tu.getVehicle().hasId() && StringUtils.isNotBlank(tu.getVehicle().getId())) {
GtfsRealtime.TripUpdate tripUpdate = entity.getTripUpdate(); if (StringUtils.isEmpty(tripUpdate.getVehicle().getId())) { GtfsRealtime.VehiclePosition v = entity.getVehicle(); if (StringUtils.isEmpty(v.getVehicle().getId())) { if (vehicleIds.contains(v.getVehicle().getId())) { RuleUtils.addOccurrence(E052, "entity ID " + entity.getId() + " has vehicle.id " + v.getVehicle().getId(), e052List, _log); } else { vehicleIds.add(v.getVehicle().getId());
if (!GtfsUtils.isAddedTrip(trip)) { RuleUtils.addOccurrence(E003, "vehicle_id " + entity.getVehicle().getVehicle().getId() + " trip_id " + tripId, errorListE003, _log); RuleUtils.addOccurrence(E016, "vehicle_id " + entity.getVehicle().getVehicle().getId() + " trip_id " + tripId, errorListE016, _log);
+ "directionId={}, tripId={}, vehicleId={}, " + "stopId={}, prediction={}, isArrival={}", update.getTrip().getRouteId(), direction, update.getTrip().getTripId(), update.getVehicle().getId(), stopTime.getStopId(), new Date(stopTime.getArrival().getTime()*1000), true); stopTime.getStopId(), update.getTrip().getTripId(), update.getVehicle().getId(), new Date(stopTime.getArrival().getTime()*1000) , new Date(feed.getHeader().getTimestamp()*1000), stopTime.getStopId(), update.getTrip().getTripId(), update.getVehicle().getId(), new Date(stopTime.getDeparture().getTime()*1000) , new Date(feed.getHeader().getTimestamp()*1000), logger.debug("No predictions for vehicleId={} for stop={}",update.getVehicle().getId(),stopTime.getStopId());
RuleUtils.addOccurrence(E006, "vehicle_id " + vehiclePosition.getVehicle().getId() + " trip_id " + vehiclePosition.getTrip().getTripId() + " is missing start_date", errorListE006, _log); RuleUtils.addOccurrence(E006, "vehicle_id " + vehiclePosition.getVehicle().getId() + " trip_id " + vehiclePosition.getTrip().getTripId() + " is missing start_time", errorListE006, _log); String prefix = "vehicle_id " + vehiclePosition.getVehicle().getId() + " trip_id " + vehiclePosition.getTrip().getTripId() + " schedule_relationship " + vehiclePosition.getTrip().getScheduleRelationship(); RuleUtils.addOccurrence(E013, prefix, errorListE013, _log);
if (!gtfsMetadata.getStopIds().contains(v.getStopId())) { String prefix = (v.hasVehicle() && v.getVehicle().hasId() ? "vehicle_id " + v.getVehicle().getId() + " " : "") + "stop_id " + v.getStopId(); RuleUtils.addOccurrence(E011, prefix, e011List, _log); if (locationType != null && locationType != 0) { String prefix = (v.hasVehicle() && v.getVehicle().hasId() ? "vehicle_id " + v.getVehicle().getId() + " " : "") + "stop_id " + v.getStopId(); RuleUtils.addOccurrence(E015, prefix, e015List, _log);
VehicleDescriptor vd = entity.getVehicle().getVehicle(); if (vd.hasId()) { vpm.setVehicleId(vd.getId());
VehicleDescriptor vehicle = entity.getTripUpdate().getVehicle(); if (vehicle != null) { tu.setVehicleId(vehicle.getId()); tu.setVehicleLabel(vehicle.getLabel()); tu.setVehicleLicensePlate(vehicle.getLicensePlate());
private void applyVehiclePositionToRecord(MonitoredResult result, BlockDescriptor blockDescriptor, VehiclePosition vehiclePosition, VehicleLocationRecord record) { Position position = vehiclePosition.getPosition(); if (vehiclePosition.hasTimestamp()) { record.setTimeOfLocationUpdate(TimeUnit.SECONDS.toMillis(vehiclePosition.getTimestamp())); //vehicle timestamp is in seconds } record.setCurrentLocationLat(position.getLatitude()); record.setCurrentLocationLon(position.getLongitude()); if (result != null) { result.addLatLon(position.getLatitude(), position.getLongitude()); } if (_scheduleAdherenceFromLocation) { CoordinatePoint location = new CoordinatePoint(position.getLatitude(), position.getLongitude()); double totalDistance = blockDescriptor.getBlockInstance().getBlock().getTotalBlockDistance(); long timestamp = vehiclePosition.hasTimestamp() ? record.getTimeOfLocationUpdate() : record.getTimeOfRecord(); ScheduledBlockLocation loc = _blockGeospatialService.getBestScheduledBlockLocationForLocation( blockDescriptor.getBlockInstance(), location, timestamp, 0, totalDistance); long serviceDateTime = record.getServiceDate(); long effectiveScheduleTime = loc.getScheduledTime() + (serviceDateTime/1000); double deviation = timestamp/1000 - effectiveScheduleTime; double oldDeviation = record.getScheduleDeviation(); record.setScheduleDeviation(deviation); _log.debug("deviation reset to {} from {} for vehicle {}", deviation, oldDeviation, vehiclePosition.getVehicle().getId()); } }
/** * Returns the vehicleID. If vehicle ID not available then returns vehicle * label. Returns null if no VehicleDescription associated with the vehicle * or if no ID or label associated with the VehicleDescription. * * @param vehicle * @return vehicle ID or label or null if there isn't one */ private static String getVehicleId(VehiclePosition vehicle) { if (!vehicle.hasVehicle()) { return null; } VehicleDescriptor desc = vehicle.getVehicle(); // Return vehicle ID if there is one if (desc.hasId()) return desc.getId(); // No vehicle ID so return vehicle label if there is one if (desc.hasLabel()) return desc.getLabel(); // No ID nor label so return null return null; }
/** * Returns vehicle and trip IDs text (vehicle_id X trip_id = Y) for the given entity if the entity is a VehiclePosition, or the trip ID text (trip_id = Y) for the given entity if the entity is a TripUpdate * * @param entity Either the VehiclePosition or TripUpdate for which to generate the ID text * @return vehicle and trip IDs text (vehicle_id X trip_id = Y) for the given entity if the entity is a VehiclePosition, or the trip ID text (trip_id = Y) for the given entity if the entity is a TripUpdate */ public static String getVehicleAndTripIdText(Object entity) { if (!(entity instanceof GtfsRealtime.VehiclePosition || entity instanceof GtfsRealtime.TripUpdate)) { throw new IllegalArgumentException("entity must be instance of VehiclePosition or TripUpdate"); } String ids = null; if (entity instanceof GtfsRealtime.VehiclePosition) { GtfsRealtime.VehiclePosition vp = (GtfsRealtime.VehiclePosition) entity; ids = "vehicle_id " + vp.getVehicle().getId() + " trip_id " + vp.getTrip().getTripId(); } else if (entity instanceof GtfsRealtime.TripUpdate) { GtfsRealtime.TripUpdate tu = (GtfsRealtime.TripUpdate) entity; ids = "trip_id " + tu.getTrip().getTripId(); } return ids; }
/** * Returns vehicle and route IDs text (vehicle_id X route_id = Y) for the given entity if the entity is a VehiclePosition, or the route ID text (route_id = Y) for the given entity if the entity is a TripUpdate * * @param entity Either the VehiclePosition or TripUpdate for which to generate the ID text * @return vehicle and route IDs text (vehicle_id X route_id = Y) for the given entity if the entity is a VehiclePosition, or the route ID text (route_id = Y) for the given entity if the entity is a TripUpdate */ public static String getVehicleAndRouteId(Object entity) { if (!(entity instanceof GtfsRealtime.VehiclePosition || entity instanceof GtfsRealtime.TripUpdate)) { throw new IllegalArgumentException("entity must be instance of VehiclePosition or TripUpdate"); } String ids = null; if (entity instanceof GtfsRealtime.VehiclePosition) { GtfsRealtime.VehiclePosition vp = (GtfsRealtime.VehiclePosition) entity; ids = "vehicle_id " + vp.getVehicle().getId() + " route_id " + vp.getTrip().getRouteId(); } else if (entity instanceof GtfsRealtime.TripUpdate) { GtfsRealtime.TripUpdate tu = (GtfsRealtime.TripUpdate) entity; ids = "route_id " + tu.getTrip().getRouteId(); } return ids; }
/** * @param vehicle * @return */ private String getVehicleId(VehiclePosition vehicle) { if (!vehicle.hasVehicle()) { return null; } VehicleDescriptor desc = vehicle.getVehicle(); if (!desc.hasId()) { return null; } return desc.getId(); }
/** * <code>optional string id = 1;</code> * * <pre> * Internal system identification of the vehicle. Should be unique per * vehicle, and can be used for tracking the vehicle as it proceeds through * the system. * </pre> */ public Builder clearId() { bitField0_ = (bitField0_ & ~0x00000001); id_ = getDefaultInstance().getId(); onChanged(); return this; } /**
/** * Returns the vehicle.id for the given VehicleDescriptor if one exists, if not the entity ID is returned in the format * "vehicle.id 1234" or "entity ID 4321". * * @param entity the entity that the VehiclePosition belongs to * @param vehicleDescriptor the vehicleDescriptor to get the ID for * @return the vehicle.id for the given VehiclePosition if one exists, if not the entity ID is returned in the format "vehicle.id 1234" or "entity ID 4321". */ public static String getVehicleId(GtfsRealtime.FeedEntity entity, GtfsRealtime.VehicleDescriptor vehicleDescriptor) { return vehicleDescriptor.hasId() ? "vehicle.id " + vehicleDescriptor.getId() : "entity ID " + entity.getId(); }
private String getVehicleId(TripUpdate tu) { if (_useLabelAsVehicleId && tu.hasVehicle() && tu.getVehicle().hasLabel()) return tu.getVehicle().getLabel(); return tu.getVehicle().getId(); } private String getVehicleId(VehiclePosition vp) {
private void cacheVehicleLocations(FeedMessage vehiclePositions) { for (FeedEntity entity : vehiclePositions.getEntityList()) { if (entity.hasVehicle()) { GtfsRealtime.VehiclePosition vehicle = entity.getVehicle(); _vehicleLocationListener.handleRawPosition( new AgencyAndId(getAgencyIds().get(0), vehicle.getVehicle().getId()), vehicle.getPosition().getLatitude(), vehicle.getPosition().getLongitude(), vehicle.getTimestamp()); } } }
private String getVehicleId(VehiclePosition vp) { if (_useLabelAsVehicleId && vp.hasVehicle() && vp.getVehicle().hasLabel()) return vp.getVehicle().getLabel(); return vp.getVehicle().getId(); }
/** * <code>optional string id = 1;</code> * * <pre> * Internal system identification of the vehicle. Should be unique per * vehicle, and can be used for tracking the vehicle as it proceeds through * the system. * </pre> */ public Builder clearId() { bitField0_ = (bitField0_ & ~0x00000001); id_ = getDefaultInstance().getId(); onChanged(); return this; } /**