/// <summary>
        /// Creats a <see cref="Coordinate"/> object with a uniformly distributed random latitude and uniformly distributed random longitude with specified eager loading options.
        /// </summary>
        /// <param name="eagerLoad"></param>
        /// <returns></returns>
        private static Coordinate GetRandomCoordinate(EagerLoad eagerLoad)
        {
            double latitude  = GetRandomDoubleBetween(-90.0, 90.0);
            double longitude = GetRandomDoubleBetween(-180.0, 180.0);

            return(new Coordinate(latitude, longitude, eagerLoad));
        }
Esempio n. 2
0
        static void Benchmark_Tests()
        {
            Coordinate tc = null;

            Console.WriteLine("Starting Benchmarks, this test may take a while to finish...");
            Console.WriteLine();
            //Benchmark Standard Object Initialization
            Benchmark(() => { tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0)); }, 100, "Standard Initialization");

            Benchmark(() => {
                tc           = new Coordinate();
                tc.Latitude  = new CoordinatePart(39, 45, 34, CoordinatesPosition.N, tc);
                tc.Longitude = new CoordinatePart(74, 34, 45, CoordinatesPosition.W, tc);
                tc.GeoDate   = new DateTime(2018, 7, 26, 15, 49, 0);
            }, 100, "Secondary Initialization");

            //Benchmark TryParse Object Initialization
            Benchmark(() => { Coordinate.TryParse("39.891219, -74.872435", new DateTime(2010, 7, 26, 15, 49, 0), out tc); }, 100, "TryParse() Initialization");

            //Benchmark with EagerLoad fully off
            Benchmark(() => {
                EagerLoad eg = new EagerLoad();
                eg.UTM_MGRS  = false;
                eg.Celestial = false;
                eg.Cartesian = false;
                tc           = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0), eg);
            }, 100, "EagerLoad Off Initialization");
            tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0));

            //Benchmack property change
            Random r = new Random();

            Benchmark(() => { tc.Latitude.DecimalDegree = r.Next(-90, 90); }, 100, "Property Change");
        }
Esempio n. 3
0
        public void Setup()
        {
            Common.Configuration.Linq.AllowMultipleQuery = true;

            _results = new QueryResult[]
            {
                new QueryResult()
                {
                    Schema     = EagerLoad.SchemaTable_SalesOrderDetails,
                    Names      = EagerLoad.Names_SalesOrderDetails,
                    FieldTypes = EagerLoad.FieldTypes_SalesOrderDetails,
                    DbTypes    = EagerLoad.DbTypes_SalesOrderDetails,
                    Data       = Enumerable.Range(0, 4768).Select(_ => EagerLoad.SampleRow_SalesOrderDetails(_ % 1000)).ToArray(),
                    //Data         = Enumerable.Range(0, 47).Select(_ => EagerLoad.SampleRow_SalesOrderDetails(_ % 1000)).ToArray(),
                    Match = sql => sql.Contains("[SalesOrderDetail]")
                },
                new QueryResult()
                {
                    Schema     = EagerLoad.SchemaTable_HeaderCustomer,
                    Names      = EagerLoad.Names_HeaderCustomer,
                    FieldTypes = EagerLoad.FieldTypes_HeaderCustomer,
                    DbTypes    = EagerLoad.DbTypes_HeaderCustomer,
                    Data       = Enumerable.Range(0, 1000).Select(_ => EagerLoad.SampleRow_HeaderCustomer(_ % 1000)).ToArray(),
                    //Data         = Enumerable.Range(0, 10).Select(_ => EagerLoad.SampleRow_HeaderCustomer(_ % 1000)).ToArray(),
                    Match = sql => sql.Contains("LEFT JOIN [Sales].[Customer]")
                }
            };

            _compiled = CompiledQuery.Compile((Db db) => from soh in db.SalesOrderHeaders
                                              .LoadWith(x => x.SalesOrderDetails)
                                              .LoadWith(x => x.Customer)
                                              where soh.SalesOrderID > 50000 && soh.SalesOrderID <= 51000
                                              select soh);
        }
Esempio n. 4
0
        public void Geodetic_To_UPS_Conversions()
        {
            EagerLoad el = new EagerLoad(EagerLoadType.UTM_MGRS);

            foreach (var currentLine in polar_coordinates)
            {
                string[] parts = currentLine.Split(',');

                double lat = Convert.ToDouble(parts[5]);
                double lng = Convert.ToDouble(parts[6]);

                string zone = parts[1];

                int easting  = Convert.ToInt32(parts[2]);
                int northing = Convert.ToInt32(parts[3]);

                Coordinate c = new Coordinate(lat, lng, el);

                //skip 80-84 due to Earthpoint using different UTM zone returns. Both methods are accurate and test against EarthPoint, but will cause test to fail.
                if (lat >= 80 && lat <= 84)
                {
                    continue;
                }
                if (Math.Abs(lat) >= 89.99999)
                {
                    continue;
                }                                           //Dont test as long doesn't exist at pole.

                Assert.AreEqual(string.Format("{0}{1}", c.UTM.LongZone, c.UTM.LatZone), zone, "Zone conversion value unexpected.");
                Assert.AreEqual(0, c.UTM.Easting - easting, 1, "Easting value outside limits");
                Assert.AreEqual(0, c.UTM.Northing - northing, 1, "Northing value outside limits");
            }
        }
Esempio n. 5
0
        public void Geodetic_To_MGRS_Polar_Conversions()
        {
            EagerLoad el = new EagerLoad(EagerLoadType.UTM_MGRS);


            foreach (var currentLine in polar_coordinates)
            {
                string[] parts = currentLine.Split(',');

                double lat = Convert.ToDouble(parts[5]);
                double lng = Convert.ToDouble(parts[6]);

                string mgrs = parts[4];

                Coordinate c = new Coordinate(lat, lng, el);

                //skip 80-84 due to Earthpoint using different UTM zone returns. Both methods are accurate and test against EarthPoint, but will cause test to fail.
                if (lat >= 80 && lat <= 84)
                {
                    continue;
                }
                if (Math.Abs(lat) >= 89.99999)
                {
                    continue;
                }                                           //Dont test as long doesn't exist at pole.


                string nMgrs = c.MGRS.ToString().Replace(" ", "");//Formatting test to ensure test runs correctly
                Assert.AreEqual(mgrs, nMgrs, "MGRS Polar value not expected");
            }
        }
Esempio n. 6
0
        public void Parse_Simple_EagerLoad_Test()
        {
            Coordinate coordinate;
            //Parse Coordinate Formats

            EagerLoad el = new EagerLoad(false);

            Assert.IsTrue(Coordinate.TryParse("12,12", el, out coordinate), "Parse Failed");
            Assert.IsNull(coordinate.CelestialInfo, "Null CelestialInfo 2 expected");
            Assert.IsNull(coordinate.ECEF, "Null ECEF2 expected");

            el = new EagerLoad(EagerLoadType.Celestial);
            Assert.IsTrue(Coordinate.TryParse("12,12", el, out coordinate), "Parse Failed");
            Assert.IsNotNull(coordinate.CelestialInfo, "CelestialInfo 2 expected");
            Assert.IsNull(coordinate.ECEF, "Null ECEF 2 expected");

            el = new EagerLoad(EagerLoadType.ECEF);
            Assert.IsTrue(Coordinate.TryParse("12,12", el, out coordinate), "Parse Failed");
            Assert.IsNull(coordinate.CelestialInfo, "Null CelestialInfo 3 expected");
            Assert.IsNotNull(coordinate.ECEF, "ECEF 3 expected");

            el = new EagerLoad(EagerLoadType.ECEF | EagerLoadType.Celestial);
            Assert.IsTrue(Coordinate.TryParse("12,12", el, out coordinate), "Parse Failed");
            Assert.IsNotNull(coordinate.CelestialInfo, "CelestialInfo 4 expected");
            Assert.IsNotNull(coordinate.ECEF, "ECEF 4 expected");
        }
Esempio n. 7
0
        private static void Null_Properties_Check(Coordinate c)
        {
            EagerLoad e = new EagerLoad(false);

            //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;
            }
            if (c.ECEF != null)
            {
                pass = false;
            }
            Pass.Write("Null Properties (Celestial, UTM, MGRS, Cartesian, ECEF)", pass);
        }
Esempio n. 8
0
 public ImageObservationCornerCoordinates(EagerLoad load)
 {
     UpperLeft  = new Coordinate(load);
     UpperRight = new Coordinate(load);
     LowerLeft  = new Coordinate(load);
     LowerRight = new Coordinate(load);
 }
Esempio n. 9
0
        public void Flag_Initialization_Tests()
        {
            EagerLoad eg = new EagerLoad(EagerLoadType.Cartesian | EagerLoadType.Celestial | EagerLoadType.UTM_MGRS | EagerLoadType.ECEF);

            if (eg.Cartesian == false || eg.Celestial == false || eg.UTM_MGRS == false || eg.ECEF == false)
            {
                Assert.Fail("Property values not expected (1).");
            }
            eg = new EagerLoad(EagerLoadType.Celestial);
            if (eg.Cartesian == true || eg.Celestial == false || eg.UTM_MGRS == true || eg.ECEF == true)
            {
                Assert.Fail("Property values not expected (2).");
            }
            eg = new EagerLoad(EagerLoadType.Cartesian);
            if (eg.Cartesian == false || eg.Celestial == true || eg.UTM_MGRS == true || eg.ECEF == true)
            {
                Assert.Fail("Property values not expected (3).");
            }
            eg = new EagerLoad(EagerLoadType.UTM_MGRS);
            if (eg.Cartesian == true || eg.Celestial == true || eg.UTM_MGRS == false || eg.ECEF == true)
            {
                Assert.Fail("Property values not expected (4).");
            }
            eg = new EagerLoad(EagerLoadType.ECEF);
            if (eg.Cartesian == true || eg.Celestial == true || eg.UTM_MGRS == true || eg.ECEF == false)
            {
                Assert.Fail("Property values not expected (5).");
            }
            eg = new EagerLoad(EagerLoadType.UTM_MGRS | EagerLoadType.Celestial);
            if (eg.Cartesian == true || eg.Celestial == false || eg.UTM_MGRS == false || eg.ECEF == true)
            {
                Assert.Fail("Property values not expected (6).");
            }
            eg = new EagerLoad(EagerLoadType.Cartesian | EagerLoadType.Celestial);
            if (eg.Cartesian == false || eg.Celestial == false || eg.UTM_MGRS == true || eg.ECEF == true)
            {
                Assert.Fail("Property values not expected (6).");
            }
            eg = new EagerLoad(EagerLoadType.UTM_MGRS | EagerLoadType.Cartesian);
            if (eg.Cartesian == false || eg.Celestial == true || eg.UTM_MGRS == false || eg.ECEF == true)
            {
                Assert.Fail("Property values not expected (7).");
            }
            eg = new EagerLoad(EagerLoadType.ECEF | EagerLoadType.Celestial);
            if (eg.Cartesian == true || eg.Celestial == false || eg.UTM_MGRS == true || eg.ECEF == false)
            {
                Assert.Fail("Property values not expected (8).");
            }
            eg = new EagerLoad(EagerLoadType.ECEF | EagerLoadType.Cartesian);
            if (eg.Cartesian == false || eg.Celestial == true || eg.UTM_MGRS == true || eg.ECEF == false)
            {
                Assert.Fail("Property values not expected (10).");
            }
            eg = new EagerLoad(EagerLoadType.ECEF | EagerLoadType.Cartesian | EagerLoadType.UTM_MGRS);
            if (eg.Cartesian == false || eg.Celestial == true || eg.UTM_MGRS == false || eg.ECEF == false)
            {
                Assert.Fail("Property values not expected (11).");
            }
        }
        private static void Coordinate_Init_Range_Checks()
        {
            bool pass = true;

            try
            {
                EagerLoad eg = new EagerLoad();

                Coordinate c = new Coordinate(90, 180);
                c = new Coordinate(-90, -180);
                c = new Coordinate(90, 180, new DateTime());
                c = new Coordinate(-90, -180, new DateTime());
                c = new Coordinate(90, 180, eg);
                c = new Coordinate(-90, -180, eg);
                c = new Coordinate(90, 180, new DateTime(), eg);
                c = new Coordinate(-90, -180, new DateTime(), eg);

                //Should fail as arguments are out of range.
                try { c = new Coordinate(91, 180); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(90, 181); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-91, -180); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-90, -181); pass = false; }
                catch { }

                //Should fail as arguments are out of range.
                try { c = new Coordinate(91, 180, new DateTime()); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(90, 181, new DateTime()); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-91, -180, new DateTime()); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-90, -181, new DateTime()); pass = false; }
                catch { }

                //Should fail as arguments are out of range.
                try { c = new Coordinate(91, 180, new DateTime(), eg); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(90, 181, new DateTime(), eg); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-91, -180, new DateTime(), eg); pass = false; }
                catch { }
                //Should fail as arguments are out of range.
                try { c = new Coordinate(-90, -181, new DateTime(), eg); pass = false; }
                catch { }
            }
            catch { pass = false; }
            Pass.Write("Coordinate Initialization Range Checks", pass);
        }
Esempio n. 11
0
        public void ECEF_Load_Call()
        {
            EagerLoad  e = new EagerLoad(false);
            Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);

            c.LoadECEFInfo();
            Assert.AreNotEqual(null, c.ECEF);
        }
Esempio n. 12
0
        /// <summary>
        /// Benchmarks Coordinate initialization with eager loading settings turned off.
        /// </summary>
        public static void EagerLoadOff_Initilization(OutputOption opt)
        {
            Benchmark(() => {
                EagerLoad eg = new EagerLoad(false);

                var tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0), eg);
            }, 100, "Eager Load Off Initialization", opt);
        }
Esempio n. 13
0
        public void Celestial_Load_Call()
        {
            EagerLoad  e = new EagerLoad(false);
            Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);

            c.LoadCelestialInfo();
            Assert.AreNotEqual(null, c.CelestialInfo);
        }
Esempio n. 14
0
        public void UTM_MGRS_Load_Call()
        {
            EagerLoad  e = new EagerLoad(false);
            Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);

            c.LoadUTM_MGRS_Info();
            Assert.AreNotEqual(null, c.MGRS, "MGRS data did not load.");
            Assert.AreNotEqual(null, c.UTM, "UTM data did not load.");
        }
Esempio n. 15
0
        public static void Run_Tests()
        {
            EagerLoad  e = new EagerLoad(false);
            Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);

            Null_Properties_Check(c);
            Load_Call_Tests(c);
            Flags_Test();
        }
Esempio n. 16
0
        public static void Run_Test()
        {
            Coordinate tc = null;

            Console.WriteLine("Starting Benchmarks, this test may take a while to finish...");
            Console.WriteLine();
            //Benchmark Standard Object Initialization
            Benchmark(() => { tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0)); }, 100, "Standard Initialization");

            Benchmark(() => {
                tc           = new Coordinate();
                tc.Latitude  = new CoordinatePart(39, 45, 34, CoordinatesPosition.N);
                tc.Longitude = new CoordinatePart(74, 34, 45, CoordinatesPosition.W);
                tc.GeoDate   = new DateTime(2018, 7, 26, 15, 49, 0);
            }, 100, "Secondary Initialization");

            //Benchmark TryParse Object Initialization
            Benchmark(() => { Coordinate.TryParse("39.891219, -74.872435", new DateTime(2010, 7, 26, 15, 49, 0), out tc); }, 100, "TryParse() Initialization");

            //Benchmark with EagerLoad fully off
            Benchmark(() => {
                EagerLoad eg = new EagerLoad(false);

                tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0), eg);
            }, 100, "EagerLoad Off Initialization");
            tc = new Coordinate(39.891219, -74.872435, new DateTime(2018, 7, 26, 15, 49, 0));

            //Benchmark property change
            Random r = new Random();

            Benchmark(() => { tc.Latitude.DecimalDegree = r.Next(-90, 90); }, 100, "Property Change");

            //Benchmark Celestial Times
            Benchmark(() => { Celestial cel = new Celestial(45, 45, DateTime.Now); }, 100, "Celestial Time Calculations");
            Benchmark(() => { Celestial cel = Celestial.CalculateSunData(45, 45, DateTime.Now); }, 100, "Solar Time Calculations");
            Benchmark(() => { Celestial cel = Celestial.CalculateMoonData(45, 45, DateTime.Now); }, 100, "Lunar Time Calculations");

            //Benchmark Local Times
            Benchmark(() => { Coordinate c = new Coordinate(45, 45, DateTime.Now, new EagerLoad(false)); Celestial cel = Celestial.Celestial_LocalTime(c, -7); }, 100, "Local Celestial Times");
            Benchmark(() => { Coordinate c = new Coordinate(45, 45, DateTime.Now, new EagerLoad(false)); Celestial cel = Celestial.Solar_LocalTime(c, -7); }, 100, "Local Sun Only Times");
            Benchmark(() => { Coordinate c = new Coordinate(45, 45, DateTime.Now, new EagerLoad(false)); Celestial cel = Celestial.Lunar_LocalTime(c, -7); }, 100, "Local Moon Only Times");

            //Benchmark EagerLoadin Exentsion Times
            Benchmark(() =>
            {
                EagerLoad el  = new EagerLoad();
                el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Solar_Cycle);
                Coordinate c  = new Coordinate(45, 45, DateTime.Now, el);
            }, 100, "Coordinate Initialization with Solar Cycle Calculations Only.");

            Benchmark(() =>
            {
                EagerLoad el  = new EagerLoad();
                el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Lunar_Cycle);
                Coordinate c  = new Coordinate(45, 45, DateTime.Now, el);
            }, 100, "Coordinate Initialization with Lunar Cycle Calculations Only.");
        }
Esempio n. 17
0
        /// <summary>
        /// Benchmarks lunar cycle calculations.
        /// </summary>
        public static void Lunar_Cycle_Calculations(OutputOption opt)
        {
            EagerLoad  el = new EagerLoad();
            Coordinate c  = new Coordinate(45, 45, DateTime.Now, el);

            el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Lunar_Cycle);
            Benchmark(() => {
                Celestial cel = c.Celestial_LocalTime(-7);
            }, 100, "Local Lunar Cycle Only Times From Coordinate", opt);
        }
Esempio n. 18
0
        /// <summary>
        /// Benchmarks all celestial calculations occurring in local time.
        /// </summary>
        public static void Celestial_Calculations_Local_Time_From_Coordinate(OutputOption opt)
        {
            EagerLoad  el = new EagerLoad();
            Coordinate c  = new Coordinate(45, 45, DateTime.Now, el);

            //Benchmark Local Times
            Benchmark(() => {
                Celestial cel = c.Celestial_LocalTime(-7);
            }, 100, "Local Celestial Times From Coordinate", opt);
        }
Esempio n. 19
0
        private static void Coordinate_Parses_EagerLoad_Test()
        {
            Coordinate coordinate;

            //Parse Coordinate Formats
            string[] coordStrings = File.ReadAllLines("CoordinateData\\Coordinates.txt");
            bool     pass         = true;

            foreach (string c in coordStrings)
            {
                EagerLoad el = new EagerLoad(false);
                if (!Coordinate.TryParse("12,12", el, out coordinate))
                {
                    pass = false;
                }
                if (coordinate.CelestialInfo != null)
                {
                    pass = false;
                }                                                      //Simple check to see if eager loading is off.

                el = new EagerLoad(EagerLoadType.Celestial);
                if (!Coordinate.TryParse("12,12", DateTime.Now, el, out coordinate))
                {
                    pass = false;
                }
                if (coordinate.CelestialInfo == null || coordinate.ECEF != null)
                {
                    pass = false;
                }                                                                                  //Simple check to see if eager loading is specified

                el = new EagerLoad(EagerLoadType.ECEF);
                if (!Coordinate.TryParse("12,12", CartesianType.ECEF, el, out coordinate))
                {
                    pass = false;
                }
                if (coordinate.ECEF == null || coordinate.CelestialInfo != null)
                {
                    pass = false;
                }                                                                                  //Simple check to see if eager loading is off.

                el = new EagerLoad(EagerLoadType.ECEF | EagerLoadType.Celestial);
                if (!Coordinate.TryParse("12,12", DateTime.Now, CartesianType.ECEF, el, out coordinate))
                {
                    pass = false;
                }
                if (coordinate.CelestialInfo == null || coordinate.ECEF == null)
                {
                    pass = false;
                }                                                                                  //Simple check to see if eager loading is off.
            }

            Pass.Write("Coordinate Eager Load Parses", pass);

            Console.WriteLine();
        }
Esempio n. 20
0
        /// <summary>
        /// Returns a series of four corner coordinates from a provided string of coordinate information.
        /// </summary>
        /// <param name="cornerCoordinatesString">The coordinate information to parse</param>
        /// <returns>An ImageObservationCornerCoordinates object containing four coordinate points for each side of a square</returns>
        protected ImageObservationCornerCoordinates GetCornerCoordinates(string cornerCoordinatesString)
        {
            string[] coordinates = Regex.Split(cornerCoordinatesString, @"(?<=[N,S,E,W])");
            // disable the celestial information (not needed)
            EagerLoad load = new EagerLoad
            {
                Celestial = false,
                Cartesian = true,
                UTM_MGRS  = true
            };
            ImageObservationCornerCoordinates cornerCoords = new ImageObservationCornerCoordinates(load);

            // upper left latitude
            if (!String.IsNullOrEmpty(coordinates[0]))
            {
                cornerCoords.UpperLeft.Latitude = GetLatitude(coordinates[0].Trim(), cornerCoords.UpperLeft);
            }
            // upper left longitude
            if (!String.IsNullOrEmpty(coordinates[2]))
            {
                cornerCoords.UpperLeft.Longitude = GetLongitude(coordinates[2].Trim(), cornerCoords.UpperLeft);
            }
            // upper right latitude
            if (!String.IsNullOrEmpty(coordinates[1]))
            {
                cornerCoords.UpperRight.Latitude = GetLatitude(coordinates[1].Trim(), cornerCoords.UpperRight);
            }
            // upper right longitude
            if (!String.IsNullOrEmpty(coordinates[3]))
            {
                cornerCoords.UpperRight.Longitude = GetLongitude(coordinates[3].Trim(), cornerCoords.UpperRight);
            }
            // lower left latitude
            if (!String.IsNullOrEmpty(coordinates[4]))
            {
                cornerCoords.LowerLeft.Latitude = GetLatitude(coordinates[4].Trim(), cornerCoords.LowerLeft);
            }
            // lower left longitude
            if (!String.IsNullOrEmpty(coordinates[6]))
            {
                cornerCoords.LowerLeft.Longitude = GetLongitude(coordinates[6].Trim(), cornerCoords.LowerLeft);
            }
            // lower right latitude
            if (!String.IsNullOrEmpty(coordinates[5]))
            {
                cornerCoords.LowerRight.Latitude = GetLatitude(coordinates[5].Trim(), cornerCoords.LowerRight);
            }
            // lower right longitude
            if (!String.IsNullOrEmpty(coordinates[7]))
            {
                cornerCoords.LowerRight.Longitude = GetLongitude(coordinates[7].Trim(), cornerCoords.LowerRight);
            }
            return(cornerCoords);
        }
Esempio n. 21
0
        public void Cartesian_EagerLoad_On_Updates_With_Coordinate_Change()
        {
            EagerLoad  el  = new EagerLoad(false);
            Coordinate c   = new Coordinate(45, 75, new DateTime(2008, 1, 2), el);
            var        val = c.Cartesian;                    //For comparison

            c.EagerLoadSettings       = new EagerLoad(true); //Turn on eager loading
            c.Latitude.DecimalDegree  = 44;
            c.Longitude.DecimalDegree = 74;
            Assert.IsFalse(Helpers.ReflectiveEquals(val, c.Cartesian));
        }
Esempio n. 22
0
        public void Coordinate_Initialize_Within_Allowed_Ranges()
        {
            EagerLoad  eg = new EagerLoad();
            Coordinate c  = new Coordinate(90, 180);

            c = new Coordinate(-90, -180);
            c = new Coordinate(90, 180, new DateTime());
            c = new Coordinate(-90, -180, new DateTime());
            c = new Coordinate(90, 180, eg);
            c = new Coordinate(-90, -180, eg);
            c = new Coordinate(90, 180, new DateTime(), eg);
            c = new Coordinate(-90, -180, new DateTime(), eg);
        }
Esempio n. 23
0
        public GeoPoint(string latZone, int longZone, double easting, double northing)
        {
            LatZone  = latZone;
            LongZone = longZone;
            Easting  = easting;
            Northing = northing;
            EagerLoad test = new EagerLoad();
            UniversalTransverseMercator utm = new UniversalTransverseMercator(latZone, longZone, easting, northing);
            Coordinate c = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);

            Latitude  = c.Latitude.ToDouble();
            Longitude = c.Longitude.ToDouble();
        }
        public void Eager_Loading_GeographicLocation_Should_Not_Throw_Error()
        {
            double    lat   = 0.0;
            double    longi = 0.0;
            EagerLoad load  = new EagerLoad()
            {
                UTM_MGRS  = true,
                Cartesian = true,
                Celestial = true
            };
            Action act = () => new GeographicLocation(lat, longi, load);

            act.Should().NotThrow <Exception>();
        }
 public void EagerLoading_Ext_Off()
 {
     EagerLoad e = new EagerLoad(true);
     e.Extensions = new EagerLoad_Extensions(false);
     Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);
     c.Latitude.DecimalDegree++; //Trigger proper changes to confirm objects remain unloaded
     c.Longitude.DecimalDegree++; //Trigger proper changes to confirm objects remain unloaded
     Assert.AreEqual(null, c.CelestialInfo.SunSet);//Solar Cycle
     Assert.AreEqual(null, c.CelestialInfo.MoonSet);//Lunar Cycle
     Assert.AreEqual(null, c.CelestialInfo.AstrologicalSigns.MoonName);//Zodiac
     Assert.AreEqual(new DateTime(), c.CelestialInfo.LunarEclipse.LastEclipse.Date);//Lunar Cycle
     Assert.AreEqual(new DateTime(), c.CelestialInfo.SolarEclipse.LastEclipse.Date);//Solar Eclipse
     Assert.AreEqual(new DateTime(), c.CelestialInfo.Solstices.Summer);//Solstice Equinox
     Assert.AreEqual(null, c.MGRS); //MGRS
 }
        public void EagerLoading_Ext_Intializes_On()
        {
            EagerLoad e = new EagerLoad();
            e.Extensions = new EagerLoad_Extensions();
            Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);

            //Check extension properties to ensure proper loading
            Assert.AreNotEqual(null, c.CelestialInfo.SunSet);//Solar Cycle
            Assert.AreNotEqual(null, c.CelestialInfo.MoonSet);//Lunar Cycle
            Assert.AreNotEqual(null, c.CelestialInfo.AstrologicalSigns.MoonName);//Zodiac
            Assert.AreNotEqual(null, c.CelestialInfo.LunarEclipse.LastEclipse.Type);//Lunar Cycle
            Assert.AreNotEqual(null, c.CelestialInfo.SolarEclipse.LastEclipse.Type);//Solar Cycle
            Assert.AreNotEqual(null, c.CelestialInfo.Solstices.Summer);//Lunar Cycle
            Assert.AreNotEqual(null, c.MGRS); //MGRS
        }
Esempio n. 27
0
        public void MGRS_Polar_To_Geodetic_Conversions()
        {
            EagerLoad el = new EagerLoad(EagerLoadType.UTM_MGRS);

            foreach (var currentLine in polar_coordinates)
            {
                string[] parts = currentLine.Split(',');

                double lat = Convert.ToDouble(parts[5]);
                double lng = Convert.ToDouble(parts[6]);

                Coordinate c = new Coordinate(lat, lng, el);

                //skip 80-84 due to Earthpoint using different UTM zone returns. Both methods are accurate and test against EarthPoint, but will cause test to fail.
                if (lat >= 80 && lat <= 84)
                {
                    continue;
                }
                if (Math.Abs(lat) >= 89.99999)
                {
                    continue;
                }                                            //Dont test as long doesn't exist at pole.


                //CONVERT BACK TEST
                double precision = .0000001; //1.1 CM Convert Back Precision


                precision = .0003;
                if (Math.Abs(c.Latitude.ToDouble()) > 89)
                {
                    precision = .002;
                }
                else if (Math.Abs(c.Latitude.ToDouble()) > 88)
                {
                    precision = .0006;
                }

                Coordinate bc = MilitaryGridReferenceSystem.MGRStoLatLong(c.MGRS, new EagerLoad(false));
                double     l  = c.Latitude.ToDouble();
                double     bL = bc.Latitude.ToDouble();
                Assert.IsFalse(Math.Abs(bL - l) > precision && Math.Abs(bL - l) != 360, "Longitude value not expected.");

                l  = c.Longitude.ToDouble();
                bL = bc.Longitude.ToDouble();
                Assert.IsFalse(Math.Abs(bL - l) > precision && Math.Abs(bL - l) != 360, "Longitude value not expected.");
            }
        }
Esempio n. 28
0
        public void EagerLoading_Intializes_On()
        {
            EagerLoad  e = new EagerLoad();
            Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e);

            Assert.AreNotEqual(null, c.CelestialInfo);
            Assert.AreNotEqual(null, c.UTM);
            Assert.AreNotEqual(null, c.MGRS);
            Assert.AreNotEqual(null, c.ECEF);
            Assert.AreNotEqual(null, c.Cartesian);

            //Check Polar Regions
            c = new Coordinate(86, 75, new DateTime(2008, 1, 2), e);
            Assert.AreNotEqual(null, c.MGRS);
            Assert.AreNotEqual(null, c.ECEF);
        }
Esempio n. 29
0
        public static Point ToUTMPoint(this double lat, double lon, int gridZone = 0)
        {
            //EagerLoad sets which CoordinateSystems are calculated set all to false except UTM_MGRS
            EagerLoad el = new EagerLoad(false);

            el.UTM_MGRS        = true;
            el.Extensions.MGRS = false;
            Coordinate c = new Coordinate(lat, lon, el);

            if (gridZone >= 1 && gridZone <= 60)
            {
                c.Lock_UTM_MGRS_Zone(gridZone);
            }
            Point utmPoint = Geometry.Create.Point(c.UTM.Easting, c.UTM.Northing, 0);

            return(utmPoint);
        }
Esempio n. 30
0
        public void Coordinate_Initializes_Without_Exceptions()
        {
            Coordinate c = new Coordinate();

            c = new Coordinate(25, 25);
            c = new Coordinate(25, 25, new DateTime(2018, 8, 5, 10, 10, 0));

            EagerLoad eg = new EagerLoad();

            eg.Cartesian = false;
            eg.Celestial = false;
            eg.UTM_MGRS  = false;

            c = new Coordinate(eg);
            c = new Coordinate(25, 25, eg);
            c = new Coordinate(25, 25, new DateTime(2018, 8, 5, 10, 10, 0), eg);
        }