Skip to content

Commit ef8382c

Browse files
authored
Merge pull request #231 from Tronald/develop
2.21.1.1
2 parents 758259f + 2936821 commit ef8382c

13 files changed

+144
-80
lines changed

CoordinateSharp.Magnetic/CoordinateSharp.Magnetic.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,25 @@ For more information, please contact Signature Group, LLC at this address: sales
4444
-->
4545
<Project Sdk="Microsoft.NET.Sdk">
4646
<PropertyGroup>
47-
<TargetFrameworks>net40; netstandard1.3; netstandard1.4; netstandard2.0; netstandard2.1; net50; net60; net70</TargetFrameworks>
47+
<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.10.0</Version>
50+
<Version>1.1.11.0</Version>
5151
<Authors>Signature Group, LLC</Authors>
5252
<Company />
5353
<PackageProjectUrl>https://github.com/Tronald/CoordinateSharp</PackageProjectUrl>
5454
<PackageLicenseUrl></PackageLicenseUrl>
5555
<Copyright>Copyright 2023</Copyright>
5656
<Description>CoordinateSharp magnetic data extensions.</Description>
57-
<PackageReleaseNotes>Maps to latest CoordinateSharp version</PackageReleaseNotes>
57+
<PackageReleaseNotes>-Adds NET 8.0 support.
58+
-Maps to latest CoordinateSharp version.</PackageReleaseNotes>
5859
<PackageTags>CoordinateSharp Latitude Longitude Coordinates Geography Magnetic Declination</PackageTags>
5960
<!-- <PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>-->
6061
<PackageLicenseFile>License.txt</PackageLicenseFile>
6162
<PackageIconUrl></PackageIconUrl>
6263
<PackageId>CoordinateSharp.Magnetic</PackageId>
6364
<Title>CoordinateSharp.Magnetic</Title>
64-
<AssemblyVersion>1.1.9.0</AssemblyVersion>
65+
<AssemblyVersion>1.1.11.0</AssemblyVersion>
6566
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
6667
<SignAssembly>true</SignAssembly>
6768
<PackageIcon>128x128.png</PackageIcon>

CoordinateSharp/Celestial/Data/LunarData.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ namespace CoordinateSharp.Eclipse
5050
{
5151
internal class LunarData
5252
{
53+
//Tables: https://eclipse.gsfc.nasa.gov/JLEX/JLEX-NA.html
54+
5355
static double[] LE1601 = new double[] {
5456
// 1601 1 18
5557
2305831.105839, 15.0, 117.3, 0.033, -0.978, 3,
@@ -14584,7 +14586,7 @@ internal class LunarData
1458414586
20.1319604, 0.56553, 5.160e-04,
1458514587
8.0835801, 0.28700, -3.300e-04
1458614588
};
14587-
14589+
1458814590
public static double[] LunarDateData(DateTime d)
1458914591
{
1459014592
//Return combined 100 year arrays so in order to grab Last and Next exlipLE.

CoordinateSharp/Celestial/Lunar/Lunar.HelperClasses.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,26 +216,23 @@ internal void ConvertTo_Local_Time(double offset)
216216
/// </summary>
217217
[Serializable]
218218
public class LunarEclipse
219-
{
220-
internal LunarEclipseDetails lastEclipse;
221-
internal LunarEclipseDetails nextEclipse;
222-
219+
{
223220
/// <summary>
224221
/// Initialize a LunarEclipse object
225222
/// </summary>
226223
public LunarEclipse()
227224
{
228-
lastEclipse = new LunarEclipseDetails();
229-
nextEclipse = new LunarEclipseDetails();
225+
LastEclipse = new LunarEclipseDetails();
226+
NextEclipse = new LunarEclipseDetails();
230227
}
231228
/// <summary>
232229
/// Details about the previous lunar eclipse at the specified DateTime and Coordinate.
233230
/// </summary>
234-
public LunarEclipseDetails LastEclipse { get { return lastEclipse; } }
231+
public LunarEclipseDetails LastEclipse { get; internal set; }
235232
/// <summary>
236233
/// Details about the next lunar eclipse at the specified DateTime and Coordinate.
237234
/// </summary>
238-
public LunarEclipseDetails NextEclipse { get { return nextEclipse; } }
235+
public LunarEclipseDetails NextEclipse { get; internal set; }
239236

240237
internal void ConvertTo_LocalTime(double offset)
241238
{
@@ -408,6 +405,8 @@ public class LunarEclipseDetails
408405
private DateTime totalEclipseEnd;
409406
private DateTime partialEclispeEnd;
410407
private DateTime penumbralEclipseEnd;
408+
private double penumbralMagnitude;
409+
private double umbralMagnitude;
411410

412411
private bool hasEclipseData;
413412

@@ -471,6 +470,15 @@ public LunarEclipseDetails(List<string> values)
471470
{
472471
penumbralEclipseEnd = date.Add(ts);
473472
}
473+
474+
double pu = 0;
475+
double.TryParse(values[2], out pu);
476+
penumbralMagnitude = pu;
477+
478+
pu = 0;
479+
double.TryParse(values[3], out pu);
480+
umbralMagnitude = pu;
481+
474482
Adjust_Dates();
475483
}
476484
/// <summary>
@@ -576,6 +584,19 @@ private void Adjust_Dates()
576584
/// DateTime when the penumbral eclipse ends.
577585
/// </summary>
578586
public DateTime PenumbralEclispeEnd { get { return penumbralEclipseEnd; } }
587+
588+
/// <summary>
589+
/// Penumbral magnitude. The fraction of the Moon's diameter that is covered by Earth's penumbra (lighter part of Earth's shadow).
590+
/// The penumbral magnitude of a total lunar eclipse is usually greater than 2 while the penumbral magnitude of a partial lunar eclipse is
591+
/// always greater than 1 and usually smaller than 2.
592+
/// </summary>
593+
public double PenumbralMagnitude { get { return penumbralMagnitude; } }
594+
595+
/// <summary>
596+
/// Umbral magnitude. The fraction of the Moon's diameter that is covered by Earth's umbra (darker part of Earth's shadow) at the instance of the greatest eclipse.
597+
/// </summary>
598+
public double UmbralMagnitude { get { return umbralMagnitude; } }
599+
579600
/// <summary>
580601
/// Lunar eclipse default string.
581602
/// </summary>

CoordinateSharp/Celestial/Lunar/MoonCalculations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,11 @@ public static void CalculateLunarEclipse(DateTime date, double lat, double longi
473473
//SET ECLIPSE DATA
474474
if (lastE >= 0)
475475
{
476-
c.LunarEclipse.lastEclipse = new LunarEclipseDetails(se[lastE]);
476+
c.LunarEclipse.LastEclipse = new LunarEclipseDetails(se[lastE]);
477477
}
478478
if (nextE >= 0)
479479
{
480-
c.LunarEclipse.nextEclipse = new LunarEclipseDetails(se[nextE]);
480+
c.LunarEclipse.NextEclipse = new LunarEclipseDetails(se[nextE]);
481481
}
482482
}
483483

CoordinateSharp/Celestial/Solar/Solar.HelperClasses.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,23 @@ internal void Convert_To_Local_Time(double offset)
160160
[Serializable]
161161
public class SolarEclipse
162162
{
163-
internal SolarEclipseDetails lastEclipse;
164-
internal SolarEclipseDetails nextEclipse;
165-
163+
166164
/// <summary>
167165
/// Initialize a SolarEclipse object.
168166
/// </summary>
169167
public SolarEclipse()
170168
{
171-
lastEclipse = new SolarEclipseDetails();
172-
nextEclipse = new SolarEclipseDetails();
169+
LastEclipse = new SolarEclipseDetails();
170+
NextEclipse = new SolarEclipseDetails();
173171
}
174172
/// <summary>
175173
/// Details about the previous solar eclipse at the specified DateTime and Coordinate.
176174
/// </summary>
177-
public SolarEclipseDetails LastEclipse { get { return lastEclipse; } }
175+
public SolarEclipseDetails LastEclipse { get; internal set; }
178176
/// <summary>
179177
/// Details about the next solar eclipse at the specified DateTime and Coordinate.
180178
/// </summary>
181-
public SolarEclipseDetails NextEclipse { get { return nextEclipse; } }
179+
public SolarEclipseDetails NextEclipse { get; internal set; }
182180

183181
internal void ConvertTo_LocalTime(double offset)
184182
{
@@ -200,6 +198,8 @@ public class SolarEclipseDetails
200198
internal DateTime aorTEclipseEnd;
201199
internal DateTime partialEclispeEnd;
202200
internal TimeSpan aorTDuration;
201+
internal double magnitude;
202+
internal double coverage;
203203

204204
internal bool hasEclipseData;
205205

@@ -254,6 +254,15 @@ public SolarEclipseDetails(List<string> values)
254254
{
255255
partialEclispeEnd = date.Add(ts);
256256
}
257+
258+
double mc = 0;
259+
double.TryParse(values[11],out mc);
260+
magnitude = mc;
261+
262+
mc = 0;
263+
double.TryParse(values[12], out mc);
264+
coverage = mc;
265+
257266
//A or T Duration
258267
if (values[13] != "-")
259268
{
@@ -366,11 +375,28 @@ private void Adjust_Dates()
366375
/// <summary>
367376
/// DateTime when the partial eclipse ends.
368377
/// </summary>
378+
[Obsolete("Property named incorrectly. Use correctly named 'PartialEclipseEnd' instead.")]
369379
public DateTime PartialEclispeEnd { get { return partialEclispeEnd; } }
380+
/// <summary>
381+
/// DateTime when the partial eclipse ends.
382+
/// </summary>
383+
public DateTime PartialEclipseEnd { get { return partialEclispeEnd; } }
384+
370385
/// <summary>
371386
/// Duration of Annular or Total eclipse (if applicable).
372387
/// </summary>
373388
public TimeSpan AorTDuration { get { return aorTDuration; } }
389+
390+
/// <summary>
391+
/// Eclipse magnitude. Annular and partial will be between 0.0-1.0, while total will exceed 1.0.
392+
/// </summary>
393+
public double Magnitude { get { return magnitude; } }
394+
395+
/// <summary>
396+
/// Coverage of the eclipse. Will be between 0.0-1.0.
397+
/// </summary>
398+
public double Coverage { get { return coverage; } }
399+
374400
/// <summary>
375401
/// Solar eclipse default string.
376402
/// </summary>

CoordinateSharp/Celestial/Solar/SolarEclipseCalc.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -920,13 +920,15 @@ private static string GetMagnitude(double[] mid)
920920
{
921921
return ans;
922922
}
923-
if (mid[40] == 2)
923+
if (mid[40] == 2) //Event occurring at sunrise
924924
{
925-
ans = a.ToString() + "(r)";
925+
return ans;
926+
//ans = a.ToString() + "(r)";
926927
}
927928
if (mid[40] == 3)
928929
{
929-
ans = a.ToString() + "(s)";
930+
return ans;
931+
//ans = a.ToString()+ "(s)"; //event occurring at sunset
930932
}
931933
return ans;
932934
}
@@ -966,11 +968,13 @@ private static string GetCoverage(double[] mid)
966968
}
967969
if (mid[40] == 2)
968970
{
969-
ans = a.ToString() + "(r)";
971+
return ans;
972+
//ans = a.ToString() + "(r)"; // + "(r)";
970973
}
971974
if (mid[40] == 3)
972975
{
973-
ans = a + "(s)";
976+
return ans;
977+
// ans = a + "(s)"; //event occurring at sunset
974978
}
975979
return ans;
976980
}

CoordinateSharp/Celestial/Solar/SunCalculations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ public static void CalculateSolarEclipse(DateTime date, double lat, double longi
330330
//SET ECLIPSE DATA
331331
if (lastE >= 0)
332332
{
333-
c.SolarEclipse.lastEclipse = new SolarEclipseDetails(se[lastE]);
333+
c.SolarEclipse.LastEclipse = new SolarEclipseDetails(se[lastE]);
334334
}
335335
if (nextE >= 0)
336336
{
337-
c.SolarEclipse.nextEclipse = new SolarEclipseDetails(se[nextE]);
337+
c.SolarEclipse.NextEclipse = new SolarEclipseDetails(se[nextE]);
338338
}
339339
}
340340

CoordinateSharp/CoordinateSharp.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,32 @@ Please visit http://coordinatesharp.com/licensing or contact Signature Group, LL
4747
-->
4848
<Project Sdk="Microsoft.NET.Sdk">
4949
<PropertyGroup>
50-
<TargetFrameworks>net40; netstandard1.3; netstandard1.4; netstandard2.0; netstandard2.1; net50; net60; net70</TargetFrameworks>
50+
<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.20.1.1</Version>
53+
<Version>2.21.1.1</Version>
5454
<Authors>Signature Group, LLC</Authors>
5555
<Company />
5656
<PackageProjectUrl>https://github.com/Tronald/CoordinateSharp</PackageProjectUrl>
5757
<PackageLicenseUrl></PackageLicenseUrl>
5858
<Copyright>Copyright 2023</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>-Adds ability to estimate time of day from sun azimuth.
61-
-Adds "out of bounds" check to UTM initialization, allowing users to detect over projection.
62-
-Deprecates 'AstrologicalSigns' class and replaces with new 'AlmanacMoonName' class.
63-
-Various documentation fixes.</PackageReleaseNotes>
60+
<PackageReleaseNotes>-Adds accessible Magnitude and Coverage property values to the SolarEclipseDetails class.
61+
-Adds accessible Penumbral and Umbral Magnitude property values to the LunarEclipseDetails class.
62+
-Add NET 8.0 support.
63+
-Adds correctly named 'PartialEclipseEnd' property to 'SolarEclipseDetails' and deprecates incorrectly named property.</PackageReleaseNotes>
6464
<PackageTags>Conversion; Latitude; Longitude; Coordinates; Geography; Sun; Moon; Solar; Lunar; Time; MGRS; UTM; EPSG:3857; ECEF; GEOREF; Web Mercator;</PackageTags>
6565
<!-- <PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>-->
6666
<PackageLicenseFile>License.txt</PackageLicenseFile> <PackageIconUrl></PackageIconUrl>
6767
<PackageId>CoordinateSharp</PackageId>
6868
<Title>CoordinateSharp</Title>
69-
<AssemblyVersion>2.20.1.1</AssemblyVersion>
69+
<AssemblyVersion>2.21.1.1</AssemblyVersion>
7070
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
7171
<SignAssembly>true</SignAssembly>
7272
<PackageIcon>128x128.png</PackageIcon>
7373
<AssemblyOriginatorKeyFile>CoordinateSharp Strong Name.snk</AssemblyOriginatorKeyFile>
7474
<DelaySign>false</DelaySign>
75-
<FileVersion>2.20.1.1</FileVersion>
75+
<FileVersion>2.21.1.1</FileVersion>
7676
<RepositoryUrl>https://github.com/Tronald/CoordinateSharp</RepositoryUrl>
7777
<PackageReadmeFile>README.md</PackageReadmeFile>
7878
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

CoordinateSharp/GlobalSuppressions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("Naming", "VSSpell001:Spell Check", Justification = "<Pending>", Scope = "member", Target = "~P:CoordinateSharp.EagerLoad_Extensions.MGRS")]
9+
[assembly: SuppressMessage("Naming", "VSSpell001:Spell Check", Justification = "<Pending>", Scope = "member", Target = "~P:CoordinateSharp.EagerLoad.GEOREF")]
10+
[assembly: SuppressMessage("Naming", "VSSpell001:Spell Check", Justification = "<Pending>", Scope = "member", Target = "~P:CoordinateSharp.Celestial.MoonIllum")]
11+
[assembly: SuppressMessage("Naming", "VSSpell001:Spell Check", Justification = "<Pending>", Scope = "member", Target = "~P:CoordinateSharp.LunarEclipseDetails.PartialEclispeBegin")]

CoordinateSharp_UnitTests/Celestial.Lunar.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Runtime.Serialization;
1010
using System.Runtime.Serialization.Formatters.Binary;
1111
using Microsoft.VisualStudio.TestTools.UnitTesting;
12+
using Newtonsoft.Json;
1213

1314
namespace CoordinateSharp_UnitTests
1415
{
@@ -111,30 +112,30 @@ public void MoonPhaseEnum()
111112
}
112113
[TestMethod]
113114
public void LunarEclipse()
114-
{
115+
{
115116
//Deserialize
116-
using (StreamReader streamReader = new StreamReader("CelestialData\\LunarEclipse.txt"))
117-
{
118-
BinaryFormatter binaryFormatter = new BinaryFormatter();
119-
LunarEclipse ev = (LunarEclipse)binaryFormatter.Deserialize(streamReader.BaseStream);
117+
string json = File.ReadAllText("CelestialData\\Coordinate.txt");
120118

121-
LunarEclipseDetails lE1 = ev.LastEclipse;
122-
LunarEclipseDetails nE1 = ev.NextEclipse;
123-
LunarEclipseDetails lE2 = data.LunarEclispe.LastEclipse;
124-
LunarEclipseDetails nE2 = data.LunarEclispe.NextEclipse;
119+
Coordinate c = JsonConvert.DeserializeObject<Coordinate>(json);
120+
LunarEclipse ev = c.CelestialInfo.LunarEclipse;
125121

126-
PropertyInfo[] properties = typeof(LunarEclipseDetails).GetProperties();
127-
foreach (PropertyInfo property in properties)
128-
{
129-
var l1 = property.GetValue(lE1);
130-
var l2 = property.GetValue(lE2);
131-
var n1 = property.GetValue(nE1);
132-
var n2 = property.GetValue(nE2);
122+
LunarEclipseDetails lE1 = ev.LastEclipse;
123+
LunarEclipseDetails nE1 = ev.NextEclipse;
124+
LunarEclipseDetails lE2 = data.LunarEclispe.LastEclipse;
125+
LunarEclipseDetails nE2 = data.LunarEclispe.NextEclipse;
133126

134-
Assert.AreEqual(l1.ToString(), l2.ToString(), "Last Eclipse data does not match.");
135-
Assert.AreEqual(n1.ToString(), n2.ToString(), "Next Eclipse data does not match.");
136-
}
127+
PropertyInfo[] properties = typeof(LunarEclipseDetails).GetProperties();
128+
foreach (PropertyInfo property in properties)
129+
{
130+
var l1 = property.GetValue(lE1);
131+
var l2 = property.GetValue(lE2);
132+
var n1 = property.GetValue(nE1);
133+
var n2 = property.GetValue(nE2);
134+
135+
Assert.AreEqual(l1.ToString(), l2.ToString(), "Last Eclipse data does not match.");
136+
Assert.AreEqual(n1.ToString(), n2.ToString(), "Next Eclipse data does not match.");
137137
}
138+
138139
}
139140

140141
[TestMethod]

0 commit comments

Comments
 (0)