/// <summary>
        /// Initializes a new instance of the <see cref="DmsPoint"/> class by taking location decimal value.
        /// </summary>
        /// <param name="locationDecimalValue">The location decimal value to be converted to DMS structure.</param>
        /// <param name="type">A value to indicate if the location point value is a latitude or longitude value.</param>
        public DmsPoint(double locationDecimalValue, LocationPointValueType type)
        {
            if (type == LocationPointValueType.Unknown)
            {
                throw new ArgumentException("Unknown type is not supported.");
            }

            this.Degree = this.ExtractDegrees(locationDecimalValue);
            this.Minute = this.ExtractMinutes(locationDecimalValue);
            this.Second = this.ExtractSeconds(locationDecimalValue);

            if (type == LocationPointValueType.Latitude)
            {
                if (locationDecimalValue < 0)
                {
                    this.Direction = Direction.South;
                }
                else
                {
                    this.Direction = Direction.North;
                }
            }
            else if (type == LocationPointValueType.Longitude)
            {
                if (locationDecimalValue < 0)
                {
                    this.Direction = Direction.West;
                }
                else
                {
                    this.Direction = Direction.East;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Gets latitude or longitude decimal and degree display values.
 /// </summary>
 /// <param name="value">The latitude or longitude value in decimal.</param>
 /// <param name="type">The type of the decimal value.</param>
 /// <returns>A string representing the latitude's decimal and degree values combined.</returns>
 private static string GetLatitudeLongitudeDisplayValue(double?value, LocationPointValueType type)
 {
     if (value.HasValue && !double.IsNaN(value.Value))
     {
         string display = value.Value.ToString();
         var    dms     = new DmsPoint(value.Value, type);
         return($"{value} / {dms.Degree}°{dms.Minute}'{dms.Second}'' {dms.Direction}");
     }
     else
     {
         return(UnknownValue);
     }
 }