示例#1
0
 public void SetPosition(LatLongDegMinSec LatLong_InDegMinSecPrefix)
 {
     DegMinSec.Latitude.Deg     = LatLong_InDegMinSecPrefix.Latitude.Deg;
     DegMinSec.Latitude.Min     = LatLong_InDegMinSecPrefix.Latitude.Min;
     DegMinSec.Latitude.Sec     = LatLong_InDegMinSecPrefix.Latitude.Sec;
     DegMinSec.Latitude.Prefix  = LatLong_InDegMinSecPrefix.Latitude.Prefix;
     DegMinSec.Longitude.Deg    = LatLong_InDegMinSecPrefix.Longitude.Deg;
     DegMinSec.Longitude.Min    = LatLong_InDegMinSecPrefix.Longitude.Min;
     DegMinSec.Longitude.Sec    = LatLong_InDegMinSecPrefix.Longitude.Sec;
     DegMinSec.Longitude.Prefix = LatLong_InDegMinSecPrefix.Longitude.Prefix;
     Decimal = ConvertDegMinSecToDecimal(DegMinSec);
 }
示例#2
0
        ///////////////////////////////////////////////////////////////////////////////////////
        // Converts Deg Min Sec to Decimal
        //
        private static LatLongDecimal ConvertDegMinSecToDecimal(LatLongDegMinSec InData)
        {
            LatLongDecimal OutData      = new LatLongDecimal();
            const double   OneOverSixty = 1.0 / 60.0;

            OutData.LatitudeDecimal  = InData.Latitude.Deg + (InData.Latitude.Min * OneOverSixty) + (InData.Latitude.Sec * OneOverSixty * OneOverSixty);
            OutData.LongitudeDecimal = InData.Longitude.Deg + (InData.Longitude.Min * OneOverSixty) + (InData.Longitude.Sec * OneOverSixty * OneOverSixty);

            if (InData.Latitude.Prefix == LatLongPrefix.S)
            {
                OutData.LatitudeDecimal = OutData.LatitudeDecimal * -1.0;
            }

            if (InData.Longitude.Prefix == LatLongPrefix.W)
            {
                OutData.LongitudeDecimal = OutData.LongitudeDecimal * -1.0;
            }

            return(OutData);
        }
        ///////////////////////////////////////////////////////////////////////////////////////
        // Converts Decimal to Deg Min Sec format
        //
        public static LatLongDegMinSec ConvertDecimalToDegMinSec(LatLongDecimal InData)
        {
            LatLongDegMinSec OutData = new LatLongDegMinSec();

            /////////////////////////////
            // Define localac temp data
            int Num1;
            int Num2;
            double Num3;
            double Temp;

            ///////////////////////////////////////////////////////////////////////////////////////
            // First convert latitude
            double TempLatitude;
            if (InData.LatitudeDecimal < 0.0)
            {
                OutData.Latitude.Prefix = LatLongPrefix.S;
                TempLatitude = InData.LatitudeDecimal * -1.0;
            }
            else
            {
                OutData.Latitude.Prefix = LatLongPrefix.N;
                TempLatitude = InData.LatitudeDecimal;
            }

            // DEG
            Num1 = (int)Math.Floor(TempLatitude);
            // MIN
            Temp = TempLatitude - Math.Floor(TempLatitude);
            Temp = Temp * 60.0;
            Num2 = (int)Math.Floor(Temp);
            // SEC
            Temp = Temp - (int)Math.Floor(Temp);
            Temp = Temp * 60.0;
            Num3 = Temp;

            OutData.Latitude.Deg = Num1;
            OutData.Latitude.Min = Num2;
            OutData.Latitude.Sec = Num3;

            ///////////////////////////////////////////////////////////////////////////////////////
            // Then convert longitude
            double TempLongitudeDec;
            if (InData.LongitudeDecimal < 0.0)
            {
                OutData.Longitude.Prefix = LatLongPrefix.W;
                TempLongitudeDec = InData.LongitudeDecimal * -1.0;
            }
            else
            {
                OutData.Longitude.Prefix = LatLongPrefix.E;
                TempLongitudeDec = InData.LongitudeDecimal;
            }
            // DEG
            Num1 = (int)Math.Floor(TempLongitudeDec);
            // MIN
            Temp = TempLongitudeDec - Math.Floor(TempLongitudeDec);
            Temp = Temp * 60.0;
            Num2 = (int)Math.Floor(Temp);
            // SEC
            Temp = Temp - (int)Math.Floor(Temp);
            Temp = Temp * 60.0;
            Num3 = (int)Math.Floor(Temp);

            OutData.Longitude.Deg = Num1;
            OutData.Longitude.Min = Num2;
            OutData.Longitude.Sec = Num3;

            return OutData;
        }
 public void SetPosition(LatLongDecimal LatLongDec)
 {
     Decimal.LatitudeDecimal = LatLongDec.LatitudeDecimal;
     Decimal.LongitudeDecimal = LatLongDec.LongitudeDecimal;
     DegMinSec = ConvertDecimalToDegMinSec(Decimal);
 }
 public void SetPosition(LatLongDegMinSec LatLong_InDegMinSecPrefix)
 {
     DegMinSec.Latitude.Deg = LatLong_InDegMinSecPrefix.Latitude.Deg;
     DegMinSec.Latitude.Min = LatLong_InDegMinSecPrefix.Latitude.Min;
     DegMinSec.Latitude.Sec = LatLong_InDegMinSecPrefix.Latitude.Sec;
     DegMinSec.Latitude.Prefix = LatLong_InDegMinSecPrefix.Latitude.Prefix;
     DegMinSec.Longitude.Deg = LatLong_InDegMinSecPrefix.Longitude.Deg;
     DegMinSec.Longitude.Min = LatLong_InDegMinSecPrefix.Longitude.Min;
     DegMinSec.Longitude.Sec = LatLong_InDegMinSecPrefix.Longitude.Sec;
     DegMinSec.Longitude.Prefix = LatLong_InDegMinSecPrefix.Longitude.Prefix;
     Decimal = ConvertDegMinSecToDecimal(DegMinSec);
 }
 public LatLongClass(LatLongDecimal LatLongDec)
 {
     Decimal.LatitudeDecimal = LatLongDec.LatitudeDecimal;
     Decimal.LongitudeDecimal = LatLongDec.LongitudeDecimal;
     DegMinSec = ConvertDecimalToDegMinSec(Decimal);
 }
 ////////////////////////////////////////////////////////////////////////////
 // Constructor which allows initialization
 // using Decimal format
 public LatLongClass(double LatitudeDeg, double LongitudeDeg)
 {
     Decimal.LatitudeDecimal = LatitudeDeg;
     Decimal.LongitudeDecimal = LongitudeDeg;
     DegMinSec = ConvertDecimalToDegMinSec(Decimal);
 }
        ///////////////////////////////////////////////////////////////////////////////////////
        // Converts Deg Min Sec to Decimal
        //
        private static LatLongDecimal ConvertDegMinSecToDecimal(LatLongDegMinSec InData)
        {
            LatLongDecimal OutData = new LatLongDecimal();
            const double OneOverSixty = 1.0 / 60.0;
            OutData.LatitudeDecimal = InData.Latitude.Deg + (InData.Latitude.Min * OneOverSixty) + (InData.Latitude.Sec * OneOverSixty * OneOverSixty);
            OutData.LongitudeDecimal = InData.Longitude.Deg + (InData.Longitude.Min * OneOverSixty) + (InData.Longitude.Sec * OneOverSixty * OneOverSixty);

            if (InData.Latitude.Prefix == LatLongPrefix.S)
                OutData.LatitudeDecimal = OutData.LatitudeDecimal * -1.0;

            if (InData.Longitude.Prefix == LatLongPrefix.W)
                OutData.LongitudeDecimal = OutData.LongitudeDecimal * -1.0;

            return OutData;
        }
示例#9
0
        ///////////////////////////////////////////////////////////////////////////////////////
        // Converts Decimal to Deg Min Sec format
        //
        public static LatLongDegMinSec ConvertDecimalToDegMinSec(LatLongDecimal InData)
        {
            LatLongDegMinSec OutData = new LatLongDegMinSec();

            /////////////////////////////
            // Define localac temp data
            int    Num1;
            int    Num2;
            double Num3;
            double Temp;

            ///////////////////////////////////////////////////////////////////////////////////////
            // First convert latitude
            double TempLatitude;

            if (InData.LatitudeDecimal < 0.0)
            {
                OutData.Latitude.Prefix = LatLongPrefix.S;
                TempLatitude            = InData.LatitudeDecimal * -1.0;
            }
            else
            {
                OutData.Latitude.Prefix = LatLongPrefix.N;
                TempLatitude            = InData.LatitudeDecimal;
            }

            // DEG
            Num1 = (int)Math.Floor(TempLatitude);
            // MIN
            Temp = TempLatitude - Math.Floor(TempLatitude);
            Temp = Temp * 60.0;
            Num2 = (int)Math.Floor(Temp);
            // SEC
            Temp = Temp - (int)Math.Floor(Temp);
            Temp = Temp * 60.0;
            Num3 = Temp;

            OutData.Latitude.Deg = Num1;
            OutData.Latitude.Min = Num2;
            OutData.Latitude.Sec = Num3;

            ///////////////////////////////////////////////////////////////////////////////////////
            // Then convert longitude
            double TempLongitudeDec;

            if (InData.LongitudeDecimal < 0.0)
            {
                OutData.Longitude.Prefix = LatLongPrefix.W;
                TempLongitudeDec         = InData.LongitudeDecimal * -1.0;
            }
            else
            {
                OutData.Longitude.Prefix = LatLongPrefix.E;
                TempLongitudeDec         = InData.LongitudeDecimal;
            }
            // DEG
            Num1 = (int)Math.Floor(TempLongitudeDec);
            // MIN
            Temp = TempLongitudeDec - Math.Floor(TempLongitudeDec);
            Temp = Temp * 60.0;
            Num2 = (int)Math.Floor(Temp);
            // SEC
            Temp = Temp - (int)Math.Floor(Temp);
            Temp = Temp * 60.0;
            Num3 = (int)Math.Floor(Temp);

            OutData.Longitude.Deg = Num1;
            OutData.Longitude.Min = Num2;
            OutData.Longitude.Sec = Num3;

            return(OutData);
        }
示例#10
0
 public void SetPosition(LatLongDecimal LatLongDec)
 {
     Decimal.LatitudeDecimal  = LatLongDec.LatitudeDecimal;
     Decimal.LongitudeDecimal = LatLongDec.LongitudeDecimal;
     DegMinSec = ConvertDecimalToDegMinSec(Decimal);
 }
示例#11
0
 public LatLongClass(LatLongDecimal LatLongDec)
 {
     Decimal.LatitudeDecimal  = LatLongDec.LatitudeDecimal;
     Decimal.LongitudeDecimal = LatLongDec.LongitudeDecimal;
     DegMinSec = ConvertDecimalToDegMinSec(Decimal);
 }
示例#12
0
 ////////////////////////////////////////////////////////////////////////////
 // Constructor which allows initialization
 // using Decimal format
 public LatLongClass(double LatitudeDeg, double LongitudeDeg)
 {
     Decimal.LatitudeDecimal  = LatitudeDeg;
     Decimal.LongitudeDecimal = LongitudeDeg;
     DegMinSec = ConvertDecimalToDegMinSec(Decimal);
 }