//--------------------------------------------------------------------- public static void AgeOrRangeWasRead(AgeRange ageRange, Percentage percentage) { ageOrRangeWasRead = true; // Have we started reading ages and ranges for another species? // If so, then first clear the old values from the previous // species. if (ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] == null) { ages.Clear(); ranges.Clear(); percentages.Clear(); } if (ageRange.Start == ageRange.End) ages.Add(ageRange.Start); else ranges.Add(ageRange); if (percentage != null) percentages[ageRange.Start] = percentage; if (HarvestSpeciesDataset.MostRecentlyFetchedSpecies != null) ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] = new SpecificAgesCohortSelector(ages, ranges, percentages); currentSpecies = HarvestSpeciesDataset.MostRecentlyFetchedSpecies; }
//--------------------------------------------------------------------- public static void AgeOrRangeWasRead(AgeRange ageRange, Percentage percentage) { ageOrRangeWasRead = true; // Have we started reading ages and ranges for another species? // If so, then first clear the old values from the previous // species. bool clearOldValues = (HarvestSpeciesDataset.MostRecentlyFetchedSpecies != null) && (ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] == null); if (clearOldValues) { ages.Clear(); ranges.Clear(); percentages.Clear(); } if (ageRange.Start == ageRange.End) ages.Add(ageRange.Start); else ranges.Add(ageRange); if (percentage != null) percentages[ageRange.Start] = percentage; if (Landis.Extension.BaseHarvest.InputParametersParser.AllSpeciesNameWasRead) ageSelectorForAllSpecies = new SpecificAgesCohortSelector(ages, ranges, percentages); if (HarvestSpeciesDataset.MostRecentlyFetchedSpecies != null) ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] = new SpecificAgesCohortSelector(ages, ranges, percentages); currentSpecies = HarvestSpeciesDataset.MostRecentlyFetchedSpecies; }
//--------------------------------------------------------------------- /// <summary> /// constructor, assign members of the stucture /// </summary> public InclusionRule(string inclusion_type, AgeRange age_range, string temp_percent, List<string> species_list) { //assign members of the struct this.inclusion_type = inclusion_type; this.age_range = age_range; //check for type 'percentage' by looking for the % character string [] split = temp_percent.Split(new char [] {'%'}); //try to make a percentage. if this doesn't work then check for keyword 'highest' try { percentOfCells = ((double) Convert.ToInt32(split[0])) / 100; } catch (Exception) { //and set percentOfCells to -1 (the flag for InclusionRequirement to handle) percentOfCells = -1; } this.species_list = species_list; //get the species index list using species name this.species_index_list = new List<int>(); foreach (string species in species_list) { if (PlugIn.ModelCore.Species[species] != null) { this.species_index_list.Add(PlugIn.ModelCore.Species[species].Index); } } //PlugIn.ModelCore.UI.WriteLine("species index = {0}", this.species_index); }
//--------------------------------------------------------------------- /// <summary> /// Does the range overlap another range? /// </summary> public bool Overlaps(AgeRange other) { return Contains(other.Start) || other.Contains(start); }