ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
Landscape Class Reference

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

#include <landscape.h>

Public Member Functions

void FillVegAreaData ()
 
double GetVegArea (int v)
 
void DumpVegAreaData (int a_day)
 
void SkylarkEvaluation (SkTerritories *a_skt)
 
void RodenticidePredatorsEvaluation (RodenticidePredators_Population_Manager *a_rppm)
 
Population_ManagerSupplyThePopManager ()
 Get the pointer to the current main population manager. More...
 
void SetThePopManager (Population_Manager *a_ptr)
 Set the pointer to the current main population manager. More...
 
int SupplyFarmAnimalCensus (int a_farm_ref, int a_LifeStage)
 
int SupplyVegPhase (int a_poly)
 
 ~Landscape (void)
 
 Landscape (const char *a_configfile, const char *a_errorfile)
 
void SimulationClosingActions ()
 
void Tick (void)
 
void TurnTheWorld (void)
 
int HowManyPonds ()
 Returns the number of ponds in the landscape. More...
 
int SupplyRandomPondIndex ()
 Returns random pond index. More...
 
int SupplyRandomPondRef ()
 Returns random pond polyref. More...
 
int SupplyPondIndex (int a_pondref)
 Returns the index of a pond based on pondref or -1 if not found. More...
 
void SetMaleNewtPresent (int a_InPondIndex)
 Sets a male as being present in a pond. More...
 
bool SupplyMaleNewtPresent (int a_InPondIndex)
 Determines if a male is present in a pond. More...
 
FarmSupplyFarmPtr (int a_owner)
 
FarmManagerSupplyFarmManagerPtr ()
 
int SupplyLargestPolyNumUsed ()
 
bool SupplyShouldSpray ()
 
double SupplyVegDigestabilityVector (unsigned int a_index)
 
double SupplyVegDigestability (int a_polyref)
 
double SupplyVegDigestability (int a_x, int a_y)
 
double SupplyVegHeightVector (unsigned int a_index)
 
double SupplyVegHeight (int a_polyref)
 
double SupplyVegHeight (int a_x, int a_y)
 
double SupplyVegBiomassVector (unsigned int a_index)
 
double SupplyVegBiomass (int a_polyref)
 
double SupplyVegBiomass (int a_x, int a_y)
 
int SupplyVegDensity (int a_polyref)
 
int SupplyVegDensity (int a_x, int a_y)
 
double SupplyWeedBiomass (int a_polyref)
 
double SupplyWeedBiomass (int a_x, int a_y)
 
bool SupplySkScrapes (int a_polyref)
 
bool SupplyVegPatchy (int a_polyref)
 
bool SupplyVegPatchy (int a_x, int a_y)
 
double SupplyGreenBiomass (int a_polyref)
 
double SupplyGreenBiomass (int a_x, int a_y)
 
double SupplyDeadBiomass (int a_polyref)
 
double SupplyDeadBiomass (int a_x, int a_y)
 
double SupplyLAGreen (int a_polyref)
 
double SupplyLAGreen (int a_x, int a_y)
 
double SupplyLATotal (int a_x, int a_y)
 
double SupplyVegCover (int a_polyref)
 
double SupplyVegCoverVector (unsigned int a_index)
 
double SupplyVegCover (int a_x, int a_y)
 
TTypesOfVegetation SupplyLastSownVeg (int a_polyref)
 
TTypesOfVegetation SupplyLastSownVeg (int a_x, int a_y)
 
TTypesOfVegetation SupplyLastSownVegVector (unsigned int a_index)
 
double SupplyInsects (int a_polyref)
 
double SupplyInsects (int a_x, int a_y)
 
bool SubtractPondLarvalFood (double a_food, int a_polyrefindex)
 Removes larval food from a pond and returns true if it was possible, otherwise false. More...
 
double SupplyRodenticide (int a_x, int a_y)
 Gets total rodenticide for a location. More...
 
bool SupplyPesticideDecay ()
 Returns true if there is any pesticide in the system at all at this point. More...
 
double SupplyPesticide (int a_x, int a_y)
 Gets total pesticide for a location. More...
 
bool SupplyOverspray (int a_x, int a_y)
 Gets the overspray flag. More...
 
double SupplyPesticideP (int a_x, int a_y)
 Gets plant pesticide for a location. More...
 
double SupplyPesticideS (int a_x, int a_y)
 Gets soil pesticide for a location. More...
 
double SupplyPesticide (int a_polyref)
 Gets total pesticide for the centroid of a polygon. More...
 
double SupplyPesticideP (int a_polyref)
 Gets plant pesticide for the centroid of a polygon. More...
 
double SupplyPesticideS (int a_polyref)
 Gets soil pesticide for the centroid of a polygon. More...
 
RodenticidePredators_Population_Manager * SupplyRodenticidePredatoryManager ()
 
TTypesOfPesticide SupplyPesticideType (void)
 
GooseFieldListGetGooseFields (double)
 Gets the list of suitable goose foraging fields today. More...
 
void CalculateOpenness (bool a_realcalc)
 Causes openness to be calulated and stored for all polygons. More...
 
void WriteOpenness (void)
 Stores openness for all polygons to a standard file. More...
 
void ReadOpenness (void)
 Reads openness values from a standard input file for all polygons. More...
 
int CalulateFieldOpennessCentroid (int a_pref)
 Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Searches from centroid. More...
 
int CalulateFieldOpennessAllCells (int a_pref)
 Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Checks all field 1m2. More...
 
int LineHighTest (int a_cx, int a_cy, double a_offsetx, double a_offsety)
 Provides a measure of the shortest distance in using a vector from a_cx,a_cy unitl tall obstacles are encountered in both +ve & -ve directions. More...
 
int SupplyOpenness (int a_poly)
 Get openness for a polygon. More...
 
int SupplyOpenness (int a_x, int a_y)
 Get openness for a location. More...
 
bool SupplyLEHigh (int a_x, int a_y)
 Tests whether the polygon at a_x,a_y is designated as high. More...
 
polylistSupplyLargeOpenFieldsNearXY (int x, int y, int range, int a_openness)
 Returns a pointer to a list of polygonrefs to large open fields within a range of location x,y. More...
 
int SupplySoilType (int a_x, int a_y)
 Returns the soil type in ALMaSS types reference numbers. More...
 
int SupplySoilTypeR (int a_x, int a_y)
 Returns the soil type in rabbit warren reference numbers. More...
 
APoint SupplyCentroid (int a_polyref)
 
APoint SupplyCentroidIndex (int a_polyrefindex)
 
int SupplyCentroidX (int a_polyref)
 
int SupplyCentroidY (int a_polyref)
 
int SupplyCentroidX (int a_x, int a_y)
 
int SupplyCentroidY (int a_x, int a_y)
 
int SupplyFarmIntensity (int a_x, int a_y)
 
int SupplyFarmIntensity (int a_polyref)
 
int SupplyFarmIntensityI (int a_polyindex)
 
TTypesOfLandscapeElement SupplyElementType (int a_polyref)
 
TTypesOfLandscapeElement SupplyElementType (int a_x, int a_y)
 
TTypesOfLandscapeElement SupplyElementTypeCC (int a_x, int a_y)
 
int SupplyCountryDesig (int a_x, int a_y)
 
int SupplyElementSubType (int a_polyref)
 
int SupplyElementSubType (int a_x, int a_y)
 
TTypesOfVegetation SupplyVegType (int a_x, int a_y)
 
TTypesOfVegetation SupplyVegType (int polyref)
 
TTypesOfVegetation SupplyVegTypeVector (unsigned int a_index)
 
int SupplyGrazingPressureVector (unsigned int a_index)
 
int SupplyGrazingPressure (int a_polyref)
 
int SupplyGrazingPressure (int a_x, int a_y)
 
bool SupplyIsCereal (int a_polyref)
 
bool SupplyIsMatureCereal (int a_polyref)
 
bool SupplyIsGrass (int a_polyref)
 
bool SupplyHasTramlines (int a_x, int a_y)
 
bool SupplyHasTramlines (int a_polyref)
 
bool SupplyJustMownVector (unsigned int a_index)
 
bool SupplyJustMown (int a_polyref)
 
int SupplyJustSprayedVector (unsigned int a_index)
 
int SupplyJustSprayed (int a_polyref)
 
int SupplyJustSprayed (int a_x, int a_y)
 
int SupplyTreeAge (int a_Polyref)
 
int SupplyTreeAge (int, int)
 
int SupplyVegAge (int a_Polyref)
 
int SupplyVegAge (int a_x, int a_y)
 
int SupplyNumberOfFarms ()
 
int SupplyFarmOwner (int a_x, int a_y)
 
int SupplyFarmOwner (int a_polyref)
 
int SupplyFarmOwnerIndex (int a_x, int a_y)
 
int SupplyFarmOwnerIndex (int a_polyref)
 
TTypesOfFarm SupplyFarmType (int a_polyref)
 
TTypesOfFarm SupplyFarmType (int a_x, int a_y)
 
TTypesOfOptFarms SupplyOptFarmType (int a_x, int a_y)
 
int SupplyFarmArea (int a_polyref)
 
double SupplyPolygonAreaVector (int a_polyref)
 Returns the area of a polygon using the vector index as a reference. More...
 
double SupplyPolygonArea (int a_polyref)
 
void SetBirdSeedForage (int a_polyref, double a_fooddensity)
 Sets the grain forage resource as seen from a goose standpoint at a polygon. More...
 
void SetBirdMaizeForage (int a_polyref, double a_fooddensity)
 Sets the maize forage resource as seen from a goose standpoint at a polygon. More...
 
double SupplyGooseGrazingForageH (double a_height, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon based on the height only. More...
 
double SupplyGooseGrazingForageH (int a_polygon, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by number based on height only. More...
 
double GetActualGooseGrazingForage (int a_x, int a_y, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location. More...
 
double GetActualGooseGrazingForage (int a_polygon, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location The amount of food avaiable as grazing resource based on the vegetation height is species specific. More...
 
double SupplyBirdSeedForage (int a_polyref)
 Returns the grain forage resource. More...
 
double SupplyBirdSeedForage (int a_x, int a_y)
 Returns the grain forage resource as seen from a goose standpoint at an x,y location. More...
 
double SupplyBirdMaizeForage (int a_polyref)
 Returns the maize forage resource. More...
 
double SupplyBirdMaizeForage (int a_x, int a_y)
 Returns the maize forage resource as seen from a goose standpoint at an x,y location. More...
 
void RecordGooseNumbers (int a_poly, int a_number)
 This records the number of geese on the polygon the day before. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseSpNumbers (int a_poly, int a_number, GooseSpecies a_goose)
 This records the number of geese of each species on the polygon the day before. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseNumbersTimed (int a_poly, int a_number)
 This records the number of geese on the polygon the day before at a predefined time. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseSpNumbersTimed (int a_poly, int a_number, GooseSpecies a_goose)
 This records the number of geese of each species on the polygon the day before at a predefined time. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void GrazeVegetation (int a_poly, double a_forage)
 Removes grazing forage from a poly per m2. More...
 
void GrazeVegetationTotal (int a_poly, double a_forage)
 Removes grazing forage from a poly and divides this out per m2. More...
 
int GetGooseNumbers (int a_poly)
 This returns the number of geese on the polygon the day before. More...
 
int GetGooseNumbers (int a_x, int a_y)
 This returns the number of geese on the polygon specifed by a_x, a_y the day before. More...
 
int SupplyLastTreatment (int a_polyref, int *a_index)
 
int SupplyLastTreatment (int a_x, int a_y, int *a_index)
 
double GetHareFoodQuality (int a_polygon)
 
double SupplyGlobalRadiation ()
 
double SupplyGlobalRadiation (long a_date)
 
double SupplyRain (void)
 
double SupplyTemp (void)
 
double SupplyHumidity (void)
 
double SupplyMeanTemp (long a_date, unsigned int a_period)
 
double SupplyWind (void)
 
int SupplyWindDirection (void)
 
double SupplySnowDepth (void)
 
bool SupplySnowcover (void)
 
int SupplyDaylength (void)
 
double SupplyRain (long a_date)
 
double SupplyTemp (long a_date)
 
double SupplyWind (long a_date)
 
double SupplyDayDegrees (int a_polyref)
 
double SupplyRainPeriod (long a_date, int a_period)
 
double SupplyWindPeriod (long a_date, int a_period)
 
double SupplyTempPeriod (long a_date, int a_period)
 
bool SupplySnowcover (long a_date)
 
bool IsFieldType (TTypesOfLandscapeElement a_tole)
 
int SupplyPolyRef (int a_x, int a_y)
 
int SupplyPolyRefIndex (int a_x, int a_y)
 
int SupplyPolyRefCC (int a_x, int a_y)
 
int SupplySimAreaWidth (void)
 
int SupplySimAreaHeight (void)
 
int SupplySimAreaMaxExtent (void)
 
int SupplySimAreaMinExtent (void)
 
int SupplyDaylength (long a_date)
 
int SupplyDayInYear (void)
 
int SupplyHour (void)
 Get the hour of the day. More...
 
int SupplyMinute (void)
 Get the minute of the hour. More...
 
unsigned int SupplyNumberOfPolygons (void)
 
TTypesOfLandscapeElement SupplyElementTypeFromVector (unsigned int a_index)
 
int SupplyPolyRefVector (unsigned int a_index)
 
int SupplyPesticideCell (int a_polyref)
 
int SupplyValidX (int a_polyref)
 
int SupplyValidY (int a_polyref)
 
double SupplyPondPesticide (int a_poly_index)
 Get the pesticide concentration per liter from a pond (must be a pond index on calling) More...
 
void CorrectCoords (int &x, int &y)
 Function to prevent wrap around errors with co-ordinates using x/y pair. More...
 
APoint CorrectCoordsPt (int x, int y)
 Function to prevent wrap around errors with co-ordinates using x/y pair. More...
 
void CorrectCoordsPointNoWrap (APoint &a_pt)
 Function to prevent wrap around errors with co-ordinates using a APoint. More...
 
int CorrectWidth (int x)
 
int CorrectHeight (int y)
 
void SetPolyMaxMinExtents (void)
 
void CalculateCentroids (void)
 
void DumpCentroids (void)
 
void BuildingDesignationCalc ()
 used to calculate whether a building is rural or town - for rodenticide use More...
 
void CentroidSpiralOut (int a_polyref, int &a_x, int &a_y)
 
void CentroidSpiralOutBlocks (int a_polyref, int &a_x, int &a_y)
 
const char * SupplyVersion (void)
 
void DumpPublicSymbols (const char *a_dumpfile, CfgSecureLevel a_level)
 
void DumpAllSymbolsAndExit (const char *a_dumpfile)
 
bool ReadSymbols (const char *a_cfgfile)
 
void DumpMapInfoByArea (const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
 
void Warn (std::string a_msg1, std::string a_msg2)
 
int * SupplyMagicMapP (int a_x, int a_y)
 
int MagicMapP2PolyRef (int a_magic)
 
int SupplyRoadWidth (int, int)
 
double SupplyTrafficLoad (int a_x, int a_y)
 
double SupplyTrafficLoad (int a_polyref)
 
int SupplyTreeHeight (int, int)
 
int SupplyUnderGrowthWidth (int, int)
 
int SupplyTreeHeight (int)
 
int SupplyUnderGrowthWidth (int)
 
long SupplyGlobalDate (void)
 
int SupplyYear (void)
 
int SupplyYearNumber (void)
 
int SupplyMonth (void)
 
int SupplyDayInMonth (void)
 
double SupplyDaylightProp ()
 
double SupplyNightProp ()
 
void SupplyLEReset (void)
 
int SupplyLENext (void)
 
int SupplyLECount (void)
 
LE_Signal SupplyLESignal (int a_polyref)
 
void SetLESignal (int a_polyref, LE_Signal a_signal)
 
void IncTreatCounter (int a_treat)
 
TTypesOfLandscapeElement TranslateEleTypes (int EleReference)
 
TTypesOfVegetation TranslateVegTypes (int VegReference)
 
LESupplyLEPointer (int a_polyref)
 
int BackTranslateEleTypes (TTypesOfLandscapeElement EleReference)
 
int BackTranslateVegTypes (TTypesOfVegetation VegReference)
 
std::string EventtypeToString (int a_event)
 
std::string PolytypeToString (TTypesOfLandscapeElement a_le_type)
 
std::string VegtypeToString (TTypesOfVegetation a_veg)
 

Protected Member Functions

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

Protected Attributes

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

Private Attributes

char m_versioninfo [30]
 
FarmManagerm_FarmManager
 List of all the farms. More...
 
vector< LE * > m_elems
 List of all landscape elements. The index is a sequential number, to get the polynum look this number up in m_polymapping. More...
 
RasterMapm_land
 The big map. More...
 
int m_width
 
int m_height
 
int m_width10
 
int m_height10
 
int m_maxextent
 
bool m_NeedCentroidCalculation
 a flag to ensure centroid calculation on object construction More...
 
bool m_NeedOpennessCalculation
 a flag to ensure openness calculation on object construction More...
 
bool m_DoMissingPolygonsManipulations
 
double * l_vegtype_areas
 
Population_Managerm_ThePopManager
 a pointer to the current main population manager More...
 
RodenticideManager * m_RodenticideManager
 
RodenticidePredators_Population_Manager * m_RodenticidePreds
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
 Curve relatning goose intake rates in KJ/min to vegetation height. More...
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
 
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
 

Detailed Description

The landscape class containing all environmental and topographical data.

Definition at line 109 of file landscape.h.

Constructor & Destructor Documentation

Landscape::~Landscape ( void  )

Definition at line 1255 of file Landscape.cpp.

References cfg_rodenticide_enable, g_crops, g_date, g_letype, g_msg, g_pest, g_weather, l_map_dump_treatcounts_enable, l_map_dump_treatcounts_file, CfgBool::value(), and CfgStr::value().

1255  {
1258  }
1259 
1260  for ( unsigned int i = 0; i < m_elems.size(); i++ )
1261  delete m_elems[ i ];
1262 
1263  free( m_polymapping );
1264  free( l_vegtype_areas );
1265  delete m_land;
1266  //delete g_rotation;
1267  delete g_crops;
1268  delete g_letype;
1269  delete g_weather;
1270  delete g_date;
1271  delete g_pest;
1273  {
1274  delete m_RodenticideManager;
1275  delete m_RodenticidePreds;
1276  }
1277  delete m_FarmManager;
1278  delete g_msg; // Must be last.
1279 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
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
class CropData * g_crops
Definition: plants.cpp:39
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
class Weather * g_weather
Definition: weather.cpp:41
const char * value(void)
Definition: configurator.h:139
class LE_TypeClass * g_letype
Definition: elements.cpp:265
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
bool value(void)
Definition: configurator.h:123
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
void DumpTreatCounters(const char *a_filename)
Definition: Landscape.cpp:3350
class Calendar * g_date
Definition: calendar.cpp:38
static CfgBool l_map_dump_treatcounts_enable("MAP_DUMP_TREATCOUNTS_ENABLE", CFG_CUSTOM, false)
static CfgStr l_map_dump_treatcounts_file("MAP_DUMP_TREATCOUNTS_FILE", CFG_CUSTOM,"treatment_counts.txt")
double * l_vegtype_areas
Definition: landscape.h:141
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
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.

Definition at line 677 of file Landscape.cpp.

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_cfg, g_crops, g_date, g_letype, g_map_le_border_chance, g_map_le_borderremoval, g_map_le_borders, g_map_le_borders_min_field_size, g_map_le_borderstype, g_map_le_borderwidth, g_map_le_unsprayedmargins, g_map_orchards_borders, g_msg, g_pest, g_weather, 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, last_treatment, RasterMap::MapWidth(), Configurator::ReadSymbols(), Calendar::Reset(), LE::SetALMaSSEleType(), LE::SetArea(), LE::SetCentroid(), LE::SetElementType(), LE::SetOpenness(), LE::SetPoly(), LE::SetSoilType(), LE::SetUnsprayedMarginPolyRef(), MapErrorMsg::SetWarnLevel(), tole_Field, tole_Freshwater, tole_HedgeBank, tole_Hedges, tole_Missing, tole_Orchard, tole_Pond, tole_Wasteland, tov_Undefined, CfgInt::value(), CfgFloat::value(), CfgBool::value(), CfgStr::value(), MapErrorMsg::Warn(), WARN_ALL, WARN_BUG, and WARN_FILE.

677  {
678 
681  // Set up operation flags
682  bool didRenumber = false;
683  bool didCalcCentroids = false;
684  bool didConsolidate = false;
685  bool didCalcOpenness = false;
686  bool didCalcOther = false;
690  // Set up globals
691  g_landscape_p = this;
692  for (int i = 1; i <= 2000; i++) {
693  g_SpeedyDivides[i] = 1 / double(i);
694  }
695  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; // W,SW,S,SE,E,NE,N,NW
696  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
697  for (int i = 0; i < 8; i++) {
698  m_x_add[i] = x_add[i];
699  m_y_add[i] = y_add[i];
700  }
701  //Pinkfeet
703  //Barnacle
705  //Greylag
707  if (cfg_WriteCurve.value()) {
708  m_GooseIntakeRateVSVegetationHeight_GL->WriteDataFile( 10 );
709  m_GooseIntakeRateVSVegetationHeight_BG->WriteDataFile( 10 );
710  m_GooseIntakeRateVSVegetationHeight_PF->WriteDataFile( 10 );
711  }
712 
714 
716  printf("This program uses the Landscape simulator V%s\n", m_versioninfo);
717  }
718  //g_cfg->DumpAllSymbolsAndExit( "allsymbols.cfg" );
719 
720  // Must come first. Used by the configurator below.
721  g_msg = new MapErrorMsg(a_errorfile);
723 
724  //g_cfg->DumpAllSymbolsAndExit( "allsymbols.cfg" );
725 
726  // Configurator instantiation is automatic.
727  g_cfg->ReadSymbols(a_configfile);
728  //g_cfg->DumpAllSymbolsAndExit( "allsymbols.cfg" );
729 
730  // For testing.
731  //g_cfg->DumpPublicSymbols( "publicsymbols.cfg", CFG_PUBLIC );
732  //exit(1);
733 
734  g_date = new Calendar;
736  g_letype = new LE_TypeClass;
738 
740 
741  // Reset treatment counters.
742  for (int i = 0; i < last_treatment; i++) {
743  m_treatment_counts[i] = 0;
744  }
745 
746  m_FarmManager = new FarmManager();
747 
748 
750 
751  //this carries out the optimisation
752  if (cfg_OptimisingFarms.value()){
755  }
756 
757 
758  m_land = new RasterMap(l_map_map_file.value(), this);
759  m_width = m_land->MapWidth();
761  m_width10 = 10 * m_width;
762  m_height10 = 10 * m_height;
763  if (m_width > m_height) m_maxextent = m_width; else m_maxextent = m_height;
764 
765  PolysValidate(false);
766 
767  g_pest = new Pesticide(m_land, this);
768  m_toxShouldSpray = false;
769 
770  // Validate polygons, ie. ensure those reference in the
771  // polygon file also shows up in the map.
772  PolysValidate(false);
774 
775  if (cfg_MaxPondSize.value() > 0) {
776  // This takes any small freshwater and converts it to a pond.
777  for (unsigned int i = 0; i < m_elems.size(); i++) {
778  if (m_elems[i]->GetElementType() == tole_Freshwater) {
779  if (m_elems[i]->GetArea() <= cfg_MaxPondSize.value()) {
780  Pond* pond = new Pond;
781  pond->DoCopy(m_elems[i]);
782  pond->SetALMaSSEleType(g_letype->BackTranslateEleTypes(tole_Pond));
783  pond->SetElementType(tole_Pond);
784  m_elems[i] = dynamic_cast<LE*>(pond);
785  }
786  }
787  }
788  }
789 
790  PolysValidate(true);
791 
798  {
799  // Find big continuous polygons
800  for (unsigned int i = 0; i < m_elems.size(); i++)
801  {
802  if (m_elems[i]->GetElementType() == tole_Missing)
803  {
804  double area = m_elems[i]->GetArea();
805  int areaMinrect = (m_elems[i]->GetMaxX() - m_elems[i]->GetMinX()) * (m_elems[i]->GetMaxY() - m_elems[i]->GetMinY());
806  if ((areaMinrect / area > 4) || (area < 1000))
807  {
808  // Unlikely to be a field, or if so a very narrow odd one. We will assume this is a missing data issue.
809  }
810  else
811  {
812  // Big poly with more than 25% of the included rectangle covered, must be a field of some sort.
813  // create a new wasteland and swap this in to the m_elems, then delete the old missing polygon
814  LE * wl = NewElement(tole_Wasteland);
815  wl->SetPoly(m_elems[i]->GetPoly());
816  wl->SetArea(floor(0.5 + area));
817  wl->SetSoilType(m_elems[i]->GetSoilType());
819  wl->SetCentroid(-1, -1);
820  wl->SetOpenness(0);
821  delete m_elems[i];
822  m_elems[i] = wl;
823  }
824  }
825  }
826  // By here all the big ones should be safely tidied away to wasteland and now we need to deal with the raster map.
828  for (unsigned int i = 0; i < m_elems.size(); i++)
829  {
830  // Now we deal with all the little ones that were not by fields
831  if (m_elems[i]->GetElementType() == tole_Missing)
832  {
833  LE * wl = NewElement(tole_Wasteland);
834  wl->SetPoly(m_elems[i]->GetPoly());
835  wl->SetArea(m_elems[i]->GetArea());
836  wl->SetSoilType(m_elems[i]->GetSoilType());
838  wl->SetCentroid(-1, -1);
839  wl->SetOpenness(0);
840  delete m_elems[i];
841  m_elems[i] = wl;
842  }
843  }
844  PolysValidate(false);
846  PolysValidate(true);
847  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after resolving missing polygons. ", "");
848  didCalcOther = true;
849  }
850 
851  // ChangeMapMapping() also enters a valid starting
852  // coordinate for the border generating farm method below.
854 
858  if ((m_LargestPolyNumUsed != ((int)m_elems.size() - 1)))
859  {
860  PolysRenumber();
861  didRenumber = true;
862  }
863  // do we want to remove small polygons?
865  {
866  cout << "In Landscape::Landscape() Small polygon removal" << endl;
867  int removed = RemoveSmallPolygons();
868  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after removing small polygons and map dump. Polygons removed:", removed);
869  didCalcOther = true;
870  }
871  // Do we want to re-write the current files and consolidate polys?
872  else if (l_map_consolidatepolys.value())
873  {
874  didConsolidate = true;
876  }
877  else if (g_map_le_borderremoval.value())
878  {
879  // Does not use centroids so is safe to use here
880  BorderRemoval();
881  CountMapSquares();
882  ForceArea();
883  g_msg->Warn(WARN_FILE, "Landscape::Landscape() - BorderRemoval "" map dump to follow.", "");
884  didCalcOther = true;
885  }
886 
887 
888  // 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
889  // are two reasons for this - 1) that we did not have them in the original polyref file, 2) that we changed the map
890  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation)
891  {
892  PolysValidate(false);
894  PolysValidate(true);
896  PolysRenumber();
898  didCalcCentroids = true;
899  }
900  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation || didCalcCentroids || l_map_calc_openness.value())
901  {
903  else CalculateOpenness(false);
904  didCalcOpenness = true;
905  }
906  if (didCalcCentroids || didConsolidate || didCalcOpenness || didCalcOther || m_NeedCentroidCalculation || didRenumber || !m_FarmManager->GetIsRenumbered())
907  {
908  // We need to dump the map and polyrefs
912  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
913  exit(0);
914  }
915 
916  // Below here we have the more complicated map manipulations. These will need recalculation of centroids and openness after they are run.
917  // However, we really do not want to get here with invalid centroids, hence forced dump and exit for manipulations up to this point.
918 
919  didCalcOther = false;
920  // Add artificial hedgebanks to the hedges in the landscape,
921  // if requested.
922  if (l_map_art_hedgebanks.value()) {
923  hb_Add();
924  didCalcOther = true;
925  }
926  else if (g_map_le_borders.value())
927  {
928  cout << "Generating LE Borders around fields" << endl;
929  cout << "Border chance = " << g_map_le_border_chance.value() << endl;
930  cout << "Border width = " << g_map_le_borderwidth.value() << endl;
931  // Generate border around each *farm* landscape element.
932  cout << "Setting MaxMin Extents" << endl;
934  cout << "Adding Borders" << endl;
935  unsigned sz = (unsigned)m_elems.size();
936  for (unsigned i = 0; i < sz; i++)
937  {
938  if (m_elems[i]->GetBorder() != NULL)
939  {
940  // Border around this element, so must be a farm field.
941  // If the field is too small then ignore it
942  if (m_elems[i]->GetArea() > g_map_le_borders_min_field_size.value())
943  {
944  TTypesOfLandscapeElement t = g_letype->TranslateEleTypes(g_map_le_borderstype.value());
945  BorderAdd(m_elems[i], t);
946  }
947  }
948  }
949  didCalcOther = true;
950  }
951  else // Some special code to 'soften' the edges of orchards
953  {
954  // Generate border around each *farm* landscape element.
955  for (unsigned int i = 0; i < m_elems.size(); i++) {
956  if (m_elems[i]->GetElementType() == tole_Orchard)
957  {
958  TTypesOfLandscapeElement t = g_letype->TranslateEleTypes(g_map_le_borderstype.value());
959  BorderAdd(m_elems[i], t);
960  }
961  }
962  didCalcOther = true;
963  }
964  else
965  // Unsprayed Margin Code....
967  {
968  CountMapSquares();
969  ForceArea();
970 
971  // Generate border around each *farm* landscape element.
972  for (unsigned int i = 0; i < m_elems.size(); i++)
973  {
974  if (m_elems[i]->GetUnsprayedMarginPolyRef() != -1)
975  {
976  // But not if the field is too small to have them (<1Ha)
977  if (m_elems[i]->GetArea() > 10000)
978  {
979  // Border around this element, so must be a farm field.
981  }
982  else m_elems[i]->SetUnsprayedMarginPolyRef(-1);
983  }
984  }
985  didCalcOther = true;
986  }
987  else if (cfg_AddBeetleBanks.value())
988  {
989  cout << "Adding beetle banks now" << endl;
991  didCalcOther = true;
992  }
993 
995  {
997  }
998 
999  if (l_map_dump_enable.value() || didCalcOther)
1000  {
1001  CountMapSquares();
1002  ForceArea();
1003  PolysValidate(false);
1005  PolysValidate(true);
1006  ChangeMapMapping();
1007  PolysRenumber();
1011  cout << "Dumping map" << endl;
1013  cout << "Dumping polygon refs file" << endl;
1015  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
1016  exit(0);
1017  }
1018 
1019  /*'''''''''''''''''' CIPE LANDSCAPE MAKER CODE HERE //'''''''''''''''''''''
1020  if ( l_map_CIPEmaker_enable.value() ) {
1021  CIPELandscapeMaker();
1022  if ( l_map_dump_exit.value() ) {
1023  g_msg->Warn( WARN_FILE, "Landscape::Landscape(): ""Normal exit after map dump.", "" );
1024  exit( 0 );
1025  }
1026  }
1027  //'''''''''''''''''' CIPE LANDSCAPE MAKER CODE ABOVE //'''''''''''''''''''''
1028  */
1029  // Set the type of hedgebanks.
1030  int l_subtype = cfg_HedgeSubtypeMinimum.value();
1031  for (unsigned int i = 0; i < m_elems.size(); i++) {
1032  if (m_elems[i]->GetElementType() == tole_HedgeBank) {
1033  m_elems[i]->SetSubType(l_subtype);
1034  if (++l_subtype >= cfg_HedgeSubtypeMaximum.value())
1035  l_subtype = cfg_HedgeSubtypeMinimum.value();
1036  }
1037  }
1038 
1039  // And another to set the type of hedges
1040  // ***CJT*** 2003-12-02
1041  l_subtype = 0;
1042  for (unsigned int i = 0; i < m_elems.size(); i++) {
1043  if (m_elems[i]->GetElementType() == tole_Hedges) {
1044  m_elems[i]->SetSubType(l_subtype);
1045  if (++l_subtype >= 3)
1046  l_subtype = 0;
1047  }
1048  }
1049  // Count up the ponds and store them now we are finished with polygon handling.
1050  CreatePondList();
1051 
1052  cout << "Initiating farm management" << endl;
1054  g_date->Reset();
1055 
1056  /*
1057  if ( g_farm_test_crop.value() ) {
1058  TestCropManagement();
1059  exit( 0 );
1060  }
1061  */
1062 
1063  // Set up treatment flags
1064  // Reset internal state for the LE loop generator.
1065  // Compulsory!
1066  SupplyLEReset();
1067  // Get number of *all* landscape elements.
1068  int l_count = SupplyLECount();
1069 
1070  // Now loop through then.
1071  for (int i = 0; i < l_count; i++) {
1072  // Fetch next LE by its polygon reference number. Alternative
1073  // loop mechanism: This will return -1 at end-of-loop.
1074  int a_poly = SupplyLENext();
1075 
1076  // Skip uninteresting polygons by type, ownership,
1077  // phase of the moon, whatever.
1078  // if ( these_are_not_the_droids_we_are_looking_for( a_poly )) {
1079  if (SupplyElementType(a_poly) != tole_Field)
1080  continue;
1081 
1082  // Example: Set x% of them to ignore insecticide of all types.
1083  if (random(100) < l_map_no_pesticide_fields.value()) {
1084  // Get current signal mask for polygon.
1085  LE_Signal l_signal = SupplyLESignal(a_poly);
1086  // Logical OR in/AND out the signals you are interested in.
1087  // The current signals are at the top of elements.h
1088  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE | LE_SIG_NO_FUNGICIDE | LE_SIG_NO_GROWTH_REG;
1089  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE;
1090  // Write the mask back out to the polygon.
1091  SetLESignal(a_poly, l_signal);
1092  }
1093  }
1094 
1095  l_vegtype_areas = (double *)malloc(sizeof(double) * (tov_Undefined + 1));
1096 
1097  if (l_vegtype_areas == NULL) {
1098  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): Out of memory!", "");
1099  exit(1);
1100  }
1101  FILE * outf;
1102  if (cfg_dumpvegjan.value()) {
1103  outf = fopen(cfg_dumpvegjanfile.value(), "w");
1104  if (!outf) {
1105  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjanfile.value());
1106  exit(1);
1107  }
1108  else
1109  fclose(outf);
1110  }
1111 
1112  if (cfg_dumpvegjune.value()) {
1113  outf = fopen(cfg_dumpvegjunefile.value(), "w");
1114  if (!outf) {
1115  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjunefile.value());
1116  exit(1);
1117  }
1118  else
1119  fclose(outf);
1120  }
1121 
1122  // Dump veg information if necessary
1123  if (l_map_dump_veg_enable.value()) {
1124  FILE * f;
1125  f = fopen("VegDump.txt", "w");
1126  if (!f) {
1127  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): VegDump.txt could not be created", "");
1128  exit(1);
1129  }
1130  fprintf(f, "Year\tDay\tHeight\tBiomass\tGrazed\tDensity\tCover\tWeedBiomass\ttovNum\tInsectBiomass\tLATotal\tLAGreen\tDigestability\tGreenBiomass\tDeadBiomass\tGooseGrazing\tSpilledGrain\nn");
1131  fclose(f);
1132  }
1134  FILE * f;
1135  f = fopen("EventDump.txt", "w");
1136  if (!f) {
1137  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): EventDump.txt could not be created", "");
1138  exit(1);
1139  }
1140  fclose(f);
1141  }
1142 
1145  }
1146 
1147  if (cfg_DumpFarmAreas.value()){
1149  }
1150 
1151  // If we are testing a pesticide then set the enum attribute
1153 
1156  {
1157  m_RodenticideManager = new RodenticideManager("BaitLocations_input.txt", this);
1158  m_RodenticidePreds = new RodenticidePredators_Population_Manager(this);
1159  }
1160 
1161  // Run a year to remove any start up effects
1162  cout << "Running intial start-up year" << endl;
1163  for (unsigned int i = 0; i < 365; i++) Tick();
1164  //switch the rotation after running the hidden year (only for optimising farms), AM, 030713
1166  // Write ASCII file:
1167  if (l_map_write_ascii.value()) {
1168  int x = l_map_ascii_utm_x.value();
1169  int y = l_map_ascii_utm_y.value();
1170  GISASCII_Output("AsciiLandscape.txt", x, y);
1171  }
1172 }
CfgBool cfg_OptimisingFarms
If set to true, the farmer decision making model is active.
static CfgBool l_map_dump_event_enable("MAP_DUMP_EVENT_ENABLE", CFG_CUSTOM, false)
void SetElementType(int a_type)
Definition: elements.h:114
static CfgStr l_map_dump_gfx_file("MAP_DUMP_GFX_FILE", CFG_CUSTOM,"dump.ppm")
int m_height10
Definition: landscape.h:130
CfgFloat cfg_G6F
int m_width
Definition: landscape.h:127
virtual void SetCentroid(int x, int y)
Definition: elements.h:139
CfgBool cfg_dumpvegjune("G_VEGAREASJUNE_ON", CFG_CUSTOM, false)
CfgStr cfg_dumpvegjanfile("G_VEGAREASJAN_FILENAME", CFG_CUSTOM,"DUMPVEG_JAN.TXT")
void SetLESignal(int a_polyref, LE_Signal a_signal)
Definition: Landscape.cpp:3334
void ConsolidatePolys(void)
Definition: Landscape.cpp:1175
class Pesticide * g_pest
Definition: pesticide.cpp:70
int MapWidth(void)
Definition: rastermap.h:57
unsigned int LE_Signal
Definition: elements.h:33
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:1904
double g_SpeedyDivides[2001]
A generally useful array of fast divide calculators by multiplication.
Definition: Landscape.cpp:230
static CfgInt cfg_MaxPondSize("MAP_MAXPONDSIZE", CFG_CUSTOM, 5000)
If freshwater area is below this it is designated a pond.
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
class CropData * g_crops
Definition: plants.cpp:39
static CfgBool l_map_art_hedgebanks("MAP_ART_HEDGEBANKS", CFG_CUSTOM, false)
CfgInt g_map_le_borderwidth("MAP_LE_BORDER_WIDTH", CFG_CUSTOM, 1)
int MapHeight(void)
Definition: rastermap.h:58
void DumpFarmrefs()
dumps the farmrefs file to a standard named file
Definition: farm.cpp:2548
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.
static CfgBool l_map_dump_veg_enable("MAP_DUMP_VEG_ENABLE", CFG_CUSTOM, true)
CfgFloat cfg_G6C
void PolysRemoveInvalid(void)
Definition: Landscape.cpp:1584
static CfgBool l_map_dump_enable("MAP_DUMP_ENABLE", CFG_CUSTOM, false)
void Save_diff_farm_types_areas()
Calculates and saves total areas of all optimising farms and specific farm types. ...
Definition: farm.cpp:2927
CfgFloat cfg_B6D
void DumpMap(const char *a_filename)
Definition: Landscape.cpp:1217
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1031
void SetUnsprayedMarginPolyRef(int a_unsprayedmargin)
Definition: elements.h:316
void PolysDump(const char *a_filename)
Definition: Landscape.cpp:1612
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
CfgStr cfg_dumpvegjunefile("G_VEGAREASJUNE_FILENAME", CFG_CUSTOM,"DUMPVEG_JUNE.TXT")
static CfgStr l_map_cropcurves_file("MAP_CROPCURVES_FILE", CFG_CUSTOM,"curves.pre")
CfgFloat cfg_P1C
double value(void)
Definition: configurator.h:107
void DumpFarmAreas()
Definition: farm.cpp:1536
Definition: elements.h:81
CfgInt cfg_HedgeSubtypeMinimum("HEDGE_SUBTYPEMINIMUM", CFG_CUSTOM, 0)
int SupplyLECount(void)
Definition: Landscape.cpp:3326
bool ReadSymbols(const char *a_cfgfile)
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
Definition: landscape.h:150
int m_height
Definition: landscape.h:128
void SetPolyMaxMinExtents(void)
Definition: Landscape.cpp:1434
void AddBeetleBanks(TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2504
void Tick(void)
Definition: Landscape.cpp:1294
void GISASCII_Output(string outpfile, int UTMX, int UTMY)
Write ASCII file of the ALMaSS map.
Definition: Landscape.cpp:3271
CfgFloat cfg_P1G
CfgBool cfg_OptimiseBedriftsmodelCrops
If set to true, the original farm optimisation model&#39;s crop set is used in the farmer decision making...
void Reset(void)
Definition: calendar.cpp:40
CfgBool cfg_P1E
CfgInt g_map_le_borders_min_field_size("MAP_LE_BORDERS_MIN_FIELD_SIZE", CFG_CUSTOM, 10000)
void InitFarms()
Calls OptimisingFarm::Init for all optimising farms.
Definition: farm.cpp:2565
CfgStr cfg_P1H
int m_maxextent
Definition: landscape.h:131
class Weather * g_weather
Definition: weather.cpp:41
void SetSoilType(int a_st)
Definition: elements.h:281
void PolysRenumber(void)
Definition: Landscape.cpp:1871
void ReadPolys2(const char *a_polyfile)
reads in polygon information. Version 2 including centroid and openness information ...
Definition: Landscape.cpp:1701
void SetPoly(int a_poly)
Definition: elements.h:220
bool m_DoMissingPolygonsManipulations
Definition: landscape.h:138
const char * value(void)
Definition: configurator.h:139
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
The Farm Manager class.
Definition: farm.h:1563
static CfgInt l_map_no_pesticide_fields("MAP_NO_PESTICIDE_FIELDS", CFG_CUSTOM, 0)
CfgStr l_map_dump_map_file("MAP_DUMP_MAP_FILE", CFG_CUSTOM,"dump.lsb")
static CfgBool l_map_dump_gfx_enable("MAP_DUMP_GFX_ENABLE", CFG_CUSTOM, false)
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void FindNeighbours()
Finds all OptimisingFarms&#39; neighbours and saves them in the farm&#39;s OptimisingFarm::m_neighbours vecto...
Definition: farm.cpp:4180
int m_treatment_counts[last_treatment]
Definition: landscape.h:171
bool value(void)
Definition: configurator.h:123
void SetWarnLevel(MapErrorState a_level)
Definition: maperrormsg.cpp:45
void CountMapSquares(void)
Definition: Landscape.cpp:1854
static CfgStr l_map_weather_file("MAP_WEATHER_FILE", CFG_CUSTOM,"weather.pre")
static CfgBool cfg_AddBeetleBanks("BBANKS_ADD", CFG_CUSTOM, false)
void ForceArea(void)
Definition: Landscape.cpp:1886
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:2375
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
Definition: landscape.h:149
static CfgBool l_map_removesmallpolygons("MAP_REMOVESMALLPOLYGONS", CFG_CUSTOM, false)
CfgFloat cfg_G6B
void Switch_rotation()
Switches OptimisingFarms Farm::m_rotation to the list of all possible rotational crops.
Definition: farm.cpp:4465
void BorderAdd(LE *a_field, TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:2129
class Configurator * g_cfg
CfgStr cfg_B6H
CfgFloat cfg_B6G
void ChangeMapMapping(void)
Definition: Landscape.cpp:1944
void UnsprayedMarginAdd(LE *a_field)
Definition: Landscape.cpp:2398
RasterMap * m_land
The big map.
Definition: landscape.h:122
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 SetArea(double a_area)
Definition: elements.h:223
CfgBool cfg_G6E
void SetOpenness(int a_openness)
Records the openness statistic for this polygon.
Definition: elements.h:368
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
class Calendar * g_date
Definition: calendar.cpp:38
static CfgStr l_map_map_file("MAP_MAP_FILE", CFG_CUSTOM,"map.lsb")
CfgFloat cfg_P1F
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1082
LE_Signal SupplyLESignal(int a_polyref)
Definition: Landscape.cpp:3330
CfgBool cfg_B6E
CfgBool g_map_orchards_borders("MAP_ORCHARDS_BORDERS", CFG_CUSTOM, false)
CfgBool cfg_DumpFarmAreas
If set to true, an output file with farm areas is produced.
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:356
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
CfgInt g_map_le_borderstype("MAP_LE_BORDERSTYPE", CFG_CUSTOM, 160)
CfgInt cfg_pesticidetesttype("PESTICIDETESTYPE", CFG_CUSTOM,-1)
CfgInt cfg_HedgeSubtypeMaximum("HEDGE_SUBTYPEMAXIMUM", CFG_CUSTOM, 3)
static CfgInt cfg_BeetleBankType("BBANK_TYPE", CFG_CUSTOM,(int) tole_BeetleBank)
CfgFloat cfg_P1A
void SupplyLEReset(void)
Definition: Landscape.cpp:3315
CfgInt g_map_le_border_chance("MAP_LE_BORDER_CHANCE", CFG_CUSTOM, 25)
int value(void)
Definition: configurator.h:92
CfgBool cfg_dumpvegjan("G_VEGAREASJAN_ON", CFG_CUSTOM, false)
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
static CfgBool l_map_print_version_info("MAP_PRINT_VERSION_INFO", CFG_CUSTOM, true)
CfgFloat cfg_G6D
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
CfgFloat cfg_B6C
double * l_vegtype_areas
Definition: landscape.h:141
TTypesOfLandscapeElement
void hb_Add(void)
Definition: hedgebanks.cpp:56
void PolysValidate(bool a_exit_on_invalid)
Definition: Landscape.cpp:1557
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:2821
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.
CfgStr l_map_dump_poly_file("MAP_DUMP_POLY_FILE", CFG_CUSTOM,"dumppolyrefs.txt")
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:2053
bool m_NeedOpennessCalculation
a flag to ensure openness calculation on object construction
Definition: landscape.h:136
CfgFloat cfg_B6F
bool GetIsRenumbered()
Returns the flag for renumbering.
Definition: farm.h:1743
CfgBool g_map_le_borders("MAP_LE_BORDERS", CFG_CUSTOM, false)
CfgFloat cfg_G6G
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
void DumpMapGraphics(const char *a_filename)
Definition: Landscape.cpp:3363
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
CfgBool g_map_le_unsprayedmargins("MAP_LE_UNSPRAYEDMARGINS", CFG_CUSTOM, false)
int RemoveSmallPolygons(void)
Removes small polygons from the map.
Definition: Landscape.cpp:1998
CfgFloat cfg_B6A
CfgBool g_map_le_borderremoval("MAP_LE_BORDERREMOVAL", CFG_CUSTOM, false)
TTypesOfPesticide
Definition: landscape.h:64
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3455
CfgBool cfg_WriteCurve
int SupplyLENext(void)
Definition: Landscape.cpp:3319
void InitiateManagement(void)
Definition: farm.cpp:2284
int m_LargestPolyNumUsed
Definition: landscape.h:172
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.
static CfgBool l_map_calc_openness("MAP_CALC_OPENNESS", CFG_CUSTOM, false)
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

Definition at line 2504 of file Landscape.cpp.

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

2504  {
2512  int BBs=0;
2513  int tx1 = cfg_BeetleBankMinX.value();
2514  int tx2 = cfg_BeetleBankMaxX.value();
2515  int ty1 = cfg_BeetleBankMinY.value();
2516  int ty2 = cfg_BeetleBankMaxY.value();
2517  bool doit = false;
2518  unsigned sz=(unsigned) m_elems.size();
2519  for (unsigned i=0; i<sz; i++)
2520  {
2521  if (m_elems[ i ]->GetElementType() == tole_Field)
2522  {
2523  doit = false;
2524  int cx = m_elems[ i ]->GetCentroidX();
2525  int cy = m_elems[ i ]->GetCentroidY();
2526  if (!cfg_BeetleBankInvert.value())
2527  {
2528  if ((cx >= tx1) && (cy >= ty1) && (cx <= tx2) && (cy <= ty2))
2529  {
2530  doit = true;
2531  }
2532  }
2533  else if ((cx < tx1) || (cy < ty1) || (cx > tx2) || (cy > ty2))
2534  {
2535  doit = true;
2536  }
2537  if (doit)
2538  {
2539  if (random(100)<cfg_BeetleBankChance.value())
2540  {
2541  if (BeetleBankPossible( m_elems[ i ], a_tole) ) BBs++;
2542  }
2543  }
2544  }
2545  }
2546  char str[25];
2547  sprintf(str,"%d",BBs);
2548  g_msg->Warn( WARN_MSG, "Landscape::AddBeetleBanks(): BeetleBanks successfully added:", str );
2549 }
CfgInt cfg_BeetleBankMaxX("BBANK_MAXX", CFG_CUSTOM, 100000)
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
CfgBool cfg_BeetleBankInvert("BBANK_INVERT", CFG_CUSTOM, false)
CfgInt cfg_BeetleBankMaxY("BBANK_MAXY", CFG_CUSTOM, 100000)
CfgInt cfg_BeetleBankMinX("BBANK_MINX", CFG_CUSTOM, 0)
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
bool value(void)
Definition: configurator.h:123
int value(void)
Definition: configurator.h:92
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
CfgInt cfg_BeetleBankMinY("BBANK_MINY", CFG_CUSTOM, 0)
bool BeetleBankPossible(LE *a_field, TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2553
static CfgInt cfg_BeetleBankChance("BBANK_CHANCE", CFG_CUSTOM, 100)
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.

Definition at line 2719 of file Landscape.cpp.

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

Definition at line 2679 of file Landscape.cpp.

2679  {
2684  int ap1 = a_polyindex;
2685  while (ap1 == a_polyindex)
2686  {
2687  a_cor->m_x += m_x_add[a_axis];
2688  a_cor->m_y += m_y_add[a_axis];
2689  if (a_cor->m_x >= m_width - 1) { a_cor->m_x = m_width - 1; return; }
2690  if (a_cor->m_y >= m_height - 1) { a_cor->m_y = m_height - 1; return; }
2691  if (a_cor->m_x <= 0) { a_cor->m_x = 0; return; }
2692  if (a_cor->m_y <= 0) { a_cor->m_y = 0; return; }
2693  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)
2694  }
2695 }
int m_width
Definition: landscape.h:127
int Get(int a_x, int a_y)
Definition: rastermap.h:86
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::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.

Definition at line 2698 of file Landscape.cpp.

2698  {
2703  int ap1 = a_polyindex;
2704  int count = 0;
2705  while (ap1 == a_polyindex && count<a_limit)
2706  {
2707  a_cor->m_x += m_x_add[a_axis];
2708  a_cor->m_y += m_y_add[a_axis];
2709  if (a_cor->m_x >= m_width - 1) { a_cor->m_x = m_width - 1; return; }
2710  if (a_cor->m_y >= m_height - 1) { a_cor->m_y = m_height - 1; return; }
2711  if (a_cor->m_x <= 0) { a_cor->m_x = 0; return; }
2712  if (a_cor->m_y <= 0) { a_cor->m_y = 0; return; }
2713  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)
2714  count++;
2715  }
2716 }
int m_width
Definition: landscape.h:127
int Get(int a_x, int a_y)
Definition: rastermap.h:86
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 Landscape::BackTranslateEleTypes ( TTypesOfLandscapeElement  EleReference)
inline

Definition at line 1588 of file landscape.h.

References LE_TypeClass::BackTranslateEleTypes(), and g_letype.

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

Definition at line 1595 of file landscape.h.

References LE_TypeClass::BackTranslateVegTypes(), and g_letype.

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

Definition at line 2752 of file Landscape.cpp.

References LE::AddArea(), LE_TypeClass::BackTranslateEleTypes(), cfg_BeetleBankWidth, g_letype, LE::SetALMaSSEleType(), LE::SetArea(), LE::SetMapValid(), LE::SetPoly(), LE::SetValidXY(), LE::SetVegPatchy(), start, tole_BeetleBank, tole_MownGrass, tole_PermanentSetaside, and CfgInt::value().

2752  {
2753  // Need to get a new number
2755  // Make the new landscape element
2756  LE * BeetleBank;
2757  switch (a_tole)
2758  {
2759  case tole_MownGrass:
2760  BeetleBank = NewElement( tole_MownGrass );
2762  break;
2764  BeetleBank = NewElement( tole_PermanentSetaside );
2766  break;
2767  case tole_BeetleBank:
2768  default:
2769  BeetleBank = NewElement( tole_BeetleBank );
2771  }
2772  BeetleBank->SetVegPatchy(true);
2773  m_polymapping[ m_LargestPolyNumUsed ] = (int) m_elems.size();
2774  m_elems.resize( m_elems.size() + 1 );
2775  m_elems[ m_elems.size() - 1 ] = BeetleBank;
2776  BeetleBank->SetPoly( m_LargestPolyNumUsed );
2777  // write lengthx12m to the map at alignment angle
2778  int area=0;
2779  int angle2=0;
2780  int width=cfg_BeetleBankWidth.value();
2781  if (a_angle==0) angle2=2;
2782  int start=(int)(a_length*0.1);
2783  for (int i=start; i<a_length; i++) {
2784  for (int w=0-width; w<width; w++) {
2785  int tx=w*m_x_add[angle2];
2786  int ty=w*m_y_add[angle2];
2787  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 );
2788  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 );
2789  area+=2;
2790  a_field->AddArea( -2.0 );
2791 
2792  }
2793  }
2794  BeetleBank->SetArea( double(area) );
2795  BeetleBank->SetValidXY( a_x+start*m_x_add[a_angle], a_y+start*m_y_add[a_angle] );
2796  BeetleBank->SetMapValid(true);
2797 
2798 }
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: elements.cpp:3042
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 Put(int a_x, int a_y, int a_elem)
Definition: rastermap.h:62
virtual void SetVegPatchy(bool)
Definition: elements.h:148
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:310
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
int value(void)
Definition: configurator.h:92
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
void SetValidXY(int a_valid_x, int a_valid_y)
Definition: elements.h:319
static CfgInt cfg_BeetleBankWidth("BBANK_WIDTH", CFG_CUSTOM, 4)
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3455
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

Definition at line 2553 of file Landscape.cpp.

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

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

Definition at line 2129 of file Landscape.cpp.

References g_map_le_borderwidth, g_msg, LE::GetValidX(), LE::GetValidY(), LE::SetArea(), LE::SetBorder(), LE::SetPoly(), CfgInt::value(), MapErrorMsg::Warn(), and WARN_BUG.

2129  {
2130  int x = a_field->GetValidX();
2131  int y = a_field->GetValidY();
2132  if ( ( x == -1 ) || ( y == -1 ) ) {
2133  g_msg->Warn( WARN_BUG, "Landscape::BorderAdd(): Uninitialized border coordinate!", "" );
2134  exit( 1 );
2135  }
2136  LE * border = NewElement(a_type);
2137  a_field->SetBorder( border );
2138  m_polymapping[ hb_first_free_poly_num ] = (int) m_elems.size();
2139  m_elems.resize( m_elems.size() + 1 );
2140  m_elems[ m_elems.size() - 1 ] = border;
2141  border->SetPoly( hb_first_free_poly_num++ );
2142  border->SetArea( 0.0 );
2144 }
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:325
CfgInt g_map_le_borderwidth("MAP_LE_BORDER_WIDTH", CFG_CUSTOM, 1)
int GetValidX(void)
Definition: elements.h:324
Definition: elements.h:81
void SetBorder(LE *a_border)
Definition: elements.h:314
void SetPoly(int a_poly)
Definition: elements.h:220
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
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:2147
int value(void)
Definition: configurator.h:92
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3455
bool Landscape::BorderNeed ( TTypesOfLandscapeElement  a_letype)
protected

Definition at line 4147 of file Landscape.cpp.

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

4147  {
4148  static char error_num[20];
4149  bool AddBorder = false;
4150  switch (a_letype) {
4151  // No border is needed toward these neighbouring element types.
4152  case tole_Hedges:
4153  case tole_HedgeBank:
4154  case tole_BeetleBank:
4155  case tole_RoadsideVerge:
4156  case tole_Marsh:
4157  case tole_RiversidePlants:
4159  case tole_OrchardBand:
4160  case tole_MownGrass:
4161  break;
4162 
4163  case tole_IndividualTree:
4164  case tole_PlantNursery:
4165  case tole_Vildtager:
4166  case tole_WindTurbine:
4167  case tole_WoodyEnergyCrop:
4168  case tole_WoodlandMargin:
4169  case tole_Pylon:
4170  case tole_NaturalGrassDry:
4171  case tole_Railway:
4172  case tole_FieldBoundary:
4173  case tole_Scrub:
4174  case tole_Field:
4176  case tole_PermPasture:
4179  case tole_PitDisused:
4180  case tole_RiversideTrees:
4181  case tole_DeciduousForest:
4182  case tole_MixedForest:
4183  case tole_YoungForest:
4184  case tole_ConiferousForest:
4185  case tole_StoneWall:
4186  case tole_Garden:
4187  case tole_Track:
4188  case tole_SmallRoad:
4189  case tole_LargeRoad:
4190  case tole_Building:
4191  case tole_ActivePit:
4192  case tole_Pond:
4193  case tole_FishFarm:
4194  case tole_Freshwater:
4195  case tole_River:
4196  case tole_Saltwater:
4197  case tole_Coast:
4198  case tole_BareRock:
4199  case tole_Heath:
4200  case tole_Orchard:
4201  case tole_AmenityGrass:
4202  case tole_Parkland:
4203  case tole_UrbanNoVeg:
4204  case tole_UrbanPark:
4206  case tole_SandDune:
4207  case tole_Copse:
4208  case tole_NaturalGrassWet:
4209  case tole_RoadsideSlope:
4210  case tole_MetalledPath:
4211  case tole_Carpark:
4212  case tole_Churchyard:
4213  case tole_Saltmarsh:
4214  case tole_Stream:
4215  case tole_HeritageSite:
4216  AddBorder = true;
4217  break;
4218 
4219  default:
4220  sprintf(error_num, "%d", a_letype);
4221  g_msg->Warn(WARN_BUG, "Landscape::BorderNeed(): Unknown element type:", error_num);
4222  exit(1);
4223  }
4224  return AddBorder;
4225 }
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
void Landscape::BorderRemoval ( void  )
protected

Definition at line 2053 of file Landscape.cpp.

References tole_Field, tole_FieldBoundary, tole_HedgeBank, and tole_Hedges.

2053  {
2054  // This does not need to be efficient, just do the job
2055  for (int x=1; x<(m_width-1); x++)
2056  for (int y=1; y<(m_height-1); y++)
2057  {
2059  if ((tole==tole_FieldBoundary) || (tole==tole_HedgeBank) || (tole==tole_Hedges))
2060  {
2061  if ( SupplyElementType(x-1,y-1) == tole_Field)
2062  {
2063  // Set the x,y location to be this field
2064  int fieldindex = SupplyPolyRefIndex(x-1,y-1);
2065  m_land->Put( x, y, fieldindex );
2066 
2067  }
2068  else
2069  if ( SupplyElementType(x-1,y) == tole_Field)
2070  {
2071  // Set the x,y location to be this field
2072  int fieldindex = SupplyPolyRefIndex(x-1,y);
2073  m_land->Put( x, y, fieldindex );
2074 
2075  }
2076  else
2077  if ( SupplyElementType(x-1,y+1) == tole_Field)
2078  {
2079  // Set the x,y location to be this field
2080  int fieldindex = SupplyPolyRefIndex(x-1,y+1);
2081  m_land->Put( x, y, fieldindex );
2082 
2083  }
2084  else
2085  if ( SupplyElementType(x,y-1) == tole_Field)
2086  {
2087  // Set the x,y location to be this field
2088  int fieldindex = SupplyPolyRefIndex(x,y-1);
2089  m_land->Put( x, y, fieldindex );
2090 
2091  }
2092  else
2093  if ( SupplyElementType(x,y+1) == tole_Field)
2094  {
2095  // Set the x,y location to be this field
2096  int fieldindex = SupplyPolyRefIndex(x,y+1);
2097  m_land->Put( x, y, fieldindex );
2098 
2099  }
2100  else
2101  if ( SupplyElementType(x+1,y-1) == tole_Field)
2102  {
2103  // Set the x,y location to be this field
2104  int fieldindex = SupplyPolyRefIndex(x+1,y-1);
2105  m_land->Put( x, y, fieldindex );
2106 
2107  }
2108  else
2109  if ( SupplyElementType(x+1,y) == tole_Field)
2110  {
2111  // Set the x,y location to be this field
2112  int fieldindex = SupplyPolyRefIndex(x+1,y);
2113  m_land->Put( x, y, fieldindex );
2114 
2115  }
2116  else
2117  if ( SupplyElementType(x+1,y+1) == tole_Field)
2118  {
2119  // Set the x,y location to be this field
2120  int fieldindex = SupplyPolyRefIndex(x+1,y+1);
2121  m_land->Put( x, y, fieldindex );
2122 
2123  }
2124  }
2125  }
2126 }
int m_width
Definition: landscape.h:127
void Put(int a_x, int a_y, int a_elem)
Definition: rastermap.h:62
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1031
int m_height
Definition: landscape.h:128
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfLandscapeElement
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1419
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.

Definition at line 2147 of file Landscape.cpp.

References LE::AddArea(), g_msg, LE::GetArea(), LE::GetBorder(), LE::GetCentroidX(), LE::GetCentroidY(), LE::GetPoly(), l_map_exit_on_zero_area, LE::SetMapValid(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_FILE.

2148 {
2152  LE * border = a_field->GetBorder(); // border is the a border object
2153  int fieldpoly = a_field->GetPoly(); // fieldpoly is the polygon number
2154  int borderpoly = border->GetPoly(); // borderpoly is the polygon number
2155  int borderindex = m_polymapping[ borderpoly ]; // borderindex is the elems index for the border
2156  int fieldindex = m_polymapping[ fieldpoly ]; // fieldindex is the elems index
2157  int test = m_land->Get(a_field->GetCentroidX(), a_field->GetCentroidY());
2158  if (test != fieldindex)
2159  {
2160  g_msg->Warn("Landscape::BorderScan - Border Scan centroid does not return correct polygon index. Index :", fieldindex);
2161  g_msg->Warn(" Returned ", test);
2162  exit(0);
2163  }
2164  int notforever = 50000;
2165  vector<APoint> listoflocs;
2170  for (int wid = 0; wid < a_width; wid++)
2171  {
2172  notforever = 50000;
2173  // These two will be modified through pointer operations in BorderStep().
2174  APoint coord(a_field->GetCentroidX(), a_field->GetCentroidY());
2175  // Find the first edge cell
2176  AxisLoop(fieldindex, &coord, random(8));
2177  while (--notforever > 0)
2178  {
2179  // Check if this position should be made into a border.
2180  if (BorderTest(fieldindex, -99, coord.m_x, coord.m_y))
2181  {
2182  // Add this pixel to the border element in the big map, but using a code for later replacement.
2183  m_land->Put(coord.m_x, coord.m_y, -99); // this puts the elems index into our map in memory
2184  listoflocs.push_back(coord);
2185  a_field->AddArea(-1.0);
2186  if (l_map_exit_on_zero_area.value() && (a_field->GetArea()<1))
2187  {
2188  char polynum[20];
2189  sprintf(polynum, "%d", a_field->GetPoly()); g_msg->Warn(WARN_FILE, "Landscape::BorderScan(): Polygon reached zero area " "when adding border. Poly num: ", polynum);
2190  exit(1);
2191  }
2192  border->AddArea(1.0);
2193  border->SetMapValid(true);
2194  }
2195  // Step to next coordinate. Quit when done.
2196  if (!BorderStep(fieldindex, -99, &coord))
2197  {
2198  break;
2199  }
2200  }
2201  for (std::vector<APoint>::iterator it = listoflocs.begin(); it != listoflocs.end(); ++it)
2202  {
2203  m_land->Put((*it).m_x, (*it).m_y, borderindex);
2204  }
2205  listoflocs.clear();
2206  }
2207 }
LE * GetBorder(void)
Definition: elements.h:311
bool BorderStep(int a_fieldpoly, int a_borderpoly, int *a_x, int *a_y)
Definition: Landscape.cpp:2260
static CfgBool l_map_exit_on_zero_area("MAP_EXIT_ON_ZERO_AREA", CFG_CUSTOM, true)
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: elements.h:189
virtual int GetCentroidY()
Definition: elements.h:138
void Put(int a_x, int a_y, int a_elem)
Definition: rastermap.h:62
Definition: elements.h:81
int Get(int a_x, int a_y)
Definition: rastermap.h:86
void AddArea(double a_area_diff)
Definition: elements.h:310
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
bool value(void)
Definition: configurator.h:123
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:2233
void SetMapValid(bool a_valid)
Definition: elements.h:221
void AxisLoop(int a_poly, int *a_x, int *a_y, int a_axis)
Definition: Landscape.cpp:2719
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
double GetArea(void)
Definition: elements.h:196
virtual int GetCentroidX()
Definition: elements.h:137
bool Landscape::BorderStep ( int  a_fieldpoly,
int  a_borderpoly,
int *  a_x,
int *  a_y 
)
protected

Definition at line 2260 of file Landscape.cpp.

2260  {
2261  int index;
2262  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2263  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2264  int width = m_land->MapWidth();
2265  int height = m_land->MapHeight();
2266  int i = 7, counter = 8;
2267  bool running = true;
2268  // First scan for another pixel that belongs to this field.
2269  while (running)
2270  {
2271  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))
2272  {
2273  index = m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]);
2274  if (index == a_fieldindex)
2275  {
2276  // Found the first field pixel while scanning around always
2277  // in the same direction.
2278  running = false;
2279  }
2280  }
2281  if (--i < 0) {
2282  // Didn't find any of our pixels. We are in a blind alley. Exit
2283  // gracefully.
2284  return false; // Signal done scanning this field.
2285  }
2286  }
2287 
2288  // Now scan around from our present facing direction and find the border
2289  // (if any).
2290  while (--counter)
2291  {
2292  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))
2293  {
2294  index = m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]);
2295  if (index == a_fieldindex)
2296  {
2297  if (--i < 0) i = 7;
2298  continue;
2299  }
2300  }
2301 
2302  // Aha! This pixel is not ours. Step one step in the
2303  // opposite(!) direction. If that pixel is ours, then
2304  // modify hotspot coordinates and exit.
2305  if (++i > 7) i = 0;
2306  if (!((*a_x) + x_add[i] + 1 > width) && !((*a_x) + x_add[i] < 0) && !((*a_y) + y_add[i] + 1 > height) &&
2307  !((*a_y) + y_add[i] < 0) && (m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]) == a_fieldindex))
2308  {
2309  (*a_x) += x_add[i];
2310  (*a_y) += y_add[i];
2311  return true;
2312  }
2313  }
2314  return false;
2315 }
int MapWidth(void)
Definition: rastermap.h:57
int MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::BorderStep ( int  a_fieldpoly,
int  a_borderpoly,
APoint *  a_coord 
)
protected

Definition at line 2318 of file Landscape.cpp.

2318  {
2319  int index;
2320  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2321  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2322  int width = m_land->MapWidth();
2323  int height = m_land->MapHeight();
2324  int i = 7, counter = 8;
2325  bool running = true;
2326  // First scan for another pixel that belongs to this field.
2327  while (running)
2328  {
2329  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))
2330  {
2331  index = m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]);
2332  if (index == a_fieldindex)
2333  {
2334  // Found the first field pixel while scanning around always
2335  // in the same direction.
2336  running = false;
2337  }
2338  }
2339  if (--i < 0) {
2340  // Didn't find any of our pixels. We are in a blind alley. Exit
2341  // gracefully.
2342  return false; // Signal done scanning this field.
2343  }
2344  }
2345 
2346  // Now scan around from our present facing direction and find the border
2347  // (if any).
2348  while (--counter)
2349  {
2350  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))
2351  {
2352  index = m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]);
2353  if (index == a_fieldindex)
2354  {
2355  if (--i < 0) i = 7;
2356  continue;
2357  }
2358  }
2359 
2360  // Aha! This pixel is not ours. Step one step in the
2361  // opposite(!) direction. If that pixel is ours, then
2362  // modify hotspot coordinates and exit.
2363  if (++i > 7) i = 0;
2364  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) &&
2365  !((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))
2366  {
2367  (a_coord->m_x) += x_add[i];
2368  (a_coord->m_y) += y_add[i];
2369  return true;
2370  }
2371  }
2372  return false;
2373 }
int MapWidth(void)
Definition: rastermap.h:57
int MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::BorderTest ( int  a_fieldpoly,
int  a_borderpoly,
int  a_x,
int  a_y 
)
protected

Definition at line 2233 of file Landscape.cpp.

2234 {
2235  int index;
2236  int x_add[ 8 ] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2237  int y_add[ 8 ] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2238  int width = m_land->MapWidth();
2239  int height = m_land->MapHeight();
2240  // Scan anti-clockwise from center pixel coordinate.
2241  for ( unsigned int i = 0; i < 8; i++ ) {
2242  if ( ( a_x + x_add[ i ] >= width ) || ( a_x + x_add[ i ] < 0 ) || ( a_y + y_add[ i ] >= height )
2243  || ( a_y + y_add[ i ] < 0 ) ) {
2244  return true;
2245  }
2246  //continue;
2247  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2248  if ( ( index != a_fieldindex ) && ( index != a_borderindex ) )
2249  {
2250  return true;
2251  // Test removed 1/07/2014 CJT
2252  //if ( BorderNeed( m_elems[ index ]->GetElementType() ) ) return true;
2253  //else return false;
2254  }
2255  }
2256  return false;
2257 }
int MapWidth(void)
Definition: rastermap.h:57
int MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
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.

Definition at line 3066 of file Landscape.cpp.

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

3067 {
3072  for (int p = 0; p< (int)m_elems.size(); p++)
3073  {
3074  TTypesOfLandscapeElement tole = m_elems[p]->GetElementType();
3075  if ( tole == tole_Building)
3076  {
3077  int cx = m_elems[p]->GetCentroidX();
3078  int cy = m_elems[p]->GetCentroidY();
3079  int near = 0;
3080  for (int j = 0; j< (int)m_elems.size(); j++)
3081  {
3082  if (m_elems[j]->GetElementType() == tole_Building)
3083  {
3084  int nx = m_elems[j]->GetCentroidX();
3085  int ny = m_elems[j]->GetCentroidY();
3086  int dx =abs(cx-nx);
3087  int dy =abs(cy-ny);
3088  if ((dx < cfg_mintownbuildingdistance.value()) && (dy < cfg_mintownbuildingdistance.value())) near++;
3089  if (near > cfg_mintownbuildingdistance.value()) break;
3090  }
3091  }
3092  if (near <= cfg_mintownbuildingnumber.value()) m_elems[p]->SetCountryDesignation(1); // Not enough buildings close by, so it is a country building
3093  else m_elems[p]->SetCountryDesignation(0);
3094  }
3095  else if (tole == tole_YoungForest)
3096  {
3097  m_elems[p]->SetCountryDesignation(2);
3098  }
3099  else if ((tole == tole_DeciduousForest) || ( tole == tole_MixedForest) || ( tole == tole_ConiferousForest ) ) m_elems[p]->SetCountryDesignation(3);
3100 
3101  }
3102 }
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_mintownbuildingdistance("MAP_MINTOWNBUILDINGDISTANCE", CFG_CUSTOM, 100)
static CfgInt cfg_mintownbuildingnumber("MAP_MINTOWNBUILDINGNUMBER", CFG_CUSTOM, 6)
int value(void)
Definition: configurator.h:92
TTypesOfLandscapeElement
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.

Definition at line 2821 of file Landscape.cpp.

2822 {
2828  cout << "In Centroid Calculations" << endl;
2829  // For each polygon
2830  for (int p = 0; p< (int)m_elems.size(); p++)
2831  {
2832  // Calcuate the actual centre
2833  int x1 = m_elems[p]->GetMinX();
2834  int y1 = m_elems[p]->GetMinY();
2835  int x2 = m_elems[p]->GetMaxX();
2836  int y2 = m_elems[p]->GetMaxY();
2837  int midx = (x1 + x2) / 2;
2838  int midy = (y1 + y2) / 2;
2839  // Now from midx & midy we move outwards in concentric circles until we find a location that matches our polyref.
2840  int polyindex = p; // Change mapmapping has been called by now, so the map contains m_elems indices.
2841  CentroidSpiralOut(polyindex, midx, midy);
2842  // 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,
2843  // 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
2844  // from this point
2845  int l;
2846  FindLongestAxis(&midx, &midy, &l);
2847  m_elems[p]->SetCentroid(midx, midy);
2848  }
2850 }
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:3066
int FindLongestAxis(int *x, int *y, int *a_length)
Definition: Landscape.cpp:2632
void CentroidSpiralOut(int a_polyref, int &a_x, int &a_y)
Definition: Landscape.cpp:2853
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

Definition at line 302 of file Landscape.cpp.

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

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:
318  case tole_PermPasture:
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
TTypesOfLandscapeElement
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.

Definition at line 379 of file Landscape.cpp.

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 Get(int a_x, int a_y)
Definition: rastermap.h:86
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.

Definition at line 337 of file Landscape.cpp.

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 
)

Definition at line 2853 of file Landscape.cpp.

References g_msg, and MapErrorMsg::Warn().

2854 {
2855  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref) return; // Found it so return
2856  // Otherwise its not found so we need to start to spiral out
2857  int loop = 1;
2858  int sx = a_x;
2859  int sy = a_y;
2860  do {
2861  a_y = sy - loop;
2862  for (int i = 0 - loop; i <= loop; i++)
2863  {
2864  a_x = sx + i;
2865  CorrectCoords(a_x, a_y);
2866  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2867  return; // Found it so return
2868  }
2869  a_y = sy + loop;
2870  for (int i = 0 - loop; i <= loop; i++)
2871  {
2872  a_x = sx + i;
2873  CorrectCoords(a_x, a_y);
2874  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2875  return; // Found it so return
2876  }
2877  a_x = sx + loop;
2878  for (int j = 0 - (loop - 1); j< loop; j++)
2879  {
2880  a_y = sy + j;
2881  CorrectCoords(a_x, a_y);
2882  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2883  return; // Found it so return
2884  }
2885  a_x = sx - loop;
2886  for (int j = 0 - (loop - 1); j< loop; j++)
2887  {
2888  a_y = sy + j;
2889  CorrectCoords(a_x, a_y);
2890  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
2891  return; // Found it so return
2892  }
2893  loop++;
2894  } while (loop<m_width); // This stopping rule should hopefully not be needed, it is set very high.
2895  g_msg->Warn("Landscape::CentroidSpiralOut: Failure of centroid main loop. Looking for polygon index ",a_polyref);
2896  a_x = m_elems[a_polyref]->GetMinX();
2897  a_y = m_elems[a_polyref]->GetMinY();
2898 }
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:1461
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
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1419
void Landscape::CentroidSpiralOutBlocks ( int  a_polyref,
int &  a_x,
int &  a_y 
)

Definition at line 2900 of file Landscape.cpp.

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

Definition at line 1944 of file Landscape.cpp.

References PEST_GRIDSIZE, and PEST_GRIDSIZE_POW2.

1944  {
1950  cout << "In Change Map Mapping" << endl;
1951  int mapwidth = m_land->MapWidth();
1952  int mapheight = m_land->MapHeight();
1953  int pest_map_width = mapwidth >> PEST_GRIDSIZE_POW2;
1954  if ( mapwidth & ( PEST_GRIDSIZE - 1 ) ) pest_map_width++;
1955  int oldindex = -1;
1956  for ( int x = 0; x < mapwidth; x++ )
1957  {
1958  for ( int y = 0; y < mapheight; y++ )
1959  {
1960  int polynum = m_land->Get( x, y ); // the polyref e.g. = 1, m_polymapping[ polynum ] = 0
1961  m_elems[ m_polymapping[ polynum ]]->SetMapIndex( m_polymapping[ polynum ] ); // Here we set index in the map to the index in elements, i.e. 0
1962  m_elems[ m_polymapping[ polynum ]]->SetMapValid( true );
1963  // Do the translation.
1964  m_land->Put( x, y, m_polymapping[ polynum ] ); // and now we write this to the map, i.e. 0
1965  // This coordinate is now valid. Throw these coordinates into
1966  // the associated landscape element.
1967  int index = m_polymapping[ SupplyPolyRef( x, y ) ];
1968  if ( index != oldindex )
1969  {
1970  m_elems[ index ]->SetValidXY( x, y );
1971  int l_x = x >> PEST_GRIDSIZE_POW2;
1972  int l_y = y >> PEST_GRIDSIZE_POW2;
1973  int pref = l_y * pest_map_width + l_x;
1974  m_elems[ index ]->SetPesticideCell( pref );
1975  oldindex = index;
1976  }
1977  }
1978  }
1979  RebuildPolyMapping();
1980 /*
1981 // Check that all of the polygons are mentioned in the map.
1982  if ( l_map_check_polygon_xref.value() )
1983  {
1984  for ( unsigned int i = 0; i < m_elems.size(); i++ )
1985  {
1986  if ( !m_elems[ i ]->GetMapValid() ) {
1987  char poly[ 20 ];
1988  sprintf( poly, "%d", m_elems[ i ]->GetPoly() );
1989  g_msg->Warn( WARN_FILE, "Landscape::ChangeMapMapping(): ""Polygon number referenced but not in map file: ", poly );
1990  exit( 1 );
1991  }
1992  }
1993  }
1994 */
1995 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1414
int MapWidth(void)
Definition: rastermap.h:57
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 Put(int a_x, int a_y, int a_elem)
Definition: rastermap.h:62
int MapHeight(void)
Definition: rastermap.h:58
void RebuildPolyMapping()
Definition: landscape.h:191
#define PEST_GRIDSIZE_POW2
Turns on code for detailed pesticide fate handling.
Definition: pesticide.h:42
int Get(int a_x, int a_y)
Definition: rastermap.h:86
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
#define PEST_GRIDSIZE
Definition: pesticide.h:43
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.

Definition at line 1175 of file Landscape.cpp.

References g_msg, tole_BareRock, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_Garden, tole_HeritageSite, tole_IndividualTree, tole_PlantNursery, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_Saltwater, tole_SandDune, tole_StoneWall, tole_UrbanNoVeg, MapErrorMsg::Warn(), and WARN_FILE.

1176 {
1182  const int TypesToReplace = 18;
1186  int foundList[TypesToReplace];
1187  cout << "Consolidating polygons with no special behaviour" << endl;
1188  for (int i = 0; i < TypesToReplace; i++) foundList[i] = -1;
1189  int mapwidth = m_land->MapWidth();
1190  int mapheight = m_land->MapHeight();
1191  for (int x = 0; x < mapwidth; x++)
1192  {
1193  for (int y = 0; y < mapheight; y++)
1194  {
1195  int ele = m_land->Get(x, y);
1196  TTypesOfLandscapeElement tole = m_elems[m_polymapping[ele]]->GetElementType();
1197  for (int t = 0; t < TypesToReplace; t++)
1198  {
1199  if (tole == replaceList[t])
1200  {
1201  // Must do something with this cell
1202  if (foundList[t] == -1) foundList[t] = ele;
1203  else
1204  {
1205  // Need to replace this cell
1206  m_land->Put(x, y, foundList[t]);
1207  }
1208  }
1209  }
1210  }
1211  }
1212  // At this point there should be many polygons that are not in the map. So we need to run the valid test.
1213  g_msg->Warn(WARN_FILE, "Landscape::ConsolidatePolys() - ""Consolidate map dump.", "");
1214 }
int MapWidth(void)
Definition: rastermap.h:57
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 Put(int a_x, int a_y, int a_elem)
Definition: rastermap.h:62
int MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
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 Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
TTypesOfLandscapeElement
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.

Definition at line 1461 of file landscape.h.

1462 {
1466  x = (m_width10 + x) % m_width;
1467  y = (m_height10 + y) % m_height;
1468 }
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

Definition at line 1481 of file landscape.h.

1482 {
1486  if (a_pt.m_x >= m_width) a_pt.m_x = m_width - 1;
1487  if (a_pt.m_y >= m_height) a_pt.m_y = m_height - 1;
1488  if (a_pt.m_x < 0) a_pt.m_x = 0;
1489  if (a_pt.m_y < 0) a_pt.m_y = 0;
1490 }
int m_width
Definition: landscape.h:127
int m_height
Definition: landscape.h:128
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.

Definition at line 1470 of file landscape.h.

1471 {
1475  APoint pt;
1476  pt.m_x = (m_width10 + x) % m_width;
1477  pt.m_y = (m_height10 + y) % m_height;
1478  return pt;
1479 }
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
int Landscape::CorrectHeight ( int  y)
inline

Definition at line 1499 of file landscape.h.

1500 {
1501  return (m_height10+y)%m_height;
1502 }
int m_height10
Definition: landscape.h:130
int m_height
Definition: landscape.h:128
int Landscape::CorrectWidth ( int  x)
inline

Definition at line 1493 of file landscape.h.

1494 {
1495  return (m_width10+x)%m_width;
1496 }
int m_width
Definition: landscape.h:127
int m_width10
Definition: landscape.h:129
void Landscape::CountMapSquares ( void  )
protected

Definition at line 1854 of file Landscape.cpp.

1854  {
1855  int mapwidth = m_land->MapWidth();
1856  int mapheight = m_land->MapHeight();
1857  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1858  m_elems[i]->SetArea(0);
1859  m_elems[ i ]->m_squares_in_map=0;
1860  }
1861 
1862  for ( int x = 0; x < mapwidth; x++ ) {
1863  for ( int y = 0; y < mapheight; y++ ) {
1864  int l_ele = m_land->Get( x, y );
1865  m_elems[ l_ele ]->m_squares_in_map++;
1866  }
1867  }
1868 }
int MapWidth(void)
Definition: rastermap.h:57
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 MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
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

Definition at line 2375 of file Landscape.cpp.

References tole_Pond.

2376 {
2378  for (unsigned int i = 0; i < m_elems.size(); i++)
2379  {
2380  if (m_elems[i]->GetElementType() == tole_Pond) {
2381  m_PondIndexList.push_back(i);
2382  m_PondRefsList.push_back(m_elems[i]->GetPoly());
2383  }
2384  }
2385 }
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.

Definition at line 1498 of file Landscape.cpp.

1498  {
1499 
1500  ofstream ofile ("Daydegrees.txt", ios::app);
1501  //print degrees
1502  ofile << m_FarmManager->GetDD();
1503  ofile << endl;
1504  ofile.close();
1505 }
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
double GetDD(void)
Returnes day degrees for the period March 1st - November 1st. Used for determining yields of crops th...
Definition: farm.h:1692
void Landscape::DumpAllSymbolsAndExit ( const char *  a_dumpfile)
inline

Definition at line 734 of file landscape.h.

References Configurator::DumpAllSymbolsAndExit(), and g_cfg.

734  {
735  g_cfg->DumpAllSymbolsAndExit( a_dumpfile );
736  }
void DumpAllSymbolsAndExit(const char *a_dumpfile)
class Configurator * g_cfg
void Landscape::DumpCentroids ( void  )

Definition at line 3054 of file Landscape.cpp.

3055 {
3056  ofstream centroidfile("PolygonCentroids.txt", ios::out);
3057  centroidfile<<"Polyref"<<'\t'<<"CX"<<'\t'<<"CY"<<'\t'<<"Type"<<'\t'<<"Area"<<'\t'<<"Country Designation"<<endl;
3058  for (int p = 0; p< (int)m_elems.size(); p++)
3059  {
3060  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;
3061  }
3062  centroidfile.close();
3063 }
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

Definition at line 1217 of file Landscape.cpp.

1218 {
1219  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.
1220  /* FILE * l_file;
1221  l_file = fopen(a_filename, "wb" );
1222  if ( !l_file ) {
1223  g_msg->Warn( WARN_FILE, "Landscape::DumpMap(): Unable to open file", a_filename );
1224  exit( 0 );
1225  }
1226 
1227  char * l_id = m_land->GetID();
1228 
1229 
1230  fwrite( l_id, 1, 12, l_file );
1231  fwrite( & m_width, 1, sizeof( int ), l_file );
1232  if (cfg_rectangularmaps_on.value() )
1233  {
1234  fwrite( & m_height, 1, sizeof( int ), l_file );
1235  }
1236  for ( int i = 0; i < m_width * m_height; i++ )
1237  {
1238  LE* le = m_elems[m_polymapping[l_map[i]]];
1239  int l_poly = le->GetPoly();
1240  fwrite( & l_poly, 1, sizeof( int ), l_file );
1241  }
1242  fclose( l_file );
1243  */
1244  ofstream OFile( a_filename, ios::binary);
1245  char id[12] = { "LSB2_Format" };
1246  OFile.write(id, 12);
1247  OFile.write((char*)&m_width, sizeof (int));
1248  OFile.write((char*)&m_height, sizeof (int));
1249  OFile.write((char*)l_map, m_width*m_height*sizeof (int));
1250  OFile.close();
1251 }
int m_width
Definition: landscape.h:127
int m_height
Definition: landscape.h:128
int * GetMagicP(int a_x, int a_y)
Definition: rastermap.h:79
RasterMap * m_land
The big map.
Definition: landscape.h:122
void Landscape::DumpMapGraphics ( const char *  a_filename)
protected

Definition at line 3363 of file Landscape.cpp.

References g_msg, tole_Field, MapErrorMsg::Warn(), and WARN_FILE.

3363  {
3364  unsigned int linesize = m_maxextent * 3;
3365  unsigned char * frame_buffer = (unsigned char *)malloc(sizeof(unsigned char)* linesize);
3366 
3367  if (frame_buffer == NULL) {
3368  g_msg->Warn(WARN_FILE, "Landscape::DumpMapGraphics(): Out of memory!", "");
3369  exit(1);
3370  }
3371 
3372  FILE * l_file = fopen(a_filename, "w");
3373  if (!l_file) {
3374  g_msg->Warn(WARN_FILE, "Landscape::DumpMapGraphics(): ""Unable to open file for writing: %s\n", a_filename);
3375  exit(1);
3376  }
3377 
3378  fprintf(l_file, "P6\n%d %d %d\n", m_width, m_height, 255);
3379 
3380  for (int y = 0; y < m_height; y++) {
3381  int i = 0;
3382  for (int x = 0; x < m_width; x++) {
3383  int eletype = (int)SupplyElementType(x, y);
3384  int localcolor = 16777215 / eletype;
3385 
3386  if (eletype == (int)tole_Field) {
3387  int category;
3388  double hei = SupplyVegHeight(x, y);
3389  if (hei > 50.0) category = 0; else category = (int)(200.0 - (hei * 4.0));
3390  localcolor = ((category * 65536) + 65535);
3391  }
3392 
3393  frame_buffer[i++] = (unsigned char)(localcolor & 0xff);
3394  frame_buffer[i++] = (unsigned char)((localcolor >> 8) & 0xff);
3395  frame_buffer[i++] = (unsigned char)((localcolor >> 16) & 0xff);
3396  }
3397  fwrite(frame_buffer, sizeof(unsigned char), linesize, l_file);
3398  }
3399 
3400  fclose(l_file);
3401 
3402  free(frame_buffer);
3403 }
int m_width
Definition: landscape.h:127
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1031
int m_height
Definition: landscape.h:128
int m_maxextent
Definition: landscape.h:131
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:857
void Landscape::DumpMapInfoByArea ( const char *  a_filename,
bool  a_append,
bool  a_dump_zero_areas,
bool  a_write_veg_names 
)

Definition at line 3416 of file Landscape.cpp.

References Calendar::DayInYear(), g_date, g_msg, Calendar::OldDays(), tov_OFirstYearDanger, tov_Undefined, MapErrorMsg::Warn(), and WARN_FILE.

3416  {
3417  FillVegAreaData();
3418  FILE * outf;
3419  if (a_append) {
3420  outf = fopen(a_filename, "a");
3421  if (!outf) {
3422  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to open file for appending", a_filename);
3423  exit(1);
3424  }
3425  }
3426  else {
3427  outf = fopen(a_filename, "w");
3428  if (!outf) {
3429  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to open file for writing", a_filename);
3430  exit(1);
3431  }
3432  }
3433 
3434  // Emit element type info.
3435  for (unsigned int i = 0; i < tov_Undefined + 1; i++) {
3436  if (i == tov_OFirstYearDanger)
3437  continue;
3438  if (!a_dump_zero_areas && l_vegtype_areas[i] < 0.5)
3439  continue;
3440 
3441  fprintf(outf, "%6ld\t%3d\t%10.0f", g_date->OldDays() + g_date->DayInYear() - 364, i, l_vegtype_areas[i]);
3442  if (a_write_veg_names)
3443  fprintf(outf, "\t%s\n", VegtypeToString((TTypesOfVegetation)i).c_str()); else
3444  fprintf(outf, "\n");
3445  }
3446 
3447  fclose(outf);
3448 }
std::string VegtypeToString(TTypesOfVegetation a_veg)
Definition: Landscape.cpp:3943
TTypesOfVegetation
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void FillVegAreaData()
Definition: Landscape.cpp:3405
int DayInYear(void)
Definition: calendar.h:58
class Calendar * g_date
Definition: calendar.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
double * l_vegtype_areas
Definition: landscape.h:141
long OldDays(void)
Definition: calendar.h:60
void Landscape::DumpPublicSymbols ( const char *  a_dumpfile,
CfgSecureLevel  a_level 
)
inline

Definition at line 730 of file landscape.h.

References Configurator::DumpPublicSymbols(), and g_cfg.

731  {
732  g_cfg->DumpPublicSymbols( a_dumpfile, a_level );
733  }
class Configurator * g_cfg
void DumpPublicSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
void Landscape::DumpTreatCounters ( const char *  a_filename)
protected

Definition at line 3350 of file Landscape.cpp.

References g_msg, last_treatment, start, MapErrorMsg::Warn(), and WARN_FILE.

3350  {
3351  FILE * l_file = fopen(a_filename, "w");
3352  if (!l_file) {
3353  g_msg->Warn(WARN_FILE, "Landscape::DumpTreatCounters(): ""Unable to open file for writing: %s\n", a_filename);
3354  exit(1);
3355  }
3356 
3357  for (int i = start; i < last_treatment; i++) {
3358  fprintf(l_file, "%3d %s %10d\n", i, EventtypeToString(i).c_str(), m_treatment_counts[i]);
3359  }
3360  fclose(l_file);
3361 }
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
int m_treatment_counts[last_treatment]
Definition: landscape.h:171
std::string EventtypeToString(int a_event)
Definition: Landscape.cpp:3670
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
void Landscape::DumpVegAreaData ( int  a_day)

Definition at line 4295 of file Landscape.cpp.

References cfg_dumpvegjan, cfg_dumpvegjanfile, cfg_dumpvegjune, cfg_dumpvegjunefile, CfgBool::value(), and CfgStr::value().

4295  {
4296 
4297  if (cfg_dumpvegjan.value()) {
4298  if ((a_day % 365) == 0) { // Jan 1st
4299  DumpMapInfoByArea(cfg_dumpvegjanfile.value(), true, true, true);
4300  return;
4301  }
4302  }
4303  if (cfg_dumpvegjune.value()) {
4304  if ((a_day % 365) == 152) { // 1st June
4305  DumpMapInfoByArea(cfg_dumpvegjunefile.value(), true, true, true);
4306  }
4307  }
4308 
4309 }
CfgBool cfg_dumpvegjune("G_VEGAREASJUNE_ON", CFG_CUSTOM, false)
CfgStr cfg_dumpvegjanfile("G_VEGAREASJAN_FILENAME", CFG_CUSTOM,"DUMPVEG_JAN.TXT")
void DumpMapInfoByArea(const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
Definition: Landscape.cpp:3416
CfgStr cfg_dumpvegjunefile("G_VEGAREASJUNE_FILENAME", CFG_CUSTOM,"DUMPVEG_JUNE.TXT")
const char * value(void)
Definition: configurator.h:139
bool value(void)
Definition: configurator.h:123
CfgBool cfg_dumpvegjan("G_VEGAREASJAN_ON", CFG_CUSTOM, false)
void Landscape::EventDump ( int  x,
int  y,
int  x2,
int  y2 
)
protected

Definition at line 1508 of file Landscape.cpp.

References g_msg, sleep_all_day, MapErrorMsg::Warn(), and WARN_FILE.

1508  {
1509  FILE * vfile=fopen("EventDump.txt", "a" );
1510  if (!vfile) {
1511  g_msg->Warn( WARN_FILE, "Landscape::EventDump(): Unable to open file", "EventDump.txt" );
1512  exit( 1 );
1513  }
1514  FarmToDo event;
1515  int i = 0;
1516  int day = SupplyDayInYear();
1517  fprintf( vfile, "%d: ", day );
1518  while ( ( event = ( FarmToDo )SupplyLastTreatment( x1, y1, & i ) ) != sleep_all_day ) {
1519  fprintf( vfile, "%d ", event );
1520  }
1521  i = 0;
1522  fprintf( vfile, " - " );
1523  while ( ( event = ( FarmToDo )SupplyLastTreatment( x2, y2, & i ) ) != sleep_all_day ) {
1524  fprintf( vfile, "%d ", event );
1525  }
1526  fprintf( vfile, "\n" );
1527  fclose( vfile );
1528 }
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
FarmToDo
Definition: treatment.h:31
int SupplyDayInYear(void)
Definition: landscape.h:1522
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
int SupplyLastTreatment(int a_polyref, int *a_index)
Definition: landscape.h:1255
void Landscape::EventDumpPesticides ( int  x1,
int  y1 
)
protected

Definition at line 1531 of file Landscape.cpp.

References fungicide_treat, g_msg, herbicide_treat, insecticide_treat, sleep_all_day, MapErrorMsg::Warn(), and WARN_FILE.

1531  {
1532  FILE * vfile=fopen("EventDump.txt", "a" );
1533  if (!vfile) {
1534  g_msg->Warn( WARN_FILE, "Landscape::EventDump(): Unable to open file", "EventDump.txt" );
1535  exit( 1 );
1536  }
1537  FarmToDo a_event;
1538  int i = 0;
1539  int day = this->SupplyGlobalDate();
1540  int herb = 0;
1541  int fung = 0;
1542  int ins = 0;
1543  while ( ( a_event = ( FarmToDo )SupplyLastTreatment( x1, y1, & i ) ) != sleep_all_day ) {
1544  if (a_event == herbicide_treat )
1545  {
1546  herb++;
1547  }
1548  else if (a_event == fungicide_treat ) fung++;
1549  else if (a_event == insecticide_treat) ins++;
1550  }
1551  if (herb+fung+ins >0 ) fprintf( vfile, "%d\t%d\t%d\t%d\n", day, herb, fung, ins );
1552  i = 0;
1553  fclose( vfile );
1554 }
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
FarmToDo
Definition: treatment.h:31
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
long SupplyGlobalDate(void)
Definition: landscape.h:1547
int SupplyLastTreatment(int a_polyref, int *a_index)
Definition: landscape.h:1255
std::string Landscape::EventtypeToString ( int  a_event)

Definition at line 3670 of file Landscape.cpp.

References autumn_harrow, autumn_or_spring_plough, autumn_plough, autumn_roll, autumn_sow, burn_straw_stubble, cattle_out, cut_to_hay, cut_to_silage, cut_weeds, deep_ploughing, fa_ammoniumsulphate, fa_greenmanure, fa_manure, fa_npk, fa_pk, fa_sludge, fa_slurry, flammebehandling, fp_greenmanure, fp_liquidNH3, fp_manganesesulphate, fp_manure, fp_npk, fp_npks, fp_pk, fp_sludge, fp_slurry, fungicide_treat, g_msg, glyphosate, growth_regulator, harvest, hay_bailing, hay_turning, herbicide_treat, hilling_up, insecticide_treat, molluscicide, mow, pigs_out, product_treat, row_cultivation, sleep_all_day, spring_harrow, spring_plough, spring_roll, spring_sow, start, straw_chopping, strigling, strigling_sow, stubble_harrowing, swathing, syninsecticide_treat, trial_control, trial_insecticidetreat, trial_toxiccontrol, MapErrorMsg::Warn(), WARN_FILE, water, and winter_plough.

3670  {
3671  char error_num[20];
3672 
3673  switch (a_event) {
3674  case start:
3675  return " start";
3676  case sleep_all_day:
3677  return " sleep_all_day";
3678  case autumn_plough:
3679  return " autumn_plough";
3680  case autumn_harrow:
3681  return " autumn_harrow";
3682  case autumn_roll:
3683  return " autumn_roll";
3684  case autumn_sow:
3685  return " autumn_sow";
3686  case winter_plough:
3687  return " winter_plough";
3688  case deep_ploughing:
3689  return " deep_ploughing";
3690  case spring_plough:
3691  return " spring_plough";
3692  case spring_harrow:
3693  return " spring_harrow";
3694  case spring_roll:
3695  return " spring_roll";
3696  case spring_sow:
3697  return " spring_sow";
3698  case fp_npks:
3699  return " fp_npks";
3700  case fp_npk:
3701  return " fp_npk";
3702  case fp_pk:
3703  return " fp_pk";
3704  case fp_liquidNH3:
3705  return " fp_liquidNH3";
3706  case fp_slurry:
3707  return " fp_slurry";
3708  case fp_manganesesulphate:
3709  return " fp_manganesesulphate";
3710  case fp_manure:
3711  return " fp_manure";
3712  case fp_greenmanure:
3713  return " fp_greenmanure";
3714  case fp_sludge:
3715  return " fp_sludge";
3716  case fa_npk:
3717  return " fa_npk";
3718  case fa_pk:
3719  return " fa_pk";
3720  case fa_slurry:
3721  return " fa_slurry";
3722  case fa_ammoniumsulphate:
3723  return " fa_ammoniumsulphate";
3724  case fa_manure:
3725  return " fa_manure";
3726  case fa_greenmanure:
3727  return " fa_greenmanure";
3728  case fa_sludge:
3729  return " fa_sludge";
3730  case herbicide_treat:
3731  return " herbicide_treat";
3732  case growth_regulator:
3733  return " growth_regulator";
3734  case fungicide_treat:
3735  return " fungicide_treat";
3736  case insecticide_treat:
3737  return " insecticide_treat";
3738  case product_treat:
3739  return "pesticide_product_treat";
3740  case syninsecticide_treat:
3741  return " syninsecticide_treat";
3742  case molluscicide:
3743  return " molluscicide";
3744  case row_cultivation:
3745  return " row_cultivation";
3746  case strigling:
3747  return " strigling";
3748  case flammebehandling:
3749  return " flammebehandling";
3750  case hilling_up:
3751  return " hilling_up";
3752  case water:
3753  return " water";
3754  case swathing:
3755  return " swathing";
3756  case harvest:
3757  return " harvest";
3758  case cattle_out:
3759  return " cattle_out";
3760  case pigs_out:
3761  return " pigs_out";
3762  case cut_to_hay:
3763  return " cut_to_hay";
3764  case cut_to_silage:
3765  return " cut_to_silage";
3766  case straw_chopping:
3767  return " straw_chopping";
3768  case hay_turning:
3769  return " hay_turning";
3770  case hay_bailing:
3771  return " hay_bailing";
3772  case stubble_harrowing:
3773  return " stubble_harrowing";
3775  return "autumn_or_spring_plough";
3776  case burn_straw_stubble:
3777  return " burn_straw_stubble";
3778  case mow:
3779  return " mow";
3780  case cut_weeds:
3781  return " cut_weeds";
3782  case strigling_sow:
3783  return " strigling_sow";
3785  return "PesticideTrialTreatment";
3786  case trial_toxiccontrol:
3787  return " PesticideTrialToxic";
3788  case trial_control:
3789  return " PesticideTrialControl";
3790  case glyphosate:
3791  return " Glyphosate on setaside";
3792  default:
3793  sprintf(error_num, "%d", a_event);
3794  g_msg->Warn(WARN_FILE, "Landscape::EventtypeToString(): Unknown event type:", error_num);
3795  exit(1);
3796  }
3797 }
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
Definition: treatment.h:82
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
void Landscape::FillVegAreaData ( )

Definition at line 3405 of file Landscape.cpp.

References tov_Undefined.

3405  {
3406  for (unsigned int i = 0; i < (tov_Undefined + 1); i++) {
3407  l_vegtype_areas[i] = 0.0;
3408  }
3409 
3410  // Sum up statistics on element type.
3411  for (unsigned int i = 0; i < m_elems.size(); i++) {
3412  l_vegtype_areas[m_elems[i]->GetVegType()] += m_elems[i]->GetArea();
3413  }
3414 }
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

Definition at line 2580 of file Landscape.cpp.

References LE::GetPoly().

2580  {
2581  // Start at x,y
2582  // 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.
2583  // Then do it again, and again until we don't move more than 1m or we have tried too many times
2584  int ourpoly=SupplyPolyRef(*(x),*(y));
2585  if (ourpoly!=a_field->GetPoly()) return false;
2586  int centers[2][8];
2587  int tries=0;
2588  int diff=999;
2589  int x1=*(x);
2590  int y1=*(y);
2591  int centreX=x1;
2592  int centreY=y1;
2593  // 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
2594  while ((diff>1) & (tries++<100)) {
2595  for (unsigned v=0; v<4; v++) {
2596  x1=centreX;
2597  y1=centreY;
2598  AxisLoop(ourpoly, &x1, &y1, v);
2599  centers[0][v]=x1-m_x_add[v];
2600  centers[1][v]=y1-m_y_add[v];
2601  x1=centreX;
2602  y1=centreY;
2603  AxisLoop(ourpoly, &x1, &y1, v+4);
2604  centers[0][v+4]=x1-m_x_add[v+4];
2605  centers[1][v+4]=y1-m_y_add[v+4];
2606 // centreX+=((centers[0][v]+x1-m_x_add[v+4])/2);
2607 // centreY+=((centers[1][v]+y1-m_y_add[v+4])/2);
2608  }
2609  int oldx=centreX;
2610  int oldy=centreY;
2611  centreX=0;
2612  centreY=0;
2613  for (int h=0; h<8; h++) {
2614  centreX+=centers[0][h];
2615  centreY+=centers[1][h];
2616  }
2617  centreX/=8;
2618  centreY/=8;
2619  diff=abs(oldx-centreX)+abs(oldy-centreY);
2620  }
2621  *(x)=centreX;
2622  *(y)=centreY;
2623  int tourpoly=SupplyPolyRef(*(x),*(y));
2624  if (tourpoly!=ourpoly) {
2625  return false; // can happen eg if there is a pond in the middle of the field
2626  }
2627 
2628  return true;
2629 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1414
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:2719
int m_x_add[8]
Definition: landscape.h:244
int Landscape::FindLongestAxis ( int *  x,
int *  y,
int *  a_length 
)
protected

Definition at line 2632 of file Landscape.cpp.

2633 {
2634  int ourpoly=SupplyPolyRef(*(a_x),*(a_y));
2635  int dist[4];
2636  int distx[8];
2637  int disty[8];
2638  int found = -1;
2639  *(a_length) = 0;
2640  int dx[8];
2641  int dy[8];
2642  int fx[8];
2643  int fy[8];
2644  for (unsigned v=0; v<8; v++)
2645  {
2646  int x1=*(a_x);
2647  int y1=*(a_y);
2648  AxisLoop(ourpoly, &x1, &y1, v);
2649  x1 -= m_x_add[v];
2650  y1 -= m_y_add[v];
2651  dx[v] = abs(*(a_x)-x1);
2652  dy[v] = abs(*(a_y)-y1);
2653  fx[v] = x1;
2654  fy[v] = y1;
2655  distx[v] = dx[v];
2656  disty[v] = dy[v];
2657  }
2658  for (int di = 0; di < 4; di++)
2659  {
2660  int dx = distx[di] + distx[di + 4];
2661  int dy = disty[di] + disty[di + 4];
2662  if (dx == 0) dist[di] = dy; else dist[di] = dx;
2663  if (dist[di] > *(a_length))
2664  {
2665  found = di;
2666  *(a_length) = dist[di];
2667  }
2668  }
2669  if (found == -1) return 0;
2670  // Now need to find the middle of the axis.
2671  int l = (*(a_length) / 2);
2672  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;
2673  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;
2674 
2675  return found;
2676 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1414
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:2719
int m_x_add[8]
Definition: landscape.h:244
bool Landscape::FindValidXY ( int  a_field,
int &  a_x,
int &  a_y 
)
protected

Definition at line 2469 of file Landscape.cpp.

2469  {
2470  // From a hopefully sensible starting point this method scans in the
2471  // 8 directions to find a good valid x and y matching a_field
2472  int x_add[ 8 ] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2473  int y_add[ 8 ] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2474  int index;
2475  int nx, ny;
2476  int width = m_land->MapWidth();
2477  int height = m_land->MapHeight();
2478  // Assume it has to within 100m
2479  for ( int i = 0; i < 100; i++ ) {
2480  for ( int l = 0; l < 8; l++ ) {
2481  nx = a_x + x_add[ l ] * i;
2482  ny = a_y + y_add[ l ] * i;
2483  if ( ( nx < width ) && ( nx >= 0 ) && ( ny < height ) && ( ny >= 0 ) ) {
2484  index = m_land->Get( nx, ny );
2485  if ( index == a_field ) {
2486  a_x = a_x + x_add[ l ] * i;
2487  a_y = a_y + y_add[ l ] * i;
2488  return true;
2489  }
2490  }
2491  }
2492  }
2493  return false;
2494 }
int MapWidth(void)
Definition: rastermap.h:57
int MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
void Landscape::ForceArea ( void  )
protected

Definition at line 1886 of file Landscape.cpp.

References g_msg, MapErrorMsg::Warn(), and WARN_BUG.

1886  {
1887  int l_area_sum = 0;
1888 
1889  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1890  m_elems[ i ]->SetArea( ( double )m_elems[ i ]->m_squares_in_map );
1891  if ( m_elems[ i ]->m_squares_in_map > 0 ) {
1892  m_elems[ i ]->SetMapValid( true );
1893  l_area_sum += m_elems[ i ]->m_squares_in_map;
1894  }
1895  }
1896 
1897  if ( l_area_sum != m_width * m_height ) {
1898  g_msg->Warn( WARN_BUG, "Landscape::ForceArea(): Polygon areas doesn't"" sum up to map area!", "" );
1899  exit( 1 );
1900  }
1901 }
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
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
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

Definition at line 559 of file landscape.h.

References RasterMap::Get().

560  {
561  return m_elems[m_land->Get(a_x, a_y)]->GetGooseGrazingForage(a_goose);
562  }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
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

Definition at line 570 of file landscape.h.

References m_polymapping.

571  {
572  return m_elems[m_polymapping[a_polygon]]->GetGooseGrazingForage(a_goose);
573  }
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.

Definition at line 564 of file Landscape.cpp.

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.

565 {
572  GooseFieldList* alist = new GooseFieldList;
576  GooseFieldListItem gfli;
577  for (unsigned int i = 0; i < m_elems.size(); i++)
578  {
579  if (m_elems[i]->GetOpenness() > a_minopenness)
580  {
581  for (int g = gs_Pinkfoot; g < gs_foobar; g++)
582  {
583  gfli.grass[g] = m_elems[i]->GetGooseGrazingForage((GooseSpecies)g);
584  gfli.geesesp[g] = m_elems[i]->GetGooseSpNosToday((GooseSpecies)g);
585  gfli.geesespTimed[g] = m_elems[i]->GetGooseSpNosTodayTimed((GooseSpecies)g);
586  }
587  gfli.grain = m_elems[i]->GetBirdSeed();
588  gfli.maize = m_elems[ i ]->GetBirdMaize();
589  gfli.openness = m_elems[ i ]->GetOpenness();
590  int pref = m_elems[ i ]->GetPoly();
591  gfli.polyref = pref;
592  gfli.geese = m_elems[i]->GetGooseNosToday();
593  gfli.geeseTimed = m_elems[i]->GetGooseNosTodayTimed();
594  gfli.vegtype = m_elems[i]->GetVegType();
595  gfli.vegtypechr = VegtypeToString(m_elems[i]->GetVegType());
596  gfli.vegheight = m_elems[i]->GetVegHeight();
597  gfli.digestability = m_elems[i]->GetDigestability();
598  gfli.vegphase = m_elems[i]->GetVegPhase();
599  gfli.previouscrop = VegtypeToString( m_elems[ i ]->GetPreviousCrop( m_elems[ i ]->GetRotIndex() ) );
600  gfli.lastsownveg = VegtypeToString( m_elems[ i ]->GetLastSownVeg() );
601  alist->push_back(gfli);
602  }
603  }
604  return alist;
605 }
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
std::string VegtypeToString(TTypesOfVegetation a_veg)
Definition: Landscape.cpp:3943
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
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
int Landscape::GetGooseNumbers ( int  a_poly)

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

Definition at line 3154 of file Landscape.cpp.

3154  {
3155  return m_elems[m_polymapping[a_polyref]]->GetGooseNos();
3156  }
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.

Definition at line 3162 of file Landscape.cpp.

3163  {
3164  return m_elems[m_land->Get(a_x, a_y)]->GetGooseNos();
3165  }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::GetHareFoodQuality ( int  a_polygon)
Todo:
Decide where to classify new LE types for hare 1

Definition at line 3168 of file Landscape.cpp.

References g_FarmIntensivenessH, tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_Building, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_FishFarm, tole_Freshwater, tole_Garden, tole_Hedges, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_MixedForest, tole_Parkland, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideVerge, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UrbanNoVeg, tole_UrbanPark, tole_Vildtager, tole_Wasteland, tole_WindTurbine, tole_WoodlandMargin, and tole_WoodyEnergyCrop.

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

Definition at line 154 of file landscape.h.

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

Definition at line 3271 of file Landscape.cpp.

References g_msg, l_map_ascii_map_entity, CfgInt::value(), MapErrorMsg::Warn(), and WARN_FILE.

3271  {
3279  FILE* OFILE;
3280  OFILE = fopen( outpfile.c_str(), "w" );
3281  if (!OFILE) {
3282  g_msg->Warn( WARN_FILE, "Landscape::GISASCII_Output() "
3283  "Unable to open file for writing:",
3284  outpfile );
3285  exit( 1 );
3286  }
3287  char c = '\n';
3288  fprintf(OFILE, "ncols %d\n", m_width);
3289  fprintf(OFILE, "nrows %d\n", m_height);
3290  fprintf(OFILE, "xllcorner %d\n", UTMX );
3291  fprintf(OFILE, "yllcorner %d\n", UTMY );
3292  fprintf(OFILE, "cellsize %d\n", 1 );
3293  fprintf(OFILE, "NODATA_value %d\n", -9999 );
3294  // The polyref loop
3295  if (l_map_ascii_map_entity.value() == 1) {
3296  for (int y = 0; y < m_height; y++) {
3297  for (int x = 0; x < m_width; x++) {
3298  fprintf(OFILE, "%d\t", SupplyPolyRef(x, y));
3299  }
3300  fprintf(OFILE, "%c", c );
3301  }
3302  }
3303  // The element type loop
3304  if (l_map_ascii_map_entity.value() == 2) {
3305  for (int y = 0; y < m_height; y++) {
3306  for (int x = 0; x < m_width; x++) {
3307  fprintf(OFILE, "%d\t", SupplyElementType( x, y ));
3308  }
3309  fprintf( OFILE, "%c", c );
3310  }
3311  }
3312  fclose( OFILE );
3313 }
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1414
int m_width
Definition: landscape.h:127
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1031
int m_height
Definition: landscape.h:128
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
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.
int value(void)
Definition: configurator.h:92
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
void Landscape::GrazeVegetation ( int  a_poly,
double  a_forage 
)
inline

Removes grazing forage from a poly per m2.

Definition at line 623 of file landscape.h.

References m_polymapping.

623  {
624  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetation( a_forage, true );
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
void Landscape::GrazeVegetationTotal ( int  a_poly,
double  a_forage 
)
inline

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

Definition at line 629 of file landscape.h.

References m_polymapping.

629  {
630  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetationTotal( a_forage );
631  }
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

Definition at line 56 of file hedgebanks.cpp.

References RasterMap::GetMagicP(), hb_AddNewHedgebanks(), hb_border_pixels, hb_ClearPolygon(), hb_core_pixels, hb_DownPolyNumbers(), hb_FindBoundingBox(), hb_FindHedges(), hb_hedges, hb_height, HB_MAGIC, hb_map, hb_MarkTheBresenhamWay(), hb_MarkTopFromLocalMax(), hb_PaintBorder(), hb_PaintWhoHasNeighbourColor(), hb_ResetColorBits(), hb_RestoreHedgeCore(), hb_size, hb_UpPolyNumbers(), hb_width, l_map_art_hb_core_thres, l_map_art_hb_width, m_elems, m_land, m_polymapping, RasterMap::MapHeight(), RasterMap::MapWidth(), PolytypeToString(), tole_FieldBoundary, and CfgFloat::value().

57 {
58  // Make a local copy of the actual map parameters for speed
59  // purposes. We are going to use these *a lot*.
60  hb_map = m_land->GetMagicP( 0, 0 );
64 
65  //#ifdef HB_TESTING
66  //m_elems[m_polymapping
67  //[hb_map[750 + 600*hb_width]]]->SetElementType( tole_Hedges );
68  //#endif
69 
70  // Generate a list of polygon numbers + HB_MAGIC for all hedge elements
71  // in our current map.
72  hb_FindHedges();
73 
74  // As one lemming at the cliff edge said to the other: "Let's Go!"
75 
76  // For every hedge polygon:
77  printf("Hedges: %d\n", hb_hedges.size());
78  fflush(stdout);
79 
80  double l_inc = 50.0/((double)hb_hedges.size());
81  double l_count = 0.001;
82 
83  for ( unsigned int i=0; i<hb_hedges.size(); i++ ) {
84  l_count += l_inc;
85  if ( l_count > 1.0 ) {
86  l_count = 0.001;
87  printf(".");
88  fflush(stdout);
89  }
90  // Find the enclosing bounding box for our current polygon.
91  if ( ! hb_FindBoundingBox( hb_hedges[i] )) {
92  // Might want to raise a runtime error upon ending here.
93  // The test for hb_FindBoundingBox() fails if we have a polygon
94  // without any pixels in the main map!
95  continue;
96  }
97 
98  // Move all polygon numbers in our bounding box up! by HB_MAGIC
99  // to make room for our 'paint' values in the space below.
101 
103 
104  hb_PaintBorder( 0 );
105 
106  int l_color = 0;
107  while ( hb_PaintWhoHasNeighbourColor( l_color,
108  l_color + 1 )) {
109  l_color++;
110  }
111 
112  double l_percent = (double)hb_core_pixels/
113  ((double)hb_core_pixels+(double)hb_border_pixels);
114 
115  if ( l_percent > l_map_art_hb_core_thres.value()) {
116  // We ought to have at least *some* visible core area
117  // within the polygon, so do a simple scan.
118 
119  // l_color now happens to contain the maximum contour/color value
120  // within our current polygon.
121  int l_min = (int)((double)l_color * l_map_art_hb_width.value());
122  while ( l_color > l_min ) {
123  hb_MarkTopFromLocalMax( l_color );
125  l_color--;
126  }
127  } else {
128  // Very thin hedge (1->2 meters),
129  // use special border case scan when adding hedge banks.
131  }
132 
134 
135  // All the previous steps were just preparations.
136  // Now do the serious stuff.
138 
139 #ifdef HB_TESTING
140  // Sanity check.
141  for ( int j=0; j<hb_size; j++ ) {
142  if ( m_polymapping[ hb_map[ j ] - HB_MAGIC ] == -1 ) {
143  printf("Oh dear!\n");
144  exit(1);
145  }
146  }
147 
148  char ffname[24];
149  sprintf( ffname, "test%02d.ppm", i);
150 #endif
151 
152  // Restore order to the map before continuing.
154 
155 #ifdef HB_TESTING
156  hb_dump_map( 0, hb_width, 0, hb_height, ffname, false );
157 #endif
158  }
159 
160  printf("\n");
161 #ifdef HB_TESTING
162  // Quick reminder.
163  for ( unsigned int i=0; i<m_elems.size(); i++ ) {
164  if ( m_elems[i]->GetArea() < 0.9 &&
165  m_elems[i]->GetElementType() != tole_FieldBoundary ) {
166  // Note: Field boundaries have not been scanned yet at this point,
167  // so they will have a zero area right here and now.
168  printf("Warning: Polygon %6d of type %s came up with area %3.2f!\n",
169  m_elems[i]->GetPoly(),
170  PolytypeToString( m_elems[i]->GetElementType() ),
171  m_elems[i]->GetArea() );
172  }
173  }
174  exit(0);
175 #endif
176 }
int MapWidth(void)
Definition: rastermap.h:57
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 hb_core_pixels
Definition: landscape.h:253
std::string PolytypeToString(TTypesOfLandscapeElement a_le_type)
Definition: Landscape.cpp:3801
int MapHeight(void)
Definition: rastermap.h:58
void hb_MarkTopFromLocalMax(int a_color)
Definition: hedgebanks.cpp:679
bool hb_FindBoundingBox(int a_poly_num)
Definition: hedgebanks.cpp:243
void hb_FindHedges(void)
Definition: hedgebanks.cpp:276
void hb_DownPolyNumbers(void)
Definition: hedgebanks.cpp:715
double value(void)
Definition: configurator.h:107
int hb_height
Definition: landscape.h:248
void hb_MarkTheBresenhamWay(void)
Definition: hedgebanks.cpp:629
int * GetMagicP(int a_x, int a_y)
Definition: rastermap.h:79
void hb_RestoreHedgeCore(int a_orig_poly_number)
Definition: hedgebanks.cpp:311
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 hb_ClearPolygon(int a_poly_num)
Definition: hedgebanks.cpp:413
bool hb_PaintWhoHasNeighbourColor(int a_neighbour_color, int a_new_color)
Definition: hedgebanks.cpp:526
vector< int > hb_hedges
Definition: landscape.h:241
void hb_UpPolyNumbers(void)
Definition: hedgebanks.cpp:289
#define HB_MAGIC
Definition: hedgebanks.cpp:38
int * hb_map
Definition: landscape.h:246
int hb_size
Definition: landscape.h:249
void hb_PaintBorder(int a_color)
Definition: hedgebanks.cpp:429
void hb_ResetColorBits(void)
Definition: hedgebanks.cpp:298
static CfgFloat l_map_art_hb_width("MAP_ART_HB_WIDTH", CFG_CUSTOM, 0.3)
int hb_width
Definition: landscape.h:247
static CfgFloat l_map_art_hb_core_thres("MAP_ART_HB_STRIPE_THRES", CFG_CUSTOM, 0.4)
int hb_border_pixels
Definition: landscape.h:254
void hb_AddNewHedgebanks(int a_orig_poly_num)
Definition: hedgebanks.cpp:198
void Landscape::hb_AddNewHedgebanks ( int  a_orig_poly_num)
protected

Definition at line 198 of file hedgebanks.cpp.

References hb_GenerateHBPolys(), HB_MAGIC, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, hb_StripingDist(), and hb_width.

Referenced by hb_Add().

199 {
201 
202  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
203  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
204  int i = l_y*hb_width + l_x;
205  int l_val = hb_map[ i ];
206  if ( l_val >= 0 && l_val < HB_MAGIC ) {
207  hb_map[ i ] = hb_StripingDist() + HB_MAGIC;
208  /*
209  m_elems[m_polymapping[hb_map[ i ]-HB_MAGIC]]->AddArea( 1.0 );
210  m_elems[m_polymapping[hb_map[ i ]-HB_MAGIC]]->m_squares_in_map++;
211  m_elems[m_polymapping[a_orig_poly_num]]->AddArea( -1.0 );
212  if ( m_elems[m_polymapping[a_orig_poly_num]]->GetArea() < 0.0 ) {
213  printf("%d %d !!!\n", l_x, l_y );
214  exit(1);
215  }
216  */
217  //m_elems[m_polymapping[a_orig_poly_num]]->m_squares_in_map--;
218  }
219  }
220  }
221 }
int hb_max_x
Definition: landscape.h:250
void hb_GenerateHBPolys(void)
Definition: hedgebanks.cpp:180
int hb_StripingDist(void)
Definition: hedgebanks.cpp:225
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
#define HB_MAGIC
Definition: hedgebanks.cpp:38
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
int hb_min_y
Definition: landscape.h:251
void Landscape::hb_Cleanup ( void  )
protected
void Landscape::hb_ClearPolygon ( int  a_poly_num)
protected

Definition at line 413 of file hedgebanks.cpp.

References HB_MAGIC_COLOR, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

414 {
415  // 'Paint' every pixel which belongs to the current polygon with the
416  // value HB_MAGIC_COLOR.
417  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
418  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
419  int l_coord = l_y*hb_width + l_x;
420  if ( hb_map[ l_coord ] == a_poly_num ) {
421  hb_map[ l_coord ] = HB_MAGIC_COLOR;
422  }
423  }
424  }
425 }
int hb_max_x
Definition: landscape.h:250
#define HB_MAGIC_COLOR
Definition: hedgebanks.cpp:39
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
int hb_min_y
Definition: landscape.h:251
void Landscape::hb_DownPolyNumbers ( void  )
protected

Definition at line 715 of file hedgebanks.cpp.

References HB_MAGIC, hb_map, hb_size, hb_width, m_elems, m_polymapping, SV_UINT32, SV_UINT8, and tole_Foobar.

Referenced by hb_Add().

716 {
717  for ( int i=0; i<hb_size; i++ ) {
718  if ( hb_map[ i ] >= HB_MAGIC ) {
719  hb_map[ i ] -= HB_MAGIC;
720  }
721  }
722 }
#define HB_MAGIC
Definition: hedgebanks.cpp:38
int * hb_map
Definition: landscape.h:246
int hb_size
Definition: landscape.h:249
bool Landscape::hb_FindBoundingBox ( int  a_poly_num)
protected

Definition at line 243 of file hedgebanks.cpp.

References hb_height, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

244 {
245  hb_min_x = hb_width + 1;
246  hb_max_x = -1;
247 
248  hb_min_y = hb_height + 1;
249  hb_max_y = -1;
250 
251  bool l_found = false;
252 
253  // Search for every pixel which belongs to the current polygon, and
254  // min and max values for x and y. Values are inclusive.
255  for ( int l_y=0; l_y<hb_height; l_y++ ) {
256  for ( int l_x=0; l_x<hb_width; l_x++ ) {
257  if ( hb_map[ l_y*hb_width + l_x ] == a_poly_num ) {
258  l_found = true;
259  if ( l_x < hb_min_x)
260  hb_min_x = l_x;
261  else if ( l_x > hb_max_x)
262  hb_max_x = l_x;
263  if ( l_y < hb_min_y)
264  hb_min_y = l_y;
265  else if ( l_y > hb_max_y)
266  hb_max_y = l_y;
267  }
268  }
269  }
270 
271  return l_found;
272 }
int hb_max_x
Definition: landscape.h:250
int hb_height
Definition: landscape.h:248
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
int hb_min_y
Definition: landscape.h:251
void Landscape::hb_FindHedges ( void  )
protected

Definition at line 276 of file hedgebanks.cpp.

References hb_hedges, m_elems, and tole_Hedges.

Referenced by hb_Add().

277 {
278  for ( unsigned int i=0; i<m_elems.size(); i++ ) {
279  if ( tole_Hedges == m_elems[i]->GetElementType() ) {
280  hb_hedges.resize( hb_hedges.size() + 1 );
281  hb_hedges[ hb_hedges.size() - 1 ] =
282  m_elems[i]->GetPoly();
283  }
284  }
285 }
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 > hb_hedges
Definition: landscape.h:241
void Landscape::hb_GenerateHBPolys ( void  )
protected

Definition at line 180 of file hedgebanks.cpp.

References hb_first_free_poly_num, hb_new_hbs, l_map_art_hb_nums, m_elems, m_polymapping, NewElement(), tole_HedgeBank, and CfgInt::value().

Referenced by hb_AddNewHedgebanks().

181 {
182  hb_new_hbs.resize( l_map_art_hb_nums.value() );
183 
184  for ( int i =0; i<l_map_art_hb_nums.value(); i++ ) {
186  hb_new_hbs[ i ]->SetArea( 0.0 );
187  hb_new_hbs[ i ]->SetSubType( i );
188  m_elems.resize( m_elems.size() + 1 );
189  m_elems[ m_elems.size() - 1 ] = hb_new_hbs[ i ];
191  (int) m_elems.size() - 1;
192  hb_new_hbs[ i ]->SetPoly( hb_first_free_poly_num++ );
193  }
194 }
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< LE * > hb_new_hbs
Definition: landscape.h:242
static CfgInt l_map_art_hb_nums("MAP_ART_HB_NUMS", CFG_CUSTOM, 3)
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
int value(void)
Definition: configurator.h:92
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3455
bool Landscape::hb_HasNeighbourColor ( int  a_x,
int  a_y,
int  a_neighbour_color 
)
inlineprotected

Definition at line 452 of file hedgebanks.cpp.

References hb_height, hb_map, and hb_width.

Referenced by hb_PaintWhoHasNeighbourColor().

454 {
455  bool l_neighbour_has_color = false;
456  bool loop=false;
457 
458  do {
459  a_x -= 1;
460  a_y -= 1;
461  if ( a_x >= 0 && a_y >= 0 &&
462  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
463  l_neighbour_has_color = true;
464  break;
465  }
466 
467  a_x++;
468  if ( hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
469  l_neighbour_has_color = true;
470  break;
471  }
472 
473  a_x++;
474  if ( a_x < hb_width &&
475  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
476  l_neighbour_has_color = true;
477  break;
478  }
479 
480  a_x -= 2;
481  a_y += 1;
482  if ( a_x >= 0 &&
483  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
484  l_neighbour_has_color = true;
485  break;
486  }
487 
488  a_x += 2;
489  if ( a_x < hb_width &&
490  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
491  l_neighbour_has_color = true;
492  break;
493  }
494 
495  a_x -= 2;
496  a_y += 1;
497 
498  if ( a_y >= hb_height )
499  break;
500 
501  if ( a_x >= 0 &&
502  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
503  l_neighbour_has_color = true;
504  break;
505  }
506 
507  a_x++;
508  if ( hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
509  l_neighbour_has_color = true;
510  break;
511  }
512 
513  a_x++;
514  if ( a_x < hb_width &&
515  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
516  l_neighbour_has_color = true;
517  break;
518  }
519  } while ( loop ); // was while (false) CJT 16-05-06
520 
521  return l_neighbour_has_color;
522 }
int hb_height
Definition: landscape.h:248
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
bool Landscape::hb_HasOtherNeighbour ( int  a_x,
int  a_y 
)
inlineprotected

Definition at line 339 of file hedgebanks.cpp.

References HB_MAGIC, hb_map, hb_MapBorder(), and hb_width.

Referenced by hb_PaintBorder().

340 {
341  bool l_has_neighbour = false;
342  bool loop=false;
343 
344  // Who said C++ needs the goto statement? ;-)
345  do {
346  a_x -= 1;
347  a_y -= 1;
348 
349  if ( hb_MapBorder( a_x, a_y ) ||
350  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
351  l_has_neighbour = true;
352  break;
353  }
354 
355  a_x++;
356  if ( hb_MapBorder( a_x, a_y ) ||
357  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
358  l_has_neighbour = true;
359  break;
360  }
361 
362  a_x++;
363  if ( hb_MapBorder( a_x, a_y ) ||
364  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
365  l_has_neighbour = true;
366  break;
367  }
368 
369  a_x -= 2;
370  a_y += 1;
371  if ( hb_MapBorder( a_x, a_y ) ||
372  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
373  l_has_neighbour = true;
374  break;
375  }
376 
377  a_x += 2;
378  if ( hb_MapBorder( a_x, a_y ) ||
379  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
380  l_has_neighbour = true;
381  break;
382  }
383 
384  a_x -= 2;
385  a_y += 1;
386 
387  if ( hb_MapBorder( a_x, a_y ) ||
388  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
389  l_has_neighbour = true;
390  break;
391  }
392 
393  a_x++;
394  if ( hb_MapBorder( a_x, a_y ) ||
395  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
396  l_has_neighbour = true;
397  break;
398  }
399 
400  a_x++;
401  if ( hb_MapBorder( a_x, a_y ) ||
402  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
403  l_has_neighbour = true;
404  break;
405  }
406  } while ( loop ); // was while (false) CJT 16-05-06
407 
408  return l_has_neighbour;
409 }
#define HB_MAGIC
Definition: hedgebanks.cpp:38
int * hb_map
Definition: landscape.h:246
bool hb_MapBorder(int a_x, int a_y)
Definition: hedgebanks.cpp:325
int hb_width
Definition: landscape.h:247
bool Landscape::hb_MapBorder ( int  a_x,
int  a_y 
)
inlineprotected

Definition at line 325 of file hedgebanks.cpp.

References hb_height, and hb_width.

Referenced by hb_HasOtherNeighbour().

326 {
327  if ( a_x < 0 ||
328  a_y < 0 ||
329  a_x >= hb_width ||
330  a_y >= hb_height ) {
331  return true;
332  }
333 
334  return false;
335 }
int hb_height
Definition: landscape.h:248
int hb_width
Definition: landscape.h:247
void Landscape::hb_MarkTheBresenhamWay ( void  )
protected

Definition at line 629 of file hedgebanks.cpp.

References HB_MAGIC, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, hb_width, l_map_art_hb_seg_len, l_map_art_hb_width, and CfgFloat::value().

Referenced by hb_Add().

630 {
631  double l_hb = l_map_art_hb_width.value()*10000.0;
632  double l_up = 10000.0 - l_hb;
633  bool l_is_hb = true;
634  double l_length = (double)(random( (int)l_hb )) * 0.0001 *
636  double l_hb_remain = 0.0;
637  double l_up_remain = 0.0;
638 
639  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++) {
640  // Note: The missing update of l_x below is intentional.
641  for ( int l_x=hb_min_x; l_x<=hb_max_x; ) {
642  int l_coord = l_y*hb_width + l_x;
643  if ( hb_map[ l_coord ] < HB_MAGIC ) {
644  // 'Painting' with a negative value turns a pixel into
645  // hedgebank 'core', ie. hedge!
646 
647  // Paint segment length with appropriate type.
648  if ( l_length >= 1.0 ) {
649  if ( l_is_hb ) {
650  hb_map[ l_coord ] = 0;
651  } else {
652  hb_map[ l_coord ] = -1;
653  }
654  l_length -= 1.0;
655  l_x++;
656  } else {
657  // Change state.
658  if ( l_is_hb ) {
659  l_is_hb = false;
660  l_hb_remain = l_length;
661  l_length = (double)(random( (int)l_up )) * 0.0001 *
662  l_map_art_hb_seg_len.value() + l_up_remain;
663  } else {
664  l_is_hb = true;
665  l_up_remain = l_length;
666  l_length = (double)(random( (int)l_hb )) * 0.0001 *
667  l_map_art_hb_seg_len.value() + l_hb_remain;
668  }
669  }
670  } else {
671  // Pixel not part of the hedge, just update the coordinate.
672  l_x++;
673  }
674  }
675  }
676 }
int hb_max_x
Definition: landscape.h:250
double value(void)
Definition: configurator.h:107
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
#define HB_MAGIC
Definition: hedgebanks.cpp:38
int * hb_map
Definition: landscape.h:246
static CfgFloat l_map_art_hb_width("MAP_ART_HB_WIDTH", CFG_CUSTOM, 0.3)
int hb_width
Definition: landscape.h:247
static CfgFloat l_map_art_hb_seg_len("MAP_ART_HB_SEG_LEN", CFG_CUSTOM, 100.0)
int hb_min_y
Definition: landscape.h:251
void Landscape::hb_MarkTopFromLocalMax ( int  a_color)
protected

Definition at line 679 of file hedgebanks.cpp.

References HB_MAGIC_PAINTER_BIT, hb_map, hb_max_x, hb_max_y, hb_MaxUnpaintedNegNeighbour(), hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

680 {
681  // Sweep through the map. If we find a pixel, which has a value
682  // equal to a_color and *not* a negative neighbour, then mark it as
683  // negative with an absolute value equal to the number of steps from
684  // here and out to the center/perimeter polygons border, calculated
685  // as the given percentage.
686 
687  // If one or more negative numbers are found among the neighbours,
688  // some that were not marked during this round, then assign a
689  // negative value equal to the minimum found plus one.
690 
691  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
692  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
693  int l_coord = l_y*hb_width + l_x;
694  int l_max;
695  if ( hb_map[ l_coord ] == a_color ) {
696  l_max = hb_MaxUnpaintedNegNeighbour( l_x, l_y );
697  if ( l_max < 0 ) {
698  if ( ++l_max < 0 ) {
699  hb_map[ l_coord ] = l_max;
700  } else {
701  // l_max was precisely -1
702  hb_map[ l_coord ] = -1;
703  }
704  } else {
705  // We are a local maxima.
706  hb_map[ l_coord ] = -a_color;
707  }
708  hb_map[ l_coord ] ^= HB_MAGIC_PAINTER_BIT;
709  }
710  }
711  }
712 }
#define HB_MAGIC_PAINTER_BIT
Definition: hedgebanks.cpp:40
int hb_max_x
Definition: landscape.h:250
int hb_MaxUnpaintedNegNeighbour(int a_x, int a_y)
Definition: hedgebanks.cpp:548
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
int hb_min_y
Definition: landscape.h:251
int Landscape::hb_MaxUnpaintedNegNeighbour ( int  a_x,
int  a_y 
)
inlineprotected

Definition at line 548 of file hedgebanks.cpp.

References hb_height, HB_MAGIC_PAINTER_BIT, hb_map, and hb_width.

Referenced by hb_MarkTopFromLocalMax().

550 {
551  int l_max_neg = 0;
552  int l_val;
553  bool loop=false; // This is just to avoid the warning about constant expression if we use: do {...} while (false)
554 
555  do {
556  a_x -= 1;
557  a_y -= 1;
558  if ( a_x >= 0 && a_y >= 0 ) {
559  l_val = hb_map[ a_x + a_y*hb_width ];
560  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
561  l_max_neg = l_val;
562  }
563  }
564 
565  a_x++;
566  l_val = hb_map[ a_x + a_y*hb_width ];
567  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
568  l_max_neg = l_val;
569  }
570 
571  a_x++;
572  if ( a_x < hb_width ) {
573  l_val = hb_map[ a_x + a_y*hb_width ];
574  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
575  l_max_neg = l_val;
576  }
577  }
578 
579  a_x -= 2;
580  a_y += 1;
581  if ( a_x >= 0 ) {
582  l_val = hb_map[ a_x + a_y*hb_width ];
583  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
584  l_max_neg = l_val;
585  }
586  }
587 
588  a_x += 2;
589  if ( a_x < hb_width ) {
590  l_val = hb_map[ a_x + a_y*hb_width ];
591  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
592  l_max_neg = l_val;
593  }
594  }
595 
596  a_x -= 2;
597  a_y += 1;
598 
599  if ( a_y >= hb_height )
600  break;
601 
602  if ( a_x >= 0 ) {
603  l_val = hb_map[ a_x + a_y*hb_width ];
604  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
605  l_max_neg = l_val;
606  }
607  }
608 
609  a_x++;
610  l_val = hb_map[ a_x + a_y*hb_width ];
611  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
612  l_max_neg = l_val;
613  }
614 
615  a_x++;
616  if ( a_x < hb_width ) {
617  l_val = hb_map[ a_x + a_y*hb_width ];
618  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
619  l_max_neg = l_val;
620  }
621  }
622  } while ( loop );
623 
624  return l_max_neg;
625 }
#define HB_MAGIC_PAINTER_BIT
Definition: hedgebanks.cpp:40
int hb_height
Definition: landscape.h:248
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
void Landscape::hb_PaintBorder ( int  a_color)
protected

Definition at line 429 of file hedgebanks.cpp.

References hb_border_pixels, hb_core_pixels, hb_HasOtherNeighbour(), HB_MAGIC_COLOR, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

430 {
431  hb_border_pixels = 0;
432  hb_core_pixels = 0;
433  // Paint every pixel which belongs to the current polygon, and which
434  // does have a neighbour *not* equal to HB_MAGIC_COLOR (our marker value).
435  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
436  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
437  int l_coord = l_y*hb_width + l_x;
438  if ( hb_map[ l_coord ] == HB_MAGIC_COLOR ) {
439  if ( hb_HasOtherNeighbour( l_x, l_y )) {
440  hb_map[ l_coord ] = a_color;
442  } else {
443  hb_core_pixels++;
444  }
445  }
446  }
447  }
448 }
int hb_core_pixels
Definition: landscape.h:253
bool hb_HasOtherNeighbour(int a_x, int a_y)
Definition: hedgebanks.cpp:339
int hb_max_x
Definition: landscape.h:250
#define HB_MAGIC_COLOR
Definition: hedgebanks.cpp:39
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
int hb_min_y
Definition: landscape.h:251
int hb_border_pixels
Definition: landscape.h:254
bool Landscape::hb_PaintWhoHasNeighbourColor ( int  a_neighbour_color,
int  a_new_color 
)
protected

Definition at line 526 of file hedgebanks.cpp.

References hb_HasNeighbourColor(), HB_MAGIC_COLOR, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

528 {
529  // Paint every pixel which belongs to the current polygon, and which
530  // has a neighbour with a color equal to a_neighbour_color.
531 
532  bool l_at_least_one = false;
533  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
534  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
535  if ( hb_map[l_y*hb_width + l_x] == HB_MAGIC_COLOR &&
536  hb_HasNeighbourColor( l_x, l_y, a_neighbour_color )) {
537  hb_map[l_y*hb_width + l_x] = a_new_color;
538  l_at_least_one = true;
539  }
540  }
541  }
542 
543  return l_at_least_one;
544 }
int hb_max_x
Definition: landscape.h:250
bool hb_HasNeighbourColor(int a_x, int a_y, int a_neighbour_color)
Definition: hedgebanks.cpp:452
#define HB_MAGIC_COLOR
Definition: hedgebanks.cpp:39
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
int hb_min_y
Definition: landscape.h:251
void Landscape::hb_ResetColorBits ( void  )
protected

Definition at line 298 of file hedgebanks.cpp.

References HB_MAGIC_PAINTER_BIT, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

299 {
300  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
301  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
302  int l_coord = l_y*hb_width + l_x;
303  if ( hb_map[l_coord] < 0 )
304  hb_map[l_coord] |= HB_MAGIC_PAINTER_BIT;
305  }
306  }
307 }
#define HB_MAGIC_PAINTER_BIT
Definition: hedgebanks.cpp:40
int hb_max_x
Definition: landscape.h:250
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
int hb_min_y
Definition: landscape.h:251
void Landscape::hb_RestoreHedgeCore ( int  a_orig_poly_number)
protected

Definition at line 311 of file hedgebanks.cpp.

References hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

312 {
313  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
314  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
315  int l_coord = l_y*hb_width + l_x;
316  if ( hb_map[l_coord] < 0 ) {
317  hb_map[l_coord] = a_orig_poly_number;
318  }
319  }
320  }
321 }
int hb_max_x
Definition: landscape.h:250
int hb_min_x
Definition: landscape.h:250
int hb_max_y
Definition: landscape.h:251
int * hb_map
Definition: landscape.h:246
int hb_width
Definition: landscape.h:247
int hb_min_y
Definition: landscape.h:251
int Landscape::hb_StripingDist ( void  )
protected

Definition at line 225 of file hedgebanks.cpp.

References LE::GetPoly(), hb_new_hbs, l_map_art_hb_nums, l_map_art_hb_tran_prob, and CfgInt::value().

Referenced by hb_AddNewHedgebanks().

226 {
227  // Striping distribution function for the new hedgebanks.
228  static LE* l_curr_ele = NULL;
229 
230  if ( !l_curr_ele ) {
231  l_curr_ele = hb_new_hbs[ random( l_map_art_hb_nums.value()) ];
232  return l_curr_ele->GetPoly();
233  }
234 
235  if ( random(100) < l_map_art_hb_tran_prob.value() )
236  l_curr_ele = hb_new_hbs[ random( l_map_art_hb_nums.value()) ];
237 
238  return l_curr_ele->GetPoly();
239 }
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: elements.h:189
vector< LE * > hb_new_hbs
Definition: landscape.h:242
static CfgInt l_map_art_hb_tran_prob("MAP_ART_HB_TRAN_PROB", CFG_CUSTOM, 30)
static CfgInt l_map_art_hb_nums("MAP_ART_HB_NUMS", CFG_CUSTOM, 3)
Definition: elements.h:81
int value(void)
Definition: configurator.h:92
void Landscape::hb_UpPolyNumbers ( void  )
protected

Definition at line 289 of file hedgebanks.cpp.

References HB_MAGIC, hb_map, and hb_size.

Referenced by hb_Add().

290 {
291  for ( int i=0; i<hb_size; i++ ) {
292  hb_map[ i ] += HB_MAGIC;
293  }
294 }
#define HB_MAGIC
Definition: hedgebanks.cpp:38
int * hb_map
Definition: landscape.h:246
int hb_size
Definition: landscape.h:249
int Landscape::HowManyPonds ( )
inline

Returns the number of ponds in the landscape.

Definition at line 315 of file landscape.h.

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

Definition at line 3339 of file Landscape.cpp.

References g_msg, last_treatment, MapErrorMsg::Warn(), and WARN_BUG.

Referenced by LE::SetLastTreatment().

3339  {
3340  if (a_treat < 0 || a_treat >= last_treatment) {
3341  char errornum[20];
3342  sprintf(errornum, "%d", a_treat);
3343  g_msg->Warn(WARN_BUG, "Landscape::IncTreatCounter(): Index"" out of range!", errornum);
3344  exit(1);
3345  }
3346  m_treatment_counts[a_treat] ++;
3347 }
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
int m_treatment_counts[last_treatment]
Definition: landscape.h:171
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
bool Landscape::IsFieldType ( TTypesOfLandscapeElement  a_tole)
inline
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

Definition at line 439 of file Landscape.cpp.

References tole_HedgeBank, tole_LargeRoad, and tole_SmallRoad.

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;
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:1031
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:421
TTypesOfLandscapeElement
int Landscape::MagicMapP2PolyRef ( int  a_magic)
inline

Definition at line 1442 of file landscape.h.

1443 {
1444  return m_elems[ a_magic ]->GetPoly();
1445 }
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

Definition at line 3455 of file Landscape.cpp.

References g_msg, LE::SetALMaSSEleType(), LE::SetElementType(), tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_BeetleBank, tole_Building, tole_BuiltUpWithParkland, tole_Carpark, tole_Chameleon, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_Field, tole_FieldBoundary, tole_FishFarm, tole_Freshwater, tole_Garden, tole_Heath, tole_HedgeBank, tole_Hedges, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_Missing, tole_MixedForest, tole_MownGrass, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_Orchard, tole_OrchardBand, tole_Parkland, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideSlope, tole_RoadsideVerge, tole_Saltmarsh, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UnsprayedFieldMargin, tole_UrbanNoVeg, tole_UrbanPark, tole_Vildtager, tole_Wasteland, tole_WindTurbine, tole_WoodlandMargin, tole_WoodyEnergyCrop, tole_YoungForest, MapErrorMsg::Warn(), and WARN_FILE.

Referenced by hb_GenerateHBPolys().

3455  {
3456  LE * elem;
3457  static char error_num[20];
3458 
3459  switch (a_type) {
3460  case tole_Hedges:
3461  elem = new Hedges;
3462  break;
3463  case tole_HedgeBank:
3464  elem = new HedgeBank;
3465  elem->SetALMaSSEleType(140);
3466  break;
3467  case tole_BeetleBank:
3468  elem = new BeetleBank;
3469  elem->SetALMaSSEleType(141);
3470  break;
3471  case tole_RoadsideVerge:
3472  elem = new RoadsideVerge;
3473  break;
3474  case tole_Railway:
3475  elem = new Railway;
3476  break;
3477  case tole_FieldBoundary:
3478  elem = new FieldBoundary;
3479  elem->SetALMaSSEleType(160);
3480  break;
3481  case tole_Marsh:
3482  elem = new Marsh;
3483  break;
3484  case tole_Orchard:
3485  elem = new Orchard;
3486  break;
3487  case tole_OrchardBand:
3488  elem = new OrchardBand;
3489  break;
3490  case tole_MownGrass:
3491  elem = new MownGrass;
3492  break;
3493  case tole_Heath:
3494  elem = new Heath;
3495  break;
3496  case tole_Scrub:
3497  elem = new Scrub;
3498  break;
3499  case tole_Field:
3500  elem = new Field;
3501  break;
3503  elem = new PermanentSetaside;
3504  break;
3505  case tole_PermPasture:
3506  elem = new PermPasture;
3507  break;
3509  elem = new PermPastureLowYield;
3510  break;
3512  elem = new PermPastureTussocky;
3513  break;
3514  case tole_NaturalGrassDry:
3515  elem = new NaturalGrassDry;
3516  break;
3517  case tole_RiversidePlants:
3518  elem = new RiversidePlants;
3519  break;
3520  case tole_PitDisused:
3521  elem = new PitDisused;
3522  break;
3523  case tole_RiversideTrees:
3524  elem = new RiversideTrees;
3525  break;
3526  case tole_DeciduousForest:
3527  elem = new DeciduousForest;
3528  break;
3529  case tole_MixedForest:
3530  elem = new MixedForest;
3531  break;
3532  case tole_YoungForest:
3533  elem = new YoungForest;
3534  break;
3535  case tole_ConiferousForest:
3536  elem = new ConiferousForest;
3537  break;
3538  case tole_StoneWall:
3539  elem = new StoneWall;
3540  break;
3541  case tole_Garden:
3542  elem = new Garden;
3543  break;
3544  case tole_Track:
3545  elem = new Track;
3546  break;
3547  case tole_SmallRoad:
3548  elem = new SmallRoad;
3549  break;
3550  case tole_LargeRoad:
3551  elem = new LargeRoad;
3552  break;
3553  case tole_Building:
3554  elem = new Building;
3555  break;
3556  case tole_ActivePit:
3557  elem = new ActivePit;
3558  break;
3559  case tole_Freshwater:
3560  elem = new Freshwater;
3561  break;
3562  case tole_Pond:
3563  elem = new Pond;
3564  break;
3565  case tole_River:
3566  elem = new River;
3567  break;
3568  case tole_Saltwater:
3569  elem = new Saltwater;
3570  break;
3571  case tole_Coast:
3572  elem = new Coast;
3573  break;
3574  case tole_BareRock:
3575  elem = new BareRock;
3576  break;
3577  case tole_AmenityGrass:
3578  elem = new AmenityGrass;
3579  break;
3580  case tole_Parkland:
3581  elem = new Parkland;
3582  break;
3583  case tole_UrbanNoVeg:
3584  elem = new UrbanNoVeg;
3585  break;
3586  case tole_UrbanPark:
3587  elem = new UrbanPark;
3588  break;
3590  elem = new BuiltUpWithParkland;
3591  break;
3592  case tole_SandDune:
3593  elem = new SandDune;
3594  break;
3595  case tole_Copse:
3596  elem = new Copse;
3597  break;
3598  case tole_RoadsideSlope:
3599  elem = new RoadsideSlope;
3600  break;
3601  case tole_MetalledPath:
3602  elem = new MetalledPath;
3603  break;
3604  case tole_Carpark:
3605  elem = new Carpark;
3606  break;
3607  case tole_Churchyard:
3608  elem = new Churchyard;
3609  break;
3610  case tole_NaturalGrassWet:
3611  elem = new NaturalGrassWet;
3612  break;
3613  case tole_Saltmarsh:
3614  elem = new Saltmarsh;
3615  break;
3616  case tole_Stream:
3617  elem = new Stream;
3618  break;
3619  case tole_HeritageSite:
3620  elem = new HeritageSite;
3621  break;
3623  elem = new UnsprayedFieldMargin;
3624  elem->SetALMaSSEleType(31);
3625  break;
3626  case tole_Wasteland:
3627  elem = new Wasteland;
3628  break;
3629  case tole_IndividualTree:
3630  elem = new IndividualTree;
3631  break;
3632  case tole_PlantNursery:
3633  elem = new PlantNursery;
3634  break;
3635  case tole_Vildtager:
3636  elem = new Vildtager;
3637  break;
3638  case tole_WindTurbine:
3639  elem = new WindTurbine;
3640  break;
3641  case tole_WoodyEnergyCrop:
3642  elem = new WoodyEnergyCrop;
3643  break;
3644  case tole_WoodlandMargin:
3645  elem = new WoodlandMargin;
3646  break;
3647  case tole_Pylon:
3648  elem = new Pylon;
3649  break;
3650  case tole_FishFarm:
3651  elem = new FishFarm;
3652  break;
3653  case tole_Missing:
3654  elem = new LE; // These should never be actually used.
3655  break;
3656  case tole_Chameleon:
3657  elem = new ChameleonLE;
3658  break;
3659  default:
3660  sprintf(error_num, "%d", a_type);
3661  g_msg->Warn(WARN_FILE, "Landscape::NewElement(): Unknown landscape element requested:", error_num);
3662  exit(1);
3663  } //switch
3664 
3665  elem->SetElementType(a_type);
3666 
3667  return elem;
3668 }
void SetElementType(int a_type)
Definition: elements.h:114
Definition: elements.h:81
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1082
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
void Landscape::PolysDump ( const char *  a_filename)
protected

Definition at line 1612 of file Landscape.cpp.

References g_msg, MapErrorMsg::Warn(), and WARN_FILE.

1613 {
1614  ofstream outf(a_filename, ios::out);
1615  int l_num_polys = 0;
1616 
1617  if (!outf.is_open()) {
1618  g_msg->Warn(WARN_FILE, "Landscape::PolysDump(): Unable to open file", a_filename);
1619  exit(1);
1620  }
1621 
1622  // Count up number if active polygons in our list.
1623  unsigned sz = (unsigned)m_elems.size();
1624  for (unsigned int i = 0; i < sz; i++) {
1625  if (m_elems[i]->GetMapValid())
1626  l_num_polys++;
1627  }
1628 
1629  outf << l_num_polys << endl;
1630  outf << "PolyType" << '\t' << "PolyRefNum" << '\t' << "Area" << '\t' << "FarmRef" << '\t' << "UnSprayedMarginRef" << '\t' << "SoilType" << '\t' << "Openness" << '\t' << "CentroidX" << '\t' << "CentroidY" << endl;
1631 
1632  /*
1633  if ( l_map_renumberpolys.value() )
1634  {
1635  RenumberPolys( true );
1636  }
1637  */
1638  // Now we can output the file
1639  for (unsigned int i = 0; i < m_elems.size(); i++)
1640  {
1641  if (m_elems[i]->GetMapValid())
1642  {
1643  outf << m_elems[i]->GetALMaSSEleType() << '\t' << m_elems[i]->GetPoly() << '\t' << m_elems[i]->GetArea() << '\t' <<
1644  m_elems[i]->GetOwnerFile() << '\t' << m_elems[i]->GetUnsprayedMarginPolyRef() << '\t' << m_elems[i]->GetSoilType() << '\t' << m_elems[i]->GetOpenness()
1645  << '\t' << m_elems[i]->GetCentroidX() << '\t' << m_elems[i]->GetCentroidY() << endl;
1646  }
1647  }
1648  outf.close();
1649 }
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
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
void Landscape::PolysRemoveInvalid ( void  )
protected

PolysValidate or ChangeMapMapping must be called after this method

Definition at line 1584 of file Landscape.cpp.

1585 {
1589  vector < LE * > l_temp;
1590  cout << "Tidying up the polygon map in PolysRemoveInvalid" << endl;
1591  unsigned int sz= (int) m_elems.size();
1592  for ( unsigned int i = 0; i < sz; i++ ) {
1593  if ( m_elems[ i ]->GetMapValid() ) {
1594  unsigned int j = (int) l_temp.size();
1595  l_temp.resize( j + 1 );
1596  l_temp[ j ] = m_elems[ i ];
1597  } else {
1598  // cout << "Deleted m_elems index:" << m_polymapping[ m_elems[ i ]->GetPoly() ] << " Polynumber :" << m_elems[ i ]->GetPoly() << BackTranslateEleTypes(m_elems[ i ]->GetElementType()) << endl;
1599  m_polymapping[ m_elems[ i ]->GetPoly() ] = -1;
1600  delete m_elems[ i ];
1601  }
1602  }
1603 
1604  for ( unsigned int i = 0; i < l_temp.size(); i++ ) {
1605  m_elems[ i ] = l_temp[ i ];
1606  }
1607  m_elems.resize( l_temp.size() );
1609 }
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

Definition at line 1871 of file Landscape.cpp.

References g_msg, MapErrorMsg::Warn(), and WARN_FILE.

1872 {
1873  cout << "In Landscape::Landscape() Polygon renumber." << endl;
1874  for (unsigned int i = 0; i < m_elems.size(); i++)
1875  {
1876  // Need to reset the poly number
1877  int index = m_elems[i]->GetMapIndex(); // This is the number currently in the map matrix
1878  m_elems[i]->SetPoly(index); // The map index and the polygon number are now one and the same
1879  m_polymapping[index] = i; // The polymapping is now linked via index to the m_elems index (i)
1880  }
1881  m_LargestPolyNumUsed = (int) m_elems.size()-1;
1882  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Map to be dumped due to polygon renumber", "");
1883 }
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
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
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 Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
int m_LargestPolyNumUsed
Definition: landscape.h:172
void Landscape::PolysValidate ( bool  a_exit_on_invalid)
protected

Definition at line 1557 of file Landscape.cpp.

References g_msg, MapErrorMsg::Warn(), and WARN_FILE.

1557  {
1558  // 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
1559  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1560  m_elems[ i ]->SetMapValid( false );
1561  if ( m_polymapping[ m_elems[ i ]->GetPoly() ] == -1 ) {
1562  char l_err[ 20 ];
1563  sprintf( l_err, "%d", m_elems[ i ]->GetPoly() );
1564  g_msg->Warn( WARN_FILE, "Landscape::PolysValidate(): Invalid polymapping ", l_err );
1565  exit( 1 );
1566  }
1567  }
1568  // Now go through the whole map and for each polygon found set MapValid as true.
1570 
1571  if ( a_exit_on_invalid ) {
1572  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1573  if ( !m_elems[ i ]->GetMapValid() ) {
1574  char l_err[ 20 ];
1575  sprintf( l_err, "%d", m_elems[ i ]->GetPoly() );
1576  g_msg->Warn( WARN_FILE, "Landscape::PolysValidate(): Invalid polygon ", l_err );
1577  exit( 0 );
1578  }
1579  }
1580  }
1581 }
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:1434
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
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 Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
std::string Landscape::PolytypeToString ( TTypesOfLandscapeElement  a_le_type)

Definition at line 3801 of file Landscape.cpp.

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

Referenced by hb_Add().

3801  {
3802  char error_num[20];
3803 
3804  switch (a_le_type) {
3805  case tole_Hedges:
3806  return " Hedge";
3807  case tole_RoadsideVerge:
3808  return " Roadside Verge";
3809  case tole_Railway:
3810  return " Railway";
3811  case tole_FieldBoundary:
3812  return " Field Boundary";
3813  case tole_Marsh:
3814  return " Marsh";
3815  case tole_Scrub:
3816  return " Scrub";
3817  case tole_Field:
3818  return " Field";
3820  return " PermPastureTussocky";
3822  return " Permanent Setaside";
3823  case tole_PermPasture:
3824  return " Permanent Pasture";
3826  return " PermPastureLowYield";
3827  case tole_NaturalGrassDry:
3828  return " Natural Grass";
3829  case tole_NaturalGrassWet:
3830  return " Natural Grass Wet";
3831  case tole_RiversidePlants:
3832  return " Riverside Plants";
3833  case tole_PitDisused:
3834  return " Pit Disused";
3835  case tole_RiversideTrees:
3836  return " Riverside Trees";
3837  case tole_DeciduousForest:
3838  return " Deciduous Forest";
3839  case tole_MixedForest:
3840  return " Mixed Forest";
3841  case tole_ConiferousForest:
3842  return " Coniferous Forest";
3843  case tole_YoungForest:
3844  return " Young Forest";
3845  case tole_StoneWall:
3846  return " Stone Wall";
3847  case tole_Garden:
3848  return " Garden";
3849  case tole_Track:
3850  return " Track";
3851  case tole_SmallRoad:
3852  return " Small Road";
3853  case tole_LargeRoad:
3854  return " Large Road";
3855  case tole_Building:
3856  return " Building";
3857  case tole_ActivePit:
3858  return " Active Pit";
3859  case tole_Pond:
3860  return " Pond";
3861  case tole_Freshwater:
3862  return " Fresh Water";
3863  case tole_River:
3864  return " River";
3865  case tole_Saltwater:
3866  return " Saltwater";
3867  case tole_Coast:
3868  return " Coast";
3869  case tole_BareRock:
3870  return " Bare Rock";
3871  case tole_HedgeBank:
3872  return " Hedgebank";
3873  case tole_Heath:
3874  return " Heath";
3875  case tole_Orchard:
3876  return " Orchard";
3877  case tole_OrchardBand:
3878  return " Orchard Band";
3879  case tole_MownGrass:
3880  return " Mown Grass";
3882  return " UnsprayedFieldMargin";
3883  case tole_AmenityGrass:
3884  return " AmenityGrass";
3885  case tole_Parkland:
3886  return " Parkland";
3887  case tole_UrbanNoVeg:
3888  return " UrbanNoVeg";
3889  case tole_UrbanPark:
3890  return " UrbanPark";
3892  return " BuiltUpWithParkland";
3893  case tole_SandDune:
3894  return " SandDune";
3895  case tole_Copse:
3896  return " Copse";
3897  case tole_RoadsideSlope:
3898  return " RoadsideSlope";
3899  case tole_MetalledPath:
3900  return " MetalledPath";
3901  case tole_Carpark:
3902  return " Carpark";
3903  case tole_Churchyard:
3904  return " Churchyard";
3905  case tole_Saltmarsh:
3906  return " Saltmarsh";
3907  case tole_Stream:
3908  return " Stream";
3909  case tole_HeritageSite:
3910  return " HeritageSite";
3911  case tole_BeetleBank: //141
3912  return " Beetle Bank";
3913  case tole_UnknownGrass:
3914  return " Unknown Grass";
3915  case tole_Wasteland:
3916  return " Waste/Building Land";
3917  case tole_IndividualTree:
3918  return " IndividualTree";
3919  case tole_PlantNursery:
3920  return " PlantNursery";
3921  case tole_Vildtager:
3922  return " Vildtager";
3923  case tole_WindTurbine:
3924  return " WindTurbine";
3925  case tole_WoodyEnergyCrop:
3926  return " WoodyEnergyCrop";
3927  case tole_WoodlandMargin:
3928  return " WoodlandMargin";
3929  case tole_Pylon:
3930  return " Pylon";
3931  case tole_FishFarm:
3932  return " FishFarm";
3933  case tole_Foobar:
3934  default:
3935  sprintf(error_num, "%d", a_le_type);
3936  g_msg->Warn(WARN_FILE, "Landscape::PolytypeToString(): Unknown event type:", error_num);
3937  exit(1);
3938  }
3939 }
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
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.

Definition at line 1701 of file Landscape.cpp.

References g_letype, g_map_le_border_chance, g_map_le_borders, g_map_le_unsprayedmargins, g_map_le_unsprayedmargins_chance, g_msg, LE::GetElementType(), l_map_chameleon_replace_num, LE::SetALMaSSEleType(), LE::SetArea(), LE::SetBorder(), LE::SetCentroid(), LE::SetOpenness(), LE::SetPoly(), LE::SetSoilType(), LE::SetUnsprayedMarginPolyRef(), tole_Field, tole_Missing, tole_Orchard, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PlantNursery, tole_Vildtager, tole_WoodyEnergyCrop, tole_YoungForest, LE_TypeClass::TranslateEleTypes(), CfgInt::value(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_FILE.

1702 {
1709  // Need to figure out if the farms are already renumbered - as the Farm manager
1710  bool farmsrenum = m_FarmManager->GetIsRenumbered();
1711 
1712  int NoPolygons;
1713  string rubbish = ""; //put here the names of the parameters;
1714  ifstream ifile(a_polyfile);
1715  if (!ifile.is_open()) {
1716  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Unable to open file", a_polyfile);
1717  std::exit(1);
1718  }
1719  char error_num[20];
1720  // First read the number of polygons
1721  ifile >> NoPolygons;
1722  m_elems.resize(NoPolygons);
1724  for (int i = 0; i < 9; i++){ ifile >> rubbish; }
1728  int np = NoPolygons;
1729  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
1730  m_polymapping = (int *)malloc(sizeof(int)* (np * 2));
1731  // Test if we have the memory to do this
1732  if (m_polymapping == NULL)
1733  {
1734  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Out of memory!", "");
1735  std::exit(1);
1736  }
1737 
1738  // Set all mappings to unused.
1739  for (int i = 0; i < np * 2; i++) {
1740  m_polymapping[i] = -1;
1741  }
1742 
1743  int ElemIndex = 0;
1744 
1745  for (int x = 0; x < NoPolygons; x++)
1746  {
1747  int PolyNum, Owner, PolyType, RealPolyType, URef, SoilType, openness, Centroid_x, Centroid_y;
1749  float Area;
1750  ifile >> PolyType >> PolyNum >> Area >> Owner >> URef >> SoilType >> openness >> Centroid_x >> Centroid_y;
1751  // Here we make some tests to check input validity
1752  if ((SoilType > 16) || (PolyNum<0))
1753  {
1754  std::sprintf(error_num, "%d", NoPolygons);
1755  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Polygon file empty before "
1756  "reading number of specified polygons (old polygon file format?):", error_num);
1757  std::exit(1);
1758  }
1759 
1760  // 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.
1761  // Because we create this sequentially in Farm.cpp we have a constant index.
1762  if ((-1 != Owner) && !farmsrenum)
1763  {
1764  // Need to replace the Owner with the new renumbered ref.
1765  Owner = m_FarmManager->GetRenumberedFarmRef(Owner);
1766  }
1767 
1768  RealPolyType = PolyType;
1770  if (PolyType == 150)
1771  {
1772  PolyType = l_map_chameleon_replace_num.value();
1773  }
1774 
1775  Type = g_letype->TranslateEleTypes(PolyType);
1776  if (Type == tole_Missing)
1777  {
1779  }
1780  if (-1 == m_polymapping[PolyNum])
1781  {
1782  // First time we have encountered this polygon number.
1783  // Borders are not mapped in this list.
1784  m_polymapping[PolyNum] = ElemIndex;
1785  LE * newland = NewElement(Type);
1786  m_elems[ElemIndex++] = newland;
1787  newland->SetPoly(PolyNum);
1788  newland->SetArea(floor(0.5 + Area));
1789  newland->SetALMaSSEleType(RealPolyType);
1790  newland->SetSoilType(SoilType);
1791  newland->SetUnsprayedMarginPolyRef(URef);
1792  newland->SetCentroid(Centroid_x,Centroid_y);
1793  newland->SetOpenness(openness);
1794  // Just for fun, or maybe because we might need it later, remember the actual largest polynum used
1795  if (PolyNum>m_LargestPolyNumUsed) m_LargestPolyNumUsed = PolyNum;
1796  // Now set any centroid or openness recalcuation flags
1797  if ((Centroid_x < 0) || (Centroid_y < 0)) m_NeedCentroidCalculation= true;
1798  if (openness < 0) m_NeedOpennessCalculation = true;
1799  // Two types of possible errors: Landscape element that is a field,
1800  // but doesn't belong to a farm, or a farm element not of type field.
1801  // Check for both cases.
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  // No owner but field polygon.
1804  sprintf(error_num, "%d", PolyNum);
1805  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Farm polygon does not belong to a farm:", error_num);
1806  exit(1);
1807  }
1808  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) {
1809  // An owner but not field elements.
1810  sprintf(error_num, "%d", PolyNum);
1811  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Farm polygon does not have element type tole_Field:", error_num);
1812  exit(1);
1813  }
1814 
1815  if (-1 != Owner)
1816  {
1817  m_FarmManager->ConnectFarm(Owner);
1818  m_FarmManager->AddField(Owner, newland, Owner);
1819  if (g_map_le_borders.value())
1820  {
1821  if (random(100) < g_map_le_border_chance.value())
1822  {
1823  // This is a farm element, so signal adding a border.
1824  newland->SetBorder((LE *)1);
1825  }
1826  }
1827  // Code to generate unsprayed margins....
1828  if (newland->GetElementType() == tole_Field)
1829  {
1831  {
1832  if (random(100) < g_map_le_unsprayedmargins_chance.value())
1833  {
1834  // This is a farm field, so signal adding a margin
1835  newland->SetUnsprayedMarginPolyRef(1);
1836  }
1837  }
1838  }
1839  // ..to here
1840  }
1841  }
1842  else {
1843  sprintf(error_num, "%d", PolyNum);
1844  g_msg->Warn(WARN_FILE, "Landscape::ReadPolys(): Duplicate polygon in file", error_num);
1845  exit(1);
1846  }
1847  }
1848  ifile.close();
1850  hb_first_free_poly_num = m_elems[NoPolygons - 1]->GetPoly() + 1;
1851 }
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:316
Definition: elements.h:81
void AddField(int a_OwnerIndex, LE *a_newland, int a_Owner)
Definition: farm.cpp:2292
void SetBorder(LE *a_border)
Definition: elements.h:314
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: elements.cpp:2597
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
CfgInt g_map_le_unsprayedmargins_chance("MAP_LE_UMARGIN_CHANCE", CFG_CUSTOM, 25)
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
int ConnectFarm(int a_owner)
Definition: farm.cpp:2303
bool value(void)
Definition: configurator.h:123
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
int hb_first_free_poly_num
Definition: landscape.h:252
static CfgInt l_map_chameleon_replace_num("MAP_CHAMELEON_REPLACE_NUM", CFG_CUSTOM, 58)
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:368
CfgInt g_map_le_border_chance("MAP_LE_BORDER_CHANCE", CFG_CUSTOM, 25)
int value(void)
Definition: configurator.h:92
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
int GetRenumberedFarmRef(int a_farmref)
Returns the farm ref index for a farmref.
Definition: farm.h:1745
TTypesOfLandscapeElement
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
bool GetIsRenumbered()
Returns the flag for renumbering.
Definition: farm.h:1743
CfgBool g_map_le_borders("MAP_LE_BORDERS", CFG_CUSTOM, false)
CfgBool g_map_le_unsprayedmargins("MAP_LE_UNSPRAYEDMARGINS", CFG_CUSTOM, false)
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3455
int m_LargestPolyNumUsed
Definition: landscape.h:172
bool Landscape::ReadSymbols ( const char *  a_cfgfile)
inline

Definition at line 737 of file landscape.h.

References g_cfg, and Configurator::ReadSymbols().

737  {
738  return g_cfg->ReadSymbols( a_cfgfile );
739  }
bool ReadSymbols(const char *a_cfgfile)
class Configurator * g_cfg
void Landscape::RebuildPolyMapping ( )
inlineprotected

Definition at line 191 of file landscape.h.

References m_polymapping.

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

Definition at line 3106 of file Landscape.cpp.

3107 {
3113  int day = SupplyDayInYear();
3114  m_elems[m_polymapping[a_polyref]]->SetGooseNos(a_number, day);
3115 }
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:1522
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()

Definition at line 3119 of file Landscape.cpp.

3120 {
3125  int day = SupplyDayInYear();
3126  m_elems[m_polymapping[a_polyref]]->SetGooseNosTimed(a_number, day);
3127 }
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:1522
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

Definition at line 3130 of file Landscape.cpp.

3130  {
3137  int day = SupplyDayInYear();
3138  m_elems[m_polymapping[a_polyref]]->SetGooseSpNos(a_number, day, a_goose);
3139  }
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:1522
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()

Definition at line 3141 of file Landscape.cpp.

3141  {
3147  int day = SupplyDayInYear();
3148  m_elems[m_polymapping[a_polyref]]->SetGooseSpNosTimed(a_number, day, a_goose);
3149  }
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:1522
void Landscape::RemoveMissingValues ( void  )
protected

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

Definition at line 1904 of file Landscape.cpp.

References tole_Missing.

1905 {
1906  bool found; // the flag for something left to work with
1907  int mapwidth = m_land->MapWidth();
1908  int mapheight = m_land->MapHeight();
1909  int counter = 0;
1910  do
1911  {
1912  found = false; counter++;
1913  for (int x = 1; x < mapwidth-1; x++)
1914  {
1915  for (int y = 1; y < mapheight-1; y++)
1916  {
1917  int apoly = m_land->Get(x,y);
1918  if (m_elems[m_polymapping[apoly]]->GetElementType() == tole_Missing)
1919  {
1920  m_land->MissingCellReplace(x, y, true);
1921  }
1922  }
1923  }
1924  counter++;
1925  } while (counter<50);
1926  // Now we only have the edges to deal with
1927  for (int x = 0; x < mapwidth; x++)
1928  {
1929  for (int y = 0; y < mapheight; y++)
1930  {
1931  int apoly = m_land->Get(x, y);
1932  if (m_elems[m_polymapping[apoly]]->GetElementType() == tole_Missing)
1933  {
1934  found = true;
1935  counter++;
1936  m_land->MissingCellReplaceWrap(x, y, true);
1937  }
1938  }
1939  }
1940  // Now we the ones that are not next to fields to deal with
1941 }
int MapWidth(void)
Definition: rastermap.h:57
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 MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
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 MissingCellReplace(int a_x, int a_y, bool a_fieldsonly)
A method for removing missing polygons.
Definition: rastermap.cpp:259
bool MissingCellReplaceWrap(int a_x, int a_y, bool a_fieldsonly)
A method for removing missing polygons - tests for edge conditions.
Definition: rastermap.cpp:288
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

Definition at line 1998 of file Landscape.cpp.

References tole_FieldBoundary, tole_HedgeBank, tole_Hedges, tole_IndividualTree, tole_MetalledPath, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideSlope, tole_RoadsideVerge, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, and tole_UnsprayedFieldMargin.

1999 {
2013  // To be sure we first count the map squares
2014  CountMapSquares();
2015  // First find polygons that don't match other rules and are single cells - remove these
2016  int removed = 0;
2017  for (unsigned int i = 0; i < m_elems.size(); i++)
2018  {
2019  if (m_elems[i]->GetArea() == 1)
2020  {
2021  TTypesOfLandscapeElement tole = m_elems[i]->GetElementType();
2022  switch (tole)
2023  {
2024  case tole_FieldBoundary:
2025  case tole_HedgeBank:
2026  case tole_Hedges:
2027  case tole_IndividualTree:
2028  case tole_MetalledPath:
2029  case tole_River:
2030  case tole_RiversidePlants:
2031  case tole_RiversideTrees:
2032  case tole_RoadsideSlope:
2033  case tole_RoadsideVerge:
2034  case tole_SmallRoad:
2035  case tole_StoneWall:
2036  case tole_Stream:
2037  case tole_Track:
2039  // These could be part of a bigger polygon, so leave them alone for now.
2040  break;
2041  default:
2042  // Get rid of this one.
2043  APoint pt = m_elems[i]->GetCentroid();
2044  m_land->CellReplacementNeighbour(pt.m_x, pt.m_y, m_elems[i]->GetPoly());
2045  removed++;
2046  }
2047  }
2048  }
2049  return removed;
2050 }
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:1854
RasterMap * m_land
The big map.
Definition: landscape.h:122
int CellReplacementNeighbour(int a_x, int a_y, int a_polyref)
A method for helping remove tiny polygons.
Definition: rastermap.cpp:216
TTypesOfLandscapeElement
void Landscape::RodenticidePredatorsEvaluation ( RodenticidePredators_Population_Manager *  a_rppm)

Definition at line 2813 of file Landscape.cpp.

2814 {
2815  for (unsigned i=0; i<m_elems.size(); i++) {
2816  a_rppm->PreCachePoly(m_elems[i]->GetPoly());
2817  }
2818 }
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::SetBirdMaizeForage ( int  a_polyref,
double  a_fooddensity 
)
inline

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

Definition at line 499 of file landscape.h.

References m_polymapping.

499  {
500  m_elems[ m_polymapping[ a_polyref ] ]->SetBirdMaize( a_fooddensity );
501  }
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.

Definition at line 492 of file landscape.h.

References m_polymapping.

493  {
494  m_elems[m_polymapping[a_polyref]]->SetBirdSeed(a_fooddensity);
495  }
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 
)

Definition at line 3334 of file Landscape.cpp.

3334  {
3335  m_elems[m_polymapping[a_polyref]]->SetSignal(a_signal);
3336 }
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.

Definition at line 328 of file landscape.h.

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  )

Definition at line 1434 of file Landscape.cpp.

1435 {
1436  // All polygon manipulation is settled now we need to give the polygons some information about themselves
1437  // This takes a little time but save time later one
1438  cout << "Setting max min polygon extents" << endl;
1439  int mwidth = m_land->MapWidth();
1440  int mheight = m_land->MapHeight();
1441  for ( int x = 0; x < mwidth; x++ ) {
1442  for ( int y = 0; y < mheight; y++ ) {
1443  int polyindex = m_land->Get( x, y );
1444  // Mark that we have seen this polygon.
1445  unsigned int ele_ref= polyindex;
1446  if (m_elems[m_polymapping[ele_ref]]->GetMaxX() < x) m_elems[m_polymapping[ele_ref]]->SetMaxX(x);
1447  if (m_elems[m_polymapping[ele_ref]]->GetMaxY() < y) m_elems[m_polymapping[ele_ref]]->SetMaxY(y);
1448  if (m_elems[m_polymapping[ele_ref]]->GetMinX() > x) m_elems[m_polymapping[ele_ref]]->SetMinX(x);
1449  if (m_elems[m_polymapping[ele_ref]]->GetMinY() > y) m_elems[m_polymapping[ele_ref]]->SetMinY(y);
1450  m_elems[m_polymapping[ele_ref]]->SetMapValid(true);
1451  }
1452  }
1453 }
int MapWidth(void)
Definition: rastermap.h:57
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 MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
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.

Definition at line 161 of file landscape.h.

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.

Definition at line 1282 of file Landscape.cpp.

References CfgBool::value().

1283 {
1288  if(cfg_OptimisingFarms.value()){
1290  }
1291 }
CfgBool cfg_OptimisingFarms
If set to true, the farmer decision making model is active.
void PrintFinalResults()
At the end of a simulation it prints results on crop distribution, pesticide and fertilizer usage...
Definition: farm.cpp:4264
bool value(void)
Definition: configurator.h:123
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
void Landscape::SkylarkEvaluation ( SkTerritories *  a_skt)

Definition at line 2806 of file Landscape.cpp.

2806  {
2807  for (unsigned i=0; i<m_elems.size(); i++) {
2808  a_skt->PreCachePoly(m_elems[i]->GetPoly());
2809  }
2810 }
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

Definition at line 2210 of file Landscape.cpp.

2211 {
2212  int index;
2213  int x_add[ 8 ] = { 1*a_step, 1*a_step, 0, -1*a_step, -1*a_step, -1*a_step, 0, 1*a_step };
2214  int y_add[ 8 ] = { 0, -1*a_step, -1*a_step, -1*a_step, 0, 1*a_step, 1*a_step, 1*a_step };
2215  int width = m_land->MapWidth();
2216  int height = m_land->MapHeight();
2217  // Scan anti-clockwise from center pixel coordinate.
2218  for ( unsigned int i = 0; i < 8; i++ ) {
2219  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 ) )
2220  {
2221  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2222  if ( index == a_polyindex )
2223  {
2224  m_elems[a_polyindex]->SetValidXY(a_x + x_add[ i ], a_y + y_add[ i ]);
2225  return true;
2226  }
2227  }
2228  }
2229  return false;
2230 }
int MapWidth(void)
Definition: rastermap.h:57
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 MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
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.

Definition at line 559 of file Landscape.cpp.

559  {
560  return dynamic_cast<Pond*>(m_elems[a_polyrefindex])->SubtractLarvalFood(a_food);
561 }
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:1082
double Landscape::SupplyBirdMaizeForage ( int  a_polyref)
inline

Returns the maize forage resource.

Definition at line 591 of file landscape.h.

References m_polymapping.

591  {
592  return m_elems[ m_polymapping[ a_polyref ] ]->GetBirdMaize();
593  }
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.

Definition at line 597 of file landscape.h.

References RasterMap::Get().

597  {
598  return m_elems[ m_land->Get( a_x, a_y ) ]->GetBirdMaize();
599  }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyBirdSeedForage ( int  a_polyref)
inline

Returns the grain forage resource.

Definition at line 577 of file landscape.h.

References m_polymapping.

578  {
579  return m_elems[m_polymapping[a_polyref]]->GetBirdSeed();
580  }
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.

Definition at line 584 of file landscape.h.

References RasterMap::Get().

585  {
586  return m_elems[m_land->Get(a_x, a_y)]->GetBirdSeed();
587  }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
APoint Landscape::SupplyCentroid ( int  a_polyref)

Definition at line 629 of file Landscape.cpp.

629  {
630  return m_elems[ m_polymapping[ a_polyref ] ]->GetCentroid();
631 }
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)

Definition at line 634 of file Landscape.cpp.

634  {
635  return m_elems[ a_polyrefindex ]->GetCentroid();
636 }
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

Definition at line 436 of file landscape.h.

References m_polymapping.

436  {
437  return m_elems[ m_polymapping[ a_polyref ] ]->GetCentroidX();
438  }
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

Definition at line 440 of file landscape.h.

References RasterMap::Get().

440 { 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
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyCentroidY ( int  a_polyref)
inline

Definition at line 439 of file landscape.h.

References m_polymapping.

439 { 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

Definition at line 441 of file landscape.h.

References RasterMap::Get(), and GooseFieldListItem::polyref.

441 { 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
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyCountryDesig ( int  a_x,
int  a_y 
)
inline

Definition at line 1053 of file landscape.h.

1054 {
1055  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCountryDesignation();
1056 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyDayDegrees ( int  a_polyref)
inline

Definition at line 1250 of file landscape.h.

References m_polymapping.

1251 {
1252  return m_elems[ m_polymapping[ a_polyref ]]->GetDayDegrees();
1253 }
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

Definition at line 1532 of file landscape.h.

References g_date, and Calendar::GetDayInMonth().

1533 {
1534  return g_date->GetDayInMonth();
1535 }
int GetDayInMonth(void)
Definition: calendar.h:72
class Calendar * g_date
Definition: calendar.cpp:38
int Landscape::SupplyDayInYear ( void  )
inline

Definition at line 1522 of file landscape.h.

References Calendar::DayInYear(), and g_date.

Referenced by Rabbit_Population_Manager::DoFirst(), Rabbit_Population_Manager::DoLast(), FarmManager::FarmManagement(), and Rabbit_Warren::UpdateForageInformation().

1523 {
1524  return g_date->DayInYear();
1525 }
int DayInYear(void)
Definition: calendar.h:58
class Calendar * g_date
Definition: calendar.cpp:38
int Landscape::SupplyDaylength ( void  )
inline

Definition at line 1456 of file landscape.h.

References Calendar::DayLength(), and g_date.

1457 {
1458  return g_date->DayLength();
1459 }
class Calendar * g_date
Definition: calendar.cpp:38
int DayLength(void)
Definition: calendar.h:63
int Landscape::SupplyDaylength ( long  a_date)
inline

Definition at line 1449 of file landscape.h.

References Calendar::DayLength(), and g_date.

1450 {
1451  return g_date->DayLength( a_date );
1452 }
class Calendar * g_date
Definition: calendar.cpp:38
int DayLength(void)
Definition: calendar.h:63
double Landscape::SupplyDaylightProp ( )
inline

Definition at line 774 of file landscape.h.

References g_date, and Calendar::GetDaylightProportion().

774 { return g_date->GetDaylightProportion(); }
class Calendar * g_date
Definition: calendar.cpp:38
double GetDaylightProportion(void)
Definition: calendar.h:73
double Landscape::SupplyDeadBiomass ( int  a_polyref)
inline

Definition at line 950 of file landscape.h.

References m_polymapping.

951 {
952  return m_elems[ m_polymapping[ a_polyref ]]->GetDeadBiomass();
953 }
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

Definition at line 955 of file landscape.h.

956 {
957  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDeadBiomass();
958 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyElementSubType ( int  a_polyref)
inline

Definition at line 1042 of file landscape.h.

References m_polymapping.

1043 {
1044  return m_elems[ m_polymapping[ a_polyref ]]->GetSubType();
1045 }
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

Definition at line 1047 of file landscape.h.

1048 {
1049  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSubType();
1050 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfLandscapeElement Landscape::SupplyElementType ( int  a_polyref)
inline

Definition at line 1031 of file landscape.h.

References m_polymapping.

Referenced by Rabbit_Population_Manager::WarrenLegalPos().

1032 {
1033  return m_elems[ m_polymapping[ a_polyref ]]->GetElementType();
1034 }
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

Definition at line 1036 of file landscape.h.

1037 {
1038  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1039 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfLandscapeElement Landscape::SupplyElementTypeCC ( int  a_x,
int  a_y 
)
inline

Definition at line 1060 of file landscape.h.

1061 {
1062  a_x = (a_x + m_width10) % m_width;
1063  a_y = (a_y + m_height10) % m_height;
1064  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1065 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
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

Definition at line 1025 of file landscape.h.

1026 {
1027  return m_elems[ a_index ]->GetElementType();
1028 }
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 
)

Definition at line 608 of file Landscape.cpp.

Referenced by FarmManager::FarmManagement().

609 {
610  return m_ThePopManager->FarmAnimalCensus(a_farm_ref, a_LifeStage);
611 }
unsigned int FarmAnimalCensus(unsigned int a_farm, unsigned int a_typeofanimal)
Population_Manager * m_ThePopManager
a pointer to the current main population manager
Definition: landscape.h:143
int Landscape::SupplyFarmArea ( int  a_polyref)
inline

Definition at line 1127 of file landscape.h.

References m_polymapping.

1128 {
1129  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetArea();
1130 }
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 
)

Definition at line 619 of file Landscape.cpp.

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

619  {
620  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner()->GetIntensity();
621 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyFarmIntensity ( int  a_polyref)

Definition at line 624 of file Landscape.cpp.

624  {
625  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetIntensity();
626 }
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)

Definition at line 614 of file Landscape.cpp.

614  {
615  return m_elems[ a_polyindex ]->GetOwner()->GetIntensity();
616 }
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

Definition at line 332 of file landscape.h.

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

Definition at line 1073 of file landscape.h.

1073  {
1074  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerFile();
1075 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyFarmOwner ( int  a_polyref)
inline

Definition at line 1079 of file landscape.h.

References m_polymapping.

1080 {
1081  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerFile();
1082 }
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

Definition at line 1086 of file landscape.h.

1087 {
1088  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerIndex();
1089 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyFarmOwnerIndex ( int  a_polyref)
inline

Definition at line 1093 of file landscape.h.

References m_polymapping.

1094 {
1095  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerIndex();
1096 }
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

Definition at line 331 of file landscape.h.

References FarmManager::GetFarmPtr().

331 { return m_FarmManager->GetFarmPtr(a_owner); }
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
Farm * GetFarmPtr(int a_owner)
Returns the pointer to a farm with a specific number.
Definition: farm.h:1623
TTypesOfFarm Landscape::SupplyFarmType ( int  a_polyref)
inline

Definition at line 1100 of file landscape.h.

References m_polymapping.

1101 {
1102  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetType();
1103 }
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

Definition at line 1107 of file landscape.h.

1108 {
1109  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner()->GetType();
1110 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
long Landscape::SupplyGlobalDate ( void  )
inline

Definition at line 1547 of file landscape.h.

References Calendar::Date(), and g_date.

Referenced by Rabbit_Female::st_EvaluateTerritory(), Rabbit_Female::st_GiveBirth(), and Rabbit_Warren::UpdateForageInformation().

1548 {
1549  return g_date->Date();
1550 }
long Date(void)
Definition: calendar.h:57
class Calendar * g_date
Definition: calendar.cpp:38
double Landscape::SupplyGlobalRadiation ( )
inline

Definition at line 1267 of file landscape.h.

References g_weather, and Weather::GetGlobalRadiation().

Referenced by VegElement::RecalculateBugsNStuff().

1268 {
1269  return g_weather->GetGlobalRadiation( );
1270 }
class Weather * g_weather
Definition: weather.cpp:41
double GetGlobalRadiation(long a_date)
Definition: weather.h:414
double Landscape::SupplyGlobalRadiation ( long  a_date)
inline

Definition at line 1272 of file landscape.h.

References g_weather, and Weather::GetGlobalRadiation().

1273 {
1274  return g_weather->GetGlobalRadiation( a_date );
1275 }
class Weather * g_weather
Definition: weather.cpp:41
double GetGlobalRadiation(long a_date)
Definition: weather.h:414
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

Definition at line 505 of file landscape.h.

Referenced by VegElement::RecalculateBugsNStuff().

506  {
512  if (a_goose == gs_Pinkfoot)
513  {
514  return m_GooseIntakeRateVSVegetationHeight_PF->GetY( a_height );
515  }
516  if (a_goose == gs_Barnacle)
517  {
518  return m_GooseIntakeRateVSVegetationHeight_BG->GetY(a_height);
519  }
520  if (a_goose == gs_Greylag)
521  {
522  return m_GooseIntakeRateVSVegetationHeight_GL->GetY(a_height);
523  }
524  Warn("Landscape::SupplyGooseGrazingForage", "Unknown Goose Type");
525  exit(1);
526  }
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:1505
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

Definition at line 530 of file landscape.h.

References m_polymapping.

531  {
537  if (a_goose == gs_Pinkfoot)
538  {
539  return m_GooseIntakeRateVSVegetationHeight_PF->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
540  }
541  if (a_goose == gs_Barnacle)
542  {
543  return m_GooseIntakeRateVSVegetationHeight_BG->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
544  }
545  if (a_goose == gs_Greylag)
546  {
547  return m_GooseIntakeRateVSVegetationHeight_GL->GetY(m_elems[m_polymapping[a_polygon]]->GetVegHeight());
548  }
549  Warn("Landscape::SupplyGooseGrazingForage", "Unknown Goose Type");
550  exit(1);
551  }
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:1505
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

Definition at line 1148 of file landscape.h.

References m_polymapping.

1149 {
1150  return m_elems[ m_polymapping[ a_polyref ] ]->GetCattleGrazing();
1151 }
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

Definition at line 1160 of file landscape.h.

1161 {
1162  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCattleGrazing();
1163 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyGrazingPressureVector ( unsigned int  a_index)
inline

Definition at line 1153 of file landscape.h.

1154 {
1155  return m_elems[ a_index ]->GetCattleGrazing();
1156 }
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

Definition at line 938 of file landscape.h.

References m_polymapping.

939 {
940  return m_elems[ m_polymapping[ a_polyref ]]->GetGreenBiomass();
941 }
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

Definition at line 943 of file landscape.h.

944 {
945  return m_elems[ m_land->Get( a_x, a_y ) ]->GetGreenBiomass();
946 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SupplyHasTramlines ( int  a_x,
int  a_y 
)
inline

Definition at line 1173 of file landscape.h.

1174 {
1175  return m_elems[ m_land->Get( a_x, a_y ) ]->HasTramlines();
1176 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SupplyHasTramlines ( int  a_polyref)
inline

Definition at line 1167 of file landscape.h.

References m_polymapping.

1168 {
1169  return m_elems[ m_polymapping[ a_polyref ] ]->HasTramlines();
1170 }
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.

Definition at line 1512 of file landscape.h.

References g_date, and Calendar::GetHour().

1512  {
1513  return g_date->GetHour();
1514 }
class Calendar * g_date
Definition: calendar.cpp:38
int GetHour(void)
Definition: calendar.h:71
double Landscape::SupplyHumidity ( void  )
inline

Definition at line 1319 of file landscape.h.

References g_weather, and Weather::GetHumidity().

1320 {
1321  return g_weather->GetHumidity();
1322 }
class Weather * g_weather
Definition: weather.cpp:41
double GetHumidity(void)
Get the humidity score today.
Definition: weather.h:421
double Landscape::SupplyInsects ( int  a_polyref)
inline

Definition at line 1009 of file landscape.h.

References m_polymapping.

1010 {
1011  return m_elems[ m_polymapping[ a_polyref ]]->GetInsectPop();
1012 }
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

Definition at line 1014 of file landscape.h.

1015 {
1016  return m_elems[ m_land->Get( a_x, a_y ) ]->GetInsectPop();
1017 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SupplyIsCereal ( int  a_polyref)
inline

Definition at line 1220 of file landscape.h.

References m_polymapping.

1221 {
1222  return m_elems[m_polymapping[a_polyref]]->IsCereal();
1223 }
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

Definition at line 1230 of file landscape.h.

References m_polymapping.

1231 {
1232  return m_elems[ m_polymapping[ a_polyref ] ]->IsGrass();
1233 }
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

Definition at line 1225 of file landscape.h.

References m_polymapping.

1226 {
1227  return m_elems[m_polymapping[a_polyref]]->IsMatureCereal();
1228 }
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

Definition at line 1184 of file landscape.h.

References m_polymapping.

1185 {
1186  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlyMown();
1187 }
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

Definition at line 1179 of file landscape.h.

1180 {
1181  return m_elems[ a_index ]->IsRecentlyMown();
1182 }
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

Definition at line 1196 of file landscape.h.

References m_polymapping.

1197 {
1198  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlySprayed();
1199 }
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

Definition at line 1201 of file landscape.h.

1202 {
1203  return m_elems[ m_land->Get( a_x, a_y ) ]->IsRecentlySprayed();
1204 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyJustSprayedVector ( unsigned int  a_index)
inline

Definition at line 1191 of file landscape.h.

1192 {
1193  return m_elems[ a_index ]->IsRecentlySprayed();
1194 }
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

Definition at line 962 of file landscape.h.

References m_polymapping.

963 {
964  return m_elems[ m_polymapping[ a_polyref ]]->GetLAGreen();
965 }
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

Definition at line 931 of file landscape.h.

932 {
933  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLAGreen();
934 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
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!

Definition at line 645 of file Landscape.cpp.

646 {
655  polylist* p_list = new polylist;
656  unsigned sz = (unsigned) m_elems.size();
657  for (unsigned i=0; i<sz; i++)
658  {
659  if ( m_elems[i]->GetOpenness() > a_openness)
660  {
661  APoint pt = m_elems[i]->GetCentroid();
662  int dx, dy;
663  if (a_x>pt.m_x) dx = a_x-pt.m_x; else dx = pt.m_x-a_x;
664  if (a_y>pt.m_y) dy = a_y-pt.m_y; else dy = pt.m_y-a_y;
665  dx++; dy++; // prevents crash with maths below.
667  int dist;
669  if (dx>dy) dist = dx + (dy * dy) /(2 * dx); else dist = dy + (dx * dx) /(2 * dy);
670  if (dist<=a_range) p_list->push_back( m_elems[i]->GetPoly());
671  }
672  }
673  return p_list;
674 }
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< unsigned > polylist
Definition: farm.h:162
int Landscape::SupplyLargestPolyNumUsed ( )
inline

Definition at line 334 of file landscape.h.

334 { return m_LargestPolyNumUsed; }
int m_LargestPolyNumUsed
Definition: landscape.h:172
TTypesOfVegetation Landscape::SupplyLastSownVeg ( int  a_polyref)
inline

Definition at line 989 of file landscape.h.

References m_polymapping.

990 {
991  return m_elems[m_polymapping[a_polyref]]->GetLastSownVeg();
992 }
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

Definition at line 994 of file landscape.h.

995 {
996  return m_elems[m_land->Get(a_x, a_y)]->GetLastSownVeg();
997 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfVegetation Landscape::SupplyLastSownVegVector ( unsigned int  a_index)
inline

Definition at line 984 of file landscape.h.

985 {
986  return m_elems[a_index]->GetLastSownVeg();
987 }
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

Definition at line 1255 of file landscape.h.

References m_polymapping.

1256 {
1257  return m_elems[ m_polymapping[ a_polyref ]]->GetLastTreatment( a_index );
1258 }
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

Definition at line 1262 of file landscape.h.

1263 {
1264  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLastTreatment( a_index );
1265 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyLATotal ( int  a_x,
int  a_y 
)
inline

Definition at line 925 of file landscape.h.

926 {
927  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLATotal();
928 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyLECount ( void  )

Definition at line 3326 of file Landscape.cpp.

3326  {
3327  return (int)m_elems.size();
3328 }
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.

Definition at line 421 of file landscape.h.

References RasterMap::Get().

421 { 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
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyLENext ( void  )

Definition at line 3319 of file Landscape.cpp.

3319  {
3320  if ((unsigned int)le_signal_index == m_elems.size()) {
3321  return -1;
3322  }
3323  return m_elems[le_signal_index++]->GetPoly();
3324 }
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

Definition at line 1020 of file landscape.h.

References m_polymapping.

Referenced by Farm::AutumnHarrow(), Farm::AutumnPlough(), Farm::AutumnRoll(), Farm::AutumnSow(), Farm::BurnStrawStubble(), Farm::CattleIsOut(), Farm::CattleIsOutLow(), Farm::CattleOut(), Farm::CattleOutLowGrazing(), Farm::CutOrch(), Farm::CutToHay(), Farm::CutToSilage(), Farm::CutWeeds(), Farm::DeepPlough(), Field::DoDevelopment(), Farm::FA_AmmoniumSulphate(), Farm::FA_GreenManure(), Farm::FA_Manure(), Farm::FA_NPK(), Farm::FA_PK(), Farm::FA_Sludge(), Farm::FA_Slurry(), Farm::FP_GreenManure(), Farm::FP_LiquidNH3(), Farm::FP_ManganeseSulphate(), Farm::FP_Manure(), Farm::FP_NPK(), Farm::FP_NPKS(), Farm::FP_PK(), Farm::FP_Sludge(), Farm::FP_Slurry(), Farm::Harvest(), OptimisingFarm::Harvest(), Farm::HarvestLong(), Farm::HayBailing(), Farm::HayTurning(), Farm::HillingUp(), Rabbit_Warren::InitEvaluation(), Farm::PigsAreOut(), Farm::PigsAreOutForced(), Farm::PigsOut(), Farm::RowCultivation(), Farm::SleepAllDay(), Farm::SpringHarrow(), Farm::SpringPlough(), Farm::SpringRoll(), Farm::SpringSow(), Farm::StrawChopping(), Farm::Strigling(), Farm::StriglingSow(), Farm::StubbleHarrowing(), Farm::Swathing(), UnsprayedMarginScan(), Farm::Water(), and Farm::WinterPlough().

1021 {
1022  return m_elems[ m_polymapping[ a_polyref ]];
1023 }
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  )

Definition at line 3315 of file Landscape.cpp.

3315  {
3316  le_signal_index = 0;
3317 }
int le_signal_index
Definition: landscape.h:297
LE_Signal Landscape::SupplyLESignal ( int  a_polyref)

Definition at line 3330 of file Landscape.cpp.

3330  {
3331  return m_elems[m_polymapping[a_polyref]]->GetSignal();
3332 }
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

Definition at line 1435 of file landscape.h.

1436 {
1437  return m_land->GetMagicP( a_x, a_y );
1438 }
int * GetMagicP(int a_x, int a_y)
Definition: rastermap.h:79
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.

Definition at line 330 of file landscape.h.

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

Definition at line 1298 of file landscape.h.

References g_weather, and Weather::GetMeanTemp().

1299 {
1300  return g_weather->GetMeanTemp( a_date, a_period );
1301 }
class Weather * g_weather
Definition: weather.cpp:41
double GetMeanTemp(long a_date, unsigned int a_period)
Definition: weather.cpp:120
int Landscape::SupplyMinute ( void  )
inline

Get the minute of the hour.

Definition at line 1518 of file landscape.h.

References g_date, and Calendar::GetMinute().

1518  {
1519  return g_date->GetMinute();
1520 }
int GetMinute(void)
Definition: calendar.h:70
class Calendar * g_date
Definition: calendar.cpp:38
int Landscape::SupplyMonth ( void  )
inline

Definition at line 1527 of file landscape.h.

References g_date, and Calendar::GetMonth().

1528 {
1529  return g_date->GetMonth();
1530 }
class Calendar * g_date
Definition: calendar.cpp:38
int GetMonth(void)
Definition: calendar.h:69
double Landscape::SupplyNightProp ( )
inline

Definition at line 775 of file landscape.h.

References g_date, g_map, and Calendar::GetDaylightProportion().

775 { return 1.0-g_date->GetDaylightProportion(); }
class Calendar * g_date
Definition: calendar.cpp:38
double GetDaylightProportion(void)
Definition: calendar.h:73
int Landscape::SupplyNumberOfFarms ( )
inline

Definition at line 1069 of file landscape.h.

1069  {
1070  return m_FarmManager->GetNoFarms();
1071 }
int GetNoFarms()
Definition: farm.h:1757
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
unsigned int Landscape::SupplyNumberOfPolygons ( void  )
inline

Definition at line 1387 of file landscape.h.

1388 {
1389  return (unsigned int) m_elems.size();
1390 }
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.

Definition at line 417 of file landscape.h.

References m_polymapping.

417 { 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.

Definition at line 419 of file landscape.h.

References RasterMap::Get().

419 { 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
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfOptFarms Landscape::SupplyOptFarmType ( int  a_x,
int  a_y 
)
inline

Definition at line 1112 of file landscape.h.

1113 {
1114  OptimisingFarm * opf;
1115  opf = dynamic_cast<OptimisingFarm*>(m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner());
1116  return opf-> Get_farmType();
1117 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
A farm that carries out crop, pesticide and fertilizer planning using simplified optimisation or othe...
Definition: farm.h:1885
RasterMap * m_land
The big map.
Definition: landscape.h:122
bool Landscape::SupplyOverspray ( int  a_x,
int  a_y 
)

Gets the overspray flag.

Definition at line 494 of file Landscape.cpp.

495 {
496  return m_elems[m_land->Get(a_x, a_y)]->GetSprayedToday();
497 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
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.

Definition at line 481 of file Landscape.cpp.

References g_pest, and Pesticide::SupplyPesticide().

Referenced by Pond::CalcPondPesticide(), and Rabbit_Warren::UpdatePesticide().

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
Definition: pesticide.cpp:70
double SupplyPesticide(int a_x, int a_y)
Definition: pesticide.h:320
double Landscape::SupplyPesticide ( int  a_polyref)

Gets total pesticide for the centroid of a polygon.

Definition at line 522 of file Landscape.cpp.

References g_pest, Pesticide::SupplyPesticide(), and CfgBool::value().

522  {
523  if (!l_pest_enable_pesticide_engine.value()) return 0.0;
524  double pp;
525 #ifdef __DETAILED_PESTICIDE_FATE
526  pp = g_pest->SupplyPesticideS(a_polyref);
527  pp += g_pest->SupplyPesticideP(a_polyref);
528 #else
529  pp = g_pest->SupplyPesticide(a_polyref);
530 #endif
531  return pp;
532 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
double SupplyPesticide(int a_x, int a_y)
Definition: pesticide.h:320
CfgBool l_pest_enable_pesticide_engine
bool value(void)
Definition: configurator.h:123
int Landscape::SupplyPesticideCell ( int  a_polyref)
inline

Definition at line 1394 of file landscape.h.

References m_polymapping.

1395 {
1396  return m_elems[ m_polymapping[ a_polyref ] ]->GetPesticideCell();
1397 }
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.

Definition at line 639 of file Landscape.cpp.

References g_pest, and Pesticide::GetAnythingToDecay().

Referenced by Rabbit_Warren::UpdatePesticide().

640 {
641  return g_pest->GetAnythingToDecay();
642 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
bool GetAnythingToDecay()
Definition: pesticide.h:219
double Landscape::SupplyPesticideP ( int  a_x,
int  a_y 
)

Gets plant pesticide for a location.

Definition at line 500 of file Landscape.cpp.

References g_pest, and Pesticide::SupplyPesticide().

500  {
501  double pp;
502 #ifdef __DETAILED_PESTICIDE_FATE
503  pp = g_pest->SupplyPesticideP(a_x, a_y);
504 #else
505  pp = g_pest->SupplyPesticide(a_x, a_y);
506 #endif
507  return pp;
508 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
double SupplyPesticide(int a_x, int a_y)
Definition: pesticide.h:320
double Landscape::SupplyPesticideP ( int  a_polyref)

Gets plant pesticide for the centroid of a polygon.

Definition at line 547 of file Landscape.cpp.

References g_pest, Pesticide::SupplyPesticide(), and CfgBool::value().

547  {
548  if (!l_pest_enable_pesticide_engine.value()) return 0.0;
549  double pp;
550 #ifdef __DETAILED_PESTICIDE_FATE
551  pp = g_pest->SupplyPesticideP(a_polyref);
552 #else
553  pp = g_pest->SupplyPesticide(a_polyref);
554 #endif
555  return pp;
556 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
double SupplyPesticide(int a_x, int a_y)
Definition: pesticide.h:320
CfgBool l_pest_enable_pesticide_engine
bool value(void)
Definition: configurator.h:123
double Landscape::SupplyPesticideS ( int  a_x,
int  a_y 
)

Gets soil pesticide for a location.

Definition at line 511 of file Landscape.cpp.

References g_pest, and Pesticide::SupplyPesticide().

511  {
512  double pp;
513 #ifdef __DETAILED_PESTICIDE_FATE
514  pp = g_pest->SupplyPesticideS(a_x, a_y);
515 #else
516  pp = g_pest->SupplyPesticide(a_x, a_y);
517 #endif
518  return pp;
519 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
double SupplyPesticide(int a_x, int a_y)
Definition: pesticide.h:320
double Landscape::SupplyPesticideS ( int  a_polyref)

Gets soil pesticide for the centroid of a polygon.

Definition at line 535 of file Landscape.cpp.

References g_pest, Pesticide::SupplyPesticide(), and CfgBool::value().

535  {
536  if (!l_pest_enable_pesticide_engine.value()) return 0.0;
537  double pp;
538 #ifdef __DETAILED_PESTICIDE_FATE
539  pp = g_pest->SupplyPesticideS(a_polyref);
540 #else
541  pp = g_pest->SupplyPesticide(a_polyref);
542 #endif
543  return pp;
544 }
class Pesticide * g_pest
Definition: pesticide.cpp:70
double SupplyPesticide(int a_x, int a_y)
Definition: pesticide.h:320
CfgBool l_pest_enable_pesticide_engine
bool value(void)
Definition: configurator.h:123
TTypesOfPesticide Landscape::SupplyPesticideType ( void  )
inline

Definition at line 401 of file landscape.h.

Referenced by Rabbit_Juvenile::InternalPesticideHandlingAndResponse(), Rabbit_Male::InternalPesticideHandlingAndResponse(), and Rabbit_Female::InternalPesticideHandlingAndResponse().

401 { 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

Definition at line 487 of file landscape.h.

References m_polymapping.

487 { 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.

Definition at line 1121 of file landscape.h.

1122 {
1123  return m_elems[ a_polyref ]->GetArea();
1124 }
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

Definition at line 1414 of file landscape.h.

Referenced by Pond::CalcPondPesticide(), Rabbit_Warren::InitEvaluation(), and Rabbit_Warren::UpdatePesticide().

1415 {
1416  return m_elems[ m_land->Get( a_x, a_y )]->GetPoly();
1417 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyPolyRefCC ( int  a_x,
int  a_y 
)
inline

Definition at line 1426 of file landscape.h.

1427 {
1428  a_x = (a_x + m_width10) % m_width;
1429  a_y = (a_y + m_height10) % m_height;
1430  return m_elems[ m_land->Get( a_x, a_y )]->GetPoly();
1431 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
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

Definition at line 1419 of file landscape.h.

1420 {
1421  return m_land->Get( a_x, a_y );
1422 }
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyPolyRefVector ( unsigned int  a_index)
inline

Definition at line 1377 of file landscape.h.

1378 {
1379  return m_elems[ a_index ]->GetPoly();
1380 }
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.

Definition at line 321 of file landscape.h.

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)

Definition at line 710 of file landscape.h.

References SupplyPondPesticide().

Referenced by SupplyPondPesticide().

710 { 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:710
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1082
double Landscape::SupplyRain ( void  )
inline

Definition at line 1291 of file landscape.h.

References g_weather, and Weather::GetRain().

Referenced by Rabbit_Population_Manager::DoFirst(), and Pesticide::Tick().

1292 {
1293  return g_weather->GetRain();
1294 }
double GetRain(long a_date)
Definition: weather.h:423
class Weather * g_weather
Definition: weather.cpp:41
double Landscape::SupplyRain ( long  a_date)
inline

Definition at line 1284 of file landscape.h.

References g_weather, and Weather::GetRain().

1285 {
1286  return g_weather->GetRain( a_date );
1287 }
double GetRain(long a_date)
Definition: weather.h:423
class Weather * g_weather
Definition: weather.cpp:41
double Landscape::SupplyRainPeriod ( long  a_date,
int  a_period 
)
inline

Definition at line 1277 of file landscape.h.

References g_weather, and Weather::GetRainPeriod().

1278 {
1279  return g_weather->GetRainPeriod( a_date, a_period );
1280 }
class Weather * g_weather
Definition: weather.cpp:41
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
int Landscape::SupplyRandomPondIndex ( )

Returns random pond index.

Definition at line 2387 of file Landscape.cpp.

References g_rand_uni().

2387  {
2388  return m_PondIndexList[int(g_rand_uni()*m_PondIndexList.size())];
2389 }
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.

Definition at line 2391 of file Landscape.cpp.

References g_rand_uni().

2391  {
2392  if (m_PondIndexList.size()>0) return m_PondRefsList[int(g_rand_uni()*m_PondIndexList.size())];
2393  return -1;
2394 }
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

Definition at line 760 of file landscape.h.

760 {return 0;}
double Landscape::SupplyRodenticide ( int  a_x,
int  a_y 
)

Gets total rodenticide for a location.

Definition at line 470 of file Landscape.cpp.

References cfg_rodenticide_enable, and CfgBool::value().

470  {
472  {
473  double pp;
474  pp = m_RodenticideManager->GetRodenticide(a_x, a_y);
475  return pp;
476  }
477  return 0;
478 }
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
bool value(void)
Definition: configurator.h:123
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
RodenticidePredators_Population_Manager* Landscape::SupplyRodenticidePredatoryManager ( )
inline

Definition at line 400 of file landscape.h.

400 { return m_RodenticidePreds; }
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
bool Landscape::SupplyShouldSpray ( )
inline

Definition at line 336 of file landscape.h.

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

336 {return m_toxShouldSpray;}
bool m_toxShouldSpray
Definition: landscape.h:295
int Landscape::SupplySimAreaHeight ( void  )
inline

Definition at line 1563 of file landscape.h.

Referenced by TAnimal::CorrectWrapRound(), Rabbit_Warren::InitEvaluation(), and Population_Manager::Population_Manager().

1564 {
1565  return m_height;
1566 }
int m_height
Definition: landscape.h:128
int Landscape::SupplySimAreaMaxExtent ( void  )
inline

Definition at line 1568 of file landscape.h.

1569 {
1570  return m_maxextent;
1571 }
int m_maxextent
Definition: landscape.h:131
int Landscape::SupplySimAreaMinExtent ( void  )
int Landscape::SupplySimAreaWidth ( void  )
inline
bool Landscape::SupplySkScrapes ( int  a_polyref)
inline

Definition at line 902 of file landscape.h.

References m_polymapping.

903 {
904  return m_elems[ m_polymapping[ a_polyref ]]->GetSkScrapes();
905 }
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

Definition at line 1363 of file landscape.h.

References g_weather, and Weather::GetSnow().

1364 {
1365  return g_weather->GetSnow();
1366 }
bool GetSnow(long a_date)
Definition: weather.cpp:132
class Weather * g_weather
Definition: weather.cpp:41
bool Landscape::SupplySnowcover ( long  a_date)
inline

Definition at line 1356 of file landscape.h.

References g_weather, and Weather::GetSnow().

1357 {
1358  return g_weather->GetSnow( a_date );
1359 }
bool GetSnow(long a_date)
Definition: weather.cpp:132
class Weather * g_weather
Definition: weather.cpp:41
double Landscape::SupplySnowDepth ( void  )
inline

Definition at line 1370 of file landscape.h.

References g_weather, and Weather::GetSnowDepth().

1371 {
1372  return g_weather->GetSnowDepth();
1373 }
double GetSnowDepth(void)
Get the current snow depth.
Definition: weather.h:431
class Weather * g_weather
Definition: weather.cpp:41
int Landscape::SupplySoilType ( int  a_x,
int  a_y 
)
inline

Returns the soil type in ALMaSS types reference numbers.

Definition at line 426 of file landscape.h.

References RasterMap::Get().

426  {
427  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSoilType( );
428  }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
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.

Definition at line 430 of file landscape.h.

References RasterMap::Get().

Referenced by Rabbit_Population_Manager::PreProcessWarrenLocations().

430  {
431  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSoilTypeR( );
432  }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyTemp ( void  )
inline

Definition at line 1312 of file landscape.h.

References g_weather, and Weather::GetTemp().

Referenced by Rabbit_Population_Manager::DoFirst(), and VegElement::RecalculateBugsNStuff().

1313 {
1314  return g_weather->GetTemp();
1315 }
class Weather * g_weather
Definition: weather.cpp:41
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
double Landscape::SupplyTemp ( long  a_date)
inline

Definition at line 1305 of file landscape.h.

References g_weather, and Weather::GetTemp().

1306 {
1307  return g_weather->GetTemp( a_date );
1308 }
class Weather * g_weather
Definition: weather.cpp:41
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
double Landscape::SupplyTempPeriod ( long  a_date,
int  a_period 
)
inline

Definition at line 1336 of file landscape.h.

References g_weather, and Weather::GetTempPeriod().

1337 {
1338  return g_weather->GetTempPeriod( a_date, a_period );
1339 }
class Weather * g_weather
Definition: weather.cpp:41
double GetTempPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:297
Population_Manager* Landscape::SupplyThePopManager ( )
inline

Get the pointer to the current main population manager.

Definition at line 159 of file landscape.h.

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

Definition at line 1214 of file landscape.h.

1215 {
1216  return m_elems[ m_land->Get( a_x, a_y ) ]->GetTrafficLoad();
1217 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyTrafficLoad ( int  a_polyref)
inline

Definition at line 1208 of file landscape.h.

References m_polymapping.

1209 {
1210  return m_elems[ m_polymapping[ a_polyref ] ]->GetTrafficLoad();
1211 }
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

Definition at line 1237 of file landscape.h.

1238 {
1239  return 1;
1240 }
int Landscape::SupplyTreeAge ( int  ,
int   
)
inline

Definition at line 473 of file landscape.h.

473 {return 0;}
int Landscape::SupplyTreeHeight ( int  ,
int   
)
inline

Definition at line 763 of file landscape.h.

763 {return 0;}
int Landscape::SupplyTreeHeight ( int  )
inline

Definition at line 765 of file landscape.h.

765 {return 0;}
int Landscape::SupplyUnderGrowthWidth ( int  ,
int   
)
inline

Definition at line 764 of file landscape.h.

764 {return 0;}
int Landscape::SupplyUnderGrowthWidth ( int  )
inline

Definition at line 766 of file landscape.h.

766 {return 0;}
int Landscape::SupplyValidX ( int  a_polyref)
inline

Definition at line 1400 of file landscape.h.

References m_polymapping.

1401 {
1402  return m_elems[ m_polymapping[ a_polyref ] ]->GetValidX();
1403 }
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

Definition at line 1407 of file landscape.h.

References m_polymapping.

1408 {
1409  return m_elems[ m_polymapping[ a_polyref ] ]->GetValidY();
1410 }
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

Definition at line 999 of file landscape.h.

References m_polymapping.

1000 {
1001  return m_elems[ m_polymapping[ a_polyref ]]->GetVegAge();
1002 }
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

Definition at line 1004 of file landscape.h.

1005 {
1006  return m_elems[m_land->Get(a_x, a_y)]->GetVegAge();
1007 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegBiomass ( int  a_polyref)
inline

Definition at line 874 of file landscape.h.

References m_polymapping.

875 {
876  return m_elems[ m_polymapping[ a_polyref ]]->GetVegBiomass();
877 }
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

Definition at line 879 of file landscape.h.

880 {
881  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegBiomass();
882 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegBiomassVector ( unsigned int  a_index)
inline

Definition at line 869 of file landscape.h.

870 {
871  return m_elems[ a_index ]->GetVegBiomass();
872 }
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

Definition at line 969 of file landscape.h.

References m_polymapping.

Referenced by Pesticide::MainMapDecay().

970 {
971  return m_elems[ m_polymapping[ a_polyref ]]->GetVegCover();
972 }
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

Definition at line 979 of file landscape.h.

980 {
981  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegCover();
982 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegCoverVector ( unsigned int  a_index)
inline

Definition at line 974 of file landscape.h.

975 {
976  return m_elems[ a_index ]->GetVegCover();
977 }
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

Definition at line 896 of file landscape.h.

References m_polymapping.

897 {
898  return m_elems[ m_polymapping[ a_polyref ]]->GetVegDensity();
899 }
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

Definition at line 919 of file landscape.h.

920 {
921  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegDensity();
922 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegDigestability ( int  a_polyref)
inline

Definition at line 840 of file landscape.h.

References m_polymapping.

Referenced by Rabbit_Warren::UpdateForageInformation().

841 {
842  return m_elems[ m_polymapping[ a_polyref ]]->GetDigestability();
843 }
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

Definition at line 846 of file landscape.h.

847 {
848  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDigestability();
849 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegDigestabilityVector ( unsigned int  a_index)
inline

Definition at line 835 of file landscape.h.

836 {
837  return m_elems[ a_index ]->GetDigestability();
838 }
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

Definition at line 857 of file landscape.h.

References m_polymapping.

Referenced by Rabbit_Warren::UpdateForageInformation().

858 {
859  return m_elems[ m_polymapping[ a_polyref ]]->GetVegHeight();
860 }
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

Definition at line 862 of file landscape.h.

863 {
864  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegHeight();
865 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyVegHeightVector ( unsigned int  a_index)
inline

Definition at line 852 of file landscape.h.

853 {
854  return m_elems[ a_index ]->GetVegHeight();
855 }
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

Definition at line 907 of file landscape.h.

References m_polymapping.

908 {
909  return m_elems[ m_polymapping[ a_polyref ]]->GetVegPatchy();
910 }
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

Definition at line 913 of file landscape.h.

914 {
915  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegPatchy();
916 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
int Landscape::SupplyVegPhase ( int  a_poly)
inline

Definition at line 164 of file landscape.h.

References m_polymapping.

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

Definition at line 1243 of file landscape.h.

1244 {
1245  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegType();
1246 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
TTypesOfVegetation Landscape::SupplyVegType ( int  polyref)
inline

Definition at line 1135 of file landscape.h.

References m_polymapping.

1136 {
1137  return m_elems[ m_polymapping[ a_polyref ] ]->GetVegType();
1138 }
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

Definition at line 1141 of file landscape.h.

1142 {
1143  return m_elems[ a_index ]->GetVegType();
1144 }
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

Definition at line 727 of file landscape.h.

727 { return m_versioninfo; }
char m_versioninfo[30]
Definition: landscape.h:112
double Landscape::SupplyWeedBiomass ( int  a_polyref)
inline

Definition at line 885 of file landscape.h.

References m_polymapping.

886 {
887  return m_elems[ m_polymapping[ a_polyref ]]->GetWeedBiomass();
888 }
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

Definition at line 891 of file landscape.h.

892 {
893  return m_elems[ m_land->Get( a_x, a_y ) ]->GetWeedBiomass();
894 }
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 Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
double Landscape::SupplyWind ( void  )
inline

Definition at line 1343 of file landscape.h.

References g_weather, and Weather::GetWind().

1344 {
1345  return g_weather->GetWind();
1346 }
double GetWind(long a_date)
Definition: weather.h:425
class Weather * g_weather
Definition: weather.cpp:41
double Landscape::SupplyWind ( long  a_date)
inline

Definition at line 1326 of file landscape.h.

References g_weather, and Weather::GetWind().

1327 {
1328  return g_weather->GetWind( a_date );
1329 }
double GetWind(long a_date)
Definition: weather.h:425
class Weather * g_weather
Definition: weather.cpp:41
int Landscape::SupplyWindDirection ( void  )
inline

Definition at line 1349 of file landscape.h.

References g_weather, and Weather::GetWindDirection().

Referenced by Pesticide::DailyQueueProcess().

1350 {
1351  return g_weather->GetWindDirection();
1352 }
class Weather * g_weather
Definition: weather.cpp:41
int GetWindDirection(void)
Definition: weather.h:427
double Landscape::SupplyWindPeriod ( long  a_date,
int  a_period 
)
inline

Definition at line 1331 of file landscape.h.

References g_weather, and Weather::GetWindPeriod().

1332 {
1333  return g_weather->GetWindPeriod( a_date, a_period );
1334 }
class Weather * g_weather
Definition: weather.cpp:41
double GetWindPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:287
int Landscape::SupplyYear ( void  )
inline

Definition at line 1537 of file landscape.h.

References g_date, and Calendar::GetYear().

1538 {
1539  return g_date->GetYear();
1540 }
int GetYear(void)
Definition: calendar.h:67
class Calendar * g_date
Definition: calendar.cpp:38
int Landscape::SupplyYearNumber ( void  )
inline

Definition at line 1542 of file landscape.h.

References g_date, and Calendar::GetYearNumber().

Referenced by Rabbit_Population_Manager::DoFirst(), FarmManager::FarmManagement(), and Farm::Trial_PesticideTreat_DateLimited().

1543 {
1544  return g_date->GetYearNumber();
1545 }
int GetYearNumber(void)
Definition: calendar.h:68
class Calendar * g_date
Definition: calendar.cpp:38
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.

Definition at line 1294 of file Landscape.cpp.

References cfg_productapplicendyear, cfg_productapplicstartyear, cfg_rodenticide_enable, Calendar::DayInYear(), g_date, g_pest, g_rand_uni(), g_weather, Calendar::GetYearNumber(), janfirst, Calendar::JanFirst(), 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, l_map_dump_veg_y, marchfirst, Calendar::MarchFirst(), Calendar::Tick(), Pesticide::Tick(), Weather::Tick(), toof_Foobar, tos_Foobar, tov_Maize, tov_Undefined, CfgInt::value(), and CfgBool::value().

1294  {
1303  g_date->Tick();
1304  g_weather->Tick();
1305 
1306  // Remember todays LAItotal for veg elements
1307  for (unsigned int i = 0; i < m_elems.size(); i++) {
1308  m_elems[ i ]->StoreLAItotal();
1309  }
1310 
1311  // Update the growth curve phases if needed.
1312  if (g_date->JanFirst()) {
1313  if (g_rand_uni() > 0.5) {
1314  m_FarmManager->SetSpilledGrain( true );
1315  }
1316  else m_FarmManager->SetSpilledGrain( false );
1317  for (unsigned int i = 0; i < m_elems.size(); i++) {
1318  m_elems[ i ]->SetGrowthPhase( janfirst );
1319  }
1320  }
1321  else if (g_date->MarchFirst()) {
1322  for (unsigned int i = 0; i < m_elems.size(); i++) {
1323  m_elems[ i ]->SetGrowthPhase( marchfirst );
1324  }
1325  // Check and see if the pesticide engine flag should be set
1327  m_toxShouldSpray = true;
1328  else m_toxShouldSpray = false;
1329  }
1330 
1331 
1332  // Grow the green stuff and let the bugs have some too.
1333  for (unsigned int i = 0; i < m_elems.size(); i++) {
1334  m_elems[ i ]->Tick();
1335  m_elems[ i ]->DoDevelopment();
1336  }
1337 
1338  //call ActualProfit function, then save this year's crop prices - for the next year's expected results calculation, then change price
1339  if (cfg_OptimisingFarms.value()) {
1340  if (!cfg_OptimiseBedriftsmodelCrops.value()) { //do this just in almass crop mode
1341 
1342  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.
1343 
1345 
1346  //print the m_cropTotals
1347  ofstream ofile2( "CropDistribution.txt", ios::app );
1348  // the distibution of crops from last year!
1349  int last_year = g_date->GetYearNumber() - 1;
1350  ofile2 << last_year << '\t';
1351  for (int c = 0; c < m_FarmManager->pm_data->Get_noCrops(); c++) ofile2 << m_FarmManager->Get_cropTotals( c ) << '\t';
1352  ofile2 << endl;
1353  //restart the m_cropTotals:
1354  for (int i = 0; i < (int)m_FarmManager->Get_cropTotals_size(); i++) {
1355  m_FarmManager->Set_cropTotals( i, 0 );
1356  }
1357 
1358  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)
1359  m_FarmManager->Save_last_years_crops_for_farms(); //saves m_rotational_crops in m_rotational_crops_visible
1361  }
1362 
1363  }
1364 
1365  //save the last year crop price;
1366  if (g_date->GetYearNumber() > 1 && g_date->DayInYear() == g_date->DayInYear( 1, 03 )) {
1367  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;
1368  int no_crops = m_FarmManager->pm_data->Get_cropTypes_almass_size();
1369  for (int c = 0; c < no_crops; c++) {
1370  double old_price = m_FarmManager->pm_data->Get_sellingPrice( tov_Undefined*f + m_FarmManager->pm_data->Get_cropTypes_almass( c ) ); //get the current price
1372  }
1373  }
1374  }
1375  //-----
1376 
1377 
1378  if (cfg_MaizeEnergy.value()) { //modify energy maize price
1379 
1380  if (g_date->DayInYear() == g_date->DayInYear( 1, 03 ) && g_date->GetYearNumber() != 0) { //print the price once a year
1381  ofstream ofileEM( "Maize_energy_price_yearly.txt", ios::app );
1382  int year = g_date->GetYearNumber();
1383  ofileEM << year << '\t';
1385  ofileEM << endl;
1386  ofileEM.close();
1387  }
1388 
1389  //changing price according to the input file EM_price.txt
1390  if (g_date->DayInYear() == g_date->DayInYear( 1, 03 ) && g_date->GetYearNumber() > 0) {//exclude the hidden year
1391  for (int f = 0; f < (toof_Foobar * tos_Foobar); f++) { //need to change the price for all farm types and soil types
1392  double new_price = m_FarmManager->pm_data->Get_emaize_price( g_date->GetYearNumber() );
1394  }
1395  }
1396  }// if energy maize
1397 
1398  }//almass crop mode
1399  }//optimising farms
1400 
1401  /* Testing removal - may cause issues with increasing or decreasing permanent vegetation
1402  if ( g_date->DayInYear() == g_date->DayInYear( 1, 11 ) ) {
1403  // Set all elements to smooth curve transition mode at November 1st.
1404  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
1405  m_elems[ i ]->ForceGrowthInitialize();
1406  }
1407  //save the day degrees - used for crops that are not harvested instead of biomass to determine yield; done on Nov 1st
1408  //m_FarmManager->SetDD (SupplyTempPeriod( g_date->Date(), 245)); // from Nov 1 - 245 days back till March 1;
1409  //DegreesDump();
1410  }
1411  */
1412 
1413  // Put the farmers to work.
1415 
1416 
1417  // Update pesticide information.
1418  g_pest->Tick();
1419 
1420  // Update rodenticide information if we are using this
1421  if (cfg_rodenticide_enable.value()) {
1422  m_RodenticideManager->Tick();
1423  m_RodenticidePreds->Tick();
1424  }
1425 
1426  // Dump event information if necessary
1429  //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() );
1431 }
CfgBool cfg_OptimisingFarms
If set to true, the farmer decision making model is active.
static CfgBool l_map_dump_event_enable("MAP_DUMP_EVENT_ENABLE", CFG_CUSTOM, false)
void ActualProfit()
Calls OptimisingFarm::ActualProfit for all optimising farms.
Definition: farm.cpp:2956
class Pesticide * g_pest
Definition: pesticide.cpp:70
void ChooseDecisionMode_for_farms()
Calls OptimisingFarm::ChooseDecisionMode for all optimising farms.
Definition: farm.cpp:2967
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_productapplicendyear("PEST_PROCTAPPLICENDYEAR", CFG_CUSTOM,-1)
void FarmManagement()
Runs the daily farm management for each farm, but also calculates annual spilled grain and maize...
Definition: farm.cpp:2258
CfgInt cfg_productapplicstartyear("PEST_PROCTAPPLICSTARTYEAR", CFG_CUSTOM, 9999999)
static CfgBool l_map_dump_veg_enable("MAP_DUMP_VEG_ENABLE", CFG_CUSTOM, true)
int GetYearNumber(void)
Definition: calendar.h:68
void SetSpilledGrain(bool a_spilledgrain)
Set m_SpilledGrain which is the flag for either 2013 (true) or 2014 (false) spilled grain distributio...
Definition: farm.h:1685
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
CfgBool cfg_OptimiseBedriftsmodelCrops
If set to true, the original farm optimisation model&#39;s crop set is used in the farmer decision making...
CfgBool cfg_MaizeEnergy
If set to true, the energy maize crop is included in the simulation.
class Weather * g_weather
Definition: weather.cpp:41
double Get_sellingPrice(int i)
Definition: farm.h:564
static CfgInt l_map_dump_veg_x("MAP_DUMP_VEG_X", CFG_CUSTOM, 100)
int SupplyYearNumber(void)
Definition: landscape.h:1542
bool value(void)
Definition: configurator.h:123
int DayInYear(void)
Definition: calendar.h:58
double Get_emaize_price(int i)
Definition: farm.h:588
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
void Tick(void)
Definition: pesticide.cpp:75
void Tick(void)
Definition: weather.cpp:58
void Set_sellingPrice(double a_value, int i)
Definition: farm.h:563
void Set_cropTotals(int i, double value)
Definition: farm.h:1696
DataForOptimisation * pm_data
Pointer to the DataForOptimisation.
Definition: farm.h:1733
void Save_last_years_crops_for_farms()
Calls OptimisingFarm::Save_last_years_crops for all optimising farms.
Definition: farm.cpp:2979
class Calendar * g_date
Definition: calendar.cpp:38
bool MarchFirst(void)
Definition: calendar.h:75
TTypesOfVegetation Get_cropTypes_almass(int i)
Definition: farm.h:579
double Get_cropTotals(int i)
Definition: farm.h:1694
bool JanFirst(void)
Definition: calendar.h:74
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:1531
int value(void)
Definition: configurator.h:92
static CfgInt l_map_dump_veg_y("MAP_DUMP_VEG_Y", CFG_CUSTOM, 100)
int Get_cropTypes_almass_size()
Definition: farm.h:580
void Tick(void)
Definition: calendar.cpp:141
void Set_sellingPrice_lastyr(double a_value, int i)
Definition: farm.h:565
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
int Get_noCrops()
Definition: farm.h:585
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
int Get_cropTotals_size()
Definition: farm.h:1697
static CfgInt l_map_dump_event_y1("MAP_DUMP_EVENT_YA", CFG_CUSTOM, 2909)
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:1456
TTypesOfLandscapeElement Landscape::TranslateEleTypes ( int  EleReference)
inline

Definition at line 1574 of file landscape.h.

References g_letype, and LE_TypeClass::TranslateEleTypes().

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

Definition at line 1581 of file landscape.h.

References g_letype, and LE_TypeClass::TranslateVegTypes().

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

Definition at line 826 of file landscape.h.

827 {
828  Tick();
829 }
void Tick(void)
Definition: Landscape.cpp:1294
bool Landscape::UMarginTest ( int  a_fieldpoly,
int  a_borderpoly,
int  a_x,
int  a_y,
int  a_width 
)
protected

Definition at line 2450 of file Landscape.cpp.

2450  {
2451  int index;
2452  int x_add[ 8 ] = { 1*a_width, 1*a_width, 0, -1*a_width, -1*a_width, -1*a_width, 0, 1*a_width };
2453  int y_add[ 8 ] = { 0, -1*a_width, -1*a_width, -1*a_width, 0, 1*a_width, 1*a_width, 1*a_width };
2454  int width = m_land->MapWidth();
2455  int height = m_land->MapHeight();
2456  // Scan anti-clockwise from center pixel coordinate.
2457  for ( unsigned int i = 0; i < 8; i++ ) {
2458  if ( ( a_x + x_add[ i ] >= width ) || ( a_x + x_add[ i ] < 0 ) || ( a_y + y_add[ i ] >= height )
2459  || ( a_y + y_add[ i ] < 0 ) ) {
2460  return true;
2461  }
2462  //continue;
2463  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2464  if ( ( index != a_fieldindex ) && ( index != a_marginindex ) ) return true;
2465  }
2466  return false;
2467 }
int MapWidth(void)
Definition: rastermap.h:57
int MapHeight(void)
Definition: rastermap.h:58
int Get(int a_x, int a_y)
Definition: rastermap.h:86
RasterMap * m_land
The big map.
Definition: landscape.h:122
void Landscape::UnsprayedMarginAdd ( LE a_field)
protected

Definition at line 2398 of file Landscape.cpp.

References g_msg, LE::GetValidX(), LE::GetValidY(), l_map_umargin_width, LE::SetArea(), LE::SetPoly(), LE::SetUnsprayedMarginPolyRef(), tole_UnsprayedFieldMargin, CfgInt::value(), MapErrorMsg::Warn(), and WARN_BUG.

2398  {
2399  int x = a_field->GetValidX();
2400  int y = a_field->GetValidY();
2401  if ( ( x == -1 ) || ( y == -1 ) ) {
2402  // Tripping this probably means it is not a field
2403  g_msg->Warn( WARN_BUG, "Landscape::UnsprayedMarginAdd(): Uninitialized border coordinate!", "" );
2404  exit( 1 );
2405  }
2406  LE * umargin = NewElement( tole_UnsprayedFieldMargin );
2407  m_polymapping[ hb_first_free_poly_num ] = (int) m_elems.size();
2408  m_elems.resize( m_elems.size() + 1 );
2409  m_elems[ m_elems.size() - 1 ] = umargin;
2411  umargin->SetPoly( hb_first_free_poly_num++ );
2412  umargin->SetArea( 0.0 );
2413 
2414  for ( int q = 0; q < l_map_umargin_width.value(); q++ )
2415  UnsprayedMarginScan( a_field, q + 1 );
2416 }
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:325
void SetUnsprayedMarginPolyRef(int a_unsprayedmargin)
Definition: elements.h:316
void UnsprayedMarginScan(LE *a_field, int a_width)
Definition: Landscape.cpp:2419
int GetValidX(void)
Definition: elements.h:324
Definition: elements.h:81
void SetPoly(int a_poly)
Definition: elements.h:220
static CfgInt l_map_umargin_width("MAP_UMARGINWIDTH", CFG_CUSTOM, 12)
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
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
int value(void)
Definition: configurator.h:92
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3455
void Landscape::UnsprayedMarginScan ( LE a_field,
int  a_width 
)
protected

Definition at line 2419 of file Landscape.cpp.

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

2419  {
2420  LE * umargin = g_landscape_p->SupplyLEPointer( a_field->GetUnsprayedMarginPolyRef() );
2421  int fieldpoly = a_field->GetPoly();
2422  int borderpoly = umargin->GetPoly();
2423  int borderindex = m_polymapping[ borderpoly ];
2424  int fieldindex = m_polymapping[ fieldpoly ];
2425  int notforever = 5000;
2426 
2427  // These two will be modified through pointer operations
2428  // in BorderStep().
2429  int x = a_field->GetValidX();
2430  int y = a_field->GetValidY();
2431  // Now the problem is that GetValid does not always return a valid co-ord!
2432  // so we need to search for one
2433  if ( !FindValidXY( fieldindex, x, y ) ) return;
2434 
2435  while ( --notforever ) {
2436  // Check if this position should be made into a border.
2437  if ( UMarginTest( fieldindex, borderindex, x, y, a_width ) ) {
2438  // Add this pixel to the border element in the big map.
2439  m_land->Put( x, y, borderindex );
2440  a_field->AddArea( -1.0 );
2441  umargin->AddArea( 1.0 );
2442  };
2443  // Step to next coordinate. Quit when done.
2444  if ( !BorderStep( fieldindex, borderindex, & x, & y ) )
2445  return;
2446  }
2447 }
bool FindValidXY(int a_field, int &a_x, int &a_y)
Definition: Landscape.cpp:2469
bool BorderStep(int a_fieldpoly, int a_borderpoly, int *a_x, int *a_y)
Definition: Landscape.cpp:2260
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
int GetValidY(void)
Definition: elements.h:325
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: elements.h:189
void Put(int a_x, int a_y, int a_elem)
Definition: rastermap.h:62
bool UMarginTest(int a_fieldpoly, int a_borderpoly, int a_x, int a_y, int a_width)
Definition: Landscape.cpp:2450
int GetValidX(void)
Definition: elements.h:324
Definition: elements.h:81
void AddArea(double a_area_diff)
Definition: elements.h:310
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

Definition at line 1456 of file Landscape.cpp.

References g_msg, MapErrorMsg::Warn(), and WARN_FILE.

1456  {
1457  FILE * vfile=fopen("VegDump.txt", "a" );
1458  if (!vfile) {
1459  g_msg->Warn( WARN_FILE, "Landscape::VegDump(): Unable to open file", "VegDump.txt" );
1460  exit( 1 );
1461  }
1462  int year = SupplyYearNumber();
1463  int day = SupplyDayInYear();
1464  double hei = SupplyVegHeight( x, y );
1465  double bio = SupplyVegBiomass( x, y );
1466  double cover = SupplyVegCover( x, y );
1467  double density = bio / ( hei + 1 );
1468  double weeds = SupplyWeedBiomass( x, y );
1469  double insects = SupplyInsects( x, y );
1470  double LATotal = SupplyLATotal(x, y);
1471  double LAGreen = SupplyLAGreen(x, y);
1472  double digest = SupplyVegDigestability(x, y);
1473  double GreenBiomass = SupplyGreenBiomass(x,y);
1474  double DeadBiomass = SupplyDeadBiomass(x,y);
1475  int grazed = SupplyGrazingPressure(x, y);
1476  double ggraze = GetActualGooseGrazingForage(m_land->Get(x, y), gs_Pinkfoot);
1477  int VegType = BackTranslateVegTypes(SupplyVegType(x, y));
1478  double grain = SupplyBirdSeedForage(x, y);
1479 
1480  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 );
1481  /*
1482  y += 100;
1483  x += 100;
1484  hei = SupplyVegHeight( x, y );
1485  bio = SupplyVegBiomass( x, y );
1486  cover = SupplyVegCover( x, y );
1487  density = bio / ( hei + 1 );
1488  weeds = SupplyWeedBiomass( x, y );
1489  VegType = SupplyVegType( x, y );
1490  insects = SupplyInsects( x, y );
1491  digest = SupplyVegDigestability(x,y);
1492  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 );
1493  */
1494  fclose( vfile );
1495 }
double SupplyLATotal(int a_x, int a_y)
Definition: landscape.h:925
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: landscape.h:1243
double SupplyGreenBiomass(int a_polyref)
Definition: landscape.h:938
int SupplyGrazingPressure(int a_polyref)
Definition: landscape.h:1148
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:559
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: landscape.h:1595
double SupplyLAGreen(int a_polyref)
Definition: landscape.h:962
int Get(int a_x, int a_y)
Definition: rastermap.h:86
double SupplyWeedBiomass(int a_polyref)
Definition: landscape.h:885
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
int SupplyYearNumber(void)
Definition: landscape.h:1542
double SupplyDeadBiomass(int a_polyref)
Definition: landscape.h:950
double SupplyInsects(int a_polyref)
Definition: landscape.h:1009
RasterMap * m_land
The big map.
Definition: landscape.h:122
int SupplyDayInYear(void)
Definition: landscape.h:1522
double SupplyVegBiomass(int a_polyref)
Definition: landscape.h:874
double SupplyVegCover(int a_polyref)
Definition: landscape.h:969
double SupplyBirdSeedForage(int a_polyref)
Returns the grain forage resource.
Definition: landscape.h:577
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:857
double SupplyVegDigestability(int a_polyref)
Definition: landscape.h:840
std::string Landscape::VegtypeToString ( TTypesOfVegetation  a_veg)

Definition at line 3943 of file Landscape.cpp.

References g_msg, tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_FieldPeas, tov_FieldPeasSilage, tov_FieldPeasStrigling, tov_FodderBeet, tov_FodderGrass, tov_Heath, tov_Lawn, tov_Maize, tov_MaizeSilage, tov_MaizeStrigling, tov_NaturalGrass, tov_NoGrowth, tov_None, tov_Oats, tov_OBarleyPeaCloverGrass, tov_OCarrots, tov_OCloverGrassGrazed1, tov_OCloverGrassGrazed2, tov_OCloverGrassSilage1, tov_OFieldPeas, tov_OFieldPeasSilage, tov_OFirstYearDanger, tov_OFodderBeet, tov_OGrazingPigs, tov_OMaizeSilage, tov_OOats, tov_OPermanentGrassGrazed, tov_OPotatoes, tov_OrchardCrop, tov_OSBarleySilage, tov_OSeedGrass1, tov_OSeedGrass2, tov_OSetaside, tov_OSpringBarley, tov_OSpringBarleyClover, tov_OSpringBarleyExt, tov_OSpringBarleyGrass, tov_OSpringBarleyPigs, tov_OTriticale, tov_OWinterBarley, tov_OWinterBarleyExt, tov_OWinterRape, tov_OWinterRye, tov_OWinterWheat, tov_OWinterWheatUndersown, tov_OWinterWheatUndersownExt, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_PlantNursery, tov_Potatoes, tov_PotatoesIndustry, tov_SeedGrass1, tov_SeedGrass2, tov_Setaside, tov_SpringBarley, tov_SpringBarleyCloverGrass, tov_SpringBarleyCloverGrassStrigling, tov_SpringBarleyGrass, tov_SpringBarleyPeaCloverGrassStrigling, tov_SpringBarleyPTreatment, tov_SpringBarleySeed, tov_SpringBarleySilage, tov_SpringBarleySKManagement, tov_SpringBarleySpr, tov_SpringBarleyStrigling, tov_SpringBarleyStriglingCulm, tov_SpringBarleyStriglingSingle, tov_SpringRape, tov_SpringWheat, tov_SugarBeet, tov_Triticale, tov_Undefined, tov_Wasteland, tov_WinterBarley, tov_WinterBarleyStrigling, tov_WinterRape, tov_WinterRapeStrigling, tov_WinterRye, tov_WinterRyeStrigling, tov_WinterWheat, tov_WinterWheatShort, tov_WinterWheatStrigling, tov_WinterWheatStriglingCulm, tov_WinterWheatStriglingSingle, tov_WWheatPControl, tov_WWheatPToxicControl, tov_WWheatPTreatment, tov_YoungForest, MapErrorMsg::Warn(), and WARN_FILE.

3943  {
3944  char error_num[20];
3945 
3946  switch (a_veg) {
3947  case tov_Carrots:
3948  return "Carrots ";
3949  case tov_BroadBeans:
3950  return "BroadBeans ";
3951  case tov_FodderGrass:
3952  return "FodderGrass ";
3954  return "CloverGrassGrazed1 ";
3956  return "CloverGrassGrazed2 ";
3957  case tov_FieldPeas:
3958  return "FieldPeas ";
3959  case tov_FieldPeasSilage:
3960  return "FieldPeasSilage ";
3961  case tov_FodderBeet:
3962  return "FodderBeet ";
3963  case tov_SugarBeet:
3964  return "SugarBeet ";
3965  case tov_OFodderBeet:
3966  return "OFodderBeet ";
3967  case tov_Lawn:
3968  return "Lawn ";
3969  case tov_Maize:
3970  return "Maize ";
3971  case tov_MaizeSilage:
3972  return "MaizeSilage ";
3973  case tov_OMaizeSilage:
3974  return "OMaizeSilage ";
3975  case tov_NaturalGrass:
3976  return "NaturalGrass ";
3977  case tov_NoGrowth:
3978  return "NoGrowth ";
3979  case tov_None:
3980  return "None ";
3981  case tov_OrchardCrop:
3982  return "OrchardCrop ";
3983  case tov_Oats:
3984  return "Oats ";
3986  return "OBarleyPeaCloverGrass";
3987  case tov_OCarrots:
3988  return "OCarrots ";
3990  return "OCloverGrassGrazed1 ";
3992  return "OCloverGrassGrazed2 ";
3994  return "OCloverGrassSilage1 ";
3995  case tov_OFieldPeas:
3996  return "OFieldPeas ";
3997  case tov_OFieldPeasSilage:
3998  return "OFieldPeasSilage ";
3999  case tov_OFirstYearDanger:
4000  return "OFirstYearDanger ";
4001  case tov_OGrazingPigs:
4002  return "OGrazingPigs ";
4003  case tov_OOats:
4004  return "OOats ";
4006  return "OPermanentGrassGrazed";
4007  case tov_OPotatoes:
4008  return "OPotatoes ";
4009  case tov_OSBarleySilage:
4010  return "OSBarleySilage ";
4011  case tov_OSeedGrass1:
4012  return "OSeedGrass1 ";
4013  case tov_OSeedGrass2:
4014  return "OSeedGrass2 ";
4015  case tov_OSetaside:
4016  return "OSetaside ";
4017  case tov_OSpringBarley:
4018  return "OSpringBarley ";
4019  case tov_OSpringBarleyExt:
4020  return "OSpringBarleyExt ";
4022  return "OSpringBarleyClover ";
4024  return "OSpringBarleyGrass ";
4025  case tov_OSpringBarleyPigs:
4026  return "OSpringBarleyPigs ";
4027  case tov_OTriticale:
4028  return "OTriticale ";
4029  case tov_OWinterBarley:
4030  return "OWinterBarley ";
4031  case tov_OWinterBarleyExt:
4032  return "OWinterBarleyExt ";
4033  case tov_OWinterRape:
4034  return "OWinterRape ";
4035  case tov_OWinterRye:
4036  return "OWinterRye ";
4038  return "OWinterWheatUndersown";
4039  case tov_OWinterWheat:
4040  return "OWinterWheat";
4042  return "OWinterWheatUsowExt ";
4044  return "PermanentGrassGrazed ";
4046  return "PermanentGrassLowYield";
4048  return "PermanentGrassTussocky";
4049  case tov_PermanentSetaside:
4050  return "PermanentSetaside ";
4051  case tov_Potatoes:
4052  return "PotatoesEat ";
4053  case tov_PotatoesIndustry:
4054  return "PotatoesIndustry ";
4055  case tov_SeedGrass1:
4056  return "SeedGrass1 ";
4057  case tov_SeedGrass2:
4058  return "SeedGrass2 ";
4059  case tov_Setaside:
4060  return "Setaside ";
4061  case tov_SpringBarley:
4062  return "SpringBarley ";
4063  case tov_SpringBarleySpr:
4064  return "SpringBarleySpr ";
4066  return "SpringBarleyPTreat ";
4068  return "SpringBarleySKMan ";
4070  return "SprBarleyCloverGrass ";
4071  case tov_SpringBarleyGrass:
4072  return "SpringBarleyGrass ";
4073  case tov_SpringBarleySeed:
4074  return "SpringBarleySeed ";
4076  return "SpringBarleySilage ";
4077  case tov_SpringRape:
4078  return "SpringRape ";
4079  case tov_SpringWheat:
4080  return "SpringWheat ";
4082  return "AgroChemIndustry Cereal ";
4083  case tov_Triticale:
4084  return "Triticale ";
4085  case tov_WinterBarley:
4086  return "WinterBarley ";
4087  case tov_WinterRape:
4088  return "WinterRape ";
4089  case tov_WinterRye:
4090  return "WinterRye ";
4091  case tov_WinterWheat:
4092  return "WinterWheat ";
4093  case tov_WinterWheatShort:
4094  return "WinterWheatShort ";
4095  case tov_WWheatPControl:
4096  return "P Trial Control ";
4098  return "P Trial Toxic Control";
4099  case tov_WWheatPTreatment:
4100  return "P Trial Treatment ";
4101  case tov_Undefined:
4102  return "Undefined ";
4104  return "WWStrigling ";
4106  return "WWStriglingSingle ";
4108  return "WWStriglingCulm ";
4110  return "SBPCGStrigling ";
4112  return "SBarleyStrigling ";
4114  return "SBarleyStriglingSgl ";
4116  return "SBarleyStriglingCulm ";
4117  case tov_MaizeStrigling:
4118  return "MaizseStrigling ";
4120  return "WRapeStrigling ";
4122  return "WRyeStrigling ";
4124  return "WBStrigling ";
4126  return "FieldPeasStrigling ";
4128  return "SBPeaCloverGrassStr ";
4129  case tov_YoungForest:
4130  return "Young Forest ";
4131  case tov_Wasteland:
4132  return "Wasteland ";
4133  case tov_Heath:
4134  return "Heath/Grass ";
4135  case tov_PlantNursery:
4136  return "Plant Nursery ";
4137 
4138  default:
4139  sprintf(error_num, "%d", a_veg);
4140  g_msg->Warn(WARN_FILE, "Landscape::VegtypeToString(): Unknown event type:", error_num);
4141  exit(1);
4142  }
4143 }
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
void Landscape::Warn ( std::string  a_msg1,
std::string  a_msg2 
)
inline
void Landscape::WriteOpenness ( void  )

Stores openness for all polygons to a standard file.

Member Data Documentation

int Landscape::hb_border_pixels
protected

Definition at line 254 of file landscape.h.

Referenced by hb_Add(), and hb_PaintBorder().

int Landscape::hb_core_pixels
protected

Definition at line 253 of file landscape.h.

Referenced by hb_Add(), and hb_PaintBorder().

int Landscape::hb_first_free_poly_num
protected

Definition at line 252 of file landscape.h.

Referenced by hb_GenerateHBPolys().

vector<int> Landscape::hb_hedges
protected

Definition at line 241 of file landscape.h.

Referenced by hb_Add(), and hb_FindHedges().

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

Definition at line 242 of file landscape.h.

Referenced by hb_GenerateHBPolys(), and hb_StripingDist().

int Landscape::hb_size
protected

Definition at line 249 of file landscape.h.

Referenced by hb_Add(), hb_DownPolyNumbers(), and hb_UpPolyNumbers().

int Landscape::hb_width
protected
double* Landscape::l_vegtype_areas
private

Definition at line 141 of file landscape.h.

int Landscape::le_signal_index
protected

Definition at line 297 of file landscape.h.

bool Landscape::m_DoMissingPolygonsManipulations
private

Flag to signal that missing polygons exist

Definition at line 138 of file landscape.h.

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.

Definition at line 119 of file landscape.h.

Referenced by hb_Add(), hb_DownPolyNumbers(), hb_FindHedges(), and hb_GenerateHBPolys().

FarmManager* Landscape::m_FarmManager
private

List of all the farms.

Definition at line 116 of file landscape.h.

Polynomial2CurveClass* Landscape::m_GooseIntakeRateVSVegetationHeight_BG
private

Definition at line 149 of file landscape.h.

Polynomial2CurveClass* Landscape::m_GooseIntakeRateVSVegetationHeight_GL
private

Definition at line 150 of file landscape.h.

Polynomial2CurveClass* Landscape::m_GooseIntakeRateVSVegetationHeight_PF
private

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

Definition at line 148 of file landscape.h.

int Landscape::m_height
private

Definition at line 128 of file landscape.h.

int Landscape::m_height10
private

Definition at line 130 of file landscape.h.

RasterMap* Landscape::m_land
private

The big map.

Definition at line 122 of file landscape.h.

Referenced by hb_Add().

int Landscape::m_LargestPolyNumUsed
protected

Definition at line 172 of file landscape.h.

int Landscape::m_maxextent
private

Definition at line 131 of file landscape.h.

bool Landscape::m_NeedCentroidCalculation
private

a flag to ensure centroid calculation on object construction

Definition at line 134 of file landscape.h.

bool Landscape::m_NeedOpennessCalculation
private

a flag to ensure openness calculation on object construction

Definition at line 136 of file landscape.h.

TTypesOfPesticide Landscape::m_PesticideType
protected

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

Definition at line 256 of file landscape.h.

vector<int> Landscape::m_PondIndexList
protected

List of pond indexes.

Definition at line 175 of file landscape.h.

vector<int> Landscape::m_PondRefsList
protected

List of pond polyrefs.

Definition at line 177 of file landscape.h.

RodenticideManager* Landscape::m_RodenticideManager
private

Definition at line 145 of file landscape.h.

RodenticidePredators_Population_Manager* Landscape::m_RodenticidePreds
private

Definition at line 146 of file landscape.h.

Population_Manager* Landscape::m_ThePopManager
private

a pointer to the current main population manager

Definition at line 143 of file landscape.h.

bool Landscape::m_toxShouldSpray
protected

Definition at line 295 of file landscape.h.

int Landscape::m_treatment_counts[last_treatment]
protected

Definition at line 171 of file landscape.h.

char Landscape::m_versioninfo[30]
private

Definition at line 112 of file landscape.h.

int Landscape::m_width
private

Definition at line 127 of file landscape.h.

int Landscape::m_width10
private

Definition at line 129 of file landscape.h.

int Landscape::m_x_add[8]
protected

Definition at line 244 of file landscape.h.

int Landscape::m_y_add[8]
protected

Definition at line 245 of file landscape.h.


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