ALMaSS Rodenticide Model ODdox  1.0
Landscape Class Reference

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

#include <landscape.h>

Public Member Functions

int BackTranslateEleTypes (TTypesOfLandscapeElement EleReference)
 
int BackTranslateVegTypes (TTypesOfVegetation VegReference)
 
void BuildingDesignationCalc ()
 used to calculate whether a building is rural or town - for rodenticide use More...
 
void CalculateCentroids (void)
 
void CalculateOpenness (bool a_realcalc)
 Causes openness to be calulated and stored for all polygons. 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 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...
 
void CentroidSpiralOut (int a_polyref, int &a_x, int &a_y)
 
void CentroidSpiralOutBlocks (int a_polyref, int &a_x, int &a_y)
 
void CorrectCoords (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...
 
APoint CorrectCoordsPt (int x, int y)
 Function to prevent wrap around errors with co-ordinates using x/y pair. More...
 
int CorrectHeight (int y)
 
int CorrectWidth (int x)
 
void DumpAllSymbolsAndExit (const char *a_dumpfile)
 
void DumpCentroids (void)
 
void DumpMapInfoByArea (const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
 
void DumpPublicSymbols (const char *a_dumpfile, CfgSecureLevel a_level)
 
void DumpVegAreaData (int a_day)
 
std::string EventtypeToString (int a_event)
 
void FillVegAreaData ()
 
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...
 
GooseFieldListGetGooseFields (double)
 Gets the list of suitable goose foraging fields today. More...
 
int GetGooseNumbers (int a_poly)
 This returns the number of geese 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...
 
double GetHareFoodQuality (int a_polygon)
 
double GetVegArea (int v)
 
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 HowManyPonds ()
 Returns the number of ponds in the landscape. More...
 
void IncTreatCounter (int a_treat)
 
bool IsFieldType (TTypesOfLandscapeElement a_tole)
 
 Landscape (const char *a_configfile, const char *a_errorfile)
 
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 MagicMapP2PolyRef (int a_magic)
 
std::string PolytypeToString (TTypesOfLandscapeElement a_le_type)
 
void ReadOpenness (void)
 Reads openness values from a standard input file for all polygons. More...
 
bool ReadSymbols (const char *a_cfgfile)
 
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 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 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 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 RodenticidePredatorsEvaluation (RodenticidePredators_Population_Manager *a_rppm)
 
void SetBirdMaizeForage (int a_polyref, double a_fooddensity)
 Sets the maize forage resource as seen from a goose standpoint at a polygon. More...
 
void SetBirdSeedForage (int a_polyref, double a_fooddensity)
 Sets the grain forage resource as seen from a goose standpoint at a polygon. More...
 
void SetLESignal (int a_polyref, LE_Signal a_signal)
 
void SetMaleNewtPresent (int a_InPondIndex)
 Sets a male as being present in a pond. More...
 
void SetPolyMaxMinExtents (void)
 
void SetThePopManager (Population_Manager *a_ptr)
 Set the pointer to the current main population manager. More...
 
void SimulationClosingActions ()
 
void SkylarkEvaluation (SkTerritories *a_skt)
 
bool SubtractPondLarvalFood (double a_food, int a_polyrefindex)
 Removes larval food from a pond and returns true if it was possible, otherwise false. More...
 
double SupplyBirdMaizeForage (int a_polyref)
 Returns the maize forage resource. 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...
 
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...
 
APoint SupplyCentroid (int a_polyref)
 
APoint SupplyCentroidIndex (int a_polyrefindex)
 
int SupplyCentroidX (int a_polyref)
 
int SupplyCentroidX (int a_x, int a_y)
 
int SupplyCentroidY (int a_polyref)
 
int SupplyCentroidY (int a_x, int a_y)
 
int SupplyCountryDesig (int a_x, int a_y)
 
double SupplyDayDegrees (int a_polyref)
 
int SupplyDayInMonth (void)
 
int SupplyDayInYear (void)
 
int SupplyDaylength (void)
 
int SupplyDaylength (long a_date)
 
double SupplyDaylightProp ()
 
double SupplyDeadBiomass (int a_polyref)
 
double SupplyDeadBiomass (int a_x, int a_y)
 
int SupplyElementSubType (int a_polyref)
 
int SupplyElementSubType (int a_x, int a_y)
 
TTypesOfLandscapeElement SupplyElementType (int a_polyref)
 
TTypesOfLandscapeElement SupplyElementType (int a_x, int a_y)
 
TTypesOfLandscapeElement SupplyElementTypeCC (int a_x, int a_y)
 
TTypesOfLandscapeElement SupplyElementTypeFromVector (unsigned int a_index)
 
int SupplyFarmAnimalCensus (int a_farm_ref, int a_LifeStage)
 
int SupplyFarmArea (int a_polyref)
 
int SupplyFarmIntensity (int a_x, int a_y)
 
int SupplyFarmIntensity (int a_polyref)
 
int SupplyFarmIntensityI (int a_polyindex)
 
FarmManager * SupplyFarmManagerPtr ()
 
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)
 
Farm * SupplyFarmPtr (int a_owner)
 
TTypesOfFarm SupplyFarmType (int a_polyref)
 
TTypesOfFarm SupplyFarmType (int a_x, int a_y)
 
long SupplyGlobalDate (void)
 
double SupplyGlobalRadiation ()
 
double SupplyGlobalRadiation (long a_date)
 
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...
 
int SupplyGrazingPressure (int a_polyref)
 
int SupplyGrazingPressure (int a_x, int a_y)
 
int SupplyGrazingPressureVector (unsigned int a_index)
 
double SupplyGreenBiomass (int a_polyref)
 
double SupplyGreenBiomass (int a_x, int a_y)
 
bool SupplyHasTramlines (int a_x, int a_y)
 
bool SupplyHasTramlines (int a_polyref)
 
int SupplyHour (void)
 Get the hour of the day. More...
 
double SupplyHumidity (void)
 
double SupplyInsects (int a_polyref)
 
double SupplyInsects (int a_x, int a_y)
 
bool SupplyIsCereal (int a_polyref)
 
bool SupplyIsGrass (int a_polyref)
 
bool SupplyIsMatureCereal (int a_polyref)
 
bool SupplyJustMown (int a_polyref)
 
bool SupplyJustMownVector (unsigned int a_index)
 
int SupplyJustSprayed (int a_polyref)
 
int SupplyJustSprayed (int a_x, int a_y)
 
int SupplyJustSprayedVector (unsigned int a_index)
 
double SupplyLAGreen (int a_polyref)
 
double SupplyLAGreen (int a_x, int a_y)
 
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 SupplyLargestPolyNumUsed ()
 
TTypesOfVegetation SupplyLastSownVeg (int a_polyref)
 
TTypesOfVegetation SupplyLastSownVeg (int a_x, int a_y)
 
TTypesOfVegetation SupplyLastSownVegVector (unsigned int a_index)
 
int SupplyLastTreatment (int a_polyref, int *a_index)
 
int SupplyLastTreatment (int a_x, int a_y, int *a_index)
 
double SupplyLATotal (int a_x, int a_y)
 
int SupplyLECount (void)
 
bool SupplyLEHigh (int a_x, int a_y)
 Tests whether the polygon at a_x,a_y is designated as high. More...
 
int SupplyLENext (void)
 
LESupplyLEPointer (int a_polyref)
 
void SupplyLEReset (void)
 
LE_Signal SupplyLESignal (int a_polyref)
 
intSupplyMagicMapP (int a_x, int a_y)
 
bool SupplyMaleNewtPresent (int a_InPondIndex)
 Determines if a male is present in a pond. More...
 
double SupplyMeanTemp (long a_date, unsigned int a_period)
 
int SupplyMinute (void)
 Get the minute of the hour. More...
 
int SupplyMonth (void)
 
double SupplyNightProp ()
 
int SupplyNumberOfFarms ()
 
unsigned int SupplyNumberOfPolygons (void)
 
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...
 
TTypesOfOptFarms SupplyOptFarmType (int a_x, int a_y)
 
double SupplyPesticide (int a_x, int a_y)
 Gets total pesticide for a location. More...
 
double SupplyPesticide (int a_polyref)
 Gets total pesticide for the centroid of a polygon. More...
 
int SupplyPesticideCell (int a_polyref)
 
bool SupplyPesticideDecay ()
 Returns true if there is any pesticide in the system at all at this point. More...
 
double SupplyPesticideP (int a_x, int a_y)
 Gets plant pesticide for a location. More...
 
double SupplyPesticideP (int a_polyref)
 Gets plant pesticide for the centroid of a polygon. More...
 
double SupplyPesticideS (int a_x, int a_y)
 Gets soil pesticide for a location. More...
 
double SupplyPesticideS (int a_polyref)
 Gets soil pesticide for the centroid of a polygon. More...
 
TTypesOfPesticide SupplyPesticideType (void)
 
double SupplyPolygonArea (int a_polyref)
 
double SupplyPolygonAreaVector (int a_polyref)
 Returns the area of a polygon using the vector index as a reference. More...
 
int SupplyPolyRef (int a_x, int a_y)
 
int SupplyPolyRefCC (int a_x, int a_y)
 
int SupplyPolyRefIndex (int a_x, int a_y)
 
int SupplyPolyRefVector (unsigned int a_index)
 
int SupplyPondIndex (int a_pondref)
 Returns the index of a pond based on pondref or -1 if not found. More...
 
double SupplyPondPesticide (int a_poly_index)
 Get the pesticide concentration per liter from a pond (must be a pond index on calling) More...
 
double SupplyRain (void)
 
double SupplyRain (long a_date)
 
double SupplyRainPeriod (long a_date, int a_period)
 
int SupplyRandomPondIndex ()
 Returns random pond index. More...
 
int SupplyRandomPondRef ()
 Returns random pond polyref. More...
 
int SupplyRoadWidth (int, int)
 
double SupplyRodenticide (int a_x, int a_y)
 Gets total rodenticide for a location. More...
 
RodenticidePredators_Population_ManagerSupplyRodenticidePredatoryManager ()
 
bool SupplyShouldSpray ()
 
int SupplySimAreaHeight (void)
 
int SupplySimAreaMaxExtent (void)
 
int SupplySimAreaMinExtent (void)
 
int SupplySimAreaWidth (void)
 
bool SupplySkScrapes (int a_polyref)
 
bool SupplySnowcover (void)
 
bool SupplySnowcover (long a_date)
 
double SupplySnowDepth (void)
 
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...
 
double SupplyTemp (void)
 
double SupplyTemp (long a_date)
 
double SupplyTempPeriod (long a_date, int a_period)
 
Population_ManagerSupplyThePopManager ()
 Get the pointer to the current main population manager. More...
 
double SupplyTrafficLoad (int a_x, int a_y)
 
double SupplyTrafficLoad (int a_polyref)
 
int SupplyTreeAge (int a_Polyref)
 
int SupplyTreeAge (int, int)
 
int SupplyTreeHeight (int, int)
 
int SupplyTreeHeight (int)
 
int SupplyUnderGrowthWidth (int, int)
 
int SupplyUnderGrowthWidth (int)
 
int SupplyValidX (int a_polyref)
 
int SupplyValidY (int a_polyref)
 
int SupplyVegAge (int a_Polyref)
 
int SupplyVegAge (int a_x, int a_y)
 
double SupplyVegBiomass (int a_polyref)
 
double SupplyVegBiomass (int a_x, int a_y)
 
double SupplyVegBiomassVector (unsigned int a_index)
 
double SupplyVegCover (int a_polyref)
 
double SupplyVegCover (int a_x, int a_y)
 
double SupplyVegCoverVector (unsigned int a_index)
 
int SupplyVegDensity (int a_polyref)
 
int SupplyVegDensity (int a_x, int a_y)
 
double SupplyVegDigestability (int a_polyref)
 
double SupplyVegDigestability (int a_x, int a_y)
 
double SupplyVegDigestabilityVector (unsigned int a_index)
 
double SupplyVegHeight (int a_polyref)
 
double SupplyVegHeight (int a_x, int a_y)
 
double SupplyVegHeightVector (unsigned int a_index)
 
bool SupplyVegPatchy (int a_polyref)
 
bool SupplyVegPatchy (int a_x, int a_y)
 
int SupplyVegPhase (int a_poly)
 
TTypesOfVegetation SupplyVegType (int a_x, int a_y)
 
TTypesOfVegetation SupplyVegType (int polyref)
 
TTypesOfVegetation SupplyVegTypeVector (unsigned int a_index)
 
const char * SupplyVersion (void)
 
double SupplyWeedBiomass (int a_polyref)
 
double SupplyWeedBiomass (int a_x, int a_y)
 
double SupplyWind (void)
 
double SupplyWind (long a_date)
 
int SupplyWindDirection (void)
 
double SupplyWindPeriod (long a_date, int a_period)
 
int SupplyYear (void)
 
int SupplyYearNumber (void)
 
void Tick (void)
 
TTypesOfLandscapeElement TranslateEleTypes (int EleReference)
 
TTypesOfVegetation TranslateVegTypes (int VegReference)
 
void TurnTheWorld (void)
 
std::string VegtypeToString (TTypesOfVegetation a_veg)
 
void Warn (std::string a_msg1, std::string a_msg2)
 
void WriteOpenness (void)
 Stores openness for all polygons to a standard file. More...
 
 ~Landscape (void)
 

Protected Member Functions

void AddBeetleBanks (TTypesOfLandscapeElement a_tole)
 
void AddGreenElement (LE *a_green)
 
int AddToClusterList (int *, int *, int *, int *, int *)
 
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 BeetleBankAdd (int x, int y, int angle, int length, LE *a_field, TTypesOfLandscapeElement a_tole)
 
bool BeetleBankPossible (LE *a_field, TTypesOfLandscapeElement a_tole)
 
void BorderAdd (LE *a_field, TTypesOfLandscapeElement a_type)
 
bool BorderNeed (TTypesOfLandscapeElement a_letype)
 
void BorderRemoval (void)
 
void BorderScan (LE *a_field, int a_width)
 
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)
 
bool BorderTest (int a_fieldpoly, int a_borderpoly, int a_x, int a_y)
 
void ChangeMapMapping (void)
 
bool CIPELandscapeMaker ()
 
void ConsolidatePolys (void)
 
void CountMapSquares (void)
 
void CreatePondList ()
 Creates a list of pond polygon refs/indexes for easy look up. More...
 
void DegreesDump ()
 Prints the sum of day degrees. See #FarmManager::daydegrees. More...
 
void DumpMap (const char *a_filename)
 
void DumpMapGraphics (const char *a_filename)
 
void DumpTreatCounters (const char *a_filename)
 
void EventDump (int x, int y, int x2, int y2)
 
void EventDumpPesticides (int x1, int y1)
 
bool FindFieldCenter (LE *a_field, int *x, int *y)
 
int FindLongestAxis (int *x, int *y, int *a_length)
 
bool FindValidXY (int a_field, int &a_x, int &a_y)
 
void ForceArea (void)
 
APoint GetNextSeed (int)
 
void GISASCII_Output (string outpfile, int UTMX, int UTMY)
 Write ASCII file of the ALMaSS map. More...
 
void hb_Add (void)
 
void hb_AddNewHedgebanks (int a_orig_poly_num)
 
void hb_Cleanup (void)
 
void hb_ClearPolygon (int a_poly_num)
 
void hb_DownPolyNumbers (void)
 
bool hb_FindBoundingBox (int a_poly_num)
 
void hb_FindHedges (void)
 
void hb_GenerateHBPolys (void)
 
bool hb_HasNeighbourColor (int a_x, int a_y, int a_neighbour_color)
 
bool hb_HasOtherNeighbour (int a_x, int a_y)
 
bool hb_MapBorder (int a_x, int a_y)
 
void hb_MarkTheBresenhamWay (void)
 
void hb_MarkTopFromLocalMax (int a_color)
 
int hb_MaxUnpaintedNegNeighbour (int a_x, int a_y)
 
void hb_PaintBorder (int a_color)
 
bool hb_PaintWhoHasNeighbourColor (int a_neighbour_color, int a_new_color)
 
void hb_ResetColorBits (void)
 
void hb_RestoreHedgeCore (int a_orig_poly_number)
 
int hb_StripingDist (void)
 
void hb_UpPolyNumbers (void)
 
void MakeCluster (void)
 Reset all polygons natural grazing level to zero. More...
 
void ModifyPolyRef (int *)
 
LENewElement (TTypesOfLandscapeElement a_type)
 
void PolysDump (const char *a_filename)
 
void PolysRemoveInvalid (void)
 
void PolysRenumber (void)
 
void PolysValidate (bool a_exit_on_invalid)
 
APoint RandomLocation (void)
 
void ReadInput (int *, int *, int *, APoint *)
 
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 RebuildPolyMapping ()
 
void RemoveMissingValues ()
 A method for replacing missing values in the map with corrected ones - slow. More...
 
int RemoveSmallPolygons (void)
 Removes small polygons from the map. More...
 
bool StepOneValid (int a_polyindex, int a_x, int a_y, int step)
 
void TestCropManagement (void)
 
bool UMarginTest (int a_fieldpoly, int a_borderpoly, int a_x, int a_y, int a_width)
 
void UnsprayedMarginAdd (LE *a_field)
 
void UnsprayedMarginScan (LE *a_field, int a_width)
 
void VegDump (int x, int y)
 

Protected Attributes

int hb_border_pixels
 
int hb_core_pixels
 
int hb_first_free_poly_num
 
vector< inthb_hedges
 
int hb_height
 
inthb_map
 
int hb_max_x
 
int hb_max_y
 
int hb_min_x
 
int hb_min_y
 
vector< LE * > hb_new_hbs
 
int hb_size
 
int hb_width
 
int le_signal_index
 
int m_LargestPolyNumUsed
 
TTypesOfPesticide m_PesticideType
 An attribute to hold the pesticide type being tested, if there is one, if not default is -1. More...
 
vector< intm_PondIndexList
 List of pond indexes. More...
 
vector< intm_PondRefsList
 List of pond polyrefs. More...
 
bool m_toxShouldSpray
 
int m_treatment_counts [last_treatment]
 
int m_x_add [8]
 
int m_y_add [8]
 

Private Attributes

double * l_vegtype_areas
 
bool m_DoMissingPolygonsManipulations
 
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...
 
FarmManager * m_FarmManager
 List of all the farms. More...
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
 Curve relatning goose intake rates in KJ/min to vegetation height. More...
 
int m_height
 
int m_height10
 
RasterMap * m_land
 The big map. More...
 
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...
 
RodenticideManagerm_RodenticideManager
 
RodenticidePredators_Population_Managerm_RodenticidePreds
 
Population_Managerm_ThePopManager
 a pointer to the current main population manager More...
 
char m_versioninfo [30]
 
int m_width
 
int m_width10
 

Detailed Description

The landscape class containing all environmental and topographical data.

Constructor & Destructor Documentation

Landscape::~Landscape ( void  )

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

1249  {
1250  if ( l_map_dump_treatcounts_enable.value() ) {
1252  }
1253 
1254  for ( unsigned int i = 0; i < m_elems.size(); i++ )
1255  delete m_elems[ i ];
1256 
1257  free( m_polymapping );
1258  free( l_vegtype_areas );
1259  delete m_land;
1260  //delete g_rotation;
1261  delete g_crops;
1262  delete g_letype;
1263  delete g_weather;
1264  delete g_date;
1265  delete g_pest;
1266  if (cfg_rodenticide_enable.value())
1267  {
1268  delete m_RodenticideManager;
1269  delete m_RodenticidePreds;
1270  }
1271  delete m_FarmManager;
1272  delete g_msg; // Must be last.
1273 }
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
class Pesticide * g_pest
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
class LE_TypeClass * g_letype
Definition: elements.cpp:265
static CfgBool l_map_dump_treatcounts_enable("MAP_DUMP_TREATCOUNTS_ENABLE", CFG_CUSTOM, false)
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
RasterMap * m_land
The big map.
Definition: landscape.h:122
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
static CfgStr l_map_dump_treatcounts_file("MAP_DUMP_TREATCOUNTS_FILE", CFG_CUSTOM,"treatment_counts.txt")
void DumpTreatCounters(const char *a_filename)
Definition: Landscape.cpp:3344
double * l_vegtype_areas
Definition: landscape.h:141
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
Landscape::Landscape ( const char *  a_configfile,
const char *  a_errorfile 
)

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.

References cfg_AddBeetleBanks(), cfg_BeetleBankType(), cfg_dumpvegjan(), cfg_dumpvegjanfile(), cfg_dumpvegjune(), cfg_dumpvegjunefile(), cfg_HedgeSubtypeMaximum(), cfg_HedgeSubtypeMinimum(), cfg_MaxPondSize(), cfg_pesticidetesttype(), cfg_rodenticide_enable(), LE::DoCopy(), g_letype, g_pest, 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_version_info(), l_map_removesmallpolygons(), l_map_weather_file(), l_map_write_ascii(), random(), LE::SetALMaSSEleType(), LE::SetArea(), LE::SetCentroid(), LE::SetElementType(), LE::SetOpenness(), LE::SetPoly(), LE::SetSoilType(), and LE::SetUnsprayedMarginPolyRef().

671  {
672 
675  // Set up operation flags
676  bool didRenumber = false;
677  bool didCalcCentroids = false;
678  bool didConsolidate = false;
679  bool didCalcOpenness = false;
680  bool didCalcOther = false;
684  // Set up globals
685  g_landscape_p = this;
686  for (int i = 1; i <= 2000; i++) {
687  g_SpeedyDivides[i] = 1 / double(i);
688  }
689  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; // W,SW,S,SE,E,NE,N,NW
690  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
691  for (int i = 0; i < 8; i++) {
692  m_x_add[i] = x_add[i];
693  m_y_add[i] = y_add[i];
694  }
695  //Pinkfeet
696  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());
697  //Barnacle
698  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());
699  //Greylag
700  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());
701  if (cfg_WriteCurve.value()) {
702  m_GooseIntakeRateVSVegetationHeight_GL->WriteDataFile( 10 );
703  m_GooseIntakeRateVSVegetationHeight_BG->WriteDataFile( 10 );
704  m_GooseIntakeRateVSVegetationHeight_PF->WriteDataFile( 10 );
705  }
706 
708 
709  if (l_map_print_version_info.value()) {
710  printf("This program uses the Landscape simulator V%s\n", m_versioninfo);
711  }
712  //g_cfg->DumpAllSymbolsAndExit( "allsymbols.cfg" );
713 
714  // Must come first. Used by the configurator below.
715  g_msg = new MapErrorMsg(a_errorfile);
716  g_msg->SetWarnLevel(WARN_ALL);
717 
718  //g_cfg->DumpAllSymbolsAndExit( "allsymbols.cfg" );
719 
720  // Configurator instantiation is automatic.
721  g_cfg->ReadSymbols(a_configfile);
722  //g_cfg->DumpAllSymbolsAndExit( "allsymbols.cfg" );
723 
724  // For testing.
725  //g_cfg->DumpPublicSymbols( "publicsymbols.cfg", CFG_PUBLIC );
726  //exit(1);
727 
728  g_date = new Calendar;
729  g_weather = new Weather(l_map_weather_file.value());
730  g_letype = new LE_TypeClass;
731  g_crops = new CropData(l_map_cropcurves_file.value());
732 
734 
735  // Reset treatment counters.
736  for (int i = 0; i < last_treatment; i++) {
737  m_treatment_counts[i] = 0;
738  }
739 
740  m_FarmManager = new FarmManager();
741 
742 
743  ReadPolys2(l_map_poly_file.value());
744 
745  //this carries out the optimisation
746  if (cfg_OptimisingFarms.value()){
747  m_FarmManager->InitFarms();
748  m_FarmManager->Save_diff_farm_types_areas();
749  }
750 
751 
752  m_land = new RasterMap(l_map_map_file.value(), this);
753  m_width = m_land->MapWidth();
754  m_height = m_land->MapHeight();
755  m_width10 = 10 * m_width;
756  m_height10 = 10 * m_height;
757  if (m_width > m_height) m_maxextent = m_width; else m_maxextent = m_height;
758 
759  PolysValidate(false);
760 
761  g_pest = new Pesticide(m_land, this);
762  m_toxShouldSpray = false;
763 
764  // Validate polygons, ie. ensure those reference in the
765  // polygon file also shows up in the map.
766  PolysValidate(false);
768 
769  if (cfg_MaxPondSize.value() > 0) {
770  // This takes any small freshwater and converts it to a pond.
771  for (unsigned int i = 0; i < m_elems.size(); i++) {
772  if (m_elems[i]->GetElementType() == tole_Freshwater) {
773  if (m_elems[i]->GetArea() <= cfg_MaxPondSize.value()) {
774  Pond* pond = new Pond;
775  pond->DoCopy(m_elems[i]);
776  pond->SetALMaSSEleType(g_letype->BackTranslateEleTypes(tole_Pond));
777  pond->SetElementType(tole_Pond);
778  m_elems[i] = dynamic_cast<LE*>(pond);
779  }
780  }
781  }
782  }
783 
784  PolysValidate(true);
785 
792  {
793  // Find big continuous polygons
794  for (unsigned int i = 0; i < m_elems.size(); i++)
795  {
796  if (m_elems[i]->GetElementType() == tole_Missing)
797  {
798  double area = m_elems[i]->GetArea();
799  int areaMinrect = (m_elems[i]->GetMaxX() - m_elems[i]->GetMinX()) * (m_elems[i]->GetMaxY() - m_elems[i]->GetMinY());
800  if ((areaMinrect / area > 4) || (area < 1000))
801  {
802  // Unlikely to be a field, or if so a very narrow odd one. We will assume this is a missing data issue.
803  }
804  else
805  {
806  // Big poly with more than 25% of the included rectangle covered, must be a field of some sort.
807  // create a new wasteland and swap this in to the m_elems, then delete the old missing polygon
808  LE * wl = NewElement(tole_Wasteland);
809  wl->SetPoly(m_elems[i]->GetPoly());
810  wl->SetArea(floor(0.5 + area));
811  wl->SetSoilType(m_elems[i]->GetSoilType());
813  wl->SetCentroid(-1, -1);
814  wl->SetOpenness(0);
815  delete m_elems[i];
816  m_elems[i] = wl;
817  }
818  }
819  }
820  // By here all the big ones should be safely tidied away to wasteland and now we need to deal with the raster map.
822  for (unsigned int i = 0; i < m_elems.size(); i++)
823  {
824  // Now we deal with all the little ones that were not by fields
825  if (m_elems[i]->GetElementType() == tole_Missing)
826  {
827  LE * wl = NewElement(tole_Wasteland);
828  wl->SetPoly(m_elems[i]->GetPoly());
829  wl->SetArea(m_elems[i]->GetArea());
830  wl->SetSoilType(m_elems[i]->GetSoilType());
832  wl->SetCentroid(-1, -1);
833  wl->SetOpenness(0);
834  delete m_elems[i];
835  m_elems[i] = wl;
836  }
837  }
838  PolysValidate(false);
840  PolysValidate(true);
841  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after resolving missing polygons. ", "");
842  didCalcOther = true;
843  }
844 
845  // ChangeMapMapping() also enters a valid starting
846  // coordinate for the border generating farm method below.
848 
852  if ((m_LargestPolyNumUsed != ((int)m_elems.size() - 1)))
853  {
854  PolysRenumber();
855  didRenumber = true;
856  }
857  // do we want to remove small polygons?
858  if (l_map_removesmallpolygons.value())
859  {
860  cout << "In Landscape::Landscape() Small polygon removal" << endl;
861  int removed = RemoveSmallPolygons();
862  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after removing small polygons and map dump. Polygons removed:", removed);
863  didCalcOther = true;
864  }
865  // Do we want to re-write the current files and consolidate polys?
866  else if (l_map_consolidatepolys.value())
867  {
868  didConsolidate = true;
870  }
871  else if (g_map_le_borderremoval.value())
872  {
873  // Does not use centroids so is safe to use here
874  BorderRemoval();
875  CountMapSquares();
876  ForceArea();
877  g_msg->Warn(WARN_FILE, "Landscape::Landscape() - BorderRemoval "" map dump to follow.", "");
878  didCalcOther = true;
879  }
880 
881 
882  // 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
883  // are two reasons for this - 1) that we did not have them in the original polyref file, 2) that we changed the map
884  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation)
885  {
886  PolysValidate(false);
888  PolysValidate(true);
890  PolysRenumber();
892  didCalcCentroids = true;
893  }
894  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation || didCalcCentroids || l_map_calc_openness.value())
895  {
896  if (l_map_calc_openness.value()) CalculateOpenness(true);
897  else CalculateOpenness(false);
898  didCalcOpenness = true;
899  }
900  if (didCalcCentroids || didConsolidate || didCalcOpenness || didCalcOther || m_NeedCentroidCalculation || didRenumber || !m_FarmManager->GetIsRenumbered())
901  {
902  // We need to dump the map and polyrefs
903  m_FarmManager->DumpFarmrefs();
904  DumpMap(l_map_dump_map_file.value());
906  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
907  exit(0);
908  }
909 
910  // Below here we have the more complicated map manipulations. These will need recalculation of centroids and openness after they are run.
911  // However, we really do not want to get here with invalid centroids, hence forced dump and exit for manipulations up to this point.
912 
913  didCalcOther = false;
914  // Add artificial hedgebanks to the hedges in the landscape,
915  // if requested.
916  if (l_map_art_hedgebanks.value()) {
917  hb_Add();
918  didCalcOther = true;
919  }
920  else if (g_map_le_borders.value())
921  {
922  cout << "Generating LE Borders around fields" << endl;
923  cout << "Border chance = " << g_map_le_border_chance.value() << endl;
924  cout << "Border width = " << g_map_le_borderwidth.value() << endl;
925  // Generate border around each *farm* landscape element.
926  cout << "Setting MaxMin Extents" << endl;
928  cout << "Adding Borders" << endl;
929  unsigned sz = (unsigned)m_elems.size();
930  for (unsigned i = 0; i < sz; i++)
931  {
932  if (m_elems[i]->GetBorder() != NULL)
933  {
934  // Border around this element, so must be a farm field.
935  // If the field is too small then ignore it
936  if (m_elems[i]->GetArea() > g_map_le_borders_min_field_size.value())
937  {
938  TTypesOfLandscapeElement t = g_letype->TranslateEleTypes(g_map_le_borderstype.value());
939  BorderAdd(m_elems[i], t);
940  }
941  }
942  }
943  didCalcOther = true;
944  }
945  else // Some special code to 'soften' the edges of orchards
946  if (g_map_orchards_borders.value())
947  {
948  // Generate border around each *farm* landscape element.
949  for (unsigned int i = 0; i < m_elems.size(); i++) {
950  if (m_elems[i]->GetElementType() == tole_Orchard)
951  {
952  TTypesOfLandscapeElement t = g_letype->TranslateEleTypes(g_map_le_borderstype.value());
953  BorderAdd(m_elems[i], t);
954  }
955  }
956  didCalcOther = true;
957  }
958  else
959  // Unsprayed Margin Code....
960  if (g_map_le_unsprayedmargins.value())
961  {
962  CountMapSquares();
963  ForceArea();
964 
965  // Generate border around each *farm* landscape element.
966  for (unsigned int i = 0; i < m_elems.size(); i++)
967  {
968  if (m_elems[i]->GetUnsprayedMarginPolyRef() != -1)
969  {
970  // But not if the field is too small to have them (<1Ha)
971  if (m_elems[i]->GetArea() > 10000)
972  {
973  // Border around this element, so must be a farm field.
975  }
976  else m_elems[i]->SetUnsprayedMarginPolyRef(-1);
977  }
978  }
979  didCalcOther = true;
980  }
981  else if (cfg_AddBeetleBanks.value())
982  {
983  cout << "Adding beetle banks now" << endl;
984  AddBeetleBanks((TTypesOfLandscapeElement)cfg_BeetleBankType.value());
985  didCalcOther = true;
986  }
987 
988  if (l_map_dump_gfx_enable.value())
989  {
991  }
992 
993  if (l_map_dump_enable.value() || didCalcOther)
994  {
995  CountMapSquares();
996  ForceArea();
997  PolysValidate(false);
999  PolysValidate(true);
1000  ChangeMapMapping();
1001  PolysRenumber();
1004  m_FarmManager->DumpFarmrefs();
1005  cout << "Dumping map" << endl;
1006  DumpMap(l_map_dump_map_file.value());
1007  cout << "Dumping polygon refs file" << endl;
1009  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
1010  exit(0);
1011  }
1012 
1013  /*'''''''''''''''''' CIPE LANDSCAPE MAKER CODE HERE //'''''''''''''''''''''
1014  if ( l_map_CIPEmaker_enable.value() ) {
1015  CIPELandscapeMaker();
1016  if ( l_map_dump_exit.value() ) {
1017  g_msg->Warn( WARN_FILE, "Landscape::Landscape(): ""Normal exit after map dump.", "" );
1018  exit( 0 );
1019  }
1020  }
1021  //'''''''''''''''''' CIPE LANDSCAPE MAKER CODE ABOVE //'''''''''''''''''''''
1022  */
1023  // Set the type of hedgebanks.
1024  int l_subtype = cfg_HedgeSubtypeMinimum.value();
1025  for (unsigned int i = 0; i < m_elems.size(); i++) {
1026  if (m_elems[i]->GetElementType() == tole_HedgeBank) {
1027  m_elems[i]->SetSubType(l_subtype);
1028  if (++l_subtype >= cfg_HedgeSubtypeMaximum.value())
1029  l_subtype = cfg_HedgeSubtypeMinimum.value();
1030  }
1031  }
1032 
1033  // And another to set the type of hedges
1034  // ***CJT*** 2003-12-02
1035  l_subtype = 0;
1036  for (unsigned int i = 0; i < m_elems.size(); i++) {
1037  if (m_elems[i]->GetElementType() == tole_Hedges) {
1038  m_elems[i]->SetSubType(l_subtype);
1039  if (++l_subtype >= 3)
1040  l_subtype = 0;
1041  }
1042  }
1043  // Count up the ponds and store them now we are finished with polygon handling.
1044  CreatePondList();
1045 
1046  cout << "Initiating farm management" << endl;
1047  m_FarmManager->InitiateManagement();
1048  g_date->Reset();
1049 
1050  /*
1051  if ( g_farm_test_crop.value() ) {
1052  TestCropManagement();
1053  exit( 0 );
1054  }
1055  */
1056 
1057  // Set up treatment flags
1058  // Reset internal state for the LE loop generator.
1059  // Compulsory!
1060  SupplyLEReset();
1061  // Get number of *all* landscape elements.
1062  int l_count = SupplyLECount();
1063 
1064  // Now loop through then.
1065  for (int i = 0; i < l_count; i++) {
1066  // Fetch next LE by its polygon reference number. Alternative
1067  // loop mechanism: This will return -1 at end-of-loop.
1068  int a_poly = SupplyLENext();
1069 
1070  // Skip uninteresting polygons by type, ownership,
1071  // phase of the moon, whatever.
1072  // if ( these_are_not_the_droids_we_are_looking_for( a_poly )) {
1073  if (SupplyElementType(a_poly) != tole_Field)
1074  continue;
1075 
1076  // Example: Set x% of them to ignore insecticide of all types.
1077  if (random(100) < l_map_no_pesticide_fields.value()) {
1078  // Get current signal mask for polygon.
1079  LE_Signal l_signal = SupplyLESignal(a_poly);
1080  // Logical OR in/AND out the signals you are interested in.
1081  // The current signals are at the top of elements.h
1082  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE | LE_SIG_NO_FUNGICIDE | LE_SIG_NO_GROWTH_REG;
1083  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE;
1084  // Write the mask back out to the polygon.
1085  SetLESignal(a_poly, l_signal);
1086  }
1087  }
1088 
1089  l_vegtype_areas = (double *)malloc(sizeof(double) * (tov_Undefined + 1));
1090 
1091  if (l_vegtype_areas == NULL) {
1092  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): Out of memory!", "");
1093  exit(1);
1094  }
1095  FILE * outf;
1096  if (cfg_dumpvegjan.value()) {
1097  outf = fopen(cfg_dumpvegjanfile.value(), "w");
1098  if (!outf) {
1099  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjanfile.value());
1100  exit(1);
1101  }
1102  else
1103  fclose(outf);
1104  }
1105 
1106  if (cfg_dumpvegjune.value()) {
1107  outf = fopen(cfg_dumpvegjunefile.value(), "w");
1108  if (!outf) {
1109  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjunefile.value());
1110  exit(1);
1111  }
1112  else
1113  fclose(outf);
1114  }
1115 
1116  // Dump veg information if necessary
1117  if (l_map_dump_veg_enable.value()) {
1118  FILE * f;
1119  f = fopen("VegDump.txt", "w");
1120  if (!f) {
1121  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): VegDump.txt could not be created", "");
1122  exit(1);
1123  }
1124  fprintf(f, "Year\tDay\tHeight\tBiomass\tGrazed\tDensity\tCover\tWeedBiomass\ttovNum\tInsectBiomass\tLATotal\tLAGreen\tDigestability\tGreenBiomass\tDeadBiomass\tGooseGrazing\tSpilledGrain\nn");
1125  fclose(f);
1126  }
1127  if (l_map_dump_event_enable.value()) {
1128  FILE * f;
1129  f = fopen("EventDump.txt", "w");
1130  if (!f) {
1131  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): EventDump.txt could not be created", "");
1132  exit(1);
1133  }
1134  fclose(f);
1135  }
1136 
1137  if (!cfg_OptimiseBedriftsmodelCrops.value()){
1138  m_FarmManager->FindNeighbours();
1139  }
1140 
1141  if (cfg_DumpFarmAreas.value()){
1142  m_FarmManager->DumpFarmAreas();
1143  }
1144 
1145  // If we are testing a pesticide then set the enum attribute
1147 
1149  if (cfg_rodenticide_enable.value())
1150  {
1151  m_RodenticideManager = new RodenticideManager("BaitLocations_input.txt", this);
1153  }
1154 
1155  // Run a year to remove any start up effects
1156  cout << "Running intial start-up year" << endl;
1157  for (unsigned int i = 0; i < 365; i++) Tick();
1158  //switch the rotation after running the hidden year (only for optimising farms), AM, 030713
1159  if (cfg_OptimisingFarms.value()) { m_FarmManager->Switch_rotation(); }
1160  // Write ASCII file:
1161  if (l_map_write_ascii.value()) {
1162  int x = l_map_ascii_utm_x.value();
1163  int y = l_map_ascii_utm_y.value();
1164  GISASCII_Output("AsciiLandscape.txt", x, y);
1165  }
1166 }
CfgInt cfg_HedgeSubtypeMinimum("HEDGE_SUBTYPEMINIMUM", CFG_CUSTOM, 0)
CfgBool cfg_OptimisingFarms
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
static CfgInt cfg_MaxPondSize("MAP_MAXPONDSIZE", CFG_CUSTOM, 5000)
If freshwater area is below this it is designated a pond.
void SetElementType(int a_type)
Definition: elements.h:114
int m_height10
Definition: landscape.h:130
CfgFloat cfg_G6F
int m_width
Definition: landscape.h:127
CfgStr l_map_dump_map_file("MAP_DUMP_MAP_FILE", CFG_CUSTOM,"dump.lsb")
static CfgBool l_map_calc_openness("MAP_CALC_OPENNESS", CFG_CUSTOM, false)
virtual void SetCentroid(int x, int y)
Definition: elements.h:139
void SetLESignal(int a_polyref, LE_Signal a_signal)
Definition: Landscape.cpp:3328
void ConsolidatePolys(void)
Definition: Landscape.cpp:1169
class Pesticide * g_pest
unsigned int LE_Signal
Definition: elements.h:33
CfgStr l_map_dump_poly_file("MAP_DUMP_POLY_FILE", CFG_CUSTOM,"dumppolyrefs.txt")
static const int version_minor
Definition: Landscape.cpp:48
void RemoveMissingValues()
A method for replacing missing values in the map with corrected ones - slow.
Definition: Landscape.cpp:1898
double g_SpeedyDivides[2001]
A generally useful array of fast divide calculators by multiplication.
Definition: Landscape.cpp:230
static CfgBool l_map_write_ascii("MAP_WRITE_ASCII", CFG_CUSTOM, false)
Used if an ASCII file for use in GIS applications should be written.
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
static CfgInt l_map_ascii_utm_x("MAP_ASCII_UTM_X", CFG_CUSTOM, 0)
If we write an ASCII file provide UTM-x of lower lefthand corner.
CfgInt cfg_pesticidetesttype("PESTICIDETESTYPE", CFG_CUSTOM,-1)
static CfgInt l_map_ascii_utm_y("MAP_ASCII_UTM_Y", CFG_CUSTOM, 0)
If we write an ASCII file provide UTM-y of lower lefthand corner.
static CfgStr l_map_map_file("MAP_MAP_FILE", CFG_CUSTOM,"map.lsb")
static CfgBool cfg_AddBeetleBanks("BBANKS_ADD", CFG_CUSTOM, false)
static CfgBool l_map_removesmallpolygons("MAP_REMOVESMALLPOLYGONS", CFG_CUSTOM, false)
CfgFloat cfg_G6C
void PolysRemoveInvalid(void)
Definition: Landscape.cpp:1578
CfgFloat cfg_B6D
static CfgBool l_map_consolidatepolys("MAP_CONSOLIDATEPOLYS", CFG_CUSTOM, false)
Used to consolidate polygons with no special behaviour into a single polygon of that type...
void DumpMap(const char *a_filename)
Definition: Landscape.cpp:1211
static CfgStr l_map_cropcurves_file("MAP_CROPCURVES_FILE", CFG_CUSTOM,"curves.pre")
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1029
void SetUnsprayedMarginPolyRef(int a_unsprayedmargin)
Definition: elements.h:314
void PolysDump(const char *a_filename)
Definition: Landscape.cpp:1606
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
CfgBool cfg_dumpvegjune("G_VEGAREASJUNE_ON", CFG_CUSTOM, false)
CfgFloat cfg_P1C
Definition: elements.h:81
int SupplyLECount(void)
Definition: Landscape.cpp:3320
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
Definition: landscape.h:150
int m_height
Definition: landscape.h:128
void SetPolyMaxMinExtents(void)
Definition: Landscape.cpp:1428
void AddBeetleBanks(TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2498
void Tick(void)
Definition: Landscape.cpp:1288
void GISASCII_Output(string outpfile, int UTMX, int UTMY)
Write ASCII file of the ALMaSS map.
Definition: Landscape.cpp:3265
CfgFloat cfg_P1G
CfgBool cfg_OptimiseBedriftsmodelCrops
static CfgBool l_map_dump_event_enable("MAP_DUMP_EVENT_ENABLE", CFG_CUSTOM, false)
CfgBool cfg_P1E
static CfgInt l_map_no_pesticide_fields("MAP_NO_PESTICIDE_FIELDS", CFG_CUSTOM, 0)
CfgStr cfg_P1H
int m_maxextent
Definition: landscape.h:131
void SetSoilType(int a_st)
Definition: elements.h:281
void PolysRenumber(void)
Definition: Landscape.cpp:1865
void ReadPolys2(const char *a_polyfile)
reads in polygon information. Version 2 including centroid and openness information ...
Definition: Landscape.cpp:1695
void SetPoly(int a_poly)
Definition: elements.h:220
bool m_DoMissingPolygonsManipulations
Definition: landscape.h:138
static const int version_revision
Definition: Landscape.cpp:49
class LE_TypeClass * g_letype
Definition: elements.cpp:265
static const char * version_date
Definition: Landscape.cpp:50
static CfgInt cfg_BeetleBankType("BBANK_TYPE", CFG_CUSTOM,(int) tole_BeetleBank)
int m_treatment_counts[last_treatment]
Definition: landscape.h:171
void CountMapSquares(void)
Definition: Landscape.cpp:1848
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:133
Class for management of bait locations.
Definition: Rodenticide.h:73
void ForceArea(void)
Definition: Landscape.cpp:1880
Landscape * g_landscape_p
Definition: Landscape.cpp:238
void CreatePondList()
Creates a list of pond polygon refs/indexes for easy look up.
Definition: Landscape.cpp:2369
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
Definition: landscape.h:149
CfgFloat cfg_G6B
void BorderAdd(LE *a_field, TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:2123
static CfgStr l_map_dump_gfx_file("MAP_DUMP_GFX_FILE", CFG_CUSTOM,"dump.ppm")
CfgStr cfg_B6H
Definition: RodenticidePredators.h:48
CfgFloat cfg_B6G
void ChangeMapMapping(void)
Definition: Landscape.cpp:1938
void UnsprayedMarginAdd(LE *a_field)
Definition: Landscape.cpp:2392
RasterMap * m_land
The big map.
Definition: landscape.h:122
void SetArea(double a_area)
Definition: elements.h:223
CfgBool cfg_G6E
CfgStr cfg_dumpvegjunefile("G_VEGAREASJUNE_FILENAME", CFG_CUSTOM,"DUMPVEG_JUNE.TXT")
void SetOpenness(int a_openness)
Records the openness statistic for this polygon.
Definition: elements.h:362
CfgFloat cfg_G6A
static CfgStr l_map_poly_file("MAP_POLY_FILE", CFG_CUSTOM,"polygonrefs.txt")
int m_y_add[8]
Definition: landscape.h:245
int m_width10
Definition: landscape.h:129
void CalculateOpenness(bool a_realcalc)
Causes openness to be calulated and stored for all polygons.
Definition: Landscape.cpp:302
CfgFloat cfg_P1F
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1073
LE_Signal SupplyLESignal(int a_polyref)
Definition: Landscape.cpp:3324
CfgBool cfg_B6E
CfgBool cfg_DumpFarmAreas
CfgStr cfg_G6H
int m_x_add[8]
Definition: landscape.h:244
CfgFloat cfg_P1D
void DoCopy(const LE *a_Le)
a copy function to be used because a copy constuctor won&#39;t work
Definition: elements.cpp:355
TTypesOfPesticide m_PesticideType
An attribute to hold the pesticide type being tested, if there is one, if not default is -1...
Definition: landscape.h:256
bool m_toxShouldSpray
Definition: landscape.h:295
CfgFloat cfg_P1A
void SupplyLEReset(void)
Definition: Landscape.cpp:3309
static CfgBool l_map_dump_enable("MAP_DUMP_ENABLE", CFG_CUSTOM, false)
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
CfgFloat cfg_G6D
CfgBool cfg_dumpvegjan("G_VEGAREASJAN_ON", CFG_CUSTOM, false)
static CfgBool l_map_art_hedgebanks("MAP_ART_HEDGEBANKS", CFG_CUSTOM, false)
CfgFloat cfg_B6C
static CfgBool l_map_print_version_info("MAP_PRINT_VERSION_INFO", CFG_CUSTOM, true)
double * l_vegtype_areas
Definition: landscape.h:141
void hb_Add(void)
void PolysValidate(bool a_exit_on_invalid)
Definition: Landscape.cpp:1551
static CfgBool l_map_dump_veg_enable("MAP_DUMP_VEG_ENABLE", CFG_CUSTOM, true)
CfgFloat cfg_B6B
bool m_NeedCentroidCalculation
a flag to ensure centroid calculation on object construction
Definition: landscape.h:134
static const int version_major
Definition: Landscape.cpp:47
char m_versioninfo[30]
Definition: landscape.h:112
void CalculateCentroids(void)
Definition: Landscape.cpp:2815
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
Curve relatning goose intake rates in KJ/min to vegetation height.
Definition: landscape.h:148
void BorderRemoval(void)
Definition: Landscape.cpp:2047
bool m_NeedOpennessCalculation
a flag to ensure openness calculation on object construction
Definition: landscape.h:136
CfgInt cfg_HedgeSubtypeMaximum("HEDGE_SUBTYPEMAXIMUM", CFG_CUSTOM, 3)
CfgFloat cfg_B6F
CfgFloat cfg_G6G
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
void DumpMapGraphics(const char *a_filename)
Definition: Landscape.cpp:3357
static CfgBool l_map_dump_gfx_enable("MAP_DUMP_GFX_ENABLE", CFG_CUSTOM, false)
int RemoveSmallPolygons(void)
Removes small polygons from the map.
Definition: Landscape.cpp:1992
Definition: elements.h:70
CfgFloat cfg_B6A
static CfgStr l_map_weather_file("MAP_WEATHER_FILE", CFG_CUSTOM,"weather.pre")
TTypesOfPesticide
Definition: landscape.h:64
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3449
CfgStr cfg_dumpvegjanfile("G_VEGAREASJAN_FILENAME", CFG_CUSTOM,"DUMPVEG_JAN.TXT")
CfgBool cfg_WriteCurve
int SupplyLENext(void)
Definition: Landscape.cpp:3313
int m_LargestPolyNumUsed
Definition: landscape.h:172
CfgFloat cfg_P1B

Member Function Documentation

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

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

2498  {
2506  int BBs=0;
2507  int tx1 = cfg_BeetleBankMinX.value();
2508  int tx2 = cfg_BeetleBankMaxX.value();
2509  int ty1 = cfg_BeetleBankMinY.value();
2510  int ty2 = cfg_BeetleBankMaxY.value();
2511  bool doit = false;
2512  unsigned sz=(unsigned) m_elems.size();
2513  for (unsigned i=0; i<sz; i++)
2514  {
2515  if (m_elems[ i ]->GetElementType() == tole_Field)
2516  {
2517  doit = false;
2518  int cx = m_elems[ i ]->GetCentroidX();
2519  int cy = m_elems[ i ]->GetCentroidY();
2520  if (!cfg_BeetleBankInvert.value())
2521  {
2522  if ((cx >= tx1) && (cy >= ty1) && (cx <= tx2) && (cy <= ty2))
2523  {
2524  doit = true;
2525  }
2526  }
2527  else if ((cx < tx1) || (cy < ty1) || (cx > tx2) || (cy > ty2))
2528  {
2529  doit = true;
2530  }
2531  if (doit)
2532  {
2533  if (random(100)<cfg_BeetleBankChance.value())
2534  {
2535  if (BeetleBankPossible( m_elems[ i ], a_tole) ) BBs++;
2536  }
2537  }
2538  }
2539  }
2540  char str[25];
2541  sprintf(str,"%d",BBs);
2542  g_msg->Warn( WARN_MSG, "Landscape::AddBeetleBanks(): BeetleBanks successfully added:", str );
2543 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
CfgInt cfg_BeetleBankMinX("BBANK_MINX", CFG_CUSTOM, 0)
CfgBool cfg_BeetleBankInvert("BBANK_INVERT", CFG_CUSTOM, false)
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:133
CfgInt cfg_BeetleBankMaxY("BBANK_MAXY", CFG_CUSTOM, 100000)
CfgInt cfg_BeetleBankMinY("BBANK_MINY", CFG_CUSTOM, 0)
static CfgInt cfg_BeetleBankChance("BBANK_CHANCE", CFG_CUSTOM, 100)
bool BeetleBankPossible(LE *a_field, TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2547
CfgInt cfg_BeetleBankMaxX("BBANK_MAXX", CFG_CUSTOM, 100000)
void Landscape::AddGreenElement ( LE a_green)
protected
int Landscape::AddToClusterList ( int ,
int ,
int ,
int ,
int  
)
protected
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.

2713  {
2718  int ap1 = a_polyindex;
2719  while (ap1 == a_polyindex)
2720  {
2721  *(a_x) += m_x_add[a_axis];
2722  *(a_y) += m_y_add[a_axis];
2723  // Before we try to get a polyindex from the map, check we are still on the world
2724  if (*(a_x) < 0)
2725  {
2726  return;
2727  }
2728  if (*(a_y) < 0)
2729  {
2730  return;
2731  }
2732  if (*(a_x) >= m_width)
2733  {
2734  return;
2735  }
2736  if (*(a_y) >= m_height)
2737  {
2738  return;
2739  }
2740  // OK still in the map, get the polyindex
2741  ap1 = m_land->Get((*a_x), (*a_y)); // NB this returns the m_elemens index not the polyref (ChangeMapMapping has been called by here)
2742  }
2743 }
int m_width
Definition: landscape.h:127
int m_height
Definition: landscape.h:128
RasterMap * m_land
The big map.
Definition: landscape.h:122
int m_y_add[8]
Definition: landscape.h:245
int m_x_add[8]
Definition: landscape.h:244
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.

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

2673  {
2678  int ap1 = a_polyindex;
2679  while (ap1 == a_polyindex)
2680  {
2681  a_cor->m_x += m_x_add[a_axis];
2682  a_cor->m_y += m_y_add[a_axis];
2683  if (a_cor->m_x >= m_width - 1) { a_cor->m_x = m_width - 1; return; }
2684  if (a_cor->m_y >= m_height - 1) { a_cor->m_y = m_height - 1; return; }
2685  if (a_cor->m_x <= 0) { a_cor->m_x = 0; return; }
2686  if (a_cor->m_y <= 0) { a_cor->m_y = 0; return; }
2687  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)
2688  }
2689 }
int m_width
Definition: landscape.h:127
int m_y
Definition: ALMaSS_Setup.h:54
int m_height
Definition: landscape.h:128
RasterMap * m_land
The big map.
Definition: landscape.h:122
int m_y_add[8]
Definition: landscape.h:245
int m_x_add[8]
Definition: landscape.h:244
int m_x
Definition: ALMaSS_Setup.h:53
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.

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

2692  {
2697  int ap1 = a_polyindex;
2698  int count = 0;
2699  while (ap1 == a_polyindex && count<a_limit)
2700  {
2701  a_cor->m_x += m_x_add[a_axis];
2702  a_cor->m_y += m_y_add[a_axis];
2703  if (a_cor->m_x >= m_width - 1) { a_cor->m_x = m_width - 1; return; }
2704  if (a_cor->m_y >= m_height - 1) { a_cor->m_y = m_height - 1; return; }
2705  if (a_cor->m_x <= 0) { a_cor->m_x = 0; return; }
2706  if (a_cor->m_y <= 0) { a_cor->m_y = 0; return; }
2707  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)
2708  count++;
2709  }
2710 }
int m_width
Definition: landscape.h:127
int m_y
Definition: ALMaSS_Setup.h:54
int m_height
Definition: landscape.h:128
RasterMap * m_land
The big map.
Definition: landscape.h:122
int m_y_add[8]
Definition: landscape.h:245
int m_x_add[8]
Definition: landscape.h:244
int m_x
Definition: ALMaSS_Setup.h:53
int Landscape::BackTranslateEleTypes ( TTypesOfLandscapeElement  EleReference)
inline

References LE_TypeClass::BackTranslateEleTypes(), and g_letype.

1587 {
1588  return g_letype->BackTranslateEleTypes( EleReference );
1589 }
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: elements.cpp:3037
class LE_TypeClass * g_letype
Definition: elements.cpp:265
int Landscape::BackTranslateVegTypes ( TTypesOfVegetation  VegReference)
inline

References LE_TypeClass::BackTranslateVegTypes(), and g_letype.

1594 {
1595  return g_letype->BackTranslateVegTypes( VegReference );
1596 }
class LE_TypeClass * g_letype
Definition: elements.cpp:265
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: elements.cpp:2859
void Landscape::BeetleBankAdd ( int  x,
int  y,
int  angle,
int  length,
LE a_field,
TTypesOfLandscapeElement  a_tole 
)
protected

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

2746  {
2747  // Need to get a new number
2749  // Make the new landscape element
2750  LE * BeetleBank;
2751  switch (a_tole)
2752  {
2753  case tole_MownGrass:
2754  BeetleBank = NewElement( tole_MownGrass );
2755  BeetleBank->SetALMaSSEleType( g_letype->BackTranslateEleTypes( tole_MownGrass ) );
2756  break;
2757  case tole_PermanentSetaside:
2758  BeetleBank = NewElement( tole_PermanentSetaside );
2759  BeetleBank->SetALMaSSEleType( g_letype->BackTranslateEleTypes( tole_PermanentSetaside ) );
2760  break;
2761  case tole_BeetleBank:
2762  default:
2763  BeetleBank = NewElement( tole_BeetleBank );
2764  BeetleBank->SetALMaSSEleType( g_letype->BackTranslateEleTypes( tole_BeetleBank ) );
2765  }
2766  BeetleBank->SetVegPatchy(true);
2768  m_elems.resize( m_elems.size() + 1 );
2769  m_elems[ m_elems.size() - 1 ] = BeetleBank;
2770  BeetleBank->SetPoly( m_LargestPolyNumUsed );
2771  // write lengthx12m to the map at alignment angle
2772  int area=0;
2773  int angle2=0;
2774  int width=cfg_BeetleBankWidth.value();
2775  if (a_angle==0) angle2=2;
2776  int start=(int)(a_length*0.1);
2777  for (int i=start; i<a_length; i++) {
2778  for (int w=0-width; w<width; w++) {
2779  int tx=w*m_x_add[angle2];
2780  int ty=w*m_y_add[angle2];
2781  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 );
2782  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 );
2783  area+=2;
2784  a_field->AddArea( -2.0 );
2785 
2786  }
2787  }
2788  BeetleBank->SetArea( double(area) );
2789  BeetleBank->SetValidXY( a_x+start*m_x_add[a_angle], a_y+start*m_y_add[a_angle] );
2790  BeetleBank->SetMapValid(true);
2791 
2792 }
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: elements.cpp:3037
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
virtual void SetVegPatchy(bool)
Definition: elements.h:148
static CfgInt cfg_BeetleBankWidth("BBANK_WIDTH", CFG_CUSTOM, 4)
Definition: elements.h:81
void SetPoly(int a_poly)
Definition: elements.h:220
class LE_TypeClass * g_letype
Definition: elements.cpp:265
void AddArea(double a_area_diff)
Definition: elements.h:308
Definition: elements.h:699
RasterMap * m_land
The big map.
Definition: landscape.h:122
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void SetArea(double a_area)
Definition: elements.h:223
int m_y_add[8]
Definition: landscape.h:245
void SetMapValid(bool a_valid)
Definition: elements.h:221
int m_x_add[8]
Definition: landscape.h:244
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
void SetValidXY(int a_valid_x, int a_valid_y)
Definition: elements.h:317
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3449
int m_LargestPolyNumUsed
Definition: landscape.h:172
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

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

2547  {
2554  int farea=(int)a_field->GetArea();
2555  if (farea<10000) return false;
2556  int cx=a_field->GetCentroidX();
2557  int cy=a_field->GetCentroidY();
2558  // The centroid is the only estimate we have (and it at least should be in the field).
2559  // So start here and find the centre
2560  if (!FindFieldCenter(a_field, &cx, &cy)) return false;
2561  // now get the alignment
2562  int length=0;
2563  int alignment=FindLongestAxis(&cx, &cy, &length);
2564  // reduce length by 20%
2565  length=int(length*0.8);
2566  int area=2*length*cfg_BeetleBankWidth.value(); // 12m wide fixed size
2567  if (area>(farea*cfg_BeetleBankMaxArea.value())) return false;
2568  // Must be small engough so lets draw it
2569  BeetleBankAdd(cx, cy, alignment, length , a_field, a_tole);
2570  return true;
2571 }
virtual int GetCentroidY()
Definition: elements.h:138
static CfgInt cfg_BeetleBankWidth("BBANK_WIDTH", CFG_CUSTOM, 4)
void BeetleBankAdd(int x, int y, int angle, int length, LE *a_field, TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2746
static CfgFloat cfg_BeetleBankMaxArea("BBANK_MAXAREA", CFG_CUSTOM, 0.05)
int FindLongestAxis(int *x, int *y, int *a_length)
Definition: Landscape.cpp:2626
double GetArea(void)
Definition: elements.h:196
bool FindFieldCenter(LE *a_field, int *x, int *y)
Definition: Landscape.cpp:2574
virtual int GetCentroidX()
Definition: elements.h:137
void Landscape::BorderAdd ( LE a_field,
TTypesOfLandscapeElement  a_type 
)
protected

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

2123  {
2124  int x = a_field->GetValidX();
2125  int y = a_field->GetValidY();
2126  if ( ( x == -1 ) || ( y == -1 ) ) {
2127  g_msg->Warn( WARN_BUG, "Landscape::BorderAdd(): Uninitialized border coordinate!", "" );
2128  exit( 1 );
2129  }
2130  LE * border = NewElement(a_type);
2131  a_field->SetBorder( border );
2133  m_elems.resize( m_elems.size() + 1 );
2134  m_elems[ m_elems.size() - 1 ] = border;
2135  border->SetPoly( hb_first_free_poly_num++ );
2136  border->SetArea( 0.0 );
2137  BorderScan(a_field, g_map_le_borderwidth.value());
2138 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int GetValidY(void)
Definition: elements.h:323
int GetValidX(void)
Definition: elements.h:322
Definition: elements.h:81
void SetBorder(LE *a_border)
Definition: elements.h:312
void SetPoly(int a_poly)
Definition: elements.h:220
int hb_first_free_poly_num
Definition: landscape.h:252
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void SetArea(double a_area)
Definition: elements.h:223
void BorderScan(LE *a_field, int a_width)
Definition: Landscape.cpp:2141
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3449
bool Landscape::BorderNeed ( TTypesOfLandscapeElement  a_letype)
protected
4141  {
4142  static char error_num[20];
4143  bool AddBorder = false;
4144  switch (a_letype) {
4145  // No border is needed toward these neighbouring element types.
4146  case tole_Hedges:
4147  case tole_HedgeBank:
4148  case tole_BeetleBank:
4149  case tole_RoadsideVerge:
4150  case tole_Marsh:
4151  case tole_RiversidePlants:
4152  case tole_UnsprayedFieldMargin:
4153  case tole_OrchardBand:
4154  case tole_MownGrass:
4155  break;
4156 
4157  case tole_IndividualTree:
4158  case tole_PlantNursery:
4159  case tole_Vildtager:
4160  case tole_WindTurbine:
4161  case tole_WoodyEnergyCrop:
4162  case tole_WoodlandMargin:
4163  case tole_Pylon:
4164  case tole_NaturalGrassDry:
4165  case tole_Railway:
4166  case tole_FieldBoundary:
4167  case tole_Scrub:
4168  case tole_Field:
4169  case tole_PermanentSetaside:
4170  case tole_PermPasture:
4171  case tole_PermPastureTussocky:
4172  case tole_PermPastureLowYield:
4173  case tole_PitDisused:
4174  case tole_RiversideTrees:
4175  case tole_DeciduousForest:
4176  case tole_MixedForest:
4177  case tole_YoungForest:
4178  case tole_ConiferousForest:
4179  case tole_StoneWall:
4180  case tole_Garden:
4181  case tole_Track:
4182  case tole_SmallRoad:
4183  case tole_LargeRoad:
4184  case tole_Building:
4185  case tole_ActivePit:
4186  case tole_Pond:
4187  case tole_FishFarm:
4188  case tole_Freshwater:
4189  case tole_River:
4190  case tole_Saltwater:
4191  case tole_Coast:
4192  case tole_BareRock:
4193  case tole_Heath:
4194  case tole_Orchard:
4195  case tole_AmenityGrass:
4196  case tole_Parkland:
4197  case tole_UrbanNoVeg:
4198  case tole_UrbanPark:
4199  case tole_BuiltUpWithParkland:
4200  case tole_SandDune:
4201  case tole_Copse:
4202  case tole_NaturalGrassWet:
4203  case tole_RoadsideSlope:
4204  case tole_MetalledPath:
4205  case tole_Carpark:
4206  case tole_Churchyard:
4207  case tole_Saltmarsh:
4208  case tole_Stream:
4209  case tole_HeritageSite:
4210  AddBorder = true;
4211  break;
4212 
4213  default:
4214  sprintf(error_num, "%d", a_letype);
4215  g_msg->Warn(WARN_BUG, "Landscape::BorderNeed(): Unknown element type:", error_num);
4216  exit(1);
4217  }
4218  return AddBorder;
4219 }
void Landscape::BorderRemoval ( void  )
protected
2047  {
2048  // This does not need to be efficient, just do the job
2049  for (int x=1; x<(m_width-1); x++)
2050  for (int y=1; y<(m_height-1); y++)
2051  {
2052  TTypesOfLandscapeElement tole = SupplyElementType(x,y);
2053  if ((tole==tole_FieldBoundary) || (tole==tole_HedgeBank) || (tole==tole_Hedges))
2054  {
2055  if ( SupplyElementType(x-1,y-1) == tole_Field)
2056  {
2057  // Set the x,y location to be this field
2058  int fieldindex = SupplyPolyRefIndex(x-1,y-1);
2059  m_land->Put( x, y, fieldindex );
2060 
2061  }
2062  else
2063  if ( SupplyElementType(x-1,y) == tole_Field)
2064  {
2065  // Set the x,y location to be this field
2066  int fieldindex = SupplyPolyRefIndex(x-1,y);
2067  m_land->Put( x, y, fieldindex );
2068 
2069  }
2070  else
2071  if ( SupplyElementType(x-1,y+1) == tole_Field)
2072  {
2073  // Set the x,y location to be this field
2074  int fieldindex = SupplyPolyRefIndex(x-1,y+1);
2075  m_land->Put( x, y, fieldindex );
2076 
2077  }
2078  else
2079  if ( SupplyElementType(x,y-1) == tole_Field)
2080  {
2081  // Set the x,y location to be this field
2082  int fieldindex = SupplyPolyRefIndex(x,y-1);
2083  m_land->Put( x, y, fieldindex );
2084 
2085  }
2086  else
2087  if ( SupplyElementType(x,y+1) == tole_Field)
2088  {
2089  // Set the x,y location to be this field
2090  int fieldindex = SupplyPolyRefIndex(x,y+1);
2091  m_land->Put( x, y, fieldindex );
2092 
2093  }
2094  else
2095  if ( SupplyElementType(x+1,y-1) == tole_Field)
2096  {
2097  // Set the x,y location to be this field
2098  int fieldindex = SupplyPolyRefIndex(x+1,y-1);
2099  m_land->Put( x, y, fieldindex );
2100 
2101  }
2102  else
2103  if ( SupplyElementType(x+1,y) == tole_Field)
2104  {
2105  // Set the x,y location to be this field
2106  int fieldindex = SupplyPolyRefIndex(x+1,y);
2107  m_land->Put( x, y, fieldindex );
2108 
2109  }
2110  else
2111  if ( SupplyElementType(x+1,y+1) == tole_Field)
2112  {
2113  // Set the x,y location to be this field
2114  int fieldindex = SupplyPolyRefIndex(x+1,y+1);
2115  m_land->Put( x, y, fieldindex );
2116 
2117  }
2118  }
2119  }
2120 }
int m_width
Definition: landscape.h:127
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1029
int m_height
Definition: landscape.h:128
RasterMap * m_land
The big map.
Definition: landscape.h:122
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1417
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.

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

2142 {
2146  LE * border = a_field->GetBorder(); // border is the a border object
2147  int fieldpoly = a_field->GetPoly(); // fieldpoly is the polygon number
2148  int borderpoly = border->GetPoly(); // borderpoly is the polygon number
2149  int borderindex = m_polymapping[ borderpoly ]; // borderindex is the elems index for the border
2150  int fieldindex = m_polymapping[ fieldpoly ]; // fieldindex is the elems index
2151  int test = m_land->Get(a_field->GetCentroidX(), a_field->GetCentroidY());
2152  if (test != fieldindex)
2153  {
2154  g_msg->Warn("Landscape::BorderScan - Border Scan centroid does not return correct polygon index. Index :", fieldindex);
2155  g_msg->Warn(" Returned ", test);
2156  exit(0);
2157  }
2158  int notforever = 50000;
2159  vector<APoint> listoflocs;
2164  for (int wid = 0; wid < a_width; wid++)
2165  {
2166  notforever = 50000;
2167  // These two will be modified through pointer operations in BorderStep().
2168  APoint coord(a_field->GetCentroidX(), a_field->GetCentroidY());
2169  // Find the first edge cell
2170  AxisLoop(fieldindex, &coord, random(8));
2171  while (--notforever > 0)
2172  {
2173  // Check if this position should be made into a border.
2174  if (BorderTest(fieldindex, -99, coord.m_x, coord.m_y))
2175  {
2176  // Add this pixel to the border element in the big map, but using a code for later replacement.
2177  m_land->Put(coord.m_x, coord.m_y, -99); // this puts the elems index into our map in memory
2178  listoflocs.push_back(coord);
2179  a_field->AddArea(-1.0);
2180  if (l_map_exit_on_zero_area.value() && (a_field->GetArea()<1))
2181  {
2182  char polynum[20];
2183  sprintf(polynum, "%d", a_field->GetPoly()); g_msg->Warn(WARN_FILE, "Landscape::BorderScan(): Polygon reached zero area " "when adding border. Poly num: ", polynum);
2184  exit(1);
2185  }
2186  border->AddArea(1.0);
2187  border->SetMapValid(true);
2188  }
2189  // Step to next coordinate. Quit when done.
2190  if (!BorderStep(fieldindex, -99, &coord))
2191  {
2192  break;
2193  }
2194  }
2195  for (std::vector<APoint>::iterator it = listoflocs.begin(); it != listoflocs.end(); ++it)
2196  {
2197  m_land->Put((*it).m_x, (*it).m_y, borderindex);
2198  }
2199  listoflocs.clear();
2200  }
2201 }
LE * GetBorder(void)
Definition: elements.h:309
bool BorderStep(int a_fieldpoly, int a_borderpoly, int *a_x, int *a_y)
Definition: Landscape.cpp:2254
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: elements.h:189
virtual int GetCentroidY()
Definition: elements.h:138
Definition: elements.h:81
void AddArea(double a_area_diff)
Definition: elements.h:308
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:133
RasterMap * m_land
The big map.
Definition: landscape.h:122
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool BorderTest(int a_fieldpoly, int a_borderpoly, int a_x, int a_y)
Definition: Landscape.cpp:2227
void SetMapValid(bool a_valid)
Definition: elements.h:221
static CfgBool l_map_exit_on_zero_area("MAP_EXIT_ON_ZERO_AREA", CFG_CUSTOM, true)
void AxisLoop(int a_poly, int *a_x, int *a_y, int a_axis)
Definition: Landscape.cpp:2713
double GetArea(void)
Definition: elements.h:196
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:50
virtual int GetCentroidX()
Definition: elements.h:137
bool Landscape::BorderStep ( int  a_fieldpoly,
int  a_borderpoly,
int a_x,
int a_y 
)
protected
2254  {
2255  int index;
2256  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2257  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2258  int width = m_land->MapWidth();
2259  int height = m_land->MapHeight();
2260  int i = 7, counter = 8;
2261  bool running = true;
2262  // First scan for another pixel that belongs to this field.
2263  while (running)
2264  {
2265  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))
2266  {
2267  index = m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]);
2268  if (index == a_fieldindex)
2269  {
2270  // Found the first field pixel while scanning around always
2271  // in the same direction.
2272  running = false;
2273  }
2274  }
2275  if (--i < 0) {
2276  // Didn't find any of our pixels. We are in a blind alley. Exit
2277  // gracefully.
2278  return false; // Signal done scanning this field.
2279  }
2280  }
2281 
2282  // Now scan around from our present facing direction and find the border
2283  // (if any).
2284  while (--counter)
2285  {
2286  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))
2287  {
2288  index = m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]);
2289  if (index == a_fieldindex)
2290  {
2291  if (--i < 0) i = 7;
2292  continue;
2293  }
2294  }
2295 
2296  // Aha! This pixel is not ours. Step one step in the
2297  // opposite(!) direction. If that pixel is ours, then
2298  // modify hotspot coordinates and exit.
2299  if (++i > 7) i = 0;
2300  if (!((*a_x) + x_add[i] + 1 > width) && !((*a_x) + x_add[i] < 0) && !((*a_y) + y_add[i] + 1 > height) &&
2301  !((*a_y) + y_add[i] < 0) && (m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]) == a_fieldindex))
2302  {
2303  (*a_x) += x_add[i];
2304  (*a_y) += y_add[i];
2305  return true;
2306  }
2307  }
2308  return false;
2309 }
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::BorderStep ( int  a_fieldpoly,
int  a_borderpoly,
APoint a_coord 
)
protected

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

2312  {
2313  int index;
2314  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2315  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2316  int width = m_land->MapWidth();
2317  int height = m_land->MapHeight();
2318  int i = 7, counter = 8;
2319  bool running = true;
2320  // First scan for another pixel that belongs to this field.
2321  while (running)
2322  {
2323  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))
2324  {
2325  index = m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]);
2326  if (index == a_fieldindex)
2327  {
2328  // Found the first field pixel while scanning around always
2329  // in the same direction.
2330  running = false;
2331  }
2332  }
2333  if (--i < 0) {
2334  // Didn't find any of our pixels. We are in a blind alley. Exit
2335  // gracefully.
2336  return false; // Signal done scanning this field.
2337  }
2338  }
2339 
2340  // Now scan around from our present facing direction and find the border
2341  // (if any).
2342  while (--counter)
2343  {
2344  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))
2345  {
2346  index = m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]);
2347  if (index == a_fieldindex)
2348  {
2349  if (--i < 0) i = 7;
2350  continue;
2351  }
2352  }
2353 
2354  // Aha! This pixel is not ours. Step one step in the
2355  // opposite(!) direction. If that pixel is ours, then
2356  // modify hotspot coordinates and exit.
2357  if (++i > 7) i = 0;
2358  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) &&
2359  !((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))
2360  {
2361  (a_coord->m_x) += x_add[i];
2362  (a_coord->m_y) += y_add[i];
2363  return true;
2364  }
2365  }
2366  return false;
2367 }
int m_y
Definition: ALMaSS_Setup.h:54
RasterMap * m_land
The big map.
Definition: landscape.h:122
int m_x
Definition: ALMaSS_Setup.h:53
bool Landscape::BorderTest ( int  a_fieldpoly,
int  a_borderpoly,
int  a_x,
int  a_y 
)
protected
2228 {
2229  int index;
2230  int x_add[ 8 ] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2231  int y_add[ 8 ] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2232  int width = m_land->MapWidth();
2233  int height = m_land->MapHeight();
2234  // Scan anti-clockwise from center pixel coordinate.
2235  for ( unsigned int i = 0; i < 8; i++ ) {
2236  if ( ( a_x + x_add[ i ] >= width ) || ( a_x + x_add[ i ] < 0 ) || ( a_y + y_add[ i ] >= height )
2237  || ( a_y + y_add[ i ] < 0 ) ) {
2238  return true;
2239  }
2240  //continue;
2241  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2242  if ( ( index != a_fieldindex ) && ( index != a_borderindex ) )
2243  {
2244  return true;
2245  // Test removed 1/07/2014 CJT
2246  //if ( BorderNeed( m_elems[ index ]->GetElementType() ) ) return true;
2247  //else return false;
2248  }
2249  }
2250  return false;
2251 }
RasterMap * m_land
The big map.
Definition: landscape.h:122
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.

References cfg_mintownbuildingdistance(), and cfg_mintownbuildingnumber().

3061 {
3066  for (int p = 0; p< (int)m_elems.size(); p++)
3067  {
3068  TTypesOfLandscapeElement tole = m_elems[p]->GetElementType();
3069  if ( tole == tole_Building)
3070  {
3071  int cx = m_elems[p]->GetCentroidX();
3072  int cy = m_elems[p]->GetCentroidY();
3073  int near = 0;
3074  for (int j = 0; j< (int)m_elems.size(); j++)
3075  {
3076  if (m_elems[j]->GetElementType() == tole_Building)
3077  {
3078  int nx = m_elems[j]->GetCentroidX();
3079  int ny = m_elems[j]->GetCentroidY();
3080  int dx =abs(cx-nx);
3081  int dy =abs(cy-ny);
3082  if ((dx < cfg_mintownbuildingdistance.value()) && (dy < cfg_mintownbuildingdistance.value())) near++;
3083  if (near > cfg_mintownbuildingdistance.value()) break;
3084  }
3085  }
3086  if (near <= cfg_mintownbuildingnumber.value()) m_elems[p]->SetCountryDesignation(1); // Not enough buildings close by, so it is a country building
3087  else m_elems[p]->SetCountryDesignation(0);
3088  }
3089  else if (tole == tole_YoungForest)
3090  {
3091  m_elems[p]->SetCountryDesignation(2);
3092  }
3093  else if ((tole == tole_DeciduousForest) || ( tole == tole_MixedForest) || ( tole == tole_ConiferousForest ) ) m_elems[p]->SetCountryDesignation(3);
3094 
3095  }
3096 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
static CfgInt cfg_mintownbuildingnumber("MAP_MINTOWNBUILDINGNUMBER", CFG_CUSTOM, 6)
static CfgInt cfg_mintownbuildingdistance("MAP_MINTOWNBUILDINGDISTANCE", CFG_CUSTOM, 100)
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.

2816 {
2822  cout << "In Centroid Calculations" << endl;
2823  // For each polygon
2824  for (int p = 0; p< (int)m_elems.size(); p++)
2825  {
2826  // Calcuate the actual centre
2827  int x1 = m_elems[p]->GetMinX();
2828  int y1 = m_elems[p]->GetMinY();
2829  int x2 = m_elems[p]->GetMaxX();
2830  int y2 = m_elems[p]->GetMaxY();
2831  int midx = (x1 + x2) / 2;
2832  int midy = (y1 + y2) / 2;
2833  // Now from midx & midy we move outwards in concentric circles until we find a location that matches our polyref.
2834  int polyindex = p; // Change mapmapping has been called by now, so the map contains m_elems indices.
2835  CentroidSpiralOut(polyindex, midx, midy);
2836  // 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,
2837  // 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
2838  // from this point
2839  int l;
2840  FindLongestAxis(&midx, &midy, &l);
2841  m_elems[p]->SetCentroid(midx, midy);
2842  }
2844 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void BuildingDesignationCalc()
used to calculate whether a building is rural or town - for rodenticide use
Definition: Landscape.cpp:3060
int FindLongestAxis(int *x, int *y, int *a_length)
Definition: Landscape.cpp:2626
void CentroidSpiralOut(int a_polyref, int &a_x, int &a_y)
Definition: Landscape.cpp:2847
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

303 {
307  for (unsigned int i = 0; i < m_elems.size(); i++)
308  {
309  TTypesOfLandscapeElement tole = m_elems[i]->GetElementType();
310  switch (tole)
311  {
312  case tole_Field:
313  case tole_Marsh:
314  case tole_Scrub:
315  case tole_PermPastureLowYield:
316  case tole_PermPastureTussocky:
317  case tole_PermanentSetaside:
318  case tole_PermPasture:
319  case tole_NaturalGrassDry:
320  case tole_NaturalGrassWet:
321  if (a_realcalc)
322  {
323  cout << i << " ";
324  m_elems[i]->SetOpenness(CalulateFieldOpennessAllCells(i));
325  }
326  else m_elems[i]->SetOpenness(0);
327  break;
328  default:
329  m_elems[i]->SetOpenness(0);
330  break;
331  }
332  }
333  if (a_realcalc) cout << endl;
334 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int CalulateFieldOpennessAllCells(int a_pref)
Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles...
Definition: Landscape.cpp:379
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.

380 {
381  int dline;
382  int d0 = 0;
383  int minX = m_elems[a_pref]->GetMinX();
384  int minY = m_elems[a_pref]->GetMinY();
385  int maxX = m_elems[a_pref]->GetMaxX();
386  int maxY = m_elems[a_pref]->GetMaxY();
387  for (int ax = minX; ax <= maxX; ax+=10)
388  {
389  for (int ay = minY; ay <= maxY; ay+=10)
390  {
391  dline = m_maxextent; // this is the width of the landscape and will always be at least as big as the biggest return value possible
392  // Get a possible point for this field
393  int cx = ax;
394  int cy = ay;
395  if (m_land->Get(ax, ay) == a_pref)
396  {
401  double offsetx = -1;
402  double offsety = -1;
403  double dx = 1.0 / 45.0;
404  double dy = 0.0;
405  for (int deg = 0; deg<90; deg++)
406  {
408  int d1 = LineHighTest(cx, cy, offsetx, offsety);
409  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
410  int d = d1;
411  if (d1 > d2) d = d2;
412  if (dline > d) dline = d; // get the minimum
413  offsetx = offsetx + dx;
414  offsety = offsety + dy;
415  }
416  offsetx = 1;
417  offsety = 1;
418  dy = 0 - dx;
419  dx = 0;
420  for (int deg = 0; deg<90; deg++)
421  {
423  int d1 = LineHighTest(cx, cy, offsetx, offsety);
424  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
425  int d = d1;
426  if (d1 > d2) d = d2;
427  if (dline > d) dline = d;
428  offsetx = offsetx + dx;
429  offsety = offsety + dy;
430  }
431  if (dline > d0) d0 = dline; // Get the maximum. Here we might also want to do something like create statistics from the range of dline
432  }
433  }
434  }
435  return d0;
436 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int m_maxextent
Definition: landscape.h:131
RasterMap * m_land
The big map.
Definition: landscape.h:122
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...
Definition: Landscape.cpp:439
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.

338 {
339  // Get the centre point for this field
340  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
341  int cx = m_elems[a_pref]->GetCentroidX();
342  int cy = m_elems[a_pref]->GetCentroidY();
343 
345  double offsetx = -1;
346  double offsety = -1;
347  double dx = 1.0 / 45.0;
348  double dy = 0.0;
349  for (int deg = 0; deg<90; deg++)
350  {
352  int d1 = LineHighTest(cx, cy, offsetx, offsety);
353  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
354  int d = d1;
355  if (d1 > d2) d = d2;
356  if (d0 > d) d0 = d;
357  offsetx = offsetx + dx;
358  offsety = offsety + dy;
359  }
360  offsetx = 1;
361  offsety = 1;
362  dy = 0 - dx;
363  dx = 0;
364  for (int deg = 0; deg<90; deg++)
365  {
367  int d1 = LineHighTest(cx, cy, offsetx, offsety);
368  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
369  int d = d1;
370  if (d1 > d2) d = d2;
371  if (d0 > d) d0 = d;
372  offsetx = offsetx + dx;
373  offsety = offsety + dy;
374  }
375  return d0;
376 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int m_maxextent
Definition: landscape.h:131
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...
Definition: Landscape.cpp:439
void Landscape::CentroidSpiralOut ( int  a_polyref,
int a_x,
int a_y 
)
2848 {
2849  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref) return; // Found it so return
2850  // Otherwise its not found so we need to start to spiral out
2851  int loop = 1;
2852  int sx = a_x;
2853  int sy = a_y;
2854  do {
2855  a_y = sy - loop;
2856  for (int i = 0 - loop; i <= loop; i++)
2857  {
2858  a_x = sx + i;
2859  CorrectCoords(a_x, a_y);
2860  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2861  return; // Found it so return
2862  }
2863  a_y = sy + loop;
2864  for (int i = 0 - loop; i <= loop; i++)
2865  {
2866  a_x = sx + i;
2867  CorrectCoords(a_x, a_y);
2868  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2869  return; // Found it so return
2870  }
2871  a_x = sx + loop;
2872  for (int j = 0 - (loop - 1); j< loop; j++)
2873  {
2874  a_y = sy + j;
2875  CorrectCoords(a_x, a_y);
2876  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2877  return; // Found it so return
2878  }
2879  a_x = sx - loop;
2880  for (int j = 0 - (loop - 1); j< loop; j++)
2881  {
2882  a_y = sy + j;
2883  CorrectCoords(a_x, a_y);
2884  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2885  return; // Found it so return
2886  }
2887  loop++;
2888  } while (loop<m_width); // This stopping rule should hopefully not be needed, it is set very high.
2889  g_msg->Warn("Landscape::CentroidSpiralOut: Failure of centroid main loop. Looking for polygon index ",a_polyref);
2890  a_x = m_elems[a_polyref]->GetMinX();
2891  a_y = m_elems[a_polyref]->GetMinY();
2892 }
int m_width
Definition: landscape.h:127
void CorrectCoords(int &x, int &y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1459
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1417
void Landscape::CentroidSpiralOutBlocks ( int  a_polyref,
int a_x,
int a_y 
)

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

2895 {
2896  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref) return; // Found it so return
2897  // Otherwise its not found so we need to start to spiral out until we find a 10x10m block of our field.
2898  int loop = 1;
2899  int sx = a_x;
2900  int sy = a_y;
2901  do {
2902  a_y = sy - loop;
2903  for (int i = 0 - loop; i <= loop; i++)
2904  {
2905  a_x = sx + i;
2906  CorrectCoords(a_x, a_y);
2907  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2908  {
2909  APoint pt(a_x, a_y);
2910  double dists = -1;
2911  double best = -1;
2912  int ind = -1;
2913  for (int d = 0; d < 8; d++)
2914  {
2915  AxisLoopLtd(a_polyref, &pt, d,10);
2916 #ifdef __BORLANDC__
2917  dists = sqrt(double((a_x - pt.m_x)*(a_x - pt.m_x) + (a_y - pt.m_y) * (a_y - pt.m_y)));
2918 #else
2919  //dists = sqrt((a_x - pt.m_x)*(a_x - pt.m_x) + (a_y - pt.m_y) * (a_y - pt.m_y));
2920  dists = (abs(a_x - pt.m_x) + abs(a_y - pt.m_y));
2921 #endif
2922  if (dists > best) { best = dists; ind = d; }
2923  }
2924  if (ind > -1)
2925  {
2926  // best /= 2;
2927  if (best >= 10)
2928  {
2929  a_x += m_x_add[ind] * 10;
2930  a_y += m_y_add[ind] * 10;
2931  return;
2932  }
2933  }
2934  return; // Found it so return even without the 10 distance
2935  }
2936  }
2937  a_y = sy + loop;
2938  for (int i = 0 - loop; i <= loop; i++)
2939  {
2940  a_x = sx + i;
2941  CorrectCoords(a_x, a_y);
2942  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2943  {
2944  APoint pt(a_x, a_y);
2945  double dists = -1;
2946  double best = -1;
2947  int ind = -1;
2948  for (int d = 0; d < 8; d++)
2949  {
2950  AxisLoopLtd(a_polyref, &pt, d,10);
2951 #ifdef __BORLANDC__
2952  dists = sqrt(double((a_x - pt.m_x)*(a_x - pt.m_x) + (a_y - pt.m_y) * (a_y - pt.m_y)));
2953 #else
2954  //dists = sqrt((a_x - pt.m_x)*(a_x - pt.m_x) + (a_y - pt.m_y) * (a_y - pt.m_y));
2955  dists = (abs(a_x - pt.m_x) + abs(a_y - pt.m_y));
2956 #endif
2957  if (dists > best) { best = dists; ind = d; }
2958  }
2959  if (ind > -1)
2960  {
2961  // best /= 2;
2962  if (best >= 10)
2963  {
2964  a_x += m_x_add[ind] * 10;
2965  a_y += m_y_add[ind] * 10;
2966  return;
2967  }
2968  }
2969  return; // Found it so return even without the 10 distance
2970  }
2971  }
2972  a_x = sx + loop;
2973  for (int j = 0 - (loop - 1); j< loop; j++)
2974  {
2975  a_y = sy + j;
2976  CorrectCoords(a_x, a_y);
2977  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2978  {
2979  APoint pt(a_x, a_y);
2980  double dists = -1;
2981  double best = -1;
2982  int ind = -1;
2983  for (int d = 0; d < 8; d++)
2984  {
2985  AxisLoopLtd(a_polyref, &pt, d,10);
2986 #ifdef __BORLANDC__
2987  dists = sqrt(double((a_x - pt.m_x)*(a_x - pt.m_x) + (a_y - pt.m_y) * (a_y - pt.m_y)));
2988 #else
2989  //dists = sqrt((a_x - pt.m_x)*(a_x - pt.m_x) + (a_y - pt.m_y) * (a_y - pt.m_y));
2990  dists = (abs(a_x - pt.m_x) + abs(a_y - pt.m_y));
2991 #endif
2992  if (dists > best) { best = dists; ind = d; }
2993  }
2994  if (ind > -1)
2995  {
2996  // best /= 2;
2997  if (best >= 10)
2998  {
2999  a_x += m_x_add[ind] * 10;
3000  a_y += m_y_add[ind] * 10;
3001  return;
3002  }
3003  }
3004  return; // Found it so return even without the 10 distance
3005  }
3006  }
3007  a_x = sx - loop;
3008  for (int j = 0 - (loop - 1); j< loop; j++)
3009  {
3010  a_y = sy + j;
3011  CorrectCoords(a_x, a_y);
3012  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3013  {
3014  APoint pt(a_x, a_y);
3015  double dists = -1;
3016  double best = -1;
3017  int ind = -1;
3018  for (int d = 0; d < 8; d++)
3019  {
3020  AxisLoopLtd(a_polyref, &pt, d,10);
3021 #ifdef __BORLANDC__
3022  dists = sqrt(double((a_x - pt.m_x)*(a_x - pt.m_x) + (a_y - pt.m_y) * (a_y - pt.m_y)));
3023 #else
3024  //dists = sqrt((a_x - pt.m_x)*(a_x - pt.m_x) + (a_y - pt.m_y) * (a_y - pt.m_y));
3025  dists = (abs(a_x - pt.m_x) + abs(a_y - pt.m_y));
3026 #endif
3027  if (dists > best) { best = dists; ind = d; }
3028  }
3029  if (ind > -1)
3030  {
3031  // best /= 2;
3032  if (best >= 10)
3033  {
3034  a_x += m_x_add[ind] * 10;
3035  a_y += m_y_add[ind] * 10;
3036  return;
3037  }
3038  }
3039  return; // Found it so return even without the 10 distance
3040  }
3041  }
3042  loop++;
3043  } while (loop<m_width); // This stopping rule should hopefully not be needed, it is set very high.
3044  exit(0);
3045 }
int m_width
Definition: landscape.h:127
void CorrectCoords(int &x, int &y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1459
void AxisLoopLtd(int a_poly, APoint *a_cor, int a_axis, int a_limit)
Definition: Landscape.cpp:2692
int m_y_add[8]
Definition: landscape.h:245
int m_x_add[8]
Definition: landscape.h:244
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1417
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:50
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.

1938  {
1944  cout << "In Change Map Mapping" << endl;
1945  int mapwidth = m_land->MapWidth();
1946  int mapheight = m_land->MapHeight();
1947  int pest_map_width = mapwidth >> PEST_GRIDSIZE_POW2;
1948  if ( mapwidth & ( PEST_GRIDSIZE - 1 ) ) pest_map_width++;
1949  int oldindex = -1;
1950  for ( int x = 0; x < mapwidth; x++ )
1951  {
1952  for ( int y = 0; y < mapheight; y++ )
1953  {
1954  int polynum = m_land->Get( x, y ); // the polyref e.g. = 1, m_polymapping[ polynum ] = 0
1955  m_elems[ m_polymapping[ polynum ]]->SetMapIndex( m_polymapping[ polynum ] ); // Here we set index in the map to the index in elements, i.e. 0
1956  m_elems[ m_polymapping[ polynum ]]->SetMapValid( true );
1957  // Do the translation.
1958  m_land->Put( x, y, m_polymapping[ polynum ] ); // and now we write this to the map, i.e. 0
1959  // This coordinate is now valid. Throw these coordinates into
1960  // the associated landscape element.
1961  int index = m_polymapping[ SupplyPolyRef( x, y ) ];
1962  if ( index != oldindex )
1963  {
1964  m_elems[ index ]->SetValidXY( x, y );
1965  int l_x = x >> PEST_GRIDSIZE_POW2;
1966  int l_y = y >> PEST_GRIDSIZE_POW2;
1967  int pref = l_y * pest_map_width + l_x;
1968  m_elems[ index ]->SetPesticideCell( pref );
1969  oldindex = index;
1970  }
1971  }
1972  }
1973  RebuildPolyMapping();
1974 /*
1975 // Check that all of the polygons are mentioned in the map.
1976  if ( l_map_check_polygon_xref.value() )
1977  {
1978  for ( unsigned int i = 0; i < m_elems.size(); i++ )
1979  {
1980  if ( !m_elems[ i ]->GetMapValid() ) {
1981  char poly[ 20 ];
1982  sprintf( poly, "%d", m_elems[ i ]->GetPoly() );
1983  g_msg->Warn( WARN_FILE, "Landscape::ChangeMapMapping(): ""Polygon number referenced but not in map file: ", poly );
1984  exit( 1 );
1985  }
1986  }
1987  }
1988 */
1989 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1412
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void RebuildPolyMapping()
Definition: landscape.h:191
RasterMap * m_land
The big map.
Definition: landscape.h:122
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool Landscape::CIPELandscapeMaker ( )
protected
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.

1170 {
1176  const int TypesToReplace = 18;
1177  TTypesOfLandscapeElement replaceList[TypesToReplace] = { tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_StoneWall, tole_BareRock, tole_BuiltUpWithParkland,
1178  tole_Carpark, tole_Churchyard, tole_Coast, tole_Garden, tole_HeritageSite,
1179  tole_IndividualTree, tole_PlantNursery, tole_Saltwater, tole_SandDune, tole_UrbanNoVeg };
1180  int foundList[TypesToReplace];
1181  cout << "Consolidating polygons with no special behaviour" << endl;
1182  for (int i = 0; i < TypesToReplace; i++) foundList[i] = -1;
1183  int mapwidth = m_land->MapWidth();
1184  int mapheight = m_land->MapHeight();
1185  for (int x = 0; x < mapwidth; x++)
1186  {
1187  for (int y = 0; y < mapheight; y++)
1188  {
1189  int ele = m_land->Get(x, y);
1190  TTypesOfLandscapeElement tole = m_elems[m_polymapping[ele]]->GetElementType();
1191  for (int t = 0; t < TypesToReplace; t++)
1192  {
1193  if (tole == replaceList[t])
1194  {
1195  // Must do something with this cell
1196  if (foundList[t] == -1) foundList[t] = ele;
1197  else
1198  {
1199  // Need to replace this cell
1200  m_land->Put(x, y, foundList[t]);
1201  }
1202  }
1203  }
1204  }
1205  }
1206  // At this point there should be many polygons that are not in the map. So we need to run the valid test.
1207  g_msg->Warn(WARN_FILE, "Landscape::ConsolidatePolys() - ""Consolidate map dump.", "");
1208 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
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.

1460 {
1464  x = (m_width10 + x) % m_width;
1465  y = (m_height10 + y) % m_height;
1466 }
int m_height10
Definition: landscape.h:130
int m_width
Definition: landscape.h:127
int m_height
Definition: landscape.h:128
int m_width10
Definition: landscape.h:129
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

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

1480 {
1484  if (a_pt.m_x >= m_width) a_pt.m_x = m_width - 1;
1485  if (a_pt.m_y >= m_height) a_pt.m_y = m_height - 1;
1486  if (a_pt.m_x < 0) a_pt.m_x = 0;
1487  if (a_pt.m_y < 0) a_pt.m_y = 0;
1488 }
int m_width
Definition: landscape.h:127
int m_y
Definition: ALMaSS_Setup.h:54
int m_height
Definition: landscape.h:128
int m_x
Definition: ALMaSS_Setup.h:53
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.

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

1469 {
1473  APoint pt;
1474  pt.m_x = (m_width10 + x) % m_width;
1475  pt.m_y = (m_height10 + y) % m_height;
1476  return pt;
1477 }
int m_height10
Definition: landscape.h:130
int m_width
Definition: landscape.h:127
int m_y
Definition: ALMaSS_Setup.h:54
int m_height
Definition: landscape.h:128
int m_width10
Definition: landscape.h:129
int m_x
Definition: ALMaSS_Setup.h:53
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:50
int Landscape::CorrectHeight ( int  y)
inline
1498 {
1499  return (m_height10+y)%m_height;
1500 }
int m_height10
Definition: landscape.h:130
int m_height
Definition: landscape.h:128
int Landscape::CorrectWidth ( int  x)
inline
1492 {
1493  return (m_width10+x)%m_width;
1494 }
int m_width
Definition: landscape.h:127
int m_width10
Definition: landscape.h:129
void Landscape::CountMapSquares ( void  )
protected
1848  {
1849  int mapwidth = m_land->MapWidth();
1850  int mapheight = m_land->MapHeight();
1851  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1852  m_elems[i]->SetArea(0);
1853  m_elems[ i ]->m_squares_in_map=0;
1854  }
1855 
1856  for ( int x = 0; x < mapwidth; x++ ) {
1857  for ( int y = 0; y < mapheight; y++ ) {
1858  int l_ele = m_land->Get( x, y );
1859  m_elems[ l_ele ]->m_squares_in_map++;
1860  }
1861  }
1862 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
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

2370 {
2372  for (unsigned int i = 0; i < m_elems.size(); i++)
2373  {
2374  if (m_elems[i]->GetElementType() == tole_Pond) {
2375  m_PondIndexList.push_back(i);
2376  m_PondRefsList.push_back(m_elems[i]->GetPoly());
2377  }
2378  }
2379 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
vector< int > m_PondIndexList
List of pond indexes.
Definition: landscape.h:175
vector< int > m_PondRefsList
List of pond polyrefs.
Definition: landscape.h:177
void Landscape::DegreesDump ( )
protected

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

1492  {
1493 
1494  ofstream ofile ("Daydegrees.txt", ios::app);
1495  //print degrees
1496  ofile << m_FarmManager->GetDD();
1497  ofile << endl;
1498  ofile.close();
1499 }
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
void Landscape::DumpAllSymbolsAndExit ( const char *  a_dumpfile)
inline
732  {
733  g_cfg->DumpAllSymbolsAndExit( a_dumpfile );
734  }
void Landscape::DumpCentroids ( void  )
3049 {
3050  ofstream centroidfile("PolygonCentroids.txt", ios::out);
3051  centroidfile<<"Polyref"<<'\t'<<"CX"<<'\t'<<"CY"<<'\t'<<"Type"<<'\t'<<"Area"<<'\t'<<"Country Designation"<<endl;
3052  for (int p = 0; p< (int)m_elems.size(); p++)
3053  {
3054  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;
3055  }
3056  centroidfile.close();
3057 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void Landscape::DumpMap ( const char *  a_filename)
protected
1212 {
1213  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.
1214  /* FILE * l_file;
1215  l_file = fopen(a_filename, "wb" );
1216  if ( !l_file ) {
1217  g_msg->Warn( WARN_FILE, "Landscape::DumpMap(): Unable to open file", a_filename );
1218  exit( 0 );
1219  }
1220 
1221  char * l_id = m_land->GetID();
1222 
1223 
1224  fwrite( l_id, 1, 12, l_file );
1225  fwrite( & m_width, 1, sizeof( int ), l_file );
1226  if (cfg_rectangularmaps_on.value() )
1227  {
1228  fwrite( & m_height, 1, sizeof( int ), l_file );
1229  }
1230  for ( int i = 0; i < m_width * m_height; i++ )
1231  {
1232  LE* le = m_elems[m_polymapping[l_map[i]]];
1233  int l_poly = le->GetPoly();
1234  fwrite( & l_poly, 1, sizeof( int ), l_file );
1235  }
1236  fclose( l_file );
1237  */
1238  ofstream OFile( a_filename, ios::binary);
1239  char id[12] = { "LSB2_Format" };
1240  OFile.write(id, 12);
1241  OFile.write((char*)&m_width, sizeof (int));
1242  OFile.write((char*)&m_height, sizeof (int));
1243  OFile.write((char*)l_map, m_width*m_height*sizeof (int));
1244  OFile.close();
1245 }
int m_width
Definition: landscape.h:127
int m_height
Definition: landscape.h:128
RasterMap * m_land
The big map.
Definition: landscape.h:122
void Landscape::DumpMapGraphics ( const char *  a_filename)
protected
3357  {
3358  unsigned int linesize = m_maxextent * 3;
3359  unsigned char * frame_buffer = (unsigned char *)malloc(sizeof(unsigned char)* linesize);
3360 
3361  if (frame_buffer == NULL) {
3362  g_msg->Warn(WARN_FILE, "Landscape::DumpMapGraphics(): Out of memory!", "");
3363  exit(1);
3364  }
3365 
3366  FILE * l_file = fopen(a_filename, "w");
3367  if (!l_file) {
3368  g_msg->Warn(WARN_FILE, "Landscape::DumpMapGraphics(): ""Unable to open file for writing: %s\n", a_filename);
3369  exit(1);
3370  }
3371 
3372  fprintf(l_file, "P6\n%d %d %d\n", m_width, m_height, 255);
3373 
3374  for (int y = 0; y < m_height; y++) {
3375  int i = 0;
3376  for (int x = 0; x < m_width; x++) {
3377  int eletype = (int)SupplyElementType(x, y);
3378  int localcolor = 16777215 / eletype;
3379 
3380  if (eletype == (int)tole_Field) {
3381  int category;
3382  double hei = SupplyVegHeight(x, y);
3383  if (hei > 50.0) category = 0; else category = (int)(200.0 - (hei * 4.0));
3384  localcolor = ((category * 65536) + 65535);
3385  }
3386 
3387  frame_buffer[i++] = (unsigned char)(localcolor & 0xff);
3388  frame_buffer[i++] = (unsigned char)((localcolor >> 8) & 0xff);
3389  frame_buffer[i++] = (unsigned char)((localcolor >> 16) & 0xff);
3390  }
3391  fwrite(frame_buffer, sizeof(unsigned char), linesize, l_file);
3392  }
3393 
3394  fclose(l_file);
3395 
3396  free(frame_buffer);
3397 }
int m_width
Definition: landscape.h:127
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1029
int m_height
Definition: landscape.h:128
int m_maxextent
Definition: landscape.h:131
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:855
void Landscape::DumpMapInfoByArea ( const char *  a_filename,
bool  a_append,
bool  a_dump_zero_areas,
bool  a_write_veg_names 
)
3410  {
3411  FillVegAreaData();
3412  FILE * outf;
3413  if (a_append) {
3414  outf = fopen(a_filename, "a");
3415  if (!outf) {
3416  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to open file for appending", a_filename);
3417  exit(1);
3418  }
3419  }
3420  else {
3421  outf = fopen(a_filename, "w");
3422  if (!outf) {
3423  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to open file for writing", a_filename);
3424  exit(1);
3425  }
3426  }
3427 
3428  // Emit element type info.
3429  for (unsigned int i = 0; i < tov_Undefined + 1; i++) {
3430  if (i == tov_OFirstYearDanger)
3431  continue;
3432  if (!a_dump_zero_areas && l_vegtype_areas[i] < 0.5)
3433  continue;
3434 
3435  fprintf(outf, "%6ld\t%3d\t%10.0f", g_date->OldDays() + g_date->DayInYear() - 364, i, l_vegtype_areas[i]);
3436  if (a_write_veg_names)
3437  fprintf(outf, "\t%s\n", VegtypeToString((TTypesOfVegetation)i).c_str()); else
3438  fprintf(outf, "\n");
3439  }
3440 
3441  fclose(outf);
3442 }
std::string VegtypeToString(TTypesOfVegetation a_veg)
Definition: Landscape.cpp:3937
void FillVegAreaData()
Definition: Landscape.cpp:3399
double * l_vegtype_areas
Definition: landscape.h:141
void Landscape::DumpPublicSymbols ( const char *  a_dumpfile,
CfgSecureLevel  a_level 
)
inline
729  {
730  g_cfg->DumpPublicSymbols( a_dumpfile, a_level );
731  }
void Landscape::DumpTreatCounters ( const char *  a_filename)
protected
3344  {
3345  FILE * l_file = fopen(a_filename, "w");
3346  if (!l_file) {
3347  g_msg->Warn(WARN_FILE, "Landscape::DumpTreatCounters(): ""Unable to open file for writing: %s\n", a_filename);
3348  exit(1);
3349  }
3350 
3351  for (int i = start; i < last_treatment; i++) {
3352  fprintf(l_file, "%3d %s %10d\n", i, EventtypeToString(i).c_str(), m_treatment_counts[i]);
3353  }
3354  fclose(l_file);
3355 }
int m_treatment_counts[last_treatment]
Definition: landscape.h:171
std::string EventtypeToString(int a_event)
Definition: Landscape.cpp:3664
void Landscape::DumpVegAreaData ( int  a_day)

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

Referenced by RunTheSim().

4289  {
4290 
4291  if (cfg_dumpvegjan.value()) {
4292  if ((a_day % 365) == 0) { // Jan 1st
4293  DumpMapInfoByArea(cfg_dumpvegjanfile.value(), true, true, true);
4294  return;
4295  }
4296  }
4297  if (cfg_dumpvegjune.value()) {
4298  if ((a_day % 365) == 152) { // 1st June
4299  DumpMapInfoByArea(cfg_dumpvegjunefile.value(), true, true, true);
4300  }
4301  }
4302 
4303 }
void DumpMapInfoByArea(const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
Definition: Landscape.cpp:3410
CfgBool cfg_dumpvegjune("G_VEGAREASJUNE_ON", CFG_CUSTOM, false)
CfgStr cfg_dumpvegjunefile("G_VEGAREASJUNE_FILENAME", CFG_CUSTOM,"DUMPVEG_JUNE.TXT")
CfgBool cfg_dumpvegjan("G_VEGAREASJAN_ON", CFG_CUSTOM, false)
CfgStr cfg_dumpvegjanfile("G_VEGAREASJAN_FILENAME", CFG_CUSTOM,"DUMPVEG_JAN.TXT")
void Landscape::EventDump ( int  x,
int  y,
int  x2,
int  y2 
)
protected
1502  {
1503  FILE * vfile=fopen("EventDump.txt", "a" );
1504  if (!vfile) {
1505  g_msg->Warn( WARN_FILE, "Landscape::EventDump(): Unable to open file", "EventDump.txt" );
1506  exit( 1 );
1507  }
1508  FarmToDo event;
1509  int i = 0;
1510  int day = SupplyDayInYear();
1511  fprintf( vfile, "%d: ", day );
1512  while ( ( event = ( FarmToDo )SupplyLastTreatment( x1, y1, & i ) ) != sleep_all_day ) {
1513  fprintf( vfile, "%d ", event );
1514  }
1515  i = 0;
1516  fprintf( vfile, " - " );
1517  while ( ( event = ( FarmToDo )SupplyLastTreatment( x2, y2, & i ) ) != sleep_all_day ) {
1518  fprintf( vfile, "%d ", event );
1519  }
1520  fprintf( vfile, "\n" );
1521  fclose( vfile );
1522 }
int SupplyDayInYear(void)
Definition: landscape.h:1520
int SupplyLastTreatment(int a_polyref, int *a_index)
Definition: landscape.h:1253
void Landscape::EventDumpPesticides ( int  x1,
int  y1 
)
protected
1525  {
1526  FILE * vfile=fopen("EventDump.txt", "a" );
1527  if (!vfile) {
1528  g_msg->Warn( WARN_FILE, "Landscape::EventDump(): Unable to open file", "EventDump.txt" );
1529  exit( 1 );
1530  }
1531  FarmToDo a_event;
1532  int i = 0;
1533  int day = this->SupplyGlobalDate();
1534  int herb = 0;
1535  int fung = 0;
1536  int ins = 0;
1537  while ( ( a_event = ( FarmToDo )SupplyLastTreatment( x1, y1, & i ) ) != sleep_all_day ) {
1538  if (a_event == herbicide_treat )
1539  {
1540  herb++;
1541  }
1542  else if (a_event == fungicide_treat ) fung++;
1543  else if (a_event == insecticide_treat) ins++;
1544  }
1545  if (herb+fung+ins >0 ) fprintf( vfile, "%d\t%d\t%d\t%d\n", day, herb, fung, ins );
1546  i = 0;
1547  fclose( vfile );
1548 }
long SupplyGlobalDate(void)
Definition: landscape.h:1545
int SupplyLastTreatment(int a_polyref, int *a_index)
Definition: landscape.h:1253
std::string Landscape::EventtypeToString ( int  a_event)
3664  {
3665  char error_num[20];
3666 
3667  switch (a_event) {
3668  case start:
3669  return " start";
3670  case sleep_all_day:
3671  return " sleep_all_day";
3672  case autumn_plough:
3673  return " autumn_plough";
3674  case autumn_harrow:
3675  return " autumn_harrow";
3676  case autumn_roll:
3677  return " autumn_roll";
3678  case autumn_sow:
3679  return " autumn_sow";
3680  case winter_plough:
3681  return " winter_plough";
3682  case deep_ploughing:
3683  return " deep_ploughing";
3684  case spring_plough:
3685  return " spring_plough";
3686  case spring_harrow:
3687  return " spring_harrow";
3688  case spring_roll:
3689  return " spring_roll";
3690  case spring_sow:
3691  return " spring_sow";
3692  case fp_npks:
3693  return " fp_npks";
3694  case fp_npk:
3695  return " fp_npk";
3696  case fp_pk:
3697  return " fp_pk";
3698  case fp_liquidNH3:
3699  return " fp_liquidNH3";
3700  case fp_slurry:
3701  return " fp_slurry";
3702  case fp_manganesesulphate:
3703  return " fp_manganesesulphate";
3704  case fp_manure:
3705  return " fp_manure";
3706  case fp_greenmanure:
3707  return " fp_greenmanure";
3708  case fp_sludge:
3709  return " fp_sludge";
3710  case fa_npk:
3711  return " fa_npk";
3712  case fa_pk:
3713  return " fa_pk";
3714  case fa_slurry:
3715  return " fa_slurry";
3716  case fa_ammoniumsulphate:
3717  return " fa_ammoniumsulphate";
3718  case fa_manure:
3719  return " fa_manure";
3720  case fa_greenmanure:
3721  return " fa_greenmanure";
3722  case fa_sludge:
3723  return " fa_sludge";
3724  case herbicide_treat:
3725  return " herbicide_treat";
3726  case growth_regulator:
3727  return " growth_regulator";
3728  case fungicide_treat:
3729  return " fungicide_treat";
3730  case insecticide_treat:
3731  return " insecticide_treat";
3732  case product_treat:
3733  return "pesticide_product_treat";
3734  case syninsecticide_treat:
3735  return " syninsecticide_treat";
3736  case molluscicide:
3737  return " molluscicide";
3738  case row_cultivation:
3739  return " row_cultivation";
3740  case strigling:
3741  return " strigling";
3742  case flammebehandling:
3743  return " flammebehandling";
3744  case hilling_up:
3745  return " hilling_up";
3746  case water:
3747  return " water";
3748  case swathing:
3749  return " swathing";
3750  case harvest:
3751  return " harvest";
3752  case cattle_out:
3753  return " cattle_out";
3754  case pigs_out:
3755  return " pigs_out";
3756  case cut_to_hay:
3757  return " cut_to_hay";
3758  case cut_to_silage:
3759  return " cut_to_silage";
3760  case straw_chopping:
3761  return " straw_chopping";
3762  case hay_turning:
3763  return " hay_turning";
3764  case hay_bailing:
3765  return " hay_bailing";
3766  case stubble_harrowing:
3767  return " stubble_harrowing";
3768  case autumn_or_spring_plough:
3769  return "autumn_or_spring_plough";
3770  case burn_straw_stubble:
3771  return " burn_straw_stubble";
3772  case mow:
3773  return " mow";
3774  case cut_weeds:
3775  return " cut_weeds";
3776  case strigling_sow:
3777  return " strigling_sow";
3778  case trial_insecticidetreat:
3779  return "PesticideTrialTreatment";
3780  case trial_toxiccontrol:
3781  return " PesticideTrialToxic";
3782  case trial_control:
3783  return " PesticideTrialControl";
3784  case glyphosate:
3785  return " Glyphosate on setaside";
3786  default:
3787  sprintf(error_num, "%d", a_event);
3788  g_msg->Warn(WARN_FILE, "Landscape::EventtypeToString(): Unknown event type:", error_num);
3789  exit(1);
3790  }
3791 }
void Landscape::FillVegAreaData ( )
3399  {
3400  for (unsigned int i = 0; i < (tov_Undefined + 1); i++) {
3401  l_vegtype_areas[i] = 0.0;
3402  }
3403 
3404  // Sum up statistics on element type.
3405  for (unsigned int i = 0; i < m_elems.size(); i++) {
3406  l_vegtype_areas[m_elems[i]->GetVegType()] += m_elems[i]->GetArea();
3407  }
3408 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
double * l_vegtype_areas
Definition: landscape.h:141
bool Landscape::FindFieldCenter ( LE a_field,
int x,
int y 
)
protected

References LE::GetPoly().

2574  {
2575  // Start at x,y
2576  // 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.
2577  // Then do it again, and again until we don't move more than 1m or we have tried too many times
2578  int ourpoly=SupplyPolyRef(*(x),*(y));
2579  if (ourpoly!=a_field->GetPoly()) return false;
2580  int centers[2][8];
2581  int tries=0;
2582  int diff=999;
2583  int x1=*(x);
2584  int y1=*(y);
2585  int centreX=x1;
2586  int centreY=y1;
2587  // 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
2588  while ((diff>1) & (tries++<100)) {
2589  for (unsigned v=0; v<4; v++) {
2590  x1=centreX;
2591  y1=centreY;
2592  AxisLoop(ourpoly, &x1, &y1, v);
2593  centers[0][v]=x1-m_x_add[v];
2594  centers[1][v]=y1-m_y_add[v];
2595  x1=centreX;
2596  y1=centreY;
2597  AxisLoop(ourpoly, &x1, &y1, v+4);
2598  centers[0][v+4]=x1-m_x_add[v+4];
2599  centers[1][v+4]=y1-m_y_add[v+4];
2600 // centreX+=((centers[0][v]+x1-m_x_add[v+4])/2);
2601 // centreY+=((centers[1][v]+y1-m_y_add[v+4])/2);
2602  }
2603  int oldx=centreX;
2604  int oldy=centreY;
2605  centreX=0;
2606  centreY=0;
2607  for (int h=0; h<8; h++) {
2608  centreX+=centers[0][h];
2609  centreY+=centers[1][h];
2610  }
2611  centreX/=8;
2612  centreY/=8;
2613  diff=abs(oldx-centreX)+abs(oldy-centreY);
2614  }
2615  *(x)=centreX;
2616  *(y)=centreY;
2617  int tourpoly=SupplyPolyRef(*(x),*(y));
2618  if (tourpoly!=ourpoly) {
2619  return false; // can happen eg if there is a pond in the middle of the field
2620  }
2621 
2622  return true;
2623 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1412
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: elements.h:189
int m_y_add[8]
Definition: landscape.h:245
void AxisLoop(int a_poly, int *a_x, int *a_y, int a_axis)
Definition: Landscape.cpp:2713
int m_x_add[8]
Definition: landscape.h:244
int Landscape::FindLongestAxis ( int x,
int y,
int a_length 
)
protected
2627 {
2628  int ourpoly=SupplyPolyRef(*(a_x),*(a_y));
2629  int dist[4];
2630  int distx[8];
2631  int disty[8];
2632  int found = -1;
2633  *(a_length) = 0;
2634  int dx[8];
2635  int dy[8];
2636  int fx[8];
2637  int fy[8];
2638  for (unsigned v=0; v<8; v++)
2639  {
2640  int x1=*(a_x);
2641  int y1=*(a_y);
2642  AxisLoop(ourpoly, &x1, &y1, v);
2643  x1 -= m_x_add[v];
2644  y1 -= m_y_add[v];
2645  dx[v] = abs(*(a_x)-x1);
2646  dy[v] = abs(*(a_y)-y1);
2647  fx[v] = x1;
2648  fy[v] = y1;
2649  distx[v] = dx[v];
2650  disty[v] = dy[v];
2651  }
2652  for (int di = 0; di < 4; di++)
2653  {
2654  int dx = distx[di] + distx[di + 4];
2655  int dy = disty[di] + disty[di + 4];
2656  if (dx == 0) dist[di] = dy; else dist[di] = dx;
2657  if (dist[di] > *(a_length))
2658  {
2659  found = di;
2660  *(a_length) = dist[di];
2661  }
2662  }
2663  if (found == -1) return 0;
2664  // Now need to find the middle of the axis.
2665  int l = (*(a_length) / 2);
2666  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;
2667  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;
2668 
2669  return found;
2670 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1412
int m_y_add[8]
Definition: landscape.h:245
void AxisLoop(int a_poly, int *a_x, int *a_y, int a_axis)
Definition: Landscape.cpp:2713
int m_x_add[8]
Definition: landscape.h:244
bool Landscape::FindValidXY ( int  a_field,
int a_x,
int a_y 
)
protected
2463  {
2464  // From a hopefully sensible starting point this method scans in the
2465  // 8 directions to find a good valid x and y matching a_field
2466  int x_add[ 8 ] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2467  int y_add[ 8 ] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2468  int index;
2469  int nx, ny;
2470  int width = m_land->MapWidth();
2471  int height = m_land->MapHeight();
2472  // Assume it has to within 100m
2473  for ( int i = 0; i < 100; i++ ) {
2474  for ( int l = 0; l < 8; l++ ) {
2475  nx = a_x + x_add[ l ] * i;
2476  ny = a_y + y_add[ l ] * i;
2477  if ( ( nx < width ) && ( nx >= 0 ) && ( ny < height ) && ( ny >= 0 ) ) {
2478  index = m_land->Get( nx, ny );
2479  if ( index == a_field ) {
2480  a_x = a_x + x_add[ l ] * i;
2481  a_y = a_y + y_add[ l ] * i;
2482  return true;
2483  }
2484  }
2485  }
2486  }
2487  return false;
2488 }
RasterMap * m_land
The big map.
Definition: landscape.h:122
void Landscape::ForceArea ( void  )
protected
1880  {
1881  int l_area_sum = 0;
1882 
1883  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1884  m_elems[ i ]->SetArea( ( double )m_elems[ i ]->m_squares_in_map );
1885  if ( m_elems[ i ]->m_squares_in_map > 0 ) {
1886  m_elems[ i ]->SetMapValid( true );
1887  l_area_sum += m_elems[ i ]->m_squares_in_map;
1888  }
1889  }
1890 
1891  if ( l_area_sum != m_width * m_height ) {
1892  g_msg->Warn( WARN_BUG, "Landscape::ForceArea(): Polygon areas doesn't"" sum up to map area!", "" );
1893  exit( 1 );
1894  }
1895 }
int m_width
Definition: landscape.h:127
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int m_height
Definition: landscape.h:128
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
558  {
559  return m_elems[m_land->Get(a_x, a_y)]->GetGooseGrazingForage(a_goose);
560  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
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
569  {
570  return m_elems[m_polymapping[a_polygon]]->GetGooseGrazingForage(a_goose);
571  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
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.

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::vegheight, GooseFieldListItem::vegphase, GooseFieldListItem::vegtype, and GooseFieldListItem::vegtypechr.

559 {
566  GooseFieldList* alist = new GooseFieldList;
570  GooseFieldListItem gfli;
571  for (unsigned int i = 0; i < m_elems.size(); i++)
572  {
573  if (m_elems[i]->GetOpenness() > a_minopenness)
574  {
575  for (int g = gs_Pinkfoot; g < gs_foobar; g++)
576  {
577  gfli.grass[g] = m_elems[i]->GetGooseGrazingForage((GooseSpecies)g);
578  gfli.geesesp[g] = m_elems[i]->GetGooseSpNosToday((GooseSpecies)g);
579  gfli.geesespTimed[g] = m_elems[i]->GetGooseSpNosTodayTimed((GooseSpecies)g);
580  }
581  gfli.grain = m_elems[i]->GetBirdSeed();
582  gfli.maize = m_elems[ i ]->GetBirdMaize();
583  gfli.openness = m_elems[ i ]->GetOpenness();
584  int pref = m_elems[ i ]->GetPoly();
585  gfli.polyref = pref;
586  gfli.geese = m_elems[i]->GetGooseNosToday();
587  gfli.geeseTimed = m_elems[i]->GetGooseNosTodayTimed();
588  gfli.vegtype = m_elems[i]->GetVegType();
589  gfli.vegtypechr = VegtypeToString(m_elems[i]->GetVegType());
590  gfli.vegheight = m_elems[i]->GetVegHeight();
591  gfli.digestability = m_elems[i]->GetDigestability();
592  gfli.vegphase = m_elems[i]->GetVegPhase();
593  gfli.previouscrop = VegtypeToString( m_elems[ i ]->GetPreviousCrop( m_elems[ i ]->GetRotIndex() ) );
594  gfli.lastsownveg = VegtypeToString( m_elems[ i ]->GetLastSownVeg() );
595  alist->push_back(gfli);
596  }
597  }
598  return alist;
599 }
double vegheight
Definition: landscape.h:91
int geeseTimed
Definition: landscape.h:83
std::string previouscrop
Definition: landscape.h:94
double grass[gs_foobar]
Definition: landscape.h:88
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
std::string lastsownveg
Definition: landscape.h:95
int polyref
Definition: landscape.h:80
std::string VegtypeToString(TTypesOfVegetation a_veg)
Definition: Landscape.cpp:3937
int geesesp[gs_foobar]
Definition: landscape.h:82
TTypesOfVegetation vegtype
Definition: landscape.h:89
A list item entry of field polygon reference numbers with associated openness and goose food scores...
Definition: landscape.h:78
double maize
Definition: landscape.h:87
std::vector< GooseFieldListItem > GooseFieldList
A list of GooseFieldListItem s.
Definition: landscape.h:100
double digestability
Definition: landscape.h:92
std::string vegtypechr
Definition: landscape.h:90
int geesespTimed[gs_foobar]
Definition: landscape.h:84
double openness
Definition: landscape.h:85
int geese
Definition: landscape.h:81
double grain
Definition: landscape.h:86
int vegphase
Definition: landscape.h:93
int Landscape::GetGooseNumbers ( int  a_poly)

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

3148  {
3149  return m_elems[m_polymapping[a_polyref]]->GetGooseNos();
3150  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
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.

3157  {
3158  return m_elems[m_land->Get(a_x, a_y)]->GetGooseNos();
3159  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::GetHareFoodQuality ( int  a_polygon)

References g_FarmIntensivenessH.

3163 {
3164  double digest;
3165  TTypesOfLandscapeElement habitat = SupplyElementType(a_polygon);
3166  switch (habitat) {
3167  // Impossible stuff
3168  case tole_Building:
3169  case tole_Pond:
3170  case tole_Freshwater:
3171  case tole_River:
3172  case tole_Saltwater:
3173  case tole_Coast:
3174  case tole_BareRock:
3175  case tole_ConiferousForest:
3176  case tole_DeciduousForest:
3177  case tole_MixedForest:
3178  case tole_SmallRoad:
3179  case tole_LargeRoad:
3180  case tole_ActivePit:
3181  case tole_UrbanNoVeg:
3182  case tole_UrbanPark:
3183  case tole_SandDune:
3184  case tole_Copse:
3185  case tole_Stream:
3186  case tole_MetalledPath:
3187  case tole_Carpark:
3188  case tole_FishFarm:
3189  // 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
3190  return 0.0;
3191 
3192  // Questionable stuff
3193  case tole_RiversidePlants:
3194  case tole_RiversideTrees:
3195  case tole_Garden:
3196  case tole_Track:
3197  case tole_StoneWall:
3198  case tole_Hedges:
3199  case tole_Marsh:
3200  case tole_PitDisused:
3201  case tole_RoadsideVerge:
3202  case tole_Railway:
3203  case tole_Scrub:
3204  case tole_AmenityGrass:
3205  case tole_Parkland:
3206  case tole_BuiltUpWithParkland:
3207  case tole_Churchyard:
3208  case tole_HeritageSite:
3209  return 0.25; // was 0.25 being half of access to low digestability stuff
3210  // case tole_MownGrass:
3211  // 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.
3213  case tole_Wasteland:
3214  case tole_IndividualTree:
3215  case tole_WoodyEnergyCrop:
3216  case tole_PlantNursery:
3217  case tole_Pylon:
3218  case tole_WindTurbine:
3219  case tole_WoodlandMargin:
3220  case tole_Vildtager:
3221  default:
3222  digest = SupplyVegDigestability(a_polygon);
3223  }
3224 #ifdef __Perfectfood
3225  return 0.8;
3226 #else
3227 #ifdef __YEARLYVARIABLEFOODQUALITY
3228  digest *= m_OurPopulationManager->m_GoodYearBadYear;
3229 #endif
3230  double veg_height;
3231  double access = 1.0;
3232  // double grazedreduction[4] = { 1.0, 0.75, 0.5, 0.25 };
3233  double grazedreduction[4] = { 1.0, 0.8, 0.2, 0.05 };
3234  veg_height = SupplyVegHeight(a_polygon);
3235  double weeds = SupplyWeedBiomass(a_polygon);
3236  if ((veg_height <= 0) && (weeds < 0.1)) return 0.25; // Always something to eat, but not much.
3237 #ifdef __Hare1950s
3238  bool veg_patchy = true;
3239 #else // If it is not the special case of the 1950s
3240  //
3241  bool veg_patchy = SupplyVegPatchy(a_polygon);
3242 #endif
3243  if (veg_patchy)
3244  {
3245  // Patchy vegetation - normally full access
3246  if (veg_height>50)
3247  {
3248  // no food at only at very very tall
3249  access -= ((veg_height - 50)* g_VegHeightForageReduction);
3250  if (access<0) access = 0;
3251  }
3252  }
3253  else
3254  {
3255  if (veg_height>g_FarmIntensivenessH)
3256  {
3257  access -= ((veg_height - g_FarmIntensivenessH)* /* g_FarmIntensiveness * */ g_VegHeightForageReduction);
3258  if (access<0) access = 0;
3259  }
3260  }
3261  return access * digest * grazedreduction[SupplyGrazingPressure(a_polygon)];
3262 #endif
3263 }
double g_VegHeightForageReduction
double g_FarmIntensivenessH
int SupplyGrazingPressure(int a_polyref)
Definition: landscape.h:1146
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1029
double SupplyWeedBiomass(int a_polyref)
Definition: landscape.h:883
bool SupplyVegPatchy(int a_polyref)
Definition: landscape.h:905
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:855
double SupplyVegDigestability(int a_polyref)
Definition: landscape.h:838
APoint Landscape::GetNextSeed ( int  )
protected
double Landscape::GetVegArea ( int  v)
inline

References DumpVegAreaData().

154 { return l_vegtype_areas[v]; }
double * l_vegtype_areas
Definition: landscape.h:141
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

References l_map_ascii_map_entity().

3265  {
3273  FILE* OFILE;
3274  OFILE = fopen( outpfile.c_str(), "w" );
3275  if (!OFILE) {
3276  g_msg->Warn( WARN_FILE, "Landscape::GISASCII_Output() "
3277  "Unable to open file for writing:",
3278  outpfile );
3279  exit( 1 );
3280  }
3281  char c = '\n';
3282  fprintf(OFILE, "ncols %d\n", m_width);
3283  fprintf(OFILE, "nrows %d\n", m_height);
3284  fprintf(OFILE, "xllcorner %d\n", UTMX );
3285  fprintf(OFILE, "yllcorner %d\n", UTMY );
3286  fprintf(OFILE, "cellsize %d\n", 1 );
3287  fprintf(OFILE, "NODATA_value %d\n", -9999 );
3288  // The polyref loop
3289  if (l_map_ascii_map_entity.value() == 1) {
3290  for (int y = 0; y < m_height; y++) {
3291  for (int x = 0; x < m_width; x++) {
3292  fprintf(OFILE, "%d\t", SupplyPolyRef(x, y));
3293  }
3294  fprintf(OFILE, "%c", c );
3295  }
3296  }
3297  // The element type loop
3298  if (l_map_ascii_map_entity.value() == 2) {
3299  for (int y = 0; y < m_height; y++) {
3300  for (int x = 0; x < m_width; x++) {
3301  fprintf(OFILE, "%d\t", SupplyElementType( x, y ));
3302  }
3303  fprintf( OFILE, "%c", c );
3304  }
3305  }
3306  fclose( OFILE );
3307 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1412
int m_width
Definition: landscape.h:127
static CfgInt l_map_ascii_map_entity("MAP_ASCII_MAP_ENTITY", CFG_CUSTOM, 1)
If we write an ASCII file what should be the mapped entity? 1 = polyref, 2 = elementype.
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1029
int m_height
Definition: landscape.h:128
void Landscape::GrazeVegetation ( int  a_poly,
double  a_forage 
)
inline

Removes grazing forage from a poly per m2.

621  {
622  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetation( a_forage, true );
623  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::GrazeVegetationTotal ( int  a_poly,
double  a_forage 
)
inline

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

627  {
628  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetationTotal( a_forage );
629  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::hb_Add ( void  )
protected
void Landscape::hb_AddNewHedgebanks ( int  a_orig_poly_num)
protected
void Landscape::hb_Cleanup ( void  )
protected
void Landscape::hb_ClearPolygon ( int  a_poly_num)
protected
void Landscape::hb_DownPolyNumbers ( void  )
protected
bool Landscape::hb_FindBoundingBox ( int  a_poly_num)
protected
void Landscape::hb_FindHedges ( void  )
protected
void Landscape::hb_GenerateHBPolys ( void  )
protected
bool Landscape::hb_HasNeighbourColor ( int  a_x,
int  a_y,
int  a_neighbour_color 
)
protected
bool Landscape::hb_HasOtherNeighbour ( int  a_x,
int  a_y 
)
protected
bool Landscape::hb_MapBorder ( int  a_x,
int  a_y 
)
protected
void Landscape::hb_MarkTheBresenhamWay ( void  )
protected
void Landscape::hb_MarkTopFromLocalMax ( int  a_color)
protected
int Landscape::hb_MaxUnpaintedNegNeighbour ( int  a_x,
int  a_y 
)
protected
void Landscape::hb_PaintBorder ( int  a_color)
protected
bool Landscape::hb_PaintWhoHasNeighbourColor ( int  a_neighbour_color,
int  a_new_color 
)
protected
void Landscape::hb_ResetColorBits ( void  )
protected
void Landscape::hb_RestoreHedgeCore ( int  a_orig_poly_number)
protected
int Landscape::hb_StripingDist ( void  )
protected
void Landscape::hb_UpPolyNumbers ( void  )
protected
int Landscape::HowManyPonds ( )
inline

Returns the number of ponds in the landscape.

315 { return int(m_PondIndexList.size()); }
vector< int > m_PondIndexList
List of pond indexes.
Definition: landscape.h:175
void Landscape::IncTreatCounter ( int  a_treat)

Referenced by LE::SetLastTreatment().

3333  {
3334  if (a_treat < 0 || a_treat >= last_treatment) {
3335  char errornum[20];
3336  sprintf(errornum, "%d", a_treat);
3337  g_msg->Warn(WARN_BUG, "Landscape::IncTreatCounter(): Index"" out of range!", errornum);
3338  exit(1);
3339  }
3340  m_treatment_counts[a_treat] ++;
3341 }
int m_treatment_counts[last_treatment]
Definition: landscape.h:171
bool Landscape::IsFieldType ( TTypesOfLandscapeElement  a_tole)
inline
674  {
675  if ((a_tole == tole_Field)
676  || (a_tole == tole_Orchard)
677  || (a_tole == tole_PermanentSetaside)
678  || (a_tole == tole_PermPasture)
679  || (a_tole == tole_PermPastureLowYield)
680  || (a_tole == tole_PermPastureTussocky)
681  || (a_tole == tole_PermPastureTussockyWet)
682  || (a_tole == tole_Vildtager)
683  || (a_tole == tole_YoungForest)
684  || (a_tole == tole_WoodyEnergyCrop)
685  ) return true;
686  return false;
687  }
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

440 {
445  int d1=-1;
446  int counter = 1;
447  bool found = false;
448  while (!found)
449  {
451  int x = (int) (a_cx + a_offsetx * counter);
452  int y = (int) (a_cy + a_offsety * counter);
453  if (x<1 || x >= (m_width-2) || y<1 || y >= (m_height-2)) return counter;
455  TTypesOfLandscapeElement tole = this->SupplyElementType(x,y);
456  if ((tole == tole_LargeRoad) || (tole == tole_SmallRoad) || (tole == tole_HedgeBank)) return counter;
457  if (SupplyLEHigh(x,y))
458  {
459  x = (int) (a_cx + a_offsetx * (counter+1));
460  y = (int) (a_cy + a_offsety * (counter+1));
461  if (SupplyLEHigh(x,y)) found = true;
462  d1=counter;
463  }
464  counter++;
465  }
466  return d1;
467 }
int m_width
Definition: landscape.h:127
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1029
int m_height
Definition: landscape.h:128
bool SupplyLEHigh(int a_x, int a_y)
Tests whether the polygon at a_x,a_y is designated as high.
Definition: landscape.h:419
int Landscape::MagicMapP2PolyRef ( int  a_magic)
inline
1441 {
1442  return m_elems[ a_magic ]->GetPoly();
1443 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void Landscape::MakeCluster ( void  )
protected

Reset all polygons natural grazing level to zero.

Inc volegrazing at x,y Get volegrazing at x,y Calculate all vole grazing densities

void Landscape::ModifyPolyRef ( int )
protected
LE * Landscape::NewElement ( TTypesOfLandscapeElement  a_type)
protected

References LE::SetALMaSSEleType(), and LE::SetElementType().

3449  {
3450  LE * elem;
3451  static char error_num[20];
3452 
3453  switch (a_type) {
3454  case tole_Hedges:
3455  elem = new Hedges;
3456  break;
3457  case tole_HedgeBank:
3458  elem = new HedgeBank;
3459  elem->SetALMaSSEleType(140);
3460  break;
3461  case tole_BeetleBank:
3462  elem = new BeetleBank;
3463  elem->SetALMaSSEleType(141);
3464  break;
3465  case tole_RoadsideVerge:
3466  elem = new RoadsideVerge;
3467  break;
3468  case tole_Railway:
3469  elem = new Railway;
3470  break;
3471  case tole_FieldBoundary:
3472  elem = new FieldBoundary;
3473  elem->SetALMaSSEleType(160);
3474  break;
3475  case tole_Marsh:
3476  elem = new Marsh;
3477  break;
3478  case tole_Orchard:
3479  elem = new Orchard;
3480  break;
3481  case tole_OrchardBand:
3482  elem = new OrchardBand;
3483  break;
3484  case tole_MownGrass:
3485  elem = new MownGrass;
3486  break;
3487  case tole_Heath:
3488  elem = new Heath;
3489  break;
3490  case tole_Scrub:
3491  elem = new Scrub;
3492  break;
3493  case tole_Field:
3494  elem = new Field;
3495  break;
3496  case tole_PermanentSetaside:
3497  elem = new PermanentSetaside;
3498  break;
3499  case tole_PermPasture:
3500  elem = new PermPasture;
3501  break;
3502  case tole_PermPastureLowYield:
3503  elem = new PermPastureLowYield;
3504  break;
3505  case tole_PermPastureTussocky:
3506  elem = new PermPastureTussocky;
3507  break;
3508  case tole_NaturalGrassDry:
3509  elem = new NaturalGrassDry;
3510  break;
3511  case tole_RiversidePlants:
3512  elem = new RiversidePlants;
3513  break;
3514  case tole_PitDisused:
3515  elem = new PitDisused;
3516  break;
3517  case tole_RiversideTrees:
3518  elem = new RiversideTrees;
3519  break;
3520  case tole_DeciduousForest:
3521  elem = new DeciduousForest;
3522  break;
3523  case tole_MixedForest:
3524  elem = new MixedForest;
3525  break;
3526  case tole_YoungForest:
3527  elem = new YoungForest;
3528  break;
3529  case tole_ConiferousForest:
3530  elem = new ConiferousForest;
3531  break;
3532  case tole_StoneWall:
3533  elem = new StoneWall;
3534  break;
3535  case tole_Garden:
3536  elem = new Garden;
3537  break;
3538  case tole_Track:
3539  elem = new Track;
3540  break;
3541  case tole_SmallRoad:
3542  elem = new SmallRoad;
3543  break;
3544  case tole_LargeRoad:
3545  elem = new LargeRoad;
3546  break;
3547  case tole_Building:
3548  elem = new Building;
3549  break;
3550  case tole_ActivePit:
3551  elem = new ActivePit;
3552  break;
3553  case tole_Freshwater:
3554  elem = new Freshwater;
3555  break;
3556  case tole_Pond:
3557  elem = new Pond;
3558  break;
3559  case tole_River:
3560  elem = new River;
3561  break;
3562  case tole_Saltwater:
3563  elem = new Saltwater;
3564  break;
3565  case tole_Coast:
3566  elem = new Coast;
3567  break;
3568  case tole_BareRock:
3569  elem = new BareRock;
3570  break;
3571  case tole_AmenityGrass:
3572  elem = new AmenityGrass;
3573  break;
3574  case tole_Parkland:
3575  elem = new Parkland;
3576  break;
3577  case tole_UrbanNoVeg:
3578  elem = new UrbanNoVeg;
3579  break;
3580  case tole_UrbanPark:
3581  elem = new UrbanPark;
3582  break;
3583  case tole_BuiltUpWithParkland:
3584  elem = new BuiltUpWithParkland;
3585  break;
3586  case tole_SandDune:
3587  elem = new SandDune;
3588  break;
3589  case tole_Copse:
3590  elem = new Copse;
3591  break;
3592  case tole_RoadsideSlope:
3593  elem = new RoadsideSlope;
3594  break;
3595  case tole_MetalledPath:
3596  elem = new MetalledPath;
3597  break;
3598  case tole_Carpark:
3599  elem = new Carpark;
3600  break;
3601  case tole_Churchyard:
3602  elem = new Churchyard;
3603  break;
3604  case tole_NaturalGrassWet:
3605  elem = new NaturalGrassWet;
3606  break;
3607  case tole_Saltmarsh:
3608  elem = new Saltmarsh;
3609  break;
3610  case tole_Stream:
3611  elem = new Stream;
3612  break;
3613  case tole_HeritageSite:
3614  elem = new HeritageSite;
3615  break;
3616  case tole_UnsprayedFieldMargin:
3617  elem = new UnsprayedFieldMargin;
3618  elem->SetALMaSSEleType(31);
3619  break;
3620  case tole_Wasteland:
3621  elem = new Wasteland;
3622  break;
3623  case tole_IndividualTree:
3624  elem = new IndividualTree;
3625  break;
3626  case tole_PlantNursery:
3627  elem = new PlantNursery;
3628  break;
3629  case tole_Vildtager:
3630  elem = new Vildtager;
3631  break;
3632  case tole_WindTurbine:
3633  elem = new WindTurbine;
3634  break;
3635  case tole_WoodyEnergyCrop:
3636  elem = new WoodyEnergyCrop;
3637  break;
3638  case tole_WoodlandMargin:
3639  elem = new WoodlandMargin;
3640  break;
3641  case tole_Pylon:
3642  elem = new Pylon;
3643  break;
3644  case tole_FishFarm:
3645  elem = new FishFarm;
3646  break;
3647  case tole_Missing:
3648  elem = new LE; // These should never be actually used.
3649  break;
3650  case tole_Chameleon:
3651  elem = new ChameleonLE;
3652  break;
3653  default:
3654  sprintf(error_num, "%d", a_type);
3655  g_msg->Warn(WARN_FILE, "Landscape::NewElement(): Unknown landscape element requested:", error_num);
3656  exit(1);
3657  } //switch
3658 
3659  elem->SetElementType(a_type);
3660 
3661  return elem;
3662 }
void SetElementType(int a_type)
Definition: elements.h:114
Definition: elements.h:984
Definition: elements.h:751
Definition: elements.h:735
Definition: elements.h:856
Definition: elements.h:1168
Definition: elements.h:1014
Definition: elements.h:769
Definition: elements.h:1136
Definition: elements.h:652
Definition: elements.h:1032
Definition: elements.h:1162
Definition: elements.h:810
Definition: elements.h:917
Definition: elements.h:763
Definition: elements.h:906
Definition: elements.h:990
Definition: elements.h:81
Definition: elements.h:1040
Definition: elements.h:869
Definition: elements.h:954
Definition: elements.h:996
Definition: elements.h:1026
Definition: elements.h:639
Definition: elements.h:960
Definition: elements.h:888
Definition: elements.h:680
Definition: elements.h:1020
Definition: elements.h:720
Definition: elements.h:1048
Definition: elements.h:1174
Definition: elements.h:842
Definition: elements.h:1056
Definition: elements.h:699
Definition: elements.h:691
Definition: elements.h:659
Definition: elements.h:816
Definition: elements.h:1144
Definition: elements.h:822
Definition: elements.h:863
Definition: elements.h:745
Definition: elements.h:936
Definition: elements.h:894
Definition: elements.h:796
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1073
Definition: elements.h:790
Definition: elements.h:1062
Definition: elements.h:707
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
Definition: elements.h:666
Definition: elements.h:1127
Definition: elements.h:948
Definition: elements.h:757
Definition: elements.h:876
Definition: elements.h:1150
Definition: elements.h:942
Definition: elements.h:1156
Definition: elements.h:978
Definition: elements.h:1119
Definition: elements.h:966
Definition: elements.h:776
Definition: elements.h:1111
Definition: elements.h:1103
Definition: elements.h:882
Definition: elements.h:673
Definition: elements.h:783
Definition: elements.h:849
void Landscape::PolysDump ( const char *  a_filename)
protected
1607 {
1608  ofstream outf(a_filename, ios::out);
1609  int l_num_polys = 0;
1610 
1611  if (!outf.is_open()) {
1612  g_msg->Warn(WARN_FILE, "Landscape::PolysDump(): Unable to open file", a_filename);
1613  exit(1);
1614  }
1615 
1616  // Count up number if active polygons in our list.
1617  unsigned sz = (unsigned)m_elems.size();
1618  for (unsigned int i = 0; i < sz; i++) {
1619  if (m_elems[i]->GetMapValid())
1620  l_num_polys++;
1621  }
1622 
1623  outf << l_num_polys << endl;
1624  outf << "PolyType" << '\t' << "PolyRefNum" << '\t' << "Area" << '\t' << "FarmRef" << '\t' << "UnSprayedMarginRef" << '\t' << "SoilType" << '\t' << "Openness" << '\t' << "CentroidX" << '\t' << "CentroidY" << endl;
1625 
1626  /*
1627  if ( l_map_renumberpolys.value() )
1628  {
1629  RenumberPolys( true );
1630  }
1631  */
1632  // Now we can output the file
1633  for (unsigned int i = 0; i < m_elems.size(); i++)
1634  {
1635  if (m_elems[i]->GetMapValid())
1636  {
1637  outf << m_elems[i]->GetALMaSSEleType() << '\t' << m_elems[i]->GetPoly() << '\t' << m_elems[i]->GetArea() << '\t' <<
1638  m_elems[i]->GetOwnerFile() << '\t' << m_elems[i]->GetUnsprayedMarginPolyRef() << '\t' << m_elems[i]->GetSoilType() << '\t' << m_elems[i]->GetOpenness()
1639  << '\t' << m_elems[i]->GetCentroidX() << '\t' << m_elems[i]->GetCentroidY() << endl;
1640  }
1641  }
1642  outf.close();
1643 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void Landscape::PolysRemoveInvalid ( void  )
protected

PolysValidate or ChangeMapMapping must be called after this method

1579 {
1583  vector < LE * > l_temp;
1584  cout << "Tidying up the polygon map in PolysRemoveInvalid" << endl;
1585  unsigned int sz= (int) m_elems.size();
1586  for ( unsigned int i = 0; i < sz; i++ ) {
1587  if ( m_elems[ i ]->GetMapValid() ) {
1588  unsigned int j = (int) l_temp.size();
1589  l_temp.resize( j + 1 );
1590  l_temp[ j ] = m_elems[ i ];
1591  } else {
1592  // cout << "Deleted m_elems index:" << m_polymapping[ m_elems[ i ]->GetPoly() ] << " Polynumber :" << m_elems[ i ]->GetPoly() << BackTranslateEleTypes(m_elems[ i ]->GetElementType()) << endl;
1593  m_polymapping[ m_elems[ i ]->GetPoly() ] = -1;
1594  delete m_elems[ i ];
1595  }
1596  }
1597 
1598  for ( unsigned int i = 0; i < l_temp.size(); i++ ) {
1599  m_elems[ i ] = l_temp[ i ];
1600  }
1601  m_elems.resize( l_temp.size() );
1603 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void RebuildPolyMapping()
Definition: landscape.h:191
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::PolysRenumber ( void  )
protected
1866 {
1867  cout << "In Landscape::Landscape() Polygon renumber." << endl;
1868  for (unsigned int i = 0; i < m_elems.size(); i++)
1869  {
1870  // Need to reset the poly number
1871  int index = m_elems[i]->GetMapIndex(); // This is the number currently in the map matrix
1872  m_elems[i]->SetPoly(index); // The map index and the polygon number are now one and the same
1873  m_polymapping[index] = i; // The polymapping is now linked via index to the m_elems index (i)
1874  }
1875  m_LargestPolyNumUsed = (int) m_elems.size()-1;
1876  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Map to be dumped due to polygon renumber", "");
1877 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int m_LargestPolyNumUsed
Definition: landscape.h:172
void Landscape::PolysValidate ( bool  a_exit_on_invalid)
protected
1551  {
1552  // 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
1553  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1554  m_elems[ i ]->SetMapValid( false );
1555  if ( m_polymapping[ m_elems[ i ]->GetPoly() ] == -1 ) {
1556  char l_err[ 20 ];
1557  sprintf( l_err, "%d", m_elems[ i ]->GetPoly() );
1558  g_msg->Warn( WARN_FILE, "Landscape::PolysValidate(): Invalid polymapping ", l_err );
1559  exit( 1 );
1560  }
1561  }
1562  // Now go through the whole map and for each polygon found set MapValid as true.
1564 
1565  if ( a_exit_on_invalid ) {
1566  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1567  if ( !m_elems[ i ]->GetMapValid() ) {
1568  char l_err[ 20 ];
1569  sprintf( l_err, "%d", m_elems[ i ]->GetPoly() );
1570  g_msg->Warn( WARN_FILE, "Landscape::PolysValidate(): Invalid polygon ", l_err );
1571  exit( 0 );
1572  }
1573  }
1574  }
1575 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void SetPolyMaxMinExtents(void)
Definition: Landscape.cpp:1428
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
std::string Landscape::PolytypeToString ( TTypesOfLandscapeElement  a_le_type)
3795  {
3796  char error_num[20];
3797 
3798  switch (a_le_type) {
3799  case tole_Hedges:
3800  return " Hedge";
3801  case tole_RoadsideVerge:
3802  return " Roadside Verge";
3803  case tole_Railway:
3804  return " Railway";
3805  case tole_FieldBoundary:
3806  return " Field Boundary";
3807  case tole_Marsh:
3808  return " Marsh";
3809  case tole_Scrub:
3810  return " Scrub";
3811  case tole_Field:
3812  return " Field";
3813  case tole_PermPastureTussocky:
3814  return " PermPastureTussocky";
3815  case tole_PermanentSetaside:
3816  return " Permanent Setaside";
3817  case tole_PermPasture:
3818  return " Permanent Pasture";
3819  case tole_PermPastureLowYield:
3820  return " PermPastureLowYield";
3821  case tole_NaturalGrassDry:
3822  return " Natural Grass";
3823  case tole_NaturalGrassWet:
3824  return " Natural Grass Wet";
3825  case tole_RiversidePlants:
3826  return " Riverside Plants";
3827  case tole_PitDisused:
3828  return " Pit Disused";
3829  case tole_RiversideTrees:
3830  return " Riverside Trees";
3831  case tole_DeciduousForest:
3832  return " Deciduous Forest";
3833  case tole_MixedForest:
3834  return " Mixed Forest";
3835  case tole_ConiferousForest:
3836  return " Coniferous Forest";
3837  case tole_YoungForest:
3838  return " Young Forest";
3839  case tole_StoneWall:
3840  return " Stone Wall";
3841  case tole_Garden:
3842  return " Garden";
3843  case tole_Track:
3844  return " Track";
3845  case tole_SmallRoad:
3846  return " Small Road";
3847  case tole_LargeRoad:
3848  return " Large Road";
3849  case tole_Building:
3850  return " Building";
3851  case tole_ActivePit:
3852  return " Active Pit";
3853  case tole_Pond:
3854  return " Pond";
3855  case tole_Freshwater:
3856  return " Fresh Water";
3857  case tole_River:
3858  return " River";
3859  case tole_Saltwater:
3860  return " Saltwater";
3861  case tole_Coast:
3862  return " Coast";
3863  case tole_BareRock:
3864  return " Bare Rock";
3865  case tole_HedgeBank:
3866  return " Hedgebank";
3867  case tole_Heath:
3868  return " Heath";
3869  case tole_Orchard:
3870  return " Orchard";
3871  case tole_OrchardBand:
3872  return " Orchard Band";
3873  case tole_MownGrass:
3874  return " Mown Grass";
3875  case tole_UnsprayedFieldMargin:
3876  return " UnsprayedFieldMargin";
3877  case tole_AmenityGrass:
3878  return " AmenityGrass";
3879  case tole_Parkland:
3880  return " Parkland";
3881  case tole_UrbanNoVeg:
3882  return " UrbanNoVeg";
3883  case tole_UrbanPark:
3884  return " UrbanPark";
3885  case tole_BuiltUpWithParkland:
3886  return " BuiltUpWithParkland";
3887  case tole_SandDune:
3888  return " SandDune";
3889  case tole_Copse:
3890  return " Copse";
3891  case tole_RoadsideSlope:
3892  return " RoadsideSlope";
3893  case tole_MetalledPath:
3894  return " MetalledPath";
3895  case tole_Carpark:
3896  return " Carpark";
3897  case tole_Churchyard:
3898  return " Churchyard";
3899  case tole_Saltmarsh:
3900  return " Saltmarsh";
3901  case tole_Stream:
3902  return " Stream";
3903  case tole_HeritageSite:
3904  return " HeritageSite";
3905  case tole_BeetleBank: //141
3906  return " Beetle Bank";
3907  case tole_UnknownGrass:
3908  return " Unknown Grass";
3909  case tole_Wasteland:
3910  return " Waste/Building Land";
3911  case tole_IndividualTree:
3912  return " IndividualTree";
3913  case tole_PlantNursery:
3914  return " PlantNursery";
3915  case tole_Vildtager:
3916  return " Vildtager";
3917  case tole_WindTurbine:
3918  return " WindTurbine";
3919  case tole_WoodyEnergyCrop:
3920  return " WoodyEnergyCrop";
3921  case tole_WoodlandMargin:
3922  return " WoodlandMargin";
3923  case tole_Pylon:
3924  return " Pylon";
3925  case tole_FishFarm:
3926  return " FishFarm";
3927  case tole_Foobar:
3928  default:
3929  sprintf(error_num, "%d", a_le_type);
3930  g_msg->Warn(WARN_FILE, "Landscape::PolytypeToString(): Unknown event type:", error_num);
3931  exit(1);
3932  }
3933 }
APoint Landscape::RandomLocation ( void  )
protected
void Landscape::ReadInput ( int ,
int ,
int ,
APoint  
)
protected
void Landscape::ReadOpenness ( void  )

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

void Landscape::ReadPolys ( const char *  a_polyfile)
protected
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.

References g_letype, LE::GetElementType(), l_map_chameleon_replace_num(), random(), LE::SetALMaSSEleType(), LE::SetArea(), LE::SetBorder(), LE::SetCentroid(), LE::SetOpenness(), LE::SetPoly(), LE::SetSoilType(), LE::SetUnsprayedMarginPolyRef(), and LE_TypeClass::TranslateEleTypes().

1696 {
1703  // Need to figure out if the farms are already renumbered - as the Farm manager
1704  bool farmsrenum = m_FarmManager->GetIsRenumbered();
1705 
1706  int NoPolygons;
1707  string rubbish = ""; //put here the names of the parameters;
1708  ifstream ifile(a_polyfile);
1709  if (!ifile.is_open()) {
1710  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Unable to open file", a_polyfile);
1711  std::exit(1);
1712  }
1713  char error_num[20];
1714  // First read the number of polygons
1715  ifile >> NoPolygons;
1716  m_elems.resize(NoPolygons);
1718  for (int i = 0; i < 9; i++){ ifile >> rubbish; }
1722  int np = NoPolygons;
1723  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
1724  m_polymapping = (int *)malloc(sizeof(int)* (np * 2));
1725  // Test if we have the memory to do this
1726  if (m_polymapping == NULL)
1727  {
1728  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Out of memory!", "");
1729  std::exit(1);
1730  }
1731 
1732  // Set all mappings to unused.
1733  for (int i = 0; i < np * 2; i++) {
1734  m_polymapping[i] = -1;
1735  }
1736 
1737  int ElemIndex = 0;
1738 
1739  for (int x = 0; x < NoPolygons; x++)
1740  {
1741  int PolyNum, Owner, PolyType, RealPolyType, URef, SoilType, openness, Centroid_x, Centroid_y;
1742  TTypesOfLandscapeElement Type;
1743  float Area;
1744  ifile >> PolyType >> PolyNum >> Area >> Owner >> URef >> SoilType >> openness >> Centroid_x >> Centroid_y;
1745  // Here we make some tests to check input validity
1746  if ((SoilType > 16) || (PolyNum<0))
1747  {
1748  std::sprintf(error_num, "%d", NoPolygons);
1749  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Polygon file empty before "
1750  "reading number of specified polygons (old polygon file format?):", error_num);
1751  std::exit(1);
1752  }
1753 
1754  // 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.
1755  // Because we create this sequentially in Farm.cpp we have a constant index.
1756  if ((-1 != Owner) && !farmsrenum)
1757  {
1758  // Need to replace the Owner with the new renumbered ref.
1759  Owner = m_FarmManager->GetRenumberedFarmRef(Owner);
1760  }
1761 
1762  RealPolyType = PolyType;
1764  if (PolyType == 150)
1765  {
1766  PolyType = l_map_chameleon_replace_num.value();
1767  }
1768 
1769  Type = g_letype->TranslateEleTypes(PolyType);
1770  if (Type == tole_Missing)
1771  {
1773  }
1774  if (-1 == m_polymapping[PolyNum])
1775  {
1776  // First time we have encountered this polygon number.
1777  // Borders are not mapped in this list.
1778  m_polymapping[PolyNum] = ElemIndex;
1779  LE * newland = NewElement(Type);
1780  m_elems[ElemIndex++] = newland;
1781  newland->SetPoly(PolyNum);
1782  newland->SetArea(floor(0.5 + Area));
1783  newland->SetALMaSSEleType(RealPolyType);
1784  newland->SetSoilType(SoilType);
1785  newland->SetUnsprayedMarginPolyRef(URef);
1786  newland->SetCentroid(Centroid_x,Centroid_y);
1787  newland->SetOpenness(openness);
1788  // Just for fun, or maybe because we might need it later, remember the actual largest polynum used
1789  if (PolyNum>m_LargestPolyNumUsed) m_LargestPolyNumUsed = PolyNum;
1790  // Now set any centroid or openness recalcuation flags
1791  if ((Centroid_x < 0) || (Centroid_y < 0)) m_NeedCentroidCalculation= true;
1792  if (openness < 0) m_NeedOpennessCalculation = true;
1793  // Two types of possible errors: Landscape element that is a field,
1794  // but doesn't belong to a farm, or a farm element not of type field.
1795  // Check for both cases.
1796  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)) {
1797  // No owner but field polygon.
1798  sprintf(error_num, "%d", PolyNum);
1799  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Farm polygon does not belong to a farm:", error_num);
1800  exit(1);
1801  }
1802  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) {
1803  // An owner but not field elements.
1804  sprintf(error_num, "%d", PolyNum);
1805  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Farm polygon does not have element type tole_Field:", error_num);
1806  exit(1);
1807  }
1808 
1809  if (-1 != Owner)
1810  {
1811  m_FarmManager->ConnectFarm(Owner);
1812  m_FarmManager->AddField(Owner, newland, Owner);
1813  if (g_map_le_borders.value())
1814  {
1815  if (random(100) < g_map_le_border_chance.value())
1816  {
1817  // This is a farm element, so signal adding a border.
1818  newland->SetBorder((LE *)1);
1819  }
1820  }
1821  // Code to generate unsprayed margins....
1822  if (newland->GetElementType() == tole_Field)
1823  {
1824  if (g_map_le_unsprayedmargins.value())
1825  {
1826  if (random(100) < g_map_le_unsprayedmargins_chance.value())
1827  {
1828  // This is a farm field, so signal adding a margin
1829  newland->SetUnsprayedMarginPolyRef(1);
1830  }
1831  }
1832  }
1833  // ..to here
1834  }
1835  }
1836  else {
1837  sprintf(error_num, "%d", PolyNum);
1838  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Duplicate polygon in file", error_num);
1839  exit(1);
1840  }
1841  }
1842  ifile.close();
1844  hb_first_free_poly_num = m_elems[NoPolygons - 1]->GetPoly() + 1;
1845 }
virtual void SetCentroid(int x, int y)
Definition: elements.h:139
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void SetUnsprayedMarginPolyRef(int a_unsprayedmargin)
Definition: elements.h:314
Definition: elements.h:81
void SetBorder(LE *a_border)
Definition: elements.h:312
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: elements.cpp:2592
void SetSoilType(int a_st)
Definition: elements.h:281
void SetPoly(int a_poly)
Definition: elements.h:220
bool m_DoMissingPolygonsManipulations
Definition: landscape.h:138
class LE_TypeClass * g_letype
Definition: elements.cpp:265
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:133
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
static CfgInt l_map_chameleon_replace_num("MAP_CHAMELEON_REPLACE_NUM", CFG_CUSTOM, 58)
int hb_first_free_poly_num
Definition: landscape.h:252
virtual TTypesOfLandscapeElement GetElementType(void)
Definition: elements.h:113
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void SetArea(double a_area)
Definition: elements.h:223
void SetOpenness(int a_openness)
Records the openness statistic for this polygon.
Definition: elements.h:362
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
bool m_NeedCentroidCalculation
a flag to ensure centroid calculation on object construction
Definition: landscape.h:134
bool m_NeedOpennessCalculation
a flag to ensure openness calculation on object construction
Definition: landscape.h:136
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3449
int m_LargestPolyNumUsed
Definition: landscape.h:172
bool Landscape::ReadSymbols ( const char *  a_cfgfile)
inline
735  {
736  return g_cfg->ReadSymbols( a_cfgfile );
737  }
void Landscape::RebuildPolyMapping ( )
inlineprotected
192  { // Rebuild m_polymapping.
193  unsigned int sz = (int)m_elems.size();
194  for (unsigned int i = 0; i < sz; i++)
195  {
196  m_polymapping[m_elems[i]->GetPoly()] = i;
197  }
198  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
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

3101 {
3107  int day = SupplyDayInYear();
3108  m_elems[m_polymapping[a_polyref]]->SetGooseNos(a_number, day);
3109 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int SupplyDayInYear(void)
Definition: landscape.h:1520
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()

3114 {
3119  int day = SupplyDayInYear();
3120  m_elems[m_polymapping[a_polyref]]->SetGooseNosTimed(a_number, day);
3121 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int SupplyDayInYear(void)
Definition: landscape.h:1520
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

3124  {
3131  int day = SupplyDayInYear();
3132  m_elems[m_polymapping[a_polyref]]->SetGooseSpNos(a_number, day, a_goose);
3133  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int SupplyDayInYear(void)
Definition: landscape.h:1520
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()

3135  {
3141  int day = SupplyDayInYear();
3142  m_elems[m_polymapping[a_polyref]]->SetGooseSpNosTimed(a_number, day, a_goose);
3143  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int SupplyDayInYear(void)
Definition: landscape.h:1520
void Landscape::RemoveMissingValues ( void  )
protected

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

1899 {
1900  bool found; // the flag for something left to work with
1901  int mapwidth = m_land->MapWidth();
1902  int mapheight = m_land->MapHeight();
1903  int counter = 0;
1904  do
1905  {
1906  found = false; counter++;
1907  for (int x = 1; x < mapwidth-1; x++)
1908  {
1909  for (int y = 1; y < mapheight-1; y++)
1910  {
1911  int apoly = m_land->Get(x,y);
1912  if (m_elems[m_polymapping[apoly]]->GetElementType() == tole_Missing)
1913  {
1914  m_land->MissingCellReplace(x, y, true);
1915  }
1916  }
1917  }
1918  counter++;
1919  } while (counter<50);
1920  // Now we only have the edges to deal with
1921  for (int x = 0; x < mapwidth; x++)
1922  {
1923  for (int y = 0; y < mapheight; y++)
1924  {
1925  int apoly = m_land->Get(x, y);
1926  if (m_elems[m_polymapping[apoly]]->GetElementType() == tole_Missing)
1927  {
1928  found = true;
1929  counter++;
1930  m_land->MissingCellReplaceWrap(x, y, true);
1931  }
1932  }
1933  }
1934  // Now we the ones that are not next to fields to deal with
1935 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
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

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

1993 {
2007  // To be sure we first count the map squares
2008  CountMapSquares();
2009  // First find polygons that don't match other rules and are single cells - remove these
2010  int removed = 0;
2011  for (unsigned int i = 0; i < m_elems.size(); i++)
2012  {
2013  if (m_elems[i]->GetArea() == 1)
2014  {
2015  TTypesOfLandscapeElement tole = m_elems[i]->GetElementType();
2016  switch (tole)
2017  {
2018  case tole_FieldBoundary:
2019  case tole_HedgeBank:
2020  case tole_Hedges:
2021  case tole_IndividualTree:
2022  case tole_MetalledPath:
2023  case tole_River:
2024  case tole_RiversidePlants:
2025  case tole_RiversideTrees:
2026  case tole_RoadsideSlope:
2027  case tole_RoadsideVerge:
2028  case tole_SmallRoad:
2029  case tole_StoneWall:
2030  case tole_Stream:
2031  case tole_Track:
2032  case tole_UnsprayedFieldMargin:
2033  // These could be part of a bigger polygon, so leave them alone for now.
2034  break;
2035  default:
2036  // Get rid of this one.
2037  APoint pt = m_elems[i]->GetCentroid();
2038  m_land->CellReplacementNeighbour(pt.m_x, pt.m_y, m_elems[i]->GetPoly());
2039  removed++;
2040  }
2041  }
2042  }
2043  return removed;
2044 }
int m_y
Definition: ALMaSS_Setup.h:54
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void CountMapSquares(void)
Definition: Landscape.cpp:1848
RasterMap * m_land
The big map.
Definition: landscape.h:122
int m_x
Definition: ALMaSS_Setup.h:53
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:50
void Landscape::RodenticidePredatorsEvaluation ( RodenticidePredators_Population_Manager a_rppm)

References RodenticidePredators_Population_Manager::PreCachePoly().

Referenced by RodenticidePredators_Population_Manager::CreatHabitatQualGrid().

2808 {
2809  for (unsigned i=0; i<m_elems.size(); i++) {
2810  a_rppm->PreCachePoly(m_elems[i]->GetPoly());
2811  }
2812 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void PreCachePoly(int a_poly)
Definition: RodenticidePredators.h:58
void Landscape::SetBirdMaizeForage ( int  a_polyref,
double  a_fooddensity 
)
inline

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

497  {
498  m_elems[ m_polymapping[ a_polyref ] ]->SetBirdMaize( a_fooddensity );
499  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::SetBirdSeedForage ( int  a_polyref,
double  a_fooddensity 
)
inline

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

491  {
492  m_elems[m_polymapping[a_polyref]]->SetBirdSeed(a_fooddensity);
493  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::SetLESignal ( int  a_polyref,
LE_Signal  a_signal 
)
3328  {
3329  m_elems[m_polymapping[a_polyref]]->SetSignal(a_signal);
3330 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::SetMaleNewtPresent ( int  a_InPondIndex)
inline

Sets a male as being present in a pond.

328 { m_elems[a_InPondIndex]->SetMaleNewtPresent(true); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
void Landscape::SetPolyMaxMinExtents ( void  )
1429 {
1430  // All polygon manipulation is settled now we need to give the polygons some information about themselves
1431  // This takes a little time but save time later one
1432  cout << "Setting max min polygon extents" << endl;
1433  int mwidth = m_land->MapWidth();
1434  int mheight = m_land->MapHeight();
1435  for ( int x = 0; x < mwidth; x++ ) {
1436  for ( int y = 0; y < mheight; y++ ) {
1437  int polyindex = m_land->Get( x, y );
1438  // Mark that we have seen this polygon.
1439  unsigned int ele_ref= polyindex;
1440  if (m_elems[m_polymapping[ele_ref]]->GetMaxX() < x) m_elems[m_polymapping[ele_ref]]->SetMaxX(x);
1441  if (m_elems[m_polymapping[ele_ref]]->GetMaxY() < y) m_elems[m_polymapping[ele_ref]]->SetMaxY(y);
1442  if (m_elems[m_polymapping[ele_ref]]->GetMinX() > x) m_elems[m_polymapping[ele_ref]]->SetMinX(x);
1443  if (m_elems[m_polymapping[ele_ref]]->GetMinY() > y) m_elems[m_polymapping[ele_ref]]->SetMinY(y);
1444  m_elems[m_polymapping[ele_ref]]->SetMapValid(true);
1445  }
1446  }
1447 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::SetThePopManager ( Population_Manager a_ptr)
inline

Set the pointer to the current main population manager.

Referenced by main().

161 { m_ThePopManager = a_ptr; }
Population_Manager * m_ThePopManager
a pointer to the current main population manager
Definition: landscape.h:143
void Landscape::SimulationClosingActions ( )

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

Referenced by CloseDownSim().

1277 {
1282  if(cfg_OptimisingFarms.value()){
1283  this->m_FarmManager->PrintFinalResults();
1284  }
1285 }
CfgBool cfg_OptimisingFarms
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
void Landscape::SkylarkEvaluation ( SkTerritories *  a_skt)
2800  {
2801  for (unsigned i=0; i<m_elems.size(); i++) {
2802  a_skt->PreCachePoly(m_elems[i]->GetPoly());
2803  }
2804 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
bool Landscape::StepOneValid ( int  a_polyindex,
int  a_x,
int  a_y,
int  step 
)
protected
2205 {
2206  int index;
2207  int x_add[ 8 ] = { 1*a_step, 1*a_step, 0, -1*a_step, -1*a_step, -1*a_step, 0, 1*a_step };
2208  int y_add[ 8 ] = { 0, -1*a_step, -1*a_step, -1*a_step, 0, 1*a_step, 1*a_step, 1*a_step };
2209  int width = m_land->MapWidth();
2210  int height = m_land->MapHeight();
2211  // Scan anti-clockwise from center pixel coordinate.
2212  for ( unsigned int i = 0; i < 8; i++ ) {
2213  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 ) )
2214  {
2215  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2216  if ( index == a_polyindex )
2217  {
2218  m_elems[a_polyindex]->SetValidXY(a_x + x_add[ i ], a_y + y_add[ i ]);
2219  return true;
2220  }
2221  }
2222  }
2223  return false;
2224 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SubtractPondLarvalFood ( double  a_food,
int  a_polyrefindex 
)

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

553  {
554  return dynamic_cast<Pond*>(m_elems[a_polyrefindex])->SubtractLarvalFood(a_food);
555 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1073
double Landscape::SupplyBirdMaizeForage ( int  a_polyref)
inline

Returns the maize forage resource.

589  {
590  return m_elems[ m_polymapping[ a_polyref ] ]->GetBirdMaize();
591  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
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.

595  {
596  return m_elems[ m_land->Get( a_x, a_y ) ]->GetBirdMaize();
597  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyBirdSeedForage ( int  a_polyref)
inline

Returns the grain forage resource.

576  {
577  return m_elems[m_polymapping[a_polyref]]->GetBirdSeed();
578  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
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.

583  {
584  return m_elems[m_land->Get(a_x, a_y)]->GetBirdSeed();
585  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
APoint Landscape::SupplyCentroid ( int  a_polyref)
623  {
624  return m_elems[ m_polymapping[ a_polyref ] ]->GetCentroid();
625 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
APoint Landscape::SupplyCentroidIndex ( int  a_polyrefindex)
628  {
629  return m_elems[ a_polyrefindex ]->GetCentroid();
630 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int Landscape::SupplyCentroidX ( int  a_polyref)
inline
434  {
435  return m_elems[ m_polymapping[ a_polyref ] ]->GetCentroidX();
436  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyCentroidX ( int  a_x,
int  a_y 
)
inline
438 { return m_elems[ m_land->Get( a_x, a_y )]->GetCentroidX(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyCentroidY ( int  a_polyref)
inline
437 { return m_elems[m_polymapping[ a_polyref ]]->GetCentroidY(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyCentroidY ( int  a_x,
int  a_y 
)
inline

References GooseFieldListItem::polyref.

439 { return m_elems[ m_land->Get( a_x, a_y )]->GetCentroidY(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyCountryDesig ( int  a_x,
int  a_y 
)
inline
1052 {
1053  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCountryDesignation();
1054 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyDayDegrees ( int  a_polyref)
inline
1249 {
1250  return m_elems[ m_polymapping[ a_polyref ]]->GetDayDegrees();
1251 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyDayInMonth ( void  )
inline

Referenced by RunTheSim().

1531 {
1532  return g_date->GetDayInMonth();
1533 }
int Landscape::SupplyDayInYear ( void  )
inline
1521 {
1522  return g_date->DayInYear();
1523 }
int Landscape::SupplyDaylength ( void  )
inline
1455 {
1456  return g_date->DayLength();
1457 }
int Landscape::SupplyDaylength ( long  a_date)
inline
1448 {
1449  return g_date->DayLength( a_date );
1450 }
double Landscape::SupplyDaylightProp ( )
inline
772 { return g_date->GetDaylightProportion(); }
double Landscape::SupplyDeadBiomass ( int  a_polyref)
inline
949 {
950  return m_elems[ m_polymapping[ a_polyref ]]->GetDeadBiomass();
951 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyDeadBiomass ( int  a_x,
int  a_y 
)
inline
954 {
955  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDeadBiomass();
956 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyElementSubType ( int  a_polyref)
inline
1041 {
1042  return m_elems[ m_polymapping[ a_polyref ]]->GetSubType();
1043 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyElementSubType ( int  a_x,
int  a_y 
)
inline
1046 {
1047  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSubType();
1048 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfLandscapeElement Landscape::SupplyElementType ( int  a_polyref)
inline

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

1030 {
1031  return m_elems[ m_polymapping[ a_polyref ]]->GetElementType();
1032 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
TTypesOfLandscapeElement Landscape::SupplyElementType ( int  a_x,
int  a_y 
)
inline
1035 {
1036  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1037 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfLandscapeElement Landscape::SupplyElementTypeCC ( int  a_x,
int  a_y 
)
inline
1059 {
1060  a_x = (a_x + m_width10) % m_width;
1061  a_y = (a_y + m_height10) % m_height;
1062  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1063 }
int m_height10
Definition: landscape.h:130
int m_width
Definition: landscape.h:127
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int m_height
Definition: landscape.h:128
RasterMap * m_land
The big map.
Definition: landscape.h:122
int m_width10
Definition: landscape.h:129
TTypesOfLandscapeElement Landscape::SupplyElementTypeFromVector ( unsigned int  a_index)
inline
1024 {
1025  return m_elems[ a_index ]->GetElementType();
1026 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int Landscape::SupplyFarmAnimalCensus ( int  a_farm_ref,
int  a_LifeStage 
)
603 {
604  return m_ThePopManager->FarmAnimalCensus(a_farm_ref, a_LifeStage);
605 }
unsigned int FarmAnimalCensus(unsigned int a_farm, unsigned int a_typeofanimal)
Definition: PopulationManager.cpp:1330
Population_Manager * m_ThePopManager
a pointer to the current main population manager
Definition: landscape.h:143
int Landscape::SupplyFarmArea ( int  a_polyref)
inline
1126 {
1127  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetArea();
1128 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyFarmIntensity ( int  a_x,
int  a_y 
)

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

613  {
614  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner()->GetIntensity();
615 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyFarmIntensity ( int  a_polyref)
618  {
619  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetIntensity();
620 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyFarmIntensityI ( int  a_polyindex)
608  {
609  return m_elems[ a_polyindex ]->GetOwner()->GetIntensity();
610 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
FarmManager* Landscape::SupplyFarmManagerPtr ( )
inline
332 { return m_FarmManager; }
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
int Landscape::SupplyFarmOwner ( int  a_x,
int  a_y 
)
inline
1071  {
1072  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerFile();
1073 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyFarmOwner ( int  a_polyref)
inline
1078 {
1079  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerFile();
1080 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyFarmOwnerIndex ( int  a_x,
int  a_y 
)
inline
1085 {
1086  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerIndex();
1087 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyFarmOwnerIndex ( int  a_polyref)
inline
1092 {
1093  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerIndex();
1094 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
Farm* Landscape::SupplyFarmPtr ( int  a_owner)
inline
331 { return m_FarmManager->GetFarmPtr(a_owner); }
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
TTypesOfFarm Landscape::SupplyFarmType ( int  a_polyref)
inline
1099 {
1100  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetType();
1101 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
TTypesOfFarm Landscape::SupplyFarmType ( int  a_x,
int  a_y 
)
inline
1106 {
1107  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner()->GetType();
1108 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
long Landscape::SupplyGlobalDate ( void  )
inline
1546 {
1547  return g_date->Date();
1548 }
double Landscape::SupplyGlobalRadiation ( )
inline

Referenced by VegElement::RecalculateBugsNStuff().

1266 {
1267  return g_weather->GetGlobalRadiation( );
1268 }
double Landscape::SupplyGlobalRadiation ( long  a_date)
inline
1271 {
1272  return g_weather->GetGlobalRadiation( a_date );
1273 }
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

Referenced by VegElement::RecalculateBugsNStuff().

504  {
510  if (a_goose == gs_Pinkfoot)
511  {
512  return m_GooseIntakeRateVSVegetationHeight_PF->GetY( a_height );
513  }
514  if (a_goose == gs_Barnacle)
515  {
516  return m_GooseIntakeRateVSVegetationHeight_BG->GetY(a_height);
517  }
518  if (a_goose == gs_Greylag)
519  {
520  return m_GooseIntakeRateVSVegetationHeight_GL->GetY(a_height);
521  }
522  Warn("Landscape::SupplyGooseGrazingForage", "Unknown Goose Type");
523  exit(1);
524  }
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
Definition: landscape.h:150
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
Definition: landscape.h:149
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1503
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
Curve relatning goose intake rates in KJ/min to vegetation height.
Definition: landscape.h:148
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
529  {
535  if (a_goose == gs_Pinkfoot)
536  {
537  return m_GooseIntakeRateVSVegetationHeight_PF->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
538  }
539  if (a_goose == gs_Barnacle)
540  {
541  return m_GooseIntakeRateVSVegetationHeight_BG->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
542  }
543  if (a_goose == gs_Greylag)
544  {
545  return m_GooseIntakeRateVSVegetationHeight_GL->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
546  }
547  Warn("Landscape::SupplyGooseGrazingForage", "Unknown Goose Type");
548  exit(1);
549  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
Definition: landscape.h:150
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
Definition: landscape.h:149
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1503
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
Curve relatning goose intake rates in KJ/min to vegetation height.
Definition: landscape.h:148
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyGrazingPressure ( int  a_polyref)
inline
1147 {
1148  return m_elems[ m_polymapping[ a_polyref ] ]->GetCattleGrazing();
1149 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyGrazingPressure ( int  a_x,
int  a_y 
)
inline
1159 {
1160  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCattleGrazing();
1161 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyGrazingPressureVector ( unsigned int  a_index)
inline
1152 {
1153  return m_elems[ a_index ]->GetCattleGrazing();
1154 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
double Landscape::SupplyGreenBiomass ( int  a_polyref)
inline
937 {
938  return m_elems[ m_polymapping[ a_polyref ]]->GetGreenBiomass();
939 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyGreenBiomass ( int  a_x,
int  a_y 
)
inline
942 {
943  return m_elems[ m_land->Get( a_x, a_y ) ]->GetGreenBiomass();
944 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SupplyHasTramlines ( int  a_x,
int  a_y 
)
inline
1172 {
1173  return m_elems[ m_land->Get( a_x, a_y ) ]->HasTramlines();
1174 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SupplyHasTramlines ( int  a_polyref)
inline
1166 {
1167  return m_elems[ m_polymapping[ a_polyref ] ]->HasTramlines();
1168 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyHour ( void  )
inline

Get the hour of the day.

1510  {
1511  return g_date->GetHour();
1512 }
double Landscape::SupplyHumidity ( void  )
inline
1318 {
1319  return g_weather->GetHumidity();
1320 }
double Landscape::SupplyInsects ( int  a_polyref)
inline
1008 {
1009  return m_elems[ m_polymapping[ a_polyref ]]->GetInsectPop();
1010 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyInsects ( int  a_x,
int  a_y 
)
inline
1013 {
1014  return m_elems[ m_land->Get( a_x, a_y ) ]->GetInsectPop();
1015 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SupplyIsCereal ( int  a_polyref)
inline
1219 {
1220  return m_elems[m_polymapping[a_polyref]]->IsCereal();
1221 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool Landscape::SupplyIsGrass ( int  a_polyref)
inline
1229 {
1230  return m_elems[ m_polymapping[ a_polyref ] ]->IsGrass();
1231 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool Landscape::SupplyIsMatureCereal ( int  a_polyref)
inline
1224 {
1225  return m_elems[m_polymapping[a_polyref]]->IsMatureCereal();
1226 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool Landscape::SupplyJustMown ( int  a_polyref)
inline
1183 {
1184  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlyMown();
1185 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool Landscape::SupplyJustMownVector ( unsigned int  a_index)
inline
1178 {
1179  return m_elems[ a_index ]->IsRecentlyMown();
1180 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int Landscape::SupplyJustSprayed ( int  a_polyref)
inline
1195 {
1196  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlySprayed();
1197 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyJustSprayed ( int  a_x,
int  a_y 
)
inline
1200 {
1201  return m_elems[ m_land->Get( a_x, a_y ) ]->IsRecentlySprayed();
1202 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyJustSprayedVector ( unsigned int  a_index)
inline
1190 {
1191  return m_elems[ a_index ]->IsRecentlySprayed();
1192 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
double Landscape::SupplyLAGreen ( int  a_polyref)
inline
961 {
962  return m_elems[ m_polymapping[ a_polyref ]]->GetLAGreen();
963 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyLAGreen ( int  a_x,
int  a_y 
)
inline
930 {
931  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLAGreen();
932 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
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!

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

640 {
649  polylist* p_list = new polylist;
650  unsigned sz = (unsigned) m_elems.size();
651  for (unsigned i=0; i<sz; i++)
652  {
653  if ( m_elems[i]->GetOpenness() > a_openness)
654  {
655  APoint pt = m_elems[i]->GetCentroid();
656  int dx, dy;
657  if (a_x>pt.m_x) dx = a_x-pt.m_x; else dx = pt.m_x-a_x;
658  if (a_y>pt.m_y) dy = a_y-pt.m_y; else dy = pt.m_y-a_y;
659  dx++; dy++; // prevents crash with maths below.
661  int dist;
663  if (dx>dy) dist = dx + (dy * dy) /(2 * dx); else dist = dy + (dx * dx) /(2 * dy);
664  if (dist<=a_range) p_list->push_back( m_elems[i]->GetPoly());
665  }
666  }
667  return p_list;
668 }
int m_y
Definition: ALMaSS_Setup.h:54
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int m_x
Definition: ALMaSS_Setup.h:53
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:50
int Landscape::SupplyLargestPolyNumUsed ( )
inline

Referenced by RodenticidePredators_Population_Manager::CreatHabitatQualGrid().

334 { return m_LargestPolyNumUsed; }
int m_LargestPolyNumUsed
Definition: landscape.h:172
TTypesOfVegetation Landscape::SupplyLastSownVeg ( int  a_polyref)
inline
988 {
989  return m_elems[m_polymapping[a_polyref]]->GetLastSownVeg();
990 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
TTypesOfVegetation Landscape::SupplyLastSownVeg ( int  a_x,
int  a_y 
)
inline
993 {
994  return m_elems[m_land->Get(a_x, a_y)]->GetLastSownVeg();
995 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfVegetation Landscape::SupplyLastSownVegVector ( unsigned int  a_index)
inline
983 {
984  return m_elems[a_index]->GetLastSownVeg();
985 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int Landscape::SupplyLastTreatment ( int  a_polyref,
int a_index 
)
inline
1254 {
1255  return m_elems[ m_polymapping[ a_polyref ]]->GetLastTreatment( a_index );
1256 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyLastTreatment ( int  a_x,
int  a_y,
int a_index 
)
inline
1261 {
1262  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLastTreatment( a_index );
1263 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyLATotal ( int  a_x,
int  a_y 
)
inline
924 {
925  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLATotal();
926 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyLECount ( void  )
3320  {
3321  return (int)m_elems.size();
3322 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
bool Landscape::SupplyLEHigh ( int  a_x,
int  a_y 
)
inline

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

419 { return m_elems[ m_land->Get( a_x, a_y ) ]->GetHigh(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyLENext ( void  )
3313  {
3314  if ((unsigned int)le_signal_index == m_elems.size()) {
3315  return -1;
3316  }
3317  return m_elems[le_signal_index++]->GetPoly();
3318 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int le_signal_index
Definition: landscape.h:297
LE * Landscape::SupplyLEPointer ( int  a_polyref)
inline

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

1019 {
1020  return m_elems[ m_polymapping[ a_polyref ]];
1021 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::SupplyLEReset ( void  )
3309  {
3310  le_signal_index = 0;
3311 }
int le_signal_index
Definition: landscape.h:297
LE_Signal Landscape::SupplyLESignal ( int  a_polyref)
3324  {
3325  return m_elems[m_polymapping[a_polyref]]->GetSignal();
3326 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int * Landscape::SupplyMagicMapP ( int  a_x,
int  a_y 
)
inline
1434 {
1435  return m_land->GetMagicP( a_x, a_y );
1436 }
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SupplyMaleNewtPresent ( int  a_InPondIndex)
inline

Determines if a male is present in a pond.

330 { return m_elems[a_InPondIndex]->IsMaleNewtPresent(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
double Landscape::SupplyMeanTemp ( long  a_date,
unsigned int  a_period 
)
inline
1297 {
1298  return g_weather->GetMeanTemp( a_date, a_period );
1299 }
int Landscape::SupplyMinute ( void  )
inline

Get the minute of the hour.

1516  {
1517  return g_date->GetMinute();
1518 }
int Landscape::SupplyMonth ( void  )
inline

Referenced by RunTheSim().

1526 {
1527  return g_date->GetMonth();
1528 }
double Landscape::SupplyNightProp ( )
inline

References g_map.

773 { return 1.0-g_date->GetDaylightProportion(); }
int Landscape::SupplyNumberOfFarms ( )
inline
1067  {
1068  return m_FarmManager->GetNoFarms();
1069 }
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
unsigned int Landscape::SupplyNumberOfPolygons ( void  )
inline
1386 {
1387  return (unsigned int) m_elems.size();
1388 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int Landscape::SupplyOpenness ( int  a_poly)
inline

Get openness for a polygon.

415 { return m_elems[m_polymapping[ a_poly ]]->GetOpenness(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyOpenness ( int  a_x,
int  a_y 
)
inline

Get openness for a location.

417 { return m_elems[ m_land->Get( a_x, a_y )]->GetOpenness(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfOptFarms Landscape::SupplyOptFarmType ( int  a_x,
int  a_y 
)
inline
1111 {
1112  OptimisingFarm * opf;
1113  opf = dynamic_cast<OptimisingFarm*>(m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner());
1114  return opf-> Get_farmType();
1115 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyPesticide ( int  a_x,
int  a_y 
)

Gets total pesticide for a location.

References g_pest.

Referenced by Pond::CalcPondPesticide().

481  {
482  double pp;
483 #ifdef __DETAILED_PESTICIDE_FATE
484  // This should be avoided if possible because it is inefficient
485  pp = g_pest->SupplyPesticideS(a_x, a_y);
486  pp += g_pest->SupplyPesticideP(a_x, a_y);
487 #else
488  pp = g_pest->SupplyPesticide(a_x, a_y);
489 #endif
490  return pp;
491 }
class Pesticide * g_pest
double Landscape::SupplyPesticide ( int  a_polyref)

Gets total pesticide for the centroid of a polygon.

References g_pest.

516  {
517  if (!l_pest_enable_pesticide_engine.value()) return 0.0;
518  double pp;
519 #ifdef __DETAILED_PESTICIDE_FATE
520  pp = g_pest->SupplyPesticideS(a_polyref);
521  pp += g_pest->SupplyPesticideP(a_polyref);
522 #else
523  pp = g_pest->SupplyPesticide(a_polyref);
524 #endif
525  return pp;
526 }
class Pesticide * g_pest
CfgBool l_pest_enable_pesticide_engine
int Landscape::SupplyPesticideCell ( int  a_polyref)
inline
1393 {
1394  return m_elems[ m_polymapping[ a_polyref ] ]->GetPesticideCell();
1395 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool Landscape::SupplyPesticideDecay ( )

Returns true if there is any pesticide in the system at all at this point.

References g_pest.

634 {
635  return g_pest->GetAnythingToDecay();
636 }
class Pesticide * g_pest
double Landscape::SupplyPesticideP ( int  a_x,
int  a_y 
)

Gets plant pesticide for a location.

References g_pest.

494  {
495  double pp;
496 #ifdef __DETAILED_PESTICIDE_FATE
497  pp = g_pest->SupplyPesticideP(a_x, a_y);
498 #else
499  pp = g_pest->SupplyPesticide(a_x, a_y);
500 #endif
501  return pp;
502 }
class Pesticide * g_pest
double Landscape::SupplyPesticideP ( int  a_polyref)

Gets plant pesticide for the centroid of a polygon.

References g_pest.

541  {
542  if (!l_pest_enable_pesticide_engine.value()) return 0.0;
543  double pp;
544 #ifdef __DETAILED_PESTICIDE_FATE
545  pp = g_pest->SupplyPesticideP(a_polyref);
546 #else
547  pp = g_pest->SupplyPesticide(a_polyref);
548 #endif
549  return pp;
550 }
class Pesticide * g_pest
CfgBool l_pest_enable_pesticide_engine
double Landscape::SupplyPesticideS ( int  a_x,
int  a_y 
)

Gets soil pesticide for a location.

References g_pest.

505  {
506  double pp;
507 #ifdef __DETAILED_PESTICIDE_FATE
508  pp = g_pest->SupplyPesticideS(a_x, a_y);
509 #else
510  pp = g_pest->SupplyPesticide(a_x, a_y);
511 #endif
512  return pp;
513 }
class Pesticide * g_pest
double Landscape::SupplyPesticideS ( int  a_polyref)

Gets soil pesticide for the centroid of a polygon.

References g_pest.

529  {
530  if (!l_pest_enable_pesticide_engine.value()) return 0.0;
531  double pp;
532 #ifdef __DETAILED_PESTICIDE_FATE
533  pp = g_pest->SupplyPesticideS(a_polyref);
534 #else
535  pp = g_pest->SupplyPesticide(a_polyref);
536 #endif
537  return pp;
538 }
class Pesticide * g_pest
CfgBool l_pest_enable_pesticide_engine
TTypesOfPesticide Landscape::SupplyPesticideType ( void  )
inline
399 { return m_PesticideType; }
TTypesOfPesticide m_PesticideType
An attribute to hold the pesticide type being tested, if there is one, if not default is -1...
Definition: landscape.h:256
double Landscape::SupplyPolygonArea ( int  a_polyref)
inline
485 { return m_elems[ m_polymapping[ a_polyref ]]->GetArea(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyPolygonAreaVector ( int  a_polyref)
inline

Returns the area of a polygon using the vector index as a reference.

1120 {
1121  return m_elems[ a_polyref ]->GetArea();
1122 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int Landscape::SupplyPolyRef ( int  a_x,
int  a_y 
)
inline

Referenced by Pond::CalcPondPesticide(), and RodenticidePredators_Population_Manager::CreatHabitatQualGrid().

1413 {
1414  return m_elems[ m_land->Get( a_x, a_y )]->GetPoly();
1415 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyPolyRefCC ( int  a_x,
int  a_y 
)
inline
1425 {
1426  a_x = (a_x + m_width10) % m_width;
1427  a_y = (a_y + m_height10) % m_height;
1428  return m_elems[ m_land->Get( a_x, a_y )]->GetPoly();
1429 }
int m_height10
Definition: landscape.h:130
int m_width
Definition: landscape.h:127
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int m_height
Definition: landscape.h:128
RasterMap * m_land
The big map.
Definition: landscape.h:122
int m_width10
Definition: landscape.h:129
int Landscape::SupplyPolyRefIndex ( int  a_x,
int  a_y 
)
inline
1418 {
1419  return m_land->Get( a_x, a_y );
1420 }
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyPolyRefVector ( unsigned int  a_index)
inline
1376 {
1377  return m_elems[ a_index ]->GetPoly();
1378 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int Landscape::SupplyPondIndex ( int  a_pondref)
inline

Returns the index of a pond based on pondref or -1 if not found.

321  {
322  for (int i = 0; i < m_PondIndexList.size(); i++) {
323  if (m_PondRefsList[i] == a_pondref) return m_PondIndexList[i];
324  }
325  return -1;
326  }
vector< int > m_PondIndexList
List of pond indexes.
Definition: landscape.h:175
vector< int > m_PondRefsList
List of pond polyrefs.
Definition: landscape.h:177
double Landscape::SupplyPondPesticide ( int  a_poly_index)
inline

Get the pesticide concentration per liter from a pond (must be a pond index on calling)

References SupplyPondPesticide().

Referenced by SupplyPondPesticide().

708 { return dynamic_cast<Pond*>(m_elems[a_poly_index])->SupplyPondPesticide(); }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
double SupplyPondPesticide(int a_poly_index)
Get the pesticide concentration per liter from a pond (must be a pond index on calling) ...
Definition: landscape.h:708
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1073
double Landscape::SupplyRain ( void  )
inline
1290 {
1291  return g_weather->GetRain();
1292 }
double Landscape::SupplyRain ( long  a_date)
inline
1283 {
1284  return g_weather->GetRain( a_date );
1285 }
double Landscape::SupplyRainPeriod ( long  a_date,
int  a_period 
)
inline
1276 {
1277  return g_weather->GetRainPeriod( a_date, a_period );
1278 }
int Landscape::SupplyRandomPondIndex ( )

Returns random pond index.

References g_rand_uni().

2381  {
2382  return m_PondIndexList[int(g_rand_uni()*m_PondIndexList.size())];
2383 }
vector< int > m_PondIndexList
List of pond indexes.
Definition: landscape.h:175
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni(g_generator, g_uni_dist)
int Landscape::SupplyRandomPondRef ( )

Returns random pond polyref.

References g_rand_uni().

2385  {
2386  if (m_PondIndexList.size()>0) return m_PondRefsList[int(g_rand_uni()*m_PondIndexList.size())];
2387  return -1;
2388 }
vector< int > m_PondIndexList
List of pond indexes.
Definition: landscape.h:175
vector< int > m_PondRefsList
List of pond polyrefs.
Definition: landscape.h:177
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni(g_generator, g_uni_dist)
int Landscape::SupplyRoadWidth ( int  ,
int   
)
inline
758 {return 0;}
double Landscape::SupplyRodenticide ( int  a_x,
int  a_y 
)

Gets total rodenticide for a location.

References cfg_rodenticide_enable().

470  {
471  if (cfg_rodenticide_enable.value())
472  {
473  double pp;
474  pp = m_RodenticideManager->GetRodenticide(a_x, a_y);
475  return pp;
476  }
477  return 0;
478 }
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
double GetRodenticide(unsigned a_x, int a_y)
Return the poisoned mice value at x,y.
Definition: Rodenticide.h:142
RodenticidePredators_Population_Manager* Landscape::SupplyRodenticidePredatoryManager ( )
inline
398 { return m_RodenticidePreds; }
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
bool Landscape::SupplyShouldSpray ( )
inline

Referenced by Orchard::DoDevelopment(), and OrchardBand::DoDevelopment().

336 {return m_toxShouldSpray;}
bool m_toxShouldSpray
Definition: landscape.h:295
int Landscape::SupplySimAreaMaxExtent ( void  )
inline
1567 {
1568  return m_maxextent;
1569 }
int m_maxextent
Definition: landscape.h:131
int Landscape::SupplySimAreaMinExtent ( void  )
bool Landscape::SupplySkScrapes ( int  a_polyref)
inline
901 {
902  return m_elems[ m_polymapping[ a_polyref ]]->GetSkScrapes();
903 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool Landscape::SupplySnowcover ( void  )
inline
1362 {
1363  return g_weather->GetSnow();
1364 }
bool Landscape::SupplySnowcover ( long  a_date)
inline
1355 {
1356  return g_weather->GetSnow( a_date );
1357 }
double Landscape::SupplySnowDepth ( void  )
inline
1369 {
1370  return g_weather->GetSnowDepth();
1371 }
int Landscape::SupplySoilType ( int  a_x,
int  a_y 
)
inline

Returns the soil type in ALMaSS types reference numbers.

424  {
425  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSoilType( );
426  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplySoilTypeR ( int  a_x,
int  a_y 
)
inline

Returns the soil type in rabbit warren reference numbers.

428  {
429  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSoilTypeR( );
430  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyTemp ( void  )
inline

Referenced by VegElement::RecalculateBugsNStuff().

1311 {
1312  return g_weather->GetTemp();
1313 }
double Landscape::SupplyTemp ( long  a_date)
inline
1304 {
1305  return g_weather->GetTemp( a_date );
1306 }
double Landscape::SupplyTempPeriod ( long  a_date,
int  a_period 
)
inline
1335 {
1336  return g_weather->GetTempPeriod( a_date, a_period );
1337 }
Population_Manager* Landscape::SupplyThePopManager ( )
inline

Get the pointer to the current main population manager.

159 { return m_ThePopManager; }
Population_Manager * m_ThePopManager
a pointer to the current main population manager
Definition: landscape.h:143
double Landscape::SupplyTrafficLoad ( int  a_x,
int  a_y 
)
inline
1213 {
1214  return m_elems[ m_land->Get( a_x, a_y ) ]->GetTrafficLoad();
1215 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyTrafficLoad ( int  a_polyref)
inline
1207 {
1208  return m_elems[ m_polymapping[ a_polyref ] ]->GetTrafficLoad();
1209 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyTreeAge ( int  a_Polyref)
inline
1236 {
1237  return 1;
1238 }
int Landscape::SupplyTreeAge ( int  ,
int   
)
inline
471 {return 0;}
int Landscape::SupplyTreeHeight ( int  ,
int   
)
inline
761 {return 0;}
int Landscape::SupplyTreeHeight ( int  )
inline
763 {return 0;}
int Landscape::SupplyUnderGrowthWidth ( int  ,
int   
)
inline
762 {return 0;}
int Landscape::SupplyUnderGrowthWidth ( int  )
inline
764 {return 0;}
int Landscape::SupplyValidX ( int  a_polyref)
inline
1399 {
1400  return m_elems[ m_polymapping[ a_polyref ] ]->GetValidX();
1401 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyValidY ( int  a_polyref)
inline
1406 {
1407  return m_elems[ m_polymapping[ a_polyref ] ]->GetValidY();
1408 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyVegAge ( int  a_Polyref)
inline
998 {
999  return m_elems[ m_polymapping[ a_polyref ]]->GetVegAge();
1000 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyVegAge ( int  a_x,
int  a_y 
)
inline
1003 {
1004  return m_elems[m_land->Get(a_x, a_y)]->GetVegAge();
1005 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegBiomass ( int  a_polyref)
inline
873 {
874  return m_elems[ m_polymapping[ a_polyref ]]->GetVegBiomass();
875 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyVegBiomass ( int  a_x,
int  a_y 
)
inline
878 {
879  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegBiomass();
880 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegBiomassVector ( unsigned int  a_index)
inline
868 {
869  return m_elems[ a_index ]->GetVegBiomass();
870 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
double Landscape::SupplyVegCover ( int  a_polyref)
inline
968 {
969  return m_elems[ m_polymapping[ a_polyref ]]->GetVegCover();
970 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyVegCover ( int  a_x,
int  a_y 
)
inline
978 {
979  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegCover();
980 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegCoverVector ( unsigned int  a_index)
inline
973 {
974  return m_elems[ a_index ]->GetVegCover();
975 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int Landscape::SupplyVegDensity ( int  a_polyref)
inline
895 {
896  return m_elems[ m_polymapping[ a_polyref ]]->GetVegDensity();
897 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
int Landscape::SupplyVegDensity ( int  a_x,
int  a_y 
)
inline
918 {
919  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegDensity();
920 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegDigestability ( int  a_polyref)
inline
839 {
840  return m_elems[ m_polymapping[ a_polyref ]]->GetDigestability();
841 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyVegDigestability ( int  a_x,
int  a_y 
)
inline
845 {
846  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDigestability();
847 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegDigestabilityVector ( unsigned int  a_index)
inline
834 {
835  return m_elems[ a_index ]->GetDigestability();
836 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
double Landscape::SupplyVegHeight ( int  a_polyref)
inline
856 {
857  return m_elems[ m_polymapping[ a_polyref ]]->GetVegHeight();
858 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyVegHeight ( int  a_x,
int  a_y 
)
inline
861 {
862  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegHeight();
863 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegHeightVector ( unsigned int  a_index)
inline
851 {
852  return m_elems[ a_index ]->GetVegHeight();
853 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
bool Landscape::SupplyVegPatchy ( int  a_polyref)
inline
906 {
907  return m_elems[ m_polymapping[ a_polyref ]]->GetVegPatchy();
908 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
bool Landscape::SupplyVegPatchy ( int  a_x,
int  a_y 
)
inline
912 {
913  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegPatchy();
914 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyVegPhase ( int  a_poly)
inline
164  {
165  return m_elems[m_polymapping[a_poly]]->GetVegPhase();
166  }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
TTypesOfVegetation Landscape::SupplyVegType ( int  a_x,
int  a_y 
)
inline
1242 {
1243  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegType();
1244 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfVegetation Landscape::SupplyVegType ( int  polyref)
inline
1134 {
1135  return m_elems[ m_polymapping[ a_polyref ] ]->GetVegType();
1136 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
TTypesOfVegetation Landscape::SupplyVegTypeVector ( unsigned int  a_index)
inline
1140 {
1141  return m_elems[ a_index ]->GetVegType();
1142 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
const char* Landscape::SupplyVersion ( void  )
inline
725 { return m_versioninfo; }
char m_versioninfo[30]
Definition: landscape.h:112
double Landscape::SupplyWeedBiomass ( int  a_polyref)
inline
884 {
885  return m_elems[ m_polymapping[ a_polyref ]]->GetWeedBiomass();
886 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
double Landscape::SupplyWeedBiomass ( int  a_x,
int  a_y 
)
inline
890 {
891  return m_elems[ m_land->Get( a_x, a_y ) ]->GetWeedBiomass();
892 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyWind ( void  )
inline
1342 {
1343  return g_weather->GetWind();
1344 }
double Landscape::SupplyWind ( long  a_date)
inline
1325 {
1326  return g_weather->GetWind( a_date );
1327 }
int Landscape::SupplyWindDirection ( void  )
inline
1348 {
1349  return g_weather->GetWindDirection();
1350 }
double Landscape::SupplyWindPeriod ( long  a_date,
int  a_period 
)
inline
1330 {
1331  return g_weather->GetWindPeriod( a_date, a_period );
1332 }
int Landscape::SupplyYear ( void  )
inline
1536 {
1537  return g_date->GetYear();
1538 }
int Landscape::SupplyYearNumber ( void  )
inline
1541 {
1542  return g_date->GetYearNumber();
1543 }
void Landscape::TestCropManagement ( void  )
protected
void Landscape::Tick ( void  )

If the farmer decision making model is on, the function:

  • calls #FarmManager::ActualProfit() function on March 1st each year starting from the 2nd year of the simulation
  • starting from the 7th year, it saves the previous year's crop set for each farm and calls the #FarmManager::ChooseDecisionMode_for_farms() function
  • saves all crop prices as last year prices (needed if crop prices are not constant)
  • saves the number of day degrees in a period March 1st - November 1st. See #FarmManager::daydegrees.
  • modifies energy maize price each year if the model is run with energy maize.

References cfg_productapplicendyear(), cfg_productapplicstartyear(), cfg_rodenticide_enable(), g_pest, g_rand_uni(), l_map_dump_event_enable(), l_map_dump_event_x1(), l_map_dump_event_y1(), l_map_dump_veg_enable(), l_map_dump_veg_x(), and l_map_dump_veg_y().

1288  {
1297  g_date->Tick();
1298  g_weather->Tick();
1299 
1300  // Remember todays LAItotal for veg elements
1301  for (unsigned int i = 0; i < m_elems.size(); i++) {
1302  m_elems[ i ]->StoreLAItotal();
1303  }
1304 
1305  // Update the growth curve phases if needed.
1306  if (g_date->JanFirst()) {
1307  if (g_rand_uni() > 0.5) {
1308  m_FarmManager->SetSpilledGrain( true );
1309  }
1310  else m_FarmManager->SetSpilledGrain( false );
1311  for (unsigned int i = 0; i < m_elems.size(); i++) {
1312  m_elems[ i ]->SetGrowthPhase( janfirst );
1313  }
1314  }
1315  else if (g_date->MarchFirst()) {
1316  for (unsigned int i = 0; i < m_elems.size(); i++) {
1317  m_elems[ i ]->SetGrowthPhase( marchfirst );
1318  }
1319  // Check and see if the pesticide engine flag should be set
1321  m_toxShouldSpray = true;
1322  else m_toxShouldSpray = false;
1323  }
1324 
1325 
1326  // Grow the green stuff and let the bugs have some too.
1327  for (unsigned int i = 0; i < m_elems.size(); i++) {
1328  m_elems[ i ]->Tick();
1329  m_elems[ i ]->DoDevelopment();
1330  }
1331 
1332  //call ActualProfit function, then save this year's crop prices - for the next year's expected results calculation, then change price
1333  if (cfg_OptimisingFarms.value()) {
1334  if (!cfg_OptimiseBedriftsmodelCrops.value()) { //do this just in almass crop mode
1335 
1336  if (g_date->DayInYear() == g_date->DayInYear( 1, 03 ) && g_date->GetYearNumber()>1) { //March 1st - do the accounting; 1 corresponds to 0 in the visual version year counter.
1337 
1338  m_FarmManager->ActualProfit();
1339 
1340  //print the m_cropTotals
1341  ofstream ofile2( "CropDistribution.txt", ios::app );
1342  // the distibution of crops from last year!
1343  int last_year = g_date->GetYearNumber() - 1;
1344  ofile2 << last_year << '\t';
1345  for (int c = 0; c < m_FarmManager->pm_data->Get_noCrops(); c++) ofile2 << m_FarmManager->Get_cropTotals( c ) << '\t';
1346  ofile2 << endl;
1347  //restart the m_cropTotals:
1348  for (int i = 0; i < (int)m_FarmManager->Get_cropTotals_size(); i++) {
1349  m_FarmManager->Set_cropTotals( i, 0 );
1350  }
1351 
1352  if (g_date->GetYearNumber() > 7) { //it's been 6 years since the first accounting was carried out (5 would be enough, but exclude one year to avoid start up effects)
1353  m_FarmManager->Save_last_years_crops_for_farms(); //saves m_rotational_crops in m_rotational_crops_visible
1354  m_FarmManager->ChooseDecisionMode_for_farms();
1355  }
1356 
1357  }
1358 
1359  //save the last year crop price;
1360  if (g_date->GetYearNumber() > 1 && g_date->DayInYear() == g_date->DayInYear( 1, 03 )) {
1361  for (int f = 0; f < (toof_Foobar * tos_Foobar); f++) { //need to save the price for all farm types and soil types, so just run through the whole vector;
1362  int no_crops = m_FarmManager->pm_data->Get_cropTypes_almass_size();
1363  for (int c = 0; c < no_crops; c++) {
1364  double old_price = m_FarmManager->pm_data->Get_sellingPrice( tov_Undefined*f + m_FarmManager->pm_data->Get_cropTypes_almass( c ) ); //get the current price
1365  m_FarmManager->pm_data->Set_sellingPrice_lastyr( old_price, tov_Undefined*f + m_FarmManager->pm_data->Get_cropTypes_almass( c ) ); //save it
1366  }
1367  }
1368  }
1369  //-----
1370 
1371 
1372  if (cfg_MaizeEnergy.value()) { //modify energy maize price
1373 
1374  if (g_date->DayInYear() == g_date->DayInYear( 1, 03 ) && g_date->GetYearNumber() != 0) { //print the price once a year
1375  ofstream ofileEM( "Maize_energy_price_yearly.txt", ios::app );
1376  int year = g_date->GetYearNumber();
1377  ofileEM << year << '\t';
1378  ofileEM << m_FarmManager->pm_data->Get_sellingPrice( tov_Maize );
1379  ofileEM << endl;
1380  ofileEM.close();
1381  }
1382 
1383  //changing price according to the input file EM_price.txt
1384  if (g_date->DayInYear() == g_date->DayInYear( 1, 03 ) && g_date->GetYearNumber() > 0) {//exclude the hidden year
1385  for (int f = 0; f < (toof_Foobar * tos_Foobar); f++) { //need to change the price for all farm types and soil types
1386  double new_price = m_FarmManager->pm_data->Get_emaize_price( g_date->GetYearNumber() );
1387  m_FarmManager->pm_data->Set_sellingPrice( new_price, tov_Undefined*f + tov_Maize );
1388  }
1389  }
1390  }// if energy maize
1391 
1392  }//almass crop mode
1393  }//optimising farms
1394 
1395  /* Testing removal - may cause issues with increasing or decreasing permanent vegetation
1396  if ( g_date->DayInYear() == g_date->DayInYear( 1, 11 ) ) {
1397  // Set all elements to smooth curve transition mode at November 1st.
1398  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1399  m_elems[ i ]->ForceGrowthInitialize();
1400  }
1401  //save the day degrees - used for crops that are not harvested instead of biomass to determine yield; done on Nov 1st
1402  //m_FarmManager->SetDD (SupplyTempPeriod( g_date->Date(), 245)); // from Nov 1 - 245 days back till March 1;
1403  //DegreesDump();
1404  }
1405  */
1406 
1407  // Put the farmers to work.
1408  m_FarmManager->FarmManagement();
1409 
1410 
1411  // Update pesticide information.
1412  g_pest->Tick();
1413 
1414  // Update rodenticide information if we are using this
1415  if (cfg_rodenticide_enable.value()) {
1418  }
1419 
1420  // Dump event information if necessary
1421  if (l_map_dump_veg_enable.value()) VegDump( l_map_dump_veg_x.value(), l_map_dump_veg_y.value() );
1422  if (l_map_dump_event_enable.value())
1423  //EventDump( l_map_dump_event_x1.value(), l_map_dump_event_y1.value(), l_map_dump_event_x2.value(), l_map_dump_event_y2.value() );
1425 }
CfgBool cfg_OptimisingFarms
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
void Tick()
Updates the rodenticide exposure for all predator territories.
Definition: RodenticidePredators.cpp:448
class Pesticide * g_pest
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
static CfgInt l_map_dump_event_y1("MAP_DUMP_EVENT_YA", CFG_CUSTOM, 2909)
static CfgInt l_map_dump_veg_x("MAP_DUMP_VEG_X", CFG_CUSTOM, 100)
CfgBool cfg_OptimiseBedriftsmodelCrops
static CfgBool l_map_dump_event_enable("MAP_DUMP_EVENT_ENABLE", CFG_CUSTOM, false)
CfgBool cfg_MaizeEnergy
int SupplyYearNumber(void)
Definition: landscape.h:1540
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
CfgInt cfg_productapplicendyear("PEST_PROCTAPPLICENDYEAR", CFG_CUSTOM,-1)
static CfgInt l_map_dump_veg_y("MAP_DUMP_VEG_Y", CFG_CUSTOM, 100)
CfgInt cfg_productapplicstartyear("PEST_PROCTAPPLICSTARTYEAR", CFG_CUSTOM, 9999999)
bool m_toxShouldSpray
Definition: landscape.h:295
static CfgInt l_map_dump_event_x1("MAP_DUMP_EVENT_XA", CFG_CUSTOM, 4287)
void EventDumpPesticides(int x1, int y1)
Definition: Landscape.cpp:1525
static CfgBool l_map_dump_veg_enable("MAP_DUMP_VEG_ENABLE", CFG_CUSTOM, true)
void Tick(void)
Advance one day.
Definition: Rodenticide.cpp:206
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni(g_generator, g_uni_dist)
void VegDump(int x, int y)
Definition: Landscape.cpp:1450
TTypesOfLandscapeElement Landscape::TranslateEleTypes ( int  EleReference)
inline

References g_letype, and LE_TypeClass::TranslateEleTypes().

1573 {
1574  return g_letype->TranslateEleTypes( EleReference );
1575 }
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: elements.cpp:2592
class LE_TypeClass * g_letype
Definition: elements.cpp:265
TTypesOfVegetation Landscape::TranslateVegTypes ( int  VegReference)
inline

References g_letype, and LE_TypeClass::TranslateVegTypes().

1580 {
1581  return g_letype->TranslateVegTypes( VegReference );
1582 }
class LE_TypeClass * g_letype
Definition: elements.cpp:265
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: elements.cpp:2687
void Landscape::TurnTheWorld ( void  )
inline

Referenced by RunTheSim().

825 {
826  Tick();
827 }
void Tick(void)
Definition: Landscape.cpp:1288
bool Landscape::UMarginTest ( int  a_fieldpoly,
int  a_borderpoly,
int  a_x,
int  a_y,
int  a_width 
)
protected
2444  {
2445  int index;
2446  int x_add[ 8 ] = { 1*a_width, 1*a_width, 0, -1*a_width, -1*a_width, -1*a_width, 0, 1*a_width };
2447  int y_add[ 8 ] = { 0, -1*a_width, -1*a_width, -1*a_width, 0, 1*a_width, 1*a_width, 1*a_width };
2448  int width = m_land->MapWidth();
2449  int height = m_land->MapHeight();
2450  // Scan anti-clockwise from center pixel coordinate.
2451  for ( unsigned int i = 0; i < 8; i++ ) {
2452  if ( ( a_x + x_add[ i ] >= width ) || ( a_x + x_add[ i ] < 0 ) || ( a_y + y_add[ i ] >= height )
2453  || ( a_y + y_add[ i ] < 0 ) ) {
2454  return true;
2455  }
2456  //continue;
2457  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2458  if ( ( index != a_fieldindex ) && ( index != a_marginindex ) ) return true;
2459  }
2460  return false;
2461 }
RasterMap * m_land
The big map.
Definition: landscape.h:122
void Landscape::UnsprayedMarginAdd ( LE a_field)
protected

References LE::GetValidX(), LE::GetValidY(), l_map_umargin_width(), LE::SetArea(), LE::SetPoly(), and LE::SetUnsprayedMarginPolyRef().

2392  {
2393  int x = a_field->GetValidX();
2394  int y = a_field->GetValidY();
2395  if ( ( x == -1 ) || ( y == -1 ) ) {
2396  // Tripping this probably means it is not a field
2397  g_msg->Warn( WARN_BUG, "Landscape::UnsprayedMarginAdd(): Uninitialized border coordinate!", "" );
2398  exit( 1 );
2399  }
2400  LE * umargin = NewElement( tole_UnsprayedFieldMargin );
2402  m_elems.resize( m_elems.size() + 1 );
2403  m_elems[ m_elems.size() - 1 ] = umargin;
2405  umargin->SetPoly( hb_first_free_poly_num++ );
2406  umargin->SetArea( 0.0 );
2407 
2408  for ( int q = 0; q < l_map_umargin_width.value(); q++ )
2409  UnsprayedMarginScan( a_field, q + 1 );
2410 }
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:119
int GetValidY(void)
Definition: elements.h:323
void SetUnsprayedMarginPolyRef(int a_unsprayedmargin)
Definition: elements.h:314
void UnsprayedMarginScan(LE *a_field, int a_width)
Definition: Landscape.cpp:2413
int GetValidX(void)
Definition: elements.h:322
Definition: elements.h:81
void SetPoly(int a_poly)
Definition: elements.h:220
int hb_first_free_poly_num
Definition: landscape.h:252
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void SetArea(double a_area)
Definition: elements.h:223
static CfgInt l_map_umargin_width("MAP_UMARGINWIDTH", CFG_CUSTOM, 12)
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3449
void Landscape::UnsprayedMarginScan ( LE a_field,
int  a_width 
)
protected

References LE::AddArea(), LE::GetPoly(), LE::GetUnsprayedMarginPolyRef(), LE::GetValidX(), LE::GetValidY(), and SupplyLEPointer().

2413  {
2414  LE * umargin = g_landscape_p->SupplyLEPointer( a_field->GetUnsprayedMarginPolyRef() );
2415  int fieldpoly = a_field->GetPoly();
2416  int borderpoly = umargin->GetPoly();
2417  int borderindex = m_polymapping[ borderpoly ];
2418  int fieldindex = m_polymapping[ fieldpoly ];
2419  int notforever = 5000;
2420 
2421  // These two will be modified through pointer operations
2422  // in BorderStep().
2423  int x = a_field->GetValidX();
2424  int y = a_field->GetValidY();
2425  // Now the problem is that GetValid does not always return a valid co-ord!
2426  // so we need to search for one
2427  if ( !FindValidXY( fieldindex, x, y ) ) return;
2428 
2429  while ( --notforever ) {
2430  // Check if this position should be made into a border.
2431  if ( UMarginTest( fieldindex, borderindex, x, y, a_width ) ) {
2432  // Add this pixel to the border element in the big map.
2433  m_land->Put( x, y, borderindex );
2434  a_field->AddArea( -1.0 );
2435  umargin->AddArea( 1.0 );
2436  };
2437  // Step to next coordinate. Quit when done.
2438  if ( !BorderStep( fieldindex, borderindex, & x, & y ) )
2439  return;
2440  }
2441 }
bool FindValidXY(int a_field, int &a_x, int &a_y)
Definition: Landscape.cpp:2463
bool BorderStep(int a_fieldpoly, int a_borderpoly, int *a_x, int *a_y)
Definition: Landscape.cpp:2254
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1018
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:311
int GetValidY(void)
Definition: elements.h:323
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: elements.h:189
bool UMarginTest(int a_fieldpoly, int a_borderpoly, int a_x, int a_y, int a_width)
Definition: Landscape.cpp:2444
int GetValidX(void)
Definition: elements.h:322
Definition: elements.h:81
void AddArea(double a_area_diff)
Definition: elements.h:308
Landscape * g_landscape_p
Definition: Landscape.cpp:238
RasterMap * m_land
The big map.
Definition: landscape.h:122
int * m_polymapping
m_polymapping is a mapping from polygon numbers into the list of landscape elements, m_elems. When using this it is important that it is the poly num and not the map index that is used in calling.
Definition: Landscape.cpp:237
void Landscape::VegDump ( int  x,
int  y 
)
protected
1450  {
1451  FILE * vfile=fopen("VegDump.txt", "a" );
1452  if (!vfile) {
1453  g_msg->Warn( WARN_FILE, "Landscape::VegDump(): Unable to open file", "VegDump.txt" );
1454  exit( 1 );
1455  }
1456  int year = SupplyYearNumber();
1457  int day = SupplyDayInYear();
1458  double hei = SupplyVegHeight( x, y );
1459  double bio = SupplyVegBiomass( x, y );
1460  double cover = SupplyVegCover( x, y );
1461  double density = bio / ( hei + 1 );
1462  double weeds = SupplyWeedBiomass( x, y );
1463  double insects = SupplyInsects( x, y );
1464  double LATotal = SupplyLATotal(x, y);
1465  double LAGreen = SupplyLAGreen(x, y);
1466  double digest = SupplyVegDigestability(x, y);
1467  double GreenBiomass = SupplyGreenBiomass(x,y);
1468  double DeadBiomass = SupplyDeadBiomass(x,y);
1469  int grazed = SupplyGrazingPressure(x, y);
1470  double ggraze = GetActualGooseGrazingForage(m_land->Get(x, y), gs_Pinkfoot);
1471  int VegType = BackTranslateVegTypes(SupplyVegType(x, y));
1472  double grain = SupplyBirdSeedForage(x, y);
1473 
1474  fprintf( vfile, "%d\t%d\t%g\t%g\t%d\t%g\t%g\t%g\t%i\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n", year, day, hei, bio, grazed, density, cover, weeds, VegType, insects, LATotal, LAGreen, digest, GreenBiomass, DeadBiomass, ggraze, grain );
1475  /*
1476  y += 100;
1477  x += 100;
1478  hei = SupplyVegHeight( x, y );
1479  bio = SupplyVegBiomass( x, y );
1480  cover = SupplyVegCover( x, y );
1481  density = bio / ( hei + 1 );
1482  weeds = SupplyWeedBiomass( x, y );
1483  VegType = SupplyVegType( x, y );
1484  insects = SupplyInsects( x, y );
1485  digest = SupplyVegDigestability(x,y);
1486  fprintf( vfile, "%g\t%g\t%g\t%g\t%g\t%i\t%g\t%g\n", hei, bio, density, cover, weeds, VegType, insects, digest );
1487  */
1488  fclose( vfile );
1489 }
double SupplyLATotal(int a_x, int a_y)
Definition: landscape.h:923
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: landscape.h:1241
double SupplyGreenBiomass(int a_polyref)
Definition: landscape.h:936
int SupplyGrazingPressure(int a_polyref)
Definition: landscape.h:1146
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...
Definition: landscape.h:557
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: landscape.h:1593
double SupplyLAGreen(int a_polyref)
Definition: landscape.h:960
double SupplyWeedBiomass(int a_polyref)
Definition: landscape.h:883
int SupplyYearNumber(void)
Definition: landscape.h:1540
double SupplyDeadBiomass(int a_polyref)
Definition: landscape.h:948
double SupplyInsects(int a_polyref)
Definition: landscape.h:1007
RasterMap * m_land
The big map.
Definition: landscape.h:122
int SupplyDayInYear(void)
Definition: landscape.h:1520
double SupplyVegBiomass(int a_polyref)
Definition: landscape.h:872
double SupplyVegCover(int a_polyref)
Definition: landscape.h:967
double SupplyBirdSeedForage(int a_polyref)
Returns the grain forage resource.
Definition: landscape.h:575
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:855
double SupplyVegDigestability(int a_polyref)
Definition: landscape.h:838
std::string Landscape::VegtypeToString ( TTypesOfVegetation  a_veg)
3937  {
3938  char error_num[20];
3939 
3940  switch (a_veg) {
3941  case tov_Carrots:
3942  return "Carrots ";
3943  case tov_BroadBeans:
3944  return "BroadBeans ";
3945  case tov_FodderGrass:
3946  return "FodderGrass ";
3947  case tov_CloverGrassGrazed1:
3948  return "CloverGrassGrazed1 ";
3949  case tov_CloverGrassGrazed2:
3950  return "CloverGrassGrazed2 ";
3951  case tov_FieldPeas:
3952  return "FieldPeas ";
3953  case tov_FieldPeasSilage:
3954  return "FieldPeasSilage ";
3955  case tov_FodderBeet:
3956  return "FodderBeet ";
3957  case tov_SugarBeet:
3958  return "SugarBeet ";
3959  case tov_OFodderBeet:
3960  return "OFodderBeet ";
3961  case tov_Lawn:
3962  return "Lawn ";
3963  case tov_Maize:
3964  return "Maize ";
3965  case tov_MaizeSilage:
3966  return "MaizeSilage ";
3967  case tov_OMaizeSilage:
3968  return "OMaizeSilage ";
3969  case tov_NaturalGrass:
3970  return "NaturalGrass ";
3971  case tov_NoGrowth:
3972  return "NoGrowth ";
3973  case tov_None:
3974  return "None ";
3975  case tov_OrchardCrop:
3976  return "OrchardCrop ";
3977  case tov_Oats:
3978  return "Oats ";
3979  case tov_OBarleyPeaCloverGrass:
3980  return "OBarleyPeaCloverGrass";
3981  case tov_OCarrots:
3982  return "OCarrots ";
3983  case tov_OCloverGrassGrazed1:
3984  return "OCloverGrassGrazed1 ";
3985  case tov_OCloverGrassGrazed2:
3986  return "OCloverGrassGrazed2 ";
3987  case tov_OCloverGrassSilage1:
3988  return "OCloverGrassSilage1 ";
3989  case tov_OFieldPeas:
3990  return "OFieldPeas ";
3991  case tov_OFieldPeasSilage:
3992  return "OFieldPeasSilage ";
3993  case tov_OFirstYearDanger:
3994  return "OFirstYearDanger ";
3995  case tov_OGrazingPigs:
3996  return "OGrazingPigs ";
3997  case tov_OOats:
3998  return "OOats ";
3999  case tov_OPermanentGrassGrazed:
4000  return "OPermanentGrassGrazed";
4001  case tov_OPotatoes:
4002  return "OPotatoes ";
4003  case tov_OSBarleySilage:
4004  return "OSBarleySilage ";
4005  case tov_OSeedGrass1:
4006  return "OSeedGrass1 ";
4007  case tov_OSeedGrass2:
4008  return "OSeedGrass2 ";
4009  case tov_OSetaside:
4010  return "OSetaside ";
4011  case tov_OSpringBarley:
4012  return "OSpringBarley ";
4013  case tov_OSpringBarleyExt:
4014  return "OSpringBarleyExt ";
4015  case tov_OSpringBarleyClover:
4016  return "OSpringBarleyClover ";
4017  case tov_OSpringBarleyGrass:
4018  return "OSpringBarleyGrass ";
4019  case tov_OSpringBarleyPigs:
4020  return "OSpringBarleyPigs ";
4021  case tov_OTriticale:
4022  return "OTriticale ";
4023  case tov_OWinterBarley:
4024  return "OWinterBarley ";
4025  case tov_OWinterBarleyExt:
4026  return "OWinterBarleyExt ";
4027  case tov_OWinterRape:
4028  return "OWinterRape ";
4029  case tov_OWinterRye:
4030  return "OWinterRye ";
4031  case tov_OWinterWheatUndersown:
4032  return "OWinterWheatUndersown";
4033  case tov_OWinterWheat:
4034  return "OWinterWheat";
4035  case tov_OWinterWheatUndersownExt:
4036  return "OWinterWheatUsowExt ";
4037  case tov_PermanentGrassGrazed:
4038  return "PermanentGrassGrazed ";
4039  case tov_PermanentGrassLowYield:
4040  return "PermanentGrassLowYield";
4041  case tov_PermanentGrassTussocky:
4042  return "PermanentGrassTussocky";
4043  case tov_PermanentSetaside:
4044  return "PermanentSetaside ";
4045  case tov_Potatoes:
4046  return "PotatoesEat ";
4047  case tov_PotatoesIndustry:
4048  return "PotatoesIndustry ";
4049  case tov_SeedGrass1:
4050  return "SeedGrass1 ";
4051  case tov_SeedGrass2:
4052  return "SeedGrass2 ";
4053  case tov_Setaside:
4054  return "Setaside ";
4055  case tov_SpringBarley:
4056  return "SpringBarley ";
4057  case tov_SpringBarleySpr:
4058  return "SpringBarleySpr ";
4059  case tov_SpringBarleyPTreatment:
4060  return "SpringBarleyPTreat ";
4061  case tov_SpringBarleySKManagement:
4062  return "SpringBarleySKMan ";
4063  case tov_SpringBarleyCloverGrass:
4064  return "SprBarleyCloverGrass ";
4065  case tov_SpringBarleyGrass:
4066  return "SpringBarleyGrass ";
4067  case tov_SpringBarleySeed:
4068  return "SpringBarleySeed ";
4069  case tov_SpringBarleySilage:
4070  return "SpringBarleySilage ";
4071  case tov_SpringRape:
4072  return "SpringRape ";
4073  case tov_SpringWheat:
4074  return "SpringWheat ";
4075  case tov_AgroChemIndustryCereal:
4076  return "AgroChemIndustry Cereal ";
4077  case tov_Triticale:
4078  return "Triticale ";
4079  case tov_WinterBarley:
4080  return "WinterBarley ";
4081  case tov_WinterRape:
4082  return "WinterRape ";
4083  case tov_WinterRye:
4084  return "WinterRye ";
4085  case tov_WinterWheat:
4086  return "WinterWheat ";
4087  case tov_WinterWheatShort:
4088  return "WinterWheatShort ";
4089  case tov_WWheatPControl:
4090  return "P Trial Control ";
4091  case tov_WWheatPToxicControl:
4092  return "P Trial Toxic Control";
4093  case tov_WWheatPTreatment:
4094  return "P Trial Treatment ";
4095  case tov_Undefined:
4096  return "Undefined ";
4097  case tov_WinterWheatStrigling:
4098  return "WWStrigling ";
4099  case tov_WinterWheatStriglingSingle:
4100  return "WWStriglingSingle ";
4101  case tov_WinterWheatStriglingCulm:
4102  return "WWStriglingCulm ";
4103  case tov_SpringBarleyCloverGrassStrigling:
4104  return "SBPCGStrigling ";
4105  case tov_SpringBarleyStrigling:
4106  return "SBarleyStrigling ";
4107  case tov_SpringBarleyStriglingSingle:
4108  return "SBarleyStriglingSgl ";
4109  case tov_SpringBarleyStriglingCulm:
4110  return "SBarleyStriglingCulm ";
4111  case tov_MaizeStrigling:
4112  return "MaizseStrigling ";
4113  case tov_WinterRapeStrigling:
4114  return "WRapeStrigling ";
4115  case tov_WinterRyeStrigling:
4116  return "WRyeStrigling ";
4117  case tov_WinterBarleyStrigling:
4118  return "WBStrigling ";
4119  case tov_FieldPeasStrigling:
4120  return "FieldPeasStrigling ";
4121  case tov_SpringBarleyPeaCloverGrassStrigling:
4122  return "SBPeaCloverGrassStr ";
4123  case tov_YoungForest:
4124  return "Young Forest ";
4125  case tov_Wasteland:
4126  return "Wasteland ";
4127  case tov_Heath:
4128  return "Heath/Grass ";
4129  case tov_PlantNursery:
4130  return "Plant Nursery ";
4131 
4132  default:
4133  sprintf(error_num, "%d", a_veg);
4134  g_msg->Warn(WARN_FILE, "Landscape::VegtypeToString(): Unknown event type:", error_num);
4135  exit(1);
4136  }
4137 }
void Landscape::Warn ( std::string  a_msg1,
std::string  a_msg2 
)
inline

Referenced by GetProbeInput_ini(), and RodenticidePredators_Population_Manager::ReadHabitatValues().

1504 {
1505  g_msg->Warn( WARN_MSG, a_msg1, a_msg2 );
1506 }
void Landscape::WriteOpenness ( void  )

Stores openness for all polygons to a standard file.

Member Data Documentation

int Landscape::hb_border_pixels
protected
int Landscape::hb_core_pixels
protected
int Landscape::hb_first_free_poly_num
protected
vector<int> Landscape::hb_hedges
protected
int Landscape::hb_height
protected
int* Landscape::hb_map
protected
int Landscape::hb_max_x
protected
int Landscape::hb_max_y
protected
int Landscape::hb_min_x
protected
int Landscape::hb_min_y
protected
vector<LE*> Landscape::hb_new_hbs
protected
int Landscape::hb_size
protected
int Landscape::hb_width
protected
double* Landscape::l_vegtype_areas
private
int Landscape::le_signal_index
protected
bool Landscape::m_DoMissingPolygonsManipulations
private

Flag to signal that missing polygons exist

vector<LE*> Landscape::m_elems
private

List of all landscape elements. The index is a sequential number, to get the polynum look this number up in m_polymapping.

FarmManager* Landscape::m_FarmManager
private

List of all the farms.

Polynomial2CurveClass* Landscape::m_GooseIntakeRateVSVegetationHeight_BG
private
Polynomial2CurveClass* Landscape::m_GooseIntakeRateVSVegetationHeight_GL
private
Polynomial2CurveClass* Landscape::m_GooseIntakeRateVSVegetationHeight_PF
private

Curve relatning goose intake rates in KJ/min to vegetation height.

int Landscape::m_height
private
int Landscape::m_height10
private
RasterMap* Landscape::m_land
private

The big map.

int Landscape::m_LargestPolyNumUsed
protected
int Landscape::m_maxextent
private
bool Landscape::m_NeedCentroidCalculation
private

a flag to ensure centroid calculation on object construction

bool Landscape::m_NeedOpennessCalculation
private

a flag to ensure openness calculation on object construction

TTypesOfPesticide Landscape::m_PesticideType
protected

An attribute to hold the pesticide type being tested, if there is one, if not default is -1.

vector<int> Landscape::m_PondIndexList
protected

List of pond indexes.

vector<int> Landscape::m_PondRefsList
protected

List of pond polyrefs.

RodenticideManager* Landscape::m_RodenticideManager
private
RodenticidePredators_Population_Manager* Landscape::m_RodenticidePreds
private
Population_Manager* Landscape::m_ThePopManager
private

a pointer to the current main population manager

bool Landscape::m_toxShouldSpray
protected
int Landscape::m_treatment_counts[last_treatment]
protected
char Landscape::m_versioninfo[30]
private
int Landscape::m_width
private
int Landscape::m_width10
private
int Landscape::m_x_add[8]
protected
int Landscape::m_y_add[8]
protected

The documentation for this class was generated from the following files: