ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
Landscape Class Reference

The landscape class containing all environmental and topographical data. More...

#include <Landscape.h>

Public Member Functions

vector< vector< int > > CalculateMaskCorners (int a_centroid_x, int a_centroid_y, int a_half_width)
 The function to calculate the corners of mask(s) for the given centroid and half-width with wrapping around. More...
 
void GenerateCellLocDict ()
 The function to create the dictionary of cell locations for every polygon. More...
 
void GeneratePolyIDMapWithinDist ()
 The function to find all the polygons within the a certain distance to each location. More...
 
std::vector< APointSupplyLocsVectorPoly (int a_poly_id)
 The function to get the vector of all the locations for the given poly ID. More...
 
APoint SupplyARandomLocPoly (int a_poly_id)
 The function to get a random location for the given poly ID. More...
 
APoint SupplyARandomLocPollenPoly (int a_poly_id)
 The function to get a random location with pollen available for the given polygon. More...
 
APoint SupplyARandomLocNectarPoly (int a_poly_id)
 The function to get a random location with nectar available for the given polygon. More...
 
APoint SupplyARandomLocResourcePoly (int a_poly_id, std::map< int, int > &a_index_locs, std::map< int, vector< APoint >> &a_poly_cell_locs, Eigen::MatrixXf &a_prop_map)
 The function to get a random location for the given resource and the given poly ID. More...
 
double SupplyPollenAtLocInPoly (int a_poly_id, APoint a_start_loc, double a_required_amount, vector< APoint > *a_locs, vector< double > *a_pest_vec)
 The function to get the given pollen in the give location in the polygon ID, the locations for the required amount of pollen are stored in a_locs, the pesticide residue are stored in a_pest_vet, the foraged amount of pollen are returned. More...
 
double SupplyNectarAtLocInPoly (int a_poly_id, APoint a_start_loc, double a_required_amount, vector< APoint > *a_locs, vector< double > *a_pest_vec)
 The function to get the given nectar in the given location in the polygon ID, the locations for the required amount of nectar are stored in a_locs, the pesticide residue are stored in a_pest_vet, the foraged amount of nectar are returned. More...
 
double SupplyResourceAtLocInPoly (int a_poly_id, APoint a_start_loc, double a_required_amount, vector< APoint > *a_locs, vector< double > *a_pest_vec, Eigen::MatrixXf &a_resource_map, int a_num_avail_cell, PollenNectarData a_resource_data, bool a_is_pollen)
 The function to get the given amount of the required resource for the given location, the function returns the foraged amount. More...
 
void ResetFlowerLocIndex (void)
 The function to reset the index for the indices of the locations with flower resource. More...
 
PollenNectarData SupplyPollenHabitatType (int a_habitat_type)
 Supply the pollen of the current day for the given habitat type. More...
 
PollenNectarData SupplyNectarHabitatType (int a_habitat_type)
 Supply the nectar of the current day for the given habitat type. More...
 
void SetPollenMap (int a_poly_id, double a_pollen_quantity, int a_min_x, int a_min_y, int a_max_x, int a_max_y)
 The function to set the pollen quantity for all the cells that belong to the given polygon ID. More...
 
void SetNectarMap (int a_poly_id, double a_nectar_quantity, int a_min_x, int a_min_y, int a_max_x, int a_max_y)
 The function to set the nectar quantity for all the cells that belong to the given polygon ID. More...
 
void SetGreenBiomassMap (int a_poly_id, double a_green_biomass, int a_min_x, int a_min_y, int a_max_x, int a_max_y)
 The function to set the green biomass (in kg) for all the cells that belong to the given polygon ID. Used to scale the transfer of pesticide into the plant. More...
 
double SupplyLocMaxPollen (int &a_peak_loc_x, int &a_peak_loc_y, int a_min_x, int a_min_y, int a_max_x, int a_max_y, int a_incr=1)
 Supply the location with the maximum pollen amount location for the given area. More...
 
double SupplyLocMaxNectar (int &a_peak_loc_x, int &a_peak_loc_y, int a_min_x, int a_min_y, int a_max_x, int a_max_y, int a_incr=1)
 Supply the location with the maximum nectar amount location for the given area. More...
 
void RunHiddenYear ()
 The function to generate the vector list of pixies for polygons with flower resource. More...
 
void FillVegAreaData ()
 Runs through all polygons and records the area of each vegetation type. More...
 
double SupplyVegArea (int v)
 Records all area vegetation types and transform it into a table. More...
 
void DumpVegAreaData (int a_day)
 Saves the information on vegetation types and areas. More...
 
void SkylarkEvaluation (SkTerritories *a_skt)
 Evaluation to find Skylark territory. More...
 
void RodenticidePredatorsEvaluation (RodenticidePredators_Population_Manager *a_rppm)
 Evaluation to find Rodenticide Predator territory. More...
 
PopulationManagerListSupplyThePopManagerList ()
 Set the pointer to the list of active population managers. More...
 
int DistanceToP (APoint a_Here, APoint a_There)
 Distance to the current main population manager, calculates distance from 2 coordinates to other 2 coordinates. More...
 
int DistanceToPSquared (APoint a_Here, APoint a_There)
 Distance to the current main population manager, calculates distance from 2 coordinates to other 2 coordinates but do not square root (for efficiency) More...
 
void SetThePopManagerList (PopulationManagerList *a_ptr)
 Set the pointer to the list of active population managers. More...
 
int SupplyVegPhase (int a_poly)
 Returns the current vegetation growth phase for a polygon. More...
 
double SupplyPestIncidenceFactor ()
 Returns Landscape::m_pestincidencefactor. More...
 
void SetPolymapping (int a_index, int a_val)
 Sets an entry in the polymapping to a specific value. More...
 
int SupplyPolymapping (int a_index)
 Returns the value of the m_polymapping array indexed by a_index. More...
 
int SupplyMaxPoly ()
 Returns the size of the Landscape::m_elems vector. More...
 
Eigen::ArrayXXi * SupplyPolyIdMapPtr ()
 Returns pointer to the Eigen Array for poly id map. More...
 
Eigen::ArrayXXf * SupplyGreenBiomassMapPtr ()
 Returns pointer to the Eigen array for green biomass. More...
 
Eigen::MatrixXf * SupplyPollenMapPtr ()
 Returns pointer to the Eigen matrix for pollen. More...
 
Eigen::MatrixXf * SupplyNectarMapPtr ()
 Returns pointer to the Eigen matrix for nectar. More...
 
list< LE * > SupplyAllVegPolys ()
 Creates a vector containing a list of all the polygons that do not have tov_None as the vegetation type. More...
 
 ~Landscape (void)
 
 Landscape (bool dump_exit=true)
 
bool IsHiddenYear (void)
 The function to return whether it is in the hidden year. More...
 
void SimulationClosingActions ()
 
void Tick (void)
 
void TurnTheWorld (void)
 
int HowManyPonds () const
 Returns the number of ponds in the landscape. More...
 
int SupplyRandomPondIndex ()
 Returns random pond index. More...
 
int SupplyRandomPondRef ()
 Returns random pond polyref. More...
 
int SupplyPondIndex (int a_pondref) const
 Returns the index of a pond based on pondref or -1 if not found. More...
 
void SetMaleNewtPresent (const int a_InPondIndex)
 Sets a male as being present in a pond. More...
 
bool SupplyMaleNewtPresent (int a_InPondIndex)
 Determines if a male is present in a pond. More...
 
FarmSupplyFarmPtr (int a_owner)
 Returns a pointer to a farm owned by a farmer with a specific farm reference number. More...
 
FarmManagerSupplyFarmManagerPtr ()
 Returns m_FarmManager, the pointer to the farm manager instance. More...
 
RasterMapSupplyRasterMap ()
 Returns m_land, the pointer to the raster map instance. More...
 
int SupplyLargestPolyNumUsed ()
 Returns m_LargestPolyNumUsed. More...
 
bool SupplyShouldSpray ()
 Returns m_toxShouldSpray, a flag indicating whether pesticide should be sprayed. More...
 
std::string SupplyCountryCode ()
 Returns m_countryCode, e.g. "DK" for Denmark. More...
 
int SupplyTimezone ()
 
void SetCountryCode (std::string country_code)
 Sets m_countryCode, e.g. "DK" for Denmark. More...
 
string SupplyLandscapeName ()
 Returns the current landscape name. More...
 
void SetSpeciesFunctions (TTypesOfPopulation a_species)
 This is the jumping off point for any landscape related species setup, it creates function pointers to these special functions. More...
 
void SetPolygonLock (int a_polyref)
 Function to set the given polygon lock. More...
 
void ReleasePolygonLock (int a_polyref)
 Function to release the given polygon locks. More...
 
double SupplyLatitude ()
 Returns m_latitude of the landscape location. More...
 
double SupplyLongitude ()
 Returns m_longitude of the landscape location. More...
 
void SetLatitude (double latitude)
 Sets the latitude of the landscape location. More...
 
void SetLongitude (double longitude)
 Sets the longitude of the landscape location. More...
 
double SupplyVegDigestibilityVector (unsigned int a_index)
 Gets the digestibility of the vegetation based on an index to the Landscape::m_elems array. More...
 
double SupplyVegDigestibility (int a_polyref)
 Gets the digestibility of the vegetation for a polygon given by a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
double SupplyVegDigestibility (int a_x, int a_y)
 Gets the digestibility of the vegetation for a polygon given by a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
double SupplyVegHeightVector (unsigned int a_index)
 Returns the height of the vegetation using the index to Landscape::m_elems. More...
 
double SupplyVegHeight (int a_polyref)
 Returns the height of the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
double SupplyVegHeight (int a_x, int a_y)
 Returns the height of the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
double SupplyVegBiomassVector (unsigned int a_index)
 Returns the biomass of the vegetation using the index a_index to Landscape::m_elems. More...
 
double SupplyVegBiomass (int a_polyref)
 Returns the biomass of the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
double SupplyVegBiomass (int a_x, int a_y)
 Returns the biomass of the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
int SupplyVegDensity (int a_polyref)
 Returns the density of the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
int SupplyVegDensity (int a_x, int a_y)
 Returns the density of the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
double SupplyWeedBiomass (int a_polyref)
 Returns the weed biomass of the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
double SupplyWeedBiomass (int a_x, int a_y)
 Returns the weed biomass of the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
void CalHaibitatFlowerResource ()
 Calculate the flower resouce for all the habitat types with flower resource. More...
 
PollenNectarData SupplyPollen (int a_polyref)
 Returns information on the pollen produced by the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
PollenNectarData SupplyPollen (int a_x, int a_y)
 Returns information on the pollen produced by the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
void RemovePollenInLoc (int a_x, int a_y, double a_mount)
 Remove the foraged ammount of pollen quantity from the cell indexed by a_x, a_y. More...
 
PollenNectarData SupplyNectar (int a_polyref)
 Returns information on the nectar produced by the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
PollenNectarData SupplyNectar (int a_x, int a_y)
 Returns information on the nectar produced by the vegetation using the polygon reference number a_polyref or based on the x, y coordinates given by a_x, a_y. More...
 
void RemoveNectarInLoc (int a_x, int a_y, double a_mount)
 Remove the foraged ammount of pollen quantity from the cell indexed by a_x, a_y. More...
 
double SupplySugar (int a_polyref)
 Returns information on the sugar produced by the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplySugar (int a_x, int a_y)
 Returns information on the sugar produced by the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyPollenQuantity (int a_polyref)
 Returns the pollen quantity produced by the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyPollenQuantity (int a_x, int a_y)
 Returns the pollen quantity produced by the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyNectarQuantity (int a_polyref)
 Returns the XXX of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyNectarQuantity (int a_x, int a_y)
 Returns the XXX of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyTotalNectar (int a_polyref)
 Returns the nectar quantity produced by the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyTotalNectar (int a_x, int a_y)
 Returns the nectar quantity produced by the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
void RemoveNectarFromTotal (int a_polyref, double a_removed_amount)
 Remove the given amount of nectar from the total amount in the given polygon. More...
 
double SupplyTotalPollen (int a_polyref)
 Returns the sugar quantity produced by of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyTotalPollen (int a_x, int a_y)
 Returns the sugar quantity produced by of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
void RemovePollenFromTotal (int a_polyref, double a_removed_amount)
 Remove the given amount of pollen from the total amount in the given polygon. More...
 
double SupplyNecDD (int a_polyref)
 Returns the current day degree sum for nectar production of the vegetation using the polygon reference number a_polyref. More...
 
double SupplySugDD (int a_polyref)
 Returns the current day degree sum for sugar production of the vegetation using the polygon reference number a_polyref. More...
 
double SupplyPolDD (int a_polyref)
 Returns the current day degree sum for pollen production of the vegetation using the polygon reference number a_polyref. More...
 
bool SupplySkScrapes (int a_polyref)
 Returns the presence of skylark scrapes in the vegetation using the polygon reference number a_polyref. More...
 
double SupplyInterestedGreenBiomass (int a_polyref)
 Returns the insterested green biomass of the vegetation using the polygon reference number a_polyref. More...
 
double SupplyInterestedGreenBiomass (int a_x, int a_y)
 Returns the interested green biomass of the vegetation using the polygon reference number a_polyref. More...
 
double SupplyInterestedGreenBiomassTotal (int a_polyref)
 Returns the interested green biomass of the vegetation+weeds using the polygon reference number a_polyref. More...
 
double SupplyInterestedGreenBiomassTotal (int a_x, int a_y)
 Returns the interested green biomass of the vegetation+weeds using the x,y coordinate. More...
 
double SupplyGreenBiomass (int a_polyref)
 Returns the green biomass of the vegetation using the polygon reference number a_polyref. More...
 
double SupplyGreenBiomass (int a_x, int a_y)
 Returns the green biomass of the vegetation using the polygon reference number a_polyref. More...
 
double SupplyGreenBiomassTotal (int a_polyref)
 Returns the green biomass of the vegetation+weeds using the polygon reference number a_polyref. More...
 
double SupplyGreenBiomassTotal (int a_x, int a_y)
 Returns the green biomass of the vegetation+weeds using the x,y coordinate. More...
 
double SupplyGreenBiomassProp (int a_polyref)
 Returns the green biomass as a proportion of biomass of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyGreenBiomassProp (int a_x, int a_y)
 Returns the green biomass as a proportion of biomass of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyVegGrowthStage (int a_polyref)
 Returns the vegetation growth stage of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyVegGrowthStage (int a_x, int a_y)
 Returns the vegetation growth stage of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyDeadBiomass (int a_polyref)
 Returns the dead biomass of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyDeadBiomass (int a_x, int a_y)
 Returns the dead biomass of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyLAGreen (int a_polyref)
 Returns the green leaf area of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyLAGreen (int a_x, int a_y)
 Returns the green leaf area of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyLATotal (int a_polyref)
 Returns leaf area in total of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyLATotal (int a_x, int a_y)
 Returns leaf area in total of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyVegCover (int a_polyref)
 Returns the vegetation cover proportion of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
bool SupplyIsVeg (int a_x, int a_y)
 Indicated if this polygon type is descended from VegElement. More...
 
double SupplyVegCoverVector (unsigned int a_index)
 Returns the vegetation cover proportion of the vegetation using the polygon index to Landscape::m_elems. More...
 
double SupplyVegCover (int a_x, int a_y)
 Returns the vegetation cover proportion of the vegetation using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
TTypesOfVegetation SupplyLastSownVeg (int a_polyref)
 Returns the last type of vegetation sown on a field using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
TTypesOfVegetation SupplyLastSownVeg (int a_x, int a_y)
 Returns the last type of vegetation sown on a field using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
TTypesOfVegetation SupplyLastSownVegVector (unsigned int a_index)
 Returns the last type of vegetation sown on a field using the polygon index to Landscape::m_elems. More...
 
double SupplyInsects (int a_polyref)
 Returns the insect biomass on a polygon using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyInsects (int a_x, int a_y)
 Returns the insect biomass on a polygon using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
bool SubtractPondLarvalFood (double a_food, int a_polyrefindex)
 Removes larval food from a pond and returns true if it was possible, otherwise false. More...
 
void CheckForPesticideRecord (LE *a_field, TTypesOfPesticideCategory a_pcide)
 Check if needed and record pesticide application. More...
 
double SupplyRodenticide (int a_x, int a_y)
 Gets total rodenticide for a location. More...
 
double SupplySeedCoating (int a_polyref, PlantProtectionProducts a_ppp)
 Gets total seed coating for the centorid of a polygen. More...
 
bool SupplyPesticideDecay (PlantProtectionProducts a_ppp)
 Returns true if there is any pesticide in the system at all at this point. More...
 
double SupplyPesticide (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets total pesticide for a location. More...
 
bool SupplyOverspray (int a_x, int a_y)
 Gets the overspray flag. More...
 
double SupplyPesticideP (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets plant pesticide for a location. More...
 
double SupplyPesticideS (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets soil pesticide for a location. More...
 
double SupplyPesticidePlantSurface (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets plant surface pesticide for a location. More...
 
double SupplyPesticideInPlant (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets pesticide within plant for a location. More...
 
double SupplyPesticideNectar (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets nectar pesticide for a location. More...
 
double SupplyPesticidePollen (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets pollen pesticide for a location. More...
 
PlantProtectionProducts SupplySprayPesticideType (int a_x, int a_y)
 Gets the sprayed pesticide type in the given location. More...
 
double SupplySprayPesticideRate (int a_x, int a_y)
 Gets the sprayed pesticide rate in the given location. More...
 
double SupplyPesticide (int a_polyref, PlantProtectionProducts a_ppp)
 Gets total pesticide for the centroid of a polygon. More...
 
double SupplyPesticideP (int a_polyref, PlantProtectionProducts a_ppp)
 Gets plant pesticide for the centroid of a polygon. More...
 
double SupplyPesticideS (int a_polyref, PlantProtectionProducts a_ppp)
 Gets soil pesticide for the centroid of a polygon. More...
 
double SupplyPesticidePlantSurface (int a_polyref, PlantProtectionProducts a_ppp)
 Gets plant surface pesticide for the centroid of a polygon. More...
 
double SupplyPesticideInPlant (int a_polyref, PlantProtectionProducts a_ppp)
 Gets pesticide within plant for the centroid of a polygon. More...
 
double SupplyPesticideNectar (int a_polyref, PlantProtectionProducts a_ppp)
 Gets nectar pesticide for the centroid of a polygon. More...
 
double SupplyPesticidePollen (int a_polyref, PlantProtectionProducts a_ppp)
 Gets pollen pesticide for the centroid of a polygon. More...
 
PlantProtectionProducts SupplySprayPesticideType (int a_polyref)
 Gets the sprayed pesticide type in the given field. More...
 
double SupplySprayPesticideRate (int a_polyref)
 Gets the sprayed pesticide rate in the given field. More...
 
RodenticidePredators_Population_Manager * SupplyRodenticidePredatoryManager ()
 
TTypesOfPesticide SupplyPesticideType (void)
 Gets type of pesticide effect from a reference. More...
 
GooseFieldListGetGooseFields (double)
 Gets the list of suitable goose foraging fields today. More...
 
void ResetGrainAndMaize ()
 Resets all grain. More...
 
void CalculateOpenness (bool a_realcalc)
 Causes openness to be calulated and stored for all polygons. More...
 
void WriteOpenness (void)
 Stores openness for all polygons to a standard file LKM - used?? More...
 
void ReadOpenness (void)
 Reads openness values from a standard input file for all polygons LKM - used?? More...
 
int CalculateFieldOpennessCentroid (int a_pref)
 Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Searches from centroid. More...
 
int CalculateFieldOpennessAllCells (int a_pref)
 Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Checks all field 1m2. More...
 
int LineHighTest (int a_cx, int a_cy, double a_offsetx, double a_offsety)
 Provides a measure of the shortest distance in using a vector from a_cx,a_cy unitl tall obstacles are encountered in both +ve & -ve directions. More...
 
int SupplyOpenness (int a_poly)
 Get openness for a polygon. More...
 
int SupplyOpenness (int a_x, int a_y)
 Get openness for a location. More...
 
polylistSupplyLargeOpenFieldsNearXY (int x, int y, int range, int a_openness)
 Returns a pointer to a list of polygonrefs to large open fields within a range of location x,y. More...
 
bool SupplyIsHumanDominated (TTypesOfLandscapeElement a_tole_type)
 For the roe deer, determines the extent of human activity and returns bool. More...
 
int SupplySoilType (int a_x, int a_y)
 Returns the soil type in ALMaSS types reference numbers. More...
 
int SupplySoilTypeR (int a_x, int a_y)
 Returns the soil type in rabbit warren reference numbers. More...
 
APoint SupplyCentroid (int a_polyref)
 Returns the centroid of a polygon using the polygon reference number a_polyref. More...
 
APoint SupplyCentroidIndex (int a_polyrefindex)
 Returns the centroid of a polygon using the polygon index in m_elems. More...
 
int SupplyCentroidX (int a_polyref)
 Returns the centroid x-coordinate of a polygon using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
int SupplyCentroidY (int a_polyref)
 Returns the centroid y-coordinate of a polygon using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
int SupplyCentroidX (int a_x, int a_y)
 Returns the centroid x-coordinate of a polygon using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
int SupplyCentroidY (int a_x, int a_y)
 Returns the centroid y-coordinate of a polygon using the polygon reference number a_polyref or based on the x,y coordinates given by a_x, a_y. More...
 
double SupplyFarmIntensity (int a_x, int a_y)
 Returns the farm intensity classification of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. More...
 
double SupplyFarmIntensity (int a_polyref)
 Returns the farm intensity classification of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. More...
 
double SupplyFarmIntensityI (int a_polyindex)
 Returns the farm intensity classification of the polygon using the polygon index in m_elems. More...
 
TTypesOfLandscapeElement SupplyElementType (int a_polyref)
 Returns the landscape type of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. Returns the value as a TTypesOfLandscapeElement. More...
 
TTypesOfLandscapeElement SupplyElementType (int a_x, int a_y)
 Returns the landscape type of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. Returns the value as a TTypesOfLandscapeElement. More...
 
TTypesOfLandscapeElement SupplyElementTypeCC (int a_x, int a_y)
 Returns the landscape type of the polygon using coordinates a_x, a_y, but allowing correction of coordinates for out of scope values. Returns the value as a TTypesOfLandscapeElement. More...
 
TTypesOfLandscapeElement GetOwner_tole (int a_x, int a_y)
 Returns the landscape type of the polygon owner (used in cases relating to e.g. unsprayed field margins) using coordinates a_x, a_y. Returns the value as a TTypesOfLandscapeElement. More...
 
int SupplyCountryDesig (int a_x, int a_y)
 Returns the designation of country or urban of the polygon using coordinates a_x, a_y. More...
 
int SupplyElementSubType (int a_polyref)
 Returns the landscape element sub-type of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. More...
 
int SupplyElementSubType (int a_x, int a_y)
 Returns the landscape element sub-type of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. More...
 
TTypesOfVegetation SupplyVegType (int a_x, int a_y)
 Returns the vegetation type of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. Returns the value as a # TTypesOfVegetation. More...
 
TTypesOfVegetation SupplyVegType (int polyref)
 Returns the vegetation type of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. Returns the value as a # TTypesOfVegetation. More...
 
TTypesOfCrops SupplyCropType (int a_x, int a_y)
 Returns the crop type of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. Returns the value as a # TTypesOfCrops. More...
 
TTypesOfCrops SupplyCropType (int polyref)
 Returns the crop type of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. Returns the value as a # TTypesOfCrops. More...
 
TTypesOfVegetation SupplyVegTypeVector (unsigned int a_index)
 Returns the vegetation type of the polygon using the polygon index to m_elems. Returns the value as a # TTypesOfVegetation. More...
 
int SupplyGrazingPressureVector (unsigned int a_index)
 Returns the grazing pressure of the polygon using the polygon index to m_elems. More...
 
int SupplyGrazingPressure (int a_polyref)
 Returns the grazing pressure of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. More...
 
int SupplyGrazingPressure (int a_x, int a_y)
 Returns the grazing pressure of the polygon using the polygon reference number a_polyref or coordinates a_x, a_y. More...
 
vector< int > SupplyPolyWithFlowers (void)
 Returns m_poly_with_flowers, a list of polygons with flowering modelled. More...
 
bool SupplyAttIsHigh (int a_x, int a_y)
 Tests whether the polygon at a_x,a_y is designated as xxx. More...
 
bool SupplyAttIsWater (int a_x, int a_y)
 Returns whether a polygon at coordinates a_x, a_y has the attribute Water set. More...
 
bool SupplyAttIsForest (int a_x, int a_y)
 Returns whether a polygon at coordinates a_x, a_y has the attribute Forest set. More...
 
bool SupplyAttIsForest (int a_polyref)
 Returns whether a polygon at coordinates a_x, a_y has the attribute Forest set. More...
 
bool SupplyAttIsWoody (int a_x, int a_y)
 Returns whether a polygon at coordinates a_x, a_y has the attribute Woody. More...
 
bool SupplyAttIsUrbanNoVeg (int a_x, int a_y)
 Returns whether a polygon at coordinates a_x, a_y, or by a_polyref has the attribute High set. More...
 
bool SupplyAttIsUrbanNoVeg (int a_polyref)
 Returns whether a polygon at coordinates a_x, a_y, or by a_polyref has the attribute High set. More...
 
bool SupplyAttIsVegPatchy (int a_polyref)
 Returns whether a polygon at coordinates a_x, a_y, or by a_polyref has the attribute Is Patchy set. More...
 
bool SupplyAttIsVegPatchy (int a_x, int a_y)
 Returns whether a polygon at coordinates a_x, a_y, or by a_polyref has the attribute Is Patchy set. More...
 
bool SupplyAttIsVegCereal (int a_polyref)
 Returns whether a polygon at coordinates a_x, a_y, or by a_polyref has the attribute Is Cereal set. More...
 
bool SupplyAttIsVegMatureCereal (int a_polyref)
 Returns whether a polygon at coordinates a_x, a_y, or by a_polyref has the attribute Is Mature Cereal set. More...
 
bool SupplyAttIsVegGrass (int a_polyref)
 Returns whether a polygon a_polyref has the attribute Is Grass set. More...
 
bool SupplyAttIsVegGrass (int a_x, int a_y)
 Returns whether a polygon a_polyref has the attribute Is Grass set. More...
 
bool SupplyAttIsVegGooseGrass (int a_polyref)
 Returns whether a polygon a_polyref has the attribute Is Goose Grass set. More...
 
bool SupplyAttIsVegMaize (int a_polyref)
 Returns whether a polygon a_polyref has the attribute Is Maize set. More...
 
bool SupplyAttUserDefinedBool (int a_polyref)
 Returns the user defined boolean attribute of a polygon using the polygon reference number a_polyref, or coordinates a_x, a_y. More...
 
bool SupplyAttUserDefinedBool (int a_x, int a_y)
 Returns the user defined boolean attribute of a polygon using the polygon reference number a_polyref, or coordinates a_x, a_y. More...
 
int SupplyAttUserDefinedInt (int a_polyref)
 Returns the user defined integer attribute of a polygon using the polygon reference number a_polyref. More...
 
void SetAttUserDefinedBool (int a_polyref, bool a_value)
 Sets the user defined boolean attribute of a polygon using the polygon reference number a_polyref. More...
 
void SetAttUserDefinedInt (int a_polyref, int a_value)
 ets the user defined integer attribute of a polygon using the polygon reference number a_polyref More...
 
bool ClassificationHigh (TTypesOfLandscapeElement tole)
 Returns whether the polygon is classfied as high. More...
 
bool ClassificationWater (TTypesOfLandscapeElement tole)
 Returns whether the polygon is classfied as water. More...
 
bool ClassificationFieldType (TTypesOfLandscapeElement a_tole)
 Returns whether the polygon is classfied as a field. More...
 
bool ClassificationUrbanNoVeg (TTypesOfLandscapeElement a_tole)
 Returns whether the polygon is classfied as urban with no vegetation. More...
 
bool ClassificationForest (TTypesOfLandscapeElement a_tole)
 Returns whether the polygon is classfied as woodland. More...
 
bool ClassificationWoody (TTypesOfLandscapeElement a_tole)
 Returns whether the polygon is classfied as woody. More...
 
void Set_all_Att_UserDefinedBool (bool(*udf_fnc)(TTypesOfLandscapeElement))
 used to classify the userdefinedbool attribute and set it - this requires supplying the correct classification function More...
 
void Set_all_Att_UserDefinedInt (int(*udf_fnc)(TTypesOfLandscapeElement))
 used to classify the userdefinedint attribute and set it - this requires supplying the correct classification function More...
 
bool ClassificationVegGrass (TTypesOfVegetation a_vege_type)
 Returns whether a vegetation type is classified as Grass. More...
 
bool ClassificationVegCereal (TTypesOfVegetation a_vege_type)
 Returns whether a vegetation type is classified as cereal. More...
 
bool ClassificationVegMatureCereal (TTypesOfVegetation a_vege_type)
 Returns whether a vegetation type is classified as cereal grown to maturity. More...
 
bool ClassificationVegGooseGrass (TTypesOfVegetation a_vege_type)
 Returns whether a vegetation type is classified as Goose Grass. More...
 
bool ClassificationVegMaize (TTypesOfVegetation a_vege_type)
 Returns whether a vegetation type is classified as maize. More...
 
bool ClassificationPermCrop (TTypesOfVegetation a_vege_type)
 Returns whether a vegetation type is classified as a permanent crop. More...
 
void Set_TOLE_Att (LE *elem)
 Uses a point to an LE instance and sets all the attributes based on its tole type. More...
 
void Set_TOV_Att (LE *elem)
 Uses a point to an LE instance and sets all the attributes based on its tov type. More...
 
bool SupplyLEHigh (int a_x, int a_y)
 Function for backwards code compatibility when Set_Att_High would now be used. More...
 
bool IsFieldType (TTypesOfLandscapeElement a_tole)
 Function for backwards code compatibility when TOV attributes would now be used. More...
 
bool SupplyIsCereal2 (TTypesOfVegetation a_vege_type)
 Function for backwards code compatibility when cereal attributes would now be used. More...
 
bool SupplyIsGrass2 (TTypesOfVegetation a_vege_type)
 Function for backwards code compatibility when grass attributes would now be used. More...
 
bool SupplyVegPatchy (int a_polyref)
 Returns whether the polygon referenced by a_polyref or a_x, a_y has a vegetation type designated as patchy. More...
 
bool SupplyVegPatchy (int a_x, int a_y)
 Returns whether the polygon referenced by a_polyref or a_x, a_y has a vegetation type designated as patchy. More...
 
bool SupplyHasTramlines (int a_x, int a_y)
 Returns whether the polygon referenced by a_polyref or a_x, a_y has a vegetation type with tramlines. More...
 
bool SupplyHasTramlines (int a_polyref)
 Returns whether the polygon referenced by a_polyref or a_x, a_y has a vegetation type with tramlines. More...
 
bool SupplyJustMownVector (unsigned int a_index)
 Returns the whether the vegetation was mown for the polygon referenced the index to Landscape::m_elems. More...
 
bool SupplyJustMown (int a_polyref)
 Returns the whether the vegetation was mown for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyJustSprayedVector (unsigned int a_index)
 Returns whether the polygon referenced by an index to Landscape::m_elems has been sprayed in the last timestep. More...
 
int SupplyJustSprayed (int a_polyref)
 Returns whether the polygon referenced by a_polyref or a_x, a_y has been sprayed in the last timestep. More...
 
int SupplyJustSprayed (int a_x, int a_y)
 Returns whether the polygon referenced by a_polyref or a_x, a_y has been sprayed in the last timestep. More...
 
int SupplyTreeAge (int a_Polyref)
 Returns the tree age for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyTreeAge (int, int)
 Returns the tree age for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyVegAge (int a_Polyref)
 Returns the vegetation age for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyVegAge (int a_x, int a_y)
 Returns the vegetation age for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyNumberOfFarms ()
 Returns the number of farms in the current landscape. More...
 
int SupplyFarmOwner (int a_x, int a_y)
 Returns the farm owner pointer for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyFarmOwner (int a_polyref)
 Returns the farm owner pointer for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyFarmOwnerIndex (int a_x, int a_y)
 Returns the farm owner reference number for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyFarmOwnerIndex (int a_polyref)
 Returns the farm owner reference number for the polygon referenced by a_polyref or a_x, a_y. More...
 
TTypesOfFarm SupplyFarmType (int a_polyref)
 Returns the farm type for the polygon referenced by a_polyref or a_x, a_y. More...
 
TTypesOfFarm SupplyFarmType (int a_x, int a_y)
 Returns the farm type for the polygon referenced by a_polyref or a_x, a_y. More...
 
string SupplyFarmRotFilename (int a_polyref)
 Returns filename for the rotation file (if any) for the polygon referenced by a_polyref or a_x, a_y. More...
 
string SupplyFarmRotFilename (int a_x, int a_y)
 Returns filename for the rotation file (if any) for the polygon referenced by a_polyref or a_x, a_y. More...
 
int SupplyFarmArea (int a_polyref)
 Returns the farm area of a farm that owns a particular polygon. More...
 
double SupplyPolygonAreaVector (int a_polyref)
 Returns the polygon area of a particular polygon using an index to m_elems. More...
 
double SupplyPolygonArea (int a_polyref)
 Returns the polygon area of a particular polygon referenced by polygon. More...
 
int SupplyGrainDist ()
 Returns m_grain_dist, a binary condition for good or bad years of spilled grain. More...
 
void SetGrainDist (int a_dist)
 Sets m_grain_dist, a binary condition for good or bad years of spilled grain. More...
 
void SetBirdSeedForage (int a_polyref, double a_fooddensity)
 Sets the grain forage resource as seen from a goose standpoint at a polygon. More...
 
void SetBirdMaizeForage (int a_polyref, double a_fooddensity)
 Sets the maize forage resource as seen from a goose standpoint at a polygon. More...
 
double SupplyGooseGrazingForageH (double a_height, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon based on the height only. More...
 
double SupplyGooseGrazingForageH (int a_polygon, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by number based on height only. More...
 
double GetActualGooseGrazingForage (int a_x, int a_y, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location. More...
 
double GetActualGooseGrazingForage (int a_polygon, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location The amount of food avaiable as grazing resource based on the vegetation height is species specific. More...
 
double SupplyBirdSeedForage (int a_polyref)
 Returns the grain forage resource. More...
 
double SupplyBirdSeedForage (int a_x, int a_y)
 Returns the grain forage resource as seen from a goose standpoint at an x,y location. More...
 
double SupplyBirdMaizeForage (int a_polyref)
 Returns the maize forage resource. More...
 
bool SupplyInStubble (int a_polyref)
 Returns whether its cereal in stubble. More...
 
double SupplyBirdMaizeForage (int a_x, int a_y)
 Returns the maize forage resource as seen from a goose standpoint at an x,y location. More...
 
void RecordGooseNumbers (int a_poly, int a_number)
 This records the number of geese on the polygon the day before. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseSpNumbers (int a_poly, int a_number, GooseSpecies a_goose)
 This records the number of geese of each species on the polygon the day before. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseNumbersTimed (int a_poly, int a_number)
 This records the number of geese on the polygon the day before at a predefined time. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseSpNumbersTimed (int a_poly, int a_number, GooseSpecies a_goose)
 This records the number of geese of each species on the polygon the day before at a predefined time. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseRoostDist (int a_polyref, int a_dist, GooseSpecies a_goose)
 Records the distance to the closest roost of goose species. More...
 
void GrazeVegetation (int a_poly, double a_forage)
 Removes grazing forage from a poly per m2. More...
 
void GrazeVegetationTotal (int a_poly, double a_forage)
 Removes grazing forage from a poly and divides this out per m2. More...
 
int GetGooseNumbers (int a_poly)
 This returns the number of geese on the polygon the day before. More...
 
int GetQuarryNumbers (int a_poly)
 This returns the number of geese which are legal quarry on the polygon the day before. More...
 
int GetGooseNumbers (int a_x, int a_y)
 This returns the number of geese on the polygon specifed by a_x, a_y the day before. More...
 
int SupplyLastTreatment (int a_polyref, int *a_index)
 Returns the last treatment recorded for the polygon. More...
 
int SupplyLastTreatment (int a_x, int a_y, int *a_index)
 Returns the last treatment recorded for the polygon. More...
 
double GetHareFoodQuality (int a_polygon)
 Returns the hare food quality of polygons LKM. More...
 
double SupplyGlobalRadiation ()
 Passes a request on to the associated Weather class function, the global amount of sunshine for the current day. More...
 
double SupplyGlobalRadiation (long a_date)
 Passes a request on to the associated Weather class function, the global mean amount of sunshine for the current day. More...
 
double SupplyRain (void)
 Passes a request on to the associated Weather class function, the amount of rain for the current day. More...
 
double SupplyTemp (void)
 Passes a request on to the associated Weather class function, the temperature for the current day. More...
 
double SupplyMinTemp (void)
 Passes a request on to the associated Weather class function, the minimum temperature for the current day. More...
 
double SupplyMaxTemp (void)
 Passes a request on to the associated Weather class function, the maximum temperature for the current day. More...
 
double SupplyMinTempYesterday (void)
 Passes a request on to the associated Weather class function, the minimum temperature for yesterday. More...
 
double SupplyMaxTempYesterday (void)
 Passes a request on to the associated Weather class function, the maximum temperature for yesterday. More...
 
double SupplyMinTempTomorrow (void)
 Passes a request on to the associated Weather class function, the minimum temperature for tomorrow. More...
 
double SupplyMaxTempTomorrow (void)
 Passes a request on to the associated Weather class function, the maximum temperature for tomorrow. More...
 
double SupplySoilTemp (void)
 Passes a request on to the associated Weather class function, the soil temperature for the current day. More...
 
double SupplyHumidity (void)
 Passes a request on to the associated Weather class function, the mean humidity for the current day. More...
 
double SupplyMeanTemp (long a_date, unsigned int a_period)
 Passes a request on to the associated Weather class function, the mean temperature for the current day. More...
 
double SupplyWind (void)
 Passes a request on to the associated Weather class function, the wind speed for the current day. More...
 
int SupplyWindDirection (void)
 Passes a request on to the associated Weather class function, the wind direction in 4 directions for the current day. More...
 
int SupplyWindDirection8 (void)
 Passes a request on to the associated Weather class function, the wind direction in 8 directions for the current day. More...
 
double SupplyWindDirectionRadians (void)
 Passes a request on to the associated Weather class function, the wind direction in radians for the current day. More...
 
double SupplySnowDepth (void)
 Passes a request on to the associated Weather class function, the snow depth for the current day. More...
 
bool SupplySnowcover (void)
 Passes a request on to the associated Weather class function, the snow cover for the current day. More...
 
int SupplyDaylength (void)
 Passes a request on to the associated Weather class function, the day length for the current day. More...
 
double SupplyTempHour (int hour)
 Returns the temperature in a given hour (0 to 23) More...
 
double SupplySoilTempHour (int hour)
 Returns the soil temperature in a given hour (0 to 23) More...
 
double SupplyWindHour (int hour)
 Returns the wind speed in a given hour (0 to 23) More...
 
double SupplyRainHour (int hour)
 Returns the amount of rain in a given hour (0 to 23) More...
 
double SupplyRadiationHour (int hour)
 Returns the amount of sunshine in a given hour (0 to 23) More...
 
double SupplyRain (long a_date)
 Passes a request on to the associated Weather class function, the amount of rain for all dates. More...
 
double SupplyTemp (long a_date)
 Passes a request on to the associated Weather class function, the temperature for all dates. More...
 
double SupplySoilTemp (long a_date)
 Passes a request on to the associated Weather class function, the soil temperature for all dates. More...
 
double SupplyWind (long a_date)
 Passes a request on to the associated Weather class function, the wind speed for all dates. More...
 
double SupplyDayDegrees (int a_polyref)
 Passes a request on to the associated Weather class function, the day degrees for all dates. More...
 
double SupplyRainPeriod (long a_date, int a_period)
 Passes a request on to the associated Weather class function, the total amount of rain from a_date and a_period of days. More...
 
double SupplyWindPeriod (long a_date, int a_period)
 Passes a request on to the associated Weather class function, the total wind speed from a_date and a_period of days. More...
 
double SupplyTempPeriod (long a_date, int a_period)
 Passes a request on to the associated Weather class function, the total temperature from a_date and a_period of days. More...
 
bool SupplySnowcover (long a_date)
 Passes a request on to the associated Weather class function, the snow cover for the current day. More...
 
int SupplyPolyRef (int a_x, int a_y)
 Get the in map polygon reference number from the x, y location. More...
 
int SupplyUMRef (int a_x, int a_y)
 Get the unsprayed margin reference number from the polygon at x,y. More...
 
LESupplyPolyLEptr (int a_x, int a_y)
 Get the pointer to the LE object associated with the polygon at x,y location or by using the polygon reference. More...
 
LESupplyPolyLEptr (int a_polyref)
 Get the pointer to the LE object associated with the polygon at x,y location or by using the polygon reference. More...
 
int SupplyPolyRefIndex (int a_x, int a_y)
 Get the index to the m_elems array for a polygon at location x,y. More...
 
int SupplyPolyRefCC (int a_x, int a_y)
 Get the in map polygon reference number from the x,y location, and correcting for possible wrap around coordinates. More...
 
vector< LE * > * SupplyPolyListPtr ()
 Returns the pointer to m_elemns. More...
 
int SupplySimAreaWidth (void)
 Gets the simulation landscape width. More...
 
int SupplySimAreaHeight (void)
 Gets the simulation landscape height. More...
 
int SupplySimAreaMaxExtent (void)
 Returns which ever is larger, height or width of simulation landscape. More...
 
int SupplySimAreaMinExtent (void)
 Returns which ever is smaller, height or width of simulation landscape LKM - used?? More...
 
int SupplyDaylength (long a_date)
 Passes a request on to the associated Calendar class function, the day length. More...
 
int SupplyDayInYear (void)
 Passes a request on to the associated Calendar class function, the day in the year. More...
 
int SupplyHour (void)
 Passes a request on to the associated Calendar class function, the hour of the day. More...
 
int SupplyMinute (void)
 Passes a request on to the associated Calendar class function, the minute of the hour. More...
 
unsigned int SupplyNumberOfPolygons (void)
 Returns the number of polygons in the landscape. More...
 
TTypesOfLandscapeElement SupplyElementTypeFromVector (unsigned int a_index)
 Gets the TTypesOfVegetation type of a polygon using the m_elems. More...
 
TTypesOfLandscapeElement SupplyOwner_tole (int a_x, int a_y)
 Gets the farm owner reference of a polygon, or -1 if not owned by a farmer. More...
 
int SupplyPolyRefVector (unsigned int a_index)
 Gets the polygon reference number from the index to m_elems. More...
 
int SupplyPesticideCell (int a_polyref)
 Gets the index to the cell used to store pesticide information from the coordinates x, y. More...
 
int SupplyValidX (int a_polyref)
 Returns an x-coordinate guaranteed to be within the polygon referenced. More...
 
int SupplyValidY (int a_polyref)
 Returns an y-coordinate guaranteed to be within the polygon referenced. More...
 
double SupplyPondPesticide (int a_poly_index)
 Get the pesticide concentration per liter from a pond (must be a pond index on calling) More...
 
void CorrectCoords (int &x, int &y)
 Function to prevent wrap around errors with co-ordinates using x/y pair. More...
 
APoint CorrectCoordsPt (int x, int y)
 Function to prevent wrap around errors with co-ordinates using x/y pair. More...
 
void CorrectCoordsPointNoWrap (APoint &a_pt)
 Function to prevent wrap around errors with co-ordinates using a APoint. More...
 
int CorrectWidth (int x)
 Function to prevent wrap around errors with width LKM. More...
 
int CorrectHeight (int y)
 Function to prevent wrap around errors with height LKM. More...
 
void SetPolyMaxMinExtents (void)
 Sets MapValid as true for each polygon found. More...
 
void CalculateCentroids (void)
 Calculate centroid for each polygon found. More...
 
void DumpCentroids (void)
 Saves centroid information for each polygon found. More...
 
void BuildingDesignationCalc ()
 used to calculate whether a building as rural or town - for rodenticide use More...
 
void CentroidSpiralOut (int a_polyref, int &a_x, int &a_y)
 Function to move from midx & midy and outwards in concentric circles until a location that matches the polyref is found LKM. More...
 
const char * SupplyVersion (void)
 Returns version info LKM. More...
 
void DumpPublicSymbols (const char *a_dumpfile, CfgSecureLevel a_level)
 Dumps all configuration values with a security level at or below a_level to a_dumpfile in alphabetical order. More...
 
void DumpAllSymbolsAndExit (const char *a_dumpfile)
 Dumps all configuration values, including private ones, to a_dumpfile and then calls exit() More...
 
bool ReadSymbols (const char *a_cfgfile)
 Reads and parses a_cfgfile for configuration values. More...
 
void DumpMapInfoByArea (const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
 Dumps landscape information by area LKM. More...
 
void Warn (std::string a_msg1, std::string a_msg2)
 Wrapper for the g_msg Warn function. More...
 
int * SupplyMagicMapP (int a_x, int a_y)
 Returns a pointer to the map at position x, y. The value found through it is an internal number from the landscape simulator, that uniquely identifies a polygon, it is not the polygon number - to find this apply MagicMap2PolyRef. More...
 
int MagicMapP2PolyRef (int a_magic)
 Converts the internal number generated from SupplyMagicMapP to the polygon number. More...
 
int SupplyRoadWidth (int, int)
 Returns the width of roads. More...
 
double SupplyTrafficLoad (int a_x, int a_y)
 Returns the traffic load. More...
 
double SupplyTrafficLoad (int a_polyref)
 Returns the traffic load. More...
 
int SupplyTreeHeight (int, int)
 Returns the height of trees. More...
 
int SupplyUnderGrowthWidth (int, int)
 Returns the width of undergrowth. More...
 
int SupplyTreeHeight (int)
 Returns the height of trees. More...
 
int SupplyUnderGrowthWidth (int)
 Returns the width of undergrowth. More...
 
long SupplyGlobalDate (void)
 Passes a request on to the associated Calendar class function, returns the simulation global date for the day, month and year supplied. More...
 
int SupplyYear (void)
 Passes a request on to the associated Calendar class function, returns m_year. More...
 
int SupplyYearNumber (void)
 Passes a request on to the associated Calendar class function, returns m_simulationyear
More...
 
int SupplyMonth (void)
 Passes a request on to the associated Calendar class function, returns m_month + 1 (the calendar month)
More...
 
std::string SupplyMonthName (void)
 Passes a request on to the associated Calendar class function, returns the month name (e.g., January)
More...
 
int SupplyDayInMonth (void)
 Passes a request on to the associated Calendar class function, returns m_day_in_month
More...
 
double SupplyDaylightProp ()
 Passes a request on to the associated Calendar class function, returns m_daylightproportion
More...
 
double SupplyNightProp ()
 Passes a request on to the associated Calendar class function, returns 1.0 - m_daylightproportion
More...
 
void SupplyLEReset (void)
 Resets internal state for the LE loop generator. More...
 
int SupplyLENext (void)
 Returns -1 at if the end of the list of m_elems is reached, polyref otherwise. More...
 
int SupplyLECount (void)
 Returns number of all landscape elements. More...
 
LE_Signal SupplyLESignal (int a_polyref)
 Returns current signal mask for polygon. More...
 
void SetLESignal (int a_polyref, LE_Signal a_signal)
 Writes the mask back out to the polygon. More...
 
void IncTreatCounter (int a_treat)
 Records that a farm treatment of the type specified has occurred. More...
 
TTypesOfLandscapeElement TranslateEleTypes (int EleReference)
 Returns element type translated from the ALMaSS reference number. More...
 
TTypesOfVegetation TranslateVegTypes (int VegReference)
 Returns vegetation type translated from the ALMaSS reference number. More...
 
TTypesOfLandscapeElement TranslateEleTypesFromString (string EleReference)
 Returns element type translated from the ALMaSS reference string. More...
 
LESupplyLEPointer (int a_polyref)
 Returns a pointer to the object referred to by the polygon number. More...
 
int BackTranslateEleTypes (TTypesOfLandscapeElement EleReference)
 Returns the ALMaSS reference number translated from the TTypesOfLandscapeElement type. More...
 
int BackTranslateVegTypes (TTypesOfVegetation VegReference)
 Returns the ALMaSS reference number translated from the TTypesOfVegetation type. More...
 
std::string EventtypeToString (int a_event)
 Returns the text representation of a treatment type. More...
 
std::string PolytypeToString (TTypesOfLandscapeElement a_le_type)
 Returns the text representation of a TTypesOfLandscapeElement type. More...
 
std::string VegtypeToString (TTypesOfVegetation a_veg)
 Returns the text representation of a TTypesOfVegetation type. More...
 
std::string CropTypeToString (TTypesOfCrops a_crop)
 Returns the text representation of a TTypesOfCrops type. More...
 
std::string FarmtypeToString (TTypesOfFarm a_farmtype)
 Returns the text name of a TTypesOfFarm type. More...
 

Public Attributes

int m_grain_dist
 Declaration of attribute, m_grain_dist, a binary condition for good or bad years of spilled grain. More...
 

Protected Member Functions

void GISASCII_Output (string outpfile, int UTMX, int UTMY)
 Write ASCII file of the ALMaSS map. More...
 
int ReadPolys1 (const char *a_polyfile)
 Is used to take a look in the input file for polygons to figure out what the format is (since multiple formats are allowed) More...
 
void ReadFlowerSpeciesComp (const char *a_flower_file)
 This function is to read the habitat species composition for flower resource. More...
 
void ReadPolys2 (const char *a_polyfile, int a_format)
 Based on the format of the file (since multiple formats are allowed), this reads the polygon information from an input file. This method sets up the Landscape::m_polymapping lookup table, checks validity of polygon and associated farm information and creates the LE instances to populate the Landscape::m_elems array, and if needed creates the links between unsprayed margins and the owner tole type. More...
 
void PolysValidate (bool a_exit_on_invalid)
 Checks for internal consistency in the polygon information, e.g. being sure that all polygons mentioned are actually in the map. More...
 
bool PolysRemoveInvalid (void)
 Checks whether all polygons are in the map, removing those that are not. More...
 
void PolysDump (const char *a_filename)
 Called if the landscape is manipulated to save the new version of the polyref input file. More...
 
void DumpMap (const char *a_filename)
 Called if the landscape is manipulated to save the new version of the.lsb input file(i.e.the topographical map) More...
 
void ConsolidatePolys (void)
 Used to replace polygons or combine them when there is no special management associated with them.This just reduces the number of polygon entries and saves time and space. More...
 
void CountMapSquares (void)
 Calculates the area for each polygon in the mapand stores it in LE::m_squares_in_map. More...
 
void PolysRenumber (void)
 Renumbers the polygons from 0 to the number of LE instances - 1. This saves space, and also means that the polygon number becomes the same as the index in Landscape::m_elems, allowing quicker lookup(reduces indirection by 1) More...
 
void RebuildPolyMapping ()
 Called if there is any change in the polygons and loops through all polygons resetting the Landscape::m_polymapping value. More...
 
void ForceArea (void)
 Check of polygon areas. Each polygon should be present in the map with the correct area recorded, otherwise this method raises an error. More...
 
void ChangeMapMapping (void)
 Maps the polygon numbers directly to the indices in m_elems. More...
 
LENewElement (TTypesOfLandscapeElement a_type)
 NewElement Creates a new LE instance and where possible it will create the highest level in the class hierarchy e.g. tole_Portarea has no behaviour so can be created as a NonVegElement (LE->NonVegElement), removing the need to have a Portarea class. More...
 
void RemoveMissingValues ()
 A method for replacing missing values in the map with corrected ones. More...
 
void VegDump (int x, int y)
 Records vegetation charateristics for the x, y location. More...
 
void EventDump (int x, int y, int x2, int y2)
 Records farm events carried out on the x, y locations. More...
 
void EventDumpPesticides (int x1, int y1)
 Records pesticided application farm events carried out on the x,y location. More...
 
void DegreesDump ()
 Prints the sum of day degrees. See FarmManager::daydegrees. More...
 
bool BorderNeed (TTypesOfLandscapeElement a_letype)
 Currently unused test for adding borders. More...
 
int BorderAdd (LE *a_field, TTypesOfLandscapeElement a_type, int a_allAround=1)
 Adds a border of the specified type (could be an unsprayed margin) around a field
More...
 
bool BorderTest (int a_fieldindex, int a_borderindex, int a_x, int a_y)
 Used to decide if a coordinate location should become a border/unsprayed margin. More...
 
void BorderRemoval (void)
 Removes field boundaries, hedgebanks and hedges if they are adjacent to a field. More...
 
int RemoveSmallPolygons (void)
 Removes small polygons from the map. More...
 
void CreatePondList ()
 Creates a list of pond polygon refs/indexes for easy look up. More...
 
void AddBeetleBanks (TTypesOfLandscapeElement a_tole)
 The starting point for adding beetlebanks to a field (can be used to add ‘banks’ of any tole_type. More...
 
int AddBeetleBankIfPossible (LE *a_field, TTypesOfLandscapeElement a_tole)
 Determines whether a beetlebank can be added to the field depending on physical characteristics and adds it. More...
 
bool FindFieldCenter (LE *a_field, int *x, int *y)
 Finds a location in the middle of a field to ‘seed a beetlebank’ More...
 
int FindLongestAxis (int *x, int *y)
 From a central location finds the longest axis of a field. More...
 
int FindBestRectangle (int a_polyindex, int *a_x, int *a_y, int *a_width, int *a_x_start, int *a_y_start)
 From a central location finds the biggest rectangle that fits inside the field. More...
 
void AxisLoop (int a_poly, int *a_x, int *a_y, int a_axis)
 Tests the length of a vector to find when we step outside a given polygon. More...
 
void AddPatches (TTypesOfLandscapeElement a_tole)
 The starting point for adding patches to a field (can be used to add patches of any tole_type) More...
 
int AddPatchIfPossible (LE *a_field, TTypesOfLandscapeElement a_tole)
 Determines whether a patch can be added to the field depending on physical characteristics and adds it. More...
 
void hb_Add (void)
 The entry point for adding hedgebanks. Hedgebanks are created by replacing part of hedge polygons with the tole_HedgeBank If the hedge is wide this will be with a border on each side, if narrow then by inserting hedgebank between trees. More...
 
void hb_AddNewHedgebanks (int a_orig_poly_num)
 Adds new hedgebanks. More...
 
int hb_StripingDist (void)
 Striping distribution function for the new hedgebanks LKM. More...
 
void hb_GenerateHBPolys (void)
 Creates the necessary new hedgebank polygons in Landscape::m_elems. More...
 
void hb_FindHedges (void)
 Generate a list of polygon numbers for new hedgebank addition. More...
 
bool hb_FindBoundingBox (int a_poly_num)
 Finds a rectangle that encloses the hedge to be manipulated. More...
 
void hb_UpPolyNumbers (void)
 Adds a big number to all polygon refs in the map to create space to safely manipulate the hedge pixels. More...
 
void hb_ClearPolygon (int a_poly_num)
 Replaces all values in the map for a polygon with a temporary value ready for manipulation. More...
 
void hb_PaintBorder (int a_color)
 Identifies all border hedge pixels. More...
 
bool hb_MapBorder (int a_x, int a_y)
 Checks for out of bounds hedgebank coordinates. More...
 
bool hb_HasOtherNeighbour (int a_x, int a_y)
 Checks if a pixel has any non hedge neighbour cell. More...
 
bool hb_PaintWhoHasNeighbourColor (int a_neighbour_color, int a_new_color)
 Pushes a value to a pixel cell that denotes that is has a neighbour that is not hedge. More...
 
bool hb_HasNeighbourColor (int a_x, int a_y, int a_neighbour_color)
 Tests for an already process neighbour cell. More...
 
void hb_MarkTopFromLocalMax (int a_color)
 Used to identify the distance a cell is from the centre of a hedge. More...
 
void hb_MarkTheBresenhamWay (void)
 ‘Paints’ the core of a hedge with a negative number for use in deciding what becomes hedgebank later More...
 
int hb_MaxUnpaintedNegNeighbour (int a_x, int a_y)
 Determines the width from centre to edge of hedge. More...
 
void hb_ResetColorBits (void)
 Remove high number colour bits from the map. More...
 
void hb_RestoreHedgeCore (int a_orig_poly_number)
 LKM. More...
 
void hb_DownPolyNumbers (void)
 Reverses the process carried out by Landscape::hb_UpPolyNumbers. More...
 
void DumpMapGraphics (const char *a_filename)
 Saves the graphics for the landscape LKM. More...
 
void DumpTreatCounters (const char *a_filename)
 When the simulation is closed this method saves the number of each farm management that has been carried out. More...
 

Protected Attributes

int m_treatment_counts [last_treatment]
 Array for containing the treatment counts. More...
 
int m_LargestPolyNumUsed
 The largest polygon number used. More...
 
vector< int > m_PondIndexList
 List of pond indexes. More...
 
vector< int > m_PondRefsList
 List of pond polyrefs. More...
 
vector< int > hb_hedges
 Declaration of attributes for hedgebanks. More...
 
vector< LE * > hb_new_hbs
 
int m_x_add [16]
 
int m_y_add [16]
 
int * hb_map
 
int hb_width
 
int hb_height
 
int hb_size
 
int hb_min_x
 
int hb_max_x
 
int hb_min_y
 
int hb_max_y
 
int hb_first_free_poly_num
 
int hb_core_pixels
 
int hb_border_pixels
 
TTypesOfPesticide m_PesticideType
 An attribute to hold the pesticide type being tested, if there is one, if not default is -1. More...
 
bool m_toxShouldSpray
 A flag indicating whether pesticide should be sprayed. More...
 
int le_signal_index
 Index for the LE signal loop. More...
 
std::string m_countryCode = "None"
 Declaration of attributes for country and coordinates. More...
 
double m_latitude = -1
 
double m_longitude = -1
 
bool m_firstyear
 Flag to indicate the that the first year is run (i.e. before simulation starts) More...
 
string LandscapeName
 A holder for the landscape name for output if needed. More...
 

Private Member Functions

void GrainDump ()
 Records total amount of grain / seed / maize available as forage for each polygon. More...
 

Private Attributes

std::vector< omp_nest_lock_t * > m_poly_omp_locks
 The locks for all the polygon. More...
 
char m_versioninfo [30]
 Version info. Initialized by the constructor. More...
 
FarmManagerm_FarmManager
 List of all the farms. More...
 
vector< LE * > m_elems
 List of all landscape elements. The index is a sequential number, to get the polynum look this number up in m_polymapping. More...
 
RasterMapm_land
 The big map. More...
 
vector< int > m_polymapping
 
vector< int > m_poly_with_flowers
 
PesticideMapm_PesticideMap = nullptr
 For specialised pesticide recording. More...
 
PesticideTablem_PesticideTable = nullptr
 For specialised pesticide recording. More...
 
PestIncidenceManagerm_PestIncidenceManager
 A pest incidence manager. More...
 
double m_pestincidencefactor
 
int m_width
 Declaration of attributes for correcting coordinates before modulus operations, saves an indirection when doing inline function calls. More...
 
int m_height
 Area length. More...
 
int m_width10
 Area width times 10. More...
 
int m_height10
 Area length times 10. More...
 
int m_minmaxextent
 Area minimum extent, the smallest value of m_width or m_height
More...
 
int m_maxextent
 Area maximum extent, the largest value of m_width or m_height
More...
 
int m_area
 Area of the whole landscape. More...
 
bool m_NeedCentroidCalculation
 A flag to ensure centroid calculation on object construction. More...
 
bool m_NeedOpennessCalculation
 A flag to ensure openness calculation on object construction. More...
 
bool m_DoMissingPolygonsManipulations
 A flag to signal that missing polygons exist. More...
 
double * l_vegtype_areas
 For veg area dumps. More...
 
PopulationManagerListm_ThePopManagerList
 A pointer to the current main population manager. More...
 
RodenticideManager * m_RodenticideManager
 A pointer to the rodenticide manager. More...
 
RodenticidePredators_Population_Manager * m_RodenticidePreds
 A pointer to the Rodenticide predators population´manager. More...
 
Polynomial2CurveClassm_GooseIntakeRateVSVegetationHeight_PF
 A curve relating goose intake rates in KJ/min to vegetation height for Pink-footed Goose (PF) More...
 
Polynomial2CurveClassm_GooseIntakeRateVSVegetationHeight_BG
 A curve relating goose intake rates in KJ/min to vegetation height for Barnacle Goose (BG) More...
 
Polynomial2CurveClassm_GooseIntakeRateVSVegetationHeight_GL
 A curve relating goose intake rates in KJ/min to vegetation height for Greylag Goose (GL) More...
 
std::map< int, vector< int > > m_habitat_species
 This the dictionary to store the composition of species for every habitat type. More...
 
std::map< int, vector< double > > m_habitat_flower_num
 This is the dictionary to store the proportion of each composition for every habitat. More...
 
std::map< int, PollenNectarDatam_habitat_pollen
 This is the dictionary to store the pollen data of each habitat type for the given day. More...
 
std::map< int, PollenNectarDatam_habitat_nectar
 This is the dictionary to store the nectar data of each habitat type fo the given day. More...
 
std::map< int, vector< APoint > > m_poly_cell_locs
 This is the dictionary to store all the locations for each polygon. More...
 
std::map< int, vector< APoint > > m_poly_cell_locs_pollen
 This is the dictionary to store all the locations used for quick access to pollen. More...
 
std::map< int, int > m_index_locs_pollen
 This is the dictionary to store all the index in m_poly_cell_locs_pollen start from which there is no pollen available. More...
 
std::map< int, vector< APoint > > m_poly_cell_locs_nectar
 This is the dictionary to store all the locations used for quick access to nectar. More...
 
std::map< int, int > m_index_locs_nectar
 This is the dictionary to store all the index in m_poly_cell_locs_nectar start from which there is no nectar available. More...
 
Eigen::MatrixXf m_pollen_map
 This is the matrix to store the pollen proportion (0-1) left for each cell. More...
 
Eigen::MatrixXf m_nectar_map
 This is the matrix to store the nectar proportion (0-1) left for each cell. More...
 
Eigen::ArrayXXf m_biomass_map
 This is the array to store the green biomass for each cell. More...
 
Eigen::ArrayXXi m_polyid_map
 This is the array to store the polygon ID for each cell. More...
 
std::vector< std::vector< std::vector< int > > > m_map_polyid_within_dist
 This is the vector to store all the polygon IDs within a certain distance to each location in a landscape. More...
 

Detailed Description

The landscape class containing all environmental and topographical data.

Constructor & Destructor Documentation

◆ ~Landscape()

Landscape::~Landscape ( void  )
2890  {
2891  for (int i=0; i<m_poly_omp_locks.size(); i++){
2892  omp_destroy_nest_lock(m_poly_omp_locks[i]);
2893  delete m_poly_omp_locks[i];
2894  }
2897  }
2898 
2899 #ifdef __RECORDFARMEVENTS
2900  m_farmeventfile->close();
2901  delete m_farmeventfile;
2902 #endif
2903 
2904  for ( unsigned int i = 0; i < m_elems.size(); i++ )
2905  delete m_elems[ i ];
2906 
2907  free( l_vegtype_areas );
2908  delete m_land;
2909  //delete g_rotation;
2910  delete m_PestIncidenceManager;
2912  {
2913  delete m_RodenticideManager;
2914  delete m_RodenticidePreds;
2915  }
2916  delete m_FarmManager;
2920  // delete g_msg; // Must be last.
2921 
2922  if (m_PesticideMap)
2923  {
2924  delete m_PesticideMap;
2925  }
2926 
2927  if (m_PesticideTable)
2928  {
2929  delete m_PesticideTable;
2930  }
2931 }

References cfg_rodenticide_enable, l_map_dump_treatcounts_enable, l_map_dump_treatcounts_file, CfgBool::value(), and CfgStr::value().

◆ Landscape()

Landscape::Landscape ( bool  dump_exit = true)

The landscape constructor sets up all the mapping, environment and management for the landscape simulation.

Next job after checking the basic map validity is to deal with any missing polygon information This is done by identifying the polygons that are large contiguous areas and making them wasteland. The rest are left and nibbled away to join adjacent polygons. This is a time consuming operation so is only done if there have been any missing info polygons found.

To be sure we have enough space to do map manipulations if required, then the polygons need to be renumbered - unless they are done already.

After the main structure is created the constructor can carry out optional more complex manipulations. These are adding hedgebanks, field boundaries, softening orchard boundaries, adding unsprayed margins, and adding beetlebanks.

After special manipulations the graphics for the landscape can be saved.

If there were any structural changes to the map by the time the execution reaches towards the end of the constructor, then a series of checks are run, before the map is saved as a new map with a _dump added to the end of the current map name. This ensures that the saved map is internally consistent.

Counts up the ponds and store them, at this point the constructor is finished with structural polygon handling.

The Farm managment is then initiated, which means that from this point all polygons will have a type of vegetation allocated. Once all polygons have their tov types, the attributes based on tov type are set.

There are a number of options to dump vegetation, event etc. information if selected, this depends on different configureation variables as needed.

If rodenticide handling is enabled then rodenticide mapping provides access to predicted relative density of poisoned rodents per unit area. To do this the constructor creates a RodenticideManager and a RodenticidePredators_Population_Manager

Optional output files are created here as needed depending on defines or config variables

There is a also some special set up required for some species models which is done at the end of the constructor

1806  {
1810  // Set up operation flags
1811  bool didRenumber = false;
1812  bool didCalcCentroids = false;
1813  bool didConsolidate = false;
1814  bool didCalcOpenness = false;
1815  bool didCalcOther = false;
1816  m_NeedCentroidCalculation = false;
1817  m_NeedOpennessCalculation = false;
1819  // Set up globals
1820  g_landscape_ptr = this;
1821  for (int i = 1; i <= 2000; i++) {
1822  g_speedy_Divides[i] = 1 / double(i);
1823  }
1824  // The following arrays correspond to:
1825  // 0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5, 180, 202.5, 225, 247.5, 270, 292.5, 315, 337.5
1826  // E, ENE, NE, NNE, N, NNW, NW, WNW, W, WSW, SW, SSW, S, SSE, SE, ESE
1827  int x_add[16] = { 1, 2, 1, 1, 0, -1, -1, -2, -1, -2, -1, -1, 0, 1, 1, 2 };
1828  int y_add[16] = { 0, -1, -1, -2, -1, -2, -1, -1, 0, 1, 1, 2, 1, 2, 1, 1 };
1829  for (int i = 0; i < 16; i++) {
1830  m_x_add[i] = x_add[i];
1831  m_y_add[i] = y_add[i];
1832  }
1833 
1835 
1837  cout << "This program uses the Landscape simulator " << m_versioninfo << endl;
1838  }
1839 #ifdef __GITVERSION
1841  {
1842  std::cout << "hash=" << GIT_HASH << ", time=" << COMPILE_TIME << ", branch=" << GIT_BRANCH << std::endl;
1843  }
1844 #endif
1845 
1846 
1847  // For creating a list of all cfg symbols when needed.
1848  //g_cfg->DumpPublicSymbols( "publicsymbols.cfg", CFG_PUBLIC );
1849  //exit(1);
1850 
1851  m_LargestPolyNumUsed = -1;
1852  m_pestincidencefactor = 1.0;
1853 
1854  // Reset treatment counters.
1855  for (int i = 0; i < last_treatment; i++) {
1856  m_treatment_counts[i] = 0;
1857  }
1858  // Due to difficulties with ordering of events here we take a sneak peek at the polyref file
1859  cout << "Setting country and lat/long " << l_map_poly_file.value() << endl;
1860  int format = ReadPolys1(l_map_poly_file.value());
1861 
1862  cout << "Creating FarmManager Object" << endl;
1863  m_FarmManager = new FarmManager(this);
1864 
1867  }
1868  // Set the vegetation type biomass scalers
1869  for (int v = 0; v < tov_Undefined; v++) { VegElement::SetBiomassScalers(static_cast<TTypesOfVegetation>(v)); }
1870  cout << "Reading polygon reference file " << l_map_poly_file.value() << endl;
1871  ReadPolys2(l_map_poly_file.value(), format); // lct: creates LE ( Landscape->m_elems[i] ) associated to each polygon, and associted field polygons to farm owners, and sets flags for borders and unsprayed margin processing
1872 
1873  cout << "Creating RasterMap Object from file " << l_map_map_file.value() << endl;
1874  m_land = new RasterMap(l_map_map_file.value(), this);
1875  m_width = m_land->MapWidth();
1876  m_height = m_land->MapHeight();
1877  m_area = m_width * m_height;
1879  m_width10 = 10 * m_width;
1880  m_height10 = 10 * m_height;
1882 
1884  // Validate polygons, ie. ensure those reference in the
1885  // polygon file also shows up in the map.
1886  cout << "In PolysValidate" << endl;
1887  PolysValidate(false);
1888  cout << "In PolysRemoveInvalid" << endl;
1890  cout << "Creating ponds" << endl;
1891  if (cfg_MaxPondSize.value() > 0) {
1892  // This takes any small freshwater and converts it to a pond.
1893  for (unsigned int i = 0; i < m_elems.size(); i++) {
1894  if (m_elems[i]->GetElementType() == tole_Freshwater) {
1895  if (m_elems[i]->GetArea() <= cfg_MaxPondSize.value()) {
1896  Pond* pond = new Pond(this);
1897  pond->DoCopy(m_elems[i]);
1898  pond->SetALMaSSEleType(g_letype->BackTranslateEleTypes(tole_Pond));
1899  pond->SetElementType(tole_Pond);
1900  // lct: We need to free the previous memory , then link to new element
1901  delete m_elems[i];
1902  m_elems[i] = dynamic_cast<LE*>(pond);
1903  }
1904  }
1905  }
1906  }
1907  cout << "In PolysValidate second time" << endl;
1908  PolysValidate(true);
1909 
1916  {
1917  cout << "In DoMissingPolygonsManipulations" << endl;
1918  // Find big continuous polygons
1919  for (unsigned int i = 0; i < m_elems.size(); i++)
1920  {
1921  if (m_elems[i]->GetElementType() == tole_Missing)
1922  {
1923  double area = m_elems[i]->GetArea();
1924  int areaMinrect = (m_elems[i]->GetMaxX() - m_elems[i]->GetMinX()) * (m_elems[i]->GetMaxY() - m_elems[i]->GetMinY());
1925  if ((areaMinrect / area > 4) || (area < 1000))
1926  {
1927  // Unlikely to be a field, or if so a very narrow odd one. We will assume this is a missing data issue.
1928  }
1929  else
1930  {
1931  // Big poly with more than 25% of the included rectangle covered, must be a field of some sort.
1932  // create a new wasteland and swap this in to the m_elems, then delete the old missing polygon
1933  LE * wl = NewElement(tole_Wasteland);
1934  wl->SetPoly(m_elems[i]->GetPoly());
1935  wl->SetArea(floor(0.5 + area)); // lct: To Remove This was already rounded wl->SetArea(area) should be enough
1936  wl->SetSoilType(m_elems[i]->GetSoilType());
1937  wl->SetUnsprayedMarginPolyRef(-1);
1938  wl->SetCentroid(-1, -1);
1939  wl->SetOpenness(0);
1940  delete m_elems[i];
1941  m_elems[i] = wl;
1942  }
1943  }
1944  }
1945  // By here all the big ones should be safely tidied away to wasteland and now we need to deal with the raster map.
1947  for (unsigned int i = 0; i < m_elems.size(); i++)
1948  {
1949  // Now we deal with all the little ones that were not by fields
1950  if (m_elems[i]->GetElementType() == tole_Missing)
1951  {
1952  LE * wl = NewElement(tole_Wasteland);
1953  wl->SetPoly(m_elems[i]->GetPoly());
1954  wl->SetArea(m_elems[i]->GetArea());
1955  wl->SetSoilType(m_elems[i]->GetSoilType());
1956  wl->SetUnsprayedMarginPolyRef(-1);
1957  wl->SetCentroid(-1, -1);
1958  wl->SetOpenness(0);
1959  delete m_elems[i];
1960  m_elems[i] = wl;
1961  }
1962  }
1963  cout << "In PolysValidate third time" << endl;
1964  PolysValidate(false);
1965  if (PolysRemoveInvalid()) {
1966  cout << "In PolysValidate fourth time" << endl;
1967  PolysValidate(true);
1968  }
1969  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after resolving missing polygons. ", "");
1970  didCalcOther = true;
1971  }
1972 
1973  // ChangeMapMapping() also enters a valid starting
1974  // coordinate for the border generating farm method below.
1975  cout << "In ChangeMapMapping" << endl;
1976  ChangeMapMapping();
1977 
1981  if ((m_LargestPolyNumUsed != ((int)m_elems.size() - 1)))
1982  {
1983  cout << "In poly renumber" << endl;
1984 
1985  PolysRenumber();
1986  didRenumber = true;
1987  }
1988  // do we want to remove small polygons?
1990  {
1991  cout << "In Landscape::Landscape() Small polygon removal" << endl;
1992  int removed = RemoveSmallPolygons();
1993  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after removing small polygons and map dump. Polygons removed:", removed);
1994  didCalcOther = true;
1995  }
1996  // Do we want to re-write the current files and consolidate polys?
1997  else if (l_map_consolidatepolys.value())
1998  {
1999  cout << "In consolidate polys" << endl;
2000  didConsolidate = true;
2001  ConsolidatePolys();
2002  }
2003  else if (g_map_le_borderremoval.value())
2004  {
2005  cout << "In map_le_borderremoval" << endl;
2006  // Does not use centroids so is safe to use here
2007  BorderRemoval();
2008  CountMapSquares();
2009  ForceArea();
2010  g_msg->Warn(WARN_FILE, "Landscape::Landscape() - BorderRemoval "" map dump to follow.", "");
2011  didCalcOther = true;
2012  }
2013 
2014 
2015  // By the time we reach this point we need to have completed all major polygon removal and are ready to calculate centroids if they are needed. There
2016  // are two reasons for this - 1) that we did not have them in the original polyref file, 2) that we changed the map
2017  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation)
2018  {
2019  PolysValidate(false);
2020  if (PolysRemoveInvalid()) PolysValidate(true);
2021  ChangeMapMapping();
2022  PolysRenumber();
2024  didCalcCentroids = true;
2025  }
2026  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation || didCalcCentroids || l_map_calc_openness.value())
2027  {
2029  else CalculateOpenness(false);
2030  didCalcOpenness = true;
2031  }
2032  if (didCalcCentroids || didConsolidate || didCalcOpenness || didCalcOther || m_NeedCentroidCalculation || didRenumber || !m_FarmManager->GetIsRenumbered())
2033  {
2034  // We need to dump the map and polyrefs
2035  string filestr = l_map_map_file.value();
2036  std::size_t ind = filestr.find(".lsb"); // Find the starting position of substring in the string
2037  if (ind != std::string::npos) {
2038  filestr.erase(ind, 4); // erase function takes two parameter, the starting index in the string from where you want to erase characters and total no of characters you want to erase.
2039  std::cout << filestr << "\n";
2040  }
2041  string dumpmap = filestr + "_dump.lsb";
2042  string farmstr = filestr + "_farmref_dump.txt";
2043  string polystr = filestr + "_polyref_dump.txt";
2044 
2045  m_FarmManager->DumpFarmrefs(farmstr.c_str());
2046  DumpMap(dumpmap.c_str());
2047  PolysDump(polystr.c_str());
2048  if (dump_exit) {
2049  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
2050  exit(0);
2051  }
2052  else {
2053  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Dump file done", "Remember to rename the new map and polyref file.");
2054  }
2055  }
2056 
2062  // Below here we have the more complicated map manipulations. These will need recalculation of centroids and openness after they are run.
2063  // However, we really do not want to get here with invalid centroids, hence forced dump and exit for manipulations up to this point.
2064 
2065  didCalcOther = false;
2066  // Add artificial hedgebanks to the hedges in the landscape,
2067  // if requested.
2068  if (l_map_art_hedgebanks.value()) {
2069  hb_Add();
2070  didCalcOther = true;
2071  }
2072  else if (g_map_le_borders.value()) // Can't create borders and hedgerows at the same time, so independently checked
2073  {
2074  cout << "Generating LE Borders around fields" << endl;
2075  cout << "Border chance = " << g_map_le_border_chance.value() << endl;
2076  cout << "Border width = " << g_map_le_borderwidth.value() << endl;
2077  cout << "Adding Borders" << endl;
2078 
2079  // Keep track of how much area the borders take up per farm
2080  std::vector<int> border_area_per_farm(m_FarmManager->GetNoFarms(), 0);
2081  std::vector<int> total_area_per_farm;
2082  for (int f = 0; f < m_FarmManager->GetNoFarms(); f++) {
2083  total_area_per_farm.push_back(m_FarmManager->GetFarmTotalSize(f));
2084  }
2085  unsigned sz = (unsigned)m_elems.size();
2086  int begin = 1;
2087  // If the flag is set to true, we first try to limit the border to one side of the field (begin == 0)
2088  // If not we only run through the fields once and add borders all around the edge (begin == 1)
2090  begin = 0;
2091  }
2092  for (int allAround = begin; allAround <= 1; allAround++){
2093  int Nborders = 0;
2094  for (unsigned i = 0; i < sz; i++) {
2095  if (m_elems[i]->GetBorder() != NULL || (allAround == begin && m_elems[i]->GetOwner() != NULL && g_random_fnc(100) < g_map_le_border_chance.value())){
2096  // Border around this element, so must be a farm field.
2097  // If the field is too small then ignore it
2098  if (m_elems[i]->GetArea() > g_map_le_borders_min_field_size.value()){
2099  int farm_id = m_elems[i]->GetOwnerIndex();
2100 
2101  // Check if farm already has enough border area
2102  if (border_area_per_farm[farm_id] < total_area_per_farm[farm_id] * cfg_FarmAreaPercentage.value() * 0.01) {
2104  int area_temp = BorderAdd(m_elems[i], t, allAround);
2105  if (area_temp > 0) {
2106  Nborders++;
2107  border_area_per_farm[farm_id] += area_temp;
2108  }
2109  }
2110  }
2111  }
2112  }
2113  g_msg->Warn(WARN_MSG, "Landscape::Landscape(): In border adding iteration: ", allAround);
2114  g_msg->WarnAddInfo(WARN_MSG, "Landscape::Landscape(): Fields with border successfully added: ", Nborders);
2115  }
2116  didCalcOther = true;
2117  }
2118  else // Some special code to 'soften' the edges of orchards
2120  {
2121  // Generate border around each *orchard* landscape element.
2122  for (unsigned int i = 0; i < m_elems.size(); i++) {
2123  if (m_elems[i]->GetElementType() == tole_Orchard)
2124  {
2126  int area = BorderAdd(m_elems[i], t);
2127  }
2128  }
2129  didCalcOther = true;
2130  }
2131 
2133  {
2134  std::vector<int> border_area_per_farm(m_FarmManager->GetNoFarms(), 0);
2135  std::vector<int> total_area_per_farm;
2136  for (int f = 0; f < m_FarmManager->GetNoFarms(); f++) {
2137  total_area_per_farm.push_back(m_FarmManager->GetFarmTotalSize(f));
2138  }
2139  int begin = 1;
2140  for (int allAround = begin; allAround <= 1; allAround++){
2141  int Nborders = 0;
2142 
2143  // Generate border around each *orchard* landscape element.
2144  for (unsigned int i = 0; i < m_elems.size(); i++) {
2145  if (m_elems[i]->GetElementType() == tole_OliveGrove)
2146  {
2147  if (m_elems[i]->GetBorder() != NULL || (allAround == begin && m_elems[i]->GetOwner() != NULL && g_random_fnc(100) < g_map_le_border_chance.value())){
2148  // Border around this element, so must be a farm field.
2149  // If the field is too small then ignore it
2150  if (m_elems[i]->GetArea() > g_map_le_borders_min_field_size.value()){
2151  int farm_id = m_elems[i]->GetOwnerIndex();
2152 
2153  // Check if farm already has enough border area
2154  if (border_area_per_farm[farm_id] < total_area_per_farm[farm_id] * cfg_FarmAreaPercentage.value() * 0.01) {
2156  int area_temp = BorderAdd(m_elems[i], t, allAround);
2157  if (area_temp > 0) {
2158  Nborders++;
2159  border_area_per_farm[farm_id] += area_temp;
2160  }
2161  }
2162  }
2163  }
2164  }
2165  g_msg->Warn(WARN_MSG, "Landscape::Landscape(): In border adding iteration: ", allAround);
2166  g_msg->WarnAddInfo(WARN_MSG, "Landscape::Landscape(): Fields with border successfully added: ", Nborders);
2167  }
2168  }
2169  didCalcOther = true;
2170  }
2171  else
2172  // Unsprayed Margin Code....
2174  {
2175  cout << "Adding unsprayed margins" << endl;
2176 
2177  // Generate border around each *farm* landscape element.
2178  for (unsigned int i = 0; i < m_elems.size(); i++)
2179  {
2180  if (m_elems[i]->GetUnsprayedMarginPolyRef() == 1)
2181  {
2182  // But not if the field is too small to have them
2183  if (m_elems[i]->GetArea() > g_map_le_umargin_min_field_size.value())
2184  {
2186  }
2187  else m_elems[i]->SetUnsprayedMarginPolyRef(-1);
2188  }
2189  }
2190  didCalcOther = true;
2191  }
2192  else if (cfg_AddBeetleBanks.value())
2193  {
2194  cout << "Adding beetle banks/strips now" << endl;
2196  didCalcOther = true;
2197  }
2198  else if (cfg_AddPatches.value())
2199  {
2200  cout << "Adding patches now" << endl;
2202  didCalcOther = true;
2203  }
2204 
2207  {
2209  }
2215  if (l_map_dump_enable.value() || didCalcOther)
2216  {
2217  CountMapSquares();
2218  ForceArea();
2219  PolysValidate(false);
2220  if (PolysRemoveInvalid()) PolysValidate(true);
2221  ChangeMapMapping();
2222  PolysRenumber();
2225  string filestr = l_map_map_file.value();
2226  std::size_t ind = filestr.find(".lsb"); // Find the starting position of substring in the string
2227  if (ind != std::string::npos) {
2228  filestr.erase(ind, 4); // erase function takes two parameter, the starting index in the string from where you want to erase characters and total no of characters you want to erase.
2229  std::cout << filestr << "\n";
2230  }
2231  string dumpmap = filestr + "_dump.lsb";
2232  string farmstr = filestr + "_farmref_dump.txt";
2233  string polystr = filestr + "_polyref_dump.txt";
2234  m_FarmManager->DumpFarmrefs(farmstr.c_str());
2235  cout << "Dumping map" << endl;
2236  DumpMap(dumpmap.c_str());
2237  cout << "Dumping polygon refs file" << endl;
2238  PolysDump(polystr.c_str());
2239  if (dump_exit) {
2240  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
2241  exit(0);
2242  }
2243  else {
2244  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Dump file done", "Remember to rename the new map and polyref file.");
2245  }
2246  }
2247 
2248  // Set the type of hedgebanks.
2249  int l_subtype = cfg_HedgeSubtypeMinimum.value();
2250  for (unsigned int i = 0; i < m_elems.size(); i++) {
2251  if (m_elems[i]->GetElementType() == tole_HedgeBank) {
2252  m_elems[i]->SetSubType(l_subtype);
2253  if (++l_subtype >= cfg_HedgeSubtypeMaximum.value())
2254  l_subtype = cfg_HedgeSubtypeMinimum.value();
2255  }
2256  }
2257 
2258  // And another to set the type of hedges
2259  // ***CJT*** 2003-12-02
2260  l_subtype = 0;
2261  for (unsigned int i = 0; i < m_elems.size(); i++) {
2262  if (m_elems[i]->GetElementType() == tole_Hedges) {
2263  m_elems[i]->SetSubType(l_subtype);
2264  if (++l_subtype >= 3)
2265  l_subtype = 0;
2266  }
2267  }
2271  CreatePondList();
2276  cout << "Initiating farm management" << endl;
2278  //Set the TOV attributes
2279  for (unsigned int i = 0; i < m_elems.size(); i++) {
2280  Set_TOV_Att(m_elems[i]);
2281  }
2282 
2283  m_toxShouldSpray = false; // Flag for special pesticide tests
2286  g_date->Reset();
2287 
2288  /*
2289  if ( g_farm_test_crop.value() ) {
2290  TestCropManagement();
2291  exit( 0 );
2292  }
2293  */
2294 
2295  // Set up treatment flags
2296  // Reset internal state for the LE loop generator.
2297  // Compulsory!
2298  SupplyLEReset();
2299  // Get number of *all* landscape elements.
2300  int l_count = SupplyLECount();
2301 
2302  // Now loop through then.
2303  for (int i = 0; i < l_count; i++) {
2304  // Fetch next LE by its polygon reference number. Alternative
2305  // loop mechanism: This will return -1 at end-of-loop.
2306  int a_poly = SupplyLENext();
2307 
2308  // Skip uninteresting polygons by type, ownership,
2309  // phase of the moon, whatever.
2310  // if ( these_are_not_the_droids_we_are_looking_for( a_poly )) {
2311  if (SupplyElementType(a_poly) != tole_Field)
2312  continue;
2313 
2314  // Example: Set x% of them to ignore insecticide of all types.
2316  // Get current signal mask for polygon.
2317  LE_Signal l_signal = SupplyLESignal(a_poly);
2318  // Logical OR in/AND out the signals you are interested in.
2319  // The current signals are at the top of Elements.h
2320  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE | LE_SIG_NO_FUNGICIDE | LE_SIG_NO_GROWTH_REG;
2321  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE;
2322  // Write the mask back out to the polygon.
2323  SetLESignal(a_poly, l_signal);
2324  }
2325  }
2326  // for veg area dumps
2327  l_vegtype_areas = (double *)malloc(sizeof(double) * (tov_Undefined + 1));
2328 
2329  if (l_vegtype_areas == NULL) {
2330  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): Out of memory!", "");
2331  exit(1);
2332  }
2333  FILE * outf;
2334  if (cfg_dumpvegjan.value()) {
2335  outf = fopen(cfg_dumpvegjanfile.value(), "w");
2336  if (!outf) {
2337  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjanfile.value());
2338  exit(1);
2339  }
2340  else
2341  fclose(outf);
2342  }
2343 
2344  if (cfg_dumpvegjune.value()) {
2345  outf = fopen(cfg_dumpvegjunefile.value(), "w");
2346  if (!outf) {
2347  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjunefile.value());
2348  exit(1);
2349  }
2350  else
2351  fclose(outf);
2352  }
2353 
2357  if (l_map_dump_veg_enable.value()) {
2358  FILE * f;
2359  f = fopen("VegDump.txt", "w");
2360  if (!f) {
2361  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): VegDump.txt could not be created", "");
2362  exit(1);
2363  }
2364  fprintf(f, "Year\tDayOfYear\tMonth\tDay\tHeight\tBiomass\tGrazed\tDensity\tCover\tWeedBiomass\ttovNum\tInsectBiomass\tLATotal\tLAGreen\tDigestibility\tGreenBiomass\tDeadBiomass\tGooseGrazing\tSpilledGrain\tPollen\tNectar\n");
2365  fclose(f);
2366  }
2368  FILE * f;
2369  f = fopen("GrainDump.txt", "w");
2370  if (!f) {
2371  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): GrainDump.txt could not be created", "");
2372  exit(1);
2373  }
2374  fprintf(f, "SimDay\tYear\tDayOfYear\tMonth\tDay\tpoly\tvegtype\tGrain\tMaize\n");
2375  fclose(f);
2376  }
2378  FILE * f;
2379  f = fopen("EventDump.txt", "w");
2380  if (!f) {
2381  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): EventDump.txt could not be created", "");
2382  exit(1);
2383  }
2384  fclose(f);
2385  }
2386 
2387  if (cfg_DumpFarmAreas.value()){
2389  }
2390 
2391  // If we are testing a pesticide then set the enum attribute
2398  {
2399  m_RodenticideManager = new RodenticideManager("BaitLocations_input.txt", this);
2400  m_RodenticidePreds = new RodenticidePredators_Population_Manager(this);
2401  }
2402 
2406  // Write ASCII file:
2407  if (l_map_write_ascii.value()) {
2408  int x = l_map_ascii_utm_x.value();
2409  int y = l_map_ascii_utm_y.value();
2410  GISASCII_Output("AsciiLandscape.txt", x, y);
2411  }
2412 
2413 #ifdef __FLOWERTESTING
2414  fstream ofilepntotal(cfg_total_polnek_file.value(), ios::out);
2415  ofilepntotal.close();
2416  fstream ofilepntov(cfg_tov_polnek_file.value(), ios::out);
2417  ofilepntov.close();
2418  fstream ofilepn(cfg_habitat_polnek_file.value(), ios::out);
2419  ofilepn.close();
2420 #endif
2421 #ifdef __RECORDFARMEVENTS
2422  m_farmeventfile = new ofstream(cfg_farmeventfile.value(), ofstream::out);
2423  // write header
2424  (*m_farmeventfile) << "Farm No \t Parcel No \t TOV \t FarmToDo \t Day \t Year \n";
2425 #endif
2426 
2429  //Pinkfeet
2431  //Barnacle
2433  //Greylag
2435  if (cfg_WriteCurve.value()) {
2439  }
2440  if (cfg_pollen_nectar_on.value()) {
2441 
2442  //Pollen and nectar ini
2443  m_pollen_map.resize(m_height, m_width);
2444  m_pollen_map.fill(0);
2445  m_nectar_map.resize(m_height, m_width);
2446  m_nectar_map.fill(0);
2447  m_polyid_map.resize(m_height, m_width);
2450  for (int i = 0; i < m_height; i++) {
2451  m_map_polyid_within_dist[i].resize(m_width);
2452  }
2453  //GeneratePolyIDMapWithinDist();
2454  // Initialize biomass map used when transferring pesticides to plant compartments
2455  m_biomass_map.resize(m_height, m_width);
2456  m_biomass_map.setZero();
2457  }
2458 
2459 
2460  m_poly_omp_locks.resize(m_elems.size());
2461  for (int i=0; i<m_poly_omp_locks.size(); i++){
2462  m_poly_omp_locks[i] = new omp_nest_lock_t;
2463  omp_init_nest_lock(m_poly_omp_locks[i]);
2464  }
2465 }

References LE_TypeClass::BackTranslateEleTypes(), cfg_AddBeetleBanks, cfg_AddPatches, cfg_B6A, cfg_B6B, cfg_B6C, cfg_B6D, cfg_B6E, cfg_B6F, cfg_B6G, cfg_B6H, cfg_BeetleBankType, cfg_DumpFarmAreas, cfg_dumpvegjan, cfg_dumpvegjanfile, cfg_dumpvegjune, cfg_dumpvegjunefile, cfg_FarmAreaPercentage, cfg_farmeventfile, cfg_G6A, cfg_G6B, cfg_G6C, cfg_G6D, cfg_G6E, cfg_G6F, cfg_G6G, cfg_G6H, cfg_habitat_polnek_file, cfg_HedgeSubtypeMaximum, cfg_HedgeSubtypeMinimum, cfg_MaxPondSize, cfg_P1A, cfg_P1B, cfg_P1C, cfg_P1D, cfg_P1E, cfg_P1F, cfg_P1G, cfg_P1H, cfg_PatchesType, cfg_pesticidemapcellsize, cfg_pesticidemapnoyears, cfg_pesticidemapon, cfg_pesticidemapstartyear, cfg_pesticidemaptype, cfg_pesticidetableon, cfg_pesticidetesttype, cfg_PestIncidenceMax, cfg_PestIncidenceMin, cfg_pollen_nectar_on, cfg_rodenticide_enable, cfg_total_polnek_file, cfg_tov_polnek_file, cfg_WriteCurve, LE::DoCopy(), g_date, g_landscape_ptr, g_letype, g_map_le_border_chance, g_map_le_border_limited, g_map_le_borderremoval, g_map_le_borders, g_map_le_borders_min_field_size, g_map_le_borderstype, g_map_le_borderwidth, g_map_le_umargin_min_field_size, g_map_le_unsprayedmargins, g_map_olivetree_borders, g_map_orchards_borders, g_msg, g_random_fnc(), g_speedy_Divides, l_map_art_hedgebanks, l_map_ascii_utm_x, l_map_ascii_utm_y, l_map_calc_openness, l_map_consolidatepolys, l_map_dump_enable, l_map_dump_event_enable, l_map_dump_gfx_enable, l_map_dump_gfx_file, l_map_dump_grain_enable, l_map_dump_veg_enable, l_map_map_file, l_map_nectarpollencomposition, l_map_no_pesticide_fields, l_map_poly_file, l_map_print_git_version_info, l_map_print_version_info, l_map_removesmallpolygons, l_map_write_ascii, last_treatment, RasterMap::MapWidth(), Calendar::Reset(), LE::SetArea(), VegElement::SetBiomassScalers(), LE::SetCentroid(), LE::SetOpenness(), LE::SetPoly(), LE::SetSoilType(), LE::SetUnsprayedMarginPolyRef(), tole_Field, tole_Freshwater, tole_HedgeBank, tole_Hedges, tole_Missing, tole_OliveGrove, tole_Orchard, tole_Pond, tole_UnsprayedFieldMargin, tole_Wasteland, tov_Undefined, LE_TypeClass::TranslateEleTypes(), CfgInt::value(), CfgFloat::value(), CfgBool::value(), CfgStr::value(), version_date, version_major, version_minor, version_revision, MapErrorMsg::Warn(), WARN_BUG, WARN_FILE, WARN_MSG, MapErrorMsg::WarnAddInfo(), and CurveClass::WriteDataFile().

Member Function Documentation

◆ AddBeetleBankIfPossible()

int Landscape::AddBeetleBankIfPossible ( LE a_field,
TTypesOfLandscapeElement  a_tole 
)
protected

Determines whether a beetlebank can be added to the field depending on physical characteristics and adds it.

Beetle bank placement rules are:
Field is above cfg_BeetleBankMaxDistance (default = 150m) long and wide Beetle banks are place along the long direction of the field

4651  {
4657  int cx = a_field->GetCentroidX();
4658  int cy = a_field->GetCentroidY();
4659  // The centroid is the only estimate we have (and it at least should be in the field).
4660  // So start here and find the centre
4661  if (!FindFieldCenter(a_field, &cx, &cy)) return -1;
4662 
4663  // Find the rectangle that describes the field the best
4664  // Returns the alignment of the longest axis in the rectangle
4665  // and sets width and starting point on short side of best rectangle
4666  int width = 0;
4667  int x_start_perp = 0;
4668  int y_start_perp = 0;
4669  int alignment = FindBestRectangle(a_field->GetPoly(), &cx, &cy, &width, &x_start_perp, &y_start_perp);
4670  if (alignment == -1) return -1;
4671  // Get alignment of shortest axis (perpendicular to longest axis)
4672  int perp = alignment + 4;
4673  if (perp >= 8) perp -= 8;
4674  // Find the number of beetle banks (if any)
4675  if (width < cfg_BeetleBankMaxDistance.value()) return -1;
4676  int numberOfBanks = floor((float)width / cfg_BeetleBankMaxDistance.value());
4677  // Correct for the length of the step
4678  if (alignment == 2 || alignment == 6) width /= sqrt(2);
4679  if (alignment == 1 || alignment == 3 || alignment == 5 || alignment == 7) width /= sqrt(5);
4680  // Find the distance between the banks so they are equidistant
4681  float distBetweenBanks = (float)width / (numberOfBanks+1);
4682  // Now create the banks along the longest axis of the best rectangle
4683  int beetle_bank_total_area = 0;
4684  for (int n = 1; n <= numberOfBanks; n++) {
4685  // Find the appropriate length and starting point
4686  int x_start = x_start_perp - n * distBetweenBanks * m_x_add[perp];
4687  int y_start = y_start_perp - n * distBetweenBanks * m_y_add[perp];
4688  int x_end = x_start_perp - n * distBetweenBanks * m_x_add[perp];
4689  int y_end = y_start_perp - n * distBetweenBanks * m_y_add[perp];
4690  AxisLoop(a_field->GetPoly(), &x_start, &y_start, alignment);
4691  x_start -= (cfg_BeetleBankWidth.value() + 1) * m_x_add[alignment];
4692  y_start -= (cfg_BeetleBankWidth.value() + 1) * m_y_add[alignment];
4693  AxisLoop(a_field->GetPoly(), &x_end, &y_end, alignment + 8);
4694  x_end -= (cfg_BeetleBankWidth.value() + 1) * m_x_add[alignment + 8];
4695  y_end -= (cfg_BeetleBankWidth.value() + 1) * m_y_add[alignment + 8];
4696  APoint p_start(x_start, y_start);
4697  APoint p_end(x_end, y_end);
4698  int length = DistanceToP(p_start, p_end);
4699  // Correct for the length of the step
4700  if (alignment == 2 || alignment == 6) length /= sqrt(2);
4701  if (alignment == 1 || alignment == 3 || alignment == 5 || alignment == 7) length /= sqrt(5);
4702 
4703  // Make the new landscape element
4704  LE* BeetleBank;
4705  BeetleBank = NewElement(a_tole);
4706  BeetleBank->SetALMaSSEleType(g_letype->BackTranslateEleTypes(a_tole));
4707  BeetleBank->SetVegPatchy(true);
4709  m_elems.resize(m_elems.size() + 1);
4710  m_elems[m_elems.size() - 1] = BeetleBank;
4713  BeetleBank->SetSlope(a_field->GetSlope());
4714  BeetleBank->SetAspect(a_field->GetAspect());
4715  BeetleBank->SetElevation(a_field->GetElevation());
4716  BeetleBank->SetOwner(a_field->GetOwner(), a_field->GetOwner()->GetFarmNumber(), a_field->GetOwnerIndex());
4717  //Set pollen and nectar curve
4719  int area = 0;
4720  int width = cfg_BeetleBankWidth.value();
4721  // Correct for the length of the step (opposite of length correction, to keep area constant)
4722  if (alignment == 2 || alignment == 6) width *= sqrt(2);
4723  if (alignment == 1 || alignment == 3 || alignment == 5 || alignment == 7) width *= sqrt(5);
4724  // Vectors are used to add all cells in the region even if the step along the longest direction is in both x and y at the same time
4725  // If the alignment is 45 degrees (or 135 degrees) the perpendicular step has 2 substeps
4726  // If the alignment is 22.5 degrees (or 67.5, 112.5, 157.5 degrees) the perpendicular step has 5 substeps
4727  vector<vector<int>> x_direction = { {0}, { -1, -1, 0, 1, 0}, { -1, 0 }, { 0, 0, 1, 0, 1}, { -1 }, { 0, 0, -1, 0, -1 }, { 0, -1 }, { 1, 1, 0, -1, 0 } };
4728  vector<vector<int>> y_direction = { {-1}, { 0, 0, -1, 0, -1}, { 0, -1 }, { 1, 1, 0, -1, 0}, { 0 }, { 1, 1, 0, -1, 0 }, { 1, 0 }, { 0, 0, -1, 0, -1 } };
4729  vector<int> l_direction = { 1, 5, 2, 5, 1, 5, 2, 5 };
4730  int tx = 0;
4731  int ty = 0;
4732 
4733  int iteration = 0;
4734  for (int w = 0; w < width; w++) {
4735  if (w > 0) {
4736  if (w % l_direction[alignment] == 0) iteration++;
4737  tx += x_direction[alignment][w - iteration * l_direction[alignment]];
4738  ty += y_direction[alignment][w - iteration * l_direction[alignment]];
4739  }
4740  for (int i = 0; i < length; i++) {
4741  int x_temp = tx + x_start - i * m_x_add[alignment];
4742  int y_temp = ty + y_start - i * m_y_add[alignment];
4743  if ((x_temp >= 0) && (y_temp >= 0) && (x_temp < m_width) && (y_temp < m_height)) {
4744  // Only add to beetle bank if we are still in the field
4745  if (a_field->GetPoly() == m_land->Get(x_temp, y_temp)) {
4746  m_land->Put(x_temp, y_temp, (int)m_elems.size() - 1);
4747  area += 1;
4748  a_field->AddArea(-1.0);
4749  }
4750  }
4751  }
4752  }
4753  BeetleBank->SetArea(double(area));
4754  beetle_bank_total_area += area;
4755  BeetleBank->SetValidXY(x_start + 0.5 * length * m_x_add[alignment], y_start + 0.5 * length * m_y_add[alignment]);
4756  BeetleBank->SetMapValid(true);
4757 
4758  }
4759  return beetle_bank_total_area;
4760 }

References LE::AddArea(), LE_TypeClass::BackTranslateEleTypes(), cfg_BeetleBankMaxDistance, cfg_BeetleBankWidth, cfg_FlowerStripPollenNectarCurveNum, g_letype, LE::GetAspect(), LE::GetCentroidX(), LE::GetCentroidY(), LE::GetElevation(), Farm::GetFarmNumber(), LE::GetOwner(), LE::GetOwnerIndex(), LE::GetPoly(), LE::GetSlope(), m_polymapping, LE::SetArea(), LE::SetAspect(), LE::SetElevation(), LE::SetMapIndex(), LE::SetMapValid(), LE::SetOwner(), LE::SetPollenNectarCurveRef(), LE::SetPoly(), LE::SetSlope(), LE::SetValidXY(), VegElement::SetVegPatchy(), and CfgInt::value().

◆ AddBeetleBanks()

void Landscape::AddBeetleBanks ( TTypesOfLandscapeElement  a_tole)
protected

The starting point for adding beetlebanks to a field (can be used to add ‘banks’ of any tole_type.

Beetle-bank addition - tests whether we can add a bank (or more) to this field, and then decides where to put it an adds it.

For each element, if it is a field then assess whether should have a beetle bank. This will depend on whether it is in the region defined for adding the bank, and a probability. This code requires polygon centroids to be active, either calculated or via l_map_read_openness == true.

To provide for more flexibilty, a tole_type is passed, and beetlebanks may be created of this tole_type instead of tole_BeetleBank

4593  {
4594  // **************************************************************************************
4598  // **************************************************************************************
4606  int BBs=0;
4607  int tx1 = cfg_BeetleBankMinX.value();
4608  int tx2 = cfg_BeetleBankMaxX.value();
4609  int ty1 = cfg_BeetleBankMinY.value();
4610  int ty2 = cfg_BeetleBankMaxY.value();
4611  bool doit = false;
4612  unsigned sz=(unsigned) m_elems.size();
4613 
4614  std::vector<int> beetle_bank_area_per_farm(m_FarmManager->GetNoFarms(), 0);
4615 
4616  for (unsigned i=0; i<sz; i++){
4617  if (m_elems[ i ]->GetElementType() == tole_Field){
4618  doit = false;
4619  int cx = m_elems[ i ]->GetCentroidX();
4620  int cy = m_elems[ i ]->GetCentroidY();
4621  if (!cfg_BeetleBankInvert.value()){
4622  if ((cx >= tx1) && (cy >= ty1) && (cx <= tx2) && (cy <= ty2)){
4623  doit = true;
4624  }
4625  }
4626  else if ((cx < tx1) || (cy < ty1) || (cx > tx2) || (cy > ty2)){
4627  doit = true;
4628  }
4629  if (doit){
4630  int farm_id = m_elems[i]->GetOwnerIndex();
4631  int farm_area = m_FarmManager->GetFarmTotalSize(farm_id);
4632  // Field is in the right area, use chance to see if beetle bank should be added
4634  // Check if farm already has enough beetle bank area
4635  if (beetle_bank_area_per_farm[farm_id] < farm_area * cfg_FarmAreaPercentage.value() * 0.01) {
4636  int area_temp = AddBeetleBankIfPossible(m_elems[i], a_tole);
4637  if (area_temp > 0) {
4638  BBs++;
4639  beetle_bank_area_per_farm[farm_id] += area_temp;
4640  }
4641  }
4642  }
4643  }
4644  }
4645  }
4646  g_msg->Warn( WARN_MSG, "Landscape::AddBeetleBanks(): Fields with BeetleBanks successfully added: ", BBs);
4647 }

References cfg_BeetleBankChance, cfg_BeetleBankInvert, cfg_BeetleBankMaxX, cfg_BeetleBankMaxY, cfg_BeetleBankMinX, cfg_BeetleBankMinY, cfg_FarmAreaPercentage, g_msg, g_random_fnc(), tole_Field, CfgInt::value(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_MSG.

◆ AddPatches()

void Landscape::AddPatches ( TTypesOfLandscapeElement  a_tole)
protected

The starting point for adding patches to a field (can be used to add patches of any tole_type)

Patches addition - tests whether we can add a patch to this field, and then decides where to put it an adds it.

For each element, if it is a field then assess whether should have a patch. This will depend on the probabilities and the size of the field. To provide for more flexibilty, a tole_type is passed, and patches may be created of any tole_type.

4977  {
4978  // **************************************************************************************
4982  // **************************************************************************************
4988  int Npatches = 0;
4989  unsigned sz = (unsigned)m_elems.size();
4990 
4991  std::vector<int> patches_area_per_farm(m_FarmManager->GetNoFarms(), 0);
4992 
4993  for (unsigned i = 0; i < sz; i++) {
4994  if (m_elems[i]->GetElementType() == tole_Field) {
4995  int farm_id = m_elems[i]->GetOwnerIndex();
4996  int farm_area = m_FarmManager->GetFarmTotalSize(farm_id);
4997  // Check if farm already has enough beetle bank area
4998  if (patches_area_per_farm[farm_id] < farm_area * cfg_FarmAreaPercentage.value() * 0.01) {
4999  int area_temp = AddPatchIfPossible(m_elems[i], a_tole);
5000  if (area_temp > 0) {
5001  Npatches++;
5002  patches_area_per_farm[farm_id] += area_temp;
5003  }
5004  }
5005  }
5006  }
5007  g_msg->Warn(WARN_MSG, "Landscape::AddPatches(): Fields with patch successfully added: ", Npatches);
5008 }

References cfg_FarmAreaPercentage, g_msg, tole_Field, CfgInt::value(), MapErrorMsg::Warn(), and WARN_MSG.

◆ AddPatchIfPossible()

int Landscape::AddPatchIfPossible ( LE a_field,
TTypesOfLandscapeElement  a_tole 
)
protected

Determines whether a patch can be added to the field depending on physical characteristics and adds it.

Patch placement rules are:
The field is above 1 / (cfg_PatchesFieldAreaMaxPercentage * 0.01) * cfg_PatchesMinWidth ** 2 m2 (default is 1/0.15 * 10**2 = 666 m2. The patch can not be bigger than cfg_PatchesMaxWidth ** 2 m2 (default is 100**2 = 10.000 m2) Patches are place in the middle of the field

5010  {
5018  // Check if field is to small to add patch
5019  if (a_field->GetArea() * cfg_PatchesFieldAreaMaxPercentage.value() * 0.01 < pow(cfg_PatchesMinWidth.value(),2))
5020  {
5021  cout << "Field area of " << a_field->GetArea() << " is to small for a patch" << endl;
5022  return -1;
5023  }
5024  int cx = a_field->GetCentroidX();
5025  int cy = a_field->GetCentroidY();
5026  // The centroid is the only estimate we have (and it at least should be in the field).
5027  // So start here and find the centre
5028  if (!FindFieldCenter(a_field, &cx, &cy)) return -1;
5029 
5030  // Make the new landscape element
5031  LE* Patch;
5032  Patch = NewElement(a_tole);
5033  Patch->SetALMaSSEleType(g_letype->BackTranslateEleTypes(a_tole));
5034  Patch->SetVegPatchy(true);
5036  m_elems.resize(m_elems.size() + 1);
5037  m_elems[m_elems.size() - 1] = Patch;
5039  Patch->SetPoly(hb_first_free_poly_num++);
5040  Patch->SetSlope(a_field->GetSlope());
5041  Patch->SetAspect(a_field->GetAspect());
5042  Patch->SetElevation(a_field->GetElevation());
5043  //Patch->SetOwner(a_field->GetOwner(), a_field->GetOwner()->GetFarmNumber(), a_field->GetOwnerIndex());
5044  //Set pollen and nectar curve
5046  int area = 0;
5047 
5048  // Add patch by spiraling out from the center cx, cy
5049  int x = 0, y = 0, dx = 0;
5050  int dy = -1;
5051  int t = cfg_PatchesMaxWidth.value();
5052  int margin = cfg_PatchesFreeMargin.value();
5053  int field_poly = a_field->GetPoly();
5054  int patch_poly = Patch->GetPoly();
5055  int temp;
5056  for (int i = 0; i < pow(t,2); i++) {
5057  //cout << x << "," << y << endl;
5058  if ((-t / 2 <= x) && (x <= t / 2) && (-t / 2 <= y) && (y <= t / 2)) {
5059  // Only add to patch if we are still in the field (and have the wanted margin around the patch)
5060  vector<int> x_coords = { cx + x, cx + x + margin, cx + x - margin, cx + x, cx + x };
5061  vector<int> y_coords = { cy + y, cy + y, cy + y, cy + y + margin, cy + y - margin };
5062  bool outOfBound = false;
5063  for (int j = 0; j < 5; j++) {
5064  if ((x_coords[j] >= 0) && (y_coords[j] >= 0) && (x_coords[j] < m_width) && (y_coords[j] < m_height)) { // Check we are in map
5065  if (field_poly != m_land->Get(x_coords[j], y_coords[j]) && patch_poly != m_land->Get(x_coords[j], y_coords[j])) { // Check if we are outside of field
5066  outOfBound = true;
5067  break;
5068  }
5069  }
5070  }
5071  if (outOfBound) continue;
5072  if ((cx + x >= 0) && (cy + y >= 0) && (cx + x < m_width) && (cy + y < m_height)) {
5073  m_land->Put(cx + x, cy + y, (int)m_elems.size() - 1);
5074  area += 1;
5075  a_field->AddArea(-1.0);
5076  // Check that the area is less than cfg_PatchesFieldAreaMaxPercentage or exit for-loop
5077  if (area > a_field->GetArea() * cfg_PatchesFieldAreaMaxPercentage.value() * 0.01) break;
5078  }
5079  }
5080  if ((x == y) || ((x < 0) && (x == -y)) || ((x > 0) && (x == 1 - y))) {
5081  temp = -dy;
5082  dy = dx;
5083  dx = temp;
5084  }
5085  x += dx;
5086  y += dy;
5087  }
5088  Patch->SetArea(double(area));
5089  Patch->SetValidXY(cx, cy);
5090  Patch->SetMapValid(true);
5091 
5092  return area;
5093 }

References LE::AddArea(), LE_TypeClass::BackTranslateEleTypes(), cfg_FlowerStripPollenNectarCurveNum, cfg_PatchesFieldAreaMaxPercentage, cfg_PatchesFreeMargin, cfg_PatchesMaxWidth, cfg_PatchesMinWidth, g_letype, LE::GetArea(), LE::GetAspect(), LE::GetCentroidX(), LE::GetCentroidY(), LE::GetElevation(), LE::GetPoly(), LE::GetSlope(), m_polymapping, LE::SetArea(), LE::SetAspect(), LE::SetElevation(), LE::SetMapIndex(), LE::SetMapValid(), LE::SetPollenNectarCurveRef(), LE::SetPoly(), LE::SetSlope(), LE::SetValidXY(), LE::SetVegPatchy(), and CfgInt::value().

◆ AxisLoop()

void Landscape::AxisLoop ( int  a_poly,
int *  a_x,
int *  a_y,
int  a_axis 
)
protected

Tests the length of a vector to find when we step outside a given polygon.

Starting at a_x,a_y each location is tested along a vector given by m_x_add & m_y_add until we step outside the polygon. a_x & a_y are modified on return.

4940  {
4945  int ap1 = a_polyindex;
4946  while (ap1 == a_polyindex)
4947  {
4948  *(a_x) += m_x_add[a_axis];
4949  *(a_y) += m_y_add[a_axis];
4950  // Before we try to get a polyindex from the map, check we are still on the world
4951  if (*(a_x) < 0)
4952  {
4953  return;
4954  }
4955  if (*(a_y) < 0)
4956  {
4957  return;
4958  }
4959  if (*(a_x) >= m_width)
4960  {
4961  return;
4962  }
4963  if (*(a_y) >= m_height)
4964  {
4965  return;
4966  }
4967  // OK still in the map, get the polyindex
4968  ap1 = m_land->Get((*a_x), (*a_y)); // NB this returns the m_elemens index not the polyref (ChangeMapMapping has been called by here)
4969  }
4970 }

◆ BackTranslateEleTypes()

int Landscape::BackTranslateEleTypes ( TTypesOfLandscapeElement  EleReference)
inline

Returns the ALMaSS reference number translated from the TTypesOfLandscapeElement type.

2333 {
2334  return g_letype->BackTranslateEleTypes( EleReference );
2335 }

References LE_TypeClass::BackTranslateEleTypes(), and g_letype.

Referenced by Vole_Base::Set_ElemBorn().

◆ BackTranslateVegTypes()

int Landscape::BackTranslateVegTypes ( TTypesOfVegetation  VegReference)
inline

Returns the ALMaSS reference number translated from the TTypesOfVegetation type.

2339 {
2340  return g_letype->BackTranslateVegTypes( VegReference );
2341 }

References LE_TypeClass::BackTranslateVegTypes(), and g_letype.

Referenced by Vole_Base::Set_VegBorn().

◆ BorderAdd()

int Landscape::BorderAdd ( LE a_field,
TTypesOfLandscapeElement  a_type,
int  a_allAround = 1 
)
protected

Adds a border of the specified type (could be an unsprayed margin) around a field

4411  {
4412 
4413  LE* border;
4414  int width;
4415  // If it is an unsprayed field margin
4416  if (a_type == tole_UnsprayedFieldMargin) {
4417  width = l_map_umargin_width.value();
4418  }
4419  else { // otherwise it is a border
4420  width = g_map_le_borderwidth.value();
4421  }
4422 
4423  if(a_field->GetBorder() != NULL){
4424  border = a_field->GetBorder();
4425  }
4426  else {
4427  // Create border and add it to list of elements
4428  border = NewElement(a_type);
4430  m_elems.resize(m_elems.size() + 1);
4431  m_elems[m_elems.size() - 1] = border;
4432 
4433  // If it is an unsprayed field margin
4434  if (a_type == tole_UnsprayedFieldMargin) {
4436  TTypesOfLandscapeElement tole = a_field->GetElementType();
4437  border->SetOwner_tole(tole);
4438  }
4439  else { // otherwise it is a border
4440  a_field->SetBorder(border);
4441  }
4442 
4443  // Add more information about border
4445  border->SetPoly(hb_first_free_poly_num++);
4446  border->SetSlope(a_field->GetSlope());
4447  border->SetAspect(a_field->GetAspect());
4448  border->SetElevation(a_field->GetElevation());
4449  if (ClassificationFieldType(a_type) == true) {
4450  border->SetOwner(a_field->GetOwner(), a_field->GetOwner()->GetFarmNumber(), a_field->GetOwnerIndex());
4451  }
4452  //Set pollen and nectar curve
4454  }
4455  // Check that centroids are inside the polygon and valid.
4456  int fieldpoly = a_field->GetPoly(); // fieldpoly is the polygon number
4457  int borderpoly = border->GetPoly(); // borderpoly is the polygon number
4458  int borderindex = m_polymapping[borderpoly]; // borderindex is the elems index for the border
4459  int fieldindex = m_polymapping[fieldpoly]; // fieldindex is the elems index
4460 
4461  // Create coordinates for circle with radius equal to the width of the border to be used for creating the border
4462  std::vector<int> x_circle;
4463  std::vector<int> y_circle;
4464  int n_circle = 0;
4465  for (int dx = -width; dx <= width; dx++) {
4466  for (int dy = -width; dy <= width; dy++) {
4467  int dist = hypot(dx, dy);
4468  if (dist <= width) {
4469  x_circle.push_back(dx);
4470  y_circle.push_back(dy);
4471  n_circle++;
4472  }
4473  }
4474  }
4475 
4476  // Find the centre of the field
4477  int cx = a_field->GetCentroidX();
4478  int cy = a_field->GetCentroidY();
4479  FindFieldCenter(a_field, &cx, &cy);
4480  // Find the rectangle that describes the field the best
4481  // Returns the alignment of the longest axis in the rectangle
4482  // and sets width and starting point on short side of best rectangle
4483  int field_width = 0;
4484  int x_start_perp = 0;
4485  int y_start_perp = 0;
4486  int alignment = FindBestRectangle(a_field->GetPoly(), &cx, &cy, &field_width, &x_start_perp, &y_start_perp);
4487 
4488  // Check that field is not too narrow
4489  if (field_width <= g_map_le_minfieldwidth.value()) {
4490  if (a_type == tole_UnsprayedFieldMargin) a_field->SetUnsprayedMarginPolyRef(-1);
4491  return -1;
4492  }
4493 
4494  int x1 = cx;
4495  int y1 = cy;
4496  int x2 = cx;
4497  int y2 = cy;
4498  if (a_allAround == 0) { // Only calculate points if they are going to be used;
4499  AxisLoop(a_field->GetPoly(), &x1, &y1, alignment + 1);
4500  AxisLoop(a_field->GetPoly(), &x2, &y2, alignment + 7);
4501  }
4502 
4503  // Loop through all pixels in rectangle surrounding the field
4504  int min_x = a_field->GetMinX();
4505  int max_x = a_field->GetMaxX();
4506  int min_y = a_field->GetMinY();
4507  int max_y = a_field->GetMaxY();
4508  //if (max(x1, x2) < max_x - width) max_x = max(x1, x2);
4509  //if (max(y1, y2) < max_y - width) max_y = max(y1, y2);
4510  //if (min(x1, x2) > min_x + width) min_x = min(x1, x2);
4511  //if (min(y1, y2) < min_y + width) min_y = min(y1, y2);
4512  int area = 0;
4513  for (int x = min_x; x <= max_x; x++) { // Loop through x
4514  for (int y = min_y; y <= max_y; y++) { // Loop through y
4515  // Make sure we are inside map
4516  if ((x >= 0) && (y >= 0) && (x < m_width) && (y < m_height)) {
4517  int positionGood = 1;
4518  if (a_allAround == 0) {
4519  // Only add on one side of line between P1(x1,y1) and P2(x2,y2)
4520  positionGood = std::copysign(1, (x2 - x1) * (y - y1) - (y2 - y1) * (x - x1));
4521  }
4522  if (positionGood >= 0) {
4523  int index = m_land->Get(x, y);
4524  if (index == fieldindex) { // Check that the current pixel is in the field
4525  for (int i = 0; i < n_circle; i++) { // Look in a circle around the pixel with a radius of the border width
4526  if (BorderTest(fieldindex, borderindex, x + x_circle[i], y + y_circle[i])) { // Test if pixel should be border
4527  m_land->Put(x, y, borderindex); // Add this pixel to the border element in the map
4528  area += 1;
4529  a_field->AddArea(-1.0); // Subtract area from field
4530  break; // Added border so stop testing
4531  }
4532  }
4533  }
4534  }
4535  }
4536  }
4537  }
4538 
4539  // If nothing was added to the border remove it again
4540  if (area == 0) {
4541  border->SetMapValid(false);
4542  // If it is an unsprayed field margin also remove border from field
4543  if (a_type == tole_UnsprayedFieldMargin) {
4544  a_field->SetUnsprayedMarginPolyRef(-1);
4545  }
4546  }
4547  else{
4548  border->AddArea(area);
4549  }
4550 
4551  return area;
4552 }

References LE::AddArea(), cfg_FlowerStripPollenNectarCurveNum, g_map_le_borderwidth, g_map_le_minfieldwidth, LE::GetAspect(), LE::GetBorder(), LE::GetCentroidX(), LE::GetCentroidY(), LE::GetElevation(), Farm::GetFarmNumber(), LE::GetMaxX(), LE::GetMaxY(), LE::GetMinX(), LE::GetMinY(), LE::GetOwner(), LE::GetOwnerIndex(), LE::GetPoly(), LE::GetSlope(), l_map_umargin_width, m_polymapping, LE::SetAspect(), LE::SetBorder(), LE::SetElevation(), LE::SetMapIndex(), LE::SetMapValid(), LE::SetOwner(), LE::SetPollenNectarCurveRef(), LE::SetPoly(), LE::SetSlope(), LE::SetUnsprayedMarginPolyRef(), tole_UnsprayedFieldMargin, and CfgInt::value().

◆ BorderNeed()

bool Landscape::BorderNeed ( TTypesOfLandscapeElement  a_letype)
protected

Currently unused test for adding borders.

7657  {
7658  static char error_num[20];
7659  bool AddBorder = false;
7660  switch (a_letype) {
7661  // No border is needed toward these neighbouring element types.
7662  case tole_BeetleBank:
7664  case tole_OrchardBand:
7665  case tole_FieldBoundary:
7666  case tole_FlowerStrip:
7668  case tole_MownGrassStrip:
7669  break;
7670 
7671  case tole_Marsh:
7672  case tole_IndividualTree:
7673  case tole_PlantNursery:
7674  case tole_Vildtager:
7675  case tole_WindTurbine:
7676  case tole_WoodyEnergyCrop:
7677  case tole_WoodlandMargin:
7678  case tole_Pylon:
7679  case tole_NaturalGrassDry:
7680  case tole_Railway:
7681  case tole_Scrub:
7682  case tole_Field:
7684  case tole_PermPasture:
7687  case tole_PitDisused:
7688  case tole_RiversideTrees:
7689  case tole_DeciduousForest:
7690  case tole_MixedForest:
7691  case tole_YoungForest:
7692  case tole_ConiferousForest:
7693  case tole_StoneWall:
7694  case tole_Fence:
7695  case tole_Garden:
7696  case tole_Track:
7697  case tole_SmallRoad:
7698  case tole_LargeRoad:
7699  case tole_Building:
7700  case tole_ActivePit:
7701  case tole_Pond:
7702  case tole_FishFarm:
7703  case tole_Freshwater:
7704  case tole_River:
7705  case tole_Saltwater:
7706  case tole_Coast:
7707  case tole_BareRock:
7708  case tole_Heath:
7709  case tole_Orchard:
7710  case tole_AmenityGrass:
7711  case tole_Parkland:
7712  case tole_UrbanNoVeg:
7713  case tole_UrbanVeg:
7714  case tole_UrbanPark:
7716  case tole_SandDune:
7717  case tole_Copse:
7718  case tole_NaturalGrassWet:
7719  case tole_RoadsideSlope:
7720  case tole_MetalledPath:
7721  case tole_Carpark:
7722  case tole_Churchyard:
7723  case tole_Saltmarsh:
7724  case tole_Stream:
7725  case tole_HeritageSite:
7726  AddBorder = true;
7727  break;
7728 
7729  default:
7730  g_msg->Warn(WARN_BUG, "Landscape::BorderNeed(): Unknown element type: ", int(a_letype));
7731  exit(1);
7732  }
7733  return AddBorder;
7734 }

References g_msg, tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_BeetleBank, tole_Building, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_Fence, tole_Field, tole_FieldBoundary, tole_FishFarm, tole_FlowerStrip, tole_FlowerStripWithRotation, tole_Freshwater, tole_Garden, tole_Heath, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_MixedForest, tole_MownGrassStrip, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_Orchard, tole_OrchardBand, tole_Parkland, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversideTrees, tole_RoadsideSlope, tole_Saltmarsh, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UnsprayedFieldMargin, tole_UrbanNoVeg, tole_UrbanPark, tole_UrbanVeg, tole_Vildtager, tole_WindTurbine, tole_WoodlandMargin, tole_WoodyEnergyCrop, tole_YoungForest, MapErrorMsg::Warn(), and WARN_BUG.

◆ BorderRemoval()

void Landscape::BorderRemoval ( void  )
protected

Removes field boundaries, hedgebanks and hedges if they are adjacent to a field.

Removes field boundaries, hedgebanks and hedges if they are adjacent to a field . This can be used for example if we want to be sure of the amount of added elements or their width.

4331  {
4336  // This does not need to be efficient, just do the job
4337  for (int x=1; x<(m_width-1); x++)
4338  for (int y=1; y<(m_height-1); y++)
4339  {
4341  if ((tole==tole_FieldBoundary) || (tole==tole_HedgeBank) || (tole==tole_Hedges) || (tole == tole_FlowerStrip))
4342  {
4343  if ( SupplyElementType(x-1,y-1) == tole_Field)
4344  {
4345  // Set the x,y location to be this field
4346  int fieldindex = SupplyPolyRefIndex(x-1,y-1);
4347  m_land->Put( x, y, fieldindex );
4348 
4349  }
4350  else
4351  if ( SupplyElementType(x-1,y) == tole_Field)
4352  {
4353  // Set the x,y location to be this field
4354  int fieldindex = SupplyPolyRefIndex(x-1,y);
4355  m_land->Put( x, y, fieldindex );
4356 
4357  }
4358  else
4359  if ( SupplyElementType(x-1,y+1) == tole_Field)
4360  {
4361  // Set the x,y location to be this field
4362  int fieldindex = SupplyPolyRefIndex(x-1,y+1);
4363  m_land->Put( x, y, fieldindex );
4364 
4365  }
4366  else
4367  if ( SupplyElementType(x,y-1) == tole_Field)
4368  {
4369  // Set the x,y location to be this field
4370  int fieldindex = SupplyPolyRefIndex(x,y-1);
4371  m_land->Put( x, y, fieldindex );
4372 
4373  }
4374  else
4375  if ( SupplyElementType(x,y+1) == tole_Field)
4376  {
4377  // Set the x,y location to be this field
4378  int fieldindex = SupplyPolyRefIndex(x,y+1);
4379  m_land->Put( x, y, fieldindex );
4380 
4381  }
4382  else
4383  if ( SupplyElementType(x+1,y-1) == tole_Field)
4384  {
4385  // Set the x,y location to be this field
4386  int fieldindex = SupplyPolyRefIndex(x+1,y-1);
4387  m_land->Put( x, y, fieldindex );
4388 
4389  }
4390  else
4391  if ( SupplyElementType(x+1,y) == tole_Field)
4392  {
4393  // Set the x,y location to be this field
4394  int fieldindex = SupplyPolyRefIndex(x+1,y);
4395  m_land->Put( x, y, fieldindex );
4396 
4397  }
4398  else
4399  if ( SupplyElementType(x+1,y+1) == tole_Field)
4400  {
4401  // Set the x,y location to be this field
4402  int fieldindex = SupplyPolyRefIndex(x+1,y+1);
4403  m_land->Put( x, y, fieldindex );
4404 
4405  }
4406  }
4407  }
4408 }

References tole_Field, tole_FieldBoundary, tole_FlowerStrip, tole_HedgeBank, and tole_Hedges.

◆ BorderTest()

bool Landscape::BorderTest ( int  a_fieldindex,
int  a_borderindex,
int  a_x,
int  a_y 
)
protected

Used to decide if a coordinate location should become a border/unsprayed margin.

4555  {
4556  // If the neighbouring cell is outside the landscape
4557  if ((a_x_neighbour >= m_width) || (a_x_neighbour < 0) || (a_y_neighbour >= m_height) || (a_y_neighbour < 0)) {
4558  return true;
4559  }
4560  // If the neighbouring cell is not the field itself, a border, an individual tree, pylon or wind turbine
4561  int index = m_land->Get(a_x_neighbour, a_y_neighbour);
4564  if ((index != a_fieldindex) && (index != a_borderindex) && (tole != tole_IndividualTree) && (tole != tole_Pylon) && (tole != tole_WindTurbine) && (tole != tole_FieldBoundary || cfg_BordersNextToFieldBoundary.value()) && (tole != border_tole) && (tole!= tole_Field || cfg_BordersBetweenFields.value())) {
4565  return true;
4566  }
4567  return false;
4568 }

References cfg_BordersBetweenFields, cfg_BordersNextToFieldBoundary, g_landscape_ptr, SupplyElementTypeFromVector(), tole_Field, tole_FieldBoundary, tole_IndividualTree, tole_Pylon, tole_WindTurbine, and CfgBool::value().

◆ BuildingDesignationCalc()

void Landscape::BuildingDesignationCalc ( )

used to calculate whether a building as rural or town - for rodenticide use

Runs through all elements and identifies the ones where rodenticide bait may be placed. If it is a building then we count the number of buildings near to it and designate it town if there are more than cfg_mintownbuildingnumber.

5357 {
5362  cout << "In BuildingDesignationCalc" << endl;
5363  for (int p = 0; p< (int)m_elems.size(); p++)
5364  {
5365  TTypesOfLandscapeElement tole = m_elems[p]->GetElementType();
5366  if ( tole == tole_Building)
5367  {
5368  int cx = m_elems[p]->GetCentroidX();
5369  int cy = m_elems[p]->GetCentroidY();
5370  int near = 0;
5371  for (int j = 0; j< (int)m_elems.size(); j++)
5372  {
5373  if (m_elems[j]->GetElementType() == tole_Building)
5374  {
5375  int nx = m_elems[j]->GetCentroidX();
5376  int ny = m_elems[j]->GetCentroidY();
5377  int dx =abs(cx-nx);
5378  int dy =abs(cy-ny);
5379  if ((dx < cfg_mintownbuildingdistance.value()) && (dy < cfg_mintownbuildingdistance.value())) near++;
5380  if (near > cfg_mintownbuildingdistance.value()) break;
5381  }
5382  }
5383  if (near <= cfg_mintownbuildingnumber.value()) m_elems[p]->SetCountryDesignation(1); // Not enough buildings close by, so it is a country building
5384  else m_elems[p]->SetCountryDesignation(0);
5385  }
5386  else if (tole == tole_YoungForest)
5387  {
5388  m_elems[p]->SetCountryDesignation(2);
5389  }
5390  else if ((tole == tole_DeciduousForest) || ( tole == tole_MixedForest) || ( tole == tole_ConiferousForest ) ) m_elems[p]->SetCountryDesignation(3);
5391 
5392  }
5393 }

References cfg_mintownbuildingdistance, cfg_mintownbuildingnumber, tole_Building, tole_ConiferousForest, tole_DeciduousForest, tole_MixedForest, tole_YoungForest, and CfgInt::value().

◆ CalculateCentroids()

void Landscape::CalculateCentroids ( void  )

Calculate centroid for each polygon found.

Finds a location inside each polygon as a roughly calculated centre point. The point will be within the polygon. This also uses the stored Max/Min coordinates for each polygon that form a rectangle around it.

5111 {
5117  cout << "In Centroid Calculations" << endl;
5118  // For each polygon
5119  for (int p = 0; p< (int)m_elems.size(); p++)
5120  {
5121  // Calcuate the actual centre
5122  int x1 = m_elems[p]->GetMinX();
5123  int y1 = m_elems[p]->GetMinY();
5124  int x2 = m_elems[p]->GetMaxX();
5125  int y2 = m_elems[p]->GetMaxY();
5126 
5127  int midx = (x1 + x2) / 2;
5128  int midy = (y1 + y2) / 2;
5129  // Now from midx & midy we move outwards in concentric circles until we find a location that matches our polyref.
5130  int polyindex = p; // Change mapmapping has been called by now, so the map contains m_elems indices.
5131  CentroidSpiralOut(polyindex, midx, midy);
5132  // Now we want to be sure that we are in the middle of the polygon not on the edge. This is tricky for complex shaped polygons,
5133  // but we have a stab at it by using the FindLongestAxis method. This puts us in the centre of the longest axis in 8 directions
5134  // from this point
5135  FindLongestAxis(&midx, &midy);
5136  m_elems[p]->SetCentroid(midx, midy);
5137  }
5139 }

◆ CalculateFieldOpennessAllCells()

int Landscape::CalculateFieldOpennessAllCells ( int  a_pref)

Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Checks all field 1m2.

Starts with North West and moves round the points of the compass 180 degrees. For each point tested we want the minimum length found, but between points we are interested in the max

runs a line out and also in 180 degrees, two lines.

runs a line out and also in 180 degrees, two lines.

496 {
497  int dline;
498  int d0 = 0;
499  int minX = m_elems[a_pref]->GetMinX();
500  int minY = m_elems[a_pref]->GetMinY();
501  int maxX = m_elems[a_pref]->GetMaxX();
502  int maxY = m_elems[a_pref]->GetMaxY();
503  for (int ax = minX; ax <= maxX; ax+=10)
504  {
505  for (int ay = minY; ay <= maxY; ay+=10)
506  {
507  dline = m_maxextent; // this is the width of the landscape and will always be at least as big as the biggest return value possible
508  // Get a possible point for this field
509  int cx = ax;
510  int cy = ay;
511  if (m_land->Get(ax, ay) == a_pref)
512  {
517  double offsetx = -1;
518  double offsety = -1;
519  double dx = 1.0 / 45.0;
520  double dy = 0.0;
521  for (int deg = 0; deg<90; deg++)
522  {
524  int d1 = LineHighTest(cx, cy, offsetx, offsety);
525  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
526  int d = d1;
527  if (d1 > d2) d = d2;
528  if (dline > d) dline = d; // get the minimum
529  offsetx = offsetx + dx;
530  offsety = offsety + dy;
531  }
532  offsetx = 1;
533  offsety = 1;
534  dy = 0 - dx;
535  dx = 0;
536  for (int deg = 0; deg<90; deg++)
537  {
539  int d1 = LineHighTest(cx, cy, offsetx, offsety);
540  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
541  int d = d1;
542  if (d1 > d2) d = d2;
543  if (dline > d) dline = d;
544  offsetx = offsetx + dx;
545  offsety = offsety + dy;
546  }
547  if (dline > d0) d0 = dline; // Get the maximum. Here we might also want to do something like create statistics from the range of dline
548  }
549  }
550  }
551  return d0;
552 }

◆ CalculateFieldOpennessCentroid()

int Landscape::CalculateFieldOpennessCentroid ( int  a_pref)

Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Searches from centroid.

Starts with North West and moves round the points of the compass 180 degrees.

runs a line out and also in 180 degrees, two lines.

runs a line out and also in 180 degrees, two lines.

454 {
455  // Get the centre point for this field
456  int d0 = m_maxextent; // this is the width of the landscape and will always be at least as big as the biggest return value possible
457  int cx = m_elems[a_pref]->GetCentroidX();
458  int cy = m_elems[a_pref]->GetCentroidY();
459 
461  double offsetx = -1;
462  double offsety = -1;
463  double dx = 1.0 / 45.0;
464  double dy = 0.0;
465  for (int deg = 0; deg<90; deg++)
466  {
468  int d1 = LineHighTest(cx, cy, offsetx, offsety);
469  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
470  int d = d1;
471  if (d1 > d2) d = d2;
472  if (d0 > d) d0 = d;
473  offsetx = offsetx + dx;
474  offsety = offsety + dy;
475  }
476  offsetx = 1;
477  offsety = 1;
478  dy = 0 - dx;
479  dx = 0;
480  for (int deg = 0; deg<90; deg++)
481  {
483  int d1 = LineHighTest(cx, cy, offsetx, offsety);
484  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
485  int d = d1;
486  if (d1 > d2) d = d2;
487  if (d0 > d) d0 = d;
488  offsetx = offsetx + dx;
489  offsety = offsety + dy;
490  }
491  return d0;
492 }

◆ CalculateMaskCorners()

vector< vector< int > > Landscape::CalculateMaskCorners ( int  a_centroid_x,
int  a_centroid_y,
int  a_half_width 
)

The function to calculate the corners of mask(s) for the given centroid and half-width with wrapping around.

2540  {
2541  vector<vector<int>> return_corners;
2542  //get the corners of the mask
2543  int temp_min_x = a_centroid_x - a_half_width;
2544  int temp_max_x = a_centroid_x + a_half_width;
2545  int temp_min_y = a_centroid_y - a_half_width;
2546  int temp_max_y = a_centroid_y + a_half_width;
2547 
2548  //check if the corners are within the landscape, if yes, only one mask
2549  if(temp_min_x>=0 && temp_max_x<m_width && temp_min_y>=0 && temp_max_y<m_height){
2550  //if the corners are within the landscape, return the corners -- only one mask
2551  return_corners.push_back({temp_min_x, temp_min_y, temp_max_x, temp_max_y});
2552  return return_corners;
2553  }
2554  //if only axis is out of the landscape, two masks
2555  else if(temp_min_x<0 && temp_max_x<m_width && temp_min_y>=0 && temp_max_y<m_height){
2556  //if only the min_x is out of the landscape, return two masks
2557  return_corners.push_back({0, temp_min_y, temp_max_x, temp_max_y});
2558  return_corners.push_back({m_width+temp_min_x, temp_min_y, m_width-1, temp_max_y});
2559  return return_corners;
2560  }
2561  else if(temp_min_x>=0 && temp_max_x>=m_width && temp_min_y>=0 && temp_max_y<m_height){
2562  //if only the max_x is out of the landscape, return two masks
2563  return_corners.push_back({temp_min_x, temp_min_y, m_width-1, temp_max_y});
2564  return_corners.push_back({0, temp_min_y, temp_max_x-m_width, temp_max_y});
2565  return return_corners;
2566  }
2567  else if(temp_min_x>=0 && temp_max_x<m_width && temp_min_y<0 && temp_max_y<m_height){
2568  //if only the min_y is out of the landscape, return two masks
2569  return_corners.push_back({temp_min_x, 0, temp_max_x, temp_max_y});
2570  return_corners.push_back({temp_min_x, m_height+temp_min_y, temp_max_x, m_height-1});
2571  return return_corners;
2572  }
2573  else if(temp_min_x>=0 && temp_max_x<m_width && temp_min_y>=0 && temp_max_y>=m_height){
2574  //if only the max_y is out of the landscape, return two masks
2575  return_corners.push_back({temp_min_x, temp_min_y, temp_max_x, m_height-1});
2576  return_corners.push_back({temp_min_x, 0, temp_max_x, temp_max_y-m_height});
2577  return return_corners;
2578  }
2579 
2580  //if both axis are out of the landscape, four masks
2581  else if(temp_min_x<0 && temp_max_x<m_width && temp_min_y<0 && temp_max_y<m_height){
2582  //if the min_x and min_y are out of the landscape, return four masks
2583  return_corners.push_back({0, 0, temp_max_x, temp_max_y});
2584  return_corners.push_back({m_width+temp_min_x, 0, m_width-1, temp_max_y});
2585  return_corners.push_back({0, m_height+temp_min_y, temp_max_x, m_height-1});
2586  return_corners.push_back({m_width+temp_min_x, m_height+temp_min_y, m_width-1, m_height-1});
2587  return return_corners;
2588  }
2589  else if(temp_min_x>=0 && temp_max_x>=m_width && temp_min_y<0 && temp_max_y<m_height){
2590  //if the max_x and min_y are out of the landscape, return four masks
2591  return_corners.push_back({temp_min_x, 0, m_width-1, temp_max_y});
2592  return_corners.push_back({0, 0, temp_max_x-m_width, temp_max_y});
2593  return_corners.push_back({temp_min_x, m_height+temp_min_y, m_width-1, m_height-1});
2594  return_corners.push_back({0, m_height+temp_min_y, temp_max_x-m_width, m_height-1});
2595  return return_corners;
2596  }
2597  else if(temp_min_x>=0 && temp_max_x>=m_width && temp_min_y>=0 && temp_max_y>=m_height){
2598  //if the min_x and max_y are out of the landscape, return four masks
2599  return_corners.push_back({temp_min_x, temp_min_y, m_width-1, m_height-1});
2600  return_corners.push_back({temp_min_x, 0, m_width-1, temp_max_y-m_height});
2601  return_corners.push_back({0, temp_min_y, temp_max_x-m_width, m_height-1});
2602  return_corners.push_back({0, 0, temp_max_x-m_width, temp_max_y-m_height});
2603  return return_corners;
2604  }
2605  else if(temp_min_x<0 && temp_max_x<m_width && temp_min_y>=0 && temp_max_y>=m_height){
2606  //if the max_x and max_y are out of the landscape, return four masks
2607  return_corners.push_back({0, temp_min_y, temp_max_x, m_height-1});
2608  return_corners.push_back({m_width+temp_min_x, temp_min_y, m_width-1, m_height-1});
2609  return_corners.push_back({0, 0, temp_max_x, temp_max_y-m_height});
2610  return_corners.push_back({m_width+temp_min_x, 0, m_width-1, temp_max_y-m_height});
2611  return return_corners;
2612  }
2613 }

Referenced by Osmia_Female::Forage().

◆ CalculateOpenness()

void Landscape::CalculateOpenness ( bool  a_realcalc)

Causes openness to be calulated and stored for all polygons.

First must calculate centroid. Runs through the list of elements and any that are marsh, field, or pasture will have an openness score calculated

417 {
421  cout << "In CalculateOpenness" << endl;
422 
423  for (unsigned int i = 0; i < m_elems.size(); i++)
424  {
425  TTypesOfLandscapeElement tole = m_elems[i]->GetElementType();
426  switch (tole)
427  {
428  case tole_Field:
429  case tole_Marsh:
430  case tole_Scrub:
434  case tole_PermPasture:
437  if (a_realcalc)
438  {
439  cout << i << " ";
440  m_elems[i]->SetOpenness(CalculateFieldOpennessAllCells(i));
441  }
442  else m_elems[i]->SetOpenness(0);
443  break;
444  default:
445  m_elems[i]->SetOpenness(0);
446  break;
447  }
448  }
449  if (a_realcalc) cout << endl;
450 }

References tole_Field, tole_Marsh, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, and tole_Scrub.

◆ CalHaibitatFlowerResource()

void Landscape::CalHaibitatFlowerResource ( )

Calculate the flower resouce for all the habitat types with flower resource.

Note
This is a temporary solution to make flower strips flowring earlier by 50 days to make them ready for Osmia.
3492  {
3493  for (auto [key, value] : m_habitat_species){
3494  m_habitat_pollen[key].m_quantity = 0;
3495  m_habitat_pollen[key].m_quality = 0;
3496  m_habitat_nectar[key].m_quantity = 0;
3497  m_habitat_nectar[key].m_quality = 0;
3498  for (int i = 0; i<value.size(); i++){
3499  if(m_habitat_flower_num[key][i]>0){
3501  if(key == 59){
3505  }
3506  else if(key == 27){
3510  }
3511  else if(key == 24){
3515  }
3516  else if(key == 29){
3520  }
3521  else if(key == 23){
3525  }
3526  else if(key == 17){
3530  }
3531  else if(key == 4){
3535  }
3536  else{
3540  }
3541  //if(m_habitat_nectar[key].m_quality > m_habitat_nectar[key].m_quantity)
3542  // cout<<"Error: Habitat "<<key<<" has more nectar quality than quantity"<<endl;
3543  }
3544  }
3545  for (int i = 0; i<value.size(); i++){
3547 
3548  m_habitat_pollen[key].m_quality = 1;
3549  }
3550  }
3551  }
3552 }

References cfg_FlowerStripStartFloweringTimePush, g_nectarpollen, PollenNectarData::m_quality, PollenNectarData::m_quantity, PollenNectarDevelopmentData::supplyNectarHabitatSpeciesCurrentDay(), PollenNectarDevelopmentData::supplyNectarHabitatSpeciesGivenDay(), PollenNectarDevelopmentData::supplyPollenHabitatSpeciesCurrentDay(), PollenNectarDevelopmentData::supplyPollenHabitatSpeciesGivenDay(), and CfgInt::value().

◆ CentroidSpiralOut()

void Landscape::CentroidSpiralOut ( int  a_polyref,
int &  a_x,
int &  a_y 
)

Function to move from midx & midy and outwards in concentric circles until a location that matches the polyref is found LKM.

5143 {
5144  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref) return; // Found it so return
5145  // Otherwise its not found so we need to start to spiral out
5146  int loop = 1;
5147  int sx = a_x;
5148  int sy = a_y;
5149  do {
5150  a_y = sy - loop;
5151  for (int i = 0 - loop; i <= loop; i++)
5152  {
5153  a_x = sx + i;
5154  CorrectCoords(a_x, a_y);
5155  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
5156  return; // Found it so return
5157  }
5158  a_y = sy + loop;
5159  for (int i = 0 - loop; i <= loop; i++)
5160  {
5161  a_x = sx + i;
5162  CorrectCoords(a_x, a_y);
5163  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
5164  return; // Found it so return
5165  }
5166  a_x = sx + loop;
5167  for (int j = 0 - (loop - 1); j< loop; j++)
5168  {
5169  a_y = sy + j;
5170  CorrectCoords(a_x, a_y);
5171  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
5172  return; // Found it so return
5173  }
5174  a_x = sx - loop;
5175  for (int j = 0 - (loop - 1); j< loop; j++)
5176  {
5177  a_y = sy + j;
5178  CorrectCoords(a_x, a_y);
5179  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
5180  return; // Found it so return
5181  }
5182  loop++;
5183  } while (loop<m_minmaxextent); // This stopping rule should hopefully not be needed, it is set very high.
5184  g_msg->Warn("Landscape::CentroidSpiralOut: Failure of centroid main loop. Looking for polygon index ",a_polyref);
5185  a_x = m_elems[a_polyref]->GetMinX();
5186  a_y = m_elems[a_polyref]->GetMinY();
5187 }

References g_msg, and MapErrorMsg::Warn().

◆ ChangeMapMapping()

void Landscape::ChangeMapMapping ( void  )
protected

Maps the polygon numbers directly to the indices in m_elems.

Our map is an array of polygon indentifiers, where we really want to know the associated landscape element of a X-Y coordinate pair.
Changing this to m_elems[] indices will save us one redirection when inquiring information from the landscape, and only costs us the fixed translation step performed here at startup.

4188  {
4194  cout << "In Change Map Mapping" << endl;
4195  int mapwidth = m_land->MapWidth();
4196  int mapheight = m_land->MapHeight();
4197  int pest_map_width = mapwidth >> PEST_GRIDSIZE_POW2;
4198  if ( mapwidth & ( PEST_GRIDSIZE - 1 ) ) pest_map_width++;
4199  int oldindex = -1;
4200  for ( int x = 0; x < mapwidth; x++ )
4201  {
4202  for ( int y = 0; y < mapheight; y++ )
4203  {
4204  int polynum = m_land->Get( x, y ); // the polyref e.g. = 1, m_polymapping[ polynum ] = 0
4205  m_elems[ m_polymapping[ polynum ]]->SetMapIndex( m_polymapping[ polynum ] ); // Here we set index in the map to the index in elements, i.e. 0
4206  m_elems[ m_polymapping[ polynum ]]->SetMapValid( true );
4207  // Do the translation.
4208  m_land->Put( x, y, m_polymapping[ polynum ] ); // and now we write this to the map, i.e. 0
4209  // This coordinate is now valid. Throw these coordinates into
4210  // the associated landscape element.
4211  int index = m_polymapping[ SupplyPolyRef( x, y ) ];
4212  if ( index != oldindex )
4213  {
4214  m_elems[ index ]->SetValidXY( x, y );
4215  int l_x = x >> PEST_GRIDSIZE_POW2;
4216  int l_y = y >> PEST_GRIDSIZE_POW2;
4217  int pref = l_y * pest_map_width + l_x;
4218  m_elems[ index ]->SetPesticideCell( pref );
4219  oldindex = index;
4220  }
4221  }
4222  }
4223  RebuildPolyMapping();
4224 /*
4225 // Check that all of the polygons are mentioned in the map.
4226  if ( l_map_check_polygon_xref.value() )
4227  {
4228  for ( unsigned int i = 0; i < m_elems.size(); i++ )
4229  {
4230  if ( !m_elems[ i ]->GetMapValid() ) {
4231  char poly[ 20 ];
4232  sprintf( poly, "%d", m_elems[ i ]->GetPoly() );
4233  g_msg->Warn( WARN_FILE, "Landscape::ChangeMapMapping(): ""Polygon number referenced but not in map file: ", poly );
4234  exit( 1 );
4235  }
4236  }
4237  }
4238 */
4239 }

References m_polymapping, PEST_GRIDSIZE, and PEST_GRIDSIZE_POW2.

◆ CheckForPesticideRecord()

void Landscape::CheckForPesticideRecord ( LE a_field,
TTypesOfPesticideCategory  a_pcide 
)

Check if needed and record pesticide application.

a_pcide can be insecticides, herbicides or fungicides, or it can be a 'test' pesticide

1624 {
1628  if (cfg_pesticidemapon.value())
1629  {
1630  if (cfg_pesticidemaptype.value() == false)
1631  {
1632  m_PesticideMap->Spray(a_field, a_pcide);
1633  }
1634  else
1635  {
1636  if (a_pcide == testpesticide) m_PesticideMap->Spray(a_field, insecticide);
1637  }
1638  }
1640  {
1641  m_PesticideTable->Spray(a_field, a_pcide);
1642  }
1643 }

References cfg_pesticidemapon, cfg_pesticidemaptype, cfg_pesticidetableon, insecticide, testpesticide, and CfgBool::value().

Referenced by Farm::FungicideTreat(), Farm::HerbicideTreat(), Farm::InsecticideTreat(), Farm::Molluscicide(), and Farm::ProductApplication().

◆ ClassificationFieldType()

bool Landscape::ClassificationFieldType ( TTypesOfLandscapeElement  a_tole)

Returns whether the polygon is classfied as a field.

1182  {
1183  switch (a_tole)
1184  {
1185  // Annual rotational field, with varying crops on it
1186  case tole_Field:
1187  // (semi-)permanent managed crops:
1188  case tole_Orchard:
1190  case tole_PermPasture:
1193  case tole_PermPastureTussockyWet: // tole NOT implemented yet
1194  // case tole_Vildtager:
1195  case tole_YoungForest:
1196  case tole_WoodyEnergyCrop:
1197  // new (2021):
1198  case tole_PlantNursery:
1199  case tole_MontadoCorkOak:
1200  case tole_MontadoHolmOak:
1201  case tole_MontadoMixed:
1203  case tole_CorkOakForest:
1204  case tole_HolmOakForest:
1205  case tole_OtherOakForest:
1206  case tole_ChestnutForest:
1207  case tole_EucalyptusForest:
1209  case tole_StonePineForest:
1210  case tole_Vineyard:
1211  case tole_OliveGrove:
1212  case tole_RiceField:
1213  // new (2021 DK Perm Crops):
1214  case tole_OOrchard:
1215  case tole_BushFruit:
1216  case tole_OBushFruit:
1217  case tole_ChristmasTrees:
1218  case tole_OChristmasTrees:
1219  case tole_EnergyCrop:
1220  case tole_OEnergyCrop:
1221  case tole_FarmForest:
1222  case tole_OFarmForest:
1223  case tole_PermPasturePigs:
1224  case tole_OPermPasturePigs:
1225  case tole_OPermPasture:
1227  case tole_FarmYoungForest:
1228  case tole_OFarmYoungForest:
1229  // new (2021 PT Perm Crops):
1230  case tole_AlmondPlantation:
1231  case tole_WalnutPlantation:
1232  // new (2021 FI Perm crops):
1233  case tole_FarmBufferZone:
1234  case tole_NaturalFarmGrass:
1235  case tole_GreenFallow:
1237  // new (2021 DE Perm Crops):
1238  case tole_FlowersPerm:
1239  case tole_AsparagusPerm:
1240  case tole_OAsparagusPerm:
1241  case tole_MushroomPerm:
1242  case tole_OtherPermCrop:
1243  return true;
1244  default:
1245  return false;
1246  }
1247 }

References tole_AgroForestrySystem, tole_AlmondPlantation, tole_AsparagusPerm, tole_BushFruit, tole_ChestnutForest, tole_ChristmasTrees, tole_CorkOakForest, tole_EnergyCrop, tole_EucalyptusForest, tole_FarmBufferZone, tole_FarmFeedingGround, tole_FarmForest, tole_FarmYoungForest, tole_Field, tole_FlowersPerm, tole_GreenFallow, tole_HolmOakForest, tole_MaritimePineForest, tole_MontadoCorkOak, tole_MontadoHolmOak, tole_MontadoMixed, tole_MushroomPerm, tole_NaturalFarmGrass, tole_OAsparagusPerm, tole_OBushFruit, tole_OChristmasTrees, tole_OEnergyCrop, tole_OFarmForest, tole_OFarmYoungForest, tole_OliveGrove, tole_OOrchard, tole_OPermPasture, tole_OPermPastureLowYield, tole_OPermPasturePigs, tole_Orchard, tole_OtherOakForest, tole_OtherPermCrop, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPasturePigs, tole_PermPastureTussocky, tole_PermPastureTussockyWet, tole_PlantNursery, tole_RiceField, tole_StonePineForest, tole_Vineyard, tole_WalnutPlantation, tole_WoodyEnergyCrop, and tole_YoungForest.

Referenced by IsFieldType().

◆ ClassificationForest()

bool Landscape::ClassificationForest ( TTypesOfLandscapeElement  a_tole)

Returns whether the polygon is classfied as woodland.

1323  {
1324 
1325  switch (tole) {
1326  case tole_WoodyEnergyCrop:
1327  case tole_DeciduousForest:
1328  case tole_MixedForest:
1329  case tole_ConiferousForest:
1330  case tole_Copse:
1331  case tole_IndividualTree:
1332  case tole_WoodlandMargin:
1333  case tole_Scrub:
1334  case tole_SwampForest:
1335  case tole_MontadoCorkOak:
1336  case tole_MontadoHolmOak:
1337  case tole_MontadoMixed:
1339  case tole_CorkOakForest:
1340  case tole_HolmOakForest:
1341  case tole_OtherOakForest:
1342  case tole_ChestnutForest:
1343  case tole_EucalyptusForest:
1344  case tole_InvasiveForest:
1346  case tole_StonePineForest:
1347  case tole_YoungForest:
1348  case tole_RiversideTrees:
1349  case tole_FarmForest:
1350  case tole_OFarmForest:
1351  return true;
1352  }
1353  return false;
1354 }

References tole_AgroForestrySystem, tole_ChestnutForest, tole_ConiferousForest, tole_Copse, tole_CorkOakForest, tole_DeciduousForest, tole_EucalyptusForest, tole_FarmForest, tole_HolmOakForest, tole_IndividualTree, tole_InvasiveForest, tole_MaritimePineForest, tole_MixedForest, tole_MontadoCorkOak, tole_MontadoHolmOak, tole_MontadoMixed, tole_OFarmForest, tole_OtherOakForest, tole_RiversideTrees, tole_Scrub, tole_StonePineForest, tole_SwampForest, tole_WoodlandMargin, tole_WoodyEnergyCrop, and tole_YoungForest.

Referenced by Set_TOLE_Att().

◆ ClassificationHigh()

bool Landscape::ClassificationHigh ( TTypesOfLandscapeElement  tole)

Returns whether the polygon is classfied as high.

1251  {
1252 
1253  if (ClassificationForest(tole))
1254  return true;
1255 
1256  switch (tole) {
1257  // NonVegetated
1259  case tole_PitDisused:
1260  case tole_UrbanNoVeg:
1261  case tole_UrbanVeg:
1262  case tole_Garden:
1263  case tole_StoneWall:
1264  case tole_WindTurbine:
1265  case tole_Pylon:
1266  case tole_ActivePit:
1267  case tole_Building:
1268  // Vegetated
1269  case tole_RiversideTrees:
1270  case tole_PlantNursery:
1271  case tole_Hedges:
1272  // orchards and orchard bands
1273  case tole_WoodyEnergyCrop:
1274  case tole_Orchard:
1275  case tole_OrchardBand:
1276  return true;
1277  }
1278 
1279  return false;
1280 }

References tole_ActivePit, tole_Building, tole_BuiltUpWithParkland, tole_Garden, tole_Hedges, tole_Orchard, tole_OrchardBand, tole_PitDisused, tole_PlantNursery, tole_Pylon, tole_RiversideTrees, tole_StoneWall, tole_UrbanNoVeg, tole_UrbanVeg, tole_WindTurbine, and tole_WoodyEnergyCrop.

Referenced by Set_TOLE_Att().

◆ ClassificationPermCrop()

bool Landscape::ClassificationPermCrop ( TTypesOfVegetation  a_vege_type)

Returns whether a vegetation type is classified as a permanent crop.

Currently (18/03/2015) only used for goose foraging, so silage maize does not produce grain

632 {
634  switch (a_vege_type)
635  {
646  case tov_YoungForest:
647  case tov_OrchardCrop:
648  case tov_NLOrchardCrop:
654  case tov_PTShrubPastures:
655  case tov_PTCorkOak:
656  case tov_PTVineyards:
659  case tov_DKOrchApple:
660  case tov_DKOrchPear:
661  case tov_DKOrchCherry:
662  case tov_DKOrchOther:
663  case tov_DKOOrchApple:
664  case tov_DKOOrchPear:
665  case tov_DKOOrchCherry:
666  case tov_DKOOrchOther:
668  case tov_DEOrchard:
670  case tov_DEOOrchard:
673  case tov_DEBushFruitPerm:
679  return true;
680  default: // No matching code so is should not be permanent crop
681  return false;
682  }
683 }

References tov_DEAsparagusEstablishedPlantation, tov_DEBushFruitPerm, tov_DEOAsparagusEstablishedPlantation, tov_DEOBushFruitPerm, tov_DEOOrchard, tov_DEOPermanentGrassGrazed, tov_DEOPermanentGrassLowYield, tov_DEOrchard, tov_DEPermanentGrassGrazed, tov_DEPermanentGrassLowYield, tov_DKBushFruit_Perm1, tov_DKBushFruit_Perm2, tov_DKChristmasTrees_Perm, tov_DKGrassTussocky_Perm, tov_DKOChristmasTrees_Perm, tov_DKOOrchApple, tov_DKOOrchCherry, tov_DKOOrchOther, tov_DKOOrchPear, tov_DKOrchApple, tov_DKOrchardCrop_Perm, tov_DKOrchCherry, tov_DKOrchOther, tov_DKOrchPear, tov_DKPlantNursery_Perm, tov_FINaturalGrassland_Perm, tov_NLOrchardCrop, tov_NLPermanentGrassGrazed, tov_NLPermanentGrassGrazedExtensive, tov_OrchardCrop, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetAside, tov_PTCorkOak, tov_PTOliveGroveIntensive, tov_PTOliveGroveSuperIntensive, tov_PTOliveGroveTraditional, tov_PTOliveGroveTradOrganic, tov_PTPermanentGrassGrazed, tov_PTShrubPastures, tov_PTVineyards, and tov_YoungForest.

◆ ClassificationUrbanNoVeg()

bool Landscape::ClassificationUrbanNoVeg ( TTypesOfLandscapeElement  a_tole)

Returns whether the polygon is classfied as urban with no vegetation.

1302  {
1303 
1304  switch (tole) {
1305  case tole_UrbanNoVeg:
1306  case tole_Airport:
1307  case tole_Portarea:
1308  case tole_Carpark:
1309  case tole_SmallRoad:
1310  case tole_LargeRoad:
1311  case tole_RefuseSite:
1312  case tole_ActivePit:
1313  case tole_MetalledPath:
1314  case tole_Building:
1315  case tole_AmenityGrass:
1316  case tole_MownGrassStrip:
1317  return true;
1318  }
1319  return false;
1320 }

References tole_ActivePit, tole_Airport, tole_AmenityGrass, tole_Building, tole_Carpark, tole_LargeRoad, tole_MetalledPath, tole_MownGrassStrip, tole_Portarea, tole_RefuseSite, tole_SmallRoad, and tole_UrbanNoVeg.

Referenced by Set_TOLE_Att().

◆ ClassificationVegCereal()

bool Landscape::ClassificationVegCereal ( TTypesOfVegetation  a_vege_type)

Returns whether a vegetation type is classified as cereal.

1032 {
1033  switch (a_vege_type)
1034  {
1035  case tov_SpringBarley:
1036  case tov_SpringBarleySpr:
1037  case tov_WinterBarley:
1038  case tov_SpringWheat:
1039  case tov_WinterWheat:
1040  case tov_WinterRye:
1041  case tov_Oats:
1042  case tov_Triticale:
1043  case tov_SpringBarleySeed:
1050  case tov_OWinterBarley:
1051  case tov_OWinterBarleyExt:
1052  case tov_OWinterRye:
1053  case tov_SpringBarleyGrass:
1056  case tov_OSpringBarley:
1057  case tov_OSpringBarleyPigs:
1059  case tov_OWinterWheat:
1060  case tov_OOats:
1061  case tov_OTriticale:
1062  case tov_WWheatPControl:
1064  case tov_WWheatPTreatment:
1068  case tov_OSpringBarleyExt:
1071  case tov_PLWinterWheat:
1072  case tov_PLWinterBarley:
1073  case tov_PLWinterRye:
1074  case tov_PLWinterTriticale:
1075  case tov_PLSpringWheat:
1076  case tov_PLSpringBarley:
1077  case tov_NLWinterWheat:
1078  case tov_NLSpringBarley:
1079  case tov_PLSpringBarleySpr:
1080  case tov_PLWinterWheatLate:
1081  case tov_PLMaize:
1082  case tov_PLMaizeSilage:
1083  case tov_Maize:
1084  case tov_MaizeSilage:
1085  case tov_MaizeStrigling:
1086  case tov_NLMaize:
1088  case tov_NLMaizeSpring:
1090  case tov_OSBarleySilage:
1091  case tov_DKWinterWheat:
1092  case tov_DKOWinterWheat:
1093  case tov_DKWinterWheat_CC:
1094  case tov_DKOWinterWheat_CC:
1095  case tov_DKSpringBarley:
1096  case tov_DKOSpringBarley:
1097  case tov_DKSpringBarley_CC:
1101  case tov_FIWinterWheat:
1102  case tov_FIOWinterWheat:
1103  case tov_FISpringWheat:
1104  case tov_FIOSpringWheat:
1105  case tov_FIWinterRye:
1106  case tov_FIOWinterRye:
1107  case tov_FISpringOats:
1108  case tov_FIOSpringOats:
1114  case tov_SESpringBarley:
1115  case tov_SEWinterWheat:
1116  case tov_FRWinterWheat:
1117  case tov_FRWinterBarley:
1118  case tov_FRWinterTriticale:
1119  case tov_DKCerealLegume:
1120  case tov_DKOCerealLegume:
1124  case tov_DKOSpringOats:
1125  case tov_DKOSpringOats_CC:
1126  case tov_DKOSpringWheat:
1127  case tov_DKOWinterBarley:
1128  case tov_DKOWinterRape:
1129  case tov_DKOWinterRye:
1130  case tov_DKOWinterRye_CC:
1133  case tov_DKSpringOats:
1134  case tov_DKSpringOats_CC:
1135  case tov_DKSpringWheat:
1136  case tov_DKWinterBarley:
1137  case tov_DKWinterRape:
1138  case tov_DKWinterRye:
1139  case tov_DKWinterRye_CC:
1140  case tov_UKMaize:
1141  case tov_UKSpringBarley:
1142  case tov_UKWinterBarley:
1143  case tov_UKWinterWheat:
1144  case tov_DEWinterWheat:
1145  case tov_DEWinterWheatLate:
1146  case tov_DEOats:
1147  case tov_DESpringRye:
1148  case tov_DEMaize:
1149  case tov_DEMaizeSilage:
1150  case tov_DEWinterRye:
1151  case tov_DEWinterBarley:
1152  case tov_DETriticale:
1153  case tov_DEOWinterWheat:
1154  case tov_DEOOats:
1155  case tov_DEOMaize:
1156  case tov_DEOMaizeSilage:
1157  case tov_DEOWinterRye:
1158  case tov_DEOWinterBarley:
1159  case tov_DEOTriticale:
1160  case tov_DESpringBarley:
1161  case tov_PTMaize:
1162  case tov_PTMaize_Hort:
1163  case tov_PTOats:
1164  case tov_PTWinterWheat:
1165  case tov_PTSorghum:
1166  case tov_PTTriticale:
1167  case tov_PTWinterBarley:
1168  case tov_PTWinterRye:
1169  case tov_IRSpringWheat:
1170  case tov_IRSpringBarley:
1171  case tov_IRSpringOats:
1172  case tov_IRWinterWheat:
1173  case tov_IRWinterBarley:
1174  case tov_IRWinterOats:
1175  return true;
1176  default: return false;
1177  }
1178 }

References tov_AgroChemIndustryCereal, tov_DEMaize, tov_DEMaizeSilage, tov_DEOats, tov_DEOMaize, tov_DEOMaizeSilage, tov_DEOOats, tov_DEOTriticale, tov_DEOWinterBarley, tov_DEOWinterRye, tov_DEOWinterWheat, tov_DESpringBarley, tov_DESpringRye, tov_DETriticale, tov_DEWinterBarley, tov_DEWinterRye, tov_DEWinterWheat, tov_DEWinterWheatLate, tov_DKCerealLegume, tov_DKCerealLegume_Whole, tov_DKOCerealLegume, tov_DKOCerealLegume_Whole, tov_DKOSpringBarley, tov_DKOSpringBarley_CC, tov_DKOSpringBarleyCloverGrass, tov_DKOSpringBarleySilage, tov_DKOSpringOats, tov_DKOSpringOats_CC, tov_DKOSpringWheat, tov_DKOWinterBarley, tov_DKOWinterRape, tov_DKOWinterRye, tov_DKOWinterRye_CC, tov_DKOWinterWheat, tov_DKOWinterWheat_CC, tov_DKSpringBarley, tov_DKSpringBarley_CC, tov_DKSpringBarley_Green, tov_DKSpringBarleyCloverGrass, tov_DKSpringBarleySilage, tov_DKSpringOats, tov_DKSpringOats_CC, tov_DKSpringWheat, tov_DKWinterBarley, tov_DKWinterRape, tov_DKWinterRye, tov_DKWinterRye_CC, tov_DKWinterWheat, tov_DKWinterWheat_CC, tov_FIOSpringBarley_Fodder, tov_FIOSpringBarley_Malt, tov_FIOSpringOats, tov_FIOSpringWheat, tov_FIOWinterRye, tov_FIOWinterWheat, tov_FISpringBarley_Fodder, tov_FISpringBarley_Malt, tov_FISpringOats, tov_FISpringWheat, tov_FISprSpringBarley_Fodder, tov_FIWinterRye, tov_FIWinterWheat, tov_FRWinterBarley, tov_FRWinterTriticale, tov_FRWinterWheat, tov_IRSpringBarley, tov_IRSpringOats, tov_IRSpringWheat, tov_IRWinterBarley, tov_IRWinterOats, tov_IRWinterWheat, tov_Maize, tov_MaizeSilage, tov_MaizeStrigling, tov_NLMaize, tov_NLMaizeSpring, tov_NLSpringBarley, tov_NLSpringBarleySpring, tov_NLWinterWheat, tov_Oats, tov_OBarleyPeaCloverGrass, tov_OOats, tov_OSBarleySilage, tov_OSpringBarley, tov_OSpringBarleyClover, tov_OSpringBarleyExt, tov_OSpringBarleyGrass, tov_OSpringBarleyPigs, tov_OTriticale, tov_OWinterBarley, tov_OWinterBarleyExt, tov_OWinterRye, tov_OWinterWheat, tov_OWinterWheatUndersown, tov_PLMaize, tov_PLMaizeSilage, tov_PLSpringBarley, tov_PLSpringBarleySpr, tov_PLSpringWheat, tov_PLWinterBarley, tov_PLWinterRye, tov_PLWinterTriticale, tov_PLWinterWheat, tov_PLWinterWheatLate, tov_PTMaize, tov_PTMaize_Hort, tov_PTOats, tov_PTSorghum, tov_PTTriticale, tov_PTWinterBarley, tov_PTWinterRye, tov_PTWinterWheat, tov_SESpringBarley, tov_SEWinterWheat, tov_SpringBarley, tov_SpringBarleyCloverGrass, tov_SpringBarleyGrass, tov_SpringBarleyPeaCloverGrassStrigling, tov_SpringBarleyPTreatment, tov_SpringBarleySeed, tov_SpringBarleySKManagement, tov_SpringBarleySpr, tov_SpringBarleyStrigling, tov_SpringBarleyStriglingCulm, tov_SpringBarleyStriglingSingle, tov_SpringWheat, tov_Triticale, tov_UKMaize, tov_UKSpringBarley, tov_UKWinterBarley, tov_UKWinterWheat, tov_WinterBarley, tov_WinterRye, tov_WinterWheat, tov_WinterWheatStrigling, tov_WinterWheatStriglingCulm, tov_WinterWheatStriglingSingle, tov_WWheatPControl, tov_WWheatPToxicControl, and tov_WWheatPTreatment.

Referenced by Set_TOV_Att(), and SupplyIsCereal2().

◆ ClassificationVegGooseGrass()

bool Landscape::ClassificationVegGooseGrass ( TTypesOfVegetation  a_vege_type)

Returns whether a vegetation type is classified as Goose Grass.

719 {
720  switch (a_vege_type)
721  {
722  case tov_NaturalGrass:
728  case tov_SeedGrass1:
729  case tov_SeedGrass2:
730  case tov_OSeedGrass1:
731  case tov_OSeedGrass2:
737  case tov_FodderGrass:
740  case tov_NLGrassGrazed1:
742  case tov_NLGrassGrazed2:
754  case tov_FIFeedingGround:
755  case tov_FIBufferZone:
764  case tov_UKTempGrass:
765  case tov_PTRyegrass:
766  case tov_PTYellowLupin:
770  case tov_PTGrassGrazed:
778  return true;
779  default:
780  return false;
781  }
782 }

References tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_DEOPermanentGrassGrazed, tov_DEOPermanentGrassLowYield, tov_DEPermanentGrassGrazed, tov_DEPermanentGrassLowYield, tov_DKGrassGrazed_Perm, tov_DKGrassLowYield_Perm, tov_DKGrassTussocky_Perm, tov_DKOGrassLowYield_Perm, tov_FIBufferZone, tov_FIBufferZone_Perm, tov_FIFeedingGround, tov_FIGrasslandPasturePerennial1, tov_FIGrasslandPasturePerennial2, tov_FIGrasslandSilageAnnual, tov_FIGrasslandSilagePerennial1, tov_FIGrasslandSilagePerennial2, tov_FIGreenFallow_1year, tov_FIGreenFallow_Perm, tov_FINaturalGrassland, tov_FINaturalGrassland_Perm, tov_FodderGrass, tov_FRGrassland_Perm, tov_IRGrassland_no_reseed, tov_IRGrassland_reseed, tov_NaturalGrass, tov_NLGrassGrazed1, tov_NLGrassGrazed1Spring, tov_NLGrassGrazed2, tov_NLGrassGrazedExtensive1, tov_NLGrassGrazedExtensive1Spring, tov_NLGrassGrazedExtensive2, tov_NLGrassGrazedExtensiveLast, tov_NLGrassGrazedLast, tov_NLPermanentGrassGrazed, tov_NLPermanentGrassGrazedExtensive, tov_OCloverGrassGrazed1, tov_OCloverGrassGrazed2, tov_OSeedGrass1, tov_OSeedGrass2, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PLFodderLucerne1, tov_PLFodderLucerne2, tov_PTCloverGrassGrazed1, tov_PTCloverGrassGrazed2, tov_PTGrassGrazed, tov_PTPermanentGrassGrazed, tov_PTRyegrass, tov_PTYellowLupin, tov_SeedGrass1, tov_SeedGrass2, tov_UKPermanentGrass, and tov_UKTempGrass.

Referenced by Set_TOV_Att().

◆ ClassificationVegGrass()

bool Landscape::ClassificationVegGrass ( TTypesOfVegetation  a_vege_type)

Returns whether a vegetation type is classified as Grass.

922 {
923  switch (a_vege_type)
924  {
925  case tov_NaturalGrass:
933  case tov_SetAside:
934  case tov_OSetAside:
935  case tov_SeedGrass1:
936  case tov_SeedGrass2:
937  case tov_OSeedGrass1:
938  case tov_OSeedGrass2:
943  case tov_OrchardCrop:
944  case tov_NLOrchardCrop:
945  case tov_YoungForest:
946  case tov_FodderGrass:
947  case tov_Heath:
948  case tov_WaterBufferZone:
952  case tov_PTCorkOak:
953  case tov_PTVineyards:
954  case tov_PTRyegrass:
955  case tov_PTYellowLupin:
956  case tov_PTSetAside:
968  case tov_FIFeedingGround:
969  case tov_FIBufferZone:
989  case tov_DKOVegSeeds:
990  case tov_DKGrazingPigs:
991  case tov_DKOGrazingPigs:
996  case tov_DKSetAside:
1006  case tov_DEOrchard:
1007  case tov_DEOOrchard:
1008  case tov_DKOSetAside:
1010  case tov_DKOrchApple:
1011  case tov_DKOrchPear:
1012  case tov_DKOrchCherry:
1013  case tov_DKOrchOther:
1014  case tov_DKOOrchApple:
1015  case tov_DKOOrchPear:
1016  case tov_DKOOrchCherry:
1017  case tov_DKOOrchOther:
1018  case tov_FRGrassland_Perm:
1019  case tov_FRGrassland:
1023  case tov_Wasteland:
1024  return true;
1025  default:
1026  return false;
1027  }
1028 }

References tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_DEGrasslandSilageAnnual, tov_DEGreenFallow_1year, tov_DEOGrasslandSilageAnnual, tov_DEOGreenFallow_1year, tov_DEOOrchard, tov_DEOPermanentGrassGrazed, tov_DEOPermanentGrassLowYield, tov_DEOrchard, tov_DEPermanentGrassGrazed, tov_DEPermanentGrassLowYield, tov_DKCloverGrassGrazed1, tov_DKCloverGrassGrazed2, tov_DKCloverGrassGrazed3, tov_DKGrassGrazed_Perm, tov_DKGrassLowYield_Perm, tov_DKGrassTussocky_Perm, tov_DKGrazingPigs, tov_DKGrazingPigs_Perm, tov_DKOCloverGrassGrazed1, tov_DKOCloverGrassGrazed2, tov_DKOCloverGrassGrazed3, tov_DKOGrassGrazed_Perm, tov_DKOGrassLowYield_Perm, tov_DKOGrazingPigs, tov_DKOGrazingPigs_Perm, tov_DKOOrchApple, tov_DKOOrchCherry, tov_DKOOrchOther, tov_DKOOrchPear, tov_DKOptimalFlowerMix1, tov_DKOptimalFlowerMix2, tov_DKOptimalFlowerMix3, tov_DKOrchApple, tov_DKOrchardCrop_Perm, tov_DKOrchCherry, tov_DKOrchOther, tov_DKOrchPear, tov_DKOSeedGrassRye_Spring, tov_DKOSetAside, tov_DKOSetAside_SummerMow, tov_DKOSpringFodderGrass, tov_DKOVegSeeds, tov_DKOWinterCloverGrassGrazedSown, tov_DKOWinterFodderGrass, tov_DKPlantNursery_Perm, tov_DKSeedGrassFescue_Spring, tov_DKSeedGrassRye_Spring, tov_DKSetAside, tov_DKSetAside_SummerMow, tov_DKSpringFodderGrass, tov_DKWinterCloverGrassGrazedSown, tov_DKWinterFodderGrass, tov_FIBufferZone, tov_FIBufferZone_Perm, tov_FIFeedingGround, tov_FIGrasslandPasturePerennial1, tov_FIGrasslandPasturePerennial2, tov_FIGrasslandSilageAnnual, tov_FIGrasslandSilagePerennial1, tov_FIGrasslandSilagePerennial2, tov_FIGreenFallow_1year, tov_FIGreenFallow_Perm, tov_FINaturalGrassland, tov_FINaturalGrassland_Perm, tov_FodderGrass, tov_FRGrassland, tov_FRGrassland_Perm, tov_Heath, tov_NaturalGrass, tov_NLOrchardCrop, tov_NLPermanentGrassGrazed, tov_NLPermanentGrassGrazedExtensive, tov_OCloverGrassGrazed1, tov_OCloverGrassGrazed2, tov_OrchardCrop, tov_OSeedGrass1, tov_OSeedGrass2, tov_OSetAside, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetAside, tov_PTCloverGrassGrazed1, tov_PTCloverGrassGrazed2, tov_PTCorkOak, tov_PTPermanentGrassGrazed, tov_PTRyegrass, tov_PTSetAside, tov_PTVineyards, tov_PTYellowLupin, tov_SeedGrass1, tov_SeedGrass2, tov_SetAside, tov_UKPermanentGrass, tov_Wasteland, tov_WaterBufferZone, and tov_YoungForest.

Referenced by Beetle_Adult::IsSuitableForHibernation(), Set_TOV_Att(), and SupplyIsGrass2().

◆ ClassificationVegMaize()

bool Landscape::ClassificationVegMaize ( TTypesOfVegetation  a_vege_type)

Returns whether a vegetation type is classified as maize.

Currently (18/03/2015) only used for goose foraging, so silage maize does not produce grain

688 {
690  switch (a_vege_type)
691  {
692  case tov_Maize:
693  case tov_OMaizeSilage:
694  case tov_MaizeSilage:
695  case tov_PLMaize:
696  case tov_PLMaizeSilage:
697  case tov_NLMaize:
698  case tov_NLMaizeSpring:
699  case tov_UKMaize:
700  case tov_DEMaize:
701  case tov_DEMaizeSilage:
702  case tov_DEOMaize:
703  case tov_DEOMaizeSilage:
704  case tov_PTMaize:
705  case tov_PTMaize_Hort:
706  case tov_DKMaize:
707  case tov_DKMaizeSilage:
708  case tov_DKOMaize:
709  case tov_DKOMaizeSilage:
710 
711  return true;
712  default: // No matching code so is should not be maize
713  return false;
714  }
715 }

References tov_DEMaize, tov_DEMaizeSilage, tov_DEOMaize, tov_DEOMaizeSilage, tov_DKMaize, tov_DKMaizeSilage, tov_DKOMaize, tov_DKOMaizeSilage, tov_Maize, tov_MaizeSilage, tov_NLMaize, tov_NLMaizeSpring, tov_OMaizeSilage, tov_PLMaize, tov_PLMaizeSilage, tov_PTMaize, tov_PTMaize_Hort, and tov_UKMaize.

Referenced by Set_TOV_Att().

◆ ClassificationVegMatureCereal()

bool Landscape::ClassificationVegMatureCereal ( TTypesOfVegetation  a_vege_type)

Returns whether a vegetation type is classified as cereal grown to maturity.

786 {
787  switch (a_vege_type)
788  {
789  case tov_SpringBarley:
790  case tov_SpringBarleySpr:
791  case tov_WinterBarley:
792  case tov_SpringWheat:
793  case tov_WinterWheat:
794  case tov_WinterRye:
795  case tov_Oats:
796  case tov_Triticale:
804  case tov_OWinterBarley:
806  case tov_OWinterRye:
810  case tov_OSpringBarley:
813  case tov_OWinterWheat:
814  case tov_OOats:
815  case tov_OTriticale:
816  case tov_WWheatPControl:
825  case tov_PLWinterWheat:
826  case tov_PLWinterBarley:
827  case tov_PLWinterRye:
829  case tov_PLSpringWheat:
830  case tov_PLSpringBarley:
833  case tov_NLSpringBarley:
834  case tov_NLWinterWheat:
836  case tov_DKWinterWheat:
837  case tov_DKOWinterWheat:
838  case tov_DKSpringBarley:
839  case tov_DKOSpringBarley:
846  case tov_FIWinterWheat:
847  case tov_FIOWinterWheat:
848  case tov_FISpringWheat:
849  case tov_FIOSpringWheat:
850  case tov_FIWinterRye:
851  case tov_FIOWinterRye:
852  case tov_FISpringOats:
853  case tov_FIOSpringOats:
859  case tov_SESpringBarley:
860  case tov_SEWinterWheat:
861  case tov_FRWinterWheat:
862  case tov_FRWinterBarley:
864  case tov_DKCerealLegume:
865  case tov_DKOCerealLegume:
869  case tov_DKOSpringOats:
870  case