if (fuzzyTripMatcher != null && informed.hasTrip()) { TripDescriptor trip = fuzzyTripMatcher.match(feedId, informed.getTrip()); informed = informed.toBuilder().setTrip(trip).build(); if (informed.hasRouteId()) { routeId = informed.getRouteId(); if (informed.hasTrip() && informed.getTrip().hasDirectionId()) { direction = informed.getTrip().getDirectionId(); } else { direction = -1; if (informed.hasTrip() && informed.getTrip().hasTripId()) { tripId = informed.getTrip().getTripId(); if (informed.hasStopId()) { stopId = informed.getStopId(); String agencyId = informed.getAgencyId(); if (informed.hasAgencyId()) { agencyId = informed.getAgencyId().intern();
checkE033(entity, entitySelector, errorListE033); checkE034(entity, entitySelector, gtfsMetadata, errorListE034); checkE035(entity, entitySelector.getTrip(), gtfsMetadata, errorListE035); if (entitySelector.hasRouteId() && entitySelector.hasTrip()) { checkE030(entity, entitySelector, gtfsMetadata, errorListE030); checkE031(entity, entitySelector, errorListE031); if (entitySelector.hasTrip()) { checkW006(entity, entitySelector.getTrip(), errorListW006); checkW009(entity, entitySelector.getTrip(), errorListW009);
List<GtfsRealtime.EntitySelector> informedEntityList = entity.getAlert().getInformedEntityList(); for (GtfsRealtime.EntitySelector entitySelector : informedEntityList) { if (entitySelector.hasStopId()) { String prefix = "alert entity ID " + entityId + " stop_id " + entitySelector.getStopId(); if (!gtfsMetadata.getStopIds().contains(entitySelector.getStopId())) { Integer locationType = gtfsMetadata.getStopToLocationTypeMap().get(entitySelector.getStopId()); if (locationType != null && locationType != 0) {
if (a.hasEffect() && a.getEffect().equals(GtfsRealtime.Alert.Effect.DETOUR)) { for (GtfsRealtime.EntitySelector entitySelector : a.getInformedEntityList()) { if (entitySelector.hasTrip()) { if (tripId.equals(entitySelector.getTrip().getTripId())) { if (routeId != null && routeId.equals(entitySelector.getTrip().getRouteId())) {
return null; EntitySelectorModel esm = new EntitySelectorModel(); if (es.hasAgencyId()) { esm.setAgencyId(es.getAgencyId()); if (es.hasRouteId()) { esm.setRouteId(es.getRouteId()); if (es.hasRouteType()) { esm.setRouteType(es.getRouteType()); if (es.hasStopId()) { esm.setStopId(es.getStopId()); if (es.hasTrip()) { TripDescriptor t = es.getTrip(); if (t.hasTripId()) esm.setTripId(t.getTripId());
public Builder mergeFrom(com.google.transit.realtime.GtfsRealtime.EntitySelector other) { if (other == com.google.transit.realtime.GtfsRealtime.EntitySelector.getDefaultInstance()) return this; if (other.hasAgencyId()) { bitField0_ |= 0x00000001; agencyId_ = other.agencyId_; onChanged(); } if (other.hasRouteId()) { bitField0_ |= 0x00000002; routeId_ = other.routeId_; onChanged(); } if (other.hasRouteType()) { setRouteType(other.getRouteType()); } if (other.hasTrip()) { mergeTrip(other.getTrip()); } if (other.hasStopId()) { bitField0_ |= 0x00000010; stopId_ = other.stopId_; onChanged(); } this.mergeExtensionFields(other); this.mergeUnknownFields(other.getUnknownFields()); return this; }
/** * Checks rule E033 - "Alert informed_entity does not have any specifiers" and adds * any errors that are found to the provided errors list * * @param entity feed entity to examine that contains an alert * @param entitySelector EntitySelector to examine for specifiers * @param errors list to add any errors for E033 to */ private void checkE033(GtfsRealtime.FeedEntity entity, GtfsRealtime.EntitySelector entitySelector, List<OccurrenceModel> errors) { GtfsRealtime.TripDescriptor trip = null; if (entitySelector.hasTrip()) { trip = entitySelector.getTrip(); } if (!entitySelector.hasAgencyId() && !entitySelector.hasRouteId() && !entitySelector.hasRouteType() && !entitySelector.hasStopId()) { // informed_entity isn't populated - check TripDescriptor if (trip == null || (!trip.hasTripId() && !trip.hasRouteId())) { RuleUtils.addOccurrence(E033, "alert ID " + entity.getId() + " informed_entity and informed_entity.trip do not not reference any agency, route, trip, or stop", errors, _log); } } }
private Affects.Builder getEntitySelectorAsAffects(EntitySelector selector, Map agencyIdMap) { Affects.Builder affects = Affects.newBuilder(); if (selector.hasAgencyId()) { String agencyId = selector.getAgencyId(); if (agencyIdMap != null && agencyIdMap.get(agencyId) != null) { agencyId = (String) agencyIdMap.get(agencyId); } affects.setAgencyId(agencyId); } if (selector.hasRouteId()) { Id routeId = _entitySource.getRouteId(selector.getRouteId()); affects.setRouteId(routeId); } if (selector.hasStopId()) { Id stopId = _entitySource.getStopId(selector.getStopId()); affects.setStopId(stopId); } if (selector.hasTrip()) { TripDescriptor trip = selector.getTrip(); if (trip.hasTripId()) affects.setTripId(_entitySource.getTripId(trip.getTripId())); else if (trip.hasRouteId()) affects.setRouteId(_entitySource.getRouteId(trip.getRouteId())); } return affects; }
/** * Checks rule E030 - "GTFS-rt alert trip_id does not belong to GTFS-rt alert route_id in GTFS trips.txt" and adds * any errors that are found to the provided errors list * * @param entity feed entity to examine that contains an alert * @param entitySelector EntitySelector that has both a routeId and a tripDescriptor * @param gtfsMetadata metadata for the static GTFS data * @param errors list to add any errors for E030 to */ private void checkE030(GtfsRealtime.FeedEntity entity, GtfsRealtime.EntitySelector entitySelector, GtfsMetadata gtfsMetadata, List<OccurrenceModel> errors) { String routeId = entitySelector.getRouteId(); GtfsRealtime.TripDescriptor tripDescriptor = entitySelector.getTrip(); if (tripDescriptor.hasTripId()) { Trip gtfsTrip = gtfsMetadata.getTrips().get(tripDescriptor.getTripId()); if (gtfsTrip != null && !routeId.equals(gtfsTrip.getRoute().getId().getId())) { String prefix = "alert ID " + entity.getId() + " informed_entity.trip.trip_id " + tripDescriptor.getTripId() + " does not belong to informed_entity.route_id " + routeId + " (GTFS says it belongs to route_id " + gtfsTrip.getRoute().getId().getId() + ")"; RuleUtils.addOccurrence(E030, prefix, errors, _log); } } }
/** * <code>optional string agency_id = 1;</code> * * <pre> * The values of the fields should correspond to the appropriate fields in the * GTFS feed. * At least one specifier must be given. If several are given, then the * matching has to apply to all the given specifiers. * </pre> */ public Builder clearAgencyId() { bitField0_ = (bitField0_ & ~0x00000001); agencyId_ = getDefaultInstance().getAgencyId(); onChanged(); return this; } /**
/** * Checks rule E031 - "Alert informed_entity.route_id does not match informed_entity.trip.route_id" and adds * any errors that are found to the provided errors list * * @param entity feed entity to examine that contains an alert * @param entitySelector EntitySelector that has both a routeId and a tripDescriptor * @param errors list to add any errors for E031 to */ private void checkE031(GtfsRealtime.FeedEntity entity, GtfsRealtime.EntitySelector entitySelector, List<OccurrenceModel> errors) { if (entitySelector.getTrip().hasRouteId()) { String routeId = entitySelector.getRouteId(); if (!entitySelector.getTrip().getRouteId().equals(routeId)) { RuleUtils.addOccurrence(E031, "alert ID " + entity.getId() + " informed_entity.route_id " + routeId + " does not equal informed_entity.trip.route_id " + entitySelector.getTrip().getRouteId(), errors, _log); } } }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (hasTrip()) { if (!getTrip().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (!extensionsAreInitialized()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; }
/** * Checks rule E034 - "GTFS-rt agency_id does not exist in GTFS data", and adds any errors that are found to the provided error list * * @param entity feed entity to examine that contains an alert * @param entitySelector EntitySelector to examine for agency_id specifier * @param gtfsMetadata information about the GTFS dataset * @param errors list to add any errors for E034 to */ private void checkE034(GtfsRealtime.FeedEntity entity, GtfsRealtime.EntitySelector entitySelector, GtfsMetadata gtfsMetadata, List<OccurrenceModel> errors) { if (entitySelector.hasAgencyId()) { if (!gtfsMetadata.getAgencyIds().contains(entitySelector.getAgencyId())) { RuleUtils.addOccurrence(E034, "alert ID " + entity.getId() + " agency_id " + entitySelector.getAgencyId(), errors, _log); } } }
/** * <code>optional string route_id = 2;</code> */ public Builder clearRouteId() { bitField0_ = (bitField0_ & ~0x00000002); routeId_ = getDefaultInstance().getRouteId(); onChanged(); return this; } /**
/** * <code>optional string stop_id = 5;</code> */ public Builder clearStopId() { bitField0_ = (bitField0_ & ~0x00000010); stopId_ = getDefaultInstance().getStopId(); onChanged(); return this; } /**
public Builder mergeFrom(com.google.transit.realtime.GtfsRealtime.EntitySelector other) { if (other == com.google.transit.realtime.GtfsRealtime.EntitySelector.getDefaultInstance()) return this; if (other.hasAgencyId()) { bitField0_ |= 0x00000001; agencyId_ = other.agencyId_; onChanged(); } if (other.hasRouteId()) { bitField0_ |= 0x00000002; routeId_ = other.routeId_; onChanged(); } if (other.hasRouteType()) { setRouteType(other.getRouteType()); } if (other.hasTrip()) { mergeTrip(other.getTrip()); } if (other.hasStopId()) { bitField0_ |= 0x00000010; stopId_ = other.stopId_; onChanged(); } this.mergeExtensionFields(other); this.mergeUnknownFields(other.getUnknownFields()); return this; }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (hasTrip()) { if (!getTrip().isInitialized()) { memoizedIsInitialized = 0; return false; } } if (!extensionsAreInitialized()) { memoizedIsInitialized = 0; return false; } memoizedIsInitialized = 1; return true; }
/** * <code>optional string agency_id = 1;</code> * * <pre> * The values of the fields should correspond to the appropriate fields in the * GTFS feed. * At least one specifier must be given. If several are given, then the * matching has to apply to all the given specifiers. * </pre> */ public Builder clearAgencyId() { bitField0_ = (bitField0_ & ~0x00000001); agencyId_ = getDefaultInstance().getAgencyId(); onChanged(); return this; } /**
/** * <code>optional string stop_id = 5;</code> */ public Builder clearStopId() { bitField0_ = (bitField0_ & ~0x00000010); stopId_ = getDefaultInstance().getStopId(); onChanged(); return this; } /**
/** * <code>optional string route_id = 2;</code> */ public Builder clearRouteId() { bitField0_ = (bitField0_ & ~0x00000002); routeId_ = getDefaultInstance().getRouteId(); onChanged(); return this; } /**