diff --git a/Sanchez.Processing/Extensions/ColorExtensions.cs b/Sanchez.Processing/Extensions/ColorExtensions.cs index 8d29c4d..a85abcb 100644 --- a/Sanchez.Processing/Extensions/ColorExtensions.cs +++ b/Sanchez.Processing/Extensions/ColorExtensions.cs @@ -1,6 +1,4 @@ -using SixLabors.ImageSharp; - -namespace Sanchez.Processing.Extensions; +namespace Sanchez.Processing.Extensions; public static class ColorExtensions { diff --git a/Sanchez.Processing/Extensions/Images/BackgroundExtensions.cs b/Sanchez.Processing/Extensions/Images/BackgroundExtensions.cs index f4fccf6..814658d 100644 --- a/Sanchez.Processing/Extensions/Images/BackgroundExtensions.cs +++ b/Sanchez.Processing/Extensions/Images/BackgroundExtensions.cs @@ -1,8 +1,4 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; - -namespace Sanchez.Processing.Extensions.Images; +namespace Sanchez.Processing.Extensions.Images; public static class BackgroundExtensions { diff --git a/Sanchez.Processing/Extensions/Images/BorderCropExtensions.cs b/Sanchez.Processing/Extensions/Images/BorderCropExtensions.cs index 884d953..4af4b0a 100644 --- a/Sanchez.Processing/Extensions/Images/BorderCropExtensions.cs +++ b/Sanchez.Processing/Extensions/Images/BorderCropExtensions.cs @@ -1,7 +1,4 @@ using Serilog; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; namespace Sanchez.Processing.Extensions.Images; diff --git a/Sanchez.Processing/Extensions/Images/DrawImageExtensions.cs b/Sanchez.Processing/Extensions/Images/DrawImageExtensions.cs index 8ea0562..1e09afc 100644 --- a/Sanchez.Processing/Extensions/Images/DrawImageExtensions.cs +++ b/Sanchez.Processing/Extensions/Images/DrawImageExtensions.cs @@ -1,8 +1,4 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; - -namespace Sanchez.Processing.Extensions.Images; +namespace Sanchez.Processing.Extensions.Images; public static class DrawImageExtensions { diff --git a/Sanchez.Processing/Extensions/Images/HistogramExtensions.cs b/Sanchez.Processing/Extensions/Images/HistogramExtensions.cs index fd79313..05e83c4 100644 --- a/Sanchez.Processing/Extensions/Images/HistogramExtensions.cs +++ b/Sanchez.Processing/Extensions/Images/HistogramExtensions.cs @@ -1,7 +1,4 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.ImageSharp.Processing.Processors.Normalization; +using SixLabors.ImageSharp.Processing.Processors.Normalization; namespace Sanchez.Processing.Extensions.Images; diff --git a/Sanchez.Processing/Extensions/Images/ImageExtensions.cs b/Sanchez.Processing/Extensions/Images/ImageExtensions.cs index efd0ff5..a48db2c 100644 --- a/Sanchez.Processing/Extensions/Images/ImageExtensions.cs +++ b/Sanchez.Processing/Extensions/Images/ImageExtensions.cs @@ -1,10 +1,8 @@ using System.ComponentModel.DataAnnotations; using System.Reflection; using ExifLibrary; -using SixLabors.ImageSharp; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Formats.Jpeg; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.Extensions.Images; @@ -24,8 +22,18 @@ public static async Task SaveWithExifAsync(this Image image, string path // Save image, increasing JPEG quality var encoder = image.DetectEncoder(path); - if (encoder is JpegEncoder jpegEncoder) jpegEncoder.Quality = 95; + if (encoder is JpegEncoder jpegEncoder) + { + encoder = new JpegEncoder + { + Quality = 95, + Interleaved = jpegEncoder.Interleaved, + ColorType = jpegEncoder.ColorType, + SkipMetadata = jpegEncoder.SkipMetadata + }; + } + try { await image.SaveAsync(path, encoder, ct); diff --git a/Sanchez.Processing/Extensions/Images/InterpolationExtensions.cs b/Sanchez.Processing/Extensions/Images/InterpolationExtensions.cs index 5e2b042..84ec8cd 100644 --- a/Sanchez.Processing/Extensions/Images/InterpolationExtensions.cs +++ b/Sanchez.Processing/Extensions/Images/InterpolationExtensions.cs @@ -1,6 +1,5 @@ using Sanchez.Processing.Models; using Sanchez.Processing.Models.Configuration; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.Extensions.Images; diff --git a/Sanchez.Processing/Extensions/Images/RegistrationExtensions.cs b/Sanchez.Processing/Extensions/Images/RegistrationExtensions.cs index 505fe33..f579c28 100644 --- a/Sanchez.Processing/Extensions/Images/RegistrationExtensions.cs +++ b/Sanchez.Processing/Extensions/Images/RegistrationExtensions.cs @@ -1,7 +1,6 @@ using Sanchez.Processing.ImageProcessing.Mask; using Sanchez.Processing.Models; using Sanchez.Processing.Models.Projections; -using SixLabors.ImageSharp.Processing; namespace Sanchez.Processing.Extensions.Images; diff --git a/Sanchez.Processing/Helpers/PathHelper.cs b/Sanchez.Processing/Helpers/PathHelper.cs index d4496a8..de82fda 100644 --- a/Sanchez.Processing/Helpers/PathHelper.cs +++ b/Sanchez.Processing/Helpers/PathHelper.cs @@ -28,7 +28,7 @@ public static class PathHelper /// private static string GetApplicationPath() { - var processFilename = Process.GetCurrentProcess().MainModule!.FileName; + var processFilename = Environment.ProcessPath; // Determine correct location of directories relative to application, depending on whether we are running // from a published executable or via dotnet. diff --git a/Sanchez.Processing/Helpers/ProgressBarFactory.cs b/Sanchez.Processing/Helpers/ProgressBarFactory.cs index 3e02f41..6c5d920 100644 --- a/Sanchez.Processing/Helpers/ProgressBarFactory.cs +++ b/Sanchez.Processing/Helpers/ProgressBarFactory.cs @@ -25,7 +25,7 @@ public static IProgressBar NewProgressBar(RenderOptions options, int maxTicks, s public static ProgressBarOptions DefaultOptions() { - return new() + return new ProgressBarOptions { ProgressCharacter = '─', ProgressBarOnBottom = true, diff --git a/Sanchez.Processing/ImageProcessing/Atmosphere/AtmosphereExtensions.cs b/Sanchez.Processing/ImageProcessing/Atmosphere/AtmosphereExtensions.cs index d74c343..44ac57d 100644 --- a/Sanchez.Processing/ImageProcessing/Atmosphere/AtmosphereExtensions.cs +++ b/Sanchez.Processing/ImageProcessing/Atmosphere/AtmosphereExtensions.cs @@ -1,8 +1,5 @@ using System.Collections.ObjectModel; -using SixLabors.ImageSharp; using SixLabors.ImageSharp.ColorSpaces; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; namespace Sanchez.Processing.ImageProcessing.Atmosphere; diff --git a/Sanchez.Processing/ImageProcessing/Atmosphere/AtmosphereRowOperation.cs b/Sanchez.Processing/ImageProcessing/Atmosphere/AtmosphereRowOperation.cs index b708084..09c08b8 100644 --- a/Sanchez.Processing/ImageProcessing/Atmosphere/AtmosphereRowOperation.cs +++ b/Sanchez.Processing/ImageProcessing/Atmosphere/AtmosphereRowOperation.cs @@ -1,10 +1,8 @@ using System.Collections.ObjectModel; using System.Numerics; using Sanchez.Processing.Models; -using SixLabors.ImageSharp; using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.ImageProcessing.Atmosphere; diff --git a/Sanchez.Processing/ImageProcessing/Crop/EwsAlignmentRowOperation.cs b/Sanchez.Processing/ImageProcessing/Crop/EwsAlignmentRowOperation.cs index 702f9ed..270def9 100644 --- a/Sanchez.Processing/ImageProcessing/Crop/EwsAlignmentRowOperation.cs +++ b/Sanchez.Processing/ImageProcessing/Crop/EwsAlignmentRowOperation.cs @@ -1,7 +1,5 @@ using System.Collections.Concurrent; using System.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.ImageProcessing.Crop; diff --git a/Sanchez.Processing/ImageProcessing/Intensity/IntensityRangeHelper.cs b/Sanchez.Processing/ImageProcessing/Intensity/IntensityRangeHelper.cs index 09a1322..e40f495 100644 --- a/Sanchez.Processing/ImageProcessing/Intensity/IntensityRangeHelper.cs +++ b/Sanchez.Processing/ImageProcessing/Intensity/IntensityRangeHelper.cs @@ -1,7 +1,4 @@ using Sanchez.Processing.Models.Angles; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; namespace Sanchez.Processing.ImageProcessing.Intensity; diff --git a/Sanchez.Processing/ImageProcessing/Lookup/ApplyLookupRowOperation.cs b/Sanchez.Processing/ImageProcessing/Lookup/ApplyLookupRowOperation.cs index 579001c..ecd4a44 100644 --- a/Sanchez.Processing/ImageProcessing/Lookup/ApplyLookupRowOperation.cs +++ b/Sanchez.Processing/ImageProcessing/Lookup/ApplyLookupRowOperation.cs @@ -1,7 +1,5 @@ using Sanchez.Processing.ImageProcessing.Intensity; using Sanchez.Processing.Models.Angles; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.ImageProcessing.Lookup; diff --git a/Sanchez.Processing/ImageProcessing/Mask/RemoveBackgroundExtensions.cs b/Sanchez.Processing/ImageProcessing/Mask/RemoveBackgroundExtensions.cs index cbbbeae..66d5ceb 100644 --- a/Sanchez.Processing/ImageProcessing/Mask/RemoveBackgroundExtensions.cs +++ b/Sanchez.Processing/ImageProcessing/Mask/RemoveBackgroundExtensions.cs @@ -1,8 +1,4 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; - -namespace Sanchez.Processing.ImageProcessing.Mask; +namespace Sanchez.Processing.ImageProcessing.Mask; public static class RemoveBackgroundExtensions { diff --git a/Sanchez.Processing/ImageProcessing/Mask/RemoveBackgroundRowOperation.cs b/Sanchez.Processing/ImageProcessing/Mask/RemoveBackgroundRowOperation.cs index 2b3d948..d4d420c 100644 --- a/Sanchez.Processing/ImageProcessing/Mask/RemoveBackgroundRowOperation.cs +++ b/Sanchez.Processing/ImageProcessing/Mask/RemoveBackgroundRowOperation.cs @@ -1,7 +1,5 @@ using System.Numerics; using Sanchez.Processing.Models; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.ImageProcessing.Mask; diff --git a/Sanchez.Processing/ImageProcessing/Noise/GaussianNoiseRowOperation.cs b/Sanchez.Processing/ImageProcessing/Noise/GaussianNoiseRowOperation.cs index 8643da5..93f0c7d 100644 --- a/Sanchez.Processing/ImageProcessing/Noise/GaussianNoiseRowOperation.cs +++ b/Sanchez.Processing/ImageProcessing/Noise/GaussianNoiseRowOperation.cs @@ -1,6 +1,5 @@ using System.Numerics; using Sanchez.Processing.Models; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.ImageProcessing.Noise; diff --git a/Sanchez.Processing/ImageProcessing/Noise/NoiseExtensions.cs b/Sanchez.Processing/ImageProcessing/Noise/NoiseExtensions.cs index f3deb2f..de9a327 100644 --- a/Sanchez.Processing/ImageProcessing/Noise/NoiseExtensions.cs +++ b/Sanchez.Processing/ImageProcessing/Noise/NoiseExtensions.cs @@ -1,8 +1,4 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; - -namespace Sanchez.Processing.ImageProcessing.Noise; +namespace Sanchez.Processing.ImageProcessing.Noise; public static class NoiseExtensions { diff --git a/Sanchez.Processing/ImageProcessing/Offset/OffsetExtensions.cs b/Sanchez.Processing/ImageProcessing/Offset/OffsetExtensions.cs index 8f05392..000bcc4 100644 --- a/Sanchez.Processing/ImageProcessing/Offset/OffsetExtensions.cs +++ b/Sanchez.Processing/ImageProcessing/Offset/OffsetExtensions.cs @@ -1,8 +1,4 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; - -namespace Sanchez.Processing.ImageProcessing.Offset; +namespace Sanchez.Processing.ImageProcessing.Offset; public static class OffsetExtensions { diff --git a/Sanchez.Processing/ImageProcessing/Projection/ReprojectRowOperation.cs b/Sanchez.Processing/ImageProcessing/Projection/ReprojectRowOperation.cs index 40ea301..e6f7830 100644 --- a/Sanchez.Processing/ImageProcessing/Projection/ReprojectRowOperation.cs +++ b/Sanchez.Processing/ImageProcessing/Projection/ReprojectRowOperation.cs @@ -7,8 +7,6 @@ using Sanchez.Processing.Models.Configuration; using Sanchez.Processing.Models.Projections; using Sanchez.Processing.Projections; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.ImageProcessing.Projection; diff --git a/Sanchez.Processing/ImageProcessing/Tint/TintExtensions.cs b/Sanchez.Processing/ImageProcessing/Tint/TintExtensions.cs index adb803e..a1daaf2 100644 --- a/Sanchez.Processing/ImageProcessing/Tint/TintExtensions.cs +++ b/Sanchez.Processing/ImageProcessing/Tint/TintExtensions.cs @@ -1,21 +1,16 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.ColorSpaces.Conversion; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.ColorSpaces.Conversion; namespace Sanchez.Processing.ImageProcessing.Tint; public static class TintExtensions { - private static readonly ColorSpaceConverter Converter = new(new ColorSpaceConverterOptions()); - /// /// Applies a tint to an image. /// public static void Tint(this Image image, Color colour) { var tint = colour.ToPixel(); - var lightness = 2 * (1 - (Converter.ToHsl(tint).L * 2 - 1)); + var lightness = 2 * (1 - (ColorSpaceConverter.ToHsl(tint).L * 2 - 1)); var operation = new TintRowOperation(tint, lightness); image.Mutate(c => c.ProcessPixelRowsAsVector4(row => operation.Invoke(row))); diff --git a/Sanchez.Processing/ImageProcessing/Tint/TintRowOperation.cs b/Sanchez.Processing/ImageProcessing/Tint/TintRowOperation.cs index d8ce03b..8e8da0e 100644 --- a/Sanchez.Processing/ImageProcessing/Tint/TintRowOperation.cs +++ b/Sanchez.Processing/ImageProcessing/Tint/TintRowOperation.cs @@ -1,5 +1,4 @@ using System.Numerics; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.ImageProcessing.Tint; diff --git a/Sanchez.Processing/ImageProcessing/Underlay/GeostationaryExtensions.cs b/Sanchez.Processing/ImageProcessing/Underlay/GeostationaryExtensions.cs index 64ddce0..f86f520 100644 --- a/Sanchez.Processing/ImageProcessing/Underlay/GeostationaryExtensions.cs +++ b/Sanchez.Processing/ImageProcessing/Underlay/GeostationaryExtensions.cs @@ -1,7 +1,4 @@ using Sanchez.Processing.Models; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; namespace Sanchez.Processing.ImageProcessing.Underlay; diff --git a/Sanchez.Processing/ImageProcessing/Underlay/GeostationaryProjectionRowOperation.cs b/Sanchez.Processing/ImageProcessing/Underlay/GeostationaryProjectionRowOperation.cs index b8d0e21..57b4fb0 100644 --- a/Sanchez.Processing/ImageProcessing/Underlay/GeostationaryProjectionRowOperation.cs +++ b/Sanchez.Processing/ImageProcessing/Underlay/GeostationaryProjectionRowOperation.cs @@ -3,8 +3,6 @@ using Sanchez.Processing.Extensions.Images; using Sanchez.Processing.Models; using Sanchez.Processing.Projections; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.ImageProcessing.Underlay; diff --git a/Sanchez.Processing/Models/Angles/AngleRange.cs b/Sanchez.Processing/Models/Angles/AngleRange.cs index 2052a6f..24d58a6 100644 --- a/Sanchez.Processing/Models/Angles/AngleRange.cs +++ b/Sanchez.Processing/Models/Angles/AngleRange.cs @@ -22,7 +22,7 @@ public AngleRange(Angle start, Angle end) : this(start.Radians, end.Radians) /// Unwraps a longitude range so the end angle is always greater than the start angle. /// This is to simplify maths for projections which wrap around the standard -180 to 180 degrees. /// - public AngleRange UnwrapLongitude() => End < Start ? new AngleRange(Start, End + Constants.Pi2) : this; + public AngleRange UnwrapLongitude() => End < Start ? this with { End = End + Constants.Pi2 } : this; public AngleRange NormaliseLongitude() => new(Start.NormaliseLongitude(), End.NormaliseLongitude()); diff --git a/Sanchez.Processing/Models/Constants.cs b/Sanchez.Processing/Models/Constants.cs index d17153b..b8dae14 100644 --- a/Sanchez.Processing/Models/Constants.cs +++ b/Sanchez.Processing/Models/Constants.cs @@ -1,6 +1,5 @@ using Sanchez.Processing.Helpers; using Sanchez.Processing.Models.Configuration; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.Models; diff --git a/Sanchez.Processing/Models/ImageBuffer.cs b/Sanchez.Processing/Models/ImageBuffer.cs index 398ff5b..8fd2b39 100644 --- a/Sanchez.Processing/Models/ImageBuffer.cs +++ b/Sanchez.Processing/Models/ImageBuffer.cs @@ -1,7 +1,4 @@ -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; - -namespace Sanchez.Processing.Models; +namespace Sanchez.Processing.Models; public class ImageBuffer { @@ -14,7 +11,7 @@ private ImageBuffer(Rgba32[] buffer, Size size) Size = size; } - public static ImageBuffer ToBuffer(Image image) => new(GetBuffer(image), image.Size()); + public static ImageBuffer ToBuffer(Image image) => new(GetBuffer(image), image.Size); private static Rgba32[] GetBuffer(Image image) { diff --git a/Sanchez.Processing/Models/Projections/Registration.cs b/Sanchez.Processing/Models/Projections/Registration.cs index 9b08e70..5520efe 100644 --- a/Sanchez.Processing/Models/Projections/Registration.cs +++ b/Sanchez.Processing/Models/Projections/Registration.cs @@ -1,7 +1,4 @@ using Sanchez.Processing.Models.Configuration; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; namespace Sanchez.Processing.Models.Projections; diff --git a/Sanchez.Processing/Models/RenderOptions.cs b/Sanchez.Processing/Models/RenderOptions.cs index e7c826a..d5916e3 100644 --- a/Sanchez.Processing/Models/RenderOptions.cs +++ b/Sanchez.Processing/Models/RenderOptions.cs @@ -1,6 +1,5 @@ using Sanchez.Processing.Models.Configuration; using Sanchez.Processing.Models.Projections; -using SixLabors.ImageSharp; namespace Sanchez.Processing.Models; @@ -163,7 +162,7 @@ public bool MultipleTargets /// /// Whether to apply gaussian noise to target image. /// - public bool Noise { get; set; } + public bool Noise { get; init; } /// /// Output image extension, based off . diff --git a/Sanchez.Processing/Models/UnderlayProjectionData.cs b/Sanchez.Processing/Models/UnderlayProjectionData.cs index 0103db2..5b16d2f 100644 --- a/Sanchez.Processing/Models/UnderlayProjectionData.cs +++ b/Sanchez.Processing/Models/UnderlayProjectionData.cs @@ -2,7 +2,6 @@ using Sanchez.Processing.Models.Angles; using Sanchez.Processing.Models.Configuration; using Sanchez.Processing.Models.Projections; -using SixLabors.ImageSharp; namespace Sanchez.Processing.Models; diff --git a/Sanchez.Processing/Projections/GeostationaryProjection.cs b/Sanchez.Processing/Projections/GeostationaryProjection.cs index ff60c4d..55be7fc 100644 --- a/Sanchez.Processing/Projections/GeostationaryProjection.cs +++ b/Sanchez.Processing/Projections/GeostationaryProjection.cs @@ -85,10 +85,10 @@ public static void ToScanningAngle(LatitudeCalculations latitudeCalculations, do /// public struct LatitudeCalculations { - public double Rc { get; set; } + public double Rc { get; init; } public double RcCosLatitude { get; set; } - public double CosLatitude { get; set; } - public double Sz { get; set; } - public double Sz2 { get; set; } + public double CosLatitude { get; init; } + public double Sz { get; init; } + public double Sz2 { get; init; } public double RadiusRatioSz2 { get; set; } } \ No newline at end of file diff --git a/Sanchez.Processing/Projections/ReverseGeostationaryProjection.cs b/Sanchez.Processing/Projections/ReverseGeostationaryProjection.cs index c38371f..ad949f5 100644 --- a/Sanchez.Processing/Projections/ReverseGeostationaryProjection.cs +++ b/Sanchez.Processing/Projections/ReverseGeostationaryProjection.cs @@ -59,7 +59,6 @@ public static void ToLatitudeLongitude(double scanningX, double scanningY, doubl public static void ToLatitudeLongitude( double scanningX, VerticalScanningCalculations verticalScanningCalculations, double satelliteLongitude, out double latitude, out double longitude) { - var l0 = satelliteLongitude; var satelliteHeight = verticalScanningCalculations.SatelliteHeight; var cosX = Cos(scanningX); @@ -80,7 +79,7 @@ public static void ToLatitudeLongitude( var sz = rs * cosX * sinY; latitude = Atan(RadiusEquatorSquared / RadiusPolarSquared * (sz / Sqrt((satelliteHeight - sx) * (satelliteHeight - sx) + sy * sy))); - longitude = (l0 - Atan(sy / (satelliteHeight - sx))).NormaliseLongitude(); + longitude = (satelliteLongitude - Atan(sy / (satelliteHeight - sx))).NormaliseLongitude(); } } @@ -90,8 +89,8 @@ public static void ToLatitudeLongitude( public struct VerticalScanningCalculations { public double T { get; set; } - public double CosY { get; set; } - public double SinY { get; set; } + public double CosY { get; init; } + public double SinY { get; init; } public double C { get; set; } - public double SatelliteHeight { get; set; } + public double SatelliteHeight { get; init; } } \ No newline at end of file diff --git a/Sanchez.Processing/Services/GradientService.cs b/Sanchez.Processing/Services/GradientService.cs index 2820cf2..6580a0c 100644 --- a/Sanchez.Processing/Services/GradientService.cs +++ b/Sanchez.Processing/Services/GradientService.cs @@ -6,10 +6,8 @@ using Sanchez.Processing.Extensions; using Sanchez.Processing.Models; using Sanchez.Processing.Models.Gradients; -using SixLabors.ImageSharp; using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.Services; @@ -48,11 +46,18 @@ private ReadOnlyCollection CreateGradient(string path) var colour = c.Colour.FromHexString(); if (colour == null) throw new ValidationException($"Unable to parse {c.Colour} as a hex triplet"); - if (c.Position == null) throw new ValidationException("Position must be specified for all colour stops"); - if (c.Position is < 0 or > 1) throw new ValidationException($"{c.Position} is an invalid position; valid values are from 0.0 to 1.0"); - - var rgb = colour.Value.ToPixel(); - return new ColourStop(_colourSpaceConverter.ToCieLch(rgb), c.Position.Value); + switch (c.Position) + { + case null: + throw new ValidationException("Position must be specified for all colour stops"); + case < 0 or > 1: + throw new ValidationException($"{c.Position} is an invalid position; valid values are from 0.0 to 1.0"); + default: + { + var rgb = colour.Value.ToPixel(); + return new ColourStop(_colourSpaceConverter.ToCieLch(rgb), c.Position.Value); + } + } }) .OrderBy(c => c.Position) .ToImmutableList(); diff --git a/Sanchez.Processing/Services/LookupService.cs b/Sanchez.Processing/Services/LookupService.cs index 7588f8d..a5bca33 100644 --- a/Sanchez.Processing/Services/LookupService.cs +++ b/Sanchez.Processing/Services/LookupService.cs @@ -1,9 +1,7 @@ using Sanchez.Processing.Extensions; using Sanchez.Processing.Models; -using SixLabors.ImageSharp; using SixLabors.ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion; -using SixLabors.ImageSharp.PixelFormats; namespace Sanchez.Processing.Services; diff --git a/Sanchez.Processing/Services/Underlay/UnderlayCacheRepository.cs b/Sanchez.Processing/Services/Underlay/UnderlayCacheRepository.cs index acd865a..1b73191 100644 --- a/Sanchez.Processing/Services/Underlay/UnderlayCacheRepository.cs +++ b/Sanchez.Processing/Services/Underlay/UnderlayCacheRepository.cs @@ -104,7 +104,7 @@ public async Task RegisterCacheAsync(SatelliteDefinition? definition, UnderlayPr await using var connection = new SqliteConnection(ConnectionString); await connection.OpenAsync(); - string sql = definition == null + var sql = definition == null ? "INSERT INTO UnderlayCache(Filename, Configuration, Timestamp) VALUES(@Filename, @Configuration, @Timestamp)" : "INSERT INTO UnderlayCache(Filename, Configuration, Longitude, Timestamp) VALUES(@Filename, @Configuration, @Longitude, @Timestamp)"; @@ -113,7 +113,7 @@ public async Task RegisterCacheAsync(SatelliteDefinition? definition, UnderlayPr { Filename = underlayPath, Configuration = JsonConvert.SerializeObject(data), - Longitude = definition?.Longitude, + definition?.Longitude, Timestamp = (DateTimeOffset)timestamp }); } diff --git a/Sanchez.Processing/Services/Underlay/UnderlayService.cs b/Sanchez.Processing/Services/Underlay/UnderlayService.cs index b6d5a04..e0045b1 100644 --- a/Sanchez.Processing/Services/Underlay/UnderlayService.cs +++ b/Sanchez.Processing/Services/Underlay/UnderlayService.cs @@ -5,9 +5,6 @@ using Sanchez.Processing.Models.Angles; using Sanchez.Processing.Models.Configuration; using Sanchez.Processing.Models.Projections; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; namespace Sanchez.Processing.Services.Underlay; @@ -104,7 +101,7 @@ private Image GetProjected(Image underlay, SatelliteDefinition? // Perform latitude crop to match IR imagery if required var equirectangularOptions = _options.EquirectangularRender; - if (equirectangularOptions == null || !equirectangularOptions.NoCrop && !equirectangularOptions.ExplicitCrop) + if (equirectangularOptions is null or { NoCrop: false, ExplicitCrop: false }) { Crop(underlay, data.LatitudeCrop!.Value); } diff --git a/Sanchez.Workflow/Models/Data/StitchWorkflowData.cs b/Sanchez.Workflow/Models/Data/StitchWorkflowData.cs index 520e7c2..307d3cd 100644 --- a/Sanchez.Workflow/Models/Data/StitchWorkflowData.cs +++ b/Sanchez.Workflow/Models/Data/StitchWorkflowData.cs @@ -15,5 +15,5 @@ public record StitchWorkflowData : WorkflowData /// public double GlobalOffset { get; init; } - public Rectangle? CropBounds { get; init; } = null!; + public Rectangle? CropBounds { get; init; } } \ No newline at end of file diff --git a/Sanchez.Workflow/Models/Data/TimelapseWorkflowData.cs b/Sanchez.Workflow/Models/Data/TimelapseWorkflowData.cs index 9543656..882fe41 100644 --- a/Sanchez.Workflow/Models/Data/TimelapseWorkflowData.cs +++ b/Sanchez.Workflow/Models/Data/TimelapseWorkflowData.cs @@ -30,5 +30,6 @@ public override void Dispose() { base.Dispose(); ImageProgressBar?.Dispose(); + GC.SuppressFinalize(this); } } \ No newline at end of file diff --git a/Sanchez.Workflow/Models/Data/WorkflowData.cs b/Sanchez.Workflow/Models/Data/WorkflowData.cs index 0f9d5e9..ccd556a 100644 --- a/Sanchez.Workflow/Models/Data/WorkflowData.cs +++ b/Sanchez.Workflow/Models/Data/WorkflowData.cs @@ -66,5 +66,7 @@ public virtual void Dispose() Activity?.Dispose(); Registration?.Dispose(); ProgressBar?.Dispose(); + + GC.SuppressFinalize(this); } } \ No newline at end of file diff --git a/Sanchez.Workflow/Services/WorkflowService.cs b/Sanchez.Workflow/Services/WorkflowService.cs index 25de74e..189cdea 100644 --- a/Sanchez.Workflow/Services/WorkflowService.cs +++ b/Sanchez.Workflow/Services/WorkflowService.cs @@ -152,7 +152,7 @@ public async Task StartAsync(CancellationTokenSource cancellationToken) => await _host.StartWorkflow(WorkflowConstants.Geostationary), // Equirectangular stitched timelapse - ProjectionType.Equirectangular when _options.StitchImages && _options.Interval != null + ProjectionType.Equirectangular when _options is { StitchImages: true, Interval: not null } => await _host.StartWorkflow(WorkflowConstants.EquirectangularTimelapse), // Equirectangular stitched diff --git a/Sanchez.Workflow/Steps/Common/ApplyNoise.cs b/Sanchez.Workflow/Steps/Common/ApplyNoise.cs index 6f787c1..9d405c0 100644 --- a/Sanchez.Workflow/Steps/Common/ApplyNoise.cs +++ b/Sanchez.Workflow/Steps/Common/ApplyNoise.cs @@ -14,16 +14,11 @@ namespace Sanchez.Workflow.Steps.Common; [UsedImplicitly(ImplicitUseTargetFlags.Members)] public class ApplyNoise : StepBody { - private readonly ILookupService _lookupService; private readonly RenderOptions _options; public Image? Image { get; set; } - public ApplyNoise(ILookupService lookupService, RenderOptions options) - { - _lookupService = lookupService; - _options = options; - } + public ApplyNoise(RenderOptions options) => _options = options; public override ExecutionResult Run(IStepExecutionContext context) { diff --git a/Sanchez.Workflow/Steps/Equirectangular/GetCropBounds.cs b/Sanchez.Workflow/Steps/Equirectangular/GetCropBounds.cs index a709224..6f3ea4f 100644 --- a/Sanchez.Workflow/Steps/Equirectangular/GetCropBounds.cs +++ b/Sanchez.Workflow/Steps/Equirectangular/GetCropBounds.cs @@ -50,7 +50,7 @@ public override ExecutionResult Run(IStepExecutionContext context) // Also, refactor. It's a mess. if (!autoCrop && !explicitCrop) { - CropBounds = !FullEarthCoverage ? GetPartialCoverageBounds(Activity, TargetImage) : TargetImage.Bounds(); + CropBounds = !FullEarthCoverage ? GetPartialCoverageBounds(Activity, TargetImage) : TargetImage.Bounds; return ExecutionResult.Next(); } @@ -61,7 +61,7 @@ public override ExecutionResult Run(IStepExecutionContext context) return ExecutionResult.Next(); } - private Rectangle GetExplicitCropBounds(IImageInfo targetImage) + private Rectangle GetExplicitCropBounds(Image targetImage) { var latitudeRange = _options.EquirectangularRender!.LatitudeRange; var longitudeRange = _options.EquirectangularRender!.LongitudeRange; @@ -81,7 +81,7 @@ private Rectangle GetExplicitCropBounds(IImageInfo targetImage) return new Rectangle(xPixelRange.Start, yPixelRange.Start, xPixelRange.Range, yPixelRange.Range); } - private Rectangle GetAutoCropBounds(IImageInfo targetImage) + private Rectangle GetAutoCropBounds(Image targetImage) { if (FullEarthCoverage) { @@ -97,7 +97,7 @@ private Rectangle GetAutoCropBounds(IImageInfo targetImage) } } - private Rectangle GetPartialCoverageBounds(Activity activity, IImageInfo targetImage) + private Rectangle GetPartialCoverageBounds(Activity activity, Image targetImage) { var minXLongitude = activity.Registrations .Where(r => r.LongitudeRange is { OverlappingLeft: false }) diff --git a/Sanchez.Workflow/Steps/Equirectangular/GetGlobalOffset.cs b/Sanchez.Workflow/Steps/Equirectangular/GetGlobalOffset.cs index acb15ed..3321947 100644 --- a/Sanchez.Workflow/Steps/Equirectangular/GetGlobalOffset.cs +++ b/Sanchez.Workflow/Steps/Equirectangular/GetGlobalOffset.cs @@ -43,7 +43,7 @@ private double GetOffset() // Explicit longitude crop var equirectangularRender = _options.EquirectangularRender; - if (equirectangularRender is { ExplicitCrop: true, LongitudeRange: { } }) + if (equirectangularRender is { ExplicitCrop: true, LongitudeRange: not null }) { return -equirectangularRender.LongitudeRange.Value.Start; } diff --git a/Sanchez.Workflow/Steps/Equirectangular/RenderUnderlay.cs b/Sanchez.Workflow/Steps/Equirectangular/RenderUnderlay.cs index 11f72d6..4ce3c86 100644 --- a/Sanchez.Workflow/Steps/Equirectangular/RenderUnderlay.cs +++ b/Sanchez.Workflow/Steps/Equirectangular/RenderUnderlay.cs @@ -68,7 +68,7 @@ public override async Task RunAsync(IStepExecutionContext conte _options.InterpolationType, _options.UnderlayPath, _options.ImageSize, - TargetImage!.Size(), + TargetImage!.Size, latitudeRange, longitudeRange.Start, _options.EquirectangularRender?.NoCrop == true || _options.EquirectangularRender?.ExplicitCrop == true); diff --git a/Sanchez.Workflow/Steps/Equirectangular/ShouldWrite.cs b/Sanchez.Workflow/Steps/Equirectangular/ShouldWrite.cs index 4fb3b47..a6436e1 100644 --- a/Sanchez.Workflow/Steps/Equirectangular/ShouldWrite.cs +++ b/Sanchez.Workflow/Steps/Equirectangular/ShouldWrite.cs @@ -49,7 +49,7 @@ public override ExecutionResult Run(IStepExecutionContext context) if (!Activity.Registrations.Any()) { - _logger.LogInformation("No images found; skipping", Activity.OutputPath); + _logger.LogInformation("No images found; skipping"); ProgressBar.Tick($"Scanning {Timestamp:s}{Identifier}"); return ExecutionResult.Outcome(false); diff --git a/Sanchez.sln b/Sanchez.sln index ba7e620..ff5c8a9 100644 --- a/Sanchez.sln +++ b/Sanchez.sln @@ -18,6 +18,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sanchez.Test.Common", "Test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sanchez.Workflow.Test", "Tests\Sanchez.Workflow.Test\Sanchez.Workflow.Test.csproj", "{20B7AFEC-00B8-4BBD-BA32-A604643C0B28}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{9F1B3718-DEC3-4E24-8280-47B3CD3BB646}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md + Directory.Build.props = Directory.Build.props + LICENSE = LICENSE + README.md = README.md + Directory.Packages.props = Directory.Packages.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Sanchez.sln.DotSettings.user b/Sanchez.sln.DotSettings.user index 077cea4..7278d58 100644 --- a/Sanchez.sln.DotSettings.user +++ b/Sanchez.sln.DotSettings.user @@ -3,10 +3,11 @@ <Assembly Path="C:\code\sanchez\Tests\Sanchez.Processing.Test\bin\Debug\netcoreapp3.1\Sanchez.Processing.dll" /> </AssemblyExplorer> - <SessionState ContinuousTestingMode="0" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + + <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <Solution /> </SessionState> - <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <SessionState ContinuousTestingMode="0" Name="All tests from Solution #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> <Solution /> </SessionState> diff --git a/Sanchez/Services/ValidationExceptionWrapper.cs b/Sanchez/Services/ValidationExceptionWrapper.cs index 39eb7d8..686c610 100644 --- a/Sanchez/Services/ValidationExceptionWrapper.cs +++ b/Sanchez/Services/ValidationExceptionWrapper.cs @@ -13,7 +13,7 @@ namespace Sanchez.Services; /// internal class ValidationExceptionWrapper : ILogEventSink, IDisposable { - readonly ILogEventSink _wrappedSink; + private readonly ILogEventSink _wrappedSink; public ValidationExceptionWrapper(ILogEventSink wrappedSink) => _wrappedSink = wrappedSink; @@ -44,7 +44,7 @@ public void Dispose() } } -static class LoggerSinkConfigurationExtensions +internal static class LoggerSinkConfigurationExtensions { /// /// Wraps log entries resulting from , reporting diff --git a/Sanchez/Validators/CommandLineOptionsValidator.cs b/Sanchez/Validators/CommandLineOptionsValidator.cs index 43e7d50..6041d78 100644 --- a/Sanchez/Validators/CommandLineOptionsValidator.cs +++ b/Sanchez/Validators/CommandLineOptionsValidator.cs @@ -61,9 +61,7 @@ private void ValidateOverlayOptions() if (minIntensity < 0) return false; if (maxIntensity > 1) return false; - if (minIntensity >= maxIntensity) return false; - - return true; + return minIntensity < maxIntensity; }) .When(r => r != null) .WithMessage("Invalid intensity range; expected format is min-max; e.g. 0.0 to 1.0"); diff --git a/Tests/Sanchez.Processing.Test/Filesystem/ImageLocatorTests.cs b/Tests/Sanchez.Processing.Test/Filesystem/ImageLocatorTests.cs index 9e5645b..7e0d210 100644 --- a/Tests/Sanchez.Processing.Test/Filesystem/ImageLocatorTests.cs +++ b/Tests/Sanchez.Processing.Test/Filesystem/ImageLocatorTests.cs @@ -14,7 +14,7 @@ public class ImageLocatorTests : AbstractTests [Test] public void LocateImages() { - RenderOptions.EquirectangularRender = new EquirectangularRenderOptions(false, false, true, null); + RenderOptions.EquirectangularRender = new EquirectangularRenderOptions(false, false, true); var targetTimestamp = new DateTime(2020, 08, 30, 03, 30, 00, DateTimeKind.Utc); RenderOptions.Tolerance = TimeSpan.FromMinutes(30); diff --git a/Tests/Sanchez.Processing.Test/Models/RenderOptionsTests.cs b/Tests/Sanchez.Processing.Test/Models/RenderOptionsTests.cs index 69f25f5..b1d70ef 100644 --- a/Tests/Sanchez.Processing.Test/Models/RenderOptionsTests.cs +++ b/Tests/Sanchez.Processing.Test/Models/RenderOptionsTests.cs @@ -103,7 +103,7 @@ public void NoStitchIfGeostationaryAndNoLatitude() private static RenderOptions GeostationaryOptions(Angle? longitude = null, Angle? endLongitude = null) { - return new() + return new RenderOptions { GeostationaryRender = new GeostationaryRenderOptions(longitude, endLongitude, false, 1.0f, 0.9f) }; @@ -111,7 +111,7 @@ private static RenderOptions GeostationaryOptions(Angle? longitude = null, Angle private static RenderOptions EquirectangularOptions() { - return new() + return new RenderOptions { EquirectangularRender = new EquirectangularRenderOptions(false, false, true) }; diff --git a/Tests/Sanchez.Processing.Test/Services/GradientServiceTests.cs b/Tests/Sanchez.Processing.Test/Services/GradientServiceTests.cs index 46210ee..a643eac 100644 --- a/Tests/Sanchez.Processing.Test/Services/GradientServiceTests.cs +++ b/Tests/Sanchez.Processing.Test/Services/GradientServiceTests.cs @@ -31,7 +31,7 @@ public async Task MissingColour() new() { Position = 0.1f - }, + } }; await CreateGradientFileAsync(gradient); @@ -54,7 +54,7 @@ public async Task MissingPosition() new() { Colour = "#aa0000" - }, + } }; await CreateGradientFileAsync(gradient); @@ -72,13 +72,13 @@ public async Task ValueTooLow() new() { Colour = "#ff0000", - Position = -0.5f, + Position = -0.5f }, new() { Colour = "#aa0000", Position = 1f - }, + } }; await CreateGradientFileAsync(gradient); @@ -102,7 +102,7 @@ public async Task ValueTooHigh() { Colour = "#aa0000", Position = 2.3f - }, + } }; await CreateGradientFileAsync(gradient); @@ -126,7 +126,7 @@ public async Task InvalidColours() { Colour = "#sanchez", Position = 1.0f - }, + } }; await CreateGradientFileAsync(gradient); diff --git a/Tests/Sanchez.Processing.Test/Validators/GeostationaryOptionsValidatorTests.cs b/Tests/Sanchez.Processing.Test/Validators/GeostationaryOptionsValidatorTests.cs index 17e4ede..2bf1b2e 100644 --- a/Tests/Sanchez.Processing.Test/Validators/GeostationaryOptionsValidatorTests.cs +++ b/Tests/Sanchez.Processing.Test/Validators/GeostationaryOptionsValidatorTests.cs @@ -206,9 +206,9 @@ public void ValidTint(string tint) VerifyNoFailure(options, "Tint"); } - private GeostationaryOptions ValidOptions() + private static GeostationaryOptions ValidOptions() { - return new() + return new GeostationaryOptions { Tint = "0000FF", SpatialResolution = Constants.Satellite.SpatialResolution.TwoKm diff --git a/Tests/Sanchez.Test/GeostationaryEndToEndTests.cs b/Tests/Sanchez.Test/GeostationaryEndToEndTests.cs index d1ab0b1..36a4561 100644 --- a/Tests/Sanchez.Test/GeostationaryEndToEndTests.cs +++ b/Tests/Sanchez.Test/GeostationaryEndToEndTests.cs @@ -122,7 +122,7 @@ public async Task Multiple() foreach (var outputFile in Directory.GetFiles(outputDirectory)) { var outputImage = await Image.LoadAsync(outputFile); - outputImage.Width.Should().Be((int)(ScaledLength)); + outputImage.Width.Should().Be(ScaledLength); outputImage.Height.Should().Be(ScaledLength); } } diff --git a/Tests/Sanchez.Workflow.Test/Equirectangular/GetCropBoundsTests.cs b/Tests/Sanchez.Workflow.Test/Equirectangular/GetCropBoundsTests.cs index a80cdc1..b1cb725 100644 --- a/Tests/Sanchez.Workflow.Test/Equirectangular/GetCropBoundsTests.cs +++ b/Tests/Sanchez.Workflow.Test/Equirectangular/GetCropBoundsTests.cs @@ -45,7 +45,7 @@ public async Task ExplicitCropWrap() { using var image = new Image(100, 100); _step.TargetImage = image; - _step.Activity = new Activity(new Registration[] { }); + _step.Activity = new Activity(Array.Empty()); var longitudeRange = new AngleRange(Angle.FromDegrees(0), Angle.FromDegrees(360)); Options.EquirectangularRender = new EquirectangularRenderOptions(false, false, false, null, longitudeRange); diff --git a/Tests/Sanchez.Workflow.Test/Equirectangular/PrepareTimeIntervalsTests.cs b/Tests/Sanchez.Workflow.Test/Equirectangular/PrepareTimeIntervalsTests.cs index c55a376..7497017 100644 --- a/Tests/Sanchez.Workflow.Test/Equirectangular/PrepareTimeIntervalsTests.cs +++ b/Tests/Sanchez.Workflow.Test/Equirectangular/PrepareTimeIntervalsTests.cs @@ -62,12 +62,12 @@ public async Task StartAndEndTimestamp() private List CreateRegistrations() { - return new() + return new List { - new Registration("first.jpg", null!, null), - new Registration("second.jpg", null!, DateTime.Today.AddHours(-1)), - new Registration("third.jpg", null!, DateTime.Today), - new Registration("fourth.jpg", null!, DateTime.Today.AddHours(-2)) + new("first.jpg", null!, null), + new("second.jpg", null!, DateTime.Today.AddHours(-1)), + new("third.jpg", null!, DateTime.Today), + new("fourth.jpg", null!, DateTime.Today.AddHours(-2)) }; } } \ No newline at end of file