Struct GpsPosition
Represents a signed geographic coordinate in degrees, minutes, seconds, and ten-thousandths of a second.
public readonly struct GpsPosition : IEquatable<GpsPosition>
- Implements
- Inherited Members
Constructors
GpsPosition(int, int, int, int, bool)
Represents a signed geographic coordinate in degrees, minutes, seconds, and ten-thousandths of a second.
public GpsPosition(int _degrees, int _minutes, int _seconds, int _subSeconds, bool _negative)
Parameters
_degreesintThe absolute whole degrees.
_minutesintThe whole minutes.
_secondsintThe whole seconds.
_subSecondsintThe ten-thousandths of a second.
_negativeboolWhether the coordinate is negative.
Properties
Degrees
Gets the absolute whole degrees.
public int Degrees { get; }
Property Value
Minutes
Gets the whole minutes.
public int Minutes { get; }
Property Value
Negative
Gets whether the coordinate is negative.
public bool Negative { get; }
Property Value
Seconds
Gets the whole seconds.
public int Seconds { get; }
Property Value
SubSeconds
Gets the ten-thousandths of a second.
public int SubSeconds { get; }
Property Value
Methods
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.
Equals(GpsPosition)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(GpsPosition other)
Parameters
otherGpsPositionAn object to compare with this object.
Returns
FromDoublePosition(double)
Creates a coordinate from signed decimal degrees.
public static GpsPosition FromDoublePosition(double coordinate)
Parameters
coordinatedoubleThe coordinate in decimal degrees.
Returns
- GpsPosition
The converted coordinate.
FromJsonString(string)
Deserializes a coordinate from JSON.
public static GpsPosition? FromJsonString(string jsonString)
Parameters
jsonStringstringThe JSON object to deserialize.
Returns
- GpsPosition?
The coordinate, or null for null or empty input.
FromString(string)
Parses the period-delimited representation returned by ToString().
public static GpsPosition? FromString(string val)
Parameters
valstringThe coordinate text.
Returns
- GpsPosition?
The parsed coordinate, or null when the format is not recognized.
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.
ToDouble()
Converts the coordinate to signed decimal degrees.
public double ToDouble()
Returns
- double
The coordinate in decimal degrees.
ToString()
Formats the coordinate as degrees, minutes, seconds, and subseconds separated by periods.
public override string ToString()
Returns
- string
The formatted coordinate.
Operators
operator +(GpsPosition, GpsPosition)
Adds two coordinates in decimal-degree space.
public static GpsPosition operator +(GpsPosition pos1, GpsPosition pos2)
Parameters
pos1GpsPositionpos2GpsPosition
Returns
operator ==(GpsPosition, GpsPosition)
Determines whether two coordinates are equal.
public static bool operator ==(GpsPosition lhs, GpsPosition rhs)
Parameters
lhsGpsPositionrhsGpsPosition
Returns
operator !=(GpsPosition, GpsPosition)
Determines whether two coordinates are not equal.
public static bool operator !=(GpsPosition lhs, GpsPosition rhs)
Parameters
lhsGpsPositionrhsGpsPosition
Returns
operator -(GpsPosition, GpsPosition)
Subtracts the second coordinate from the first in decimal-degree space.
public static GpsPosition operator -(GpsPosition pos1, GpsPosition pos2)
Parameters
pos1GpsPositionpos2GpsPosition