Exemple #1
0
        public void CalcGridStatsAndExposures_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\Findlay.cfm";

            thisInst.Open(Filename);
            thisInst.topo.GetElevsAndSRDH_ForCalcs(thisInst, null, false);

            Nodes newNode = new Nodes();

            newNode.gridStats = new Grid_Info();
            newNode.UTMX      = 280000;
            newNode.UTMY      = 4550000;

            Check_class check = new Check_class();
            int         isOk  = check.NewNodeCheck(thisInst.topo, newNode.UTMX, newNode.UTMY, 10000, "Calcs");

            newNode.CalcGridStatsAndExposures(thisInst);

            Assert.AreNotSame(newNode.expo, null, "Didn't calculate exposures");
            Assert.AreNotSame(newNode.gridStats, null, "Didn't calculate grid stats");
            Assert.AreNotSame(newNode.expo[0].expo, null, "Didn't calculate exposures");
            Assert.AreNotSame(newNode.expo[0].SR, null, "Didn't calculate roughness");
            Assert.AreNotSame(newNode.expo[0].dispH, null, "Didn't calculate displacement height");
            Assert.AreNotSame(newNode.gridStats.stats, null, "Didn't calculate grid stats");

            thisInst.Close();
        }
        public void LandCoverCheck_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\TopoCheck model.cfm";

            thisInst.Open(Filename);

            Check_class check     = new Check_class();
            string      allOrPlot = "Plot";

            bool isOk = check.LandCoverCheck(thisInst.topo, 682000, 4709000, "Test 1", false);

            Assert.AreEqual(isOk, true, "Wrong TopoCheck Test 1");

            isOk = check.LandCoverCheck(thisInst.topo, 682000, 4716600, "Test 2", false);
            Assert.AreEqual(isOk, false, "Wrong TopoCheck Test 2");

            isOk = check.LandCoverCheck(thisInst.topo, 1077700, 4674500, "Test 3", false);
            Assert.AreEqual(isOk, true, "Wrong TopoCheck Test 3");

            isOk = check.LandCoverCheck(thisInst.topo, 1083650, 4674000, "Test 4", false);
            Assert.AreEqual(isOk, false, "Wrong TopoCheck Test 4");

            thisInst.Close();
        }
        public void TopoCheck_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\TopoCheck model.cfm";

            thisInst.Open(Filename);

            Check_class check     = new Check_class();
            string      allOrPlot = "Plot";

            bool isOk = check.TopoCheck(thisInst.topo, 850000, 4500000, "Test 1", false);

            Assert.AreEqual(isOk, true, "Wrong TopoCheck Test 1");

            isOk = check.TopoCheck(thisInst.topo, 684480, 4663890, "Test 2", false);
            Assert.AreEqual(isOk, false, "Wrong TopoCheck Test 2");

            isOk = check.TopoCheck(thisInst.topo, 1053800, 4350000, "Test 3", false);
            Assert.AreEqual(isOk, false, "Wrong TopoCheck Test 3");

            isOk = check.TopoCheck(thisInst.topo, 688300, 4335000, "Test 4", false);
            Assert.AreEqual(isOk, true, "Wrong TopoCheck Test 4");

            isOk = check.TopoCheck(thisInst.topo, 1034000, 4677000, "Test 5", false);
            Assert.AreEqual(isOk, false, "Wrong TopoCheck Test 5");

            thisInst.Close();
        }
        public void IsGeoTiff_Test()
        {
            // Opens a GeoTiff with elevation data. IsGeoTiff should return true. Then opens Tiff with color RGB values. IsGeoTiff should return false
            string goodTiffName = testingFolder + "Findlay Topo.tif";
            string badTiffName  = testingFolder + "DEM JM.tif";

            TopoInfo    topo  = new TopoInfo();
            Check_class check = new Check_class();

            GdalConfiguration.ConfigureGdal();
            Gdal.AllRegister();
            Dataset GDAL_obj;

            // Test function with GeoTiff file
            try
            {
                GDAL_obj = Gdal.Open(goodTiffName, Access.GA_ReadOnly);
            }
            catch
            {
                return;
            }

            int width  = GDAL_obj.RasterXSize;
            int height = GDAL_obj.RasterYSize;

            Band GD_Raster = GDAL_obj.GetRasterBand(1);

            double[] buff = new double[width * height];
            GD_Raster.ReadRaster(0, 0, width, height, buff, width, height, 0, 0);

            bool isGeoTiff = check.IsGeoTIFF(buff);

            Assert.AreSame(true, isGeoTiff);

            // Test function with a TIF (color RGB) file
            try
            {
                GDAL_obj = Gdal.Open(goodTiffName, Access.GA_ReadOnly);
            }
            catch
            {
                return;
            }

            width  = GDAL_obj.RasterXSize;
            height = GDAL_obj.RasterYSize;

            GD_Raster = GDAL_obj.GetRasterBand(1);

            buff = new double[width * height];
            GD_Raster.ReadRaster(0, 0, width, height, buff, width, height, 0, 0);

            isGeoTiff = check.IsGeoTIFF(buff);
            Assert.AreSame(false, isGeoTiff);
        }
Exemple #5
0
        public void ExportNodesInSector(Continuum thisInst, Nodes startNode, int reso, double minDir, double maxDir, int minRadius, int maxRadius, string exportFile)
        {
            NodeCollection nodeList = new NodeCollection();
            Nodes          thisNode = new Nodes();
            Check_class    check    = new Check_class();

            StreamWriter sw = new StreamWriter(exportFile);

            // Adjust maxDir if it is less than minDir (i.e. if it crosses over 0 degs)
            if (maxDir < minDir)
            {
                maxDir = maxDir + 360;
            }

            // Do polar coordinate sweep and find node at each angle and radius. Find node with highest elevation
            for (double i = minDir; i <= maxDir; i++)
            {
                for (double j = minRadius; j <= maxRadius; j = j + reso)
                {
                    thisNode.UTMX = startNode.UTMX + j * Math.Cos((90 - i) * Math.PI / 180);
                    thisNode.UTMY = startNode.UTMY + j * Math.Sin((90 - i) * Math.PI / 180);

                    // Find closest nodes on fixed grid
                    TopoInfo.TopoGrid closestNode = thisInst.topo.GetClosestNodeFixedGrid(thisNode.UTMX, thisNode.UTMY, 250, 12000);
                    thisNode.UTMX = closestNode.UTMX;
                    thisNode.UTMY = closestNode.UTMY;

                    int newOk = check.NewNodeCheck(thisInst.topo, thisNode.UTMX, thisNode.UTMY, 10000, "Calcs");

                    if (newOk == 100)
                    {
                        thisNode.elev = thisInst.topo.CalcElevs(thisNode.UTMX, thisNode.UTMY);
                        sw.WriteLine(thisNode.UTMX + "," + thisNode.UTMY + "," + thisNode.elev);
                    }
                }
            }

            sw.Close();
        }