Exemplo n.º 1
0
        /// <summary>
        /// order is determined
        /// </summary>
        public Point2[] Basins()
        {
            switch (_map.Projection)
            {
            case Projection.Healpix:
            case Projection.Healpix2Equirectangular:
                ApproxMan = new ApproximationManager(HealpixManager);
                break;
            }

            switch (_map.Projection)
            {
            case Projection.Healpix:
                return(ApproxMan.Pixels);

            case Projection.Healpix2Equirectangular:
            case Projection.Equirectangular:
                var height = _map.YResolution * HealpixManager.Nside;
                var width  = 4 * HealpixManager.Nside;
                var points = new Point2[height * width];
                for (var y = 0; y < height; y++)
                {
                    for (var x = 0; x < width; x++)
                    {
                        // todo do not store points in memory
                        points[(y * width) + x] = new Point2(x, y);
                    }
                }
                return(points);
            }
            return(null);
        }
        public void GetMeanAltitude()
        {
            var man = new ApproximationManager(new HealpixManager(0));

            foreach (var pixel in man.Pixels)
            {
                pixel.Altitude = pixel.P;
            }
            Assert.AreEqual(4, man.GetMeanAltitude(new Coor {
                X = 90, Y = 0
            }));
            Assert.AreEqual(5, man.GetMeanAltitude(new Coor {
                X = 0, Y = 0
            }));

            Assert.AreEqual(1.5, man.GetMeanAltitude(new Coor {
                X = 0, Y = 70
            }));

            Assert.AreEqual(1.5, man.GetMeanAltitude(new Coor {
                X = 0, Y = 90
            }), .02);
            Assert.AreEqual(0, man.GetMeanAltitude(new Coor {
                X = 135, Y = 90
            }));
            Assert.AreEqual(0, man.GetMeanAltitude(new Coor {
                X = 135, Y = 80
            }));
            Assert.AreEqual(5.5, man.GetMeanAltitude(new Coor {
                X = 135, Y = 0
            }));

            Assert.AreEqual(0, man.GetMeanAltitude(new Coor {
                X = 135, Y = HealpixManagerTests.L41
            }), .1);
            Assert.AreEqual(1.3, man.GetMeanAltitude(new Coor {
                X = 135, Y = 10
            }), .1);
            Assert.AreEqual(1.8, man.GetMeanAltitude(new Coor {
                X = 135, Y = 1
            }), .1);

            Assert.AreEqual(3.6, man.GetMeanAltitude(new Coor {
                X = 0, Y = HealpixManagerTests.L41
            }), .1);

            // vertical border at left
            Assert.AreEqual(9.5, man.GetMeanAltitude(new Coor {
                X = 0, Y = -80
            }));
            Assert.AreEqual(9.9, man.GetMeanAltitude(new Coor {
                X = -170, Y = -80
            }), .1);
            Assert.AreEqual(11, man.GetMeanAltitude(new Coor {
                X = -135, Y = -89
            }), .1);
        }
        public void GetMeanDeltas()
        {
            var man = new ApproximationManager(new HealpixManager(3));

            Assert.AreEqual(7, man.GetMeanDeltas(new Coor {
                X = 0, Y = 41.8
            }), 1);
            Assert.AreEqual(7, man.GetMeanDeltas(new Coor {
                X = 0, Y = 42
            }), 1);

            Assert.AreEqual(12, man.GetMeanDeltas(new Coor {
                X = 0, Y = 60
            }), 1);
            Assert.AreEqual(9, man.GetMeanDeltas(new Coor {
                X = 0, Y = 50
            }), 1);
        }