示例#1
0
        /// <summary>
        /// Determines whether a specified address has a standard building number
        /// A standard building number is a simple non-zero, positive integer building number
        ///   without a building name or sub name
        /// </summary>
        /// <param name="address">The address</param>
        /// <returns>True if the address has a standard building number, otherwise false</returns>
        private static bool HasStandardBuildingNumber(RouteLogSequencedPointsDTO address)
        {
            // The building number is standard if it is a positive non-zero value
            bool isStandard = false;

            if (address.BuildingNumber.HasValue)
            {
                if (address.BuildingNumber.Value > 0)
                {
                    isStandard = true;
                }
            }

            // If the building number is standard
            if (isStandard)
            {
                // If the building also has a name or a sub name
                if (!string.IsNullOrWhiteSpace(address.SubBuildingName) || !string.IsNullOrWhiteSpace(address.BuildingName))
                {
                    // The building number is not standard
                    isStandard = false;
                }
            }

            // Return whether the address has a standard building number
            return(isStandard);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
0
        /// <summary>
        /// Constructs route log summary group with an initial address
        /// </summary>
        /// <param name="address">The address</param>
        public RouteLogSummaryGroup(RouteLogSequencedPointsDTO address)
        {
            // Default the group type
            this.CurrentGroupType = GroupType.Unknown;

            // Add the address to the group
            this.AddressList.Add(address);

            // Update the last address and first and last building numbers
            this.LastAddress         = address;
            this.FirstBuildingNumber = address.BuildingNumber;
            this.LastBuildingNumber  = null;

            // Initialize the delivery point count
            this.DeliveryPointCount = 1;

            // Initialize the multiple occupancy count
            this.MultipleOccupancy = address.MultipleOccupancy;
            this.StreetName        = address.StreetName;
            this.SubBuildingName   = address.SubBuildingName;
            this.BuildingName      = address.BuildingName;
        }
示例#5
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);
        }