public override WorkTrip GetAssociations(WorkTrip subject, WorkTrip candidateSubject) { bool hoursMatch = subject.FromHour == candidateSubject.FromHour && subject.ToHour == candidateSubject.ToHour; if (hoursMatch) { bool isInRange = AssociationCalculations.CalculateAssociation((double)subject.FromLongitude.Value, (double)subject.FromLatitude.Value, (double)candidateSubject.FromLongitude.Value, (double)candidateSubject.FromLatitude.Value, (double)subject.AcceptableDistance.Value); if (isInRange) { bool isInRangeTo = AssociationCalculations.CalculateAssociation((double)subject.ToLongitude.Value, (double)subject.ToLatitude.Value, (double)candidateSubject.ToLongitude.Value, (double)candidateSubject.ToLatitude.Value, (double)subject.AcceptableDistance.Value); if (isInRangeTo) { return(candidateSubject); } } } return(null); }
public List <IAssociationEntity> GetAssociationsFromCollection(WorkTrip requested, List <WorkTrip> subjects) { List <IAssociationEntity> result = new List <IAssociationEntity>(); foreach (WorkTrip item in subjects) { IAssociationEntity entity = new AssociationEntity(); entity.Current = requested; WorkTrip associated = GetAssociations(requested, item); if (associated != null) { entity.Associatated.Add(associated); //entity associated } result.Add(entity); } return(result); }
public abstract WorkTrip GetAssociations(WorkTrip subject, WorkTrip candidateSubject);