Beispiel #1
0
 /// <summary>
 /// Check if any combination of one name contains the other.
 /// </summary>
 /// <param name="formation">The formation.</param>
 /// <returns>System.Boolean.</returns>
 private bool potentialMatchByNameUnaltered(Formation formation)
 {
     return(eitherContainsOther(FormationName, formation.Name) ||
            eitherContainsOther(FormationName, formation.OtherName) ||
            eitherContainsOther(FormationName, formation.SubFormationName) ||
            eitherContainsOther(SubFormationName, formation.Name) ||
            eitherContainsOther(SubFormationName, formation.OtherName) ||
            eitherContainsOther(SubFormationName, formation.SubFormationName));
 }
Beispiel #2
0
        /// <summary>
        /// Determines whether there is a unique possible match where no user input is needed.
        /// If so, a valid index of the formation is returned.
        /// Returns -1 if no unique match was determined.
        /// </summary>
        /// <returns>System.Int32.</returns>
        private int uniqueMatchIndex()
        {
            switch (_possibleFormations.Count)
            {
            case 0:
                return(-1);

            case 1:
                return(0);

            default:     // For now, let's loosely assume that the following potential matches are reliable and don't require user selection
                Formation formation = probableMatchByName(_possibleFormations);
                return(formation == null ? -1 : _possibleFormations.IndexOf(formation));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Check with elevations normalized, e.g. no 13,749 or 13,749', just 13749.
        /// </summary>
        /// <param name="formation">The formation.</param>
        /// <returns><c>true</c> if if there is a match among any of the name combinations, <c>false</c> otherwise.</returns>
        private bool potentialMatchByNameNumeric(Formation formation)
        {
            string formationNameNormalizedNumeric                  = FormationName.GetNumbers();
            string subFormationNameNormalizedNumeric               = SubFormationName.GetNumbers();
            string potentialFormationNameNormalizedNumeric         = formation.Name.GetNumbers();
            string potentialFormationOtherNameNormalizedNumeric    = formation.OtherName.GetNumbers();
            string potentialSubFormationOtherNameNormalizedNumeric = formation.SubFormationName.GetNumbers();

            return(eitherContainsOther(formationNameNormalizedNumeric, potentialFormationNameNormalizedNumeric) ||
                   eitherContainsOther(formationNameNormalizedNumeric, potentialFormationOtherNameNormalizedNumeric) ||
                   eitherContainsOther(formationNameNormalizedNumeric, potentialSubFormationOtherNameNormalizedNumeric) ||
                   eitherContainsOther(subFormationNameNormalizedNumeric, potentialFormationNameNormalizedNumeric) ||
                   eitherContainsOther(subFormationNameNormalizedNumeric, potentialFormationOtherNameNormalizedNumeric) ||
                   eitherContainsOther(subFormationNameNormalizedNumeric, potentialSubFormationOtherNameNormalizedNumeric));
        }
Beispiel #4
0
        /// <summary>
        /// Check with the names singular and made non-possessive, with other tweaks for geographical name irregularities.
        /// </summary>
        /// <param name="formation">The formation.</param>
        /// <returns><c>true</c> if there is a match among any of the name combinations, <c>false</c> otherwise.</returns>
        private bool potentialMatchByNameNormalized(Formation formation)
        {
            string formationNameNormalized                  = FormationName.ApplyToIndividualWords(NormalizeGeographicName);
            string subFormationNameNormalized               = SubFormationName.ApplyToIndividualWords(NormalizeGeographicName);
            string potentialFormationNameNormalized         = formation.Name.ApplyToIndividualWords(NormalizeGeographicName);
            string potentialFormationOtherNameNormalized    = formation.OtherName.ApplyToIndividualWords(NormalizeGeographicName);
            string potentialSubFormationOtherNameNormalized = formation.SubFormationName.ApplyToIndividualWords(NormalizeGeographicName);

            return(eitherContainsOther(formationNameNormalized, potentialFormationNameNormalized) ||
                   eitherContainsOther(formationNameNormalized, potentialFormationOtherNameNormalized) ||
                   eitherContainsOther(formationNameNormalized, potentialSubFormationOtherNameNormalized) ||
                   eitherContainsOther(subFormationNameNormalized, potentialFormationNameNormalized) ||
                   eitherContainsOther(subFormationNameNormalized, potentialFormationOtherNameNormalized) ||
                   eitherContainsOther(subFormationNameNormalized, potentialSubFormationOtherNameNormalized));
        }
Beispiel #5
0
        /// <summary>
        /// Adds the formation to the region if the coordinates lie within the region shape.
        /// </summary>
        /// <param name="formation">The location.</param>
        public bool AddFormationByCoordinates(Formation formation)
        {
            if (!IsBaseShape())
            {
                foreach (CompositeShape <Coordinate, Boundary, Extents> shape in this)
                {
                    Region region = shape as Region;
                    bool?  result = region?.AddFormationByCoordinates(formation);
                    if (result.HasValue && result.Value)
                    {
                        return(true);
                    }
                }
            }

            if (!isWithinExtents(formation) || !PointIntersection.IsWithinShape(new Point(formation.Longitude, formation.Latitude), Boundary.Select(coordinate => (Point)coordinate).ToArray()))
            {
                return(false);
            }

            _formationsBase.Add(formation);
            return(true);
        }
Beispiel #6
0
 /// <summary>
 /// Determines whether the specified location is within extents.
 /// </summary>
 /// <param name="location">The location.</param>
 /// <returns><c>true</c> if the specified location is within extents; otherwise, <c>false</c>.</returns>
 private bool isWithinExtents(Formation location)
 {
     return(_extents.IsWithinExtents(new Coordinate(location.Latitude, location.Longitude)));
 }
Beispiel #7
0
 /// <summary>
 /// There is a potential match based on the various formation names.
 /// </summary>
 /// <param name="formation">The formation.</param>
 /// <returns><c>true</c> if is a potential match based on the various formation names, <c>false</c> otherwise.</returns>
 private bool potentialMatchByName(Formation formation)
 {
     return(potentialMatchByNameUnaltered(formation) ||
            potentialMatchByNameNormalized(formation) ||
            potentialMatchByNameNumeric(formation));
 }