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
| Name | Description |
|---|---|
| GeoPosition(double, double, double?) | A position on the Earth, in degrees, with an optional altitude, measure and time. |
GeoPosition(double, double, double?)
GeoPosition.csA position on the Earth, in degrees, with an optional altitude, measure and time.
Parameters
Longitudedouble- The longitude, from -180 (west) to 180 (east).
Latitudedouble- The latitude, from -90 (south) to 90 (north).
Altitudedouble?- The altitude, in meters, or
nullwhen 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
| Name | Description |
|---|---|
| Altitude | Gets the altitude, in meters, or null when the position has none. |
| Latitude | The latitude, from -90 (south) to 90 (north). |
| Longitude | The longitude, from -180 (west) to 180 (east). |
| Measure | 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. |
| Time | 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. |
Altitude
GeoPosition.csLatitude
GeoPosition.csLongitude
GeoPosition.csMeasure
GeoPosition.csTime
GeoPosition.csGets 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
Methods
| Name | Description |
|---|---|
| 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?)
Equals overloads
Equals(GeoPosition)
GeoPosition.csGets a value that indicates whether this position is equal to another one.
public bool Equals(GeoPosition other)Parameters
otherGeoPosition- 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)
GetDistance(GeoPosition)
GeoPosition.csGets 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
otherGeoPosition- 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.csToString()
Operators
| Name | Description |
|---|---|
| operator ==(GeoPosition, GeoPosition) | |
| operator !=(GeoPosition, GeoPosition) |
operator ==(GeoPosition, GeoPosition)
public static bool operator ==(GeoPosition left, GeoPosition right)No documentation is available.
operator !=(GeoPosition, GeoPosition)
public static bool operator !=(GeoPosition left, GeoPosition right)No documentation is available.
Constants
| Name | Description |
|---|---|
| EarthRadius | The 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