Table of Contents

Struct Distance

Represents a distance in meters, miles, or kilometers.

public readonly struct Distance
Inherited Members

Constructors

Distance(double)

Initializes a new instance of the Distance struct with a value in meters.

public Distance(double meters)

Parameters

meters double

The distance in meters.

Properties

Kilometers

Gets the distance in kilometers.

public double Kilometers { get; }

Property Value

double

Meters

Gets the distance in meters.

public double Meters { get; }

Property Value

double

Miles

Gets the distance in miles.

public double Miles { get; }

Property Value

double

Methods

BetweenPositions(MapCoordinate, MapCoordinate)

Calculates the great-circle distance between two coordinates using the Haversine formula.

public static Distance BetweenPositions(MapCoordinate position1, MapCoordinate position2)

Parameters

position1 MapCoordinate

The first coordinate.

position2 MapCoordinate

The second coordinate.

Returns

Distance

The distance between the two coordinates.

Equals(Distance)

Determines whether this instance is equal to another Distance.

public bool Equals(Distance other)

Parameters

other Distance

Returns

bool

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromKilometers(double)

Creates a new Distance from a value in kilometers.

public static Distance FromKilometers(double kilometers)

Parameters

kilometers double

Returns

Distance

FromMeters(double)

Creates a new Distance from a value in meters.

public static Distance FromMeters(double meters)

Parameters

meters double

Returns

Distance

FromMiles(double)

Creates a new Distance from a value in miles.

public static Distance FromMiles(double miles)

Parameters

miles double

Returns

Distance

GetHashCode()

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.

Operators

operator ==(Distance, Distance)

Determines whether two Distance instances are equal.

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

Parameters

left Distance
right Distance

Returns

bool

operator !=(Distance, Distance)

Determines whether two Distance instances are not equal.

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

Parameters

left Distance
right Distance

Returns

bool