コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #3
0
 public void ParseFromInvalidFormattedString()
 {
     DMSComponents.Parse("61° 13' 13' 5.0002\" N", GeoAngleFormatOptions.ShowUnits);
 }
コード例 #4
0
 public void ParseFromInvalidCompactString()
 {
     DMSComponents.Parse("611c305.0002;N", GeoAngleFormatOptions.Compact);
 }