This commit is contained in:
2023-10-15 09:51:56 -07:00
parent 2cd2c2b434
commit cd5ab223c9
75 changed files with 895 additions and 722 deletions

View File

@ -933,7 +933,6 @@ public partial class DlibDotNet
Shared.Models.Property? property;
List<string> parseExceptions = new();
List<Tuple<string, DateTime>> subFileTuples = new();
List<KeyValuePair<string, string>> metadataCollection;
string[] changesFrom = new string[] { nameof(A_Property) };
FileHolder resizedFileHolder = _Resize.GetResizedFileHolder(cResultsFullGroupDirectory, item, outputResolutionHasNumber);
ReadOnlyCollection<LocationContainer<MetadataExtractor.Directory>> locationContainers = mapLogic.GetLocationContainers(item);
@ -966,7 +965,7 @@ public partial class DlibDotNet
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), item.SourceDirectoryFileHolder.LastWriteTime.Value));
else
subFileTuples.Add(new Tuple<string, DateTime>(nameof(A_Property), new FileInfo(item.SourceDirectoryFileHolder.FullName).LastWriteTime));
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex();
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex(_Configuration.PropertyConfiguration.Offset);
bool nameWithoutExtensionIsIdFormat = Shared.Models.Stateless.Methods.IProperty.NameWithoutExtensionIsIdFormat(item.ImageFileHolder);
bool nameWithoutExtensionIsPaddedIdFormat = IDirectory.NameWithoutExtensionIsPaddedIdFormat(item.ImageFileHolder, sortOrderOnlyLengthIndex);
if (nameWithoutExtensionIsIdFormat && item.ImageFileHolder.NameWithoutExtension != item.Property.Id.ToString())
@ -985,10 +984,32 @@ public partial class DlibDotNet
item.SetResizedFileHolder(_Resize.FileNameExtension, resizedFileHolder);
MappingFromItem mappingFromItem = IMappingFromItem.GetMappingFromItem(containerDateTimes, item, resizedFileHolder);
Map.Models.Stateless.Methods.IMapLogic.SetCreationTimeMaybeMoveToDecade(_Configuration.PropertyConfiguration, _Configuration.MoveToDecade && _Configuration.LocationContainerDistanceTolerance is null, mappingFromItem, locationContainers);
(int metadataGroups, metadataCollection) = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
ReadOnlyDictionary<string, MetadataExtractorDirectory> metadataExtractorDirectories = metadata.GetMetadataCollection(subFileTuples, parseExceptions, changesFrom, mappingFromItem);
if (_AppSettings.MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection));
Dictionary<string, int[]> outputResolutionToResize = _Resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, metadataCollection, item.Property, mappingFromItem);
if (_AppSettings.Places.Count > 0)
{
float latitude;
float longitude;
double? distance;
MetadataExtractor.GeoLocation? geoLocation = Metadata.Models.Stateless.Methods.IMetadata.GeoLocation(metadataExtractorDirectories);
foreach (Place place in _AppSettings.Places)
{
if (geoLocation is null)
continue;
latitude = Math.Abs(place.Latitude.Degrees) + (place.Latitude.Minutes / 60) + (place.Latitude.Seconds / 3600);
if (place.Latitude.Degrees < 0)
latitude *= -1;
longitude = Math.Abs(place.Longitude.Degrees) + (place.Longitude.Minutes / 60) + (place.Longitude.Seconds / 3600);
if (place.Longitude.Degrees < 0)
longitude *= -1;
distance = geoLocation is null ? null : Metadata.Models.Stateless.Methods.IMetadata.GetDistance(latitude, longitude, geoLocation.Latitude, geoLocation.Longitude);
if (distance is null or > 3)
continue;
distance += 1;
}
}
Dictionary<string, int[]> outputResolutionToResize = _Resize.GetResizeKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, subFileTuples, parseExceptions, item.Property, mappingFromItem);
if (_AppSettings.MaxDegreeOfParallelism < 2)
ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs));
if (_Configuration.SaveResizedSubfiles)

View File

@ -1,3 +1,4 @@
using System.Collections.ObjectModel;
using System.Text.Json;
using System.Text.Json.Serialization;
@ -5,6 +6,7 @@ namespace View_by_Distance.Instance.Models;
public record AppSettings(string Company,
int MaxDegreeOfParallelism,
ReadOnlyCollection<Place> Places,
string WorkingDirectoryName)
{

View File

@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using System.Collections.ObjectModel;
using System.Text.Json;
using System.Text.Json.Serialization;
@ -9,6 +10,7 @@ public class AppSettings
public string? Company { get; set; }
public int? MaxDegreeOfParallelism { get; set; }
public string[]? Places { get; set; }
public string? WorkingDirectoryName { get; set; }
public override string ToString()
@ -22,10 +24,13 @@ public class AppSettings
Models.AppSettings result;
if (appSettings?.Company is null) throw new NullReferenceException(nameof(appSettings.Company));
if (appSettings?.MaxDegreeOfParallelism is null) throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
// if (appSettings?.Places is null) throw new NullReferenceException(nameof(appSettings.Places));
if (appSettings?.WorkingDirectoryName is null) throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
ReadOnlyCollection<Models.Place> places = Place.GetPlaces(appSettings.Places);
result = new(
appSettings.Company,
appSettings.MaxDegreeOfParallelism.Value,
places,
appSettings.WorkingDirectoryName
);
return result;

View File

@ -0,0 +1,25 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Instance.Models.Binder;
public class DegreesMinutesSeconds
{
public float? Degrees { get; set; }
public float? Minutes { get; set; }
public float? Seconds { get; set; }
public override string ToString()
{
string result = JsonSerializer.Serialize(this, BinderDegreesMinutesSecondsSourceGenerationContext.Default.DegreesMinutesSeconds);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(DegreesMinutesSeconds))]
internal partial class BinderDegreesMinutesSecondsSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -0,0 +1,66 @@
using System.Collections.ObjectModel;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Instance.Models.Binder;
public class Place
{
public string? Title { get; set; }
public DegreesMinutesSeconds? Latitude { get; set; }
public DegreesMinutesSeconds? Longitude { get; set; }
public override string ToString()
{
string result = JsonSerializer.Serialize(this, BinderPlaceSourceGenerationContext.Default.Place);
return result;
}
private static Models.Place Get(Place? Place)
{
Models.Place result;
Models.DegreesMinutesSeconds latitude;
Models.DegreesMinutesSeconds longitude;
if (Place is null) throw new NullReferenceException(nameof(Place));
if (Place.Title is null) throw new NullReferenceException(nameof(Place.Title));
if (Place.Latitude is null) throw new NullReferenceException(nameof(Place.Latitude));
if (Place.Latitude.Degrees is null) throw new NullReferenceException(nameof(Place.Latitude.Degrees));
if (Place.Latitude.Minutes is null) throw new NullReferenceException(nameof(Place.Latitude.Minutes));
if (Place.Latitude.Seconds is null) throw new NullReferenceException(nameof(Place.Latitude.Seconds));
if (Place.Longitude is null) throw new NullReferenceException(nameof(Place.Longitude));
latitude = new(Place.Latitude.Degrees.Value, Place.Latitude.Minutes.Value, Place.Latitude.Seconds.Value);
if (Place.Longitude.Degrees is null) throw new NullReferenceException(nameof(Place.Longitude.Degrees));
if (Place.Longitude.Minutes is null) throw new NullReferenceException(nameof(Place.Longitude.Minutes));
if (Place.Longitude.Seconds is null) throw new NullReferenceException(nameof(Place.Longitude.Seconds));
longitude = new(Place.Longitude.Degrees.Value, Place.Longitude.Minutes.Value, Place.Longitude.Seconds.Value);
result = new(
Place.Title,
latitude,
longitude
);
return result;
}
internal static ReadOnlyCollection<Models.Place> GetPlaces(string[]? places)
{
List<Models.Place> results = new();
if (places is not null)
{
Place? place;
foreach (string jsonElement in places)
{
place = JsonSerializer.Deserialize(jsonElement, BinderPlaceSourceGenerationContext.Default.Place);
results.Add(Get(place));
}
}
return new(results);
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Place))]
internal partial class BinderPlaceSourceGenerationContext : JsonSerializerContext
{
}

View File

@ -0,0 +1,23 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Instance.Models;
public record DegreesMinutesSeconds(float Degrees,
float Minutes,
float Seconds)
{
public override string ToString()
{
string result = JsonSerializer.Serialize(this, DegreesMinutesSecondsSourceGenerationContext.Default.DegreesMinutesSeconds);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(DegreesMinutesSeconds))]
internal partial class DegreesMinutesSecondsSourceGenerationContext : JsonSerializerContext
{
}

23
Instance/Models/Place.cs Normal file
View File

@ -0,0 +1,23 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace View_by_Distance.Instance.Models;
public record Place(string Title,
DegreesMinutesSeconds Latitude,
DegreesMinutesSeconds Longitude)
{
public override string ToString()
{
string result = JsonSerializer.Serialize(this, PlaceSourceGenerationContext.Default.Place);
return result;
}
}
[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(Place))]
internal partial class PlaceSourceGenerationContext : JsonSerializerContext
{
}