Exemple #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);
 }
Exemple #2
0
 // Default constructor
 public LatLongClass()
 {
     DegMinSec.Latitude.Deg     = 0;
     DegMinSec.Latitude.Min     = 0;
     DegMinSec.Latitude.Sec     = 0.0;
     DegMinSec.Latitude.Prefix  = LatLongPrefix.Not_Valid;
     DegMinSec.Longitude.Deg    = 0;
     DegMinSec.Longitude.Min    = 0;
     DegMinSec.Longitude.Sec    = 0;
     DegMinSec.Longitude.Prefix = LatLongPrefix.Not_Valid;
     Decimal = ConvertDegMinSecToDecimal(DegMinSec);
 }
Exemple #3
0
 ////////////////////////////////////////////////////////////////////////////
 // Constructor which allows intialization using
 // Deg Min Sec format
 public LatLongClass(int LatDeg, int LatMin, double LatSec, LatLongPrefix LatPrefix,
                     int LonDeg, int LonMin, double LonSec, LatLongPrefix LonPrefix)
 {
     DegMinSec.Latitude.Deg     = LatDeg;
     DegMinSec.Latitude.Min     = LatMin;
     DegMinSec.Latitude.Sec     = LatSec;
     DegMinSec.Latitude.Prefix  = LatPrefix;
     DegMinSec.Longitude.Deg    = LonDeg;
     DegMinSec.Longitude.Min    = LonMin;
     DegMinSec.Longitude.Sec    = LonSec;
     DegMinSec.Longitude.Prefix = LonPrefix;
     Decimal = ConvertDegMinSecToDecimal(DegMinSec);
 }
Exemple #4
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 intialization using
 // Deg Min Sec format
 public LatLongClass(int LatDeg, int LatMin, double LatSec, LatLongPrefix LatPrefix,
     int LonDeg, int LonMin, double LonSec, LatLongPrefix LonPrefix)
 {
     DegMinSec.Latitude.Deg = LatDeg;
     DegMinSec.Latitude.Min = LatMin;
     DegMinSec.Latitude.Sec = LatSec;
     DegMinSec.Latitude.Prefix = LatPrefix;
     DegMinSec.Longitude.Deg = LonDeg;
     DegMinSec.Longitude.Min = LonMin;
     DegMinSec.Longitude.Sec = LonSec;
     DegMinSec.Longitude.Prefix = LonPrefix;
     Decimal = ConvertDegMinSecToDecimal(DegMinSec);
 }
 // Default constructor
 public LatLongClass()
 {
     DegMinSec.Latitude.Deg = 0;
     DegMinSec.Latitude.Min = 0;
     DegMinSec.Latitude.Sec = 0.0;
     DegMinSec.Latitude.Prefix = LatLongPrefix.Not_Valid;
     DegMinSec.Longitude.Deg = 0;
     DegMinSec.Longitude.Min = 0;
     DegMinSec.Longitude.Sec = 0;
     DegMinSec.Longitude.Prefix = LatLongPrefix.Not_Valid;
     Decimal = ConvertDegMinSecToDecimal(DegMinSec);
 }
        ///////////////////////////////////////////////////////////////////////////////////////
        // 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;
        }
Exemple #12
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);
        }
Exemple #13
0
 public void SetPosition(LatLongDecimal LatLongDec)
 {
     Decimal.LatitudeDecimal  = LatLongDec.LatitudeDecimal;
     Decimal.LongitudeDecimal = LatLongDec.LongitudeDecimal;
     DegMinSec = ConvertDecimalToDegMinSec(Decimal);
 }
Exemple #14
0
 public LatLongClass(LatLongDecimal LatLongDec)
 {
     Decimal.LatitudeDecimal  = LatLongDec.LatitudeDecimal;
     Decimal.LongitudeDecimal = LatLongDec.LongitudeDecimal;
     DegMinSec = ConvertDecimalToDegMinSec(Decimal);
 }