protected override void LogYear(Model model, SqliteCommand insertRow) { if (this.mYearFilter.IsEmpty == false) { if (this.mYearFilter.Evaluate(model.CurrentYear) == 0.0) { return; } } foreach (ResourceUnit ru in model.Landscape.ResourceUnits) { if (ru.EnvironmentID == -1) { continue; // do not include if out of project area } foreach (ResourceUnitTreeSpecies ruSpecies in ru.Trees.SpeciesAvailableOnResourceUnit) { ResourceUnitTreeStatistics speciesStats = ruSpecies.Statistics; if (speciesStats.TreeCount == 0 && speciesStats.CohortCount == 0) { continue; } insertRow.Parameters[0].Value = model.CurrentYear; insertRow.Parameters[1].Value = ru.ResourceUnitGridIndex; insertRow.Parameters[2].Value = ru.EnvironmentID; insertRow.Parameters[3].Value = ruSpecies.Species.ID; insertRow.Parameters[4].Value = ru.AreaInLandscape / Constant.RUArea; // keys // insertRow.Parameters[4].Value = ru.boundingBox().center().x() << ru.boundingBox().center().y(); // temp insertRow.Parameters[5].Value = speciesStats.TreeCount; insertRow.Parameters[6].Value = speciesStats.AverageDbh; insertRow.Parameters[7].Value = speciesStats.AverageHeight; insertRow.Parameters[8].Value = speciesStats.StemVolume; insertRow.Parameters[9].Value = speciesStats.GetTotalCarbon(); insertRow.Parameters[10].Value = speciesStats.LiveAndSnagStemVolume; insertRow.Parameters[11].Value = speciesStats.BasalArea; insertRow.Parameters[12].Value = speciesStats.TreeNpp; insertRow.Parameters[13].Value = speciesStats.TreeNppAboveground; insertRow.Parameters[14].Value = speciesStats.LeafAreaIndex; insertRow.Parameters[15].Value = speciesStats.CohortCount; insertRow.ExecuteNonQuery(); } } }
public void AddResourceUnit(ResourceUnit ru, ResourceUnitTreeStatistics ruSpeciesStats) { if (ruSpeciesStats.IsPerHectare == false) { throw new ArgumentOutOfRangeException(nameof(ruSpeciesStats), "Attempt to aggregate species statistics which are not per hectare."); } this.totalAreaInLandscape += ru.AreaInLandscape; this.totalAreaWithTrees += ru.AreaWithTrees; this.AverageDbh += ruSpeciesStats.AverageDbh * ru.AreaInLandscape; this.AverageHeight += ruSpeciesStats.AverageHeight * ru.AreaInLandscape; this.BasalArea += ruSpeciesStats.BasalArea * ru.AreaInLandscape; this.CohortCount += ruSpeciesStats.CohortCount * ru.AreaInLandscape; this.LeafAreaIndex += ruSpeciesStats.LeafArea; this.LiveAndSnagStemVolume += ruSpeciesStats.LiveAndSnagStemVolume * ru.AreaInLandscape; this.LiveStemVolume += ruSpeciesStats.StemVolume * ru.AreaInLandscape; this.TreeCount += ruSpeciesStats.TreeCount * ru.AreaInLandscape; this.TotalCarbon += ruSpeciesStats.GetTotalCarbon() * ru.AreaInLandscape; this.TreeNpp += ruSpeciesStats.TreeNpp * ru.AreaInLandscape; this.TreeNppAboveground += ruSpeciesStats.TreeNppAboveground * ru.AreaInLandscape; }