String vehicleId = entity.getVehicle().getVehicle().getId(); String tripId = ""; if (entity.getVehicle().hasTrip() && entity.getVehicle().getTrip().hasTripId()) {
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);
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 (!vehiclePosition.getVehicle().hasId()) {
VehicleDescriptor vd = entity.getVehicle().getVehicle(); if (vd.hasId()) { vpm.setVehicleId(vd.getId());
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);
mergeVehicle(other.getVehicle());
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()); } }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (hasTrip()) { if (!getTrip().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (hasVehicle()) { if (!getVehicle().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (hasPosition()) { if (!getPosition().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (!extensionsAreInitialized()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; }
/** * 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; }
/** * Returns the vehicleID. Returns null if no VehicleDescription associated * with the vehicle or if no ID associated with the VehicleDescription. * * @param vehicle * @return vehicle ID or null if there isn't one */ private static String getLicensePlate(VehiclePosition vehicle) { if (!vehicle.hasVehicle()) { return null; } VehicleDescriptor desc = vehicle.getVehicle(); if (!desc.hasLicensePlate()) { return null; } return desc.getLicensePlate(); }
/** * @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(); }
/** * Returns 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". * * @param entity the entity that the VehiclePosition belongs to * @param vehiclePosition the VehiclePosition 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.VehiclePosition vehiclePosition) { if (!vehiclePosition.hasVehicle()) { return "entity ID " + entity.getId(); } return getVehicleId(entity, vehiclePosition.getVehicle()); }
/** * Returns true if this vehiclePosition has a vehicle ID, false if it does not * * @param vehiclePosition to examine * @return true if this vehiclePosition has a vehicle ID, false if it does not */ private boolean hasVehicleId(GtfsRealtime.VehiclePosition vehiclePosition) { return vehiclePosition.hasVehicle() && vehiclePosition.getVehicle().hasId(); }
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(); }
mergeVehicle(other.getVehicle());
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (hasTrip()) { if (!getTrip().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (hasVehicle()) { if (!getVehicle().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (hasPosition()) { if (!getPosition().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (!extensionsAreInitialized()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; }