Class TripMergeStrategy
java.lang.Object
org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
org.onebusaway.gtfs_merge.strategies.AbstractSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>
org.onebusaway.gtfs_merge.strategies.AbstractIdentifiableSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>
org.onebusaway.gtfs_merge.strategies.TripMergeStrategy
- All Implemented Interfaces:
EntityMergeStrategy
public class TripMergeStrategy
extends AbstractIdentifiableSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>
Entity merge strategy for handling
Trip entities. This strategy also handles merging the
StopTime entities associated with each trip.- Author:
- bdferris
-
Nested Class Summary
Nested classes/interfaces inherited from class org.onebusaway.gtfs_merge.strategies.AbstractIdentifiableSingleEntityMergeStrategy
AbstractIdentifiableSingleEntityMergeStrategy.ScoringTask<T> -
Field Summary
Fields inherited from class org.onebusaway.gtfs_merge.strategies.AbstractIdentifiableSingleEntityMergeStrategy
_duplicateScoringStrategyFields inherited from class org.onebusaway.gtfs_merge.strategies.AbstractSingleEntityMergeStrategy
_entityTypeFields inherited from class org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
_duplicateDetectionStrategy, _logDuplicatesStrategy, _minElementDuplicateScoreForFuzzyMatch, _minElementsDuplicateScoreForAutoDetect, _minElementsInCommonScoreForAutoDetect -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgetEntityTypes(Collection<Class<?>> entityTypes) Recall that we handleStopTimeentities in addition toTripentities.protected booleanrejectDuplicateOverDifferences(GtfsMergeContext context, org.onebusaway.gtfs.model.Trip sourceEntity, org.onebusaway.gtfs.model.Trip targetDuplicate) Even if we have detected that two trips are duplicates, they might have slight differences that prevent them from being represented as one merged trip.protected voidreplaceDuplicateEntry(GtfsMergeContext context, org.onebusaway.gtfs.model.Trip oldTrip, org.onebusaway.gtfs.model.Trip newTrip) If we've detected a duplicate for an entity in the source feed with some entity in the merged output feed, we want to replace all references to the old entity with the new merged entity.protected voidsave(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity) Saves the specified entity to the merged output feed.Methods inherited from class org.onebusaway.gtfs_merge.strategies.AbstractIdentifiableSingleEntityMergeStrategy
getFuzzyDuplicate, getIdentityDuplicate, pickBestDuplicateDetectionStrategy, rename, toStringMethods inherited from class org.onebusaway.gtfs_merge.strategies.AbstractSingleEntityMergeStrategy
getDescription, merge, mergeEntityMethods inherited from class org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
determineDuplicateDetectionStrategy, getDuplicateRenamingStrategy, setDuplicateDetectionStrategy, setDuplicateRenamingStrategy, setLogDuplicatesStrategy
-
Constructor Details
-
TripMergeStrategy
public TripMergeStrategy()
-
-
Method Details
-
getEntityTypes
Recall that we handleStopTimeentities in addition toTripentities.- Specified by:
getEntityTypesin interfaceEntityMergeStrategy- Overrides:
getEntityTypesin classAbstractSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>- Parameters:
entityTypes- the handled types should be added to this output collection.
-
rejectDuplicateOverDifferences
protected boolean rejectDuplicateOverDifferences(GtfsMergeContext context, org.onebusaway.gtfs.model.Trip sourceEntity, org.onebusaway.gtfs.model.Trip targetDuplicate) Even if we have detected that two trips are duplicates, they might have slight differences that prevent them from being represented as one merged trip. For example, if a trip in a subsequent feed adds, removes, or modifies a stop time, we might avoid merging the two trips such that the schedule is correct in the merged feed.TODO: Think about how this should be applied in relation to the service calendars of the two trips.
- Overrides:
rejectDuplicateOverDifferencesin classAbstractSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>- Parameters:
context-sourceEntity-targetDuplicate-- Returns:
-
replaceDuplicateEntry
protected void replaceDuplicateEntry(GtfsMergeContext context, org.onebusaway.gtfs.model.Trip oldTrip, org.onebusaway.gtfs.model.Trip newTrip) Description copied from class:AbstractSingleEntityMergeStrategyIf we've detected a duplicate for an entity in the source feed with some entity in the merged output feed, we want to replace all references to the old entity with the new merged entity. Sub-classes will override this method to provide logic specific to particular entity types, as it relates to updating entity references.- Specified by:
replaceDuplicateEntryin classAbstractSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>- Parameters:
context-oldTrip- the old entity in the source feed that should be replacednewTrip- the new entity in the output merged feed that duplicates the old entity
-
save
Description copied from class:AbstractIdentifiableSingleEntityMergeStrategySaves the specified entity to the merged output feed. If the raw id of the entity duplicates an existing entity in the output feed, its id will be renamed.- Overrides:
savein classAbstractIdentifiableSingleEntityMergeStrategy<org.onebusaway.gtfs.model.Trip>- Parameters:
context-entity-
-