示例#1
0
        /// <summary>
        /// Load Magnetic Values.
        /// </summary>
        /// <param name="lat">Signed Latitude (Geodetic)</param>
        /// <param name="lng">Signed Longitude (Geodetic)</param>
        /// <param name="height">Height in Meters</param>
        /// <param name="semiMajorAxis">Semi-Major Axis</param>
        /// <param name="inverseFlattening">Inverse Flattening</param>
        /// <param name="date">Date Time</param>
        private void Load(double lat, double lng, double height, double semiMajorAxis, double inverseFlattening, DateTime date)
        {
            if (lat > 90 || lat < -90)
            {
                throw new ArgumentOutOfRangeException("Latitude exceeds maximum of 90 degrees.");
            }
            if (lng > 180 || lng < -180)
            {
                throw new ArgumentOutOfRangeException("Longitude exceeds maximum of 180 degrees.");
            }
            latSigned              = lat;
            lngSigned              = lng;
            this.semiMajorAxis     = semiMajorAxis;
            this.inverseFlattening = inverseFlattening;
            flattening             = 1 / inverseFlattening;            //Flattening
            eccentricitySquared    = flattening * (2 - flattening);    //Eccentricity  Squared
            semiMinorAxis          = semiMajorAxis * (1 - flattening); //Semi-minor axis

            nLatGD = lat.NormalizeDegrees360();
            nLngGD = lng.NormalizeDegrees360();

            radiusOfCurvature = semiMajorAxis / Math.Sqrt(1 - (eccentricitySquared * Math.Pow(Math.Sin(nLatGD.ToRadians()), 2)));
            northPolarAxis    = (radiusOfCurvature * (1 - eccentricitySquared) + height) * Math.Sin(nLatGD.ToRadians());
            double latRad = nLatGD.ToRadians();

            pointOfInterest = (radiusOfCurvature + height) * Math.Cos(latRad);
            radius          = Math.Sqrt(Math.Pow(pointOfInterest, 2) + Math.Pow(northPolarAxis, 2));

            nLatGC = Math.Asin(northPolarAxis / radius);
            nLngGC = nLngGD.ToRadians();

            TimeSpan ts = date - new DateTime(date.Year, 1, 1);
            int      ly = 365;

            if (DateTime.IsLeapYear(date.Year))
            {
                ly = 366;
            }
            decimalDate = date.Year + (ts.TotalDays / ly);


            points = new DataPoints(Model, this);
            points.Load_Values(); //Load Calculated Values

            magneticFieldElements = new MagneticFieldElements(this);
            secularVariations     = new SecularVariations(this);
            uncertainty           = new Uncertainty(this);
        }
        /// <summary>
        /// Load Magnetic Values
        /// </summary>
        /// <param name="lat">Signed Latitude (Geodetic)</param>
        /// <param name="lng">Signed Longitude (Geodetic)</param>
        /// <param name="height">Height in Meters</param>
        /// <param name="semiMajorAxis">Semi-Major Axis</param>
        /// <param name="inverseFlattening">Inverse Flattening</param>
        /// <param name="date">Date Time</param>
        /// <param name="model">Data Model</param>
        private void Load(double lat, double lng, double height, double semiMajorAxis, double inverseFlattening, DateTime date, DataModel model)
        {
            this.semiMajorAxis     = semiMajorAxis;
            this.inverseFlattening = inverseFlattening;
            flattening             = 1 / inverseFlattening;            //Flattening
            eccentricitySquared    = flattening * (2 - flattening);    //Eccentricity  Squared
            semiMinorAxis          = semiMajorAxis * (1 - flattening); //Semi-minor axis

            nLatGD = lat.NormalizeDegrees360();
            nLngGD = lng.NormalizeDegrees360();

            radiusOfCurvature = semiMajorAxis / Math.Sqrt(1 - (eccentricitySquared * Math.Pow(Math.Sin(nLatGD.ToRadians()), 2)));
            northPolarAxis    = (radiusOfCurvature * (1 - eccentricitySquared) + height) * Math.Sin(nLatGD.ToRadians());
            pointOfInterest   = (radiusOfCurvature - height) * Math.Cos(nLatGD.ToRadians());
            radius            = Math.Sqrt(Math.Pow(pointOfInterest, 2) + Math.Pow(northPolarAxis, 2));

            nLatGC = Math.Asin(northPolarAxis / radius);
            nLngGC = nLngGD.ToRadians();

            TimeSpan ts = date - new DateTime(date.Year, 1, 1);
            int      ly = 365;

            if (DateTime.IsLeapYear(date.Year))
            {
                ly = 366;
            }
            decimalDate = date.Year + (ts.TotalDays / ly);


            points = new DataPoints(model, this);
            points.Load_Values(); //Load Calculated Values

            magneticFieldElements = new MagneticFieldElements(this);
            secularVariations     = new SecularVariations(this);
            uncertainty           = new Uncertainty(this);
        }