Struct Distance
- Namespace
- MapLibreNative.Maui.Geometry
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
metersdoubleThe distance in meters.
Properties
Kilometers
Gets the distance in kilometers.
public double Kilometers { get; }
Property Value
Meters
Gets the distance in meters.
public double Meters { get; }
Property Value
Miles
Gets the distance in miles.
public double Miles { get; }
Property Value
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
position1MapCoordinateThe first coordinate.
position2MapCoordinateThe 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
otherDistance
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
kilometersdouble
Returns
FromMeters(double)
Creates a new Distance from a value in meters.
public static Distance FromMeters(double meters)
Parameters
metersdouble
Returns
FromMiles(double)
Creates a new Distance from a value in miles.
public static Distance FromMiles(double miles)
Parameters
milesdouble
Returns
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
Returns
operator !=(Distance, Distance)
Determines whether two Distance instances are not equal.
public static bool operator !=(Distance left, Distance right)