public void TestInvalidEncoderInput() { //Null coordinates Assert.Throws <ArgumentException>(() => { PolylineEncoderDecoder.Decode(null); }); //Empty coordinates list test Assert.Throws <ArgumentException>(() => { PolylineEncoderDecoder.Decode(string.Empty); }); }
public void TestLatLngZDecode() { var computed = PolylineEncoderDecoder.Decode("BlBoz5xJ67i1BU1B7PUzIhaUxL7YU"); var tuples = new List <LatLngZ>(); tuples.Add(new LatLngZ(50.10228, 8.69821, 10)); tuples.Add(new LatLngZ(50.10201, 8.69567, 20)); tuples.Add(new LatLngZ(50.10063, 8.69150, 30)); tuples.Add(new LatLngZ(50.09878, 8.68752, 40)); Assert.AreEqual(computed.Count, tuples.Count); for (int i = 0; i < computed.Count; ++i) { Assert.AreEqual(computed[i], tuples[i]); } }
public void TestSimpleLatLngDecoding() { var computed = PolylineEncoderDecoder.Decode("BFoz5xJ67i1B1B7PzIhaxL7Y"); var expected = new List <LatLngZ>(); expected.Add(new LatLngZ(50.10228, 8.69821)); expected.Add(new LatLngZ(50.10201, 8.69567)); expected.Add(new LatLngZ(50.10063, 8.69150)); expected.Add(new LatLngZ(50.09878, 8.68752)); Assert.AreEqual(computed.Count, expected.Count); for (int i = 0; i < computed.Count; ++i) { Assert.AreEqual(computed[i], expected[i]); } }
public void EncodedFlexilineMatchesDecodedResultTest() { using (var decodedEnumerator = File.ReadLines("../../../../../../test/round_half_up/decoded.txt").GetEnumerator()) { foreach (var flexiline in File.ReadLines("../../../../../../test/round_half_up/encoded.txt")) { decodedEnumerator.MoveNext(); var testResultStr = decodedEnumerator.Current; var expectedResult = ParseExpectedTestResult(testResultStr); var decoded = PolylineEncoderDecoder.Decode(flexiline); var encoded = PolylineEncoderDecoder.Encode( decoded, expectedResult.Precision.Precision2d, expectedResult.Precision.Type3d, expectedResult.Precision.Precision3d); ThirdDimension thirdDimension = PolylineEncoderDecoder.GetThirdDimension(encoded); Assert.AreEqual(expectedResult.Precision.Type3d, thirdDimension); for (int i = 0; i < decoded.Count; i++) { AssertEqualWithPrecision( expectedResult.Coordinates[i].Lat, decoded[i].Lat, expectedResult.Precision.Precision2d); AssertEqualWithPrecision( expectedResult.Coordinates[i].Lng, decoded[i].Lng, expectedResult.Precision.Precision2d); AssertEqualWithPrecision( expectedResult.Coordinates[i].Z, decoded[i].Z, expectedResult.Precision.Precision3d); } if (flexiline != encoded) { Console.WriteLine($@"WARNING expected {flexiline} but got {encoded}"); } } } }
public void TestComplexLatLngDecoding() { var computed = PolylineEncoderDecoder.Decode("BF05xgKuy2xCx9B7vUl0OhnR54EqSzpEl-HxjD3pBiGnyGi2CvwFsgD3nD4vB6e"); var pairs = new List <LatLngZ>(); pairs.Add(new LatLngZ(52.51994, 13.38663)); pairs.Add(new LatLngZ(52.51009, 13.28169)); pairs.Add(new LatLngZ(52.43518, 13.19352)); pairs.Add(new LatLngZ(52.41073, 13.19645)); pairs.Add(new LatLngZ(52.38871, 13.15578)); pairs.Add(new LatLngZ(52.37278, 13.14910)); pairs.Add(new LatLngZ(52.37375, 13.11546)); pairs.Add(new LatLngZ(52.38752, 13.08722)); pairs.Add(new LatLngZ(52.40294, 13.07062)); pairs.Add(new LatLngZ(52.41058, 13.07555)); Assert.AreEqual(computed.Count, pairs.Count); for (int i = 0; i < computed.Count; ++i) { Assert.AreEqual(computed[i], pairs[i]); } }