Struct LinearDistance
Allows the use of different types of linear measurement units
Implements
Inherited Members
Namespace: FpAssistantCore.General
Assembly: FpAssistantCoreScl.dll
Syntax
public struct LinearDistance : IEquatable<LinearDistance>
Remarks
This covers both distances along the surface of the earth as well as altitude or vertical distances
Constructors
View SourceLinearDistance(double, LinearDistanceUnits)
Constructor to initialise with a specific value and unit type
Declaration
[JsonConstructor]
public LinearDistance(double value, LinearDistanceUnits valueUnit)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | |
| LinearDistanceUnits | valueUnit |
Remarks
[JsonConstructor] : Parameter names must match property names so that [JsonConstructor] attribute on this constructor can be called
See Also
View SourceLinearDistance(double, AltitudeUnits)
Constructor to initialise with a specific value and altitude unit type
Declaration
public LinearDistance(double linearDistanceValue, AltitudeUnits altitudeUnit)
Parameters
| Type | Name | Description |
|---|---|---|
| double | linearDistanceValue | Numerical value of the distance |
| AltitudeUnits | altitudeUnit | Unit type of the distance from an AltitudeUnit enum |
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | AltitudeUnits enum value is not currently supported in LinearDistance constructor |
See Also
View SourceLinearDistance(double, CoordinateSystemUnits)
Constructor to initialise with a specific value and coordinate system unit type
Declaration
public LinearDistance(double linearDistanceValue, CoordinateSystemUnits coordinateSystemUnits)
Parameters
| Type | Name | Description |
|---|---|---|
| double | linearDistanceValue | Numerical value of the distance |
| CoordinateSystemUnits | coordinateSystemUnits | Unit type of the distance from an CoordinateSystemUnits enum |
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | CoordinateSystemUnits enum value is not currently supported in LinearDistance constructor |
See Also
View SourceLinearDistance(string)
Constructor to initialise with a specific value and unit type as a string
Declaration
public LinearDistance(string linearDistanceValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | linearDistanceValue | String value of the distance |
Remarks
Postfix text for string can be: km k kilometres kilometre kilometres kilometre
m metres metre meter metre mt
f feet ft
nm n naut nautical
Examples
LinearDistance ld = new LinearDistance("100m");
Exceptions
| Type | Condition |
|---|---|
| FormatException | Invalid argument passed |
Properties
View SourceIsSi
Determine if declaration is an SI or Non-SI unit type
Declaration
[JsonIgnore]
public bool IsSi { get; }
Property Value
| Type | Description |
|---|---|
| bool | True is a SI unit, otherwise False |
Remarks
SI Units: Kilometres and Metres
Non-SI Units: Nautical Miles and Feet
Examples
LinearDistance ld1KM = new LinearDistance(1.00, LinearDistanceUnits.KM);
if ( ld1KM.IsSi == true ) { }
View Source
Value
Contains the numerical value of the distance
Declaration
public double Value { get; set; }
Property Value
| Type | Description |
|---|---|
| double | Numerical value of the distance |
ValueUnit
The type of measurement unit of the distance value
Declaration
public LinearDistanceUnits ValueUnit { get; }
Property Value
| Type | Description |
|---|---|
| LinearDistanceUnits | Enum value of the assigned unit |
Remarks
Changing of the unit is not permitted
Methods
View SourceAdd(LinearDistance, LinearDistance)
ADD of two LinearDistance objects
Declaration
public static LinearDistance Add(LinearDistance left, LinearDistance right)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | left | |
| LinearDistance | right |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of addition |
AsAltitude()
Converts the current object to Altitude object
Declaration
public Altitude AsAltitude()
Returns
| Type | Description |
|---|---|
| Altitude | Altitude object |
Remarks
Will convert KM to Metres and NM to Feet as these units are not allowed in Altitude object
ConvertTo(LinearDistanceUnits)
Converts the current object to another type of unit
Declaration
public LinearDistance ConvertTo(LinearDistanceUnits linearDistanceUnit_ConvertTo)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistanceUnits | linearDistanceUnit_ConvertTo | The unit to convert the current distance to |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object with request measurement unit |
ConvertTo(CriteriaUnits)
Converts the current object to another type of unit
Declaration
public LinearDistance ConvertTo(CriteriaUnits criteriaUnit)
Parameters
| Type | Name | Description |
|---|---|---|
| CriteriaUnits | criteriaUnit | Type of unit required |
Returns
| Type | Description |
|---|---|
| LinearDistance | Distance converted to unit |
Remarks
Will convert between feet and metres | NM and KM only based on the SI or Non-SI unit value
See Also
View SourceConvertTo(CoordinateSystemUnits)
Converts the current object to another type of unit
Declaration
public LinearDistance ConvertTo(CoordinateSystemUnits CoordinateSystemUnitConvertTo)
Parameters
| Type | Name | Description |
|---|---|---|
| CoordinateSystemUnits | CoordinateSystemUnitConvertTo |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object with request measurement unit |
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | CoordinateSystemUnits enum value is not currently supported in LinearDistance struct constructor |
See Also
View SourceDivide(LinearDistance, LinearDistance)
Operator division of two LinearDistance objects
Declaration
public static LinearDistance Divide(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand of the addition |
| LinearDistance | linearDistance2 | Second operand of the addition |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of addition |
Equals(LinearDistance)
Declaration
public bool Equals(LinearDistance other)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
View SourceFeetToMetres(double)
Convert Feet to Metres
Declaration
public static double FeetToMetres(double feet)
Parameters
| Type | Name | Description |
|---|---|---|
| double | feet | Feet value |
Returns
| Type | Description |
|---|---|
| double | Metres value |
FeetToNM(double)
Convert Feet to NM
Declaration
public static double FeetToNM(double feet)
Parameters
| Type | Name | Description |
|---|---|---|
| double | feet | Feet value |
Returns
| Type | Description |
|---|---|
| double | NM value |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
View SourceMetresToFeet(double)
Convert Metres to Feet
Declaration
public static double MetresToFeet(double metres)
Parameters
| Type | Name | Description |
|---|---|---|
| double | metres | Metres value |
Returns
| Type | Description |
|---|---|
| double | Feet value |
MetresToNM(double)
Convert Metres to NM
Declaration
public static double MetresToNM(double metres)
Parameters
| Type | Name | Description |
|---|---|---|
| double | metres | Metres value |
Returns
| Type | Description |
|---|---|
| double | NM value |
Multiply(LinearDistance, LinearDistance)
Multiply of two LinearDistance objects
Declaration
public static LinearDistance Multiply(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand of the multiplication |
| LinearDistance | linearDistance2 | Second operand of the multiplication |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of multiplication |
NMToFeet(double)
Convert NM to Feet
Declaration
public static double NMToFeet(double nm)
Parameters
| Type | Name | Description |
|---|---|---|
| double | nm | NM value |
Returns
| Type | Description |
|---|---|
| double | NM value |
NMToMetres(double)
Convert NM to Metres
Declaration
public static double NMToMetres(double nm)
Parameters
| Type | Name | Description |
|---|---|---|
| double | nm | NM value |
Returns
| Type | Description |
|---|---|
| double | NM value |
PrecisionFeet(int)
Set precision for Feet in .ToString()
Declaration
public void PrecisionFeet(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value |
PrecisionKilometres(int)
Set precision for Kilometres used in .ToString()
Declaration
public void PrecisionKilometres(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value |
PrecisionMetres(int)
Set precision for Metres in .ToString()
Declaration
public void PrecisionMetres(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value |
PrecisionNauticalMiles(int)
Set precision for Nautical Miles used in .ToString()
Declaration
public void PrecisionNauticalMiles(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value |
Subtract(LinearDistance, LinearDistance)
Subtract of two LinearDistance objects
Declaration
public static LinearDistance Subtract(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand |
| LinearDistance | linearDistance2 | Second operand |
Returns
| Type | Description |
|---|---|
| LinearDistance | Value of subtraction in units of first operand |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
View SourceToString(LinearDistanceFormat)
Declaration
public string ToString(LinearDistanceFormat linearDistanceFormat)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistanceFormat | linearDistanceFormat |
Returns
| Type | Description |
|---|---|
| string |
ToString(IFormatProvider, LinearDistanceFormat)
Declaration
public string ToString(IFormatProvider provider, LinearDistanceFormat linearDistanceFormat)
Parameters
| Type | Name | Description |
|---|---|---|
| IFormatProvider | provider | |
| LinearDistanceFormat | linearDistanceFormat |
Returns
| Type | Description |
|---|---|
| string |
ZeroMetres()
0 Metres
Declaration
public static LinearDistance ZeroMetres()
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance instance set to 0 Metres |
Operators
View Sourceoperator +(LinearDistance, LinearDistance)
Operator addition of two LinearDistance objects
Declaration
public static LinearDistance operator +(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand of the addition |
| LinearDistance | linearDistance2 | Second operand of the addition |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of addition |
operator +(LinearDistance, double)
Operator addition of a LinearDistance and an double data types
Declaration
public static LinearDistance operator +(LinearDistance linearDistance, double distance)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance | First operand of the addition |
| double | distance | Value of distance, second operand |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of addition |
operator +(LinearDistance, int)
Operator addition of a LinearDistance and an int data types
Declaration
public static LinearDistance operator +(LinearDistance linearDistance, int distance)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance | First operand of the addition |
| int | distance | Value of distance, second operand |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of addition |
operator /(LinearDistance, LinearDistance)
Operator division of two LinearDistance objects
Declaration
public static LinearDistance operator /(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand of the addition |
| LinearDistance | linearDistance2 | Second operand of the addition |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of addition |
operator /(LinearDistance, double)
Operator division of a LinearDistance object and double
Declaration
public static LinearDistance operator /(LinearDistance linearDistance, double distance)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance | |
| double | distance | Second operand of the addition |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of addition |
operator /(LinearDistance, int)
Operator division of a LinearDistance object and int
Declaration
public static LinearDistance operator /(LinearDistance linearDistance, int distance)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance | |
| int | distance | Second operand of the addition |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of addition |
operator ==(LinearDistance, LinearDistance)
Declaration
public static bool operator ==(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | |
| LinearDistance | linearDistance2 |
Returns
| Type | Description |
|---|---|
| bool |
explicit operator LinearDistance(Altitude)
Operator explicit cast from Altitude type
Declaration
public static explicit operator LinearDistance(Altitude altitude)
Parameters
| Type | Name | Description |
|---|---|---|
| Altitude | altitude |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object with same values of altitude object |
Examples
Altitude altitudeFeet = new Altitude(123, AltitudeUnits.Feet);
LinearDistance linearDistanceFeet = (LinearDistance)altitudeFeet;
View Source
operator >(LinearDistance, LinearDistance)
Operator Greater Than of two LinearDistance objects
Declaration
public static bool operator >(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand |
| LinearDistance | linearDistance2 | Second operand |
Returns
| Type | Description |
|---|---|
| bool | True if linearDistance1 greater than linearDistance2 |
operator !=(LinearDistance, LinearDistance)
Declaration
public static bool operator !=(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | |
| LinearDistance | linearDistance2 |
Returns
| Type | Description |
|---|---|
| bool |
operator <(LinearDistance, LinearDistance)
Operator Less Than of two LinearDistance objects
Declaration
public static bool operator <(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand |
| LinearDistance | linearDistance2 | Second operand |
Returns
| Type | Description |
|---|---|
| bool | True if linearDistance1 less than linearDistance2 |
operator *(LinearDistance, LinearDistance)
Operator multiplication of two LinearDistance objects
Declaration
public static LinearDistance operator *(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand of the multiplication |
| LinearDistance | linearDistance2 | Second operand of the multiplication |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of multiplication |
operator *(LinearDistance, double)
Operator multiplication of a LinearDistance object and double
Declaration
public static LinearDistance operator *(LinearDistance linearDistance, double distance)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance | |
| double | distance | Second operand of the multiplication |
Returns
| Type | Description |
|---|---|
| LinearDistance | LinearDistance object of multiplication |
operator -(LinearDistance, LinearDistance)
Operator Subtraction of two LinearDistance objects
Declaration
public static LinearDistance operator -(LinearDistance linearDistance1, LinearDistance linearDistance2)
Parameters
| Type | Name | Description |
|---|---|---|
| LinearDistance | linearDistance1 | First operand |
| LinearDistance | linearDistance2 | Second operand |
Returns
| Type | Description |
|---|---|
| LinearDistance | Value of Subtraction in units of first operand |