GeoPosition Struct

A position on the Earth, in degrees, with an optional altitude, measure and time.

public readonly struct GeoPosition : IEquatable<GeoPosition>

Remarks

Set GeoPosition.Measure and GeoPosition.Time with an object initializer, such as new GeoPosition(2.35, 48.86) { Time = DateTimeOffset.UtcNow }. Two positions are equal when their coordinates, altitudes and measures are equal and their times are the same instant, as for DateTimeOffset.

Implements

Constructors

NameDescription
GeoPosition(double, double, double?)A position on the Earth, in degrees, with an optional altitude, measure and time.

GeoPosition(double, double, double?)

GeoPosition.cs

A position on the Earth, in degrees, with an optional altitude, measure and time.

public GeoPosition(double Longitude, double Latitude, double? Altitude = null)

Parameters

Longitude double
The longitude, from -180 (west) to 180 (east).
Latitude double
The latitude, from -90 (south) to 90 (north).
Altitude double?
The altitude, in meters, or null when the position has none.

Remarks

Set GeoPosition.Measure and GeoPosition.Time with an object initializer, such as new GeoPosition(2.35, 48.86) { Time = DateTimeOffset.UtcNow }. Two positions are equal when their coordinates, altitudes and measures are equal and their times are the same instant, as for DateTimeOffset.

Properties

NameDescription
AltitudeGets the altitude, in meters, or null when the position has none.
LatitudeThe latitude, from -90 (south) to 90 (north).
LongitudeThe longitude, from -180 (west) to 180 (east).
MeasureGets the measure (the M value of WKT, WKB and shapefiles), or null when the position has none. Its meaning depends on the data, such as the distance from the start of a road, in its own unit.
TimeGets the time at which the position was recorded, such as the time of a point of a GPS track, or null when the position has none.

Gets the altitude, in meters, or null when the position has none.

public double? Altitude { get; init; }

Property value

double?

The latitude, from -90 (south) to 90 (north).

public double Latitude { get; init; }

Property value

double

The longitude, from -180 (west) to 180 (east).

public double Longitude { get; init; }

Property value

double

Gets the measure (the M value of WKT, WKB and shapefiles), or null when the position has none. Its meaning depends on the data, such as the distance from the start of a road, in its own unit.

public double? Measure { get; init; }

Property value

double?

Gets the time at which the position was recorded, such as the time of a point of a GPS track, or null when the position has none.

public DateTimeOffset? Time { get; init; }

Property value

DateTimeOffset?

Methods

NameDescription
Deconstruct(double, double, double?)
Equals(GeoPosition)Gets a value that indicates whether this position is equal to another one.
Equals(object)
GetDistance(GeoPosition)Gets the great-circle distance to another position, in meters, on a sphere of radius GeoPosition.EarthRadius. The altitudes are ignored.
GetHashCode()Returns the hash code for this instance.
ToString()

Deconstruct(double, double, double?)

public void Deconstruct(out double Longitude, out double Latitude, out double? Altitude)

Parameters

Longitude double
Latitude double
Altitude double?

No documentation is available.

Equals overloads

Equals(GeoPosition)

GeoPosition.cs

Gets a value that indicates whether this position is equal to another one.

public bool Equals(GeoPosition other)
Parameters
other GeoPosition
The other position.
Returns

bool true when the coordinates, altitudes and measures are equal and the times are the same instant; otherwise, false.

Equals(object)

public override bool Equals(object obj)
Parameters
obj object
Returns

bool

No documentation is available.

GetDistance(GeoPosition)

GeoPosition.cs

Gets the great-circle distance to another position, in meters, on a sphere of radius GeoPosition.EarthRadius. The altitudes are ignored.

public double GetDistance(GeoPosition other)

Parameters

other GeoPosition
The other position.

Returns

double The distance, in meters.

Remarks

The haversine formula: the Earth is not a sphere, so the result can differ from the distance on the ellipsoid by up to 0.5%.

GetHashCode()

GeoPosition.cs

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int A 32-bit signed integer that is the hash code for this instance.

ToString()

public override string ToString()

Returns

string

No documentation is available.

Operators

NameDescription
operator ==(GeoPosition, GeoPosition)
operator !=(GeoPosition, GeoPosition)

operator ==(GeoPosition, GeoPosition)

public static bool operator ==(GeoPosition left, GeoPosition right)

Parameters

left GeoPosition
right GeoPosition

Returns

bool

No documentation is available.

operator !=(GeoPosition, GeoPosition)

public static bool operator !=(GeoPosition left, GeoPosition right)

Parameters

left GeoPosition
right GeoPosition

Returns

bool

No documentation is available.

Constants

NameDescription
EarthRadiusThe mean radius of the Earth, in meters, as defined by the IUGG.

EarthRadius

The mean radius of the Earth, in meters, as defined by the IUGG.

public const double EarthRadius = 6371008.8d