示例#1
0
        /// <summary>
        /// Determines whether the specified address continues the group
        /// To continue the group the address must:
        ///   Have the same thoroughfare
        /// AND
        ///   Continue the sequence predicted by the group type
        /// </summary>
        /// <param name="address">The address</param>
        /// <param name="group">The group</param>
        /// <returns>True if the address continues the group, otherwise false</returns>
        private static bool ContinuesGroup(RouteLogSequencedPointsDTO address, RouteLogSummaryGroup group)
        {
            // Assume that the address does not continue the group
            bool doesContinueGroup = false;

            // If the thoroughfare is the same as in the last address
            if (address.StreetName == group.LastAddress.StreetName)
            {
                // Determine whether the group type for the address is the same as the group type
                GroupType groupTypeForAddress = IdentifyGroupType(address, group);
                if (groupTypeForAddress == group.CurrentGroupType)
                {
                    doesContinueGroup = true;
                }
            }

            // Return whether the address continues the group
            return(doesContinueGroup);
        }
示例#2
0
        /// <summary>
        /// Attempts to add the specified address to the group
        /// </summary>
        /// <param name="address">The address</param>
        /// <param name="group">The group</param>
        /// <returns>True if the address could be added to the group, otherwise false</returns>
        private static bool Add(RouteLogSequencedPointsDTO address, RouteLogSummaryGroup group)
        {
            // Determine whether the address should be part of the group
            //
            // Assume that the address is not part of the group
            bool canAdd = false;

            // If the group type is unknown
            if (group.CurrentGroupType == GroupType.Unknown)
            {
                // Identify the group type from the address
                group.CurrentGroupType = IdentifyGroupType(address, group);

                // The address can be added if the group type is known
                canAdd = group.CurrentGroupType != GroupType.Unknown;
            }
            else
            {
                // The address can be added if it continues the sequence predicted by the group type
                canAdd = ContinuesGroup(address, group);
            }

            // If the address can be added
            if (canAdd)
            {
                // Add the address to the group
                group.AddressList.Add(address);

                // Update the last address and last building number
                group.LastAddress        = address;
                group.LastBuildingNumber = address.BuildingNumber;

                // Update the delivery point count
                group.DeliveryPointCount++;

                // Update the multiple occupancy count if the address has multiple occupancy
                group.MultipleOccupancy = group.MultipleOccupancy + address.MultipleOccupancy;
            }

            // Return whether the address can be added to the group
            return(canAdd);
        }
示例#3
0
        /// <summary>
        /// This method is used to get the sequenced points summary
        /// </summary>
        /// <param name="addressList">addressList as List of route sequenced Points</param>
        /// <returns>routeSummary as List<RouteLogSequencedPointsDTO></returns>
        internal static List <RouteLogSummaryPoint> GetSequencedPointSummary(List <RouteLogSequencedPointsDTO> addressList)
        {
            // Initialize the list of summary points
            List <RouteLogSummaryPoint> summaryPoints = new List <RouteLogSummaryPoint>();

            // If there are any addresses to process
            if (addressList != null && addressList.Count > 0)
            {
                // Group
                // The group keeps track of the current group while the summary is being generated
                RouteLogSummaryGroup group = null;

                // Step through the addresses
                foreach (RouteLogSequencedPointsDTO address in addressList)
                {
                    // If the group is not set
                    if (group == null)
                    {
                        // The current address is the start of a new group
                        //
                        // Initialize a new group from the current address
                        group = new RouteLogSummaryGroup(address);
                    }
                    else
                    {
                        // If the current address can be added to the current group
                        if (Add(address, group))
                        {
                            // The address belongs to the current group
                            //
                            // Do nothing
                        }
                        else
                        {
                            // The address belongs to a new group
                            //
                            // Create a summary point from the current group
                            string specialInstructions   = string.Empty; // TODO update when special instruction functionality is available
                            string hazardsAndAreaHazards = string.Empty; // TODO update when hazards and area hazards functionality is available
                            RouteLogSummaryPoint row     = new RouteLogSummaryPoint(group.StreetName, group.Description, group.DeliveryPointCount.ToString(), group.MultipleOccupancy.ToString(), specialInstructions, hazardsAndAreaHazards);
                            summaryPoints.Add(row);

                            // Initialize a new group from the current address
                            group = new RouteLogSummaryGroup(address);
                        }
                    }
                }

                // If there is a group to process
                if (group != null)
                {
                    // Process the final group
                    //
                    // Create a summary point from the current group
                    string specialInstructions   = string.Empty; // TODO update when special instruction functionality is available
                    string hazardsAndAreaHazards = string.Empty; // TODO update when hazards and area hazards functionality is available
                    RouteLogSummaryPoint row     = new RouteLogSummaryPoint(group.StreetName, group.Description, group.DeliveryPointCount.ToString(), group.MultipleOccupancy.ToString(), specialInstructions, hazardsAndAreaHazards);
                    summaryPoints.Add(row);
                }
            }

            // Return the summary points
            return(summaryPoints);
        }
示例#4
0
        /// <summary>
        /// Identifies the group type using the address and the last address in the group
        /// </summary>
        /// <param name="address">The address</param>
        /// <param name="group">The group</param>
        /// <returns>The group type</returns>
        private static GroupType IdentifyGroupType(RouteLogSequencedPointsDTO address, RouteLogSummaryGroup group)
        {
            // Assume that the group type is unknown
            GroupType groupType = GroupType.Unknown;

            // Determine the group type
            //
            // If the last address and address has a standard building number
            if (HasStandardBuildingNumber(group.LastAddress) && HasStandardBuildingNumber(address))
            {
                // Determine the group type from the building numbers
                groupType = IdentifyGroupType(group.LastAddress.BuildingNumber.Value, address.BuildingNumber.Value);
            }
            else
            {
                // Only addresses with standard building numbers can be matched to a group type
                groupType = GroupType.Unknown;
            }

            // Return the group type
            return(groupType);
        }