public void Check_60_Degree_Handling() { Coordinate c = new Coordinate(new EagerLoad(false)); var options = new CoordinateFormatOptions(); options.Format = CoordinateFormatType.Degree_Decimal_Minutes; var lat = new CoordinatePart(CoordinateType.Lat); lat.Degrees = 89; lat.Minutes = 59; lat.Seconds = 59.99999; var lng = new CoordinatePart(CoordinateType.Long); lng.Degrees = 179; lng.Minutes = 59; lng.Seconds = 59.99999; c.Latitude = lat; c.Longitude = lng; Assert.AreEqual("N 90º 0' 0\" E 180º 0' 0\"", c.ToString()); Assert.AreEqual("N 90º 0' E 180º 0'", c.ToString(options)); lat.Position = CoordinatesPosition.S; lng.Position = CoordinatesPosition.W; Assert.AreEqual("S 90º 0' 0\" W 180º 0' 0\"", c.ToString()); Assert.AreEqual("S 90º 0' W 180º 0'", c.ToString(options)); }
public void Parse_Degree__Minute_Decimal_Seconds_String() { CoordinateFormatOptions options = new CoordinateFormatOptions() { Format = CoordinateFormatType.Degree_Minutes_Seconds }; Parse_Geodetic_Strings(options); }
public void Parse_Decimal_Degrees_String() { CoordinateFormatOptions options = new CoordinateFormatOptions() { Format = CoordinateFormatType.Decimal_Degree, Round = 6 }; Parse_Geodetic_Strings(options); }
public void Degrees_Minutes_Seconds_Conversion() { string s1 = "N 39º 34' 36.48\" E 72º 29' 9.24\""; string s2 = "S 15º 34' 36.48\" E 100º 29' 9.24\""; string s3 = "N 65º 15' 0\" W 15º 11' 9.24\""; string s4 = "S 80º 39' 32.4\" W 152º 29' 24\""; string[] expecteds = new string[] { s1, s2, s3, s4 }; CoordinateFormatOptions format = new CoordinateFormatOptions() { Format = CoordinateFormatType.Degree_Minutes_Seconds }; Assert_Geodetic_Conversion(expecteds, format); }
public void Degree_Decimal_Minute_Format_Conversion() { string s1 = "N 39º 34.608' E 72º 29.154'"; string s2 = "S 15º 34.608' E 100º 29.154'"; string s3 = "N 65º 15' W 15º 11.154'"; string s4 = "S 80º 39.54' W 152º 29.4'"; string[] expecteds = new string[] { s1, s2, s3, s4 }; CoordinateFormatOptions format = new CoordinateFormatOptions() { Format = CoordinateFormatType.Degree_Decimal_Minutes }; Assert_Geodetic_Conversion(expecteds, format); }
public void Decimal_Degree_Format_Conversion() { string s1 = "N 39.577º E 72.486º"; string s2 = "S 15.577º E 100.486º"; string s3 = "N 65.25º W 15.186º"; string s4 = "S 80.659º W 152.49º"; string[] expecteds = new string[] { s1, s2, s3, s4 }; CoordinateFormatOptions format = new CoordinateFormatOptions() { Format = CoordinateFormatType.Decimal_Degree }; Assert_Geodetic_Conversion(expecteds, format); }
public void Decimal_Format_Conversion() { string s1 = "39.577 72.486"; string s2 = "-15.577 100.486"; string s3 = "65.25 -15.186"; string s4 = "-80.659 -152.49"; string[] expecteds = new string[] { s1, s2, s3, s4 }; CoordinateFormatOptions format = new CoordinateFormatOptions() { Format = CoordinateFormatType.Decimal }; Assert_Geodetic_Conversion(expecteds, format); }
/// <summary> /// Tests whether parsing string representations (depending on <paramref name="options"/>) of 100 random <see cref="Coordinate"/> objects returns "close enough" <see cref="Coordinate"/> objects. /// </summary> /// <param name="options"></param> private void Parse_Geodetic_Strings(CoordinateFormatOptions options) { EagerLoad el = new EagerLoad(false); void DoOneRandomTest() { Coordinate expected = GetRandomCoordinate(el); string s = expected.ToString(options); Coordinate actual = Coordinate.Parse(s); AsserCoordinatesAreClose(expected, actual); } for (int i = 0; i < nrRepetitions; ++i) { DoOneRandomTest(); } }
/// <summary> /// Asserts conversions /// </summary> /// <param name="lat">Latitude</param> /// <param name="lng">Longitude</param> /// <param name="expected">Expected Value</param> /// <param name="format">Coordinate Format</param> private void Assert_Geodetic_Conversion(string[] expecteds, CoordinateFormatOptions format) { int x = 0; List <double[]> coordinates = new List <double[]>() { tc1, tc2, tc3, tc4 }; foreach (string expected in expecteds) { Coordinate c = new Coordinate(coordinates[x][0], coordinates[x][1], eg); c.FormatOptions = format; if (format.Format == CoordinateFormatType.Degree_Minutes_Seconds) { Debug.WriteLine(c.ToString()); } Assert.AreEqual(expected, c.ToString(), string.Format("Value: {0} Expected: {1}", c.ToString(), expected)); x++; } }
//Unit Test Console //This is a partial unit test meant to test initialization of objects. //Error, limit & MVVM testing should be done in the WPF test app. static void Main(string[] args) { //Test Lat Long KWRI 40.0352° N, 74.5844° W //Test Coordinate Initialization w & w/o eager load d("INITIALIZATION TESTS:"); Coordinate c = new Coordinate(); d(c.ToString()); c = new Coordinate(40.0352, -74.5844); d(c.ToString()); c = new Coordinate(40.0352, -74.5844, new DateTime(2017, 8, 21, 0, 0, 0)); d(c.ToString()); EagerLoad eagerLoad = new EagerLoad(); c = new Coordinate(eagerLoad); d(c.ToString()); c = new Coordinate(40.0352, -74.5844, eagerLoad); d(c.ToString()); c = new Coordinate(40.0352, -74.5844, new DateTime(2017, 8, 21, 0, 0, 0), eagerLoad); d(c.ToString()); //Test Coord String Formats CoordinateFormatOptions cfo = new CoordinateFormatOptions(); cfo.Format = CoordinateFormatType.Degree_Decimal_Minutes; cfo.Display_Symbols = false; cfo.Display_Trailing_Zeros = true; c.FormatOptions = cfo; d(c.Latitude.ToString() + " - " + c.Longitude.ToString()); //Test ToDouble d(c.Latitude.ToDouble() + " - " + c.Longitude.ToDouble()); //Test UTM & MGRS d(c.MGRS.ToString()); d(c.MGRS.Digraph + " - " + c.MGRS.Easting + " - " + c.MGRS.LatZone + " - " + c.MGRS.LongZone + " - " + c.MGRS.Northing); d(c.UTM.ToString()); d(c.UTM.Easting + " - " + c.UTM.LatZone + " - " + c.UTM.LongZone + " - " + c.UTM.Northing); //TEST CELESTIAL //Main Properties d("SUN CONDITION: " + c.CelestialInfo.SunCondition.ToString()); d("SUN RISE: " + c.CelestialInfo.SunRise); d("SUN SET: " + c.CelestialInfo.SunSet); d("SUN ALTITUDE: " + c.CelestialInfo.SunAltitude); d("SUN AZIMUTH: " + c.CelestialInfo.SunAzimuth); d("MOON CONDITION: " + c.CelestialInfo.MoonCondition.ToString()); d("MOON DISTANCE: " + c.CelestialInfo.MoonDistance); d("MOON RISE: " + c.CelestialInfo.MoonRise); d("MOON SET: " + c.CelestialInfo.MoonSet); //Sub Properties d("CIVIL DAWN: " + c.CelestialInfo.AdditionalSolarTimes.CivilDawn.ToString()); d("CIVIL DUSK: " + c.CelestialInfo.AdditionalSolarTimes.CivilDusk.ToString()); d("NAUTICAL DAWN: " + c.CelestialInfo.AdditionalSolarTimes.NauticalDawn.ToString()); d("NAUTICAL DUSK: " + c.CelestialInfo.AdditionalSolarTimes.NauticalDusk.ToString()); d("MOON NAME: " + c.CelestialInfo.AstrologicalSigns.MoonName); d("MOON SIGN: " + c.CelestialInfo.AstrologicalSigns.MoonSign); d("ZODIAC SIGN: " + c.CelestialInfo.AstrologicalSigns.ZodiacSign); d("MOON ANGLE: " + c.CelestialInfo.MoonIllum.Angle.ToString()); d("MOON FRACTION: " + c.CelestialInfo.MoonIllum.Fraction.ToString()); d("MOON PHASE: " + c.CelestialInfo.MoonIllum.Phase.ToString()); d("MOON PHASENAME: " + c.CelestialInfo.MoonIllum.PhaseName.ToString()); //VALUE CHANGE NOTIFICATION TEST (PARTIAL. MORE COMPLETE TESTING OF NOTIFICATION CHANGES SHOULD BE DONE IN THE MVVM WPF TESTER) //New Lat Long Cape Town Intl 33.9715° S, 18.6021° E d("COORDINATE CHANGE NOTIFICATION TESTS"); c.Latitude.DecimalDegree = 33.9715; c.Latitude.Position = CoordinatesPosition.S; c.Longitude.DecimalDegree = 18.6021; c.Longitude.Position = CoordinatesPosition.E; d(c.ToString()); d(c.MGRS.ToString()); d(c.UTM.ToString()); d("SUN CONDITION: " + c.CelestialInfo.SunCondition.ToString()); d("SUN RISE: " + c.CelestialInfo.SunRise); d("SUN SET: " + c.CelestialInfo.SunSet); d("SUN ALTITUDE: " + c.CelestialInfo.SunAltitude); d("SUN AZIMUTH: " + c.CelestialInfo.SunAzimuth); d("MOON CONDITION: " + c.CelestialInfo.MoonCondition.ToString()); d("MOON DISTANCE: " + c.CelestialInfo.MoonDistance); d("MOON RISE: " + c.CelestialInfo.MoonRise); d("MOON SET: " + c.CelestialInfo.MoonSet); //EAGERLOAD TESTS eagerLoad.Celestial = false; c = new Coordinate(40.0352, -74.5844, DateTime.Now, eagerLoad); try { d(c.CelestialInfo.SunSet.Value.ToString()); } catch (NullReferenceException ex) { d("TEST EAGERLOAD OFF: " + ex.Message); } c.LoadCelestialInfo(); d(c.CelestialInfo.SunSet.Value.ToString()); //TEST STATIC CELESTIALS Console.WriteLine(Celestial.CalculateCelestialTimes(40.0352, -74.5844, DateTime.Now).SunSet); Console.ReadKey(); }