-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor geometric and geodetic interfaces
- Loading branch information
Showing
30 changed files
with
462 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
namespace NetFabric.Numerics.Geography; | ||
using System.Numerics; | ||
|
||
public readonly record struct Datum<TDatum> | ||
where TDatum : IDatum<TDatum>? | ||
namespace NetFabric.Numerics.Geography; | ||
|
||
public abstract class Datum<T> | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
{ | ||
public abstract string Name { get; } | ||
|
||
public abstract Offset<T> Offset { get; } | ||
public abstract Ellipsoid<T> Ellipsoid { get; } | ||
} | ||
|
||
public sealed class Datum<TDatum, T> | ||
: Datum<T> | ||
where TDatum : IDatum<T> | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
{ | ||
public string Name | ||
static Lazy<Datum<TDatum, T>> lazyInstance = new(() => new()); | ||
|
||
private Datum() {} | ||
|
||
internal static Datum<TDatum, T> Instance | ||
=> lazyInstance.Value; | ||
|
||
public override string Name | ||
=> TDatum.Name; | ||
public Offset<double> Offset | ||
public override Offset<T> Offset | ||
=> TDatum.Offset; | ||
public Ellipsoid<double> Ellipsoid | ||
public override Ellipsoid<T> Ellipsoid | ||
=> TDatum.Ellipsoid; | ||
} |
18 changes: 7 additions & 11 deletions
18
src/NetFabric.Numerics.Geography/Geodetic2/CoordinateSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
using System.Collections.ObjectModel; | ||
using System.Numerics; | ||
|
||
namespace NetFabric.Numerics.Geography.Geodetic2; | ||
|
||
public readonly record struct CoordinateSystem<TDatum, TAngle> | ||
: IGeodeticCoordinateSystem<TDatum> | ||
where TDatum : IDatum<TDatum> | ||
where TAngle : struct, IFloatingPoint<TAngle>, IMinMaxValue<TAngle> | ||
public readonly record struct CoordinateSystem<TDatum, T> | ||
: IGeodeticCoordinateSystem<CoordinateSystem<TDatum, T>, TDatum, T> | ||
where TDatum : IDatum<T> | ||
where T : struct, IFloatingPoint<T>, IMinMaxValue<T> | ||
{ | ||
public Datum<TDatum> Datum | ||
=> new(); | ||
|
||
static readonly IReadOnlyList<Coordinate> coordinates | ||
= new[] { | ||
new Coordinate("Latitude", typeof(Angle<Degrees, TAngle>)), | ||
new Coordinate("Longitude", typeof(Angle<Degrees, TAngle>)), | ||
new Coordinate("Latitude", typeof(Angle<Degrees, T>)), | ||
new Coordinate("Longitude", typeof(Angle<Degrees, T>)), | ||
}; | ||
|
||
public IReadOnlyList<Coordinate> Coordinates | ||
public static IReadOnlyList<Coordinate> Coordinates | ||
=> coordinates; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.