Example #1
0
        /// <summary>
        /// Creates an EagerLoad object. Only the specified flags will be set to eager load.
        /// </summary>
        /// <param name="et">EagerLoadType</param>
        /// <example>
        /// The following example sets CelestialInfo and Cartesian properties to eager load. Other conversions will be lazy loaded.
        /// <code>
        /// //Create an EagerLoading object with only CelestialInfo and Cartesian properties set to eager load.
        /// EagerLoad el = new EagerLoad(EagerLoadType.Celestial | EagerLoadType.Cartesian);
        ///
        /// //Create coordinate with defined eagerloading settings.
        /// Coordinate coord = new Coordinate(25, 25, new DateTime(2018, 3, 2), el);
        ///
        /// //Display UTC sunset time at the location.
        /// Console.WriteLine(coord.CelestialInfo.SunSet); //3/2/2018 4:23:46 PM
        /// Console.WriteLine(coord.Cartesian); //0.8213938 0.38302222 0.42261826
        ///
        /// //Load UTM_MGRS when ready.
        /// coord.LoadUTM_MGRS_Info();
        /// Console.WriteLine(coord.UTM); //35R 298154mE 2766437mN
        /// </code>
        /// </example>
        public EagerLoad(EagerLoadType et)
        {
            Extensions = new EagerLoad_Extensions();
            Cartesian  = false;
            Celestial  = false;
            UTM_MGRS   = false;
            ECEF       = false;

            if (et.HasFlag(EagerLoadType.Cartesian))
            {
                Cartesian = true;
            }
            if (et.HasFlag(EagerLoadType.Celestial))
            {
                Celestial = true;
            }
            if (et.HasFlag(EagerLoadType.UTM_MGRS))
            {
                UTM_MGRS = true;
            }
            if (et.HasFlag(EagerLoadType.ECEF))
            {
                ECEF = true;
            }
        }
Example #2
0
        /// <summary>
        /// Creates an EagerLoad object. Only the specified flags will be set to eager load.
        /// </summary>
        /// <param name="et">EagerLoadType</param>
        /// <returns>EagerLoad</returns>
        /// <example>
        /// The following example sets CelestialInfo and Cartesian properties to eager load using a static method. Other conversions will be lazy loaded.
        /// <code>
        /// //Create coordinate with defined eagerloading settings.
        /// Coordinate coord = new Coordinate(25, 25, new DateTime(2018, 3, 2), EagerLoad.Create(EagerLoadType.Celestial | EagerLoadType.Cartesian));
        ///
        /// //Display UTC sunset time at the location.
        /// Console.WriteLine(coord.CelestialInfo.SunSet); //3/2/2018 4:23:46 PM
        /// Console.WriteLine(coord.Cartesian); //0.8213938 0.38302222 0.42261826
        ///
        /// //Load UTM_MGRS when ready.
        /// coord.LoadUTM_MGRS_Info();
        /// Console.WriteLine(coord.UTM); //35R 298154mE 2766437mN
        /// </code>
        /// </example>
        public static EagerLoad Create(EagerLoadType et)
        {
            EagerLoad el = new EagerLoad(et);

            return(el);
        }
Example #3
0
        static void EagerLoading_Tests()
        {
            EagerLoad  e = new EagerLoad(false);
            Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);
            //Check to make sure items don't initialize
            bool pass = true;

            if (c.CelestialInfo != null)
            {
                pass = false;
            }
            if (c.UTM != null)
            {
                pass = false;
            }
            if (c.MGRS != null)
            {
                pass = false;
            }
            if (c.Cartesian != null)
            {
                pass = false;
            }
            Write_Pass("Null Properties (Celestial, UTM, MGRS, Cartesian)", pass);

            //Check Load_Calls
            pass = true;
            c.LoadCelestialInfo();
            if (c.CelestialInfo == null)
            {
                pass = false;
            }
            c.LoadUTM_MGRS_Info();
            if (c.UTM == null)
            {
                pass = false;
            }
            if (c.MGRS == null)
            {
                pass = false;
            }
            c.LoadCartesianInfo();
            if (c.Cartesian == null)
            {
                pass = false;
            }
            Write_Pass("Load Calls (Celestial, UTM, MGRS, Cartesian)", pass);

            if (pass)
            {
                Celestial cel = c.CelestialInfo;
                MilitaryGridReferenceSystem mgrs = c.MGRS;
                UniversalTransverseMercator utm  = c.UTM;
                Cartesian cart = c.Cartesian;

                c.Latitude.DecimalDegree  = -45;
                c.Longitude.DecimalDegree = -75;

                //Properties should not change.
                if (!ReflectiveEquals(c.CelestialInfo, cel))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.MGRS, mgrs))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.UTM, utm))
                {
                    pass = false;
                }
                if (!ReflectiveEquals(c.Cartesian, cart))
                {
                    pass = false;
                }
                //Properties should remain equal as no load calls were made
                Write_Pass("Property State Hold (Celestial, UTM, MGRS, Cartesian)", pass);

                //Properties should change
                pass = true;
                c.LoadCelestialInfo();
                c.LoadCartesianInfo();
                c.LoadUTM_MGRS_Info();
                if (ReflectiveEquals(c.CelestialInfo, cel))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.MGRS, mgrs))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.UTM, utm))
                {
                    pass = false;
                }
                if (ReflectiveEquals(c.Cartesian, cart))
                {
                    pass = false;
                }
                //Properties should not be equal as chages have been made
                Write_Pass("Property State Change (Celestial, UTM, MGRS, Cartesian)", pass);
            }
            else
            {
                //Passes auto fail has properties didn't load when called.

                Write_Pass("Property State Hold (Celestial, UTM, MGRS, Cartesian)", false);
                Write_Pass("Property State Change (Celestial, UTM, MGRS, Cartesian)", false);
            }

            //EagerLoaded Flags Test
            EagerLoadType et = EagerLoadType.Cartesian | EagerLoadType.Celestial | EagerLoadType.Cartesian;
            EagerLoad     eg = new EagerLoad(et);

            pass = true;
            if (eg.Cartesian == false || eg.Celestial == false || eg.UTM_MGRS == false)
            {
                pass = false;
            }
            if (EagerLoad.Create(et).Cartesian == false || EagerLoad.Create(et).Celestial == false || EagerLoad.Create(et).UTM_MGRS == false)
            {
                pass = false;
            }
            Write_Pass("Flags Test", pass);
        }