예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public abstract WorkTrip GetAssociations(WorkTrip subject, WorkTrip candidateSubject);