From e9d2c6374ead0157be5c3907b6773f990496e454 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Sun, 5 Feb 2023 08:59:50 -0700 Subject: [PATCH] Sorting and save --- Distance/Models/MapLogicSupport.cs | 7 ++++++- Instance/DlibDotNet.cs | 2 ++ Shared/Models/Stateless/Methods/ISortingContainer.cs | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Distance/Models/MapLogicSupport.cs b/Distance/Models/MapLogicSupport.cs index cc2e6d4..6f9bb2e 100644 --- a/Distance/Models/MapLogicSupport.cs +++ b/Distance/Models/MapLogicSupport.cs @@ -245,7 +245,12 @@ public class MapLogicSupport : Shared.Models.Methods.IMapLogicSupport if (!collection.Any()) results = Array.Empty(); else - results = Shared.Models.Stateless.Methods.ISortingContainer.Sort(collection); + { + if (_RangeDaysDeltaTolerance[1] > _RangeDaysDeltaTolerance[2]) + results = Shared.Models.Stateless.Methods.ISortingContainer.Sort(collection); + else + results = Shared.Models.Stateless.Methods.ISortingContainer.SortUsingDaysDelta(collection); + } return results; } diff --git a/Instance/DlibDotNet.cs b/Instance/DlibDotNet.cs index 6c643a7..1203662 100644 --- a/Instance/DlibDotNet.cs +++ b/Instance/DlibDotNet.cs @@ -1093,6 +1093,8 @@ public partial class DlibDotNet LookForAbandoned(idToLocationContainers, distinctFilteredIds); Mapping[] mappingCollection = MapLogicSupport.GetSelectedMappingCollection(distinctFilteredFaces); int totalNotMapped = mapLogic.UpdateMappingFromPerson(mappingCollection); + string json = System.Text.Json.JsonSerializer.Serialize(mappingCollection); + File.WriteAllText(Path.Combine(eDistanceContentDirectory, $"{ticks}.json"), json); if (a2PeopleContentDirectory is not null && false) mapLogic.CreateTree(ticks, a2PeopleContentDirectory); foreach (string outputResolution in _Configuration.OutputResolutions) diff --git a/Shared/Models/Stateless/Methods/ISortingContainer.cs b/Shared/Models/Stateless/Methods/ISortingContainer.cs index dc6a5ed..0abc684 100644 --- a/Shared/Models/Stateless/Methods/ISortingContainer.cs +++ b/Shared/Models/Stateless/Methods/ISortingContainer.cs @@ -6,6 +6,8 @@ public interface ISortingContainer Models.SortingContainer[] TestStatic_Sort(List collection) => Sort(collection); static Models.SortingContainer[] Sort(List collection) => + (from l in collection orderby l.Sorting.DistancePermyriad select l).ToArray(); + static Models.SortingContainer[] SortUsingDaysDelta(List collection) => (from l in collection orderby l.Sorting.DistancePermyriad, l.Sorting.DaysDelta select l).ToArray(); } \ No newline at end of file