Skip to content

Commit 8d77b0c

Browse files
authored
Merge pull request #243 from Tronald/develop
2.24.2.1
2 parents f464766 + 98f1000 commit 8d77b0c

File tree

5 files changed

+56
-8
lines changed

5 files changed

+56
-8
lines changed

CoordinateSharp.Magnetic/CoordinateSharp.Magnetic.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ For more information, please contact Signature Group, LLC at this address: sales
4747
<TargetFrameworks>net40; netstandard1.3; netstandard1.4; netstandard2.0; netstandard2.1; net50; net60; net70; net80</TargetFrameworks>
4848
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
4949
<GenerateDocumentationFile>true</GenerateDocumentationFile>
50-
<Version>1.1.14.0</Version>
50+
<Version>1.1.15.0</Version>
5151
<Authors>Signature Group, LLC</Authors>
5252
<Company />
5353
<PackageProjectUrl>https://github.com/Tronald/CoordinateSharp</PackageProjectUrl>
@@ -61,7 +61,7 @@ For more information, please contact Signature Group, LLC at this address: sales
6161
<PackageIconUrl></PackageIconUrl>
6262
<PackageId>CoordinateSharp.Magnetic</PackageId>
6363
<Title>CoordinateSharp.Magnetic</Title>
64-
<AssemblyVersion>1.1.14.0</AssemblyVersion>
64+
<AssemblyVersion>1.1.15.0</AssemblyVersion>
6565
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
6666
<SignAssembly>true</SignAssembly>
6767
<PackageIcon>128x128.png</PackageIcon>

CoordinateSharp/Celestial/Solar/SunCalculations.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ public static void CalculateSunTime(double lat, double lng, DateTime date, Celes
9191
//https://github.com/Tronald/CoordinateSharp/issues/167
9292

9393
var safety = new Celestial();
94-
CalculateSunAngle(c.solarNoon.Value, lng, lat, safety, celC);
94+
//Solarnoon may return null on certain days due to formula limitations in circumpolar regions.
95+
//When this occurs set noon to 00:00 because issue occurs around 0 hour.
96+
//The check is accurate enough for up or down all day determination
97+
DateTime? snoon = c.solarNoon;
98+
if (snoon == null) { snoon=actualDate.AddHours(-offset); }
99+
CalculateSunAngle(snoon.Value, lng, lat, safety, celC);
95100

96101
if (safety.sunAltitude <= -.8333)
97102
{

CoordinateSharp/CoordinateSharp.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,28 @@ Please visit http://coordinatesharp.com/licensing or contact Signature Group, LL
5050
<TargetFrameworks>net40; netstandard1.3; netstandard1.4; netstandard2.0; netstandard2.1; net50; net60; net70; net80</TargetFrameworks>
5151
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
5252
<GenerateDocumentationFile>true</GenerateDocumentationFile>
53-
<Version>2.24.1.1</Version>
53+
<Version>2.24.2.1</Version>
5454
<Authors>Signature Group, LLC</Authors>
5555
<Company />
5656
<PackageProjectUrl>https://github.com/Tronald/CoordinateSharp</PackageProjectUrl>
5757
<PackageLicenseUrl></PackageLicenseUrl>
5858
<Copyright>Copyright 2024</Copyright>
5959
<Description>CoordinateSharp is a high powered, lightweight .NET library that can convert geographical coordinates, perform distance logic, and calculate location based sun, moon, and magnetic information with minimal code.</Description>
60-
<PackageReleaseNotes>-Fixes bug causing incorrect sun condition to report in circumpolar regions during slow transition at horizon.
61-
-Adds feature to allow custom specification of earth shape during point densification.</PackageReleaseNotes>
60+
<PackageReleaseNotes>-Fixes critical bug causing exceptions near poles.
61+
-Fixes bugs causing incorrect sun condition to report in circumpolar regions during slow transition at horizon.
62+
-Adds overload to GeoFence.Denisfy() to allow custom specification of earth shape during point densification.</PackageReleaseNotes>
6263
<PackageTags>Conversion; Latitude; Longitude; Coordinates; Geography; Sun; Moon; Solar; Lunar; Time; MGRS; UTM; EPSG:3857; ECEF; GEOREF; Web Mercator;</PackageTags>
6364
<!-- <PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>-->
6465
<PackageLicenseFile>License.txt</PackageLicenseFile> <PackageIconUrl></PackageIconUrl>
6566
<PackageId>CoordinateSharp</PackageId>
6667
<Title>CoordinateSharp</Title>
67-
<AssemblyVersion>2.24.1.1</AssemblyVersion>
68+
<AssemblyVersion>2.24.2.1</AssemblyVersion>
6869
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
6970
<SignAssembly>true</SignAssembly>
7071
<PackageIcon>128x128.png</PackageIcon>
7172
<AssemblyOriginatorKeyFile>CoordinateSharp Strong Name.snk</AssemblyOriginatorKeyFile>
7273
<DelaySign>false</DelaySign>
73-
<FileVersion>2.24.1.1</FileVersion>
74+
<FileVersion>2.24.2.1</FileVersion>
7475
<RepositoryUrl>https://github.com/Tronald/CoordinateSharp</RepositoryUrl>
7576
<PackageReadmeFile>README.md</PackageReadmeFile>
7677
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

CoordinateSharp_UnitTests/Celestial.Solar.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Reflection.Metadata.Ecma335;
1414
using System.Text.Json;
1515
using Newtonsoft.Json;
16+
using System.Threading.Tasks;
1617

1718
namespace CoordinateSharp_UnitTests
1819
{
@@ -778,6 +779,7 @@ public void Check_Horizon_Hang_Correction()
778779
Assert.AreEqual(c.SunCondition, CelestialStatus.NoSet);
779780

780781
}
782+
781783
}
782784

783785

CoordinateSharp_UnitTests/Coordinate_Initialization_Tests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using CoordinateSharp;
44
using NuGet.Frameworks;
55
using System.Xml;
6+
using System.Collections.Generic;
7+
using System.Threading.Tasks;
68

79
namespace CoordinateSharp_UnitTests
810
{
@@ -55,6 +57,44 @@ public void CoordinatePart_Initializes_Without_Exceptions()
5557

5658
}
5759

60+
//Test has high chance to catch random exception issues in circumpolar region.
61+
//Long running however, so comment out until final tests ran if needed
62+
[TestMethod]
63+
public void CoordinateInitExceptionCheckNPole()
64+
{
65+
List<Task> tasks = new List<Task>();
66+
67+
for (int i1 = -180; i1 < 180; i1++)
68+
{
69+
DateTime dateTime1 = new DateTime(2024, 1, 1);
70+
71+
for (int i = 0; i < 365; i++)
72+
{
73+
int currentI1 = i1;
74+
DateTime currentDate = dateTime1.AddDays(i);
75+
76+
// Initialize the Coordinate object within a Task
77+
Task coordinateTask = Task.Run(() =>
78+
{
79+
var coordinate = new Coordinate(90, currentI1, currentDate);
80+
coordinate.Offset = 2;
81+
return coordinate;
82+
});
83+
84+
tasks.Add(coordinateTask);
85+
}
86+
}
87+
88+
try
89+
{
90+
Task.WhenAll(tasks).GetAwaiter().GetResult();
91+
}
92+
catch (Exception ex)
93+
{
94+
Assert.Fail($"Task threw an exception: {ex}");
95+
}
96+
}
97+
5898
/// <summary>
5999
/// Test UTM initialization to ensure no exceptions are thrown.
60100
/// </summary>

0 commit comments

Comments
 (0)