/// <summary> /// Merges the formations by adding any potential matches to the matching <see cref="FormationMatcher"/> objects. /// </summary> public void MergeFormations() { if (IsBaseShape()) { foreach (Formation potentialFormation in _formationsBase) { if (_formations.Count > 0) { foreach (FormationMatcher formation in _formations) { formation.AddIfPotentialMatchByName(potentialFormation); } } else { FormationMatcher formation = new FormationMatcher(Name, potentialFormation.Name, potentialFormation.SubFormationName); formation.AddIfPotentialMatchByName(potentialFormation); AddFormationByRegionName(formation); } } } else { foreach (CompositeShape <Coordinate, Boundary, Extents> shape in this) { Region region = shape as Region; region?.MergeFormations(); } } }
/// <summary> /// Adds the formation to the region if the region name matches. /// </summary> /// <param name="formation">The location.</param> public bool AddFormationByRegionName(FormationMatcher formation) { if (!IsBaseShape()) { foreach (CompositeShape <Coordinate, Boundary, Extents> shape in this) { Region region = shape as Region; bool? result = region?.AddFormationByRegionName(formation); if (result.HasValue && result.Value) { return(true); } } } if (string.CompareOrdinal(formation.RegionName, Name) != 0) { return(false); } _formations.Add(formation); return(true); }