The growth calculator can also be used to apply treatments to a compartment during the growth simulation. This is useful both for updating stand register data (ajpourhållning) where, for example, harvesting has been done but the register data not updated. The feature is also intended for planning purposes.
Use the following syntax to set up a collection of treatments to perform:
| Growing a compartment with treatments |
Copy Code |
|---|---|
//Create a container for treatments var growthCalculator = new GrowthCalculator(); compartment.GrowthCalculator = gc; // Passing the ApiCompartment object to the constructor is optional, but has the advantage that you can control // how default treatments are set up. You must have assigned a GrowthCalculator to the compartment object for this to work. var treatments = new ApiTreatmentList(compartment); //Perform a thinning January 1st, 2015. Some treatments require additional info, like minimum diameter to thin and thinning intensity in this case treatments.AddTreatment( TreatmentType.Thinning, new DateTime(2015, 1, 1), new Treatment.CuttingTreatmentDetails(10, false, ThinningSystem.NotSpecified, 0.35)); // Alternatively, you can add a treatment using default settings. If you have passed an ApiCompartment to the ApiTreatmentList constructor, and assigned a GrowthCalculator to the compartment , // treatment.AddTreatment(TreatmentType.Thinning, new DateTime(2015, 1, 1)); //Grow to the year 2030, performing the treatments on the way ApiState result = compartment.Grow(treatments, new DateTime(2030, 1, 1)); | |
Viewing/using treatment results
All functions for growing a compartment discussed above, return an ApiState holding data of the most recent state. If the compartment was grown with treatments, every intermediate state, both before and after the treatment, is also stored in the compartment. Use the property ProjectedStates to access these:
| Example of how to use ProjectedStates |
Copy Code |
|---|---|
double total = 0; //Loop over all states with Before == false, which means that they are states AFTER a treatment foreach(var state in compartment.ProjectedStates.Where(s => !s.Before && s.Date == theDate)) { //If this is an "After" state, the ApiState holds the TreatmentData for the treatment. //Sum all stems cut in all treatments total += state.TreatmentData.StemsCutTotal; } | |