//---------------------------------------------------------------------
        static DisturbedSites()
        {
            // columns:    123456789
            string[] rows = new string[]{ "---------",    // row 1
                                          "---aaDa--",    // row 2
                                          "--aDDaa--",    // row 3
                                          "--aaaaaa-",    // row 4
                                          "-aaa--DD-",    // row 5
                                          "-Da---aaa",    // row 6
                                          "--aa--D--"};   // row 7
            bool[,] array = Bool.Make2DimArray(rows, "aD");
            int rowCount = array.GetLength(0);
            int colCount = array.GetLength(1);
            DataGrid<EcoregionCode> grid = new DataGrid<EcoregionCode>(rowCount, colCount);
            for (int row = 1; row <= rowCount; row++) {
                for (int col = 1; col <= colCount; col++) {
                    if (array[row-1, col-1])
                        grid[row, col] = new EcoregionCode(1, true);
                    else
                        grid[row, col] = new EcoregionCode(0, false);
                }
            }
            mixedLandscape = new Landscape(grid, 1);

            List<Location> locList = new List<Location>();
            foreach (ActiveSite site in mixedLandscape) {
                int row = site.Location.Row;
                int column = site.Location.Column;
                if (rows[row-1][column-1] == 'D')
                    locList.Add(site.Location);
            }
            locations = locList.ToArray();
        }
        public void Init()
        {
            EcoregionCode[,] array = new EcoregionCode[0,0];
            DataGrid<EcoregionCode> grid = new DataGrid<EcoregionCode>(array);
            landscape = new Landscape(grid, 1);

            siteVarRegistry = new SiteVarRegistry();
        }
        public void Init()
        {
            EcoregionCode[,] array = new EcoregionCode[0, 0];
            DataGrid <EcoregionCode> grid = new DataGrid <EcoregionCode>(array);

            landscape = new Landscape(grid, 1);

            siteVarRegistry = new SiteVarRegistry();
        }
Esempio n. 4
0
        //---------------------------------------------------------------------

        public static ILandscape Make1by1Landscape()
        {
            EcoregionCode[,] grid = new EcoregionCode[, ] {
                { new EcoregionCode(1, true) }
            };
            DataGrid <EcoregionCode> dataGrid = new DataGrid <EcoregionCode>(grid);

            return(new Landscape(dataGrid, 1));
        }
Esempio n. 5
0
 // Generate a 2-D array of ecoregion codes from an 2-D int array.
 // Negative integers are considered inactive ecoregion codes (code =
 // absolute value of the negative integer).
 public static EcoregionCode[,] MakeEcoregionCodes(int[,] ecoregions)
 {
     int rows = ecoregions.GetLength(0);
     int columns = ecoregions.GetLength(1);
     EcoregionCode[,] codes = new EcoregionCode[rows, columns];
     for (int row = 0; row < rows; row++) {
         for (int column = 0; column < columns; column++) {
             int code = ecoregions[row, column];
             if (code < 0)
                 codes[row, column] = new EcoregionCode((ushort) -code, false);
             else
                 codes[row, column] = new EcoregionCode((ushort) code, true);
         }
     }
     return codes;
 }
Esempio n. 6
0
        //---------------------------------------------------------------------

        static DisturbedSites()
        {
            // columns:    123456789
            string[] rows = new string[] { "---------",   // row 1
                                           "---aaDa--",   // row 2
                                           "--aDDaa--",   // row 3
                                           "--aaaaaa-",   // row 4
                                           "-aaa--DD-",   // row 5
                                           "-Da---aaa",   // row 6
                                           "--aa--D--" }; // row 7
            bool[,] array = Bool.Make2DimArray(rows, "aD");
            int rowCount = array.GetLength(0);
            int colCount = array.GetLength(1);
            DataGrid <EcoregionCode> grid = new DataGrid <EcoregionCode>(rowCount, colCount);

            for (int row = 1; row <= rowCount; row++)
            {
                for (int col = 1; col <= colCount; col++)
                {
                    if (array[row - 1, col - 1])
                    {
                        grid[row, col] = new EcoregionCode(1, true);
                    }
                    else
                    {
                        grid[row, col] = new EcoregionCode(0, false);
                    }
                }
            }
            mixedLandscape = new Landscape(grid, 1);

            List <Location> locList = new List <Location>();

            foreach (ActiveSite site in mixedLandscape)
            {
                int row    = site.Location.Row;
                int column = site.Location.Column;
                if (rows[row - 1][column - 1] == 'D')
                {
                    locList.Add(site.Location);
                }
            }
            locations = locList.ToArray();
        }
Esempio n. 7
0
        public void Map16Bit()
        {
            Map map = new Map(path16Bit, dataset, rasterDriverMgr);

            using (IInputGrid <EcoregionCode> inputGrid = map.OpenAsInputGrid()) {
                Assert.AreEqual(dims16Bit.Rows, inputGrid.Dimensions.Rows);
                Assert.AreEqual(dims16Bit.Columns, inputGrid.Dimensions.Columns);

                for (int row = 0; row < dims16Bit.Rows; ++row)
                {
                    for (int column = 0; column < dims16Bit.Columns; ++column)
                    {
                        ushort        mapCode       = ecoregions16Bit[row, column];
                        IEcoregion    ecoregion     = dataset.Find(mapCode);
                        EcoregionCode ecoregionCode = inputGrid.ReadValue();
                        Assert.AreEqual(mapCode, (int)ecoregionCode);
                        Assert.AreEqual(ecoregion.Active, ecoregionCode.IsActive);
                    }
                }
            }
        }
Esempio n. 8
0
        //---------------------------------------------------------------------

        // Generate a 2-D array of ecoregion codes from an 2-D int array.
        // Negative integers are considered inactive ecoregion codes (code =
        // absolute value of the negative integer).
        public static EcoregionCode[,] MakeEcoregionCodes(int[,] ecoregions)
        {
            int rows    = ecoregions.GetLength(0);
            int columns = ecoregions.GetLength(1);

            EcoregionCode[,] codes = new EcoregionCode[rows, columns];
            for (int row = 0; row < rows; row++)
            {
                for (int column = 0; column < columns; column++)
                {
                    int code = ecoregions[row, column];
                    if (code < 0)
                    {
                        codes[row, column] = new EcoregionCode((ushort)-code, false);
                    }
                    else
                    {
                        codes[row, column] = new EcoregionCode((ushort)code, true);
                    }
                }
            }
            return(codes);
        }
Esempio n. 9
0
        //---------------------------------------------------------------------

        public static ILandscape Make1by1Landscape()
        {
            EcoregionCode[,] grid = new EcoregionCode[,]{ {new EcoregionCode(1, true)} };
            DataGrid<EcoregionCode> dataGrid = new DataGrid<EcoregionCode>(grid);
            return new Landscape(dataGrid, 1);
        }