WholePercentages

This commit is contained in:
2023-06-21 07:24:32 -07:00
parent 8863fd763f
commit 1d0506d74c
22 changed files with 254 additions and 255 deletions

View File

@ -18,7 +18,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
protected readonly ReadOnlyDictionary<int, List<int>> _SkipNotSkipCollection;
protected readonly ReadOnlyDictionary<long, PersonContainer> _PersonKeyToPersonContainer;
protected readonly List<LocationContainer<MetadataExtractor.Directory>> _LocationContainers;
protected readonly ReadOnlyDictionary<int, Dictionary<int, PersonContainer[]>> _IdThenNormalizedRectangleToPersonContainers;
protected readonly ReadOnlyDictionary<int, Dictionary<int, PersonContainer[]>> _IdThenWholePercentagesToPersonContainers;
private readonly long _Ticks;
private readonly Serilog.ILogger? _Log;
@ -44,7 +44,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
List<LocationContainer<MetadataExtractor.Directory>> locationContainers = new();
string? rootDirectoryParent = Path.GetDirectoryName(propertyConfiguration.RootDirectory);
string eDistanceContentTicksDirectory = Path.Combine(eDistanceContentDirectory, $"({ticks})");
Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers = new();
Dictionary<int, Dictionary<int, PersonContainer[]>> idThenWholePercentagesToPersonContainers = new();
Dictionary<int, List<LocationContainer<MetadataExtractor.Directory>>> idToLocationContainers = new();
if (string.IsNullOrEmpty(rootDirectoryParent))
throw new NullReferenceException(nameof(rootDirectoryParent));
@ -63,7 +63,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
skipCollection,
skipNotSkipCollection,
locationContainers,
idThenNormalizedRectangleToPersonContainers);
idThenWholePercentagesToPersonContainers);
}
foreach (string propertyContentCollectionFile in propertyConfiguration.PropertyContentCollectionFiles)
{
@ -83,7 +83,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
_PersonKeyToPersonContainer = new(personKeyToPersonContainer);
_EDistanceContentTicksDirectory = eDistanceContentTicksDirectory;
_NotMappedPersonContainers = notMappedPersonContainers.OrderByDescending(l => l.Key).ToList();
_IdThenNormalizedRectangleToPersonContainers = new(idThenNormalizedRectangleToPersonContainers);
_IdThenWholePercentagesToPersonContainers = new(idThenWholePercentagesToPersonContainers);
}
public override string ToString()
@ -113,11 +113,11 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
List<int>? collection;
PersonBirthday personBirthday;
List<string> shouldMove = new();
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> idToCollection in _IdThenNormalizedRectangleToPersonContainers)
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> idToCollection in _IdThenWholePercentagesToPersonContainers)
{
foreach (KeyValuePair<int, PersonContainer[]> normalizedRectangleToPersonContainers in idToCollection.Value)
foreach (KeyValuePair<int, PersonContainer[]> wholePercentagesToPersonContainers in idToCollection.Value)
{
foreach (PersonContainer personContainer in normalizedRectangleToPersonContainers.Value)
foreach (PersonContainer personContainer in wholePercentagesToPersonContainers.Value)
{
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
continue;
@ -142,10 +142,10 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
return results;
}
(bool, Dictionary<int, PersonContainer[]>?) Shared.Models.Methods.IMapLogic.GetNormalizedRectangleToPersonContainers(int id)
(bool, Dictionary<int, PersonContainer[]>?) Shared.Models.Methods.IMapLogic.GetWholePercentagesToPersonContainers(int id)
{
bool result = _IdThenNormalizedRectangleToPersonContainers.TryGetValue(id, out Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers);
return new(result, normalizedRectangleToPersonContainers);
bool result = _IdThenWholePercentagesToPersonContainers.TryGetValue(id, out Dictionary<int, PersonContainer[]>? wholePercentagesToPersonContainers);
return new(result, wholePercentagesToPersonContainers);
}
public int UpdateMappingFromPerson(Mapping mapping)
@ -158,19 +158,19 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
string mappingSegmentB;
PersonBirthday personBirthday;
PersonContainer[]? personContainers;
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
Dictionary<int, PersonContainer[]>? wholePercentagesToPersonContainers;
for (int i = 1; i < 2; i++)
{
if (mapping.MappingFromLocation is null)
continue;
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangleToPersonContainers))
if (!_IdThenWholePercentagesToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out wholePercentagesToPersonContainers))
{
if (mapping.MappingFromFilter.InSkipCollection is not null && mapping.MappingFromFilter.InSkipCollection.Value)
continue;
result += 1;
continue;
}
if (!normalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out personContainers))
if (!wholePercentagesToPersonContainers.TryGetValue(mapping.MappingFromLocation.WholePercentages, out personContainers))
{
if (mapping.MappingFromFilter.InSkipCollection is not null && mapping.MappingFromFilter.InSkipCollection.Value)
continue;
@ -359,7 +359,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
string personKeyFormatted;
PersonBirthday personBirthday;
PersonContainer personContainer;
result = Path.Combine(_EDistanceContentTicksDirectory, by, sortingContainer.Sorting.Id.ToString(), sortingContainer.Sorting.NormalizedRectangle.ToString());
result = Path.Combine(_EDistanceContentTicksDirectory, by, sortingContainer.Sorting.Id.ToString(), sortingContainer.Sorting.WholePercentages.ToString());
for (int i = _NotMappedPersonContainers.Count - 1; i > 0; i--)
{
personContainer = _NotMappedPersonContainers[i];
@ -378,7 +378,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
return result;
}
private List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, string d2FacePartsContentCollectionDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, Dictionary<long, List<int>> personKeyToIds, int? useFiltersCounter, bool saveMapped, bool saveIndividually, bool sortingContainersAny)
private List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, string d2FacePartsContentCollectionDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToWholePercentagesToMapping, Dictionary<long, List<int>> personKeyToIds, int? useFiltersCounter, bool saveMapped, bool saveIndividually, bool sortingContainersAny)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -404,7 +404,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
FileHolder facePartsFileHolder;
FileHolder hiddenFaceFileHolder;
string? facePartsContentCollectionFile;
Dictionary<int, Mapping>? normalizedRectangleToMapping;
Dictionary<int, Mapping>? wholePercentagesToMapping;
int padLeft = _Configuration.FaceDistancePermyriad.ToString().Length;
string forceSingleImageHumanized = nameof(Shared.Models.Stateless.IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
foreach (Mapping mapping in mappingCollection)
@ -479,14 +479,14 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
keyMapping = null;
else
{
if (!idToNormalizedRectangleToMapping.TryGetValue(mapping.SortingContainer.Sorting.Id, out normalizedRectangleToMapping))
if (!idToWholePercentagesToMapping.TryGetValue(mapping.SortingContainer.Sorting.Id, out wholePercentagesToMapping))
continue;
if (!normalizedRectangleToMapping.ContainsKey(mapping.SortingContainer.Sorting.NormalizedRectangle))
if (!wholePercentagesToMapping.ContainsKey(mapping.SortingContainer.Sorting.WholePercentages))
continue;
keyMapping = normalizedRectangleToMapping[mapping.SortingContainer.Sorting.NormalizedRectangle];
keyMapping = wholePercentagesToMapping[mapping.SortingContainer.Sorting.WholePercentages];
if (keyMapping.MappingFromLocation is null)
continue;
if (saveIndividually && keyMapping.MappingFromLocation.NormalizedRectangle == mapping.MappingFromLocation.NormalizedRectangle)
if (saveIndividually && keyMapping.MappingFromLocation.WholePercentages == mapping.MappingFromLocation.WholePercentages)
results.Add(new(Path.Combine(directory, "Maybe")));
}
facesDirectory = Stateless.MapLogic.GetFacesDirectory(dFacesContentDirectory, mapping.MappingFromItem);
@ -545,18 +545,18 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
return results;
}
public List<SaveContainer> GetSaveContainers(bool saveIndividually, string dFacesContentDirectory, string d2FacePartsContentDirectory, string d2FacePartsContentCollectionDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, int? useFiltersCounter, bool sortingContainersAny)
public List<SaveContainer> GetSaveContainers(bool saveIndividually, string dFacesContentDirectory, string d2FacePartsContentDirectory, string d2FacePartsContentCollectionDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToWholePercentagesToMapping, int? useFiltersCounter, bool sortingContainersAny)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
List<SaveContainer> results;
bool saveMapped = false;
Dictionary<long, List<int>> personKeyToIds = new();
results = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, d2FacePartsContentCollectionDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToIds, useFiltersCounter, saveMapped, saveIndividually, sortingContainersAny);
results = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, d2FacePartsContentCollectionDirectory, mappingCollection, idToWholePercentagesToMapping, personKeyToIds, useFiltersCounter, saveMapped, saveIndividually, sortingContainersAny);
return results;
}
public void SaveMapped(string dFacesContentDirectory, string d2FacePartsContentDirectory, string d2FacePartsContentCollectionDirectory, Dictionary<long, List<int>> personKeyToIds, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, int totalNotMapped)
public void SaveMapped(string dFacesContentDirectory, string d2FacePartsContentDirectory, string d2FacePartsContentCollectionDirectory, Dictionary<long, List<int>> personKeyToIds, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToWholePercentagesToMapping, int totalNotMapped)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -565,7 +565,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
int? useFiltersCounter = null;
bool saveIndividually = false;
string mappingDirectory = Path.Combine(_EDistanceContentTicksDirectory, nameof(Shared.Models.Stateless.IMapLogic.Mapping));
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, d2FacePartsContentCollectionDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToIds, useFiltersCounter, saveMapped, sortingContainersAny: true, saveIndividually: false);
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, d2FacePartsContentCollectionDirectory, mappingCollection, idToWholePercentagesToMapping, personKeyToIds, useFiltersCounter, saveMapped, sortingContainersAny: true, saveIndividually: false);
SaveContainers(saveIndividually, totalNotMapped, updated, saveContainers);
if (!string.IsNullOrEmpty(_EDistanceContentTicksDirectory) && Directory.Exists(mappingDirectory))
Stateless.MapLogic.SaveMappingShortcuts(mappingDirectory);
@ -574,15 +574,15 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
public bool Used(FaceDistance faceDistanceEncoding)
{
bool result = false;
if (faceDistanceEncoding.NormalizedRectangle is null)
if (faceDistanceEncoding.WholePercentages is null)
throw new NotSupportedException();
List<int>? normalizedRectangles;
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles) && normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value))
List<int>? wholePercentagesCollection;
Dictionary<int, PersonContainer[]>? wholePercentagesToPersonContainers;
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out wholePercentagesCollection) && wholePercentagesCollection.Contains(faceDistanceEncoding.WholePercentages.Value))
result = true;
if (!result && _IdThenNormalizedRectangleToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangleToPersonContainers))
if (!result && _IdThenWholePercentagesToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out wholePercentagesToPersonContainers))
{
if (normalizedRectangleToPersonContainers.ContainsKey(faceDistanceEncoding.NormalizedRectangle.Value))
if (wholePercentagesToPersonContainers.ContainsKey(faceDistanceEncoding.WholePercentages.Value))
result = true;
}
return result;
@ -595,26 +595,26 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
List<Sorting> results = new();
Sorting sorting;
FaceDistance faceDistanceLength;
List<int>? normalizedRectangles;
List<int>? wholePercentagesCollection;
bool skipNotSkipCollectionAny = _SkipNotSkipCollection.Any();
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
Dictionary<int, PersonContainer[]>? wholePercentagesToPersonContainers;
for (int j = 0; j < faceDistanceLengths.Count; j++)
{
if (faceDistanceEncoding.NormalizedRectangle is null)
if (faceDistanceEncoding.WholePercentages is null)
throw new NotSupportedException();
if (j == i)
continue;
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles) && normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value))
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out wholePercentagesCollection) && wholePercentagesCollection.Contains(faceDistanceEncoding.WholePercentages.Value))
continue;
if (skipNotSkipCollectionAny && (!_SkipNotSkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles) || !normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value)))
if (skipNotSkipCollectionAny && (!_SkipNotSkipCollection.TryGetValue(faceDistanceEncoding.Id, out wholePercentagesCollection) || !wholePercentagesCollection.Contains(faceDistanceEncoding.WholePercentages.Value)))
continue;
if (_IdThenNormalizedRectangleToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangleToPersonContainers))
if (_IdThenWholePercentagesToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out wholePercentagesToPersonContainers))
{
if (normalizedRectangleToPersonContainers.ContainsKey(faceDistanceEncoding.NormalizedRectangle.Value))
if (wholePercentagesToPersonContainers.ContainsKey(faceDistanceEncoding.WholePercentages.Value))
continue;
}
faceDistanceLength = faceDistanceLengths[j];
if (faceDistanceLength.NormalizedRectangle is null || faceDistanceLength.Length is null)
if (faceDistanceLength.WholePercentages is null || faceDistanceLength.Length is null)
throw new NotSupportedException();
if (faceDistanceLength.Length == 0)
continue;
@ -623,7 +623,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
continue;
if (sorting.Id == faceDistanceEncoding.Id)
{
if (sorting.NormalizedRectangle == faceDistanceEncoding.NormalizedRectangle.Value)
if (sorting.WholePercentages == faceDistanceEncoding.WholePercentages.Value)
continue;
continue;
}
@ -648,13 +648,13 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
string personKeyFormatted;
PersonBirthday personBirthday;
PersonContainer[]? personContainers;
List<int> wholePercentagesCollectionForA;
List<int> wholePercentagesCollectionForB;
Dictionary<string, int> keyToCount = new();
List<int> normalizedRectangleCollectionForA;
List<int> normalizedRectangleCollectionForB;
Dictionary<string, string> keyToSegmentC = new();
Dictionary<int, List<int>> idToNormalizedRectangleCollectionForA = new();
Dictionary<int, List<int>> idToNormalizedRectangleCollectionForB = new();
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
Dictionary<int, List<int>> idToWholePercentagesCollectionForA = new();
Dictionary<int, List<int>> idToWholePercentagesCollectionForB = new();
Dictionary<int, PersonContainer[]>? wholePercentagesToPersonContainers;
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - _Ticks).TotalSeconds);
string message = $") {sortingContainers.Length:000} Update From Sorting Container(s) - {totalSeconds} total second(s)";
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
@ -664,25 +664,25 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
progressBar.Tick();
if (sortingContainer.Mapping?.MappingFromLocation is null)
throw new NotSupportedException();
if (!idToNormalizedRectangleCollectionForA.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
idToNormalizedRectangleCollectionForA.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
normalizedRectangleCollectionForA = idToNormalizedRectangleCollectionForA[sortingContainer.Mapping.MappingFromItem.Id];
if (!idToNormalizedRectangleCollectionForB.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
idToNormalizedRectangleCollectionForB.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
normalizedRectangleCollectionForB = idToNormalizedRectangleCollectionForB[sortingContainer.Mapping.MappingFromItem.Id];
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(sortingContainer.Sorting.Id, out normalizedRectangleToPersonContainers) || !normalizedRectangleToPersonContainers.TryGetValue(sortingContainer.Sorting.NormalizedRectangle, out personContainers))
if (!idToWholePercentagesCollectionForA.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
idToWholePercentagesCollectionForA.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
wholePercentagesCollectionForA = idToWholePercentagesCollectionForA[sortingContainer.Mapping.MappingFromItem.Id];
if (!idToWholePercentagesCollectionForB.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
idToWholePercentagesCollectionForB.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
wholePercentagesCollectionForB = idToWholePercentagesCollectionForB[sortingContainer.Mapping.MappingFromItem.Id];
if (!_IdThenWholePercentagesToPersonContainers.TryGetValue(sortingContainer.Sorting.Id, out wholePercentagesToPersonContainers) || !wholePercentagesToPersonContainers.TryGetValue(sortingContainer.Sorting.WholePercentages, out personContainers))
{
if (!_Configuration.SaveSortingWithoutPerson)
continue;
if (normalizedRectangleCollectionForA.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle))
if (wholePercentagesCollectionForA.Contains(sortingContainer.Mapping.MappingFromLocation.WholePercentages))
continue;
sortingContainer.Mapping.UpdateMappingFromUnknownPerson(saveIndividually, sortingContainer);
normalizedRectangleCollectionForA.Add(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle);
wholePercentagesCollectionForA.Add(sortingContainer.Mapping.MappingFromLocation.WholePercentages);
result += 1;
}
else
{
if (normalizedRectangleCollectionForB.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle))
if (wholePercentagesCollectionForB.Contains(sortingContainer.Mapping.MappingFromLocation.WholePercentages))
continue;
foreach (PersonContainer personContainer in personContainers)
{
@ -705,7 +705,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
keyToSegmentC[key] = sortingContainer.Sorting.DistancePermyriad.ToString();
}
sortingContainer.Mapping.UpdateMappingFromPerson(personContainer.ApproximateYears, personContainer.DisplayDirectoryName, personBirthday, mappingSegmentB, keyToSegmentC[key], sortingContainer);
normalizedRectangleCollectionForB.Add(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle);
wholePercentagesCollectionForB.Add(sortingContainer.Mapping.MappingFromLocation.WholePercentages);
result += 1;
break;
}
@ -714,7 +714,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
return result;
}
public void CopyManualFiles(string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
public void CopyManualFiles(string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToWholePercentagesToMapping)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -727,19 +727,19 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
const int zero = 0;
string faceFileName;
string shortcutFile;
int? wholePercentages;
string? directoryName;
string mappingSegmentB;
string personDirectory;
string? facesDirectory;
int? normalizedRectangle;
string personKeyFormatted;
string personDisplayFileName;
PersonBirthday personBirthday;
string? personDisplayDirectory;
WindowsShortcut windowsShortcut;
Dictionary<int, Mapping>? normalizedRectangleToMapping;
Dictionary<int, Mapping>? wholePercentagesToMapping;
string by = nameof(Shared.Models.Stateless.IMapLogic.ManualCopy);
Dictionary<int, PersonContainer[]>? normalizedRectangleToPeronContainerCollection;
Dictionary<int, PersonContainer[]>? wholePercentagesToPeronContainerCollection;
string successful = $"_ {nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Successful";
foreach (KeyValuePair<long, PersonContainer> personKeyToPersonContainer in _PersonKeyToPersonContainer)
{
@ -750,8 +750,8 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
{
if (!personDisplayDirectoryAllFile.EndsWith(_Configuration.FacesFileNameExtension))
continue;
(id, normalizedRectangle) = IMapping.GetConverted(_Configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
if (id is null || normalizedRectangle is null)
(id, wholePercentages) = IMapping.GetConverted(_Configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
if (id is null || wholePercentages is null)
continue;
fileInfo = new(personDisplayDirectoryAllFile);
if (!fileInfo.Exists)
@ -762,11 +762,11 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
mappingSegmentB = Stateless.MapLogic.GetMappingSegmentB(_Ticks, personBirthday, personKeyToPersonContainer.Value.ApproximateYears, fileInfo.CreationTime, isWrongYear: null);
directory = Path.Combine(_EDistanceContentTicksDirectory, by, personKeyFormatted, mappingSegmentB);
personDirectory = Path.Combine(directory, personKeyToPersonContainer.Value.DisplayDirectoryName, "lnk");
if (!idToNormalizedRectangleToMapping.TryGetValue(id.Value, out normalizedRectangleToMapping))
if (!idToWholePercentagesToMapping.TryGetValue(id.Value, out wholePercentagesToMapping))
continue;
if (!normalizedRectangleToMapping.ContainsKey(normalizedRectangle.Value))
if (!wholePercentagesToMapping.ContainsKey(wholePercentages.Value))
continue;
mapping = normalizedRectangleToMapping[normalizedRectangle.Value];
mapping = wholePercentagesToMapping[wholePercentages.Value];
if (mapping.MappingFromLocation is null)
continue;
if (string.IsNullOrEmpty(personDisplayDirectory))
@ -780,7 +780,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
continue;
faceFileName = $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}";
checkFile = Path.Combine(directory, fileInfo.Name);
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(id.Value, out normalizedRectangleToPeronContainerCollection) || !normalizedRectangleToPeronContainerCollection.ContainsKey(normalizedRectangle.Value))
if (!_IdThenWholePercentagesToPersonContainers.TryGetValue(id.Value, out wholePercentagesToPeronContainerCollection) || !wholePercentagesToPeronContainerCollection.ContainsKey(wholePercentages.Value))
{
if (!Directory.Exists(personDirectory))
_ = Directory.CreateDirectory(personDirectory);
@ -1366,12 +1366,12 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
}
}
public Dictionary<int, Dictionary<int, PersonContainer[]>> GetMissing(Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
public Dictionary<int, Dictionary<int, PersonContainer[]>> GetMissing(Dictionary<int, Dictionary<int, Mapping>> idToWholePercentagesToMapping)
{
Dictionary<int, Dictionary<int, PersonContainer[]>> results = new();
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> idToCollection in _IdThenNormalizedRectangleToPersonContainers)
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> idToCollection in _IdThenWholePercentagesToPersonContainers)
{
if (idToNormalizedRectangleToMapping.ContainsKey(idToCollection.Key))
if (idToWholePercentagesToMapping.ContainsKey(idToCollection.Key))
continue;
results.Add(idToCollection.Key, idToCollection.Value);
}
@ -1381,7 +1381,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
public bool InSkipCollection(int id, MappingFromLocation mappingFromLocation)
{
bool result;
result = _SkipCollection.TryGetValue(id, out List<int>? normalizedRectangles) && normalizedRectangles.Contains(mappingFromLocation.NormalizedRectangle);
result = _SkipCollection.TryGetValue(id, out List<int>? wholePercentagesCollection) && wholePercentagesCollection.Contains(mappingFromLocation.WholePercentages);
return result;
}

View File

@ -16,7 +16,7 @@ internal abstract class MapLogic
private static void SetPersonCollections(Configuration configuration, ReadOnlyCollection<PersonContainer> personContainers, string? a2PeopleSingletonDirectory, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<string> personKeyFormattedCollection, Dictionary<int, List<int>> skipCollection, Dictionary<int, List<int>> skipNotSkipCollection)
{
int? id;
int? normalizedRectangle;
int? wholePercentages;
string personKeyFormatted;
string newestPersonKeyFormatted;
bool skipNotSkipDirectoriesAny = configuration.SkipNotSkipDirectories.Any();
@ -27,20 +27,20 @@ internal abstract class MapLogic
{
if (!personDisplayDirectoryAllFile.EndsWith(configuration.FacesFileNameExtension))
continue;
(id, normalizedRectangle) = IMapping.GetConverted(configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
if (id is null || normalizedRectangle is null)
(id, wholePercentages) = IMapping.GetConverted(configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
if (id is null || wholePercentages is null)
continue;
if (!skipNotSkipDirectoriesAny || !checkDirectories.Any(l => personDisplayDirectoryAllFile.StartsWith(l)))
{
if (!skipCollection.ContainsKey(id.Value))
skipCollection.Add(id.Value, new());
skipCollection[id.Value].Add(normalizedRectangle.Value);
skipCollection[id.Value].Add(wholePercentages.Value);
}
else
{
if (!skipNotSkipCollection.ContainsKey(id.Value))
skipNotSkipCollection.Add(id.Value, new());
skipNotSkipCollection[id.Value].Add(normalizedRectangle.Value);
skipNotSkipCollection[id.Value].Add(wholePercentages.Value);
}
}
if (personContainer.Person is null || personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
@ -157,8 +157,8 @@ internal abstract class MapLogic
string[] files;
string fileName;
const int zero = 0;
int? wholePercentages;
string[] yearDirectories;
int? normalizedRectangle;
string personKeyFormatted;
string ticksDirectoryName;
string? personFirstInitial;
@ -235,8 +235,8 @@ internal abstract class MapLogic
{
if (file.EndsWith(".lnk"))
continue;
(id, normalizedRectangle) = IMapping.GetConverted(configuration.FacesFileNameExtension, file);
if (id is null || normalizedRectangle is null)
(id, wholePercentages) = IMapping.GetConverted(configuration.FacesFileNameExtension, file);
if (id is null || wholePercentages is null)
continue;
fileName = Path.GetFileName(file);
if (distinct.Contains(fileName))
@ -285,21 +285,21 @@ internal abstract class MapLogic
return results.ToArray();
}
private static void SetKeyValuePairs(Configuration configuration, ReadOnlyCollection<PersonContainer> personContainers, Dictionary<long, List<PersonContainer>> personKeyToPersonContainerCollection, Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer)
private static void SetKeyValuePairs(Configuration configuration, ReadOnlyCollection<PersonContainer> personContainers, Dictionary<long, List<PersonContainer>> personKeyToPersonContainerCollection, Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer, List<(string, string[], int, int)> personKeyFormattedIdThenWholePercentagesCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenWholePercentagesToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer)
{
PersonBirthday? personBirthday;
PersonContainer[] distinctPersonContainers;
(long, PersonContainer)[] collection = GetDistinctCollection(configuration, personContainers, personKeyToPersonContainerCollection, personKeyFormattedToPersonContainer);
foreach ((long personKey, PersonContainer personContainer) in collection)
personKeyToPersonContainer.Add(personKey, personContainer);
Dictionary<int, Dictionary<int, List<PersonContainer>>> idThenNormalizedRectangleToPersonContainerCollection = new();
if (personKeyFormattedIdThenNormalizedRectangleCollection.Any())
Dictionary<int, Dictionary<int, List<PersonContainer>>> idThenWholePercentagesToPersonContainerCollection = new();
if (personKeyFormattedIdThenWholePercentagesCollection.Any())
{
string personDisplayDirectory;
PersonContainer personContainer;
string personDisplayDirectoryName;
Dictionary<string, (string[], PersonContainer)> personDisplayDirectoryTo = new();
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, int id, int normalizedRectangle) in personKeyFormattedIdThenNormalizedRectangleCollection)
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, int id, int wholePercentages) in personKeyFormattedIdThenWholePercentagesCollection)
{
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
if (personBirthday is null)
@ -313,22 +313,22 @@ internal abstract class MapLogic
}
if (personDisplayDirectoryName.Length != 1 && personDisplayDirectoryName != configuration.MappingDefaultName && !personDisplayDirectoryTo.ContainsKey(personDisplayDirectory))
personDisplayDirectoryTo.Add(personDisplayDirectory, new(personDisplayDirectoryNames, personKeyFormattedToPersonContainer[personKeyFormatted]));
if (!idThenNormalizedRectangleToPersonContainerCollection.ContainsKey(id))
idThenNormalizedRectangleToPersonContainerCollection.Add(id, new());
if (!idThenNormalizedRectangleToPersonContainerCollection[id].ContainsKey(normalizedRectangle))
idThenNormalizedRectangleToPersonContainerCollection[id].Add(normalizedRectangle, new());
idThenNormalizedRectangleToPersonContainerCollection[id][normalizedRectangle].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
if (!idThenWholePercentagesToPersonContainerCollection.ContainsKey(id))
idThenWholePercentagesToPersonContainerCollection.Add(id, new());
if (!idThenWholePercentagesToPersonContainerCollection[id].ContainsKey(wholePercentages))
idThenWholePercentagesToPersonContainerCollection[id].Add(wholePercentages, new());
idThenWholePercentagesToPersonContainerCollection[id][wholePercentages].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
}
foreach (KeyValuePair<string, (string[], PersonContainer)> keyValuePair in personDisplayDirectoryTo)
possiblyNewPersonDisplayDirectoryNamesAndPersonContainer.Add(keyValuePair.Value);
}
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in idThenNormalizedRectangleToPersonContainerCollection)
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in idThenWholePercentagesToPersonContainerCollection)
{
idThenNormalizedRectangleToPersonContainers.Add(keyValuePair.Key, new());
idThenWholePercentagesToPersonContainers.Add(keyValuePair.Key, new());
foreach (KeyValuePair<int, List<PersonContainer>> innerKeyValuePair in keyValuePair.Value)
{
distinctPersonContainers = GetDistinctPersonContainers(innerKeyValuePair.Value);
idThenNormalizedRectangleToPersonContainers[keyValuePair.Key].Add(innerKeyValuePair.Key, distinctPersonContainers);
idThenWholePercentagesToPersonContainers[keyValuePair.Key].Add(innerKeyValuePair.Key, distinctPersonContainers);
}
};
}
@ -363,15 +363,15 @@ internal abstract class MapLogic
return results;
}
private static int SetCollectionsAndGetUnableToConvertCount(Configuration configuration, long ticks, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, string[], string)> collection)
private static int SetCollectionsAndGetUnableToConvertCount(Configuration configuration, long ticks, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenWholePercentagesCollection, List<(string, string[], string)> collection)
{
int result = 0;
int? id;
int? normalizedRectangle;
List<int> normalizedRectangles;
int? wholePercentages;
string? newestPersonKeyFormatted;
string personDisplayDirectoryName;
Dictionary<int, List<int>> idToNormalizedRectangles = new();
List<int> wholePercentagesCollection;
Dictionary<int, List<int>> idToWholePercentagesCollection = new();
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
string message = $") {collection.Count:000} join from ticks Director(ies) - C - {totalSeconds} total second(s)";
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
@ -385,21 +385,21 @@ internal abstract class MapLogic
continue;
newestPersonKeyFormatted = personKeyFormatted;
}
(id, normalizedRectangle) = IMapping.GetConverted(configuration.FacesFileNameExtension, mappedFaceFile);
if (id is null || normalizedRectangle is null)
(id, wholePercentages) = IMapping.GetConverted(configuration.FacesFileNameExtension, mappedFaceFile);
if (id is null || wholePercentages is null)
{
result++;
continue;
}
if (!idToNormalizedRectangles.ContainsKey(id.Value))
idToNormalizedRectangles.Add(id.Value, new());
normalizedRectangles = idToNormalizedRectangles[id.Value];
normalizedRectangles.Add(normalizedRectangle.Value);
idToNormalizedRectangles[id.Value].Add(normalizedRectangle.Value);
if (!idToWholePercentagesCollection.ContainsKey(id.Value))
idToWholePercentagesCollection.Add(id.Value, new());
wholePercentagesCollection = idToWholePercentagesCollection[id.Value];
wholePercentagesCollection.Add(wholePercentages.Value);
idToWholePercentagesCollection[id.Value].Add(wholePercentages.Value);
personDisplayDirectoryName = personDisplayDirectoryNames[^1];
if (string.IsNullOrEmpty(personDisplayDirectoryName))
continue;
personKeyFormattedIdThenNormalizedRectangleCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, normalizedRectangle.Value));
personKeyFormattedIdThenWholePercentagesCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, wholePercentages.Value));
}
return result;
}
@ -610,22 +610,22 @@ internal abstract class MapLogic
private static void ParallelFor(Configuration configuration, string eDistanceContentDirectory, List<LocationContainer<MetadataExtractor.Directory>> collection, long personKey, string file)
{
const string lnk = ".lnk";
int? id, normalizedRectangle;
int? id, wholePercentages;
IReadOnlyList<MetadataExtractor.Directory> directories;
bool fromDistanceContent = !file.EndsWith(lnk) && file.Contains(eDistanceContentDirectory);
if (!file.EndsWith(lnk))
(id, normalizedRectangle) = IMapping.GetConverted(configuration.FacesFileNameExtension, file);
(id, wholePercentages) = IMapping.GetConverted(configuration.FacesFileNameExtension, file);
else
(id, normalizedRectangle) = IMapping.GetConverted(configuration.FacesFileNameExtension, file[..^4]);
if (id is null || normalizedRectangle is null)
(id, wholePercentages) = IMapping.GetConverted(configuration.FacesFileNameExtension, file[..^4]);
if (id is null || wholePercentages is null)
return;
if (file.EndsWith(lnk) || (!configuration.DistanceMoveUnableToMatch && !configuration.DistanceRenameToMatch))
directories = new List<MetadataExtractor.Directory>();
else
directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(file);
Rectangle? rectangle = ILocation.GetNormalizedRectangle(configuration.LocationDigits, normalizedRectangle.Value);
Rectangle? rectangle = ILocation.GetWholePercentages(configuration.LocationDigits, wholePercentages.Value);
lock (collection)
collection.Add(new(fromDistanceContent, file, personKey, id.Value, normalizedRectangle.Value, directories, rectangle, null));
collection.Add(new(fromDistanceContent, file, personKey, id.Value, wholePercentages.Value, directories, rectangle, null));
}
private static void OpenPossibleDuplicates(Configuration configuration, List<(long, int, string, double?)> duplicates)
@ -661,7 +661,7 @@ internal abstract class MapLogic
Rectangle? rectangle;
List<string> delete = new();
Rectangle intersectRectangle;
(string File, int NormalizedRectangle) item;
(string File, int WholePercentages) item;
Dictionary<string, (string, int)> distinct = new();
List<(long, int, string, double?)> duplicates = new();
foreach (LocationContainer<MetadataExtractor.Directory> locationContainer in collection)
@ -669,13 +669,13 @@ internal abstract class MapLogic
key = string.Concat(locationContainer.PersonKey, locationContainer.Id);
if (distinct.TryGetValue(key, out item))
{
if (item.NormalizedRectangle == locationContainer.NormalizedRectangle)
if (item.WholePercentages == locationContainer.WholePercentages)
continue;
if (locationContainer.Rectangle is null)
percent = null;
else
{
rectangle = ILocation.GetNormalizedRectangle(configuration.LocationDigits, item.NormalizedRectangle);
rectangle = ILocation.GetWholePercentages(configuration.LocationDigits, item.WholePercentages);
if (locationContainer.Rectangle is null || rectangle is null)
percent = null;
else
@ -689,7 +689,7 @@ internal abstract class MapLogic
duplicates.Add(new(locationContainer.PersonKey, locationContainer.Id, locationContainer.File, percent));
continue;
}
distinct.Add(key, new(locationContainer.File, locationContainer.NormalizedRectangle));
distinct.Add(key, new(locationContainer.File, locationContainer.WholePercentages));
}
if (!configuration.DeletePossibleDuplicates && duplicates.Any())
OpenPossibleDuplicates(configuration, duplicates);
@ -726,7 +726,7 @@ internal abstract class MapLogic
return results;
}
internal static void Set(int maxDegreeOfParallelism, Configuration configuration, long ticks, ReadOnlyCollection<PersonContainer> personContainers, string? a2PeopleSingletonDirectory, string eDistanceContentDirectory, Dictionary<long, PersonContainer> personKeyToPersonContainer, List<PersonContainer> notMappedPersonContainers, Dictionary<int, List<int>> skipCollection, Dictionary<int, List<int>> skipNotSkipCollection, List<LocationContainer<MetadataExtractor.Directory>> locationContainers, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers)
internal static void Set(int maxDegreeOfParallelism, Configuration configuration, long ticks, ReadOnlyCollection<PersonContainer> personContainers, string? a2PeopleSingletonDirectory, string eDistanceContentDirectory, Dictionary<long, PersonContainer> personKeyToPersonContainer, List<PersonContainer> notMappedPersonContainers, Dictionary<int, List<int>> skipCollection, Dictionary<int, List<int>> skipNotSkipCollection, List<LocationContainer<MetadataExtractor.Directory>> locationContainers, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenWholePercentagesToPersonContainers)
{
string message;
int totalSeconds;
@ -736,7 +736,7 @@ internal abstract class MapLogic
Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer = new();
Dictionary<long, List<PersonContainer>> personKeyToPersonContainerCollection = new();
string[] ticksDirectories = UpdateDateVerifyAndGetTicksDirectories(eDistanceContentDirectory);
List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection = new();
List<(string, string[], int, int)> personKeyFormattedIdThenWholePercentagesCollection = new();
List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer = new();
SetPersonCollections(configuration, personContainers, a2PeopleSingletonDirectory, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedCollection, skipCollection, skipNotSkipCollection);
// personContainers.AddRange(GetNonSpecificPeopleCollection(configuration, ticks, personKeys));
@ -744,14 +744,14 @@ internal abstract class MapLogic
message = $") {ticksDirectories.Length:000} compile from and clean ticks Director(ies) - B - {totalSeconds} total second(s)";
List<(string, string[], string)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, personKeyFormattedCollection, ticksDirectories, message);
locationContainers.AddRange(GetLocationContainers(maxDegreeOfParallelism, configuration, ticks, personContainers, eDistanceContentDirectory, collection));
int unableToMatchCount = SetCollectionsAndGetUnableToConvertCount(configuration, ticks, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedRectangleCollection, collection);
SetKeyValuePairs(configuration, personContainers, personKeyToPersonContainerCollection, personKeyFormattedToPersonContainer, personKeyFormattedIdThenNormalizedRectangleCollection, personKeyToPersonContainer, idThenNormalizedRectangleToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer);
int unableToMatchCount = SetCollectionsAndGetUnableToConvertCount(configuration, ticks, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenWholePercentagesCollection, collection);
SetKeyValuePairs(configuration, personContainers, personKeyToPersonContainerCollection, personKeyFormattedToPersonContainer, personKeyFormattedIdThenWholePercentagesCollection, personKeyToPersonContainer, idThenWholePercentagesToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer);
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
message = $") {collection.Count:000} message from ticks Director(ies) - D - {unableToMatchCount} Unable To Match Count / {collection.Count} Collection - {totalSeconds} total second(s)";
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
using (ProgressBar progressBar = new(collection.Count, message, options))
{
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> keyValuePair in idThenNormalizedRectangleToPersonContainers)
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> keyValuePair in idThenWholePercentagesToPersonContainers)
{
progressBar.Tick();
foreach (KeyValuePair<int, PersonContainer[]> keyValue in keyValuePair.Value)
@ -841,7 +841,7 @@ internal abstract class MapLogic
SaveContainer result;
if (sortingContainer.Mapping.MappingFromLocation is null)
throw new NullReferenceException(nameof(sortingContainer.Mapping.MappingFromLocation));
FileHolder faceFileHolder = new($"C:/{sortingContainer.Sorting.Id}.{sortingContainer.Sorting.NormalizedRectangle}");
FileHolder faceFileHolder = new($"C:/{sortingContainer.Sorting.Id}.{sortingContainer.Sorting.WholePercentages}");
string shortcutFile;
if (mappingFromPerson is null)
shortcutFile = Path.Combine(directory, $"{sortingContainer.Mapping.MappingFromLocation.DeterministicHashCodeKey}{sortingContainer.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}.{sortingContainer.Sorting.DistancePermyriad}.lnk");
@ -1019,7 +1019,7 @@ internal abstract class MapLogic
return results;
}
internal static Dictionary<int, Dictionary<int, Mapping>> GetIdToNormalizedRectangleToFace(Mapping[] mappingCollection)
internal static Dictionary<int, Dictionary<int, Mapping>> GetIdToWholePercentagesToFace(Mapping[] mappingCollection)
{
Dictionary<int, Dictionary<int, Mapping>> results = new();
Dictionary<int, Mapping>? keyValuePairs;
@ -1033,9 +1033,9 @@ internal abstract class MapLogic
if (!results.TryGetValue(mapping.MappingFromItem.Id, out keyValuePairs))
throw new Exception();
}
if (keyValuePairs.ContainsKey(mapping.MappingFromLocation.NormalizedRectangle))
if (keyValuePairs.ContainsKey(mapping.MappingFromLocation.WholePercentages))
continue;
keyValuePairs.Add(mapping.MappingFromLocation.NormalizedRectangle, mapping);
keyValuePairs.Add(mapping.MappingFromLocation.WholePercentages, mapping);
}
return results;
}

View File

@ -23,9 +23,9 @@ public interface IMapLogic
static Shared.Models.Mapping[] GetSelectedMappingCollection(List<Shared.Models.Face> faces) =>
MapLogic.GetSelectedMappingCollection(faces);
Dictionary<int, Dictionary<int, Shared.Models.Mapping>> TestStatic_GetIdToNormalizedRectangleToFace(Shared.Models.Mapping[] mappingCollection) =>
GetIdToNormalizedRectangleToFace(mappingCollection);
static Dictionary<int, Dictionary<int, Shared.Models.Mapping>> GetIdToNormalizedRectangleToFace(Shared.Models.Mapping[] mappingCollection) =>
MapLogic.GetIdToNormalizedRectangleToFace(mappingCollection);
Dictionary<int, Dictionary<int, Shared.Models.Mapping>> TestStatic_GetIdToWholePercentagesToFace(Shared.Models.Mapping[] mappingCollection) =>
GetIdToWholePercentagesToFace(mappingCollection);
static Dictionary<int, Dictionary<int, Shared.Models.Mapping>> GetIdToWholePercentagesToFace(Shared.Models.Mapping[] mappingCollection) =>
MapLogic.GetIdToWholePercentagesToFace(mappingCollection);
}