Exemplo n.º 1
0
        public static void SetEscortPercentages(IPersonDayWrapper personDay, out double escortPercentage, out double nonEscortPercentage, bool excludeWorkAndSchool = false)
        {
            if (personDay == null || personDay.HomeBasedTours == 0)
            {
                escortPercentage    = 0;
                nonEscortPercentage = 0;
            }
            else
            {
                var totalTours     = excludeWorkAndSchool ? personDay.GetTotalToursExcludingWorkAndSchool() : personDay.GetTotalTours();
                var totalStops     = excludeWorkAndSchool ? personDay.GetTotalStopsExcludingWorkAndSchool() : personDay.GetTotalStops();
                var escortStopFlag = (personDay.EscortStops > 0).ToFlag();

                escortPercentage    = escortStopFlag / Math.Max(totalTours, 1.0);
                nonEscortPercentage = (totalStops - escortStopFlag) / Math.Max(totalTours, 1.0);
            }
        }