Exemple #1
0
        public void ParseFromValidCompactString()
        {
            Dictionary <String, DMSComponents> testCases = new Dictionary <String, DMSComponents>();

            testCases.Add("611305.0002,N", new DMSComponents(61.21805560));
            testCases.Add("313418.6067,n", new DMSComponents(31.5718352));
            testCases.Add("570850.9694,N", new DMSComponents(57.1474915));
            testCases.Add("522455.0908,n", new DMSComponents(52.41530300));
            testCases.Add("1495401.0001,W", new DMSComponents(-149.90027780));
            testCases.Add("0851501.7615,w", new DMSComponents(-85.2504893));
            testCases.Add("0020543.4292,W", new DMSComponents(-2.095397));
            testCases.Add("0040458.5120,w", new DMSComponents(-4.08292000));

            foreach (KeyValuePair <String, DMSComponents> kv in testCases)
            {
                DMSComponents dms = DMSComponents.Parse(kv.Key, GeoAngleFormatOptions.Compact);
                Assert.AreEqual(dms.get_sign(), kv.Value.get_sign());
                Assert.AreEqual(dms.get_wholeDegrees(), kv.Value.get_wholeDegrees());
                Assert.AreEqual(dms.get_wholeMinutes(), kv.Value.get_wholeMinutes());
                String msg = String.Format("Parsed: {0}: {1} != {2} (Expected)",
                                           kv.Key,
                                           dms.get_decimalSeconds(),
                                           kv.Value.get_decimalSeconds());
                Assert.IsTrue(Math.Abs(dms.get_decimalSeconds() - kv.Value.get_decimalSeconds()) < 0.0001, msg);
            }
        }
Exemple #2
0
        public void ParseFromValidFormattedString()
        {
            Dictionary <String, DMSComponents> testCases = new Dictionary <String, DMSComponents>();

            testCases.Add("61° 13' 5.0002\" N", new DMSComponents(61.21805560));
            testCases.Add("31° 34' 18.6067\" N", new DMSComponents(31.5718352));
            testCases.Add("57° 8' 50.9694\" N", new DMSComponents(57.1474915));
            testCases.Add("52° 24' 55.0908\" N", new DMSComponents(52.41530300));
            testCases.Add("149° 54' 1.0001\" W", new DMSComponents(-149.90027780));
            testCases.Add("85° 15' 1.7615\" W", new DMSComponents(-85.2504893));
            testCases.Add("2° 5' 43.4292\" W", new DMSComponents(-2.095397));
            testCases.Add("4° 4' 58.5120\" W", new DMSComponents(-4.08292000));

            foreach (KeyValuePair <String, DMSComponents> kv in testCases)
            {
                DMSComponents dms = DMSComponents.Parse(kv.Key, GeoAngleFormatOptions.ShowUnits);
                Assert.AreEqual(dms.get_sign(), kv.Value.get_sign());
                Assert.AreEqual(dms.get_wholeDegrees(), kv.Value.get_wholeDegrees());
                Assert.AreEqual(dms.get_wholeMinutes(), kv.Value.get_wholeMinutes());
                String msg = String.Format("Parsed: {0}: {1} != {2} (Expected)",
                                           kv.Key,
                                           dms.get_decimalSeconds(),
                                           kv.Value.get_decimalSeconds());
                Assert.IsTrue(Math.Abs(dms.get_decimalSeconds() - kv.Value.get_decimalSeconds()) < 0.0001, msg);
            }
        }
Exemple #3
0
        public void DefaultConstructor()
        {
            DMSComponents dms = new DMSComponents();

            Assert.AreEqual(dms.get_sign(), 0);
            Assert.AreEqual(dms.get_wholeDegrees(), 0);
            Assert.AreEqual(dms.get_wholeMinutes(), 0);
            Assert.IsTrue(Math.Abs(dms.get_decimalSeconds()) < 0.000001, "Decimal seconds default init");
        }
Exemple #4
0
        public void ConstructorWithNegaitiveParameter()
        {
            double degrees = -_rnd.NextDouble() * 180;

            DMSComponents dms = new DMSComponents(degrees);

            DMSComponents dms2 = new DMSComponents();

            dms2.set_sign(dms.get_sign());
            dms2.set_wholeDegrees(dms.get_wholeDegrees());
            dms2.set_wholeMinutes(dms.get_wholeMinutes());
            dms2.set_decimalSeconds(dms.get_decimalSeconds());

            Assert.IsTrue(Math.Abs(dms2.ToDDD() - degrees) < 0.000001,
                          String.Format("ToDDD({0}) != {1}", dms2.ToDDD(), degrees));
        }