Exemplo n.º 1
0
        /// <summary>
        /// Reads the input map of management areas.
        /// </summary>
        /// <param name="path">
        /// Path to the map.
        /// </param>
        /// <param name="managementAreas">
        /// Management areas that have prescriptions applied to them.
        /// </param>
        public static void ReadMap(string path,
                                   IManagementAreaDataset managementAreas)
        {
            IInputRaster <UIntPixel> map;

            try {
                map = Model.Core.OpenRaster <UIntPixel>(path);
            }
            catch (FileNotFoundException) {
                string mesg = string.Format("Error: The file {0} does not exist", path);
                throw new System.ApplicationException(mesg);
            }

            if (map.Dimensions != Model.Core.Landscape.Dimensions)
            {
                string mesg = string.Format("Error: The input map {0} does not have the same dimension (row, column) as the ecoregions map", path);
                throw new System.ApplicationException(mesg);
            }

            List <uint> inactiveMgmtAreas = new List <uint>();

            using (map) {
                UIntPixel pixel = map.BufferPixel;
                foreach (Site site in Model.Core.Landscape.AllSites)
                {
                    map.ReadBufferPixel();
                    if (site.IsActive)
                    {
                        uint           mapCode  = pixel.MapCode.Value;
                        ManagementArea mgmtArea = managementAreas.Find(mapCode);
                        if (mgmtArea == null)
                        {
                            if (!inactiveMgmtAreas.Contains(mapCode))
                            {
                                inactiveMgmtAreas.Add(mapCode);
                            }
                        }
                        else
                        {
                            mgmtArea.OnMap = true;
                            SiteVars.ManagementArea[site] = mgmtArea;
                        }
                    }
                }
            }

            // Inform user about non-active areas: those that don't have any
            // applied prescriptions.
            if (inactiveMgmtAreas.Count > 0)
            {
                Model.Core.UI.WriteLine("   Inactive management areas: {0}",
                                        MapCodesToString(inactiveMgmtAreas));
            }
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------

        /// <summary>
        /// A new Stand Object, given a map code
        /// </summary>
        public Stand(uint mapCode)
        {
            this.mapCode           = mapCode;
            this.siteLocations     = new List <Location>();
            this.activeArea        = Model.Core.CellArea;
            this.mgmtArea          = null;
            this.neighbors         = new List <Stand>();
            this.ma_neighbors      = new List <Stand>(); //new list for neighbors not in this management area
            this.yearAgeComputed   = Model.Core.StartTime;
            this.setAsideUntil     = Model.Core.StartTime;
            this.timeLastHarvested = -1;
            //initialize damage_table dictionary
            damage_table = new Dictionary <string, int>();
            this.rejectedPrescriptionNames = new List <string>();
        }
        //---------------------------------------------------------------------

        /// <summary>
        /// Adds a new management area to the dataset.
        /// </summary>
        public void Add(ManagementArea mgmtArea)
        {
            Require.ArgumentNotNull(mgmtArea);
            mgmtAreas[mgmtArea.MapCode] = mgmtArea;
        }