コード例 #1
0
        public Boolean CheckTransform(
            CoordinateReferenceSystem srcCRS, double x1, double y1,
            CoordinateReferenceSystem tgtCRS, double x2, double y2,
            double tolerance)
        {
            p.X = x1;
            p.Y = y1;
            var trans = ctFactory.CreateTransform(srcCRS, tgtCRS);

            trans.Transform(p, p2);

            var dx    = Math.Abs(p2.X - x2);
            var dy    = Math.Abs(p2.Y - y2);
            var delta = Math.Max(dx, dy);

            if (_verbose)
            {
                Console.Write("{0} => {1}", srcCRS.Name, tgtCRS.Name);
            }

            var isInTol = delta <= tolerance;

            if (_verbose)
            {
                if (!isInTol)
                {
                    Console.WriteLine(" ... FAILED");
                    var source = p.ToShortString();
                    Console.WriteLine("\t{0} -> {1}", source, p2.ToShortString());

                    var result = new ProjCoordinate(x2, y2);
                    var offset = new ProjCoordinate(p2.X - x2, p2.Y - y2);
                    Console.WriteLine("\t{0}    {1},  (tolerance={2}, max delta={3})",
                                      new string(' ', source.Length), result.ToShortString(),
                                      tolerance, delta);
                    Console.WriteLine("\tSource CRS: " + srcCRS.GetParameterString());
                    Console.WriteLine("\tTarget CRS: " + tgtCRS.GetParameterString());
                }
                else
                {
                    Console.WriteLine(" ... PASSED");
                }
            }


            return(isInTol);
        }
コード例 #2
0
        static void Run(String code)
        {
            CoordinateReferenceSystemFactory csFactory = new CoordinateReferenceSystemFactory();
            CoordinateReferenceSystem        cs        = csFactory.CreateFromName(code);

            if (cs == null)
            {
                return;
            }
            ProjectionGridRoundTripper tripper = new ProjectionGridRoundTripper(cs);
            //tripper.setLevelDebug(true);
            Boolean isOK = tripper.RunGrid(Tolerance);

            double[] extent = tripper.Extent;

            Console.WriteLine(code + " - " + cs.GetParameterString());
            Console.WriteLine(
                @" - extent: [ " + extent[0] + @", " + extent[1] + @" : " + extent[2] + @", " + extent[3] + @" ]" +
                @" - tol: " + Tolerance +
                @" - # pts run = " + tripper.TransformCount);

            Assert.IsTrue(isOK);
        }
コード例 #3
0
        public void Print(TextWriter os)
        {
            os.Write(_testName);
            if (_verbose)
            {
                os.WriteLine();
                os.WriteLine("{0} -> {1} (expected {2})", _srcPt.ToShortString(), _resultPt.ToShortString(),
                             new ProjCoordinate(_tgtOrd1, _tgtOrd2, _tgtOrd3).ToShortString());
            }

            if (!_isInTol)
            {
                os.WriteLine(@" ... FAIL");
                if (_verbose)
                {
                    os.WriteLine(@"  Source CRS ({0}:{1}): {2}", _srcCrsAuth, _srcCrs, _srcCRS.GetParameterString());
                    os.WriteLine(@"  Target CRS ({0}:{1}): {2}", _tgtCrsAuth, _tgtCrs, _tgtCRS.GetParameterString());
                }
            }
            else
            {
                os.WriteLine(" ... PASSED");
            }
        }