Exemplo n.º 1
0
        public static SexagesimalAngle FromDouble(double angleInDegrees)
        {
            //ensure the value will fall within the primary range [-180.0..+180.0]
            while (angleInDegrees < -180.0)
            {
                angleInDegrees += 360.0;
            }

            while (angleInDegrees > 180.0)
            {
                angleInDegrees -= 360.0;
            }

            var result = new SexagesimalAngle();

            //switch the value to positive
            result.IsNegative = angleInDegrees < 0;
            angleInDegrees    = Math.Abs(angleInDegrees);

            //gets the degree
            result.Degrees = (int)Math.Floor(angleInDegrees);
            var delta = angleInDegrees - result.Degrees;

            //gets minutes and seconds
            var seconds = (int)Math.Floor(3600.0 * delta);

            result.Seconds = seconds % 60;
            result.Minutes = (int)Math.Floor(seconds / 60.0);
            delta          = delta * 3600.0 - seconds;

            //gets fractions
            result.Milliseconds = (int)(1000.0 * delta);

            return(result);
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            string gps = (Active ? "Active, Speed: " : "Inactive, Speed: ") + SpeedMph.ToString("0.0") + " mph" +
                         ", Lat: " + SexagesimalAngle.ToString(Latitude) + ", Lon: " + SexagesimalAngle.ToString(Longitude);

            return(gps);
        }