ALMaSS Rodenticide ODdox  1.1
The rodenticide model description following ODdox protocol
Landscape Class Reference

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

#include <landscape.h>

Public Member Functions

void FillVegAreaData ()
 
double GetVegArea (int v)
 
void DumpVegAreaData (int a_day)
 
void SkylarkEvaluation (SkTerritories *a_skt)
 
void RodenticidePredatorsEvaluation (RodenticidePredators_Population_Manager *a_rppm)
 
Population_ManagerSupplyThePopManager ()
 Get the pointer to the current main population manager. More...
 
void SetThePopManager (Population_Manager *a_ptr)
 Set the pointer to the current main population manager. More...
 
int SupplyFarmAnimalCensus (int a_farm_ref, int a_LifeStage)
 
int SupplyVegPhase (int a_poly)
 
void SetPolymapping (int a_index, int a_val)
 
int GetPolymapping (int a_index)
 
 ~Landscape (void)
 
 Landscape (void)
 
void SimulationClosingActions ()
 
void Tick (void)
 
void TurnTheWorld (void)
 
int HowManyPonds ()
 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)
 Returns the index of a pond based on pondref or -1 if not found. More...
 
void SetMaleNewtPresent (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...
 
Farm * SupplyFarmPtr (int a_owner)
 
FarmManager * SupplyFarmManagerPtr ()
 
int SupplyLargestPolyNumUsed ()
 
bool SupplyShouldSpray ()
 
double SupplyVegDigestabilityVector (unsigned int a_index)
 
double SupplyVegDigestability (int a_polyref)
 
double SupplyVegDigestability (int a_x, int a_y)
 
double SupplyVegHeightVector (unsigned int a_index)
 
double SupplyVegHeight (int a_polyref)
 
double SupplyVegHeight (int a_x, int a_y)
 
double SupplyVegBiomassVector (unsigned int a_index)
 
double SupplyVegBiomass (int a_polyref)
 
double SupplyVegBiomass (int a_x, int a_y)
 
int SupplyVegDensity (int a_polyref)
 
int SupplyVegDensity (int a_x, int a_y)
 
double SupplyWeedBiomass (int a_polyref)
 
double SupplyWeedBiomass (int a_x, int a_y)
 
PollenNectarQuality SupplyPollen (int a_polyref)
 
PollenNectarQuality SupplyPollen (int a_x, int a_y)
 
double SupplyTotalPollen (int a_polyref)
 
double SupplyTotalPollen (int a_x, int a_y)
 
PollenNectarQuality SupplyNectar (int a_polyref)
 
PollenNectarQuality SupplyNectar (int a_x, int a_y)
 
double SupplyTotalNectar (int a_polyref)
 
double SupplyTotalNectar (int a_x, int a_y)
 
bool SupplySkScrapes (int a_polyref)
 
bool SupplyVegPatchy (int a_polyref)
 
bool SupplyVegPatchy (int a_x, int a_y)
 
double SupplyGreenBiomass (int a_polyref)
 
double SupplyGreenBiomass (int a_x, int a_y)
 
double SupplyDeadBiomass (int a_polyref)
 
double SupplyDeadBiomass (int a_x, int a_y)
 
double SupplyLAGreen (int a_polyref)
 
double SupplyLAGreen (int a_x, int a_y)
 
double SupplyLATotal (int a_x, int a_y)
 
double SupplyVegCover (int a_polyref)
 
double SupplyVegCoverVector (unsigned int a_index)
 
double SupplyVegCover (int a_x, int a_y)
 
TTypesOfVegetation SupplyLastSownVeg (int a_polyref)
 
TTypesOfVegetation SupplyLastSownVeg (int a_x, int a_y)
 
TTypesOfVegetation SupplyLastSownVegVector (unsigned int a_index)
 
double SupplyInsects (int a_polyref)
 
double SupplyInsects (int a_x, int a_y)
 
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...
 
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 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...
 
RodenticidePredators_Population_ManagerSupplyRodenticidePredatoryManager ()
 
TTypesOfPesticide SupplyPesticideType (void)
 
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. More...
 
void ReadOpenness (void)
 Reads openness values from a standard input file for all polygons. More...
 
int CalulateFieldOpennessCentroid (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 CalulateFieldOpennessAllCells (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...
 
bool SupplyLEHigh (int a_x, int a_y)
 Tests whether the polygon at a_x,a_y is designated as high. More...
 
polylist * SupplyLargeOpenFieldsNearXY (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...
 
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)
 
APoint SupplyCentroidIndex (int a_polyrefindex)
 
int SupplyCentroidX (int a_polyref)
 
int SupplyCentroidY (int a_polyref)
 
int SupplyCentroidX (int a_x, int a_y)
 
int SupplyCentroidY (int a_x, int a_y)
 
int SupplyFarmIntensity (int a_x, int a_y)
 
int SupplyFarmIntensity (int a_polyref)
 
int SupplyFarmIntensityI (int a_polyindex)
 
TTypesOfLandscapeElement SupplyElementType (int a_polyref)
 
TTypesOfLandscapeElement SupplyElementType (int a_x, int a_y)
 
TTypesOfLandscapeElement SupplyElementTypeCC (int a_x, int a_y)
 
int SupplyCountryDesig (int a_x, int a_y)
 
int SupplyElementSubType (int a_polyref)
 
int SupplyElementSubType (int a_x, int a_y)
 
TTypesOfVegetation SupplyVegType (int a_x, int a_y)
 
TTypesOfVegetation SupplyVegType (int polyref)
 
TTypesOfVegetation SupplyVegTypeVector (unsigned int a_index)
 
int SupplyGrazingPressureVector (unsigned int a_index)
 
int SupplyGrazingPressure (int a_polyref)
 
int SupplyGrazingPressure (int a_x, int a_y)
 
bool SupplyIsCereal (int a_polyref)
 
bool SupplyIsMatureCereal (int a_polyref)
 
bool SupplyIsGrass (int a_polyref)
 
bool SupplyIsGrass2 (TTypesOfVegetation a_vege_type)
 
bool SupplyIsCereal2 (TTypesOfVegetation a_vege_type)
 
bool SupplyHasTramlines (int a_x, int a_y)
 
bool SupplyHasTramlines (int a_polyref)
 
bool SupplyJustMownVector (unsigned int a_index)
 
bool SupplyJustMown (int a_polyref)
 
int SupplyJustSprayedVector (unsigned int a_index)
 
int SupplyJustSprayed (int a_polyref)
 
int SupplyJustSprayed (int a_x, int a_y)
 
int SupplyTreeAge (int a_Polyref)
 
int SupplyTreeAge (int, int)
 
int SupplyVegAge (int a_Polyref)
 
int SupplyVegAge (int a_x, int a_y)
 
int SupplyNumberOfFarms ()
 
int SupplyFarmOwner (int a_x, int a_y)
 
int SupplyFarmOwner (int a_polyref)
 
int SupplyFarmOwnerIndex (int a_x, int a_y)
 
int SupplyFarmOwnerIndex (int a_polyref)
 
TTypesOfFarm SupplyFarmType (int a_polyref)
 
TTypesOfFarm SupplyFarmType (int a_x, int a_y)
 
TTypesOfOptFarms SupplyOptFarmType (int a_x, int a_y)
 
int SupplyFarmArea (int a_polyref)
 
double SupplyPolygonAreaVector (int a_polyref)
 Returns the area of a polygon using the vector index as a reference. More...
 
double SupplyPolygonArea (int a_polyref)
 
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. 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)
 
int SupplyLastTreatment (int a_x, int a_y, int *a_index)
 
double GetHareFoodQuality (int a_polygon)
 
double SupplyGlobalRadiation ()
 
double SupplyGlobalRadiation (long a_date)
 
double SupplyRain (void)
 
double SupplyTemp (void)
 
double SupplyHumidity (void)
 
double SupplyMeanTemp (long a_date, unsigned int a_period)
 
double SupplyWind (void)
 
int SupplyWindDirection (void)
 
double SupplySnowDepth (void)
 
bool SupplySnowcover (void)
 
int SupplyDaylength (void)
 
double SupplyRain (long a_date)
 
double SupplyTemp (long a_date)
 
double SupplyWind (long a_date)
 
double SupplyDayDegrees (int a_polyref)
 
double SupplyRainPeriod (long a_date, int a_period)
 
double SupplyWindPeriod (long a_date, int a_period)
 
double SupplyTempPeriod (long a_date, int a_period)
 
bool SupplySnowcover (long a_date)
 
bool IsFieldType (TTypesOfLandscapeElement a_tole)
 
int SupplyPolyRef (int a_x, int a_y)
 
int SupplyPolyRefIndex (int a_x, int a_y)
 
int SupplyPolyRefCC (int a_x, int a_y)
 
int SupplySimAreaWidth (void)
 
int SupplySimAreaHeight (void)
 
int SupplySimAreaMaxExtent (void)
 
int SupplySimAreaMinExtent (void)
 
int SupplyDaylength (long a_date)
 
int SupplyDayInYear (void)
 
int SupplyHour (void)
 Get the hour of the day. More...
 
int SupplyMinute (void)
 Get the minute of the hour. More...
 
unsigned int SupplyNumberOfPolygons (void)
 
TTypesOfLandscapeElement SupplyElementTypeFromVector (unsigned int a_index)
 
int SupplyPolyRefVector (unsigned int a_index)
 
int SupplyPesticideCell (int a_polyref)
 
int SupplyValidX (int a_polyref)
 
int SupplyValidY (int a_polyref)
 
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)
 
int CorrectHeight (int y)
 
void SetPolyMaxMinExtents (void)
 
void CalculateCentroids (void)
 
void DumpCentroids (void)
 
void BuildingDesignationCalc ()
 used to calculate whether a building is rural or town - for rodenticide use More...
 
void CentroidSpiralOut (int a_polyref, int &a_x, int &a_y)
 
const char * SupplyVersion (void)
 
void DumpPublicSymbols (const char *a_dumpfile, CfgSecureLevel a_level)
 
void DumpAllSymbolsAndExit (const char *a_dumpfile)
 
bool ReadSymbols (const char *a_cfgfile)
 
void DumpMapInfoByArea (const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
 
void Warn (std::string a_msg1, std::string a_msg2)
 
intSupplyMagicMapP (int a_x, int a_y)
 
int MagicMapP2PolyRef (int a_magic)
 
int SupplyRoadWidth (int, int)
 
double SupplyTrafficLoad (int a_x, int a_y)
 
double SupplyTrafficLoad (int a_polyref)
 
int SupplyTreeHeight (int, int)
 
int SupplyUnderGrowthWidth (int, int)
 
int SupplyTreeHeight (int)
 
int SupplyUnderGrowthWidth (int)
 
long SupplyGlobalDate (void)
 
int SupplyYear (void)
 
int SupplyYearNumber (void)
 
int SupplyMonth (void)
 
int SupplyDayInMonth (void)
 
double SupplyDaylightProp ()
 
double SupplyNightProp ()
 
void SupplyLEReset (void)
 
int SupplyLENext (void)
 
int SupplyLECount (void)
 
LE_Signal SupplyLESignal (int a_polyref)
 
void SetLESignal (int a_polyref, LE_Signal a_signal)
 
void IncTreatCounter (int a_treat)
 
TTypesOfLandscapeElement TranslateEleTypes (int EleReference)
 
TTypesOfVegetation TranslateVegTypes (int VegReference)
 
LESupplyLEPointer (int a_polyref)
 
int BackTranslateEleTypes (TTypesOfLandscapeElement EleReference)
 
int BackTranslateVegTypes (TTypesOfVegetation VegReference)
 
std::string EventtypeToString (int a_event)
 
std::string PolytypeToString (TTypesOfLandscapeElement a_le_type)
 
std::string VegtypeToString (TTypesOfVegetation a_veg)
 
void InitOsmiaBeeNesting ()
 Read in the Osmia nest density files and allocate to each LE object. More...
 
void UpdateOsmiaNesting ()
 Tesll all LE objects to update their osmia nest status. More...
 
bool SupplyOsmiaNest (int a_x, int a_y)
 Find out whether an osmia nest can be made here. More...
 
void IncOsmiaNest (int a_x, int a_y)
 Reopen the osmia nest here
More...
 
void ReleaseOsmiaNest (int a_x, int a_y)
 Reopen the osmia nest here
More...
 

Protected Member Functions

void GISASCII_Output (string outpfile, int UTMX, int UTMY)
 Write ASCII file of the ALMaSS map. More...
 
void AddGreenElement (LE *a_green)
 
void ReadPolys (const char *a_polyfile)
 
void ReadPolys2 (const char *a_polyfile)
 reads in polygon information. Version 2 including centroid and openness information More...
 
void PolysValidate (bool a_exit_on_invalid)
 
bool PolysRemoveInvalid (void)
 
void PolysDump (const char *a_filename)
 
void DumpMap (const char *a_filename)
 
void ConsolidatePolys (void)
 
void CountMapSquares (void)
 
void PolysRenumber (void)
 
void RebuildPolyMapping ()
 
void ForceArea (void)
 
void ChangeMapMapping (void)
 
LENewElement (TTypesOfLandscapeElement a_type)
 
void RemoveMissingValues ()
 A method for replacing missing values in the map with corrected ones - slow. More...
 
void TestCropManagement (void)
 
void VegDump (int x, int y)
 
void EventDump (int x, int y, int x2, int y2)
 
void EventDumpPesticides (int x1, int y1)
 
void DegreesDump ()
 Prints the sum of day degrees. See #FarmManager::daydegrees. More...
 
bool BorderNeed (TTypesOfLandscapeElement a_letype)
 
void BorderAdd (LE *a_field, TTypesOfLandscapeElement a_type)
 
void BorderRemoval (void)
 
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 UnsprayedMarginAdd (LE *a_field)
 
void UnsprayedMarginScan (LE *a_field, int a_width)
 
void BorderScan (LE *a_field, int a_width)
 
bool BorderTest (int a_fieldpoly, int a_borderpoly, int a_x, int a_y)
 
bool StepOneValid (int a_polyindex, int a_x, int a_y, int step)
 
bool UMarginTest (int a_fieldpoly, int a_borderpoly, int a_x, int a_y, int a_width)
 
bool FindValidXY (int a_field, int &a_x, int &a_y)
 
bool BorderStep (int a_fieldpoly, int a_borderpoly, int *a_x, int *a_y)
 
bool BorderStep (int a_fieldpoly, int a_borderpoly, APoint *a_coord)
 
void AddBeetleBanks (TTypesOfLandscapeElement a_tole)
 
bool BeetleBankPossible (LE *a_field, TTypesOfLandscapeElement a_tole)
 
void BeetleBankAdd (int x, int y, int angle, int length, LE *a_field, TTypesOfLandscapeElement a_tole)
 
bool FindFieldCenter (LE *a_field, int *x, int *y)
 
int FindLongestAxis (int *x, int *y, int *a_length)
 
void AxisLoop (int a_poly, int *a_x, int *a_y, int a_axis)
 
void AxisLoop (int a_poly, APoint *a_cor, int a_axis)
 
void AxisLoopLtd (int a_poly, APoint *a_cor, int a_axis, int a_limit)
 
void hb_Add (void)
 
void hb_AddNewHedgebanks (int a_orig_poly_num)
 
int hb_StripingDist (void)
 
void hb_GenerateHBPolys (void)
 
void hb_FindHedges (void)
 
bool hb_FindBoundingBox (int a_poly_num)
 
void hb_UpPolyNumbers (void)
 
void hb_ClearPolygon (int a_poly_num)
 
void hb_PaintBorder (int a_color)
 
bool hb_MapBorder (int a_x, int a_y)
 
bool hb_HasOtherNeighbour (int a_x, int a_y)
 
bool hb_PaintWhoHasNeighbourColor (int a_neighbour_color, int a_new_color)
 
bool hb_HasNeighbourColor (int a_x, int a_y, int a_neighbour_color)
 
void hb_MarkTopFromLocalMax (int a_color)
 
void hb_MarkTheBresenhamWay (void)
 
int hb_MaxUnpaintedNegNeighbour (int a_x, int a_y)
 
void hb_ResetColorBits (void)
 
void hb_RestoreHedgeCore (int a_orig_poly_number)
 
void hb_DownPolyNumbers (void)
 
void hb_Cleanup (void)
 
void DumpMapGraphics (const char *a_filename)
 
void DumpTreatCounters (const char *a_filename)
 
bool CIPELandscapeMaker ()
 

Protected Attributes

int m_treatment_counts [last_treatment]
 
int m_LargestPolyNumUsed
 
vector< intm_PondIndexList
 List of pond indexes. More...
 
vector< intm_PondRefsList
 List of pond polyrefs. More...
 
vector< inthb_hedges
 
vector< LE * > hb_new_hbs
 
int m_x_add [8]
 
int m_y_add [8]
 
inthb_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
 
int le_signal_index
 

Private Attributes

char m_versioninfo [30]
 
FarmManager * m_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...
 
RasterMap * m_land
 The big map. More...
 
vector< intm_polymapping
 
PesticideMap * m_PesticideMap
 For specialised pesticide recording. More...
 
int m_width
 
int m_height
 
int m_width10
 
int m_height10
 
int m_minmaxextent
 
int m_maxextent
 
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
 
double * l_vegtype_areas
 
Population_Managerm_ThePopManager
 a pointer to the current main population manager More...
 
RodenticideManagerm_RodenticideManager
 
RodenticidePredators_Population_Managerm_RodenticidePreds
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
 Curve relatning goose intake rates in KJ/min to vegetation height. More...
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
 

Detailed Description

The landscape class containing all environmental and topographical data.

Constructor & Destructor Documentation

◆ ~Landscape()

Landscape::~Landscape ( void  )
1424  {
1425  if ( l_map_dump_treatcounts_enable.value() ) {
1427  }
1428 
1429 #ifdef __RECORDFARMEVENTS
1430  m_farmeventfile->close();
1431  delete m_farmeventfile;
1432 #endif
1433 
1434  for ( unsigned int i = 0; i < m_elems.size(); i++ )
1435  delete m_elems[ i ];
1436 
1437  free( l_vegtype_areas );
1438  delete m_land;
1439  //delete g_rotation;
1440  delete g_crops;
1441  delete g_letype;
1442  delete g_weather;
1443  delete g_date;
1444  delete g_pest;
1445  if (cfg_rodenticide_enable.value())
1446  {
1447  delete m_RodenticideManager;
1448  delete m_RodenticidePreds;
1449  }
1450  delete m_FarmManager;
1451  delete g_msg; // Must be last.
1452 }

References cfg_rodenticide_enable(), g_letype, g_pest, l_map_dump_treatcounts_enable(), and l_map_dump_treatcounts_file().

◆ Landscape()

Landscape::Landscape ( void  )

If the farmer decision making model is on, the #FarmManager::InitFarms() is called here to initialise the farms. The #FarmManager::FindNeighbours() function is called.

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.

Rodenticide handling code. If enabled then rodenticide mapping provides access to predicted relative density of poisoned rodents per unit area.

814  {
815 
818  // Set up operation flags
819  bool didRenumber = false;
820  bool didCalcCentroids = false;
821  bool didConsolidate = false;
822  bool didCalcOpenness = false;
823  bool didCalcOther = false;
827  // Set up globals
828  g_landscape_p = this;
829  for (int i = 1; i <= 2000; i++) {
830  g_SpeedyDivides[i] = 1 / double(i);
831  }
832  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; // W,SW,S,SE,E,NE,N,NW
833  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
834  for (int i = 0; i < 8; i++) {
835  m_x_add[i] = x_add[i];
836  m_y_add[i] = y_add[i];
837  }
838 
839 
841 
842  if (l_map_print_version_info.value()) {
843  printf("This program uses the Landscape simulator V%s\n", m_versioninfo);
844  }
845 #ifdef __GITVERSION
846  if (l_map_print_git_version_info.value())
847  {
848  std::cout << "hash=" << GIT_HASH << ", time=" << COMPILE_TIME << ", branch=" << GIT_BRANCH << std::endl;
849  }
850 #endif
851 
852 
853  // For testing.
854  //g_cfg->DumpPublicSymbols( "publicsymbols.cfg", CFG_PUBLIC );
855  //exit(1);
856 
857  //Pinkfeet
858  m_GooseIntakeRateVSVegetationHeight_PF = new Polynomial2CurveClass(cfg_P1A.value(), cfg_P1B.value(), cfg_P1C.value(), cfg_P1D.value(), cfg_P1E.value(), cfg_P1F.value(), cfg_P1G.value(), cfg_P1H.value());
859  //Barnacle
860  m_GooseIntakeRateVSVegetationHeight_BG = new Polynomial2CurveClass(cfg_B6A.value(), cfg_B6B.value(), cfg_B6C.value(), cfg_B6D.value(), cfg_B6E.value(), cfg_B6F.value(), cfg_B6G.value(), cfg_B6H.value());
861  //Greylag
862  m_GooseIntakeRateVSVegetationHeight_GL = new Polynomial2CurveClass(cfg_G6A.value(), cfg_G6B.value(), cfg_G6C.value(), cfg_G6D.value(), cfg_G6E.value(), cfg_G6F.value(), cfg_G6G.value(), cfg_G6H.value());
863  if (cfg_WriteCurve.value()) {
864  m_GooseIntakeRateVSVegetationHeight_GL->WriteDataFile(10);
865  m_GooseIntakeRateVSVegetationHeight_BG->WriteDataFile(10);
866  m_GooseIntakeRateVSVegetationHeight_PF->WriteDataFile(10);
867  }
868 
869  cout << "Creating Calendar Object" << endl;
870  g_date = new Calendar;
871  cout << "Creating Weather Object" << endl;
872  g_weather = new Weather(l_map_weather_file.value());
873  cout << "Creating LE_TypeClass Object" << endl;
874  g_letype = new LE_TypeClass;
875  cout << "Creating PlantGrowthData Object" << endl;
876  g_crops = new PlantGrowthData(l_map_cropcurves_file.value());
877  cout << "Creating PollenNectarDevelopmentData Object" << endl;
878  g_nectarpollen = new PollenNectarDevelopmentData("toleALMaSSNectarPollenInput.txt", "tovALMaSSNectarPollenInput.txt", this);
880 
881  // Reset treatment counters.
882  for (int i = 0; i < last_treatment; i++) {
883  m_treatment_counts[i] = 0;
884  }
885  cout << "Creating FarmManager Object" << endl;
886  m_FarmManager = new FarmManager();
887 
888  cout << "Reading polygon reference file" << endl;
889  ReadPolys2(l_map_poly_file.value());
890 
891  //this carries out the optimisation
892  if (cfg_OptimisingFarms.value()){
893  m_FarmManager->InitFarms();
894  m_FarmManager->Save_diff_farm_types_areas();
895  }
896 
897  cout << "Creating RasterMap Object" << endl;
898  m_land = new RasterMap(l_map_map_file.value(), this);
899  m_width = m_land->MapWidth();
900  m_height = m_land->MapHeight();
902  m_width10 = 10 * m_width;
903  m_height10 = 10 * m_height;
905 
906 
907  // Validate polygons, ie. ensure those reference in the
908  // polygon file also shows up in the map.
909  cout << "In PolysValidate" << endl;
910  PolysValidate(false);
911  cout << "In PolysRemoveInvalid" << endl;
913  cout << "Creating ponds" << endl;
914  if (cfg_MaxPondSize.value() > 0) {
915  // This takes any small freshwater and converts it to a pond.
916  for (unsigned int i = 0; i < m_elems.size(); i++) {
917  if (m_elems[i]->GetElementType() == tole_Freshwater) {
918  if (m_elems[i]->GetArea() <= cfg_MaxPondSize.value()) {
919  Pond* pond = new Pond;
920  pond->DoCopy(m_elems[i]);
921  pond->SetALMaSSEleType(g_letype->BackTranslateEleTypes(tole_Pond));
922  pond->SetElementType(tole_Pond);
923  m_elems[i] = dynamic_cast<LE*>(pond);
924  }
925  }
926  }
927  }
928  cout << "In PolysValidate second time" << endl;
929  PolysValidate(true);
930 
937  {
938  cout << "In DoMissingPolygonsManipulations" << endl;
939  // Find big continuous polygons
940  for (unsigned int i = 0; i < m_elems.size(); i++)
941  {
942  if (m_elems[i]->GetElementType() == tole_Missing)
943  {
944  double area = m_elems[i]->GetArea();
945  int areaMinrect = (m_elems[i]->GetMaxX() - m_elems[i]->GetMinX()) * (m_elems[i]->GetMaxY() - m_elems[i]->GetMinY());
946  if ((areaMinrect / area > 4) || (area < 1000))
947  {
948  // Unlikely to be a field, or if so a very narrow odd one. We will assume this is a missing data issue.
949  }
950  else
951  {
952  // Big poly with more than 25% of the included rectangle covered, must be a field of some sort.
953  // create a new wasteland and swap this in to the m_elems, then delete the old missing polygon
954  LE * wl = NewElement(tole_Wasteland);
955  wl->SetPoly(m_elems[i]->GetPoly());
956  wl->SetArea(floor(0.5 + area));
957  wl->SetSoilType(m_elems[i]->GetSoilType());
959  wl->SetCentroid(-1, -1);
960  wl->SetOpenness(0);
961  delete m_elems[i];
962  m_elems[i] = wl;
963  }
964  }
965  }
966  // By here all the big ones should be safely tidied away to wasteland and now we need to deal with the raster map.
968  for (unsigned int i = 0; i < m_elems.size(); i++)
969  {
970  // Now we deal with all the little ones that were not by fields
971  if (m_elems[i]->GetElementType() == tole_Missing)
972  {
973  LE * wl = NewElement(tole_Wasteland);
974  wl->SetPoly(m_elems[i]->GetPoly());
975  wl->SetArea(m_elems[i]->GetArea());
976  wl->SetSoilType(m_elems[i]->GetSoilType());
978  wl->SetCentroid(-1, -1);
979  wl->SetOpenness(0);
980  delete m_elems[i];
981  m_elems[i] = wl;
982  }
983  }
984  cout << "In PolysValidate third time" << endl;
985  PolysValidate(false);
986  if (PolysRemoveInvalid()) {
987  cout << "In PolysValidate fourth time" << endl;
988  PolysValidate(true);
989  }
990  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after resolving missing polygons. ", "");
991  didCalcOther = true;
992  }
993 
994  // ChangeMapMapping() also enters a valid starting
995  // coordinate for the border generating farm method below.
996  cout << "In ChangeMapMapping" << endl;
998 
1002  if ((m_LargestPolyNumUsed != ((int)m_elems.size() - 1)))
1003  {
1004  cout << "In poly renumber" << endl;
1005 
1006  PolysRenumber();
1007  didRenumber = true;
1008  }
1009  // do we want to remove small polygons?
1010  if (l_map_removesmallpolygons.value())
1011  {
1012  cout << "In Landscape::Landscape() Small polygon removal" << endl;
1013  int removed = RemoveSmallPolygons();
1014  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after removing small polygons and map dump. Polygons removed:", removed);
1015  didCalcOther = true;
1016  }
1017  // Do we want to re-write the current files and consolidate polys?
1018  else if (l_map_consolidatepolys.value())
1019  {
1020  cout << "In consolidate polys" << endl;
1021  didConsolidate = true;
1022  ConsolidatePolys();
1023  }
1024  else if (g_map_le_borderremoval.value())
1025  {
1026  cout << "In map_le_borderremoval" << endl;
1027  // Does not use centroids so is safe to use here
1028  BorderRemoval();
1029  CountMapSquares();
1030  ForceArea();
1031  g_msg->Warn(WARN_FILE, "Landscape::Landscape() - BorderRemoval "" map dump to follow.", "");
1032  didCalcOther = true;
1033  }
1034 
1035 
1036  // 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
1037  // are two reasons for this - 1) that we did not have them in the original polyref file, 2) that we changed the map
1038  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation)
1039  {
1040  PolysValidate(false);
1041  if (PolysRemoveInvalid()) PolysValidate(true);
1042  ChangeMapMapping();
1043  PolysRenumber();
1045  didCalcCentroids = true;
1046  }
1047  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation || didCalcCentroids || l_map_calc_openness.value())
1048  {
1049  if (l_map_calc_openness.value()) CalculateOpenness(true);
1050  else CalculateOpenness(false);
1051  didCalcOpenness = true;
1052  }
1053  if (didCalcCentroids || didConsolidate || didCalcOpenness || didCalcOther || m_NeedCentroidCalculation || didRenumber || !m_FarmManager->GetIsRenumbered())
1054  {
1055  // We need to dump the map and polyrefs
1056  m_FarmManager->DumpFarmrefs();
1057  DumpMap(l_map_dump_map_file.value());
1059  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
1060  exit(0);
1061  }
1062 
1063  // Below here we have the more complicated map manipulations. These will need recalculation of centroids and openness after they are run.
1064  // However, we really do not want to get here with invalid centroids, hence forced dump and exit for manipulations up to this point.
1065 
1066  didCalcOther = false;
1067  // Add artificial hedgebanks to the hedges in the landscape,
1068  // if requested.
1069  if (l_map_art_hedgebanks.value()) {
1070  hb_Add();
1071  didCalcOther = true;
1072  }
1073  else if (g_map_le_borders.value())
1074  {
1075  cout << "Generating LE Borders around fields" << endl;
1076  cout << "Border chance = " << g_map_le_border_chance.value() << endl;
1077  cout << "Border width = " << g_map_le_borderwidth.value() << endl;
1078  // Generate border around each *farm* landscape element.
1079  cout << "Setting MaxMin Extents" << endl;
1081  cout << "Adding Borders" << endl;
1082  unsigned sz = (unsigned)m_elems.size();
1083  for (unsigned i = 0; i < sz; i++)
1084  {
1085  if (m_elems[i]->GetBorder() != NULL)
1086  {
1087  // Border around this element, so must be a farm field.
1088  // If the field is too small then ignore it
1089  if (m_elems[i]->GetArea() > g_map_le_borders_min_field_size.value())
1090  {
1091  TTypesOfLandscapeElement t = g_letype->TranslateEleTypes(g_map_le_borderstype.value());
1092  BorderAdd(m_elems[i], t);
1093  }
1094  }
1095  }
1096  didCalcOther = true;
1097  }
1098  else // Some special code to 'soften' the edges of orchards
1099  if (g_map_orchards_borders.value())
1100  {
1101  // Generate border around each *farm* landscape element.
1102  for (unsigned int i = 0; i < m_elems.size(); i++) {
1103  if (m_elems[i]->GetElementType() == tole_Orchard)
1104  {
1105  TTypesOfLandscapeElement t = g_letype->TranslateEleTypes(g_map_le_borderstype.value());
1106  BorderAdd(m_elems[i], t);
1107  }
1108  }
1109  didCalcOther = true;
1110  }
1111  else
1112  // Unsprayed Margin Code....
1113  if (g_map_le_unsprayedmargins.value())
1114  {
1115  CountMapSquares();
1116  ForceArea();
1117 
1118  // Generate border around each *farm* landscape element.
1119  for (unsigned int i = 0; i < m_elems.size(); i++)
1120  {
1121  if (m_elems[i]->GetUnsprayedMarginPolyRef() != -1)
1122  {
1123  // But not if the field is too small to have them (<1Ha)
1124  if (m_elems[i]->GetArea() > 10000)
1125  {
1126  // Border around this element, so must be a farm field.
1128  }
1129  else m_elems[i]->SetUnsprayedMarginPolyRef(-1);
1130  }
1131  }
1132  didCalcOther = true;
1133  }
1134  else if (cfg_AddBeetleBanks.value())
1135  {
1136  cout << "Adding beetle banks now" << endl;
1137  AddBeetleBanks((TTypesOfLandscapeElement)cfg_BeetleBankType.value());
1138  didCalcOther = true;
1139  }
1140 
1141  if (l_map_dump_gfx_enable.value())
1142  {
1144  }
1145 
1146  if (l_map_dump_enable.value() || didCalcOther)
1147  {
1148  CountMapSquares();
1149  ForceArea();
1150  PolysValidate(false);
1151  if (PolysRemoveInvalid()) PolysValidate(true);
1152  ChangeMapMapping();
1153  PolysRenumber();
1156  m_FarmManager->DumpFarmrefs();
1157  cout << "Dumping map" << endl;
1158  DumpMap(l_map_dump_map_file.value());
1159  cout << "Dumping polygon refs file" << endl;
1161  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
1162  exit(0);
1163  }
1164 
1165  /*'''''''''''''''''' CIPE LANDSCAPE MAKER CODE HERE //'''''''''''''''''''''
1166  if ( l_map_CIPEmaker_enable.value() ) {
1167  CIPELandscapeMaker();
1168  if ( l_map_dump_exit.value() ) {
1169  g_msg->Warn( WARN_FILE, "Landscape::Landscape(): ""Normal exit after map dump.", "" );
1170  exit( 0 );
1171  }
1172  }
1173  //'''''''''''''''''' CIPE LANDSCAPE MAKER CODE ABOVE //'''''''''''''''''''''
1174  */
1175  // Set the type of hedgebanks.
1176  int l_subtype = cfg_HedgeSubtypeMinimum.value();
1177  for (unsigned int i = 0; i < m_elems.size(); i++) {
1178  if (m_elems[i]->GetElementType() == tole_HedgeBank) {
1179  m_elems[i]->SetSubType(l_subtype);
1180  if (++l_subtype >= cfg_HedgeSubtypeMaximum.value())
1181  l_subtype = cfg_HedgeSubtypeMinimum.value();
1182  }
1183  }
1184 
1185  // And another to set the type of hedges
1186  // ***CJT*** 2003-12-02
1187  l_subtype = 0;
1188  for (unsigned int i = 0; i < m_elems.size(); i++) {
1189  if (m_elems[i]->GetElementType() == tole_Hedges) {
1190  m_elems[i]->SetSubType(l_subtype);
1191  if (++l_subtype >= 3)
1192  l_subtype = 0;
1193  }
1194  }
1195  // Count up the ponds and store them now we are finished with polygon handling.
1196  CreatePondList();
1197 
1198  cout << "Initiating farm management" << endl;
1199  m_FarmManager->InitiateManagement();
1200  g_pest = new Pesticide(m_land, this);
1201  m_toxShouldSpray = false; // Flag for special pesticide tests
1202  if (cfg_pesticidemapon.value()) m_PesticideMap = new PesticideMap(cfg_pesticidemapstartyear.value(), cfg_pesticidemapnoyears.value(), cfg_pesticidemapcellsize.value(),this, m_land,cfg_pesticidemaptype.value());
1203  g_date->Reset();
1204 
1205  /*
1206  if ( g_farm_test_crop.value() ) {
1207  TestCropManagement();
1208  exit( 0 );
1209  }
1210  */
1211 
1212  // Set up treatment flags
1213  // Reset internal state for the LE loop generator.
1214  // Compulsory!
1215  SupplyLEReset();
1216  // Get number of *all* landscape elements.
1217  int l_count = SupplyLECount();
1218 
1219  // Now loop through then.
1220  for (int i = 0; i < l_count; i++) {
1221  // Fetch next LE by its polygon reference number. Alternative
1222  // loop mechanism: This will return -1 at end-of-loop.
1223  int a_poly = SupplyLENext();
1224 
1225  // Skip uninteresting polygons by type, ownership,
1226  // phase of the moon, whatever.
1227  // if ( these_are_not_the_droids_we_are_looking_for( a_poly )) {
1228  if (SupplyElementType(a_poly) != tole_Field)
1229  continue;
1230 
1231  // Example: Set x% of them to ignore insecticide of all types.
1232  if (random(100) < l_map_no_pesticide_fields.value()) {
1233  // Get current signal mask for polygon.
1234  LE_Signal l_signal = SupplyLESignal(a_poly);
1235  // Logical OR in/AND out the signals you are interested in.
1236  // The current signals are at the top of elements.h
1237  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE | LE_SIG_NO_FUNGICIDE | LE_SIG_NO_GROWTH_REG;
1238  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE;
1239  // Write the mask back out to the polygon.
1240  SetLESignal(a_poly, l_signal);
1241  }
1242  }
1243 
1244  l_vegtype_areas = (double *)malloc(sizeof(double) * (tov_Undefined + 1));
1245 
1246  if (l_vegtype_areas == NULL) {
1247  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): Out of memory!", "");
1248  exit(1);
1249  }
1250  FILE * outf;
1251  if (cfg_dumpvegjan.value()) {
1252  outf = fopen(cfg_dumpvegjanfile.value(), "w");
1253  if (!outf) {
1254  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjanfile.value());
1255  exit(1);
1256  }
1257  else
1258  fclose(outf);
1259  }
1260 
1261  if (cfg_dumpvegjune.value()) {
1262  outf = fopen(cfg_dumpvegjunefile.value(), "w");
1263  if (!outf) {
1264  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjunefile.value());
1265  exit(1);
1266  }
1267  else
1268  fclose(outf);
1269  }
1270 
1271 #ifdef __RECORDFARMEVENTS
1272  m_farmeventfile = new ofstream("FarmEvents.txt", ofstream::out);
1273 #endif
1274 
1275 
1276  // Dump veg information if necessary
1277  if (l_map_dump_veg_enable.value()) {
1278  FILE * f;
1279  f = fopen("VegDump.txt", "w");
1280  if (!f) {
1281  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): VegDump.txt could not be created", "");
1282  exit(1);
1283  }
1284  fprintf(f, "Year\tDay\tHeight\tBiomass\tGrazed\tDensity\tCover\tWeedBiomass\ttovNum\tInsectBiomass\tLATotal\tLAGreen\tDigestability\tGreenBiomass\tDeadBiomass\tGooseGrazing\tSpilledGrain\nn");
1285  fclose(f);
1286  }
1287  if (l_map_dump_event_enable.value()) {
1288  FILE * f;
1289  f = fopen("EventDump.txt", "w");
1290  if (!f) {
1291  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): EventDump.txt could not be created", "");
1292  exit(1);
1293  }
1294  fclose(f);
1295  }
1296 
1297  if (!cfg_OptimiseBedriftsmodelCrops.value()){
1298  m_FarmManager->FindNeighbours();
1299  }
1300 
1301  if (cfg_DumpFarmAreas.value()){
1302  m_FarmManager->DumpFarmAreas();
1303  }
1304 
1305  // If we are testing a pesticide then set the enum attribute
1307 
1309  if (cfg_rodenticide_enable.value())
1310  {
1311  m_RodenticideManager = new RodenticideManager("BaitLocations_input.txt", this);
1313  }
1314 
1315  // Run a year to remove any start up effects
1316  cout << "Running initial start-up year" << endl;
1317  for (unsigned int i = 0; i < 365; i++) Tick();
1318  //switch the rotation after running the hidden year (only for optimising farms), AM, 030713
1319  if (cfg_OptimisingFarms.value()) { m_FarmManager->Switch_rotation(); }
1320  // Write ASCII file:
1321  if (l_map_write_ascii.value()) {
1322  int x = l_map_ascii_utm_x.value();
1323  int y = l_map_ascii_utm_y.value();
1324  GISASCII_Output("AsciiLandscape.txt", x, y);
1325  }
1326 }

References LE_TypeClass::BackTranslateEleTypes(), cfg_AddBeetleBanks(), 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_G6A, cfg_G6B, cfg_G6C, cfg_G6D, cfg_G6E, cfg_G6F, cfg_G6G, cfg_G6H, cfg_HedgeSubtypeMaximum(), cfg_HedgeSubtypeMinimum(), cfg_MaxPondSize(), cfg_OptimiseBedriftsmodelCrops, cfg_OptimisingFarms, cfg_P1A, cfg_P1B, cfg_P1C, cfg_P1D, cfg_P1E, cfg_P1F, cfg_P1G, cfg_P1H, cfg_pesticidemapcellsize(), cfg_pesticidemapnoyears(), cfg_pesticidemapon(), cfg_pesticidemapstartyear(), cfg_pesticidemaptype(), cfg_pesticidetesttype(), cfg_rodenticide_enable(), cfg_WriteCurve, LE::DoCopy(), g_landscape_p, g_letype, g_nectarpollen, g_pest, g_SpeedyDivides, l_map_art_hedgebanks(), l_map_ascii_utm_x(), l_map_ascii_utm_y(), l_map_calc_openness(), l_map_consolidatepolys(), l_map_cropcurves_file(), l_map_dump_enable(), l_map_dump_event_enable(), l_map_dump_gfx_enable(), l_map_dump_gfx_file(), l_map_dump_map_file(), l_map_dump_poly_file(), l_map_dump_veg_enable(), l_map_map_file(), 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_weather_file(), l_map_write_ascii(), random(), LE::SetArea(), LE::SetOpenness(), LE::SetPoly(), LE::SetSoilType(), LE::SetUnsprayedMarginPolyRef(), LE_TypeClass::TranslateEleTypes(), version_date, version_major, version_minor, and version_revision.

Member Function Documentation

◆ AddBeetleBanks()

void Landscape::AddBeetleBanks ( TTypesOfLandscapeElement  a_tole)
protected

Beetle-bank addition - tests whether we can add a bank 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

2723  {
2731  int BBs=0;
2732  int tx1 = cfg_BeetleBankMinX.value();
2733  int tx2 = cfg_BeetleBankMaxX.value();
2734  int ty1 = cfg_BeetleBankMinY.value();
2735  int ty2 = cfg_BeetleBankMaxY.value();
2736  bool doit = false;
2737  unsigned sz=(unsigned) m_elems.size();
2738  for (unsigned i=0; i<sz; i++)
2739  {
2740  if (m_elems[ i ]->GetElementType() == tole_Field)
2741  {
2742  doit = false;
2743  int cx = m_elems[ i ]->GetCentroidX();
2744  int cy = m_elems[ i ]->GetCentroidY();
2745  if (!cfg_BeetleBankInvert.value())
2746  {
2747  if ((cx >= tx1) && (cy >= ty1) && (cx <= tx2) && (cy <= ty2))
2748  {
2749  doit = true;
2750  }
2751  }
2752  else if ((cx < tx1) || (cy < ty1) || (cx > tx2) || (cy > ty2))
2753  {
2754  doit = true;
2755  }
2756  if (doit)
2757  {
2758  if (random(100)<cfg_BeetleBankChance.value())
2759  {
2760  if (BeetleBankPossible( m_elems[ i ], a_tole) ) BBs++;
2761  }
2762  }
2763  }
2764  }
2765  char str[25];
2766  sprintf(str,"%d",BBs);
2767  g_msg->Warn( WARN_MSG, "Landscape::AddBeetleBanks(): BeetleBanks successfully added:", str );
2768 }

References cfg_BeetleBankChance(), cfg_BeetleBankInvert(), cfg_BeetleBankMaxX(), cfg_BeetleBankMaxY(), cfg_BeetleBankMinX(), cfg_BeetleBankMinY(), and random().

◆ AddGreenElement()

void Landscape::AddGreenElement ( LE a_green)
protected

◆ AxisLoop() [1/2]

void Landscape::AxisLoop ( int  a_poly,
APoint a_cor,
int  a_axis 
)
protected

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.

2898  {
2903  int ap1 = a_polyindex;
2904  while (ap1 == a_polyindex)
2905  {
2906  a_cor->m_x += m_x_add[a_axis];
2907  a_cor->m_y += m_y_add[a_axis];
2908  if (a_cor->m_x >= m_width - 1) { a_cor->m_x = m_width - 1; return; }
2909  if (a_cor->m_y >= m_height - 1) { a_cor->m_y = m_height - 1; return; }
2910  if (a_cor->m_x <= 0) { a_cor->m_x = 0; return; }
2911  if (a_cor->m_y <= 0) { a_cor->m_y = 0; return; }
2912  ap1 = m_land->Get(a_cor->m_x, a_cor->m_y); // NB this returns the m_elemens index not the polyref (ChangeMapMapping has been called by here)
2913  }
2914 }

References APoint::m_x, and APoint::m_y.

◆ AxisLoop() [2/2]

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

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.

2938  {
2943  int ap1 = a_polyindex;
2944  while (ap1 == a_polyindex)
2945  {
2946  *(a_x) += m_x_add[a_axis];
2947  *(a_y) += m_y_add[a_axis];
2948  // Before we try to get a polyindex from the map, check we are still on the world
2949  if (*(a_x) < 0)
2950  {
2951  return;
2952  }
2953  if (*(a_y) < 0)
2954  {
2955  return;
2956  }
2957  if (*(a_x) >= m_width)
2958  {
2959  return;
2960  }
2961  if (*(a_y) >= m_height)
2962  {
2963  return;
2964  }
2965  // OK still in the map, get the polyindex
2966  ap1 = m_land->Get((*a_x), (*a_y)); // NB this returns the m_elemens index not the polyref (ChangeMapMapping has been called by here)
2967  }
2968 }

◆ AxisLoopLtd()

void Landscape::AxisLoopLtd ( int  a_poly,
APoint a_cor,
int  a_axis,
int  a_limit 
)
protected

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.

2917  {
2922  int ap1 = a_polyindex;
2923  int count = 0;
2924  while (ap1 == a_polyindex && count<a_limit)
2925  {
2926  a_cor->m_x += m_x_add[a_axis];
2927  a_cor->m_y += m_y_add[a_axis];
2928  if (a_cor->m_x >= m_width - 1) { a_cor->m_x = m_width - 1; return; }
2929  if (a_cor->m_y >= m_height - 1) { a_cor->m_y = m_height - 1; return; }
2930  if (a_cor->m_x <= 0) { a_cor->m_x = 0; return; }
2931  if (a_cor->m_y <= 0) { a_cor->m_y = 0; return; }
2932  ap1 = m_land->Get(a_cor->m_x, a_cor->m_y); // NB this returns the m_elemens index not the polyref (ChangeMapMapping has been called by here)
2933  count++;
2934  }
2935 }

References APoint::m_x, and APoint::m_y.

◆ BackTranslateEleTypes()

int Landscape::BackTranslateEleTypes ( TTypesOfLandscapeElement  EleReference)
inline
1663 {
1664  return g_letype->BackTranslateEleTypes( EleReference );
1665 }

References LE_TypeClass::BackTranslateEleTypes(), and g_letype.

◆ BackTranslateVegTypes()

int Landscape::BackTranslateVegTypes ( TTypesOfVegetation  VegReference)
inline
1670 {
1671  return g_letype->BackTranslateVegTypes( VegReference );
1672 }

References LE_TypeClass::BackTranslateVegTypes(), and g_letype.

◆ BeetleBankAdd()

void Landscape::BeetleBankAdd ( int  x,
int  y,
int  angle,
int  length,
LE a_field,
TTypesOfLandscapeElement  a_tole 
)
protected
2971  {
2972  // Need to get a new number
2974  // Make the new landscape element
2975  LE * BeetleBank;
2976  switch (a_tole)
2977  {
2978  case tole_MownGrass:
2979  BeetleBank = NewElement( tole_MownGrass );
2980  BeetleBank->SetALMaSSEleType( g_letype->BackTranslateEleTypes( tole_MownGrass ) );
2981  break;
2982  case tole_PermanentSetaside:
2983  BeetleBank = NewElement( tole_PermanentSetaside );
2984  BeetleBank->SetALMaSSEleType( g_letype->BackTranslateEleTypes( tole_PermanentSetaside ) );
2985  break;
2986  case tole_BeetleBank:
2987  default:
2988  BeetleBank = NewElement( tole_BeetleBank );
2989  BeetleBank->SetALMaSSEleType( g_letype->BackTranslateEleTypes( tole_BeetleBank ) );
2990  }
2991  BeetleBank->SetVegPatchy(true);
2993  m_elems.resize( m_elems.size() + 1 );
2994  m_elems[ m_elems.size() - 1 ] = BeetleBank;
2996  // write lengthx12m to the map at alignment angle
2997  int area=0;
2998  int angle2=0;
2999  int width=cfg_BeetleBankWidth.value();
3000  if (a_angle==0) angle2=2;
3001  int start=(int)(a_length*0.1);
3002  for (int i=start; i<a_length; i++) {
3003  for (int w=0-width; w<width; w++) {
3004  int tx=w*m_x_add[angle2];
3005  int ty=w*m_y_add[angle2];
3006  m_land->Put( tx+a_x+i*m_x_add[a_angle], ty+a_y+i*m_y_add[a_angle], (int) m_elems.size() - 1 );
3007  m_land->Put( tx+a_x-i*m_x_add[a_angle], ty+a_y-i*m_y_add[a_angle], (int) m_elems.size() - 1 );
3008  area+=2;
3009  a_field->AddArea( -2.0 );
3010 
3011  }
3012  }
3013  BeetleBank->SetArea( double(area) );
3014  BeetleBank->SetValidXY( a_x+start*m_x_add[a_angle], a_y+start*m_y_add[a_angle] );
3015  BeetleBank->SetMapValid(true);
3016 
3017 }

References LE::AddArea(), LE_TypeClass::BackTranslateEleTypes(), cfg_BeetleBankWidth(), g_letype, m_polymapping, LE::SetArea(), LE::SetMapValid(), LE::SetPoly(), LE::SetValidXY(), and VegElement::SetVegPatchy().

◆ BeetleBankPossible()

bool Landscape::BeetleBankPossible ( LE a_field,
TTypesOfLandscapeElement  a_tole 
)
protected

Beetle bank placement rules are:
No bank if the total bank area is going to be >=5% of the field area
No bank if the field is < 1Ha
No bank if the breadth of the field is < 100m

2772  {
2779  int farea=(int)a_field->GetArea();
2780  if (farea<10000) return false;
2781  int cx=a_field->GetCentroidX();
2782  int cy=a_field->GetCentroidY();
2783  // The centroid is the only estimate we have (and it at least should be in the field).
2784  // So start here and find the centre
2785  if (!FindFieldCenter(a_field, &cx, &cy)) return false;
2786  // now get the alignment
2787  int length=0;
2788  int alignment=FindLongestAxis(&cx, &cy, &length);
2789  // reduce length by 20%
2790  length=int(length*0.8);
2791  int area=2*length*cfg_BeetleBankWidth.value(); // 12m wide fixed size
2792  if (area>(farea*cfg_BeetleBankMaxArea.value())) return false;
2793  // Must be small engough so lets draw it
2794  BeetleBankAdd(cx, cy, alignment, length , a_field, a_tole);
2795  return true;
2796 }

References cfg_BeetleBankMaxArea(), cfg_BeetleBankWidth(), and LE::GetArea().

◆ BorderAdd()

void Landscape::BorderAdd ( LE a_field,
TTypesOfLandscapeElement  a_type 
)
protected
2347  {
2348  int x = a_field->GetValidX();
2349  int y = a_field->GetValidY();
2350  if ( ( x == -1 ) || ( y == -1 ) ) {
2351  g_msg->Warn( WARN_BUG, "Landscape::BorderAdd(): Uninitialized border coordinate!", "" );
2352  exit( 1 );
2353  }
2354  LE * border = NewElement(a_type);
2355  a_field->SetBorder( border );
2357  m_elems.resize( m_elems.size() + 1 );
2358  m_elems[ m_elems.size() - 1 ] = border;
2359  border->SetPoly( hb_first_free_poly_num++ );
2360  border->SetArea( 0.0 );
2361  BorderScan(a_field, g_map_le_borderwidth.value());
2362 }

References LE::GetValidX(), LE::GetValidY(), m_polymapping, LE::SetArea(), LE::SetBorder(), and LE::SetPoly().

◆ BorderNeed()

bool Landscape::BorderNeed ( TTypesOfLandscapeElement  a_letype)
protected
4529  {
4530  static char error_num[20];
4531  bool AddBorder = false;
4532  switch (a_letype) {
4533  // No border is needed toward these neighbouring element types.
4534  case tole_Hedges:
4535  case tole_HedgeBank:
4536  case tole_BeetleBank:
4537  case tole_RoadsideVerge:
4538  case tole_Marsh:
4539  case tole_RiversidePlants:
4540  case tole_UnsprayedFieldMargin:
4541  case tole_OrchardBand:
4542  case tole_MownGrass:
4543  case tole_WaterBufferZone:
4544  break;
4545 
4546  case tole_IndividualTree:
4547  case tole_PlantNursery:
4548  case tole_Vildtager:
4549  case tole_WindTurbine:
4550  case tole_WoodyEnergyCrop:
4551  case tole_WoodlandMargin:
4552  case tole_Pylon:
4553  case tole_NaturalGrassDry:
4554  case tole_Railway:
4555  case tole_FieldBoundary:
4556  case tole_Scrub:
4557  case tole_Field:
4558  case tole_PermanentSetaside:
4559  case tole_PermPasture:
4560  case tole_PermPastureTussocky:
4561  case tole_PermPastureLowYield:
4562  case tole_PitDisused:
4563  case tole_RiversideTrees:
4564  case tole_DeciduousForest:
4565  case tole_MixedForest:
4566  case tole_YoungForest:
4567  case tole_ConiferousForest:
4568  case tole_StoneWall:
4569  case tole_Fence:
4570  case tole_Garden:
4571  case tole_Track:
4572  case tole_SmallRoad:
4573  case tole_LargeRoad:
4574  case tole_Building:
4575  case tole_ActivePit:
4576  case tole_Pond:
4577  case tole_FishFarm:
4578  case tole_Freshwater:
4579  case tole_River:
4580  case tole_Saltwater:
4581  case tole_Coast:
4582  case tole_BareRock:
4583  case tole_Heath:
4584  case tole_Orchard:
4585  case tole_AmenityGrass:
4586  case tole_Parkland:
4587  case tole_UrbanNoVeg:
4588  case tole_UrbanVeg:
4589  case tole_UrbanPark:
4590  case tole_BuiltUpWithParkland:
4591  case tole_SandDune:
4592  case tole_Copse:
4593  case tole_NaturalGrassWet:
4594  case tole_RoadsideSlope:
4595  case tole_MetalledPath:
4596  case tole_Carpark:
4597  case tole_Churchyard:
4598  case tole_Saltmarsh:
4599  case tole_Stream:
4600  case tole_HeritageSite:
4601  AddBorder = true;
4602  break;
4603 
4604  default:
4605  sprintf(error_num, "%d", a_letype);
4606  g_msg->Warn(WARN_BUG, "Landscape::BorderNeed(): Unknown element type:", error_num);
4607  exit(1);
4608  }
4609  return AddBorder;
4610 }

◆ BorderRemoval()

void Landscape::BorderRemoval ( void  )
protected
2271  {
2272  // This does not need to be efficient, just do the job
2273  for (int x=1; x<(m_width-1); x++)
2274  for (int y=1; y<(m_height-1); y++)
2275  {
2276  TTypesOfLandscapeElement tole = SupplyElementType(x,y);
2277  if ((tole==tole_FieldBoundary) || (tole==tole_HedgeBank) || (tole==tole_Hedges))
2278  {
2279  if ( SupplyElementType(x-1,y-1) == tole_Field)
2280  {
2281  // Set the x,y location to be this field
2282  int fieldindex = SupplyPolyRefIndex(x-1,y-1);
2283  m_land->Put( x, y, fieldindex );
2284 
2285  }
2286  else
2287  if ( SupplyElementType(x-1,y) == tole_Field)
2288  {
2289  // Set the x,y location to be this field
2290  int fieldindex = SupplyPolyRefIndex(x-1,y);
2291  m_land->Put( x, y, fieldindex );
2292 
2293  }
2294  else
2295  if ( SupplyElementType(x-1,y+1) == tole_Field)
2296  {
2297  // Set the x,y location to be this field
2298  int fieldindex = SupplyPolyRefIndex(x-1,y+1);
2299  m_land->Put( x, y, fieldindex );
2300 
2301  }
2302  else
2303  if ( SupplyElementType(x,y-1) == tole_Field)
2304  {
2305  // Set the x,y location to be this field
2306  int fieldindex = SupplyPolyRefIndex(x,y-1);
2307  m_land->Put( x, y, fieldindex );
2308 
2309  }
2310  else
2311  if ( SupplyElementType(x,y+1) == tole_Field)
2312  {
2313  // Set the x,y location to be this field
2314  int fieldindex = SupplyPolyRefIndex(x,y+1);
2315  m_land->Put( x, y, fieldindex );
2316 
2317  }
2318  else
2319  if ( SupplyElementType(x+1,y-1) == tole_Field)
2320  {
2321  // Set the x,y location to be this field
2322  int fieldindex = SupplyPolyRefIndex(x+1,y-1);
2323  m_land->Put( x, y, fieldindex );
2324 
2325  }
2326  else
2327  if ( SupplyElementType(x+1,y) == tole_Field)
2328  {
2329  // Set the x,y location to be this field
2330  int fieldindex = SupplyPolyRefIndex(x+1,y);
2331  m_land->Put( x, y, fieldindex );
2332 
2333  }
2334  else
2335  if ( SupplyElementType(x+1,y+1) == tole_Field)
2336  {
2337  // Set the x,y location to be this field
2338  int fieldindex = SupplyPolyRefIndex(x+1,y+1);
2339  m_land->Put( x, y, fieldindex );
2340 
2341  }
2342  }
2343  }
2344 }

◆ BorderScan()

void Landscape::BorderScan ( LE a_field,
int  a_width 
)
protected

Requires centroid calculation before calling this method. Centroids must be inside the polygon and valid.

Loop through this procedure the width of the margin times. Each time a dummy margin is added using polyref=-99 and all locations this is done are remembered. Then later all positions covered by -99 are replaced with the real polygon index.

2366 {
2370  LE * border = a_field->GetBorder(); // border is the a border object
2371  int fieldpoly = a_field->GetPoly(); // fieldpoly is the polygon number
2372  int borderpoly = border->GetPoly(); // borderpoly is the polygon number
2373  int borderindex = m_polymapping[ borderpoly ]; // borderindex is the elems index for the border
2374  int fieldindex = m_polymapping[ fieldpoly ]; // fieldindex is the elems index
2375  int test = m_land->Get(a_field->GetCentroidX(), a_field->GetCentroidY());
2376  if (test != fieldindex)
2377  {
2378  g_msg->Warn("Landscape::BorderScan - Border Scan centroid does not return correct polygon index. Index :", fieldindex);
2379  g_msg->Warn(" Returned ", test);
2380  exit(0);
2381  }
2382  int notforever = 50000;
2383  vector<APoint> listoflocs;
2388  for (int wid = 0; wid < a_width; wid++)
2389  {
2390  notforever = 50000;
2391  // These two will be modified through pointer operations in BorderStep().
2392  APoint coord(a_field->GetCentroidX(), a_field->GetCentroidY());
2393  // Find the first edge cell
2394  AxisLoop(fieldindex, &coord, random(8));
2395  while (--notforever > 0)
2396  {
2397  // Check if this position should be made into a border.
2398  if (BorderTest(fieldindex, -99, coord.m_x, coord.m_y))
2399  {
2400  // Add this pixel to the border element in the big map, but using a code for later replacement.
2401  m_land->Put(coord.m_x, coord.m_y, -99); // this puts the elems index into our map in memory
2402  listoflocs.push_back(coord);
2403  a_field->AddArea(-1.0);
2404  if (l_map_exit_on_zero_area.value() && (a_field->GetArea()<1))
2405  {
2406  char polynum[20];
2407  sprintf(polynum, "%d", a_field->GetPoly());
2408  g_msg->Warn(WARN_FILE, "Landscape::BorderScan(): Polygon reached zero area " "when adding border. Poly num: ", polynum);
2409  exit(1);
2410  }
2411  border->AddArea(1.0);
2412  border->SetMapValid(true);
2413  }
2414  // Step to next coordinate. Quit when done.
2415  if (!BorderStep(fieldindex, -99, &coord))
2416  {
2417  break;
2418  }
2419  }
2420  for (std::vector<APoint>::iterator it = listoflocs.begin(); it != listoflocs.end(); ++it)
2421  {
2422  m_land->Put((*it).m_x, (*it).m_y, borderindex);
2423  }
2424  listoflocs.clear();
2425  }
2426 }

References LE::AddArea(), LE::GetArea(), LE::GetBorder(), LE::GetPoly(), l_map_exit_on_zero_area(), m_polymapping, random(), and LE::SetMapValid().

◆ BorderStep() [1/2]

bool Landscape::BorderStep ( int  a_fieldpoly,
int  a_borderpoly,
APoint a_coord 
)
protected
2537  {
2538  int index;
2539  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2540  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2541  int width = m_land->MapWidth();
2542  int height = m_land->MapHeight();
2543  int i = 7, counter = 8;
2544  bool running = true;
2545  // First scan for another pixel that belongs to this field.
2546  while (running)
2547  {
2548  if (!((a_coord->m_x) + x_add[i] >= width) && !((a_coord->m_x) + x_add[i] < 0) && !((a_coord->m_y) + y_add[i] >= height) && !((a_coord->m_y) + y_add[i] < 0))
2549  {
2550  index = m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]);
2551  if (index == a_fieldindex)
2552  {
2553  // Found the first field pixel while scanning around always
2554  // in the same direction.
2555  running = false;
2556  }
2557  }
2558  if (--i < 0) {
2559  // Didn't find any of our pixels. We are in a blind alley. Exit
2560  // gracefully.
2561  return false; // Signal done scanning this field.
2562  }
2563  }
2564 
2565  // Now scan around from our present facing direction and find the border
2566  // (if any).
2567  while (--counter)
2568  {
2569  if (!((a_coord->m_x) + x_add[i] >= width) && !((a_coord->m_x) + x_add[i] < 0) && !((a_coord->m_y) + y_add[i] >= height) && !((a_coord->m_y) + y_add[i] < 0))
2570  {
2571  index = m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]);
2572  if (index == a_fieldindex)
2573  {
2574  if (--i < 0) i = 7;
2575  continue;
2576  }
2577  }
2578 
2579  // Aha! This pixel is not ours. Step one step in the
2580  // opposite(!) direction. If that pixel is ours, then
2581  // modify hotspot coordinates and exit.
2582  if (++i > 7) i = 0;
2583  if (!((a_coord->m_x) + x_add[i] + 1 > width) && !((a_coord->m_x) + x_add[i] < 0) && !((a_coord->m_y) + y_add[i] + 1 > height) &&
2584  !((a_coord->m_y) + y_add[i] < 0) && (m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]) == a_fieldindex))
2585  {
2586  (a_coord->m_x) += x_add[i];
2587  (a_coord->m_y) += y_add[i];
2588  return true;
2589  }
2590  }
2591  return false;
2592 }

References APoint::m_x, and APoint::m_y.

◆ BorderStep() [2/2]

bool Landscape::BorderStep ( int  a_fieldpoly,
int  a_borderpoly,
int a_x,
int a_y 
)
protected
2479  {
2480  int index;
2481  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2482  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2483  int width = m_land->MapWidth();
2484  int height = m_land->MapHeight();
2485  int i = 7, counter = 8;
2486  bool running = true;
2487  // First scan for another pixel that belongs to this field.
2488  while (running)
2489  {
2490  if (!((*a_x) + x_add[i] >= width) && !((*a_x) + x_add[i] < 0) && !((*a_y) + y_add[i] >= height) && !((*a_y) + y_add[i] < 0))
2491  {
2492  index = m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]);
2493  if (index == a_fieldindex)
2494  {
2495  // Found the first field pixel while scanning around always
2496  // in the same direction.
2497  running = false;
2498  }
2499  }
2500  if (--i < 0) {
2501  // Didn't find any of our pixels. We are in a blind alley. Exit
2502  // gracefully.
2503  return false; // Signal done scanning this field.
2504  }
2505  }
2506 
2507  // Now scan around from our present facing direction and find the border
2508  // (if any).
2509  while (--counter)
2510  {
2511  if (!((*a_x) + x_add[i] >= width) && !((*a_x) + x_add[i] < 0) && !((*a_y) + y_add[i] >= height) && !((*a_y) + y_add[i] < 0))
2512  {
2513  index = m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]);
2514  if (index == a_fieldindex)
2515  {
2516  if (--i < 0) i = 7;
2517  continue;
2518  }
2519  }
2520 
2521  // Aha! This pixel is not ours. Step one step in the
2522  // opposite(!) direction. If that pixel is ours, then
2523  // modify hotspot coordinates and exit.
2524  if (++i > 7) i = 0;
2525  if (!((*a_x) + x_add[i] + 1 > width) && !((*a_x) + x_add[i] < 0) && !((*a_y) + y_add[i] + 1 > height) &&
2526  !((*a_y) + y_add[i] < 0) && (m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]) == a_fieldindex))
2527  {
2528  (*a_x) += x_add[i];
2529  (*a_y) += y_add[i];
2530  return true;
2531  }
2532  }
2533  return false;
2534 }

◆ BorderTest()

bool Landscape::BorderTest ( int  a_fieldpoly,
int  a_borderpoly,
int  a_x,
int  a_y 
)
protected
2453 {
2454  int index;
2455  int x_add[ 8 ] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2456  int y_add[ 8 ] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2457  int width = m_land->MapWidth();
2458  int height = m_land->MapHeight();
2459  // Scan anti-clockwise from center pixel coordinate.
2460  for ( unsigned int i = 0; i < 8; i++ ) {
2461  if ( ( a_x + x_add[ i ] >= width ) || ( a_x + x_add[ i ] < 0 ) || ( a_y + y_add[ i ] >= height )
2462  || ( a_y + y_add[ i ] < 0 ) ) {
2463  return true;
2464  }
2465  //continue;
2466  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2467  if ( ( index != a_fieldindex ) && ( index != a_borderindex ) )
2468  {
2469  return true;
2470  // Test removed 1/07/2014 CJT
2471  //if ( BorderNeed( m_elems[ index ]->GetElementType() ) ) return true;
2472  //else return false;
2473  }
2474  }
2475  return false;
2476 }

◆ BuildingDesignationCalc()

void Landscape::BuildingDesignationCalc ( )

used to calculate whether a building is 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.

3288 {
3293  cout << "In BuildingDesignationCalc" << endl;
3294  for (int p = 0; p< (int)m_elems.size(); p++)
3295  {
3296  TTypesOfLandscapeElement tole = m_elems[p]->GetElementType();
3297  if ( tole == tole_Building)
3298  {
3299  int cx = m_elems[p]->GetCentroidX();
3300  int cy = m_elems[p]->GetCentroidY();
3301  int near = 0;
3302  for (int j = 0; j< (int)m_elems.size(); j++)
3303  {
3304  if (m_elems[j]->GetElementType() == tole_Building)
3305  {
3306  int nx = m_elems[j]->GetCentroidX();
3307  int ny = m_elems[j]->GetCentroidY();
3308  int dx =abs(cx-nx);
3309  int dy =abs(cy-ny);
3310  if ((dx < cfg_mintownbuildingdistance.value()) && (dy < cfg_mintownbuildingdistance.value())) near++;
3311  if (near > cfg_mintownbuildingdistance.value()) break;
3312  }
3313  }
3314  if (near <= cfg_mintownbuildingnumber.value()) m_elems[p]->SetCountryDesignation(1); // Not enough buildings close by, so it is a country building
3315  else m_elems[p]->SetCountryDesignation(0);
3316  }
3317  else if (tole == tole_YoungForest)
3318  {
3319  m_elems[p]->SetCountryDesignation(2);
3320  }
3321  else if ((tole == tole_DeciduousForest) || ( tole == tole_MixedForest) || ( tole == tole_ConiferousForest ) ) m_elems[p]->SetCountryDesignation(3);
3322 
3323  }
3324 }

References cfg_mintownbuildingdistance(), and cfg_mintownbuildingnumber().

◆ CalculateCentroids()

void Landscape::CalculateCentroids ( void  )

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.

3041 {
3047  cout << "In Centroid Calculations" << endl;
3048  // For each polygon
3049  for (int p = 0; p< (int)m_elems.size(); p++)
3050  {
3051  // Calcuate the actual centre
3052  int x1 = m_elems[p]->GetMinX();
3053  int y1 = m_elems[p]->GetMinY();
3054  int x2 = m_elems[p]->GetMaxX();
3055  int y2 = m_elems[p]->GetMaxY();
3056 
3057  int midx = (x1 + x2) / 2;
3058  int midy = (y1 + y2) / 2;
3059  // Now from midx & midy we move outwards in concentric circles until we find a location that matches our polyref.
3060  int polyindex = p; // Change mapmapping has been called by now, so the map contains m_elems indices.
3061  CentroidSpiralOut(polyindex, midx, midy);
3062  // 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,
3063  // 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
3064  // from this point
3065  int l;
3066  FindLongestAxis(&midx, &midy, &l);
3067  m_elems[p]->SetCentroid(midx, midy);
3068  }
3070 }

◆ 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

323 {
327  cout << "In CalculateOpenness" << endl;
328 
329  for (unsigned int i = 0; i < m_elems.size(); i++)
330  {
331  TTypesOfLandscapeElement tole = m_elems[i]->GetElementType();
332  switch (tole)
333  {
334  case tole_Field:
335  case tole_Marsh:
336  case tole_Scrub:
337  case tole_PermPastureLowYield:
338  case tole_PermPastureTussocky:
339  case tole_PermanentSetaside:
340  case tole_PermPasture:
341  case tole_NaturalGrassDry:
342  case tole_NaturalGrassWet:
343  if (a_realcalc)
344  {
345  cout << i << " ";
346  m_elems[i]->SetOpenness(CalulateFieldOpennessAllCells(i));
347  }
348  else m_elems[i]->SetOpenness(0);
349  break;
350  default:
351  m_elems[i]->SetOpenness(0);
352  break;
353  }
354  }
355  if (a_realcalc) cout << endl;
356 }

◆ CalulateFieldOpennessAllCells()

int Landscape::CalulateFieldOpennessAllCells ( 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.

402 {
403  int dline;
404  int d0 = 0;
405  int minX = m_elems[a_pref]->GetMinX();
406  int minY = m_elems[a_pref]->GetMinY();
407  int maxX = m_elems[a_pref]->GetMaxX();
408  int maxY = m_elems[a_pref]->GetMaxY();
409  for (int ax = minX; ax <= maxX; ax+=10)
410  {
411  for (int ay = minY; ay <= maxY; ay+=10)
412  {
413  dline = m_maxextent; // this is the width of the landscape and will always be at least as big as the biggest return value possible
414  // Get a possible point for this field
415  int cx = ax;
416  int cy = ay;
417  if (m_land->Get(ax, ay) == a_pref)
418  {
423  double offsetx = -1;
424  double offsety = -1;
425  double dx = 1.0 / 45.0;
426  double dy = 0.0;
427  for (int deg = 0; deg<90; deg++)
428  {
430  int d1 = LineHighTest(cx, cy, offsetx, offsety);
431  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
432  int d = d1;
433  if (d1 > d2) d = d2;
434  if (dline > d) dline = d; // get the minimum
435  offsetx = offsetx + dx;
436  offsety = offsety + dy;
437  }
438  offsetx = 1;
439  offsety = 1;
440  dy = 0 - dx;
441  dx = 0;
442  for (int deg = 0; deg<90; deg++)
443  {
445  int d1 = LineHighTest(cx, cy, offsetx, offsety);
446  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
447  int d = d1;
448  if (d1 > d2) d = d2;
449  if (dline > d) dline = d;
450  offsetx = offsetx + dx;
451  offsety = offsety + dy;
452  }
453  if (dline > d0) d0 = dline; // Get the maximum. Here we might also want to do something like create statistics from the range of dline
454  }
455  }
456  }
457  return d0;
458 }

◆ CalulateFieldOpennessCentroid()

int Landscape::CalulateFieldOpennessCentroid ( 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.

360 {
361  // Get the centre point for this field
362  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
363  int cx = m_elems[a_pref]->GetCentroidX();
364  int cy = m_elems[a_pref]->GetCentroidY();
365 
367  double offsetx = -1;
368  double offsety = -1;
369  double dx = 1.0 / 45.0;
370  double dy = 0.0;
371  for (int deg = 0; deg<90; deg++)
372  {
374  int d1 = LineHighTest(cx, cy, offsetx, offsety);
375  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
376  int d = d1;
377  if (d1 > d2) d = d2;
378  if (d0 > d) d0 = d;
379  offsetx = offsetx + dx;
380  offsety = offsety + dy;
381  }
382  offsetx = 1;
383  offsety = 1;
384  dy = 0 - dx;
385  dx = 0;
386  for (int deg = 0; deg<90; deg++)
387  {
389  int d1 = LineHighTest(cx, cy, offsetx, offsety);
390  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
391  int d = d1;
392  if (d1 > d2) d = d2;
393  if (d0 > d) d0 = d;
394  offsetx = offsetx + dx;
395  offsety = offsety + dy;
396  }
397  return d0;
398 }

◆ CentroidSpiralOut()

void Landscape::CentroidSpiralOut ( int  a_polyref,
int a_x,
int a_y 
)
3074 {
3075  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref) return; // Found it so return
3076  // Otherwise its not found so we need to start to spiral out
3077  int loop = 1;
3078  int sx = a_x;
3079  int sy = a_y;
3080  do {
3081  a_y = sy - loop;
3082  for (int i = 0 - loop; i <= loop; i++)
3083  {
3084  a_x = sx + i;
3085  CorrectCoords(a_x, a_y);
3086  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3087  return; // Found it so return
3088  }
3089  a_y = sy + loop;
3090  for (int i = 0 - loop; i <= loop; i++)
3091  {
3092  a_x = sx + i;
3093  CorrectCoords(a_x, a_y);
3094  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3095  return; // Found it so return
3096  }
3097  a_x = sx + loop;
3098  for (int j = 0 - (loop - 1); j< loop; j++)
3099  {
3100  a_y = sy + j;
3101  CorrectCoords(a_x, a_y);
3102  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3103  return; // Found it so return
3104  }
3105  a_x = sx - loop;
3106  for (int j = 0 - (loop - 1); j< loop; j++)
3107  {
3108  a_y = sy + j;
3109  CorrectCoords(a_x, a_y);
3110  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3111  return; // Found it so return
3112  }
3113  loop++;
3114  } while (loop<m_minmaxextent); // This stopping rule should hopefully not be needed, it is set very high.
3115  g_msg->Warn("Landscape::CentroidSpiralOut: Failure of centroid main loop. Looking for polygon index ",a_polyref);
3116  a_x = m_elems[a_polyref]->GetMinX();
3117  a_y = m_elems[a_polyref]->GetMinY();
3118 }

◆ ChangeMapMapping()

void Landscape::ChangeMapMapping ( void  )
protected

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.

2130  {
2136  cout << "In Change Map Mapping" << endl;
2137  int mapwidth = m_land->MapWidth();
2138  int mapheight = m_land->MapHeight();
2139  int pest_map_width = mapwidth >> PEST_GRIDSIZE_POW2;
2140  if ( mapwidth & ( PEST_GRIDSIZE - 1 ) ) pest_map_width++;
2141  int oldindex = -1;
2142  for ( int x = 0; x < mapwidth; x++ )
2143  {
2144  for ( int y = 0; y < mapheight; y++ )
2145  {
2146  int polynum = m_land->Get( x, y ); // the polyref e.g. = 1, m_polymapping[ polynum ] = 0
2147  m_elems[ m_polymapping[ polynum ]]->SetMapIndex( m_polymapping[ polynum ] ); // Here we set index in the map to the index in elements, i.e. 0
2148  m_elems[ m_polymapping[ polynum ]]->SetMapValid( true );
2149  // Do the translation.
2150  m_land->Put( x, y, m_polymapping[ polynum ] ); // and now we write this to the map, i.e. 0
2151  // This coordinate is now valid. Throw these coordinates into
2152  // the associated landscape element.
2153  int index = m_polymapping[ SupplyPolyRef( x, y ) ];
2154  if ( index != oldindex )
2155  {
2156  m_elems[ index ]->SetValidXY( x, y );
2157  int l_x = x >> PEST_GRIDSIZE_POW2;
2158  int l_y = y >> PEST_GRIDSIZE_POW2;
2159  int pref = l_y * pest_map_width + l_x;
2160  m_elems[ index ]->SetPesticideCell( pref );
2161  oldindex = index;
2162  }
2163  }
2164  }
2165  RebuildPolyMapping();
2166 /*
2167 // Check that all of the polygons are mentioned in the map.
2168  if ( l_map_check_polygon_xref.value() )
2169  {
2170  for ( unsigned int i = 0; i < m_elems.size(); i++ )
2171  {
2172  if ( !m_elems[ i ]->GetMapValid() ) {
2173  char poly[ 20 ];
2174  sprintf( poly, "%d", m_elems[ i ]->GetPoly() );
2175  g_msg->Warn( WARN_FILE, "Landscape::ChangeMapMapping(): ""Polygon number referenced but not in map file: ", poly );
2176  exit( 1 );
2177  }
2178  }
2179  }
2180 */
2181 }

References m_polymapping.

◆ CheckForPesticideRecord()

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

Check if needed and record pesticide application.

670 {
671  if (cfg_pesticidemapon.value())
672  {
673  if (cfg_pesticidemaptype.value() == false)
674  {
675  m_PesticideMap->Spray(a_field, a_pcide);
676  }
677  else
678  {
679  if (a_pcide == testpesticide) m_PesticideMap->Spray(a_field, insecticide);
680  }
681  }
682 }

References cfg_pesticidemapon(), cfg_pesticidemaptype(), insecticide, and testpesticide.

◆ CIPELandscapeMaker()

bool Landscape::CIPELandscapeMaker ( )
protected

◆ ConsolidatePolys()

void Landscape::ConsolidatePolys ( void  )
protected

Runs through the map checking each cell for polygon type. If it is in our replace list then it re-written as the first instance of that polygon type encountered. All subsequent instances of that type are then deleted.
replaceList contains the types of all tole types with no behaviour that can be consolidated. This list needs to be kept up-to-date.

1330 {
1336  const int TypesToReplace = 16;
1337  TTypesOfLandscapeElement replaceList[TypesToReplace] = {
1338  tole_River,
1339  tole_RiversidePlants,
1340  tole_RiversideTrees,
1341  tole_StoneWall,
1342  tole_BareRock,
1343  tole_BuiltUpWithParkland,
1344  tole_Carpark,
1345  tole_Churchyard,
1346  tole_Coast,
1347  tole_Garden,
1348  tole_HeritageSite,
1349  tole_IndividualTree,
1350  tole_PlantNursery,
1351  tole_Saltwater,
1352  tole_SandDune,
1353  tole_UrbanNoVeg
1354  };
1355  int foundList[TypesToReplace];
1356  cout << "Consolidating polygons with no special behaviour" << endl;
1357  for (int i = 0; i < TypesToReplace; i++) foundList[i] = -1;
1358  int mapwidth = m_land->MapWidth();
1359  int mapheight = m_land->MapHeight();
1360  for (int x = 0; x < mapwidth; x++)
1361  {
1362  for (int y = 0; y < mapheight; y++)
1363  {
1364  int ele = m_land->Get(x, y);
1365  TTypesOfLandscapeElement tole = m_elems[m_polymapping[ele]]->GetElementType();
1366  for (int t = 0; t < TypesToReplace; t++)
1367  {
1368  if (tole == replaceList[t])
1369  {
1370  // Must do something with this cell
1371  if (foundList[t] == -1) foundList[t] = ele;
1372  else
1373  {
1374  // Need to replace this cell
1375  m_land->Put(x, y, foundList[t]);
1376  }
1377  }
1378  }
1379  }
1380  }
1381  // At this point there should be many polygons that are not in the map. So we need to run the valid test.
1382  g_msg->Warn(WARN_FILE, "Landscape::ConsolidatePolys() - ""Consolidate map dump.", "");
1383 }

References m_polymapping.

◆ CorrectCoords()

void Landscape::CorrectCoords ( int x,
int y 
)
inline

Function to prevent wrap around errors with co-ordinates using x/y pair.

m_width10 & m_height10 are used to avoid problems with co-ordinate values that are very large. Problems will only occur if coords passed are >10x the world width or height.

1536 {
1540  x = (m_width10 + x) % m_width;
1541  y = (m_height10 + y) % m_height;
1542 }

References m_height, m_height10, m_width, and m_width10.

◆ CorrectCoordsPointNoWrap()

void Landscape::CorrectCoordsPointNoWrap ( APoint a_pt)
inline

Function to prevent wrap around errors with co-ordinates using a APoint.

This just cuts off extremes of coordinate values so that the point stays in landscape. Can't use a modulus or we get wrap around, and in this case we don't want that

1556 {
1560  if (a_pt.m_x >= m_width) a_pt.m_x = m_width - 1;
1561  if (a_pt.m_y >= m_height) a_pt.m_y = m_height - 1;
1562  if (a_pt.m_x < 0) a_pt.m_x = 0;
1563  if (a_pt.m_y < 0) a_pt.m_y = 0;
1564 }

References m_height, m_width, APoint::m_x, and APoint::m_y.

◆ CorrectCoordsPt()

APoint Landscape::CorrectCoordsPt ( int  x,
int  y 
)
inline

Function to prevent wrap around errors with co-ordinates using x/y pair.

m_width10 & m_height10 are used to avoid problems with co-ordinate values that are very large. Problems will only occur if coords passed are >10x the world width or height.

1545 {
1549  APoint pt;
1550  pt.m_x = (m_width10 + x) % m_width;
1551  pt.m_y = (m_height10 + y) % m_height;
1552  return pt;
1553 }

References m_height, m_height10, m_width, m_width10, APoint::m_x, and APoint::m_y.

◆ CorrectHeight()

int Landscape::CorrectHeight ( int  y)
inline
1574 {
1575  return (m_height10+y)%m_height;
1576 }

References m_height, and m_height10.

◆ CorrectWidth()

int Landscape::CorrectWidth ( int  x)
inline
1568 {
1569  return (m_width10+x)%m_width;
1570 }

References m_width, and m_width10.

◆ CountMapSquares()

void Landscape::CountMapSquares ( void  )
protected
2040  {
2041  int mapwidth = m_land->MapWidth();
2042  int mapheight = m_land->MapHeight();
2043  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
2044  m_elems[i]->SetArea(0);
2045  m_elems[ i ]->m_squares_in_map=0;
2046  }
2047 
2048  for ( int x = 0; x < mapwidth; x++ ) {
2049  for ( int y = 0; y < mapheight; y++ ) {
2050  int l_ele = m_land->Get( x, y );
2051  m_elems[ l_ele ]->m_squares_in_map++;
2052  }
2053  }
2054 }

◆ CreatePondList()

void Landscape::CreatePondList ( )
protected

Creates a list of pond polygon refs/indexes for easy look up.

Just creates an unordered list of polyref numbers and m_elems indices for all ponds. This is for easy look-up by e.g. newts

2595 {
2597  for (unsigned int i = 0; i < m_elems.size(); i++)
2598  {
2599  if (m_elems[i]->GetElementType() == tole_Pond) {
2600  m_PondIndexList.push_back(i);
2601  m_PondRefsList.push_back(m_elems[i]->GetPoly());
2602  }
2603  }
2604 }

◆ DegreesDump()

void Landscape::DegreesDump ( )
protected

Prints the sum of day degrees. See #FarmManager::daydegrees.

1687  {
1688 
1689  ofstream ofile ("Daydegrees.txt", ios::app);
1690  //print degrees
1691  ofile << m_FarmManager->GetDD();
1692  ofile << endl;
1693  ofile.close();
1694 }

◆ DumpAllSymbolsAndExit()

void Landscape::DumpAllSymbolsAndExit ( const char *  a_dumpfile)
inline
785  {
786  g_cfg->DumpAllSymbolsAndExit( a_dumpfile );
787  }

◆ DumpCentroids()

void Landscape::DumpCentroids ( void  )
3276 {
3277  ofstream centroidfile("PolygonCentroids.txt", ios::out);
3278  centroidfile<<"Polyref"<<'\t'<<"CX"<<'\t'<<"CY"<<'\t'<<"Type"<<'\t'<<"Area"<<'\t'<<"Country Designation"<<endl;
3279  for (int p = 0; p< (int)m_elems.size(); p++)
3280  {
3281  centroidfile<<m_elems[p]->GetPoly()<<'\t'<<m_elems[p]->GetCentroidX()<<'\t'<<m_elems[p]->GetCentroidY()<<'\t'<<m_elems[p]->GetElementType()<<'\t'<<m_elems[p]->GetArea()<<'\t'<<m_elems[p]->GetCountryDesignation()<<endl;
3282  }
3283  centroidfile.close();
3284 }

◆ DumpMap()

void Landscape::DumpMap ( const char *  a_filename)
protected
1387 {
1388  int * l_map = m_land->GetMagicP(0, 0); // Hmmm - this is a nasty way round the class data protection. Gets a pointer direct to m_map in rastermap.
1389  /* FILE * l_file;
1390  l_file = fopen(a_filename, "wb" );
1391  if ( !l_file ) {
1392  g_msg->Warn( WARN_FILE, "Landscape::DumpMap(): Unable to open file", a_filename );
1393  exit( 0 );
1394  }
1395 
1396  char * l_id = m_land->GetID();
1397 
1398 
1399  fwrite( l_id, 1, 12, l_file );
1400  fwrite( & m_width, 1, sizeof( int ), l_file );
1401  if (cfg_rectangularmaps_on.value() )
1402  {
1403  fwrite( & m_height, 1, sizeof( int ), l_file );
1404  }
1405  for ( int i = 0; i < m_width * m_height; i++ )
1406  {
1407  LE* le = m_elems[m_polymapping[l_map[i]]];
1408  int l_poly = le->GetPoly();
1409  fwrite( & l_poly, 1, sizeof( int ), l_file );
1410  }
1411  fclose( l_file );
1412  */
1413  ofstream OFile( a_filename, ios::binary);
1414  char id[12] = { "LSB2_Format" };
1415  OFile.write(id, 12);
1416  OFile.write((char*)&m_width, sizeof (int));
1417  OFile.write((char*)&m_height, sizeof (int));
1418  OFile.write((char*)l_map, m_width*m_height*sizeof (int));
1419  OFile.close();
1420 }

◆ DumpMapGraphics()

void Landscape::DumpMapGraphics ( const char *  a_filename)
protected
3599  {
3600  unsigned int linesize = m_maxextent * 3;
3601  unsigned char * frame_buffer = (unsigned char *)malloc(sizeof(unsigned char)* linesize);
3602 
3603  if (frame_buffer == NULL) {
3604  g_msg->Warn(WARN_FILE, "Landscape::DumpMapGraphics(): Out of memory!", "");
3605  exit(1);
3606  }
3607 
3608  FILE * l_file = fopen(a_filename, "w");
3609  if (!l_file) {
3610  g_msg->Warn(WARN_FILE, "Landscape::DumpMapGraphics(): ""Unable to open file for writing: %s\n", a_filename);
3611  exit(1);
3612  }
3613 
3614  fprintf(l_file, "P6\n%d %d %d\n", m_width, m_height, 255);
3615 
3616  for (int y = 0; y < m_height; y++) {
3617  int i = 0;
3618  for (int x = 0; x < m_width; x++) {
3619  int eletype = (int)SupplyElementType(x, y);
3620  int localcolor = 16777215 / eletype;
3621 
3622  if (eletype == (int)tole_Field) {
3623  int category;
3624  double hei = SupplyVegHeight(x, y);
3625  if (hei > 50.0) category = 0; else category = (int)(200.0 - (hei * 4.0));
3626  localcolor = ((category * 65536) + 65535);
3627  }
3628 
3629  frame_buffer[i++] = (unsigned char)(localcolor & 0xff);
3630  frame_buffer[i++] = (unsigned char)((localcolor >> 8) & 0xff);
3631  frame_buffer[i++] = (unsigned char)((localcolor >> 16) & 0xff);
3632  }
3633  fwrite(frame_buffer, sizeof(unsigned char), linesize, l_file);
3634  }
3635 
3636  fclose(l_file);
3637 
3638  free(frame_buffer);
3639 }

◆ DumpMapInfoByArea()

void Landscape::DumpMapInfoByArea ( const char *  a_filename,
bool  a_append,
bool  a_dump_zero_areas,
bool  a_write_veg_names 
)
3652  {
3653  FillVegAreaData();
3654  FILE * outf;
3655  if (a_append) {
3656  outf = fopen(a_filename, "a");
3657  if (!outf) {
3658  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to open file for appending", a_filename);
3659  exit(1);
3660  }
3661  }
3662  else {
3663  outf = fopen(a_filename, "w");
3664  if (!outf) {
3665  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to open file for writing", a_filename);
3666  exit(1);
3667  }
3668  }
3669 
3670  // Emit element type info.
3671  for (unsigned int i = 0; i < tov_Undefined + 1; i++) {
3672  if (i == tov_OFirstYearDanger)
3673  continue;
3674  if (!a_dump_zero_areas && l_vegtype_areas[i] < 0.5)
3675  continue;
3676 
3677  fprintf(outf, "%6ld\t%3d\t%10.0f", g_date->OldDays() + g_date->DayInYear() - 364, i, l_vegtype_areas[i]);
3678  if (a_write_veg_names)
3679  fprintf(outf, "\t%s\n", VegtypeToString((TTypesOfVegetation)i).c_str()); else
3680  fprintf(outf, "\n");
3681  }
3682 
3683  fclose(outf);
3684 }

◆ DumpPublicSymbols()

void Landscape::DumpPublicSymbols ( const char *  a_dumpfile,
CfgSecureLevel  a_level 
)
inline
782  {
783  g_cfg->DumpPublicSymbols( a_dumpfile, a_level );
784  }

◆ DumpTreatCounters()

void Landscape::DumpTreatCounters ( const char *  a_filename)
protected
3586  {
3587  FILE * l_file = fopen(a_filename, "w");
3588  if (!l_file) {
3589  g_msg->Warn(WARN_FILE, "Landscape::DumpTreatCounters(): ""Unable to open file for writing: %s\n", a_filename);
3590  exit(1);
3591  }
3592 
3593  for (int i = start; i < last_treatment; i++) {
3594  fprintf(l_file, "%3d %s %10d\n", i, EventtypeToString(i).c_str(), m_treatment_counts[i]);
3595  }
3596  fclose(l_file);
3597 }

◆ DumpVegAreaData()

void Landscape::DumpVegAreaData ( int  a_day)
4680  {
4681 
4682  if (cfg_dumpvegjan.value()) {
4683  if ((a_day % 365) == 0) { // Jan 1st
4684  DumpMapInfoByArea(cfg_dumpvegjanfile.value(), true, true, true);
4685  return;
4686  }
4687  }
4688  if (cfg_dumpvegjune.value()) {
4689  if ((a_day % 365) == 152) { // 1st June
4690  DumpMapInfoByArea(cfg_dumpvegjunefile.value(), true, true, true);
4691  }
4692  }
4693 
4694 }

References cfg_dumpvegjan(), cfg_dumpvegjanfile(), cfg_dumpvegjune(), and cfg_dumpvegjunefile().

Referenced by RunTheSim().

◆ EventDump()

void Landscape::EventDump ( int  x,
int  y,
int  x2,
int  y2 
)
protected
1697  {
1698  FILE * vfile=fopen("EventDump.txt", "a" );
1699  if (!vfile) {
1700  g_msg->Warn( WARN_FILE, "Landscape::EventDump(): Unable to open file", "EventDump.txt" );
1701  exit( 1 );
1702  }
1703  FarmToDo event;
1704  int i = 0;
1705  int day = SupplyDayInYear();
1706  fprintf( vfile, "%d: ", day );
1707  while ( ( event = ( FarmToDo )SupplyLastTreatment( x1, y1, & i ) ) != sleep_all_day ) {
1708  fprintf( vfile, "%d ", event );
1709  }
1710  i = 0;
1711  fprintf( vfile, " - " );
1712  while ( ( event = ( FarmToDo )SupplyLastTreatment( x2, y2, & i ) ) != sleep_all_day ) {
1713  fprintf( vfile, "%d ", event );
1714  }
1715  fprintf( vfile, "\n" );
1716  fclose( vfile );
1717 }

◆ EventDumpPesticides()

void Landscape::EventDumpPesticides ( int  x1,
int  y1 
)
protected
1720  {
1721  FILE * vfile=fopen("EventDump.txt", "a" );
1722  if (!vfile) {
1723  g_msg->Warn( WARN_FILE, "Landscape::EventDump(): Unable to open file", "EventDump.txt" );
1724  exit( 1 );
1725  }
1726  FarmToDo a_event;
1727  int i = 0;
1728  int day = this->SupplyGlobalDate();
1729  int herb = 0;
1730  int fung = 0;
1731  int ins = 0;
1732  while ( ( a_event = ( FarmToDo )SupplyLastTreatment( x1, y1, & i ) ) != sleep_all_day ) {
1733  if (a_event == herbicide_treat )
1734  {
1735  herb++;
1736  }
1737  else if (a_event == fungicide_treat ) fung++;
1738  else if (a_event == insecticide_treat) ins++;
1739  }
1740  if (herb+fung+ins >0 ) fprintf( vfile, "%d\t%d\t%d\t%d\n", day, herb, fung, ins );
1741  i = 0;
1742  fclose( vfile );
1743 }

◆ EventtypeToString()

std::string Landscape::EventtypeToString ( int  a_event)
3918  {
3919  char error_num[20];
3920 
3921  switch (a_event) {
3922  case start:
3923  return " start";
3924  case sleep_all_day:
3925  return " sleep_all_day";
3926  case autumn_plough:
3927  return " autumn_plough";
3928  case stubble_plough:
3929  return " stubble_plough";
3930  case stubble_cultivator_heavy:
3931  return " stubble_cultivator_heavy";
3932  case heavy_cultivator_aggregate:
3933  return " heavy_cultivator_aggregate";
3934  case autumn_harrow:
3935  return " autumn_harrow";
3936  case preseeding_cultivator:
3937  return " preseeding_cultivator";
3938  case preseeding_cultivator_sow:
3939  return " preseeding_cultivator_sow";
3940  case autumn_roll:
3941  return " autumn_roll";
3942  case autumn_sow:
3943  return " autumn_sow";
3944  case winter_plough:
3945  return " winter_plough";
3946  case deep_ploughing:
3947  return " deep_ploughing";
3948  case spring_plough:
3949  return " spring_plough";
3950  case spring_harrow:
3951  return " spring_harrow";
3952  case spring_roll:
3953  return " spring_roll";
3954  case spring_sow:
3955  return " spring_sow";
3956  case spring_sow_with_ferti:
3957  return " spring_sow_with_ferti";
3958  case fp_npks:
3959  return " fp_npks";
3960  case fp_npk:
3961  return " fp_npk";
3962  case fp_pk:
3963  return " fp_pk";
3964  case fp_liquidNH3:
3965  return " fp_liquidNH3";
3966  case fp_slurry:
3967  return " fp_slurry";
3968  case fp_ammoniumsulphate:
3969  return " fp_ammoniumsulphate";
3970  case fp_manganesesulphate:
3971  return " fp_manganesesulphate";
3972  case fp_manure:
3973  return " fp_manure";
3974  case fp_greenmanure:
3975  return " fp_greenmanure";
3976  case fp_sludge:
3977  return " fp_sludge";
3978  case fp_rsm:
3979  return " fp_rsm";
3980  case fp_calcium:
3981  return " fp_calcium";
3982  case fa_npk:
3983  return " fa_npk";
3984  case fa_pk:
3985  return " fa_pk";
3986  case fa_slurry:
3987  return " fa_slurry";
3988  case fa_ammoniumsulphate:
3989  return " fa_ammoniumsulphate";
3990  case fa_manganesesulphate:
3991  return " fa_manganesesulphate";
3992  case fa_manure:
3993  return " fa_manure";
3994  case fa_greenmanure:
3995  return " fa_greenmanure";
3996  case fa_sludge:
3997  return " fa_sludge";
3998  case fa_rsm:
3999  return " fa_rsm";
4000  case fa_calcium:
4001  return " fa_calcium";
4002  case herbicide_treat:
4003  return " herbicide_treat";
4004  case growth_regulator:
4005  return " growth_regulator";
4006  case fungicide_treat:
4007  return " fungicide_treat";
4008  case insecticide_treat:
4009  return " insecticide_treat";
4010  case product_treat:
4011  return "pesticide_product_treat";
4012  case syninsecticide_treat:
4013  return " syninsecticide_treat";
4014  case molluscicide:
4015  return " molluscicide";
4016  case row_cultivation:
4017  return " row_cultivation";
4018  case strigling:
4019  return " strigling";
4020  case flammebehandling:
4021  return " flammebehandling";
4022  case hilling_up:
4023  return " hilling_up";
4024  case water:
4025  return " water";
4026  case swathing:
4027  return " swathing";
4028  case harvest:
4029  return " harvest";
4030  case cattle_out:
4031  return " cattle_out";
4032  case pigs_out:
4033  return " pigs_out";
4034  case cut_to_hay:
4035  return " cut_to_hay";
4036  case cut_to_silage:
4037  return " cut_to_silage";
4038  case straw_chopping:
4039  return " straw_chopping";
4040  case hay_turning:
4041  return " hay_turning";
4042  case hay_bailing:
4043  return " hay_bailing";
4044  case stubble_harrowing:
4045  return " stubble_harrowing";
4046  case autumn_or_spring_plough:
4047  return "autumn_or_spring_plough";
4048  case burn_straw_stubble:
4049  return " burn_straw_stubble";
4050  case mow:
4051  return " mow";
4052  case cut_weeds:
4053  return " cut_weeds";
4054  case strigling_sow:
4055  return " strigling_sow";
4056  case trial_insecticidetreat:
4057  return "PesticideTrialTreatment";
4058  case trial_toxiccontrol:
4059  return " PesticideTrialToxic";
4060  case trial_control:
4061  return " PesticideTrialControl";
4062  case glyphosate:
4063  return " Glyphosate on setaside";
4064  case biocide:
4065  return " biocide";
4066  case strigling_hill:
4067  return " strigling_hill";
4068  case bed_forming:
4069  return " bed_forming";
4070  case flower_cutting:
4071  return " flower_cutting";
4072  case bulb_harvest:
4073  return " bulb_harvest";
4074  case straw_covering:
4075  return " straw_covering";
4076  case straw_removal:
4077  return " straw_removal";
4078  default:
4079  sprintf(error_num, "%d", a_event);
4080  g_msg->Warn(WARN_FILE, "Landscape::EventtypeToString(): Unknown event type:", error_num);
4081  exit(1);
4082  }
4083 }

◆ FillVegAreaData()

void Landscape::FillVegAreaData ( )
3641  {
3642  for (unsigned int i = 0; i < (tov_Undefined + 1); i++) {
3643  l_vegtype_areas[i] = 0.0;
3644  }
3645 
3646  // Sum up statistics on element type.
3647  for (unsigned int i = 0; i < m_elems.size(); i++) {
3648  l_vegtype_areas[m_elems[i]->GetVegType()] += m_elems[i]->GetArea();
3649  }
3650 }

◆ FindFieldCenter()

bool Landscape::FindFieldCenter ( LE a_field,
int x,
int y 
)
protected
2799  {
2800  // Start at x,y
2801  // works by selecting the point that is a mean of the co-ords of the centers of 4 axes from this point that are in the field.
2802  // Then do it again, and again until we don't move more than 1m or we have tried too many times
2803  int ourpoly=SupplyPolyRef(*(x),*(y));
2804  if (ourpoly!=a_field->GetPoly()) return false;
2805  int centers[2][8];
2806  int tries=0;
2807  int diff=999;
2808  int x1=*(x);
2809  int y1=*(y);
2810  int centreX=x1;
2811  int centreY=y1;
2812  // NB we might escape without bounds checking here because the polygon number does not wrap round - will only ever be a problem if we go SimX+1,SimY+1
2813  while ((diff>1) & (tries++<100)) {
2814  for (unsigned v=0; v<4; v++) {
2815  x1=centreX;
2816  y1=centreY;
2817  AxisLoop(ourpoly, &x1, &y1, v);
2818  centers[0][v]=x1-m_x_add[v];
2819  centers[1][v]=y1-m_y_add[v];
2820  x1=centreX;
2821  y1=centreY;
2822  AxisLoop(ourpoly, &x1, &y1, v+4);
2823  centers[0][v+4]=x1-m_x_add[v+4];
2824  centers[1][v+4]=y1-m_y_add[v+4];
2825 // centreX+=((centers[0][v]+x1-m_x_add[v+4])/2);
2826 // centreY+=((centers[1][v]+y1-m_y_add[v+4])/2);
2827  }
2828  int oldx=centreX;
2829  int oldy=centreY;
2830  centreX=0;
2831  centreY=0;
2832  for (int h=0; h<8; h++) {
2833  centreX+=centers[0][h];
2834  centreY+=centers[1][h];
2835  }
2836  centreX/=8;
2837  centreY/=8;
2838  diff=abs(oldx-centreX)+abs(oldy-centreY);
2839  }
2840  *(x)=centreX;
2841  *(y)=centreY;
2842  int tourpoly=SupplyPolyRef(*(x),*(y));
2843  if (tourpoly!=ourpoly) {
2844  return false; // can happen eg if there is a pond in the middle of the field
2845  }
2846 
2847  return true;
2848 }

References LE::GetPoly().

◆ FindLongestAxis()

int Landscape::FindLongestAxis ( int x,
int y,
int a_length 
)
protected
2852 {
2853  int ourpoly=SupplyPolyRef(*(a_x),*(a_y));
2854  int dist[4];
2855  int distx[8];
2856  int disty[8];
2857  int found = -1;
2858  *(a_length) = 0;
2859  int dx[8];
2860  int dy[8];
2861  int fx[8];
2862  int fy[8];
2863  for (unsigned v=0; v<8; v++)
2864  {
2865  int x1=*(a_x);
2866  int y1=*(a_y);
2867  AxisLoop(ourpoly, &x1, &y1, v);
2868  x1 -= m_x_add[v];
2869  y1 -= m_y_add[v];
2870  dx[v] = abs(*(a_x)-x1);
2871  dy[v] = abs(*(a_y)-y1);
2872  fx[v] = x1;
2873  fy[v] = y1;
2874  distx[v] = dx[v];
2875  disty[v] = dy[v];
2876  }
2877  for (int di = 0; di < 4; di++)
2878  {
2879  int ddx = distx[di] + distx[di + 4];
2880  int ddy = disty[di] + disty[di + 4];
2881  if (ddx == 0) dist[di] = ddy; else dist[di] = ddx;
2882  if (dist[di] > *(a_length))
2883  {
2884  found = di;
2885  *(a_length) = dist[di];
2886  }
2887  }
2888  if (found == -1) return 0;
2889  // Now need to find the middle of the axis.
2890  int l = (*(a_length) / 2);
2891  if (fx[found] > fx[found + 4]) *(a_x) = fx[found + 4] + m_x_add[found] * l; else *(a_x) = fx[found + 4] - m_x_add[found + 4] * l;
2892  if (fy[found] > fy[found + 4]) *(a_y) = fy[found + 4] + m_y_add[found] * l; else *(a_y) = fy[found + 4] - m_y_add[found + 4] * l;
2893 
2894  return found;
2895 }

◆ FindValidXY()

bool Landscape::FindValidXY ( int  a_field,
int a_x,
int a_y 
)
protected
2688  {
2689  // From a hopefully sensible starting point this method scans in the
2690  // 8 directions to find a good valid x and y matching a_field
2691  int x_add[ 8 ] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2692  int y_add[ 8 ] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2693  int index;
2694  int nx, ny;
2695  int width = m_land->MapWidth();
2696  int height = m_land->MapHeight();
2697  // Assume it has to within 100m
2698  for ( int i = 0; i < 100; i++ ) {
2699  for ( int l = 0; l < 8; l++ ) {
2700  nx = a_x + x_add[ l ] * i;
2701  ny = a_y + y_add[ l ] * i;
2702  if ( ( nx < width ) && ( nx >= 0 ) && ( ny < height ) && ( ny >= 0 ) ) {
2703  index = m_land->Get( nx, ny );
2704  if ( index == a_field ) {
2705  a_x = a_x + x_add[ l ] * i;
2706  a_y = a_y + y_add[ l ] * i;
2707  return true;
2708  }
2709  }
2710  }
2711  }
2712  return false;
2713 }

◆ ForceArea()

void Landscape::ForceArea ( void  )
protected
2072  {
2073  int l_area_sum = 0;
2074 
2075  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
2076  m_elems[ i ]->SetArea( ( double )m_elems[ i ]->m_squares_in_map );
2077  if ( m_elems[ i ]->m_squares_in_map > 0 ) {
2078  m_elems[ i ]->SetMapValid( true );
2079  l_area_sum += m_elems[ i ]->m_squares_in_map;
2080  }
2081  }
2082 
2083  if ( l_area_sum != m_width * m_height ) {
2084  g_msg->Warn( WARN_BUG, "Landscape::ForceArea(): Polygon areas doesn't"" sum up to map area!", "" );
2085  exit( 1 );
2086  }
2087 }

◆ GetActualGooseGrazingForage() [1/2]

double Landscape::GetActualGooseGrazingForage ( int  a_polygon,
GooseSpecies  a_goose 
)
inline

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.

Parameters
a_polygon[in] The polygon refence number for the polygon we are interested in (assumed grass or cereals). This needs to be checked before calling
a_goose[in] Is the type of goose calling which is needed to determine how to assess the value of the current forage availability (ie its different for different types of geese)
Returns
KJ/min
608  {
609  return m_elems[m_polymapping[a_polygon]]->GetGooseGrazingForage(a_goose);
610  }

References m_elems, and m_polymapping.

◆ GetActualGooseGrazingForage() [2/2]

double Landscape::GetActualGooseGrazingForage ( int  a_x,
int  a_y,
GooseSpecies  a_goose 
)
inline

Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location.

Parameters
a_x[in] The x-coordinate in a polygon we are interested in (assumed grass or cereals). This needs to be checked before calling
a_y[in] The x-coordinate in a polygon we are interested in (assumed grass or cereals). This needs to be checked before calling
a_goose[in] Is the type of goose calling which is needed to determine how to assess the value of the current forage availability (ie its different for different types of geese)
Returns
KJ/min
597  {
598  return m_elems[m_land->Get(a_x, a_y)]->GetGooseGrazingForage(a_goose);
599  }

References m_elems, and m_land.

◆ GetGooseFields()

GooseFieldList * Landscape::GetGooseFields ( double  a_minopenness)

Gets the list of suitable goose foraging fields today.

Here we need to go through all possible goose feeding locations to find out if they have any forage in them, and then create a list of those to return.
To make this efficient we need to have a list of fields.

First must calculate centroid. Runs through the list of elements and any that have an openness score bigger than our target are saved.

686 {
693  GooseFieldList* alist = new GooseFieldList;
697  GooseFieldListItem gfli;
698  for (unsigned int i = 0; i < m_elems.size(); i++)
699  {
700  if (m_elems[i]->GetOpenness() > a_minopenness)
701  {
702  for (int g = gs_Pinkfoot; g < gs_foobar; g++)
703  {
704  gfli.grass[g] = m_elems[i]->GetGooseGrazingForage((GooseSpecies)g);
705  gfli.geesesp[g] = m_elems[i]->GetGooseSpNosToday((GooseSpecies)g);
706  gfli.geesespTimed[g] = m_elems[i]->GetGooseSpNosTodayTimed((GooseSpecies)g);
707  gfli.roostdists[g] = m_elems[i]->GetGooseRoostDist((GooseSpecies)g);
708  }
709  gfli.grain = m_elems[i]->GetBirdSeed();
710  gfli.maize = m_elems[ i ]->GetBirdMaize();
711  gfli.openness = m_elems[ i ]->GetOpenness();
712  int pref = m_elems[ i ]->GetPoly();
713  gfli.polyref = pref;
714  gfli.geese = m_elems[i]->GetGooseNosToday();
715  gfli.geeseTimed = m_elems[i]->GetGooseNosTodayTimed();
716  gfli.vegtype = m_elems[i]->GetVegType();
717  gfli.vegtypechr = VegtypeToString(m_elems[i]->GetVegType());
718  gfli.vegheight = m_elems[i]->GetVegHeight();
719  gfli.digestability = m_elems[i]->GetDigestability();
720  gfli.vegphase = m_elems[i]->GetVegPhase();
721  gfli.previouscrop = VegtypeToString( m_elems[ i ]->GetPreviousCrop( m_elems[ i ]->GetRotIndex() ) );
722  gfli.lastsownveg = VegtypeToString( m_elems[ i ]->GetLastSownVeg() );
723  alist->push_back(gfli);
724  }
725  }
726  return alist;
727 }

References GooseFieldListItem::digestability, GooseFieldListItem::geese, GooseFieldListItem::geesesp, GooseFieldListItem::geesespTimed, GooseFieldListItem::geeseTimed, GooseFieldListItem::grain, GooseFieldListItem::grass, GooseFieldListItem::lastsownveg, GooseFieldListItem::maize, GooseFieldListItem::openness, GooseFieldListItem::polyref, GooseFieldListItem::previouscrop, GooseFieldListItem::roostdists, GooseFieldListItem::vegheight, GooseFieldListItem::vegphase, GooseFieldListItem::vegtype, and GooseFieldListItem::vegtypechr.

◆ GetGooseNumbers() [1/2]

int Landscape::GetGooseNumbers ( int  a_poly)

This returns the number of geese on the polygon the day before.

3383  {
3384  return m_elems[m_polymapping[a_polyref]]->GetGooseNos();
3385  }

References m_polymapping.

◆ GetGooseNumbers() [2/2]

int Landscape::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.

This returns the number of geese on the polygon the day before.

3398  {
3399  return m_elems[m_land->Get(a_x, a_y)]->GetGooseNos();
3400  }

◆ GetHareFoodQuality()

double Landscape::GetHareFoodQuality ( int  a_polygon)
Todo:
Decide where to classify new LE types for hare 1
3404 {
3405  double digest;
3406  TTypesOfLandscapeElement habitat = SupplyElementType(a_polygon);
3407  switch (habitat) {
3408  // Impossible stuff
3409  case tole_Building:
3410  case tole_Pond:
3411  case tole_Freshwater:
3412  case tole_River:
3413  case tole_Saltwater:
3414  case tole_Coast:
3415  case tole_BareRock:
3416  case tole_ConiferousForest:
3417  case tole_DeciduousForest:
3418  case tole_MixedForest:
3419  case tole_SmallRoad:
3420  case tole_LargeRoad:
3421  case tole_ActivePit:
3422  case tole_UrbanNoVeg:
3423  case tole_UrbanPark:
3424  case tole_SandDune:
3425  case tole_Copse:
3426  case tole_Stream:
3427  case tole_MetalledPath:
3428  case tole_Carpark:
3429  case tole_FishFarm:
3430  case tole_Fence:
3431  // EnergyBalance(activity_Foraging, 100); // This is a bug - it penalises for foraging in impossible areas - not intended but not found until after parameter fitting! Removed 28/07/2014
3432  return 0.0;
3433 
3434  // Questionable stuff
3435  case tole_RiversidePlants:
3436  case tole_RiversideTrees:
3437  case tole_Garden:
3438  case tole_Track:
3439  case tole_StoneWall:
3440  case tole_Hedges:
3441  case tole_Marsh:
3442  case tole_PitDisused:
3443  case tole_RoadsideVerge:
3444  case tole_Railway:
3445  case tole_Scrub:
3446  case tole_AmenityGrass:
3447  case tole_Parkland:
3448  case tole_BuiltUpWithParkland:
3449  case tole_Churchyard:
3450  case tole_HeritageSite:
3451  return 0.25; // was 0.25 being half of access to low digestability stuff
3452  // case tole_MownGrass:
3453  // digest = 0.8; // Added 28/07/2014 this is a way to compensate for the lack of choice when foraging, i.e. the whole area is assumed to be foraged equally.
3455  case tole_Wasteland:
3456  case tole_IndividualTree:
3457  case tole_WoodyEnergyCrop:
3458  case tole_PlantNursery:
3459  case tole_Pylon:
3460  case tole_WindTurbine:
3461  case tole_WoodlandMargin:
3462  case tole_Vildtager:
3463  default:
3464  digest = SupplyVegDigestability(a_polygon);
3465  }
3466 #ifdef __Perfectfood
3467  return 0.8;
3468 #else
3469 #ifdef __YEARLYVARIABLEFOODQUALITY
3470  digest *= m_OurPopulationManager->m_GoodYearBadYear;
3471 #endif
3472  double veg_height;
3473  double access = 1.0;
3474  // double grazedreduction[4] = { 1.0, 0.75, 0.5, 0.25 };
3475  double grazedreduction[4] = { 1.0, 0.8, 0.2, 0.05 };
3476  veg_height = SupplyVegHeight(a_polygon);
3477  double weeds = SupplyWeedBiomass(a_polygon);
3478  if ((veg_height <= 0) && (weeds < 0.1)) return 0.25; // Always something to eat, but not much.
3479 #ifdef __Hare1950s
3480  bool veg_patchy = true;
3481 #else // If it is not the special case of the 1950s
3482  //
3483  bool veg_patchy = SupplyVegPatchy(a_polygon);
3484 #endif
3485  if (veg_patchy)
3486  {
3487  // Patchy vegetation - normally full access
3488  if (veg_height>50)
3489  {
3490  // no food at only at very very tall
3491  access -= ((veg_height - 50)* g_VegHeightForageReduction);
3492  if (access<0) access = 0;
3493  }
3494  }
3495  else
3496  {
3497  if (veg_height>g_FarmIntensivenessH)
3498  {
3499  access -= ((veg_height - g_FarmIntensivenessH)* /* g_FarmIntensiveness * */ g_VegHeightForageReduction);
3500  if (access<0) access = 0;
3501  }
3502  }
3503  return access * digest * grazedreduction[SupplyGrazingPressure(a_polygon)];
3504 #endif
3505 }

References g_FarmIntensivenessH, and g_VegHeightForageReduction.

◆ GetPolymapping()

int Landscape::GetPolymapping ( int  a_index)
inline
183 { return m_polymapping[a_index]; }

References m_polymapping.

◆ GetQuarryNumbers()

int Landscape::GetQuarryNumbers ( int  a_poly)

This returns the number of geese which are legal quarry on the polygon the day before.

This returns the number of geese on the polygon the day before.

3390  {
3391  return m_elems[m_polymapping[a_polyref]]->GetQuarryNos();
3392  }

References m_polymapping.

◆ GetVegArea()

double Landscape::GetVegArea ( int  v)
inline
170 { return l_vegtype_areas[v]; }

References l_vegtype_areas.

◆ GISASCII_Output()

void Landscape::GISASCII_Output ( string  outpfile,
int  UTMX,
int  UTMY 
)
protected

Write ASCII file of the ALMaSS map.

Here we write a ASCII file of the current map. Useful when visualizing output from simulations. The function will output the entity that is defined in the config: l_map_ascii_map_entity. The default is polyref number (l_map_ascii_map_entity = 1).

Parameters
[in]outpfileName of the output file
[in]UTMXUtm x-coordinate of the lower lefthand corner of the map
[in]UTMYUtm y-coordinate of the lower lefthand corner of the map
3507  {
3515  FILE* OFILE;
3516  OFILE = fopen( outpfile.c_str(), "w" );
3517  if (!OFILE) {
3518  g_msg->Warn( WARN_FILE, "Landscape::GISASCII_Output() "
3519  "Unable to open file for writing:",
3520  outpfile );
3521  exit( 1 );
3522  }
3523  char c = '\n';
3524  fprintf(OFILE, "ncols %d\n", m_width);
3525  fprintf(OFILE, "nrows %d\n", m_height);
3526  fprintf(OFILE, "xllcorner %d\n", UTMX );
3527  fprintf(OFILE, "yllcorner %d\n", UTMY );
3528  fprintf(OFILE, "cellsize %d\n", 1 );
3529  fprintf(OFILE, "NODATA_value %d\n", -9999 );
3530  // The polyref loop
3531  if (l_map_ascii_map_entity.value() == 1) {
3532  for (int y = 0; y < m_height; y++) {
3533  for (int x = 0; x < m_width; x++) {
3534  fprintf(OFILE, "%d\t", SupplyPolyRef(x, y));
3535  }
3536  fprintf(OFILE, "%c", c );
3537  }
3538  }
3539  // The element type loop
3540  if (l_map_ascii_map_entity.value() == 2) {
3541  for (int y = 0; y < m_height; y++) {
3542  for (int x = 0; x < m_width; x++) {
3543  fprintf(OFILE, "%d\t", SupplyElementType( x, y ));
3544  }
3545  fprintf( OFILE, "%c", c );
3546  }
3547  }
3548  fclose( OFILE );
3549 }

References l_map_ascii_map_entity().

◆ GrazeVegetation()

void Landscape::GrazeVegetation ( int  a_poly,
double  a_forage 
)
inline

Removes grazing forage from a poly per m2.

670  {
671  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetation( a_forage, true );
672  }

References m_elems, and m_polymapping.

◆ GrazeVegetationTotal()

void Landscape::GrazeVegetationTotal ( int  a_poly,
double  a_forage 
)
inline

Removes grazing forage from a poly and divides this out per m2.

676  {
677  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetationTotal( a_forage );
678  }

References m_elems, and m_polymapping.

◆ hb_Add()

void Landscape::hb_Add ( void  )
protected

◆ hb_AddNewHedgebanks()

void Landscape::hb_AddNewHedgebanks ( int  a_orig_poly_num)
protected

◆ hb_Cleanup()

void Landscape::hb_Cleanup ( void  )
protected

◆ hb_ClearPolygon()

void Landscape::hb_ClearPolygon ( int  a_poly_num)
protected

◆ hb_DownPolyNumbers()

void Landscape::hb_DownPolyNumbers ( void  )
protected

◆ hb_FindBoundingBox()

bool Landscape::hb_FindBoundingBox ( int  a_poly_num)
protected

◆ hb_FindHedges()

void Landscape::hb_FindHedges ( void  )
protected

◆ hb_GenerateHBPolys()

void Landscape::hb_GenerateHBPolys ( void  )
protected

◆ hb_HasNeighbourColor()

bool Landscape::hb_HasNeighbourColor ( int  a_x,
int  a_y,
int  a_neighbour_color 
)
protected

◆ hb_HasOtherNeighbour()

bool Landscape::hb_HasOtherNeighbour ( int  a_x,
int  a_y 
)
protected

◆ hb_MapBorder()

bool Landscape::hb_MapBorder ( int  a_x,
int  a_y 
)
protected

◆ hb_MarkTheBresenhamWay()

void Landscape::hb_MarkTheBresenhamWay ( void  )
protected

◆ hb_MarkTopFromLocalMax()

void Landscape::hb_MarkTopFromLocalMax ( int  a_color)
protected

◆ hb_MaxUnpaintedNegNeighbour()

int Landscape::hb_MaxUnpaintedNegNeighbour ( int  a_x,
int  a_y 
)
protected

◆ hb_PaintBorder()

void Landscape::hb_PaintBorder ( int  a_color)
protected

◆ hb_PaintWhoHasNeighbourColor()

bool Landscape::hb_PaintWhoHasNeighbourColor ( int  a_neighbour_color,
int  a_new_color 
)
protected

◆ hb_ResetColorBits()

void Landscape::hb_ResetColorBits ( void  )
protected

◆ hb_RestoreHedgeCore()

void Landscape::hb_RestoreHedgeCore ( int  a_orig_poly_number)
protected

◆ hb_StripingDist()

int Landscape::hb_StripingDist ( void  )
protected

◆ hb_UpPolyNumbers()

void Landscape::hb_UpPolyNumbers ( void  )
protected

◆ HowManyPonds()

int Landscape::HowManyPonds ( )
inline

Returns the number of ponds in the landscape.

336 { return int(m_PondIndexList.size()); }

References m_PondIndexList.

◆ IncOsmiaNest()

void Landscape::IncOsmiaNest ( int  a_x,
int  a_y 
)
inline

Reopen the osmia nest here

866  {
867  m_elems[m_land->Get(a_x, a_y)]->IncOsmiaNesting();
868  }

References m_elems, and m_land.

◆ IncTreatCounter()

void Landscape::IncTreatCounter ( int  a_treat)
3575  {
3576  if (a_treat < 0 || a_treat >= last_treatment) {
3577  char errornum[20];
3578  sprintf(errornum, "%d", a_treat);
3579  g_msg->Warn(WARN_BUG, "Landscape::IncTreatCounter(): Index"" out of range!", errornum);
3580  exit(1);
3581  }
3582  m_treatment_counts[a_treat] ++;
3583 }

Referenced by LE::SetLastTreatment().

◆ InitOsmiaBeeNesting()

void Landscape::InitOsmiaBeeNesting ( )

Read in the Osmia nest density files and allocate to each LE object.

Reads in an input file Ela and provides a max nest number to each instance of LE* in the m_elems vector

4698 {
4700  array<int, tole_Foobar> tole_ref;
4701  array<double, tole_Foobar> maxOsmiaNests;
4702  array<double, tole_Foobar> minOsmiaNests;
4703  fstream ifile(cfg_OsmiaNestByLE_Datafile.value(), ios::in);
4704  if (!ifile.is_open()) {
4705  g_msg->Warn("Cannot open file: ", cfg_OsmiaNestByLE_Datafile.value());
4706  exit(1);
4707  }
4708  // Read the file tole type by tole type - here we can't rely on the order but need the tole number
4709  int length;
4710  ifile >> length;
4711  if (length != tole_Foobar) {
4712  g_msg->Warn("Inconsistent file length with tole_Foobar: ", int(tole_Foobar));
4713  exit(1);
4714  }
4715  // read the file
4716  for (int i = 0; i < length; i++)
4717  {
4718  ifile >> tole_ref[i] >> minOsmiaNests[i] >> maxOsmiaNests[i];
4719  }
4720  ifile.close();
4721  for (unsigned int e = 0; e < m_elems.size(); e++) {
4722  int eletype = m_elems[e]->GetALMaSSEleType();
4723  // first find the eletype
4724  int found = -1;
4725  for (int j = 0; j < length; j++)
4726  {
4727  if (tole_ref[j] == eletype) {
4728  found = j;
4729  break;
4730  }
4731  }
4732  if (found == -1) {
4733  g_msg->Warn("Inconsistent file data, missing tole type ref: ", eletype);
4734  exit(1);
4735  }
4736  // We have the ref type, so now calculate the number of nests and set it
4737  m_elems[e]->SetMaxOsmiaNests(minOsmiaNests[found] + double(g_rand_uni() * (maxOsmiaNests[found] - minOsmiaNests[found])));
4738  }
4739 }

References cfg_OsmiaNestByLE_Datafile(), and g_rand_uni().

◆ IsFieldType()

bool Landscape::IsFieldType ( TTypesOfLandscapeElement  a_tole)
inline
727  {
728  if ((a_tole == tole_Field)
729  || (a_tole == tole_Orchard)
730  || (a_tole == tole_PermanentSetaside)
731  || (a_tole == tole_PermPasture)
732  || (a_tole == tole_PermPastureLowYield)
733  || (a_tole == tole_PermPastureTussocky)
734  || (a_tole == tole_PermPastureTussockyWet)
735  || (a_tole == tole_Vildtager)
736  || (a_tole == tole_YoungForest)
737  || (a_tole == tole_WoodyEnergyCrop)
738  ) return true;
739  return false;
740  }

◆ LineHighTest()

int Landscape::LineHighTest ( int  a_cx,
int  a_cy,
double  a_offsetx,
double  a_offsety 
)
inline

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.

Returns
d1 is the distance from cx,cy to the obstruction. Runs out a line along a vector set by offsetx & offsety, from cx & cy until it meets too many high elements.

Will only stop when two consecutive squares return 'high'.

The criteria for threat or non-open are based on geese and include tall objects and roads

462 {
467  int d1=-1;
468  int counter = 1;
469  bool found = false;
470  while (!found)
471  {
473  int x = (int) (a_cx + a_offsetx * counter);
474  int y = (int) (a_cy + a_offsety * counter);
475  if (x<1 || x >= (m_width-2) || y<1 || y >= (m_height-2)) return counter;
477  TTypesOfLandscapeElement tole = this->SupplyElementType(x,y);
478  if ((tole == tole_LargeRoad) || (tole == tole_SmallRoad) || (tole == tole_HedgeBank)) return counter;
479  if (SupplyLEHigh(x,y))
480  {
481  x = (int) (a_cx + a_offsetx * (counter+1));
482  y = (int) (a_cy + a_offsety * (counter+1));
483  if (SupplyLEHigh(x,y)) found = true;
484  d1=counter;
485  }
486  counter++;
487  }
488  return d1;
489 }

◆ MagicMapP2PolyRef()

int Landscape::MagicMapP2PolyRef ( int  a_magic)
inline
1517 {
1518  return m_elems[ a_magic ]->GetPoly();
1519 }

References m_elems.

◆ NewElement()

LE * Landscape::NewElement ( TTypesOfLandscapeElement  a_type)
protected
3688  {
3689  LE * elem;
3690  static char error_num[20];
3691 
3692  switch (a_type) {
3693  case tole_Hedges:
3694  elem = new Hedges;
3695  break;
3696  case tole_HedgeBank:
3697  elem = new HedgeBank;
3698  break;
3699  case tole_BeetleBank:
3700  elem = new BeetleBank;
3701  break;
3702  case tole_RoadsideVerge:
3703  elem = new RoadsideVerge;
3704  break;
3705  case tole_Railway:
3706  elem = new Railway;
3707  break;
3708  case tole_FieldBoundary:
3709  elem = new FieldBoundary;
3710  break;
3711  case tole_Marsh:
3712  elem = new Marsh;
3713  break;
3714  case tole_Orchard:
3715  elem = new Orchard;
3716  break;
3717  case tole_OrchardBand:
3718  elem = new OrchardBand;
3719  break;
3720  case tole_MownGrass:
3721  elem = new MownGrass;
3722  break;
3723  case tole_Heath:
3724  elem = new Heath;
3725  break;
3726  case tole_Scrub:
3727  elem = new Scrub;
3728  break;
3729  case tole_Field:
3730  elem = new Field;
3731  break;
3732  case tole_PermanentSetaside:
3733  elem = new PermanentSetaside;
3734  break;
3735  case tole_PermPasture:
3736  elem = new PermPasture;
3737  break;
3738  case tole_PermPastureLowYield:
3739  elem = new PermPastureLowYield;
3740  break;
3741  case tole_PermPastureTussocky:
3742  elem = new PermPastureTussocky;
3743  break;
3744  case tole_NaturalGrassDry:
3745  elem = new NaturalGrassDry;
3746  break;
3747  case tole_UnknownGrass:
3748  elem = new NaturalGrassDry;
3749  break;
3750  case tole_RiversidePlants:
3751  elem = new RiversidePlants;
3752  break;
3753  case tole_PitDisused:
3754  elem = new PitDisused;
3755  break;
3756  case tole_RiversideTrees:
3757  elem = new RiversideTrees;
3758  break;
3759  case tole_DeciduousForest:
3760  elem = new DeciduousForest;
3761  break;
3762  case tole_MixedForest:
3763  elem = new MixedForest;
3764  break;
3765  case tole_YoungForest:
3766  elem = new YoungForest;
3767  break;
3768  case tole_ConiferousForest:
3769  elem = new ConiferousForest;
3770  break;
3771  case tole_StoneWall:
3772  elem = new StoneWall;
3773  break;
3774  case tole_Fence:
3775  elem = new Fence;
3776  break;
3777  case tole_Garden:
3778  elem = new Garden;
3779  break;
3780  case tole_Track:
3781  elem = new Track;
3782  break;
3783  case tole_SmallRoad:
3784  elem = new SmallRoad;
3785  break;
3786  case tole_LargeRoad:
3787  elem = new LargeRoad;
3788  break;
3789  case tole_Building:
3790  elem = new Building;
3791  break;
3792  case tole_ActivePit:
3793  elem = new ActivePit;
3794  break;
3795  case tole_Freshwater:
3796  elem = new Freshwater;
3797  break;
3798  case tole_Pond:
3799  elem = new Pond;
3800  break;
3801  case tole_River:
3802  elem = new River;
3803  break;
3804  case tole_Saltwater:
3805  elem = new Saltwater;
3806  break;
3807  case tole_Coast:
3808  elem = new Coast;
3809  break;
3810  case tole_BareRock:
3811  elem = new BareRock;
3812  break;
3813  case tole_AmenityGrass:
3814  elem = new AmenityGrass;
3815  break;
3816  case tole_Parkland:
3817  elem = new Parkland;
3818  break;
3819  case tole_UrbanNoVeg:
3820  elem = new UrbanNoVeg;
3821  break;
3822  case tole_UrbanPark:
3823  elem = new UrbanPark;
3824  break;
3825  case tole_BuiltUpWithParkland:
3826  elem = new BuiltUpWithParkland;
3827  break;
3828  case tole_SandDune:
3829  elem = new SandDune;
3830  break;
3831  case tole_Copse:
3832  elem = new Copse;
3833  break;
3834  case tole_RoadsideSlope:
3835  elem = new RoadsideSlope;
3836  break;
3837  case tole_MetalledPath:
3838  elem = new MetalledPath;
3839  break;
3840  case tole_Carpark:
3841  elem = new Carpark;
3842  break;
3843  case tole_Churchyard:
3844  elem = new Churchyard;
3845  break;
3846  case tole_NaturalGrassWet:
3847  elem = new NaturalGrassWet;
3848  break;
3849  case tole_Saltmarsh:
3850  elem = new Saltmarsh;
3851  break;
3852  case tole_Stream:
3853  elem = new Stream;
3854  break;
3855  case tole_HeritageSite:
3856  elem = new HeritageSite;
3857  break;
3858  case tole_UnsprayedFieldMargin:
3859  elem = new UnsprayedFieldMargin;
3860  break;
3861  case tole_Wasteland:
3862  elem = new Wasteland;
3863  break;
3864  case tole_IndividualTree:
3865  elem = new IndividualTree;
3866  break;
3867  case tole_PlantNursery:
3868  elem = new PlantNursery;
3869  break;
3870  case tole_Vildtager:
3871  elem = new Vildtager;
3872  break;
3873  case tole_WindTurbine:
3874  elem = new WindTurbine;
3875  break;
3876  case tole_WoodyEnergyCrop:
3877  elem = new WoodyEnergyCrop;
3878  break;
3879  case tole_WoodlandMargin:
3880  elem = new WoodlandMargin;
3881  break;
3882  case tole_Pylon:
3883  elem = new Pylon;
3884  break;
3885  case tole_FishFarm:
3886  elem = new FishFarm;
3887  break;
3888  case tole_Missing:
3889  elem = new LE; // These should never be actually used.
3890  break;
3891  case tole_Chameleon:
3892  elem = new ChameleonLE;
3893  break;
3894  case tole_DrainageDitch:
3895  elem = new DrainageDitch;
3896  break;
3897  case tole_UrbanVeg:
3898  elem = new UrbanVeg;
3899  break;
3900  case tole_WaterBufferZone:
3901  elem = new WaterBufferZone;
3902  break;
3903  case tole_Canal:
3904  elem = new Canal;
3905  break;
3906  default:
3907  sprintf(error_num, "%d", a_type);
3908  g_msg->Warn(WARN_FILE, "Landscape::NewElement(): Unknown landscape element requested:", error_num);
3909  exit(1);
3910  } //switch
3911 
3912  elem->SetALMaSSEleType(g_letype->BackTranslateEleTypes(a_type));
3913  elem->SetElementType(a_type);
3915  return elem;
3916 }

References LE_TypeClass::BackTranslateEleTypes(), g_letype, and LE::SetPollenNectarData().

◆ PolysDump()

void Landscape::PolysDump ( const char *  a_filename)
protected
1804 {
1805  ofstream outf(a_filename, ios::out);
1806  int l_num_polys = 0;
1807 
1808  if (!outf.is_open()) {
1809  g_msg->Warn(WARN_FILE, "Landscape::PolysDump(): Unable to open file", a_filename);
1810  exit(1);
1811  }
1812 
1813  // Count up number if active polygons in our list.
1814  unsigned sz = (unsigned)m_elems.size();
1815  for (unsigned int i = 0; i < sz; i++) {
1816  if (m_elems[i]->GetMapValid())
1817  l_num_polys++;
1818  }
1819 
1820  outf << l_num_polys << endl;
1821  outf << "PolyType" << '\t' << "PolyRefNum" << '\t' << "Area" << '\t' << "FarmRef" << '\t' << "UnSprayedMarginRef" << '\t' << "SoilType" << '\t' << "Openness" << '\t' << "CentroidX" << '\t' << "CentroidY" << endl;
1822 
1823  /*
1824  if ( l_map_renumberpolys.value() )
1825  {
1826  RenumberPolys( true );
1827  }
1828  */
1829  // Now we can output the file
1830  for (unsigned int i = 0; i < m_elems.size(); i++)
1831  {
1832  if (m_elems[i]->GetMapValid())
1833  {
1834  outf << m_elems[i]->GetALMaSSEleType() << '\t' << m_elems[i]->GetPoly() << '\t' << m_elems[i]->GetArea() << '\t' <<
1835  m_elems[i]->GetOwnerFile() << '\t' << m_elems[i]->GetUnsprayedMarginPolyRef() << '\t' << m_elems[i]->GetSoilType() << '\t' << m_elems[i]->GetOpenness()
1836  << '\t' << m_elems[i]->GetCentroidX() << '\t' << m_elems[i]->GetCentroidY() << endl;
1837  }
1838  }
1839  outf.close();
1840 }

◆ PolysRemoveInvalid()

bool Landscape::PolysRemoveInvalid ( void  )
protected

PolysValidate or ChangeMapMapping must be called after this method

1773 {
1777  bool didsomething = false;
1778  vector < LE * > l_temp;
1779  cout << "Tidying up the polygon map in PolysRemoveInvalid" << endl;
1780  unsigned int sz= (int) m_elems.size();
1781  for ( unsigned int i = 0; i < sz; i++ ) {
1782  if ( m_elems[ i ]->GetMapValid() ) {
1783  unsigned int j = (int) l_temp.size();
1784  l_temp.resize( j + 1 );
1785  l_temp[ j ] = m_elems[ i ];
1786  } else {
1787  // cout << "Deleted m_elems index:" << m_polymapping[ m_elems[ i ]->GetPoly() ] << " Polynumber :" << m_elems[ i ]->GetPoly() << BackTranslateEleTypes(m_elems[ i ]->GetElementType()) << endl;
1788  m_polymapping[ m_elems[ i ]->GetPoly() ] = -1;
1789  delete m_elems[ i ];
1790  didsomething = true;
1791  }
1792  }
1793 
1794  for ( unsigned int i = 0; i < l_temp.size(); i++ ) {
1795  m_elems[ i ] = l_temp[ i ];
1796  }
1797  m_elems.resize( l_temp.size() );
1799  return didsomething;
1800 }

References m_polymapping.

◆ PolysRenumber()

void Landscape::PolysRenumber ( void  )
protected
2058 {
2059  cout << "In Landscape::Landscape() Polygon renumber." << endl;
2060  for (unsigned int i = 0; i < m_elems.size(); i++)
2061  {
2062  // Need to reset the poly number
2063  int index = m_elems[i]->GetMapIndex(); // This is the number currently in the map matrix
2064  m_elems[i]->SetPoly(index); // The map index and the polygon number are now one and the same
2065  m_polymapping[index] = i; // The polymapping is now linked via index to the m_elems index (i)
2066  }
2067  m_LargestPolyNumUsed = (int) m_elems.size()-1;
2068  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Map to be dumped due to polygon renumber", "");
2069 }

References m_polymapping.

◆ PolysValidate()

void Landscape::PolysValidate ( bool  a_exit_on_invalid)
protected
1746  {
1747  // First loop just sets the MapValid as false (and checks for a major screw-up if this elemenent does not exist even in the list
1748  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1749  m_elems[ i ]->SetMapValid( false );
1750  if ( m_polymapping[ m_elems[ i ]->GetPoly() ] == -1 ) {
1751  char l_err[ 20 ];
1752  sprintf( l_err, "%d", m_elems[ i ]->GetPoly() );
1753  g_msg->Warn( WARN_FILE, "Landscape::PolysValidate(): Invalid polymapping ", l_err );
1754  exit( 1 );
1755  }
1756  }
1757  // Now go through the whole map and for each polygon found set MapValid as true.
1759  if ( a_exit_on_invalid ) {
1760  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1761  if ( !m_elems[ i ]->GetMapValid() ) {
1762  char l_err[ 20 ];
1763  sprintf( l_err, "%d", m_elems[ i ]->GetPoly() );
1764  g_msg->Warn( WARN_FILE, "Landscape::PolysValidate(): Invalid polygon ", l_err );
1765  exit( 0 );
1766  }
1767  }
1768  }
1769 }

References m_polymapping.

◆ PolytypeToString()

std::string Landscape::PolytypeToString ( TTypesOfLandscapeElement  a_le_type)
4087  {
4088  char error_num[20];
4089 
4090  switch (a_le_type) {
4091  case tole_Hedges:
4092  return " Hedge";
4093  case tole_RoadsideVerge:
4094  return " Roadside Verge";
4095  case tole_Railway:
4096  return " Railway";
4097  case tole_FieldBoundary:
4098  return " Field Boundary";
4099  case tole_Marsh:
4100  return " Marsh";
4101  case tole_Scrub:
4102  return " Scrub";
4103  case tole_Field:
4104  return " Field";
4105  case tole_PermPastureTussocky:
4106  return " PermPastureTussocky";
4107  case tole_PermanentSetaside:
4108  return " Permanent Setaside";
4109  case tole_PermPasture:
4110  return " Permanent Pasture";
4111  case tole_PermPastureLowYield:
4112  return " PermPastureLowYield";
4113  case tole_NaturalGrassDry:
4114  return " Natural Grass";
4115  case tole_NaturalGrassWet:
4116  return " Natural Grass Wet";
4117  case tole_RiversidePlants:
4118  return " Riverside Plants";
4119  case tole_PitDisused:
4120  return " Pit Disused";
4121  case tole_RiversideTrees:
4122  return " Riverside Trees";
4123  case tole_DeciduousForest:
4124  return " Deciduous Forest";
4125  case tole_MixedForest:
4126  return " Mixed Forest";
4127  case tole_ConiferousForest:
4128  return " Coniferous Forest";
4129  case tole_YoungForest:
4130  return " Young Forest";
4131  case tole_StoneWall:
4132  return " Stone Wall";
4133  case tole_Garden:
4134  return " Garden";
4135  case tole_Track:
4136  return " Track";
4137  case tole_SmallRoad:
4138  return " Small Road";
4139  case tole_LargeRoad:
4140  return " Large Road";
4141  case tole_Building:
4142  return " Building";
4143  case tole_ActivePit:
4144  return " Active Pit";
4145  case tole_Pond:
4146  return " Pond";
4147  case tole_Freshwater:
4148  return " Fresh Water";
4149  case tole_River:
4150  return " River";
4151  case tole_Saltwater:
4152  return " Saltwater";
4153  case tole_Coast:
4154  return " Coast";
4155  case tole_BareRock:
4156  return " Bare Rock";
4157  case tole_HedgeBank:
4158  return " Hedgebank";
4159  case tole_Heath:
4160  return " Heath";
4161  case tole_Orchard:
4162  return " Orchard";
4163  case tole_OrchardBand:
4164  return " Orchard Band";
4165  case tole_MownGrass:
4166  return " Mown Grass";
4167  case tole_UnsprayedFieldMargin:
4168  return " UnsprayedFieldMargin";
4169  case tole_AmenityGrass:
4170  return " AmenityGrass";
4171  case tole_Parkland:
4172  return " Parkland";
4173  case tole_UrbanNoVeg:
4174  return " UrbanNoVeg";
4175  case tole_UrbanVeg:
4176  return " UrbanVeg";
4177  case tole_UrbanPark:
4178  return " UrbanPark";
4179  case tole_BuiltUpWithParkland:
4180  return " BuiltUpWithParkland";
4181  case tole_SandDune:
4182  return " SandDune";
4183  case tole_Copse:
4184  return " Copse";
4185  case tole_RoadsideSlope:
4186  return " RoadsideSlope";
4187  case tole_MetalledPath:
4188  return " MetalledPath";
4189  case tole_Carpark:
4190  return " Carpark";
4191  case tole_Churchyard:
4192  return " Churchyard";
4193  case tole_Saltmarsh:
4194  return " Saltmarsh";
4195  case tole_Stream:
4196  return " Stream";
4197  case tole_HeritageSite:
4198  return " HeritageSite";
4199  case tole_BeetleBank: //141
4200  return " Beetle Bank";
4201  case tole_UnknownGrass:
4202  return " Unknown Grass";
4203  case tole_Wasteland:
4204  return " Waste/Building Land";
4205  case tole_IndividualTree:
4206  return " IndividualTree";
4207  case tole_PlantNursery:
4208  return " PlantNursery";
4209  case tole_Vildtager:
4210  return " Vildtager";
4211  case tole_WindTurbine:
4212  return " WindTurbine";
4213  case tole_WoodyEnergyCrop:
4214  return " WoodyEnergyCrop";
4215  case tole_WoodlandMargin:
4216  return " WoodlandMargin";
4217  case tole_Pylon:
4218  return " Pylon";
4219  case tole_FishFarm:
4220  return " FishFarm";
4221  case tole_Fence:
4222  return " Fence";
4223  case tole_WaterBufferZone:
4224  return " Unsprayed buffer zone around water";
4225  case tole_Foobar:
4226  default:
4227  sprintf(error_num, "%d", a_le_type);
4228  g_msg->Warn(WARN_FILE, "Landscape::PolytypeToString(): Unknown event type:", error_num);
4229  exit(1);
4230  }
4231 }

◆ ReadOpenness()

void Landscape::ReadOpenness ( void  )

Reads openness values from a standard input file for all polygons.

◆ ReadPolys()

void Landscape::ReadPolys ( const char *  a_polyfile)
protected

◆ ReadPolys2()

void Landscape::ReadPolys2 ( const char *  a_polyfile)
protected

reads in polygon information. Version 2 including centroid and openness information

The polygon file consists of 9 columns:

  1. Polygon Number 2. Type 3. Area as a double 4. Owner (-1 = now owner), 5- -1 or unsprayed margin polynum
    , column 6 is soil type (-1 if not used), column 7 is the polygon openness score (-1 if unset), 8 is the x-coordinate of the centroid, and 9 is the y-coordinate of the centroid. If either of these centroid coords are -1, then the centroid calculation will be forced.
    If this is to be used then cfg_map_usesoiltypes needs to be set as true (default true).

As of December 2014 there is a header row of information to be skipped here

As of July 2013 we have the need to use really big maps, hence polygon reference numbers need to be kept within reasonable bounds. It is now a requirement that any polyref number is < twice the total number of polygons in the file.

This is a quick way to replace one type with another for some simulations, polygon type 150 therefore has some special uses

With the polygons renumbered, we can safely set the hb_first_free_poly_num to the number of polygons we have.

1893 {
1900  // Need to figure out if the farms are already renumbered - as the Farm manager
1901  bool farmsrenum = m_FarmManager->GetIsRenumbered();
1902 
1903  int NoPolygons;
1904  string rubbish = ""; //put here the names of the parameters;
1905  ifstream ifile(a_polyfile);
1906  if (!ifile.is_open()) {
1907  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Unable to open file", a_polyfile);
1908  std::exit(1);
1909  }
1910  char error_num[20];
1911  // First read the number of polygons
1912  ifile >> NoPolygons;
1913  m_elems.resize(NoPolygons);
1915  for (int i = 0; i < 9; i++){ ifile >> rubbish; }
1919  int np = NoPolygons;
1920  if (NoPolygons < 10000) np = 10000; // this is just to cope with old maps with < 10000 polygons that do not follow the rules for new maps
1921  m_polymapping.resize(np * 2);
1922 
1923  // Set all mappings to unused.
1924  for (int i = 0; i < np * 2; i++) {
1925  m_polymapping[i] = -1;
1926  }
1927 
1928  int ElemIndex = 0;
1929 
1930  for (int x = 0; x < NoPolygons; x++)
1931  {
1932  int PolyNum, Owner, PolyType, RealPolyType, URef, SoilType, openness, Centroid_x, Centroid_y;
1933  TTypesOfLandscapeElement Type;
1934  float Area;
1935  ifile >> PolyType >> PolyNum >> Area >> Owner >> URef >> SoilType >> openness >> Centroid_x >> Centroid_y;
1936  // Here we make some tests to check input validity
1937  if ((SoilType > 16) || (PolyNum<0))
1938  {
1939  std::sprintf(error_num, "%d", NoPolygons);
1940  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Polygon file empty before "
1941  "reading number of specified polygons (old polygon file format?):", error_num);
1942  std::exit(1);
1943  }
1944 
1945  // Owner is the farm number or -1. If farms have not been renumbered then this needs mapped to the index in the list of farms.
1946  // Because we create this sequentially in Farm.cpp we have a constant index.
1947  if ((-1 != Owner) && !farmsrenum)
1948  {
1949  // Need to replace the Owner with the new renumbered ref.
1950  Owner = m_FarmManager->GetRenumberedFarmRef(Owner);
1951  }
1952 
1953  RealPolyType = PolyType;
1955  if (PolyType == 150)
1956  {
1957  PolyType = l_map_chameleon_replace_num.value();
1958  }
1959 
1960  Type = g_letype->TranslateEleTypes(PolyType);
1961  if (Type == tole_Missing)
1962  {
1964  }
1965  if (-1 == m_polymapping[PolyNum])
1966  {
1967  // First time we have encountered this polygon number.
1968  // Borders are not mapped in this list.
1969  m_polymapping[PolyNum] = ElemIndex;
1970  LE * newland = NewElement(Type);
1971  m_elems[ElemIndex++] = newland;
1972  newland->SetPoly(PolyNum);
1973  newland->SetMapIndex(PolyNum);
1974  newland->SetArea(floor(0.5 + Area));
1975  newland->SetALMaSSEleType(RealPolyType);
1976  newland->SetSoilType(SoilType);
1977  newland->SetUnsprayedMarginPolyRef(URef);
1978  newland->SetCentroid(Centroid_x,Centroid_y);
1979  newland->SetOpenness(openness);
1980  // Just for fun, or maybe because we might need it later, remember the actual largest polynum used
1981  if (PolyNum>m_LargestPolyNumUsed) m_LargestPolyNumUsed = PolyNum;
1982  // Now set any centroid or openness recalcuation flags
1983  if ((Centroid_x < 0) || (Centroid_y < 0)) m_NeedCentroidCalculation= true;
1984  if (openness < 0) m_NeedOpennessCalculation = true;
1985  // Two types of possible errors: Landscape element that is a field,
1986  // but doesn't belong to a farm, or a farm element not of type field.
1987  // Check for both cases.
1988  if (-1 == Owner && (Type == tole_Field || Type == tole_YoungForest || Type == tole_Orchard || Type == tole_PermPastureTussocky || Type == tole_PermPasture || Type == tole_PermanentSetaside || Type == tole_PermPastureLowYield || Type == tole_WoodyEnergyCrop || Type == tole_Vildtager || Type == tole_PlantNursery)) {
1989  // No owner but field polygon.
1990  sprintf(error_num, "%d", PolyNum);
1991  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Farm polygon does not belong to a farm:", error_num);
1992  exit(1);
1993  }
1994  if (-1 != Owner && Type != tole_Field && Type != tole_YoungForest && Type != tole_Orchard && Type != tole_PermPastureTussocky && Type != tole_PermPasture && Type != tole_PermanentSetaside && Type != tole_PermPastureLowYield && Type != tole_WoodyEnergyCrop && Type != tole_Vildtager && Type != tole_PlantNursery) {
1995  // An owner but not field elements.
1996  sprintf(error_num, "%d", PolyNum);
1997  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Farm polygon does not have element type tole_Field:", error_num);
1998  exit(1);
1999  }
2000 
2001  if (-1 != Owner)
2002  {
2003  m_FarmManager->ConnectFarm(Owner);
2004  m_FarmManager->AddField(Owner, newland, Owner);
2005  if (g_map_le_borders.value())
2006  {
2007  if (random(100) < g_map_le_border_chance.value())
2008  {
2009  // This is a farm element, so signal adding a border.
2010  newland->SetBorder((LE *)1);
2011  }
2012  }
2013  // Code to generate unsprayed margins....
2014  if (newland->GetElementType() == tole_Field)
2015  {
2016  if (g_map_le_unsprayedmargins.value())
2017  {
2018  if (random(100) < g_map_le_unsprayedmargins_chance.value())
2019  {
2020  // This is a farm field, so signal adding a margin
2021  newland->SetUnsprayedMarginPolyRef(1);
2022  }
2023  }
2024  }
2025  // ..to here
2026  }
2027  }
2028  else {
2029  sprintf(error_num, "%d", PolyNum);
2030  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Duplicate polygon in file", error_num);
2031  exit(1);
2032  }
2033  }
2034  ifile.close();
2036  hb_first_free_poly_num = m_elems[NoPolygons - 1]->GetPoly() + 1;
2037 }

References g_letype, l_map_chameleon_replace_num(), m_polymapping, random(), LE::SetArea(), LE::SetBorder(), LE::SetMapIndex(), LE::SetOpenness(), LE::SetPoly(), LE::SetSoilType(), LE::SetUnsprayedMarginPolyRef(), and LE_TypeClass::TranslateEleTypes().

◆ ReadSymbols()

bool Landscape::ReadSymbols ( const char *  a_cfgfile)
inline
788  {
789  return g_cfg->ReadSymbols( a_cfgfile );
790  }

◆ RebuildPolyMapping()

void Landscape::RebuildPolyMapping ( )
inlineprotected
214  { // Rebuild m_polymapping.
215  unsigned int sz = (int)m_elems.size();
216  for (unsigned int i = 0; i < sz; i++)
217  {
218  m_polymapping[m_elems[i]->GetMapIndex()] = i;
219  }
220  }

References m_elems, and m_polymapping.

◆ RecordGooseNumbers()

void Landscape::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()

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()
Note that the record is the for the day before because this method is called by DoFirst, so there are no geese today

3329 {
3335  int day = SupplyDayInYear();
3336  m_elems[m_polymapping[a_polyref]]->SetGooseNos(a_number, day);
3337 }

References m_polymapping.

◆ RecordGooseNumbersTimed()

void Landscape::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()

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()

3342 {
3347  int day = SupplyDayInYear();
3348  m_elems[m_polymapping[a_polyref]]->SetGooseNosTimed(a_number, day);
3349 }

References m_polymapping.

◆ RecordGooseRoostDist()

void Landscape::RecordGooseRoostDist ( int  a_polyref,
int  a_dist,
GooseSpecies  a_goose 
)

Records the distance to the closest roost of goose species.

This records the distance to the closest roost for a goose species.

3373  {
3377  m_elems[m_polymapping[a_polyref]]->SetGooseRoostDist(a_dist, a_goose);
3378  }

References m_polymapping.

◆ RecordGooseSpNumbers()

void Landscape::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()

This records the number of geese on the polygon the day before by species. 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()
Note that the record is the for the day before because this method is called by DoFirst, so there are no geese today

3352  {
3359  int day = SupplyDayInYear();
3360  m_elems[m_polymapping[a_polyref]]->SetGooseSpNos(a_number, day, a_goose);
3361  }

References m_polymapping.

◆ RecordGooseSpNumbersTimed()

void Landscape::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()

This records the number of geese on the polygon the day before at a predefined time by species. 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()

3363  {
3369  int day = SupplyDayInYear();
3370  m_elems[m_polymapping[a_polyref]]->SetGooseSpNosTimed(a_number, day, a_goose);
3371  }

References m_polymapping.

◆ ReleaseOsmiaNest()

void Landscape::ReleaseOsmiaNest ( int  a_x,
int  a_y 
)
inline

Reopen the osmia nest here

871  {
872  m_elems[m_land->Get(a_x, a_y)]->ReleaseOsmiaNest();
873  }

References m_elems, and m_land.

◆ RemoveMissingValues()

void Landscape::RemoveMissingValues ( void  )
protected

A method for replacing missing values in the map with corrected ones - slow.

2091 {
2092  bool found; // the flag for something left to work with
2093  int mapwidth = m_land->MapWidth();
2094  int mapheight = m_land->MapHeight();
2095  int counter = 0;
2096  do
2097  {
2098  found = false; counter++;
2099  for (int x = 1; x < mapwidth-1; x++)
2100  {
2101  for (int y = 1; y < mapheight-1; y++)
2102  {
2103  int apoly = m_land->Get(x,y);
2104  if (m_elems[m_polymapping[apoly]]->GetElementType() == tole_Missing)
2105  {
2106  m_land->MissingCellReplace(x, y, true);
2107  }
2108  }
2109  }
2110  counter++;
2111  } while (counter<50);
2112  // Now we only have the edges to deal with
2113  for (int x = 0; x < mapwidth; x++)
2114  {
2115  for (int y = 0; y < mapheight; y++)
2116  {
2117  int apoly = m_land->Get(x, y);
2118  if (m_elems[m_polymapping[apoly]]->GetElementType() == tole_Missing)
2119  {
2120  found = true;
2121  counter++;
2122  m_land->MissingCellReplaceWrap(x, y, true);
2123  }
2124  }
2125  }
2126  // Now we the ones that are not next to fields to deal with
2127 }

References m_polymapping.

◆ RemoveSmallPolygons()

int Landscape::RemoveSmallPolygons ( void  )
protected

Removes small polygons from the map.

The method removes small polygons from the map and joins them with polygons that are close too them - there different rules depending on the type of polygon we have. Some small polygons can be legal, others need something done. Field polygons with management also have some minimum restrictions which are different from normal polygons.
This method is not written for efficiency, so simple brute force approaches are taken - it will take time to execute.

Rules:

  • Linear features: Isolated cells of these are possible, but they should not be separate polygons. These need to be joined together to form bigger, if not contiguous polygons
  • other 1m cell polygons need to be removed and replaced with the most common surrounding cell
  • Field polygons: If they are less than 1000m2 then they are assumed to be grassland
2185 {
2199  // To be sure we first count the map squares
2200  CountMapSquares();
2201  // Then force the area to match the counted squares
2202  ForceArea();
2203  // Next find polygons that don't match other rules and are single cells - remove these
2204  int removed = 0;
2205  for (int i = 0; i < m_elems.size(); i++)
2206  {
2207  TTypesOfLandscapeElement tole = m_elems[i]->GetElementType();
2208  int area = int(m_elems[i]->GetArea());
2209  if (area == 1)
2210  {
2211  switch (tole)
2212  {
2213  case tole_FieldBoundary:
2214  case tole_HedgeBank:
2215  case tole_Hedges:
2216  case tole_IndividualTree:
2217  case tole_MetalledPath:
2218  case tole_River:
2219  case tole_RiversidePlants:
2220  case tole_RiversideTrees:
2221  case tole_RoadsideSlope:
2222  case tole_RoadsideVerge:
2223  case tole_SmallRoad:
2224  case tole_StoneWall:
2225  case tole_Fence:
2226  case tole_Stream:
2227  case tole_Track:
2228  case tole_UnsprayedFieldMargin:
2229  case tole_WaterBufferZone:
2230  // These could be part of a bigger polygon, so leave them alone for now.
2231  break;
2232  default:
2233  // Get rid of this one.
2234  APoint pt = m_elems[i]->GetCentroid();
2235  // Just check that the centroid is correct
2236  int poly = m_elems[i]->GetPoly();
2237  if (poly != i)
2238  {
2239  g_msg->Warn(WARN_FILE, "Landscape::RemoveSmallPolygons: Centroid not in polygon: ", i);
2240  exit(99);
2241  }
2242  // The next line just fixes the map, and replaces the cell value
2243  if (m_land->CellReplacementNeighbour(pt.m_x, pt.m_y, poly) == 1) {
2244  // Now we need to remove the polygon. This means we must also rebuild the map later.
2245  m_elems[i]->SetMapValid(false);
2246  removed++;
2247  }
2248  }
2249  }
2250  // Field removal below 100m2
2251  else if (tole == tole_Field)
2252  {
2253  if (area < 100) {
2254  // Need to copy the useful information to new grassland element and switch that one in, removing the field.
2255  NaturalGrassDry* grass = new NaturalGrassDry;
2256  grass->DoCopy(m_elems[i]);
2257  grass->SetALMaSSEleType(g_letype->BackTranslateEleTypes(tole_NaturalGrassDry));
2258  grass->SetElementType(tole_NaturalGrassDry);
2259  grass->SetOwner(NULL,-1,-1);
2260  delete m_elems[i]; // remove the old LE
2261  m_elems[i] = dynamic_cast<LE*>(grass);
2262  }
2263  }
2264  }
2266  ChangeMapMapping();
2267  return removed;
2268 }

References LE_TypeClass::BackTranslateEleTypes(), LE::DoCopy(), g_letype, APoint::m_x, APoint::m_y, and LE::SetOwner().

◆ ResetGrainAndMaize()

void Landscape::ResetGrainAndMaize ( )

Resets all grain.

To avoid grain from previous years sticking onto fields and confusing the goose foraging model, we make a hard reset of everything.

731 {
736  for (unsigned int i = 0; i < m_elems.size(); i++)
737  {
738  m_elems[i]->SetBirdSeed(0.0);
739  m_elems[i]->SetBirdMaize(0.0);
740  }
741 }

◆ RodenticidePredatorsEvaluation()

void Landscape::RodenticidePredatorsEvaluation ( RodenticidePredators_Population_Manager a_rppm)
3033 {
3034  for (unsigned i=0; i<m_elems.size(); i++) {
3035  a_rppm->PreCachePoly(m_elems[i]->GetPoly());
3036  }
3037 }

References RodenticidePredators_Population_Manager::PreCachePoly().

Referenced by RodenticidePredators_Population_Manager::CreatHabitatQualGrid().

◆ SetBirdMaizeForage()

void Landscape::SetBirdMaizeForage ( int  a_polyref,
double  a_fooddensity 
)
inline

Sets the maize forage resource as seen from a goose standpoint at a polygon.

535  {
536  m_elems[ m_polymapping[ a_polyref ] ]->SetBirdMaize( a_fooddensity );
537  }

References m_elems, and m_polymapping.

◆ SetBirdSeedForage()

void Landscape::SetBirdSeedForage ( int  a_polyref,
double  a_fooddensity 
)
inline

Sets the grain forage resource as seen from a goose standpoint at a polygon.

529  {
530  m_elems[m_polymapping[a_polyref]]->SetBirdSeed(a_fooddensity);
531  }

References m_elems, and m_polymapping.

◆ SetLESignal()

void Landscape::SetLESignal ( int  a_polyref,
LE_Signal  a_signal 
)
3570  {
3571  m_elems[m_polymapping[a_polyref]]->SetSignal(a_signal);
3572 }

References m_polymapping.

◆ SetMaleNewtPresent()

void Landscape::SetMaleNewtPresent ( int  a_InPondIndex)
inline

Sets a male as being present in a pond.

349 { m_elems[a_InPondIndex]->SetMaleNewtPresent(true); }

References m_elems.

◆ SetPolymapping()

void Landscape::SetPolymapping ( int  a_index,
int  a_val 
)
inline
182 { m_polymapping[a_index] = a_val; }

References m_polymapping.

◆ SetPolyMaxMinExtents()

void Landscape::SetPolyMaxMinExtents ( void  )
1623 {
1624  // All polygon manipulation is settled now we need to give the polygons some information about themselves
1625  // This takes a little time but save time later one
1626  cout << "Setting max min polygon extents" << endl;
1627  int mwidth = m_land->MapWidth();
1628  int mheight = m_land->MapHeight();
1629  for ( int x = 0; x < mwidth; x++ ) {
1630  for ( int y = 0; y < mheight; y++ ) {
1631  int polyindex = m_land->Get( x, y );
1632  // Mark that we have seen this polygon.
1633  unsigned int ele_ref= polyindex;
1634  if (m_elems[m_polymapping[ele_ref]]->GetMaxX() < x) m_elems[m_polymapping[ele_ref]]->SetMaxX(x);
1635  if (m_elems[m_polymapping[ele_ref]]->GetMaxY() < y) m_elems[m_polymapping[ele_ref]]->SetMaxY(y);
1636  if (m_elems[m_polymapping[ele_ref]]->GetMinX() > x) m_elems[m_polymapping[ele_ref]]->SetMinX(x);
1637  if (m_elems[m_polymapping[ele_ref]]->GetMinY() > y) m_elems[m_polymapping[ele_ref]]->SetMinY(y);
1638  m_elems[m_polymapping[ele_ref]]->SetMapValid(true);
1639  }
1640  }
1641 }

References m_polymapping.

◆ SetThePopManager()

void Landscape::SetThePopManager ( Population_Manager a_ptr)
inline

Set the pointer to the current main population manager.

177 { m_ThePopManager = a_ptr; }

References m_ThePopManager.

Referenced by main().

◆ SimulationClosingActions()

void Landscape::SimulationClosingActions ( )

These are the things that are needed to be done after the simulation ends, but before landscape objects are deleted.

1456 {
1461  if(cfg_OptimisingFarms.value()){
1462  this->m_FarmManager->PrintFinalResults();
1463  }
1464 }

References cfg_OptimisingFarms.

Referenced by CloseDownSim().

◆ SkylarkEvaluation()

void Landscape::SkylarkEvaluation ( SkTerritories *  a_skt)
3025  {
3026  for (unsigned i=0; i<m_elems.size(); i++) {
3027  a_skt->PreCachePoly(m_elems[i]->GetPoly());
3028  }
3029 }

◆ StepOneValid()

bool Landscape::StepOneValid ( int  a_polyindex,
int  a_x,
int  a_y,
int  step 
)
protected
2430 {
2431  int index;
2432  int x_add[ 8 ] = { 1*a_step, 1*a_step, 0, -1*a_step, -1*a_step, -1*a_step, 0, 1*a_step };
2433  int y_add[ 8 ] = { 0, -1*a_step, -1*a_step, -1*a_step, 0, 1*a_step, 1*a_step, 1*a_step };
2434  int width = m_land->MapWidth();
2435  int height = m_land->MapHeight();
2436  // Scan anti-clockwise from center pixel coordinate.
2437  for ( unsigned int i = 0; i < 8; i++ ) {
2438  if ( ( a_x + x_add[ i ] < width ) && ( a_x + x_add[ i ] >= 0 ) && ( a_y + y_add[ i ] < height ) && ( a_y + y_add[ i ] >= 0 ) )
2439  {
2440  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2441  if ( index == a_polyindex )
2442  {
2443  m_elems[a_polyindex]->SetValidXY(a_x + x_add[ i ], a_y + y_add[ i ]);
2444  return true;
2445  }
2446  }
2447  }
2448  return false;
2449 }

◆ SubtractPondLarvalFood()

bool Landscape::SubtractPondLarvalFood ( double  a_food,
int  a_polyrefindex 
)

Removes larval food from a pond and returns true if it was possible, otherwise false.

664  {
665  return dynamic_cast<Pond*>(m_elems[a_polyrefindex])->SubtractLarvalFood(a_food);
666 }

◆ SupplyBirdMaizeForage() [1/2]

double Landscape::SupplyBirdMaizeForage ( int  a_polyref)
inline

Returns the maize forage resource.

628  {
629  return m_elems[m_polymapping[a_polyref]]->GetBirdMaize();
630  }

References m_elems, and m_polymapping.

◆ SupplyBirdMaizeForage() [2/2]

double Landscape::SupplyBirdMaizeForage ( int  a_x,
int  a_y 
)
inline

Returns the maize forage resource as seen from a goose standpoint at an x,y location.

640  {
641  return m_elems[ m_land->Get( a_x, a_y ) ]->GetBirdMaize();
642  }

References m_elems, and m_land.

◆ SupplyBirdSeedForage() [1/2]

double Landscape::SupplyBirdSeedForage ( int  a_polyref)
inline

Returns the grain forage resource.

615  {
616  return m_elems[m_polymapping[a_polyref]]->GetBirdSeed();
617  }

References m_elems, and m_polymapping.

◆ SupplyBirdSeedForage() [2/2]

double Landscape::SupplyBirdSeedForage ( int  a_x,
int  a_y 
)
inline

Returns the grain forage resource as seen from a goose standpoint at an x,y location.

622  {
623  return m_elems[m_polymapping[m_land->Get(a_x, a_y)]]->GetBirdSeed();
624  }

References m_elems, m_land, and m_polymapping.

◆ SupplyCentroid()

APoint Landscape::SupplyCentroid ( int  a_polyref)
766  {
767  return m_elems[ m_polymapping[ a_polyref ] ]->GetCentroid();
768 }

References m_polymapping.

◆ SupplyCentroidIndex()

APoint Landscape::SupplyCentroidIndex ( int  a_polyrefindex)
771  {
772  return m_elems[ a_polyrefindex ]->GetCentroid();
773 }

◆ SupplyCentroidX() [1/2]

int Landscape::SupplyCentroidX ( int  a_polyref)
inline
470  {
471  return m_elems[ m_polymapping[ a_polyref ] ]->GetCentroidX();
472  }

References m_elems, and m_polymapping.

◆ SupplyCentroidX() [2/2]

int Landscape::SupplyCentroidX ( int  a_x,
int  a_y 
)
inline
474 { return m_elems[ m_land->Get( a_x, a_y )]->GetCentroidX(); }

References m_elems, and m_land.

◆ SupplyCentroidY() [1/2]

int Landscape::SupplyCentroidY ( int  a_polyref)
inline
473 { return m_elems[m_polymapping[ a_polyref ]]->GetCentroidY(); }

References m_elems, and m_polymapping.

◆ SupplyCentroidY() [2/2]

int Landscape::SupplyCentroidY ( int  a_x,
int  a_y 
)
inline
475 { return m_elems[ m_land->Get( a_x, a_y )]->GetCentroidY(); }

References m_elems, and m_land.

◆ SupplyCountryDesig()

int Landscape::SupplyCountryDesig ( int  a_x,
int  a_y 
)
inline
1133 {
1134  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCountryDesignation();
1135 }

References m_elems, and m_land.

◆ SupplyDayDegrees()

double Landscape::SupplyDayDegrees ( int  a_polyref)
inline
1327 {
1328  return m_elems[ m_polymapping[ a_polyref ]]->GetDayDegrees();
1329 }

References m_elems, and m_polymapping.

◆ SupplyDayInMonth()

int Landscape::SupplyDayInMonth ( void  )
inline
1607 {
1608  return g_date->GetDayInMonth();
1609 }

Referenced by RunTheSim().

◆ SupplyDayInYear()

int Landscape::SupplyDayInYear ( void  )
inline
1597 {
1598  return g_date->DayInYear();
1599 }

◆ SupplyDaylength() [1/2]

int Landscape::SupplyDaylength ( long  a_date)
inline
1524 {
1525  return g_date->DayLength( a_date );
1526 }

◆ SupplyDaylength() [2/2]

int Landscape::SupplyDaylength ( void  )
inline
1531 {
1532  return g_date->DayLength();
1533 }

◆ SupplyDaylightProp()

double Landscape::SupplyDaylightProp ( )
inline
825 { return g_date->GetDaylightProportion(); }

◆ SupplyDeadBiomass() [1/2]

double Landscape::SupplyDeadBiomass ( int  a_polyref)
inline
1030 {
1031  return m_elems[ m_polymapping[ a_polyref ]]->GetDeadBiomass();
1032 }

References m_elems, and m_polymapping.

◆ SupplyDeadBiomass() [2/2]

double Landscape::SupplyDeadBiomass ( int  a_x,
int  a_y 
)
inline
1035 {
1036  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDeadBiomass();
1037 }

References m_elems, and m_land.

◆ SupplyElementSubType() [1/2]

int Landscape::SupplyElementSubType ( int  a_polyref)
inline
1122 {
1123  return m_elems[ m_polymapping[ a_polyref ]]->GetSubType();
1124 }

References m_elems, and m_polymapping.

◆ SupplyElementSubType() [2/2]

int Landscape::SupplyElementSubType ( int  a_x,
int  a_y 
)
inline
1127 {
1128  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSubType();
1129 }

References m_elems, and m_land.

◆ SupplyElementType() [1/2]

TTypesOfLandscapeElement Landscape::SupplyElementType ( int  a_polyref)
inline
1111 {
1112  return m_elems[ m_polymapping[ a_polyref ]]->GetElementType();
1113 }

References m_elems, and m_polymapping.

Referenced by RodenticidePredators_Population_Manager::EvaluatePoly(), and MovementMap::Init().

◆ SupplyElementType() [2/2]

TTypesOfLandscapeElement Landscape::SupplyElementType ( int  a_x,
int  a_y 
)
inline
1116 {
1117  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1118 }

References m_elems, and m_land.

◆ SupplyElementTypeCC()

TTypesOfLandscapeElement Landscape::SupplyElementTypeCC ( int  a_x,
int  a_y 
)
inline
1140 {
1141  a_x = (a_x + m_width10) % m_width;
1142  a_y = (a_y + m_height10) % m_height;
1143  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1144 }

References m_elems, m_height, m_height10, m_land, m_width, and m_width10.

◆ SupplyElementTypeFromVector()

TTypesOfLandscapeElement Landscape::SupplyElementTypeFromVector ( unsigned int  a_index)
inline
1105 {
1106  return m_elems[ a_index ]->GetElementType();
1107 }

References m_elems.

◆ SupplyFarmAnimalCensus()

int Landscape::SupplyFarmAnimalCensus ( int  a_farm_ref,
int  a_LifeStage 
)
746 {
747  return m_ThePopManager->FarmAnimalCensus(a_farm_ref, a_LifeStage);
748 }

◆ SupplyFarmArea()

int Landscape::SupplyFarmArea ( int  a_polyref)
inline
1207 {
1208  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetArea();
1209 }

References m_elems, and m_polymapping.

◆ SupplyFarmIntensity() [1/2]

int Landscape::SupplyFarmIntensity ( int  a_polyref)
761  {
762  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetIntensity();
763 }

References m_polymapping.

◆ SupplyFarmIntensity() [2/2]

int Landscape::SupplyFarmIntensity ( int  a_x,
int  a_y 
)
756  {
757  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner()->GetIntensity();
758 }

Referenced by VegElement::DoDevelopment(), and VegElement::RecalculateBugsNStuff().

◆ SupplyFarmIntensityI()

int Landscape::SupplyFarmIntensityI ( int  a_polyindex)
751  {
752  return m_elems[ a_polyindex ]->GetOwner()->GetIntensity();
753 }

◆ SupplyFarmManagerPtr()

FarmManager* Landscape::SupplyFarmManagerPtr ( )
inline
353 { return m_FarmManager; }

References m_FarmManager.

◆ SupplyFarmOwner() [1/2]

int Landscape::SupplyFarmOwner ( int  a_polyref)
inline
1159 {
1160  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerFile();
1161 }

References m_elems, and m_polymapping.

◆ SupplyFarmOwner() [2/2]

int Landscape::SupplyFarmOwner ( int  a_x,
int  a_y 
)
inline
1152  {
1153  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerFile();
1154 }

References m_elems, and m_land.

◆ SupplyFarmOwnerIndex() [1/2]

int Landscape::SupplyFarmOwnerIndex ( int  a_polyref)
inline
1173 {
1174  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerIndex();
1175 }

References m_elems, and m_polymapping.

◆ SupplyFarmOwnerIndex() [2/2]

int Landscape::SupplyFarmOwnerIndex ( int  a_x,
int  a_y 
)
inline
1166 {
1167  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerIndex();
1168 }

References m_elems, and m_land.

◆ SupplyFarmPtr()

Farm* Landscape::SupplyFarmPtr ( int  a_owner)
inline
352 { return m_FarmManager->GetFarmPtr(a_owner); }

References m_FarmManager.

◆ SupplyFarmType() [1/2]

TTypesOfFarm Landscape::SupplyFarmType ( int  a_polyref)
inline
1180 {
1181  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetType();
1182 }

References m_elems, and m_polymapping.

◆ SupplyFarmType() [2/2]

TTypesOfFarm Landscape::SupplyFarmType ( int  a_x,
int  a_y 
)
inline
1187 {
1188  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner()->GetType();
1189 }

References m_elems, and m_land.

◆ SupplyGlobalDate()

long Landscape::SupplyGlobalDate ( void  )
inline
1622 {
1623  return g_date->Date();
1624 }

◆ SupplyGlobalRadiation() [1/2]

double Landscape::SupplyGlobalRadiation ( )
inline
1342 {
1343  return g_weather->GetGlobalRadiation( );
1344 }

Referenced by VegElement::RecalculateBugsNStuff().

◆ SupplyGlobalRadiation() [2/2]

double Landscape::SupplyGlobalRadiation ( long  a_date)
inline
1347 {
1348  return g_weather->GetGlobalRadiation( a_date );
1349 }

◆ SupplyGooseGrazingForageH() [1/2]

double Landscape::SupplyGooseGrazingForageH ( double  a_height,
GooseSpecies  a_goose 
)
inline

Returns the leaf forage resource as seen from a goose standpoint at a polygon based on the height only.

Parameters
a_height[in] The vegetation height (assumed grass or cereals). This needs to be checked before calling
a_goose[in] Is the type of goose calling which is needed to determine how to assess the value of the current forage availability (ie its different for different types of geese)
Returns
KJ/min
542  {
548  if (a_goose == gs_Pinkfoot)
549  {
550  return m_GooseIntakeRateVSVegetationHeight_PF->GetY( a_height );
551  }
552  if (a_goose == gs_Barnacle)
553  {
554  if (a_height == 0.0) return 0.0;
555  else return m_GooseIntakeRateVSVegetationHeight_BG->GetY(a_height);
556  }
557  if (a_goose == gs_Greylag)
558  {
559  return m_GooseIntakeRateVSVegetationHeight_GL->GetY(a_height);
560  }
561  Warn("Landscape::SupplyGooseGrazingForage", "Unknown Goose Type");
562  exit(1);
563  }

References m_GooseIntakeRateVSVegetationHeight_BG, m_GooseIntakeRateVSVegetationHeight_GL, m_GooseIntakeRateVSVegetationHeight_PF, and Warn().

Referenced by VegElement::CalcGooseForageResources().

◆ SupplyGooseGrazingForageH() [2/2]

double Landscape::SupplyGooseGrazingForageH ( int  a_polygon,
GooseSpecies  a_goose 
)
inline

Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by number based on height only.

Parameters
a_polygon[in] The polygon refence number for the polygon we are interested in (assumed grass or cereals). This needs to be checked before calling
a_goose[in] Is the type of goose calling which is needed to determine how to assess the value of the current forage availability (ie its different for different types of geese)
Returns
KJ/min
568  {
574  if (a_goose == gs_Pinkfoot)
575  {
576  return m_GooseIntakeRateVSVegetationHeight_PF->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
577  }
578  if (a_goose == gs_Barnacle)
579  {
580  return m_GooseIntakeRateVSVegetationHeight_BG->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
581  }
582  if (a_goose == gs_Greylag)
583  {
584  return m_GooseIntakeRateVSVegetationHeight_GL->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
585  }
586  Warn("Landscape::SupplyGooseGrazingForage", "Unknown Goose Type");
587  exit(1);
588  }

References m_elems, m_GooseIntakeRateVSVegetationHeight_BG, m_GooseIntakeRateVSVegetationHeight_GL, m_GooseIntakeRateVSVegetationHeight_PF, m_polymapping, and Warn().

◆ SupplyGrazingPressure() [1/2]

int Landscape::SupplyGrazingPressure ( int  a_polyref)
inline
1228 {
1229  return m_elems[ m_polymapping[ a_polyref ] ]->GetCattleGrazing();
1230 }

References m_elems, and m_polymapping.

◆ SupplyGrazingPressure() [2/2]

int Landscape::SupplyGrazingPressure ( int  a_x,
int  a_y 
)
inline
1240 {
1241  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCattleGrazing();
1242 }

References m_elems, and m_land.

◆ SupplyGrazingPressureVector()

int Landscape::SupplyGrazingPressureVector ( unsigned int  a_index)
inline
1233 {
1234  return m_elems[ a_index ]->GetCattleGrazing();
1235 }

References m_elems.

◆ SupplyGreenBiomass() [1/2]

double Landscape::SupplyGreenBiomass ( int  a_polyref)
inline
1018 {
1019  return m_elems[ m_polymapping[ a_polyref ]]->GetGreenBiomass();
1020 }

References m_elems, and m_polymapping.

◆ SupplyGreenBiomass() [2/2]

double Landscape::SupplyGreenBiomass ( int  a_x,
int  a_y 
)
inline
1023 {
1024  return m_elems[ m_land->Get( a_x, a_y ) ]->GetGreenBiomass();
1025 }

References m_elems, and m_land.

◆ SupplyHasTramlines() [1/2]

bool Landscape::SupplyHasTramlines ( int  a_polyref)
inline
1247 {
1248  return m_elems[ m_polymapping[ a_polyref ] ]->HasTramlines();
1249 }

References m_elems, and m_polymapping.

◆ SupplyHasTramlines() [2/2]

bool Landscape::SupplyHasTramlines ( int  a_x,
int  a_y 
)
inline
1253 {
1254  return m_elems[ m_land->Get( a_x, a_y ) ]->HasTramlines();
1255 }

References m_elems, and m_land.

◆ SupplyHour()

int Landscape::SupplyHour ( void  )
inline

Get the hour of the day.

1586  {
1587  return g_date->GetHour();
1588 }

◆ SupplyHumidity()

double Landscape::SupplyHumidity ( void  )
inline
1394 {
1395  return g_weather->GetHumidity();
1396 }

◆ SupplyInsects() [1/2]

double Landscape::SupplyInsects ( int  a_polyref)
inline
1089 {
1090  return m_elems[ m_polymapping[ a_polyref ]]->GetInsectPop();
1091 }

References m_elems, and m_polymapping.

◆ SupplyInsects() [2/2]

double Landscape::SupplyInsects ( int  a_x,
int  a_y 
)
inline
1094 {
1095  return m_elems[ m_land->Get( a_x, a_y ) ]->GetInsectPop();
1096 }

References m_elems, and m_land.

◆ SupplyInStubble()

bool Landscape::SupplyInStubble ( int  a_polyref)
inline

Returns whether its cereal.

634  {
635  return m_elems[m_polymapping[a_polyref]]->GetStubble();
636  }

References m_elems, and m_polymapping.

◆ SupplyIsCereal()

bool Landscape::SupplyIsCereal ( int  a_polyref)
inline
1301 {
1302  return m_elems[m_polymapping[a_polyref]]->IsCereal();
1303 }

References m_elems, and m_polymapping.

◆ SupplyIsCereal2()

bool Landscape::SupplyIsCereal2 ( TTypesOfVegetation  a_vege_type)
533 {
534  switch (a_vege_type)
535  {
536  case tov_SpringBarley:
537  case tov_SpringBarleySpr:
538  case tov_WinterBarley:
539  case tov_SpringWheat:
540  case tov_WinterWheat:
541  case tov_WinterRye:
542  case tov_Oats:
543  case tov_Triticale:
544  case tov_SpringBarleySeed:
545  case tov_SpringBarleyStrigling:
546  case tov_SpringBarleyStriglingSingle:
547  case tov_SpringBarleyStriglingCulm:
548  case tov_WinterWheatStrigling:
549  case tov_WinterWheatStriglingSingle:
550  case tov_WinterWheatStriglingCulm:
551  case tov_OWinterBarley:
552  case tov_OWinterBarleyExt:
553  case tov_OWinterRye:
554  case tov_SpringBarleyGrass:
555  case tov_SpringBarleyCloverGrass:
556  case tov_SpringBarleyPeaCloverGrassStrigling:
557  case tov_OSpringBarley:
558  case tov_OSpringBarleyPigs:
559  case tov_OWinterWheatUndersown:
560  case tov_OWinterWheat:
561  case tov_OOats:
562  case tov_OTriticale:
563  case tov_WWheatPControl:
564  case tov_WWheatPToxicControl:
565  case tov_WWheatPTreatment:
566  case tov_AgroChemIndustryCereal:
567  case tov_SpringBarleyPTreatment:
568  case tov_SpringBarleySKManagement:
569  case tov_OSpringBarleyExt:
570  case tov_OSpringBarleyGrass:
571  case tov_OSpringBarleyClover:
572  case tov_PLWinterWheat:
573  case tov_PLWinterBarley:
574  case tov_PLWinterRye:
575  case tov_PLWinterTriticale:
576  case tov_PLSpringWheat:
577  case tov_PLSpringBarley:
578  case tov_NLWinterWheat:
579  case tov_NLSpringBarley:
580  return true;
581  default: return false;
582 }
583 }

◆ SupplyIsGrass()

bool Landscape::SupplyIsGrass ( int  a_polyref)
inline
1311 {
1312  return m_elems[ m_polymapping[ a_polyref ] ]->IsGrass();
1313 }

References m_elems, and m_polymapping.

◆ SupplyIsGrass2()

bool Landscape::SupplyIsGrass2 ( TTypesOfVegetation  a_vege_type)
504 {
505  switch (a_vege_type)
506  {
507  case tov_NaturalGrass:
508  case tov_PermanentGrassGrazed:
509  case tov_PermanentGrassLowYield:
510  case tov_PermanentGrassTussocky:
511  case tov_PermanentSetaside:
512  case tov_Setaside:
513  case tov_SeedGrass1:
514  case tov_SeedGrass2:
515  case tov_OSeedGrass1:
516  case tov_OSeedGrass2:
517  case tov_CloverGrassGrazed1:
518  case tov_CloverGrassGrazed2:
519  case tov_OCloverGrassGrazed1:
520  case tov_OCloverGrassGrazed2:
521  case tov_OrchardCrop:
522  case tov_YoungForest:
523  case tov_FodderGrass:
524  case tov_Heath:
525  case tov_WaterBufferZone:
526  return true;
527  default: return false;
528  }
529 }

◆ SupplyIsMatureCereal()

bool Landscape::SupplyIsMatureCereal ( int  a_polyref)
inline
1306 {
1307  return m_elems[m_polymapping[a_polyref]]->IsMatureCereal();
1308 }

References m_elems, and m_polymapping.

◆ SupplyJustMown()

bool Landscape::SupplyJustMown ( int  a_polyref)
inline
1264 {
1265  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlyMown();
1266 }

References m_elems, and m_polymapping.

◆ SupplyJustMownVector()

bool Landscape::SupplyJustMownVector ( unsigned int  a_index)
inline
1259 {
1260  return m_elems[ a_index ]->IsRecentlyMown();
1261 }

References m_elems.

◆ SupplyJustSprayed() [1/2]

int Landscape::SupplyJustSprayed ( int  a_polyref)
inline
1276 {
1277  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlySprayed();
1278 }

References m_elems, and m_polymapping.

◆ SupplyJustSprayed() [2/2]

int Landscape::SupplyJustSprayed ( int  a_x,
int  a_y 
)
inline
1281 {
1282  return m_elems[ m_land->Get( a_x, a_y ) ]->IsRecentlySprayed();
1283 }

References m_elems, and m_land.

◆ SupplyJustSprayedVector()

int Landscape::SupplyJustSprayedVector ( unsigned int  a_index)
inline
1271 {
1272  return m_elems[ a_index ]->IsRecentlySprayed();
1273 }

References m_elems.

◆ SupplyLAGreen() [1/2]

double Landscape::SupplyLAGreen ( int  a_polyref)
inline
1042 {
1043  return m_elems[ m_polymapping[ a_polyref ]]->GetLAGreen();
1044 }

References m_elems, and m_polymapping.

◆ SupplyLAGreen() [2/2]

double Landscape::SupplyLAGreen ( int  a_x,
int  a_y 
)
inline
1011 {
1012  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLAGreen();
1013 }

References m_elems, and m_land.

◆ SupplyLargeOpenFieldsNearXY()

polylist * Landscape::SupplyLargeOpenFieldsNearXY ( 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.

There is a limit of 1000 polygons to return. There are probably more speed efficient ways to do this, but the simplest is to simply trawl through the list of polygons and pull out each polygon with an openness score > a_openness - then see if the centroid is within range. NB calling method must delete the polylist* passed back!

18/12/2013 this method has been rendered obselete by changes to hunters referring to famers rather than a co-ordinate and range.

Calculates distance from location a_x, a_y. This is done using an approximation to pythagorus to avoid a speed problem.

NB this will crash if either a_dy or a_dx are zero!

783 {
792  polylist* p_list = new polylist;
793  unsigned sz = (unsigned) m_elems.size();
794  for (unsigned i=0; i<sz; i++)
795  {
796  if ( m_elems[i]->GetOpenness() > a_openness)
797  {
798  APoint pt = m_elems[i]->GetCentroid();
799  int dx, dy;
800  if (a_x>pt.m_x) dx = a_x-pt.m_x; else dx = pt.m_x-a_x;
801  if (a_y>pt.m_y) dy = a_y-pt.m_y; else dy = pt.m_y-a_y;
802  dx++; dy++; // prevents crash with maths below.
804  int dist;
806  if (dx>dy) dist = dx + (dy * dy) /(2 * dx); else dist = dy + (dx * dx) /(2 * dy);
807  if (dist<=a_range) p_list->push_back( m_elems[i]->GetPoly());
808  }
809  }
810  return p_list;
811 }

References APoint::m_x, and APoint::m_y.

◆ SupplyLargestPolyNumUsed()

int Landscape::SupplyLargestPolyNumUsed ( )
inline

◆ SupplyLastSownVeg() [1/2]

TTypesOfVegetation Landscape::SupplyLastSownVeg ( int  a_polyref)
inline
1069 {
1070  return m_elems[m_polymapping[a_polyref]]->GetLastSownVeg();
1071 }

References m_elems, and m_polymapping.

◆ SupplyLastSownVeg() [2/2]

TTypesOfVegetation Landscape::SupplyLastSownVeg ( int  a_x,
int  a_y 
)
inline
1074 {
1075  return m_elems[m_land->Get(a_x, a_y)]->GetLastSownVeg();
1076 }

References m_elems, and m_land.

◆ SupplyLastSownVegVector()

TTypesOfVegetation Landscape::SupplyLastSownVegVector ( unsigned int  a_index)
inline
1064 {
1065  return m_elems[a_index]->GetLastSownVeg();
1066 }

References m_elems.

◆ SupplyLastTreatment() [1/2]

int Landscape::SupplyLastTreatment ( int  a_polyref,
int a_index 
)
inline
1332 {
1333  return m_elems[ m_polymapping[ a_polyref ]]->GetLastTreatment( a_index );
1334 }

References m_elems, and m_polymapping.

◆ SupplyLastTreatment() [2/2]

int Landscape::SupplyLastTreatment ( int  a_x,
int  a_y,
int a_index 
)
inline
1337 {
1338  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLastTreatment( a_index );
1339 }

References m_elems, and m_land.

◆ SupplyLATotal()

double Landscape::SupplyLATotal ( int  a_x,
int  a_y 
)
inline
1005 {
1006  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLATotal();
1007 }

References m_elems, and m_land.

◆ SupplyLECount()

int Landscape::SupplyLECount ( void  )
3562  {
3563  return (int)m_elems.size();
3564 }

◆ SupplyLEHigh()

bool Landscape::SupplyLEHigh ( int  a_x,
int  a_y 
)
inline

Tests whether the polygon at a_x,a_y is designated as high.

455 { return m_elems[ m_land->Get( a_x, a_y ) ]->GetHigh(); }

References m_elems, and m_land.

◆ SupplyLENext()

int Landscape::SupplyLENext ( void  )
3555  {
3556  if ((unsigned int)le_signal_index == m_elems.size()) {
3557  return -1;
3558  }
3559  return m_elems[le_signal_index++]->GetPoly();
3560 }

◆ SupplyLEPointer()

LE * Landscape::SupplyLEPointer ( int  a_polyref)
inline
1100 {
1101  return m_elems[ m_polymapping[ a_polyref ]];
1102 }

References m_elems, and m_polymapping.

Referenced by Field::DoDevelopment(), VegElement::SetVegType(), and UnsprayedMarginScan().

◆ SupplyLEReset()

void Landscape::SupplyLEReset ( void  )
3551  {
3552  le_signal_index = 0;
3553 }

◆ SupplyLESignal()

LE_Signal Landscape::SupplyLESignal ( int  a_polyref)
3566  {
3567  return m_elems[m_polymapping[a_polyref]]->GetSignal();
3568 }

References m_polymapping.

◆ SupplyMagicMapP()

int * Landscape::SupplyMagicMapP ( int  a_x,
int  a_y 
)
inline
1510 {
1511  return m_land->GetMagicP( a_x, a_y );
1512 }

References m_land.

◆ SupplyMaleNewtPresent()

bool Landscape::SupplyMaleNewtPresent ( int  a_InPondIndex)
inline

Determines if a male is present in a pond.

351 { return m_elems[a_InPondIndex]->IsMaleNewtPresent(); }

References m_elems.

◆ SupplyMeanTemp()

double Landscape::SupplyMeanTemp ( long  a_date,
unsigned int  a_period 
)
inline
1373 {
1374  return g_weather->GetMeanTemp( a_date, a_period );
1375 }

◆ SupplyMinute()

int Landscape::SupplyMinute ( void  )
inline

Get the minute of the hour.

1592  {
1593  return g_date->GetMinute();
1594 }

◆ SupplyMonth()

int Landscape::SupplyMonth ( void  )
inline
1602 {
1603  return g_date->GetMonth();
1604 }

Referenced by RunTheSim().

◆ SupplyNectar() [1/2]

PollenNectarQuality Landscape::SupplyNectar ( int  a_polyref)
inline
381 { return m_elems[a_polyref]->GetNectar(); };

References m_elems.

◆ SupplyNectar() [2/2]

PollenNectarQuality Landscape::SupplyNectar ( int  a_x,
int  a_y 
)
inline
382 { return m_elems[m_land->Get(a_x, a_y)]->GetNectar(); };

References m_elems, and m_land.

◆ SupplyNightProp()

double Landscape::SupplyNightProp ( )
inline
826 { return 1.0-g_date->GetDaylightProportion(); }

◆ SupplyNumberOfFarms()

int Landscape::SupplyNumberOfFarms