21 lines
1.0 KiB
C#
21 lines
1.0 KiB
C#
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|
|
|
internal abstract class Sorting
|
|
{
|
|
|
|
internal static Models.Sorting Get(int faceDistancePermyriad, float distanceTolerance, Models.FaceDistance faceDistanceEncoding, Models.FaceDistance faceDistanceLength)
|
|
{
|
|
Models.Sorting result;
|
|
if (faceDistanceLength.Length is null)
|
|
throw new NotSupportedException();
|
|
if (faceDistanceLength.WholePercentages is null)
|
|
throw new NotSupportedException();
|
|
TimeSpan timeSpan = new(faceDistanceLength.DateTimeOriginalThenMinimumDateTime.Ticks - faceDistanceEncoding.DateTimeOriginalThenMinimumDateTime.Ticks);
|
|
bool older = timeSpan.TotalMilliseconds < 0;
|
|
int daysDelta = (int)Math.Round(Math.Abs(timeSpan.TotalDays), 0);
|
|
int distancePermyriad = (int)(faceDistanceLength.Length.Value / distanceTolerance * faceDistancePermyriad);
|
|
result = new(daysDelta, distancePermyriad, faceDistanceLength.Id, older, faceDistanceLength.WholePercentages.Value);
|
|
return result;
|
|
}
|
|
|
|
} |