Exemplo n.º 1
0
 /// <summary>
 /// Load Cartesian information (required if eager loading is turned off).
 /// </summary>
 /// <example>
 /// The following example shows how to Load Cartesian information when eager loading is turned off.
 /// <code>
 /// EagerLoad eagerLoad = new EagerLoad();
 /// eagerLoad.Cartesian = false;
 /// Coordinate c = new Coordinate(40.0352, -74.5844, DateTime.Now, eagerLoad);
 ///
 /// //To load Cartesian information when ready
 /// c.LoadCartesianInfo;
 /// </code>
 /// </example>
 public void LoadCartesianInfo()
 {
     cartesian = new Cartesian(this);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Notify property changed
        /// </summary>
        /// <param name="propName">Property Name</param>
        public void NotifyPropertyChanged(string propName)
        {
            switch (propName)
            {
            case "CelestialInfo":
                if (!EagerLoadSettings.Celestial)
                {
                    return;
                }                                                 //Prevent calls while eagerloading is off
                if (EagerLoadSettings.Celestial && celestialInfo == null)
                {
                    celestialInfo = new Celestial(false);
                }                                                                                                      //Create object if EagerLoading is on and object is null (EagerLoading turned on later).
                celestialInfo.CalculateCelestialTime(latitude.DecimalDegree, longitude.DecimalDegree, geoDate, EagerLoadSettings, offset);
                break;

            case "UTM":
                if (!EagerLoadSettings.UTM_MGRS)
                {
                    return;
                }
                else if (EagerLoadSettings.UTM_MGRS && utm == null)
                {
                    utm = new UniversalTransverseMercator(latitude.ToDouble(), longitude.ToDouble(), this, equatorial_radius, inverse_flattening);
                }
                else
                {
                    utm.ToUTM(latitude.ToDouble(), longitude.ToDouble(), utm, utm_mgrs_LongitudeZone_Override);
                }
                break;

            case "utm":
                //Adjust case and notify of change.
                //Use to notify without calling ToUTM()
                propName = "UTM";
                break;

            case "MGRS":
                if (!EagerLoadSettings.UTM_MGRS || !EagerLoadSettings.Extensions.MGRS || utm == null)
                {
                    return;
                }
                else if (EagerLoadSettings.UTM_MGRS && EagerLoadSettings.Extensions.MGRS && mgrs == null)
                {
                    mgrs = new MilitaryGridReferenceSystem(utm);
                }
                else
                {
                    MGRS.ToMGRS(utm);
                }
                break;

            case "Cartesian":
                if (!EagerLoadSettings.Cartesian)
                {
                    return;
                }
                else if (EagerLoadSettings.Cartesian && cartesian == null)
                {
                    cartesian = new Cartesian(this);
                }
                else
                {
                    Cartesian.ToCartesian(this);
                }
                break;

            case "ECEF":
                if (!EagerLoadSettings.ECEF)
                {
                    return;
                }
                else if (EagerLoadSettings.ECEF && ecef == null)
                {
                    ecef = new ECEF(this);
                }
                else
                {
                    ECEF.ToECEF(this);
                }
                break;

            default:
                break;
            }

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Coordinate build logic goes here.
        /// </summary>
        /// <param name="lat">Signed latitude</param>
        /// <param name="longi">Signed longitude</param>
        /// <param name="date">Date at location</param>
        /// <param name="eagerLoad">Eagerloading settings</param>
        private void Coordinate_Builder(double lat, double longi, DateTime date, EagerLoad eagerLoad)
        {
            //SET EagerLoading Setting
            EagerLoadSettings = eagerLoad;

            //Use default constructor if signed degree is 0 for performance.
            if (lat == 0)
            {
                latitude = new CoordinatePart(CoordinateType.Lat);
            }
            else
            {
                latitude = new CoordinatePart(lat, CoordinateType.Lat);
            }

            if (longi == 0)
            {
                longitude = new CoordinatePart(CoordinateType.Long);
            }
            else
            {
                longitude = new CoordinatePart(longi, CoordinateType.Long);
            }

            //Set CoordinatePart parents
            latitude.parent  = this;
            longitude.parent = this;

            //Set UTC date at location
            geoDate = date;


            //LOAD NEW COORDINATE SYSTEMS HERE

            //Load Celestial
            if (eagerLoad.Celestial)
            {
                celestialInfo = new Celestial(lat, longi, date, 0, eagerLoad);
            }
            //Load UTM MGRS
            if (eagerLoad.UTM_MGRS)
            {
                utm = new UniversalTransverseMercator(lat, longi, this);
                if (eagerLoad.Extensions.MGRS)
                {
                    mgrs = new MilitaryGridReferenceSystem(utm);
                }
            }
            //Load CARTESIAN
            if (eagerLoad.Cartesian)
            {
                cartesian = new Cartesian(this);
            }
            //Load ECEF
            if (eagerLoad.ECEF)
            {
                ecef = new ECEF(this);
            }



            //Set Ellipsoid
            equatorial_radius  = 6378137.0;
            inverse_flattening = 298.257223563;
        }