Exemplo n.º 1
0
        public static GeoAngle 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 GeoAngle();

            //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 static string getLongitude(PointLatLng p)
        {
            GeoAngle ga = GeoAngle.FromDouble(p.Lng);

            return(string.Format(
                       "{0}° {1:00}' {2:00}\".{3:000} {4}",
                       ga.Degrees,
                       ga.Minutes,
                       ga.Seconds,
                       ga.Milliseconds,
                       ga.IsNegative ? 'W' : 'E'));
        }
Exemplo n.º 3
0
 public static double ToDouble(GeoAngle angleInDegrees)
 {
     return(angleInDegrees.Degrees + (angleInDegrees.Minutes / 60) + (angleInDegrees.Seconds / 3600));
 }