Landis.Extension.BaseHarvest.Prescription.Harvest C# (CSharp) Method

Harvest() public method

Harvests a stand (and possibly its neighbors) according to the prescription's site-selection method.
public Harvest ( Stand stand ) : void
stand Stand
return void
        public virtual void Harvest(Stand stand)
        {
            if (isDebugEnabled)
                log.DebugFormat("  Prescription {0} is harvesting stand {1}", this.Name, stand.MapCode);

            //set prescription name for stand
            stand.PrescriptionName = this.Name;
            stand.HarvestedRank = PlugIn.CurrentRank;
            stand.LastPrescription = this;
            
            stand.MinTimeSinceDamage = this.minTimeSinceDamage;
            
            //set current stand
            currentStand = stand;
            currentStand.ClearDamageTable();

            // SelectSites(stand) is where either complete, complete stand spreading, or partial stand
            // spreading are activated.
            // tjs - This is what gets the sites that will be harvested
           

            foreach (ActiveSite site in siteSelector.SelectSites(stand)) {
                currentSite = site;

                SiteVars.Cohorts[site].RemoveMarkedCohorts(this);         

                //  In order for easement prescriptions to properly "spread", we need to count
                //  each site in its area harvested even if no cohorts are damaged.
                //if (SiteVars.CohortsDamaged[site] > 0)
                {
                    stand.LastAreaHarvested += PlugIn.ModelCore.CellArea;
                }    

                //  With land-use, a prescription doesn't necessarily damage a site's cohorts
                //  (for example, an easement prescription).  So, always assign the current
                //  prescription to the site, regardless if any cohorts were damaged.  This
                //  will cause the prescription to appear on the timestep's prescription map.
                SiteVars.Prescription[site] = this;

                if (speciesToPlant != null)
                    Reproduction.ScheduleForPlanting(speciesToPlant, site);

                if (landUseAfterHarvest != null)
                {
                    if (isDebugEnabled)
                    {
                        string landUseBefore = (LandUse.SiteVar[site] == null) ? "(null)" : LandUse.SiteVar[site].Name;
                        log.DebugFormat("    site {0}, land use: {1} --> {2}", site, landUseBefore, landUseAfterHarvest.Name);
                        if (landUseBefore != "forest")
                            log.DebugFormat("     stand rank = {0}", stand.Rank);
                    }
                    LandUse.SiteVar[site] = landUseAfterHarvest;

                    // Now that the site's land-use has changed, set its stand aside for the rest
                    // of the scenario.  Note: because of stand-spreading algorithm, the site may
                    // not belong to the stand that this method was called with.
                    SiteVars.Stand[site].SetAsideUntil(PlugIn.ModelCore.EndTime + 1);
                }
            } 
            return; 
        }