public TestPoint transform(TestPoint p) { return(new TestPoint { epsgCode = code, p = transformer.transform(projections[p.epsgCode].info, info, p.p) }); }
static void ExtendedTest() { Console.WriteLine("-- extended test --\n"); foreach (Transform dummy in transformers) { projections.Add(new SortedList <int, ProjectionInfo>()); } foreach (CoreProjectionInfo cpi in rawProjectionData) { for (int j = 0; j < transformers.Length; j++) { ProjectionInfo.addNew(projections[j], cpi, transformers[j]); } } TestPoint[] reference = new TestPoint[testPoints.Length * projections[0].Count]; ConsoleColor defaultFgColor = Console.ForegroundColor; for (int i = 0; i < projections.Count; i++) { SortedList <int, ProjectionInfo> projectionInfos = projections[i]; for (int j = 0; j < testPoints.Length; j++) { for (int k = 0; k < projectionInfos.Count; k++) { int refIdx = k * testPoints.Length + j; KeyValuePair <int, ProjectionInfo> projectionInfo = projectionInfos.ElementAt(k); DateTime then = DateTime.Now; TestPoint p = new TestPoint(); Exception _ex = null; int m = 1; for (int l = 0; l < m; l++) { try { p = projectionInfo.Value.transform(testPoints[j]); } catch (Exception ex) { _ex = _ex ?? ex; p = new TestPoint { epsgCode = projectionInfo.Key }; } } StringBuilder output = new StringBuilder( $"{projectionInfo.Value.transformer.Name}: {testPoints[j]} ==> {p} in {(double) (1000 * (DateTime.Now - then).TotalMilliseconds / m):0.00}µs"); ConsoleColor fgColor = defaultFgColor; if (i == 0) { reference[refIdx] = p; } else { Delta delta = reference[refIdx] - p; output.Append($", delta={delta.d:0.00} (dx={delta.dx:0.00}, dy={delta.dy:0.00})"); if (delta.d > 1e-1) { fgColor = ConsoleColor.Red; } } Console.ForegroundColor = fgColor; Console.WriteLine(output.ToString()); if (_ex != null) { Console.WriteLine("caught " + _ex.GetType().Name + ", message: " + _ex.Message); Console.WriteLine(_ex.StackTrace.ToString()); } Console.ForegroundColor = defaultFgColor; } } } Console.WriteLine("\n<press return to continue>"); Console.ReadLine(); }