本文整理汇总了C#中Stand类的典型用法代码示例。如果您正苦于以下问题:C# Stand类的具体用法?C# Stand怎么用?C# Stand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Stand类属于命名空间,在下文中一共展示了Stand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUnharvestedNeighbors
//---------------------------------------------------------------------
/// <summary>
/// Adds a stand's unharvested neighbors and their rankings to a
/// sorted list of stand rankings.
/// </summary>
/// <remarks>
/// The stand rankings are in highest to lowest order. A neighbor is
/// only added to the list if its rank is > 0 and it isn't already in
/// the list.
/// </remarks>
public void AddUnharvestedNeighbors(Stand stand,
List<StandRanking> neighborRankings)
{
foreach (Stand neighbor in stand.Neighbors) {
if (! neighbor.Harvested) {
bool inList = false;
foreach (StandRanking ranking in neighborRankings) {
if (ranking.Stand == neighbor) {
inList = true;
break;
}
}
if (inList)
continue;
StandRanking neighborRanking = GetRanking(neighbor);
if (neighborRanking.Rank <= 0)
continue;
int i;
for (i = 0; i < neighborRankings.Count; i++) {
if (neighborRankings[i].Rank < neighborRanking.Rank)
break;
}
neighborRankings.Insert(i, neighborRanking);
}
}
}
示例2:
//---------------------------------------------------------------------
//require that the stand wait a certain minimum time before being
//eligible for harvesting again.
bool IRequirement.MetBy(Stand stand)
{
//Model.Core.UI.WriteLine("stand {0} TimeLastHarvested = {1}", stand.MapCode, stand.TimeLastHarvested);
int time_since = Model.Core.CurrentTime - stand.TimeLastHarvested;
//Model.Core.UI.WriteLine("time_since stand {0} was harvested = {1}\n", stand.MapCode, time_since);
return time_since >= minTime;
}
示例3: AssignSiteToStand
//---------------------------------------------------------------------
/// <summary>
/// Assigns an active site to a particular stand.
/// </summary>
/// <param name="activeSite">
/// The active site that is being assigned to a stand.
/// </param>
/// <param name="mapCode">
/// The map code of the stand that the site is being assigned to.
/// </param>
public static void AssignSiteToStand(ActiveSite activeSite,
ushort mapCode)
{
double blockArea = (activeSite.SharesData ? Model.BlockArea : Model.Core.CellArea)
// Skip the site if its management area is not active.
if (SiteVars.ManagementArea[activeSite] == null)
return;
Stand stand;
//check if this stand is already in the dictionary
if (stands.TryGetValue(mapCode, out stand)) {
//if the stand is already in the dictionary, check if it is in the same management area.
//if it's not in the same MA, throw exception.
if (SiteVars.ManagementArea[activeSite] != stand.ManagementArea) {
throw new PixelException(activeSite.Location,
"Stand {0} is in management areas {1} and {2}",
stand.MapCode,
stand.ManagementArea.MapCode,
SiteVars.ManagementArea[activeSite].MapCode);
}
}
//valid site location which has not been keyed by the dictionary.
else {
//assign stand (trygetvalue set it to null when it wasn't found in the dictionary)
stand = new Stand(mapCode, blockArea);
//add this stand to the correct management area (pointed to by the site)
SiteVars.ManagementArea[activeSite].Add(stand);
stands[mapCode] = stand;
}
//add this site to this stand
stand.Add(activeSite);
}
示例4: ComputeRank
//---------------------------------------------------------------------
/// <summary>
/// Computes the rank for a stand.
/// </summary>
protected override double ComputeRank(Stand stand, int i)
{
SiteVars.ReInitialize();
//if (SiteVars.CFSFuelType == null)
// throw new System.ApplicationException("Error: CFS Fuel Type NOT Initialized. Fuel extension MUST be active.");
double standFireRisk = 0.0;
//Model.Core.UI.WriteLine("Base Harvest: EconomicRank.cs: ComputeRank: there are {0} sites in this stand.", stand.SiteCount);
foreach (ActiveSite site in stand) {
//double siteFireRisk = 0.0;
int fuelType = SiteVars.CFSFuelType[site];
//Model.Core.UI.WriteLine("Base Harvest: ComputeRank: FuelType = {0}.", fuelType);
FireRiskParameters rankingParameters = rankTable[fuelType];
standFireRisk = (double)rankingParameters.Rank;
//foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
//{
// FireRiskParameters rankingParameters = rankTable[speciesCohorts.Species];
// foreach (ICohort cohort in speciesCohorts) {
// if (rankingParameters.MinimumAge > 0 &&
// rankingParameters.MinimumAge <= cohort.Age)
// siteEconImportance += (double) rankingParameters.Rank / rankingParameters.MinimumAge * cohort.Age;
// }
//}
//standEconImportance += siteEconImportance;
}
standFireRisk /= stand.SiteCount;
return standFireRisk;
}
示例5: ReadMap
/// <summary>
/// Reads the input map of stands.
/// </summary>
/// <param name="path">
/// Path to the map.
/// </param>
public static void ReadMap(string path)
{
Dictionary<ushort, Stand> stands = new Dictionary<ushort, Stand>();
IInputRaster<MapCodePixel> map = Model.Core.OpenRaster<MapCodePixel>(path);
using (map) {
// TODO: make sure its dimensions match landscape's dimensions
foreach (Site site in Model.Core.Landscape.AllSites) {
MapCodePixel pixel = map.ReadPixel();
// Process the pixel only if the site is active and it's
// in an active management area.
if (site.IsActive && SiteVars.ManagementArea[site] != null) {
ushort mapCode = pixel.Band0;
Stand stand;
if (stands.TryGetValue(mapCode, out stand)) {
if (SiteVars.ManagementArea[site] != stand.ManagementArea)
throw new PixelException(site.Location,
"Stand {0} is in management areas {1} and {2}",
stand.MapCode,
stand.ManagementArea.MapCode,
SiteVars.ManagementArea[site].MapCode);
}
else {
stand = new Stand(mapCode);
SiteVars.ManagementArea[site].Add(stand);
stands[mapCode] = stand;
}
stand.Add((ActiveSite) site);
}
}
}
}
示例6: foreach
//---------------------------------------------------------------------
bool IRequirement.MetBy(Stand stand)
{
//PlugIn.ModelCore.UI.WriteLine("checking stand {0}", stand.MapCode);
//get list of neighboring stands (must cast from enum)
List<Stand> neighbor_stands = new List<Stand>();
neighbor_stands = (List<Stand>) stand.Neighbors;
//add ma_neighbors to this list as well, to check with all the neighboring stands that are in a different management area
foreach (Stand n_stand in stand.MaNeighbors) {
neighbor_stands.Add(n_stand);
}
//loop through neighbor stands (including ma_neighbors), if one is too young then return false
foreach (Stand n_stand in neighbor_stands) {
//if n_stand is too young, return false (breaking out of loop as soon as one neighbor fails)
if (type == "StandAge") {
if (n_stand.Age < time) {
return false;
}
}
//if type was mintimesincelastharvest
else {
if (n_stand.TimeSinceLastHarvested < time) {
//PlugIn.ModelCore.UI.WriteLine("stand {0} NOT ranked.", stand.MapCode);
return false;
}
}
}
return true;
}
示例7: ReadMap
/// <summary>
/// Reads the input map of stands.
/// </summary>
/// <param name="path">
/// Path to the map.
/// </param>
public static void ReadMap(string path)
{
Stand stand;
Dictionary<uint, Stand> stands = new Dictionary<uint, Stand>();
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);
}
using (map) {
UIntPixel pixel = map.BufferPixel;
foreach (Site site in Model.Core.Landscape.AllSites)
{
map.ReadBufferPixel();
uint mapCode = pixel.MapCode.Value;
if (site.IsActive && SiteVars.ManagementArea[site] != null)
{
if (stands.TryGetValue(mapCode, out stand)) {
//if the stand is already in the dictionary, check if it is in the same management area.
//if it's not in the same MA, throw exception.
if (SiteVars.ManagementArea[site] != stand.ManagementArea) {
string mesg = string.Format("Stand {0} is in management areas {1} and {2}",
stand.MapCode,
stand.ManagementArea.MapCode,
SiteVars.ManagementArea[site].MapCode);
throw new System.ApplicationException(mesg);
}
}
//valid site location which has not been keyed by the dictionary.
else {
//assign stand (trygetvalue set it to null when it wasn't found in the dictionary)
stand = new Stand(mapCode);
//add this stand to the correct management area (pointed to by the site)
SiteVars.ManagementArea[site].Add(stand);
stands[mapCode] = stand;
}
//add this site to this stand
stand.Add((ActiveSite) site);
}
}
}
}
示例8:
//---------------------------------------------------------------------
//mark the whole area selected as harvested
IEnumerable<ActiveSite> ISiteSelector.SelectSites(Stand stand)
{
areaSelected = stand.ActiveArea;
stand.MarkAsHarvested();
//mark this stand's event id
stand.EventId = EventId.MakeNewId();
return stand;
}
示例9: GetRanking
//---------------------------------------------------------------------
/// <summary>
/// Gets the ranking for an unharvested stand from among the whole set
/// of stand rankings.
/// </summary>
public StandRanking GetRanking(Stand stand)
{
// Search backward through the stand rankings because unharvested
// stands are at the end of the list.
for (int i = rankings.Length - 1; i >= 0; i--) {
if (rankings[i].Stand == stand)
return rankings[i];
}
throw new System.ApplicationException("ERROR: Stand not found in rankings");
}
示例10: Harvest
//---------------------------------------------------------------------
/// <summary>
/// Harvests a stand (and possibly its neighbors) according to the
/// repeat-harvest's site-selection method.
/// </summary>
/// <returns>
/// The area that was harvested (units: hectares).
/// </returns>
public override double Harvest(Stand stand)
{
double areaHarvested = base.Harvest(stand);
harvestedStands.Clear();
harvestedStands.Add(stand);
if (spreadingSiteSelector != null)
harvestedStands.AddRange(spreadingSiteSelector.HarvestedNeighbors);
return areaHarvested;
}
示例11: SelectSites
//---------------------------------------------------------------------
public IEnumerable<ActiveSite> SelectSites(Stand stand)
{
foreach (ActiveSite activeSite in originalSelector.SelectSites(stand)) {
yield return activeSite;
// At this point, a prescription is done harvesting the
// site with age-only cohort selectors. See if any
// specific-age cohort selectors have flagged some cohorts
// for partial thinning.
PartialHarvestDisturbance.ReduceCohortBiomass(activeSite);
}
}
示例12:
//---------------------------------------------------------------------
//mark the whole area selected as harvested
IEnumerable<ActiveSite> ISiteSelector.SelectSites(Stand stand)
{
areaSelected = stand.ActiveArea;
stand.MarkAsHarvested();
//mark this stand's event id
stand.EventId = PlugIn.EventId;
//increment global event id number
PlugIn.EventId++;
return stand;
}
示例13: Harvest
//---------------------------------------------------------------------
/// <summary>
/// Harvests a stand (and possibly its neighbors) according to the
/// repeat-harvest's site-selection method.
/// </summary>
/// <returns>
/// The area that was harvested (units: hectares).
/// </returns>
public override double Harvest(Stand stand)
{
if (stand.IsSetAside) {
CohortSelector = additionalCohortSelector;
SpeciesToPlant = additionalSpeciesToPlant;
}
else {
CohortSelector = initialCohortSelector;
SpeciesToPlant = initialSpeciesToPlant;
}
return base.Harvest(stand);
}
示例14: foreach
//---------------------------------------------------------------------
IEnumerable<ActiveSite> ISiteSelector.SelectSites(Stand stand)
{
IEnumerable<ActiveSite> selectedSites = (IEnumerable<ActiveSite>) baseClassSelectSites.Invoke(this, new object[] {stand});
foreach (ActiveSite activeSite in selectedSites) {
yield return activeSite;
// At this point, a prescription is done harvesting the
// site with age-only cohort selectors. See if any
// specific-age cohort selectors have flagged some cohorts
// for partial thinning.
PartialHarvestDisturbance.ReduceCohortBiomass(activeSite, stand);
}
}
示例15: SelectSites
//---------------------------------------------------------------------
public IEnumerable<ActiveSite> SelectSites(Stand stand)
{
//PlugIn.ModelCore.Log.WriteLine("Site Selector Wrapper");
foreach (ActiveSite activeSite in originalSelector.SelectSites(stand)) {
// At this point, a prescription is done harvesting the
// site with age-only cohort selectors. See if any
// specific-age cohort selectors have flagged some cohorts
// for partial thinning.
PartialHarvestDisturbance.ReduceCohortBiomass(activeSite, stand);
yield return activeSite;
}
}