SaveRandomForOutputResolutions
This commit is contained in:
@ -101,13 +101,71 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Dictionary<int, List<long>> GetIdToPersonKeys(Dictionary<long, List<int>> keyValuePairs)
|
||||
{
|
||||
Dictionary<int, List<long>> results = new();
|
||||
List<long>? collection;
|
||||
foreach (KeyValuePair<long, List<int>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
foreach (int id in keyValuePair.Value)
|
||||
{
|
||||
if (!results.TryGetValue(id, out collection))
|
||||
{
|
||||
results.Add(id, new());
|
||||
if (!results.TryGetValue(id, out collection))
|
||||
throw new Exception();
|
||||
}
|
||||
if (collection.Contains(keyValuePair.Key))
|
||||
continue;
|
||||
collection.Add(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public Dictionary<int, List<long>> GetIdToPeronKeys()
|
||||
{
|
||||
Dictionary<int, List<long>> results;
|
||||
long key;
|
||||
const int zero = 0;
|
||||
List<int>? collection;
|
||||
PersonBirthday personBirthday;
|
||||
Dictionary<long, List<int>> keyValuePairs = new();
|
||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> idToCollection in _IdThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
foreach (KeyValuePair<int, PersonContainer[]> normalizedRectangleToPersonContainers in idToCollection.Value)
|
||||
{
|
||||
foreach (PersonContainer personContainer in normalizedRectangleToPersonContainers.Value)
|
||||
{
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
continue;
|
||||
personBirthday = personContainer.Birthdays[zero];
|
||||
if (IPersonBirthday.IsCounterPersonBirthday(personBirthday))
|
||||
continue;
|
||||
key = personBirthday.Value.Ticks;
|
||||
if (!keyValuePairs.TryGetValue(key, out collection))
|
||||
{
|
||||
keyValuePairs.Add(key, new());
|
||||
if (!keyValuePairs.TryGetValue(key, out collection))
|
||||
throw new Exception();
|
||||
}
|
||||
if (collection.Contains(idToCollection.Key))
|
||||
continue;
|
||||
collection.Add(idToCollection.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
results = GetIdToPersonKeys(keyValuePairs);
|
||||
return results;
|
||||
}
|
||||
|
||||
(bool, Dictionary<int, PersonContainer[]>?) Shared.Models.Methods.IMapLogic.GetNormalizedRectangleToPersonContainers(int id)
|
||||
{
|
||||
bool result = _IdThenNormalizedRectangleToPersonContainers.TryGetValue(id, out Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers);
|
||||
return new(result, normalizedRectangleToPersonContainers);
|
||||
}
|
||||
|
||||
public (Dictionary<long, int>, int) AddToMapping(Mapping[] mappingCollection)
|
||||
public int UpdateMappingFromPerson(Mapping[] mappingCollection)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -116,21 +174,19 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
const int zero = 0;
|
||||
string mappingSegmentB;
|
||||
PersonBirthday personBirthday;
|
||||
PersonContainer[]? collection;
|
||||
List<PersonContainer> personContainers = new();
|
||||
Dictionary<long, int> personKeyToCount = new();
|
||||
PersonContainer[]? personContainers;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
personContainers.Clear();
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangleToPersonContainers))
|
||||
result += 1;
|
||||
else
|
||||
{
|
||||
if (!normalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out collection))
|
||||
result += 1;
|
||||
else
|
||||
personContainers.AddRange(collection);
|
||||
result += 1;
|
||||
continue;
|
||||
}
|
||||
if (!normalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out personContainers))
|
||||
{
|
||||
result += 1;
|
||||
continue;
|
||||
}
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
@ -138,14 +194,41 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
continue;
|
||||
personBirthday = personContainer.Birthdays[zero];
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
if (!personKeyToCount.ContainsKey(personKey))
|
||||
personKeyToCount.Add(personKey, 0);
|
||||
personKeyToCount[personKey] += 1;
|
||||
mappingSegmentB = Stateless.MapLogic.GetMappingSegmentB(_Ticks, personBirthday, personContainer.ApproximateYears, mapping.MappingFromItem);
|
||||
mapping.UpdateMappingFromPerson(personContainer.ApproximateYears, personContainer.DisplayDirectoryName, personBirthday, mappingSegmentB);
|
||||
}
|
||||
}
|
||||
return new(personKeyToCount, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Dictionary<long, int> GetPersonKeyToCount(Mapping[] mappingCollection)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
Dictionary<long, int> results = new();
|
||||
long personKey;
|
||||
const int zero = 0;
|
||||
PersonBirthday personBirthday;
|
||||
PersonContainer[]? personContainers;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangleToPersonContainers))
|
||||
continue;
|
||||
if (!normalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out personContainers))
|
||||
continue;
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
continue;
|
||||
personBirthday = personContainer.Birthdays[zero];
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
if (!results.ContainsKey(personKey))
|
||||
results.Add(personKey, 0);
|
||||
results[personKey] += 1;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void SaveContainers(int totalNotMapped, int? updated, List<SaveContainer> saveContainers)
|
||||
@ -1200,11 +1283,11 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
public Dictionary<int, Dictionary<int, PersonContainer[]>> GetMissing(Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
|
||||
{
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> results = new();
|
||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> normalizedRectangleToPersonContainers in _IdThenNormalizedRectangleToPersonContainers)
|
||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> idToCollection in _IdThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
if (idToNormalizedRectangleToMapping.ContainsKey(normalizedRectangleToPersonContainers.Key))
|
||||
if (idToNormalizedRectangleToMapping.ContainsKey(idToCollection.Key))
|
||||
continue;
|
||||
results.Add(normalizedRectangleToPersonContainers.Key, normalizedRectangleToPersonContainers.Value);
|
||||
results.Add(idToCollection.Key, idToCollection.Value);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
Reference in New Issue
Block a user