ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
landscape.h
Go to the documentation of this file.
1 // Landscape.h
2 //
3 /*
4 *******************************************************************************************************
5 Copyright (c) 2011, Christopher John Topping, University of Aarhus
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or without modification, are permitted provided
9 that the following conditions are met:
10 
11 Redistributions of source code must retain the above copyright notice, this list of conditions and the
12 following disclaimer.
13 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
14 the following disclaimer in the documentation and/or other materials provided with the distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
19 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 ********************************************************************************************************
25 */
26 
27 #define _CRTDBG_MAP_ALLOC
28 
29 #ifndef TLANDSCAPE_H
30 #define TLANDSCAPE_H
31 
32 #include <vector>
33 
34 // General
35 const int January = 0;
36 const int February = 31;
37 const int March = 59;
38 const int April = 90;
39 const int May = 120;
40 const int June = 151;
41 const int July = 181;
42 const int August = 212;
43 const int September = 243;
44 const int October = 273;
45 const int November = 304;
46 const int December = 334;
47 
48 // m_polymapping is a mapping from polygon numbers into
49 // the list of landscape elements, m_elems.
50 extern int *m_polymapping;
51 
52 extern class Pesticide *g_pest;
53 
54 class RasterMap;
55 class SkTerritories;
56 class RodenticidePredators_Population_Manager;
57 
61 };
62 
63 
64 typedef enum
65 {
76 
79 {
80  int polyref;
81  int geese;
82  int geesesp[gs_foobar];
84  int geesespTimed[gs_foobar];
85  double openness;
86  double grain;
87  double maize;
88  double grass[gs_foobar]; // Available grass forage is species specific
90  std::string vegtypechr;
91  double vegheight;
92  double digestability;
93  int vegphase;
94  std::string previouscrop;
95  std::string lastsownveg;
96  std::string debugveg;
97 };
98 
100 typedef std::vector<GooseFieldListItem> GooseFieldList;
101 
102 
103 //------------------------------------------------------------------------------
104 
110 {
111  // Version info. Initialized by the constructor.
112  char m_versioninfo[30];
113 
115  //vector<Farm*> m_farms;
117 
119  vector<LE*> m_elems;
120 
123 
124  // For correcting coordinates before modulus operations.
125  // Put here so we saves an indirection when doing inline
126  // function calls.
127  int m_width;
128  int m_height;
132 
139 
140  // For veg area dumps
144 
145  RodenticideManager *m_RodenticideManager;
146  RodenticidePredators_Population_Manager* m_RodenticidePreds;
151 
152 public:
153  void FillVegAreaData();
154  inline double GetVegArea(int v) { return l_vegtype_areas[v]; }
155  void DumpVegAreaData(int a_day);
156  void SkylarkEvaluation(SkTerritories* a_skt);
157  void RodenticidePredatorsEvaluation(RodenticidePredators_Population_Manager* a_rppm);
159  Population_Manager * SupplyThePopManager() { return m_ThePopManager; }
161  void SetThePopManager(Population_Manager * a_ptr) { m_ThePopManager = a_ptr; }
162  // Only used if we are using rodenticide code
163  int SupplyFarmAnimalCensus(int a_farm_ref, int a_LifeStage);
164  int SupplyVegPhase(int a_poly) {
165  return m_elems[m_polymapping[a_poly]]->GetVegPhase();
166  }
167 protected:
169  void GISASCII_Output(string outpfile, int UTMX, int UTMY);
170 // Array for containing the treatment counts.
171  int m_treatment_counts[last_treatment];
173  void AddGreenElement( LE *a_green );
175  vector <int>m_PondIndexList;
177  vector <int>m_PondRefsList;
178  /*
179  void RenumberPolys(bool a_checkvalid);
180  */
181  void ReadPolys(const char *a_polyfile);
183  void ReadPolys2(const char *a_polyfile);
184  void PolysValidate(bool a_exit_on_invalid);
185  void PolysRemoveInvalid( void );
186  void PolysDump( const char *a_filename );
187  void DumpMap( const char *a_filename );
188  void ConsolidatePolys( void );
189  void CountMapSquares(void);
190  void PolysRenumber(void);
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  }
199  void ForceArea(void);
200  void ChangeMapMapping( void );
201  LE* NewElement( TTypesOfLandscapeElement a_type );
203  void RemoveMissingValues();
204  void TestCropManagement( void ); // Optional, configurable.
205  void VegDump(int x,int y);
206  void EventDump(int x,int y, int x2, int y2);
207  void EventDumpPesticides( int x1, int y1 );
209  void DegreesDump();
210  bool BorderNeed( TTypesOfLandscapeElement a_letype );
211  void BorderAdd(LE* a_field, TTypesOfLandscapeElement a_type);
212  void BorderRemoval( void );
214  int RemoveSmallPolygons( void );
216  void CreatePondList();
217  //void OrchardBorderAdd ( LE* a_field );
218  void UnsprayedMarginAdd ( LE* a_field );
219  void UnsprayedMarginScan( LE* a_field, int a_width );
220  void BorderScan( LE* a_field, int a_width );
221  bool BorderTest( int a_fieldpoly, int a_borderpoly, int a_x, int a_y );
222  bool StepOneValid( int a_polyindex, int a_x, int a_y, int step );
223  bool UMarginTest( int a_fieldpoly, int a_borderpoly,int a_x, int a_y, int a_width );
224  bool FindValidXY(int a_field, int &a_x, int &a_y);
225  bool BorderStep(int a_fieldpoly, int a_borderpoly, int* a_x, int* a_y);
226  bool BorderStep(int a_fieldpoly, int a_borderpoly, APoint* a_coord);
227  // int BorderJump( int a_add );
228 
229  void AddBeetleBanks( TTypesOfLandscapeElement a_tole );
230  bool BeetleBankPossible( LE * a_field, TTypesOfLandscapeElement a_tole );
231  void BeetleBankAdd(int x, int y, int angle, int length , LE* a_field, TTypesOfLandscapeElement a_tole);
232  bool FindFieldCenter(LE* a_field, int* x, int* y);
233  int FindLongestAxis(int* x, int* y, int* a_length);
234  void AxisLoop(int a_poly, int* a_x, int* a_y, int a_axis);
235  void AxisLoop(int a_poly, APoint* a_cor, int a_axis);
236  void AxisLoopLtd(int a_poly, APoint* a_cor, int a_axis, int a_limit);
237  // List of private methods and member elements, which are needed
238  // when adding artificial hedgebanks. Forget I did this. One should
239  // never store what is essentially local variables within the main
240  // class definition.
241  vector<int> hb_hedges;
242  vector<LE*> hb_new_hbs;
243 
244  int m_x_add[ 8 ];
245  int m_y_add[ 8 ];
246  int* hb_map;
247  int hb_width;
249  int hb_size;
250  int hb_min_x, hb_max_x;
251  int hb_min_y, hb_max_y;
257 
258  void hb_Add( void );
259  void hb_AddNewHedgebanks( int a_orig_poly_num );
260  int hb_StripingDist( void );
261  void hb_GenerateHBPolys( void );
262  void hb_FindHedges( void );
263  bool hb_FindBoundingBox( int a_poly_num );
264  void hb_UpPolyNumbers( void );
265  void hb_ClearPolygon( int a_poly_num );
266  void hb_PaintBorder( int a_color );
267  bool hb_MapBorder( int a_x, int a_y );
268  bool hb_HasOtherNeighbour( int a_x, int a_y );
269  bool hb_PaintWhoHasNeighbourColor( int a_neighbour_color,
270  int a_new_color );
271  bool hb_HasNeighbourColor( int a_x, int a_y,
272  int a_neighbour_color );
273  void hb_MarkTopFromLocalMax( int a_color );
274  void hb_MarkTheBresenhamWay( void );
275  int hb_MaxUnpaintedNegNeighbour( int a_x, int a_y );
276  void hb_ResetColorBits( void );
277  void hb_RestoreHedgeCore( int a_orig_poly_number );
278  void hb_DownPolyNumbers( void );
279  void hb_Cleanup( void );
280 
281  //#define HB_TESTING
282 
283  void DumpMapGraphics( const char *a_filename );
284 
285 #ifdef HB_TESTING
286  void hb_dump_map( int a_beginx, int a_width,
287  int a_beginy, int a_height,
288  char* a_filename,
289  bool a_high_numbers );
290  int hb_dump_color( int a_x, int a_y,
291  bool a_high_numbers );
292 #endif
293 
294  // The pesticide engine should I spray flag
296  // For the LE signal loop.
298 
299  void DumpTreatCounters( const char* a_filename );
300 
301  bool CIPELandscapeMaker();
302 
303 public:
304  ~Landscape( void );
305  Landscape( const char *a_configfile,
306  const char *a_errorfile );
307  //** \brief Things to do when closing the simulation */
308  void SimulationClosingActions();
309  // Tick() and TurnTheWorld() are identical, the last one is retained
310  // for historical reasons.
311  void Tick( void );
312  void TurnTheWorld( void );
313 
315  int HowManyPonds() { return int(m_PondIndexList.size()); }
317  int SupplyRandomPondIndex();
319  int SupplyRandomPondRef();
321  int SupplyPondIndex(int a_pondref) {
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  }
328  void SetMaleNewtPresent(int a_InPondIndex) { m_elems[a_InPondIndex]->SetMaleNewtPresent(true); }
330  bool SupplyMaleNewtPresent(int a_InPondIndex) { return m_elems[a_InPondIndex]->IsMaleNewtPresent(); }
331  Farm* SupplyFarmPtr(int a_owner) { return m_FarmManager->GetFarmPtr(a_owner); }
332  FarmManager* SupplyFarmManagerPtr() { return m_FarmManager; }
333 
334  int SupplyLargestPolyNumUsed() { return m_LargestPolyNumUsed; }
335 
336  bool SupplyShouldSpray() {return m_toxShouldSpray;}
337 
338  double SupplyVegDigestabilityVector( unsigned int a_index );
339  double SupplyVegDigestability( int a_polyref );
340  double SupplyVegDigestability( int a_x, int a_y );
341 
342  double SupplyVegHeightVector( unsigned int a_index );
343  double SupplyVegHeight( int a_polyref );
344  double SupplyVegHeight( int a_x, int a_y );
345 
346  double SupplyVegBiomassVector( unsigned int a_index );
347  double SupplyVegBiomass( int a_polyref );
348  double SupplyVegBiomass( int a_x, int a_y );
349 
350  int SupplyVegDensity( int a_polyref );
351  int SupplyVegDensity( int a_x, int a_y );
352 
353  double SupplyWeedBiomass( int a_polyref );
354  double SupplyWeedBiomass( int a_x, int a_y );
355 
356  bool SupplySkScrapes(int a_polyref);
357 
358  bool SupplyVegPatchy( int a_polyref );
359  bool SupplyVegPatchy( int a_x, int a_y );
360 
361  double SupplyGreenBiomass( int a_polyref );
362  double SupplyGreenBiomass( int a_x, int a_y );
363 
364  double SupplyDeadBiomass( int a_polyref );
365  double SupplyDeadBiomass( int a_x, int a_y );
366 
367  double SupplyLAGreen( int a_polyref );
368  double SupplyLAGreen( int a_x, int a_y );
369  double SupplyLATotal( int a_x, int a_y );
370 
371  double SupplyVegCover( int a_polyref );
372  double SupplyVegCoverVector( unsigned int a_index );
373  double SupplyVegCover( int a_x, int a_y );
374  TTypesOfVegetation SupplyLastSownVeg(int a_polyref);
375  TTypesOfVegetation SupplyLastSownVeg(int a_x, int a_y);
376  TTypesOfVegetation SupplyLastSownVegVector(unsigned int a_index);
377 
378  double SupplyInsects( int a_polyref );
379  double SupplyInsects( int a_x, int a_y );
381  bool SubtractPondLarvalFood(double a_food, int a_polyrefindex);
383  double SupplyRodenticide(int a_x, int a_y);
385  bool SupplyPesticideDecay();
387  double SupplyPesticide(int a_x, int a_y);
389  bool SupplyOverspray(int a_x, int a_y);
391  double SupplyPesticideP(int a_x, int a_y);
393  double SupplyPesticideS(int a_x, int a_y);
395  double SupplyPesticide(int a_polyref);
397  double SupplyPesticideP(int a_polyref);
399  double SupplyPesticideS(int a_polyref);
400  RodenticidePredators_Population_Manager* SupplyRodenticidePredatoryManager() { return m_RodenticidePreds; }
401  TTypesOfPesticide SupplyPesticideType( void ) { return m_PesticideType; }
403  GooseFieldList* GetGooseFields(double);
405  void CalculateOpenness(bool a_realcalc);
407  void WriteOpenness( void );
409  void ReadOpenness( void );
411  int CalulateFieldOpennessCentroid(int a_pref);
413  int CalulateFieldOpennessAllCells(int a_pref);
415  int LineHighTest(int a_cx, int a_cy, double a_offsetx, double a_offsety);
417  int SupplyOpenness(int a_poly) { return m_elems[m_polymapping[ a_poly ]]->GetOpenness(); }
419  int SupplyOpenness(int a_x, int a_y) { return m_elems[ m_land->Get( a_x, a_y )]->GetOpenness(); }
421  bool SupplyLEHigh(int a_x, int a_y) { return m_elems[ m_land->Get( a_x, a_y ) ]->GetHigh(); }
423  polylist* SupplyLargeOpenFieldsNearXY(int x, int y, int range, int a_openness );
424 
426  int SupplySoilType( int a_x, int a_y ) {
427  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSoilType( );
428  }
430  int SupplySoilTypeR( int a_x, int a_y ) {
431  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSoilTypeR( );
432  }
433 
434  APoint SupplyCentroid( int a_polyref );
435  APoint SupplyCentroidIndex( int a_polyrefindex );
436  int SupplyCentroidX( int a_polyref ) {
437  return m_elems[ m_polymapping[ a_polyref ] ]->GetCentroidX();
438  }
439  int SupplyCentroidY( int a_polyref ) { return m_elems[m_polymapping[ a_polyref ]]->GetCentroidY(); }
440  int SupplyCentroidX( int a_x, int a_y ) { return m_elems[ m_land->Get( a_x, a_y )]->GetCentroidX(); }
441  int SupplyCentroidY( int a_x, int a_y ) { return m_elems[ m_land->Get( a_x, a_y )]->GetCentroidY(); }
442 
443  int SupplyFarmIntensity( int a_x, int a_y );
444  int SupplyFarmIntensity( int a_polyref );
445  int SupplyFarmIntensityI( int a_polyindex );
446 
447  TTypesOfLandscapeElement SupplyElementType( int a_polyref );
448  TTypesOfLandscapeElement SupplyElementType( int a_x, int a_y );
449  TTypesOfLandscapeElement SupplyElementTypeCC( int a_x, int a_y );
450 
451  int SupplyCountryDesig( int a_x, int a_y );
452 
453  int SupplyElementSubType( int a_polyref );
454  int SupplyElementSubType( int a_x, int a_y );
455 
456  TTypesOfVegetation SupplyVegType(int a_x, int a_y);
457  TTypesOfVegetation SupplyVegType(int polyref);
458  TTypesOfVegetation SupplyVegTypeVector( unsigned int a_index );
459  int SupplyGrazingPressureVector(unsigned int a_index);
460  int SupplyGrazingPressure(int a_polyref);
461  int SupplyGrazingPressure(int a_x, int a_y);
462  bool SupplyIsCereal(int a_polyref);
463  bool SupplyIsMatureCereal(int a_polyref);
464  bool SupplyIsGrass(int a_polyref);
465  bool SupplyHasTramlines( int a_x, int a_y );
466  bool SupplyHasTramlines( int a_polyref );
467  bool SupplyJustMownVector( unsigned int a_index );
468  bool SupplyJustMown( int a_polyref );
469  int SupplyJustSprayedVector( unsigned int a_index );
470  int SupplyJustSprayed( int a_polyref );
471  int SupplyJustSprayed( int a_x, int a_y );
472  int SupplyTreeAge(int a_Polyref);
473  int SupplyTreeAge(int /* a_x */, int /* a_y */) {return 0;}
474  int SupplyVegAge(int a_Polyref);
475  int SupplyVegAge(int a_x, int a_y);
476  int SupplyNumberOfFarms();
477  int SupplyFarmOwner( int a_x, int a_y );
478  int SupplyFarmOwner( int a_polyref );
479  int SupplyFarmOwnerIndex( int a_x, int a_y );
480  int SupplyFarmOwnerIndex( int a_polyref );
481 
482  TTypesOfFarm SupplyFarmType( int a_polyref );
483  TTypesOfFarm SupplyFarmType( int a_x, int a_y );
484  TTypesOfOptFarms SupplyOptFarmType (int a_x, int a_y); //AM, 270813
485  int SupplyFarmArea( int a_polyref );
486  double SupplyPolygonAreaVector( int a_polyref );
487  double SupplyPolygonArea( int a_polyref ) { return m_elems[ m_polymapping[ a_polyref ]]->GetArea(); }
488 
492  void SetBirdSeedForage(int a_polyref, double a_fooddensity)
493  {
494  m_elems[m_polymapping[a_polyref]]->SetBirdSeed(a_fooddensity);
495  }
499  void SetBirdMaizeForage( int a_polyref, double a_fooddensity ) {
500  m_elems[ m_polymapping[ a_polyref ] ]->SetBirdMaize( a_fooddensity );
501  }
505  double SupplyGooseGrazingForageH( double a_height, GooseSpecies a_goose)
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  }
527 
530  double SupplyGooseGrazingForageH(int a_polygon, GooseSpecies a_goose)
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  }
559  double GetActualGooseGrazingForage(int a_x, int a_y, GooseSpecies a_goose)
560  {
561  return m_elems[m_land->Get(a_x, a_y)]->GetGooseGrazingForage(a_goose);
562  }
570  double GetActualGooseGrazingForage(int a_polygon, GooseSpecies a_goose)
571  {
572  return m_elems[m_polymapping[a_polygon]]->GetGooseGrazingForage(a_goose);
573  }
577  double SupplyBirdSeedForage(int a_polyref)
578  {
579  return m_elems[m_polymapping[a_polyref]]->GetBirdSeed();
580  }
584  double SupplyBirdSeedForage(int a_x, int a_y)
585  {
586  return m_elems[m_land->Get(a_x, a_y)]->GetBirdSeed();
587  }
591  double SupplyBirdMaizeForage( int a_polyref ) {
592  return m_elems[ m_polymapping[ a_polyref ] ]->GetBirdMaize();
593  }
597  double SupplyBirdMaizeForage( int a_x, int a_y ) {
598  return m_elems[ m_land->Get( a_x, a_y ) ]->GetBirdMaize();
599  }
604  void RecordGooseNumbers(int a_poly, int a_number);
609  void RecordGooseSpNumbers(int a_poly, int a_number, GooseSpecies a_goose);
614  void RecordGooseNumbersTimed(int a_poly, int a_number);
619  void RecordGooseSpNumbersTimed(int a_poly, int a_number, GooseSpecies a_goose);
623  void GrazeVegetation( int a_poly, double a_forage ) {
624  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetation( a_forage, true );
625  }
629  void GrazeVegetationTotal( int a_poly, double a_forage ) {
630  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetationTotal( a_forage );
631  }
635  int GetGooseNumbers(int a_poly);
639  int GetGooseNumbers(int a_x, int a_y);
640 
641  int SupplyLastTreatment( int a_polyref, int *a_index );
642  int SupplyLastTreatment( int a_x, int a_y, int *a_index );
643  double GetHareFoodQuality(int a_polygon);
644 
645  // Weather data.
646 
647  // Energizer Bunny Edition. Use these if at all possible.
648  // Returns the requested data for *today* (whatever that is).
649  double SupplyGlobalRadiation( );
650  double SupplyGlobalRadiation( long a_date );
651  double SupplyRain( void );
652  double SupplyTemp( void );
653  double SupplyHumidity(void);
654  double SupplyMeanTemp(long a_date, unsigned int a_period);
655  double SupplyWind( void );
656  int SupplyWindDirection( void );
657  double SupplySnowDepth( void );
658  bool SupplySnowcover( void );
659  int SupplyDaylength( void );
660 
661  // *Yawn*! These work for all dates as expected, but
662  // they are slow, slow, slzzz....
663  double SupplyRain( long a_date );
664  double SupplyTemp( long a_date );
665  double SupplyWind( long a_date );
666  double SupplyDayDegrees(int a_polyref);
667  double SupplyRainPeriod( long a_date, int a_period );
668  double SupplyWindPeriod( long a_date, int a_period );
669  double SupplyTempPeriod(long a_date, int a_period);
670  // double SupplyGlobalRadiation( a_date );
671 
672  // Warning: Known spooky behaviour, but it works, sort of...
673  bool SupplySnowcover( long a_date );
674 
675  // Misc.
677  if ((a_tole == tole_Field)
678  || (a_tole == tole_Orchard)
679  || (a_tole == tole_PermanentSetaside)
680  || (a_tole == tole_PermPasture)
681  || (a_tole == tole_PermPastureLowYield)
682  || (a_tole == tole_PermPastureTussocky)
683  || (a_tole == tole_PermPastureTussockyWet)
684  || (a_tole == tole_Vildtager)
685  || (a_tole == tole_YoungForest)
686  || (a_tole == tole_WoodyEnergyCrop)
687  ) return true;
688  return false;
689  }
690  int SupplyPolyRef( int a_x, int a_y );
691  int SupplyPolyRefIndex( int a_x, int a_y );
692  int SupplyPolyRefCC( int a_x, int a_y );
693  int SupplySimAreaWidth( void );
694  int SupplySimAreaHeight( void );
695  int SupplySimAreaMaxExtent( void );
696  int SupplySimAreaMinExtent( void );
697  int SupplyDaylength( long a_date );
698  int SupplyDayInYear( void );
699  int SupplyHour( void );
700  int SupplyMinute( void );
701  unsigned int SupplyNumberOfPolygons( void );
703  SupplyElementTypeFromVector( unsigned int a_index );
704  int SupplyPolyRefVector( unsigned int a_index );
705  int SupplyPesticideCell(int a_polyref);
706  int SupplyValidX(int a_polyref);
707  int SupplyValidY(int a_polyref);
708 
710  double SupplyPondPesticide(int a_poly_index) { return dynamic_cast<Pond*>(m_elems[a_poly_index])->SupplyPondPesticide(); }
711 
713  void CorrectCoords(int &x, int &y);
715  APoint CorrectCoordsPt(int x, int y);
717  void CorrectCoordsPointNoWrap( APoint &a_pt );
718  int CorrectWidth( int x );
719  int CorrectHeight( int y );
720  void SetPolyMaxMinExtents( void );
721  void CalculateCentroids( void );
722  void DumpCentroids( void );
724  void BuildingDesignationCalc();
725  void CentroidSpiralOut(int a_polyref, int &a_x, int &a_y);
726  void CentroidSpiralOutBlocks(int a_polyref, int &a_x, int &a_y);
727  const char* SupplyVersion(void) { return m_versioninfo; }
728 
729  // Debugging, warning and configuration methods.
730  void DumpPublicSymbols( const char *a_dumpfile,
731  CfgSecureLevel a_level ) {
732  g_cfg->DumpPublicSymbols( a_dumpfile, a_level );
733  }
734  void DumpAllSymbolsAndExit( const char *a_dumpfile ) {
735  g_cfg->DumpAllSymbolsAndExit( a_dumpfile );
736  }
737  bool ReadSymbols( const char *a_cfgfile ) {
738  return g_cfg->ReadSymbols( a_cfgfile );
739  }
740  void DumpMapInfoByArea( const char *a_filename,
741  bool a_append,
742  bool a_dump_zero_areas,
743  bool a_write_veg_names
744  );
745 
746  void Warn( std::string a_msg1, std::string a_msg2 );
747 
748  // This is really, really naughty, but for the sake of efficiency...
749  // SupplyMagicMapP( int a_x, int a_y ) returns a pointer to the map
750  // at position x, y. The value found through it is an internal magic
751  // number from the landscape simulator, that uniquely identifies a
752  // polygon. It is however not the polygon number. To find that one
753  // must convert the magic number via
754  // MagicMapP2PolyRef( int a_magic ).
755  //
756  int* SupplyMagicMapP( int a_x, int a_y );
757  int MagicMapP2PolyRef( int a_magic );
758 
759 // For the Roe Deer
760  int SupplyRoadWidth(int,int) {return 0;}
761  double SupplyTrafficLoad( int a_x, int a_y );
762  double SupplyTrafficLoad( int a_polyref );
763  int SupplyTreeHeight(int,int) {return 0;}
764  int SupplyUnderGrowthWidth(int,int) {return 0;}
765  int SupplyTreeHeight(int /* polyref */ ) {return 0;}
766  int SupplyUnderGrowthWidth(int /* polyref */ ) {return 0;}
767 
768 // For the debugging programmer.
769  long SupplyGlobalDate( void );
770  int SupplyYear( void );
771  int SupplyYearNumber( void );
772  int SupplyMonth( void );
773  int SupplyDayInMonth( void );
775  double SupplyNightProp() { return 1.0-g_date->GetDaylightProportion(); }
776 
777 // General use. Introduced 1/12-2003.
778 // Reset internal loop counter.
779  void SupplyLEReset( void );
780 // Returns -1 at end-of-loop, polygon ref otherwise.
781  int SupplyLENext( void );
782  int SupplyLECount( void );
783  LE_Signal SupplyLESignal( int a_polyref );
784  void SetLESignal( int a_polyref, LE_Signal a_signal );
785 
786  void IncTreatCounter( int a_treat );
787 
788  TTypesOfLandscapeElement TranslateEleTypes(int EleReference);
789  TTypesOfVegetation TranslateVegTypes(int VegReference);
790  LE* SupplyLEPointer( int a_polyref );
791 
792  int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference);
793  int BackTranslateVegTypes(TTypesOfVegetation VegReference);
794 
795  std::string EventtypeToString( int a_event );
796  std::string PolytypeToString( TTypesOfLandscapeElement a_le_type );
797  std::string VegtypeToString( TTypesOfVegetation a_veg );
798 
799  // /** \brief Reset all polygons natural grazing level to zero */
800  // void ResetAllVoleGrazing( void )
801  // {
802  // for ( unsigned int i=0; i<m_elems.size(); i++ ) m_elems[i]->ResetVoleGrazing();
803  // }
804  // /** \brief Inc volegrazing at x,y */
805  // void IncVoleGrazing(int a_x, int a_y) { m_elems[ m_land->Get( a_x, a_y ) ]->AddVoleGrazing(1); }
806  // /** \brief Get volegrazing at x,y */
807  // double SupplyVoleGrazingDensityVector(unsigned int a_index) { return m_elems[ a_index ]->GetVoleGrazingDensity(); }
808  // /** \brief Calculate all vole grazing densities */
809  // void CalcAllVoleGrazingDensity()
810  // {
811  //for ( unsigned int i=0; i<m_elems.size(); i++ ) { m_elems[i]->CalcVoleGrazingDensity(); }
812  // }
813 
814 protected:
815  void MakeCluster(void);
816  void ReadInput(int* , int* , int* , APoint*);
817  APoint RandomLocation(void);
818  APoint GetNextSeed(int);
819  int AddToClusterList(int* , int* , int*, int*, int*);
820  void ModifyPolyRef(int* );
821 };
822 
823 
824 extern Landscape *g_map;
825 
826 inline void Landscape::TurnTheWorld( void )
827 {
828  Tick();
829 }
830 
831 // We are interested in *speed*. Inlining all the lookup functions
832 // here and in the associated classes will cost us very little
833 // but a few KB of memory.
834 
835 inline double Landscape::SupplyVegDigestabilityVector(unsigned int a_index )
836 {
837  return m_elems[ a_index ]->GetDigestability();
838 }
839 
840 inline double Landscape::SupplyVegDigestability( int a_polyref )
841 {
842  return m_elems[ m_polymapping[ a_polyref ]]->GetDigestability();
843 }
844 
845 
846 inline double Landscape::SupplyVegDigestability( int a_x, int a_y )
847 {
848  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDigestability();
849 }
850 
851 
852 inline double Landscape::SupplyVegHeightVector( unsigned int a_index )
853 {
854  return m_elems[ a_index ]->GetVegHeight();
855 }
856 
857 inline double Landscape::SupplyVegHeight( int a_polyref )
858 {
859  return m_elems[ m_polymapping[ a_polyref ]]->GetVegHeight();
860 }
861 
862 inline double Landscape::SupplyVegHeight( int a_x, int a_y )
863 {
864  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegHeight();
865 }
866 
867 
868 
869 inline double Landscape::SupplyVegBiomassVector( unsigned int a_index )
870 {
871  return m_elems[ a_index ]->GetVegBiomass();
872 }
873 
874 inline double Landscape::SupplyVegBiomass( int a_polyref )
875 {
876  return m_elems[ m_polymapping[ a_polyref ]]->GetVegBiomass();
877 }
878 
879 inline double Landscape::SupplyVegBiomass( int a_x, int a_y )
880 {
881  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegBiomass();
882 }
883 
884 
885 inline double Landscape::SupplyWeedBiomass( int a_polyref )
886 {
887  return m_elems[ m_polymapping[ a_polyref ]]->GetWeedBiomass();
888 }
889 
890 
891 inline double Landscape::SupplyWeedBiomass( int a_x, int a_y )
892 {
893  return m_elems[ m_land->Get( a_x, a_y ) ]->GetWeedBiomass();
894 }
895 
896 inline int Landscape::SupplyVegDensity( int a_polyref )
897 {
898  return m_elems[ m_polymapping[ a_polyref ]]->GetVegDensity();
899 }
900 
901 
902 inline bool Landscape::SupplySkScrapes( int a_polyref )
903 {
904  return m_elems[ m_polymapping[ a_polyref ]]->GetSkScrapes();
905 }
906 
907 inline bool Landscape::SupplyVegPatchy( int a_polyref )
908 {
909  return m_elems[ m_polymapping[ a_polyref ]]->GetVegPatchy();
910 }
911 
912 
913 inline bool Landscape::SupplyVegPatchy( int a_x, int a_y )
914 {
915  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegPatchy();
916 }
917 
918 
919 inline int Landscape::SupplyVegDensity( int a_x, int a_y )
920 {
921  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegDensity();
922 }
923 
924 
925 inline double Landscape::SupplyLATotal( int a_x, int a_y )
926 {
927  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLATotal();
928 }
929 
930 
931 inline double Landscape::SupplyLAGreen( int a_x, int a_y )
932 {
933  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLAGreen();
934 }
935 
936 
937 
938 inline double Landscape::SupplyGreenBiomass( int a_polyref )
939 {
940  return m_elems[ m_polymapping[ a_polyref ]]->GetGreenBiomass();
941 }
942 
943 inline double Landscape::SupplyGreenBiomass( int a_x, int a_y )
944 {
945  return m_elems[ m_land->Get( a_x, a_y ) ]->GetGreenBiomass();
946 }
947 
948 
949 
950 inline double Landscape::SupplyDeadBiomass( int a_polyref )
951 {
952  return m_elems[ m_polymapping[ a_polyref ]]->GetDeadBiomass();
953 }
954 
955 inline double Landscape::SupplyDeadBiomass( int a_x, int a_y )
956 {
957  return m_elems[ m_land->Get( a_x, a_y ) ]->GetDeadBiomass();
958 }
959 
960 
961 
962 inline double Landscape::SupplyLAGreen( int a_polyref )
963 {
964  return m_elems[ m_polymapping[ a_polyref ]]->GetLAGreen();
965 }
966 
967 
968 
969 inline double Landscape::SupplyVegCover( int a_polyref )
970 {
971  return m_elems[ m_polymapping[ a_polyref ]]->GetVegCover();
972 }
973 
974 inline double Landscape::SupplyVegCoverVector( unsigned int a_index )
975 {
976  return m_elems[ a_index ]->GetVegCover();
977 }
978 
979 inline double Landscape::SupplyVegCover( int a_x, int a_y )
980 {
981  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegCover();
982 }
983 
985 {
986  return m_elems[a_index]->GetLastSownVeg();
987 }
988 
990 {
991  return m_elems[m_polymapping[a_polyref]]->GetLastSownVeg();
992 }
993 
995 {
996  return m_elems[m_land->Get(a_x, a_y)]->GetLastSownVeg();
997 }
998 
999 inline int Landscape::SupplyVegAge(int a_polyref)
1000 {
1001  return m_elems[ m_polymapping[ a_polyref ]]->GetVegAge();
1002 }
1003 
1004 inline int Landscape::SupplyVegAge( int a_x, int a_y )
1005 {
1006  return m_elems[m_land->Get(a_x, a_y)]->GetVegAge();
1007 }
1008 
1009 inline double Landscape::SupplyInsects( int a_polyref )
1010 {
1011  return m_elems[ m_polymapping[ a_polyref ]]->GetInsectPop();
1012 }
1013 
1014 inline double Landscape::SupplyInsects( int a_x, int a_y )
1015 {
1016  return m_elems[ m_land->Get( a_x, a_y ) ]->GetInsectPop();
1017 }
1018 
1019 
1020 inline LE* Landscape::SupplyLEPointer( int a_polyref )
1021 {
1022  return m_elems[ m_polymapping[ a_polyref ]];
1023 }
1024 
1026 {
1027  return m_elems[ a_index ]->GetElementType();
1028 }
1029 
1030 
1032 {
1033  return m_elems[ m_polymapping[ a_polyref ]]->GetElementType();
1034 }
1035 
1037 {
1038  return m_elems[ m_land->Get( a_x, a_y ) ]->GetElementType();
1039 }
1040 
1041 
1042 inline int Landscape::SupplyElementSubType( int a_polyref )
1043 {
1044  return m_elems[ m_polymapping[ a_polyref ]]->GetSubType();
1045 }
1046 
1047 inline int Landscape::SupplyElementSubType( int a_x, int a_y )
1048 {
1049  return m_elems[ m_land->Get( a_x, a_y ) ]->GetSubType();
1050 }
1051 
1052 
1053 inline int Landscape::SupplyCountryDesig( int a_x, int a_y )
1054 {
1055  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCountryDesignation();
1056 }
1057 
1058 
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 }
1066 
1067 
1068 
1070  return m_FarmManager->GetNoFarms();
1071 }
1072 
1073 inline int Landscape::SupplyFarmOwner( int a_x, int a_y ) {
1074  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerFile();
1075 }
1076 
1077 
1078 
1079 inline int Landscape::SupplyFarmOwner( int a_polyref )
1080 {
1081  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerFile();
1082 }
1083 
1084 
1085 
1086 inline int Landscape::SupplyFarmOwnerIndex( int a_x, int a_y )
1087 {
1088  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwnerIndex();
1089 }
1090 
1091 
1092 
1093 inline int Landscape::SupplyFarmOwnerIndex( int a_polyref )
1094 {
1095  return m_elems[ m_polymapping[ a_polyref ]]->GetOwnerIndex();
1096 }
1097 
1098 
1099 
1101 {
1102  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetType();
1103 }
1104 
1105 
1106 
1107 inline TTypesOfFarm Landscape::SupplyFarmType( int a_x, int a_y )
1108 {
1109  return m_elems[ m_land->Get( a_x, a_y ) ]->GetOwner()->GetType();
1110 }
1111 
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 }
1118 
1119 
1121 inline double Landscape::SupplyPolygonAreaVector( int a_polyref )
1122 {
1123  return m_elems[ a_polyref ]->GetArea();
1124 }
1125 
1126 
1127 inline int Landscape::SupplyFarmArea( int a_polyref )
1128 {
1129  return m_elems[ m_polymapping[ a_polyref ]]->GetOwner()->GetArea();
1130 }
1131 
1132 
1133 
1134 inline TTypesOfVegetation
1135  Landscape::SupplyVegType( int a_polyref )
1136 {
1137  return m_elems[ m_polymapping[ a_polyref ] ]->GetVegType();
1138 }
1139 
1140 inline TTypesOfVegetation
1141  Landscape::SupplyVegTypeVector( unsigned int a_index )
1142 {
1143  return m_elems[ a_index ]->GetVegType();
1144 }
1145 
1146 
1147 
1148 inline int Landscape::SupplyGrazingPressure( int a_polyref )
1149 {
1150  return m_elems[ m_polymapping[ a_polyref ] ]->GetCattleGrazing();
1151 }
1152 
1153 inline int Landscape::SupplyGrazingPressureVector( unsigned int a_index )
1154 {
1155  return m_elems[ a_index ]->GetCattleGrazing();
1156 }
1157 
1158 
1159 
1160 inline int Landscape::SupplyGrazingPressure( int a_x, int a_y )
1161 {
1162  return m_elems[ m_land->Get( a_x, a_y ) ]->GetCattleGrazing();
1163 }
1164 
1165 
1166 
1167 inline bool Landscape::SupplyHasTramlines( int a_polyref )
1168 {
1169  return m_elems[ m_polymapping[ a_polyref ] ]->HasTramlines();
1170 }
1171 
1172 
1173 inline bool Landscape::SupplyHasTramlines( int a_x, int a_y )
1174 {
1175  return m_elems[ m_land->Get( a_x, a_y ) ]->HasTramlines();
1176 }
1177 
1178 
1179 inline bool Landscape::SupplyJustMownVector( unsigned int a_index )
1180 {
1181  return m_elems[ a_index ]->IsRecentlyMown();
1182 }
1183 
1184 inline bool Landscape::SupplyJustMown( int a_polyref )
1185 {
1186  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlyMown();
1187 }
1188 
1189 
1190 
1191 inline int Landscape::SupplyJustSprayedVector( unsigned int a_index )
1192 {
1193  return m_elems[ a_index ]->IsRecentlySprayed();
1194 }
1195 
1196 inline int Landscape::SupplyJustSprayed( int a_polyref )
1197 {
1198  return m_elems[ m_polymapping[ a_polyref ] ]->IsRecentlySprayed();
1199 }
1200 
1201 inline int Landscape::SupplyJustSprayed( int a_x, int a_y )
1202 {
1203  return m_elems[ m_land->Get( a_x, a_y ) ]->IsRecentlySprayed();
1204 }
1205 
1206 
1207 
1208 inline double Landscape::SupplyTrafficLoad( int a_polyref )
1209 {
1210  return m_elems[ m_polymapping[ a_polyref ] ]->GetTrafficLoad();
1211 }
1212 
1213 
1214 inline double Landscape::SupplyTrafficLoad( int a_x, int a_y )
1215 {
1216  return m_elems[ m_land->Get( a_x, a_y ) ]->GetTrafficLoad();
1217 }
1218 
1219 
1220 inline bool Landscape::SupplyIsCereal(int a_polyref)
1221 {
1222  return m_elems[m_polymapping[a_polyref]]->IsCereal();
1223 }
1224 
1225 inline bool Landscape::SupplyIsMatureCereal(int a_polyref)
1226 {
1227  return m_elems[m_polymapping[a_polyref]]->IsMatureCereal();
1228 }
1229 
1230 inline bool Landscape::SupplyIsGrass(int a_polyref)
1231 {
1232  return m_elems[ m_polymapping[ a_polyref ] ]->IsGrass();
1233 }
1234 
1235 
1236 
1237 inline int Landscape::SupplyTreeAge( int /* a_polyref */ )
1238 {
1239  return 1;
1240 }
1241 
1242 inline TTypesOfVegetation
1243  Landscape::SupplyVegType( int a_x, int a_y )
1244 {
1245  return m_elems[ m_land->Get( a_x, a_y ) ]->GetVegType();
1246 }
1247 
1248 
1249 
1250 inline double Landscape::SupplyDayDegrees( int a_polyref )
1251 {
1252  return m_elems[ m_polymapping[ a_polyref ]]->GetDayDegrees();
1253 }
1254 
1255 inline int Landscape::SupplyLastTreatment( int a_polyref, int *a_index )
1256 {
1257  return m_elems[ m_polymapping[ a_polyref ]]->GetLastTreatment( a_index );
1258 }
1259 
1260 
1261 
1262 inline int Landscape::SupplyLastTreatment( int a_x, int a_y, int *a_index )
1263 {
1264  return m_elems[ m_land->Get( a_x, a_y ) ]->GetLastTreatment( a_index );
1265 }
1266 
1268 {
1269  return g_weather->GetGlobalRadiation( );
1270 }
1271 
1272 inline double Landscape::SupplyGlobalRadiation( long a_date )
1273 {
1274  return g_weather->GetGlobalRadiation( a_date );
1275 }
1276 
1277 inline double Landscape::SupplyRainPeriod( long a_date, int a_period )
1278 {
1279  return g_weather->GetRainPeriod( a_date, a_period );
1280 }
1281 
1282 
1283 
1284 inline double Landscape::SupplyRain( long a_date )
1285 {
1286  return g_weather->GetRain( a_date );
1287 }
1288 
1289 
1290 
1291 inline double Landscape::SupplyRain( void )
1292 {
1293  return g_weather->GetRain();
1294 }
1295 
1296 
1297 
1298 inline double Landscape::SupplyMeanTemp( long a_date, unsigned int a_period )
1299 {
1300  return g_weather->GetMeanTemp( a_date, a_period );
1301 }
1302 
1303 
1304 
1305 inline double Landscape::SupplyTemp( long a_date )
1306 {
1307  return g_weather->GetTemp( a_date );
1308 }
1309 
1310 
1311 
1312 inline double Landscape::SupplyTemp(void)
1313 {
1314  return g_weather->GetTemp();
1315 }
1316 
1317 
1318 
1319 inline double Landscape::SupplyHumidity(void)
1320 {
1321  return g_weather->GetHumidity();
1322 }
1323 
1324 
1325 
1326 inline double Landscape::SupplyWind( long a_date )
1327 {
1328  return g_weather->GetWind( a_date );
1329 }
1330 
1331 inline double Landscape::SupplyWindPeriod( long a_date, int a_period )
1332 {
1333  return g_weather->GetWindPeriod( a_date, a_period );
1334 }
1335 
1336 inline double Landscape::SupplyTempPeriod( long a_date, int a_period )
1337 {
1338  return g_weather->GetTempPeriod( a_date, a_period );
1339 }
1340 
1341 
1342 
1343 inline double Landscape::SupplyWind( void )
1344 {
1345  return g_weather->GetWind();
1346 }
1347 
1348 
1350 {
1351  return g_weather->GetWindDirection();
1352 }
1353 
1354 
1355 
1356 inline bool Landscape::SupplySnowcover( long a_date )
1357 {
1358  return g_weather->GetSnow( a_date );
1359 }
1360 
1361 
1362 
1363 inline bool Landscape::SupplySnowcover( void )
1364 {
1365  return g_weather->GetSnow();
1366 }
1367 
1368 
1369 
1370 inline double Landscape::SupplySnowDepth( void )
1371 {
1372  return g_weather->GetSnowDepth();
1373 }
1374 
1375 
1376 
1377 inline int Landscape::SupplyPolyRefVector( unsigned int a_index )
1378 {
1379  return m_elems[ a_index ]->GetPoly();
1380 }
1381 
1382 
1383 
1384 
1385 
1386 inline unsigned int
1388 {
1389  return (unsigned int) m_elems.size();
1390 }
1391 
1392 
1393 
1394 inline int Landscape::SupplyPesticideCell(int a_polyref)
1395 {
1396  return m_elems[ m_polymapping[ a_polyref ] ]->GetPesticideCell();
1397 }
1398 
1399 
1400 inline int Landscape::SupplyValidX(int a_polyref)
1401 {
1402  return m_elems[ m_polymapping[ a_polyref ] ]->GetValidX();
1403 }
1404 
1405 
1406 
1407 inline int Landscape::SupplyValidY(int a_polyref)
1408 {
1409  return m_elems[ m_polymapping[ a_polyref ] ]->GetValidY();
1410 }
1411 
1412 
1413 
1414 inline int Landscape::SupplyPolyRef( int a_x, int a_y )
1415 {
1416  return m_elems[ m_land->Get( a_x, a_y )]->GetPoly();
1417 }
1418 
1419 inline int Landscape::SupplyPolyRefIndex( int a_x, int a_y )
1420 {
1421  return m_land->Get( a_x, a_y );
1422 }
1423 
1424 
1425 
1426 inline int Landscape::SupplyPolyRefCC( int a_x, int a_y )
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 }
1432 
1433 
1434 
1435 inline int* Landscape::SupplyMagicMapP( int a_x, int a_y )
1436 {
1437  return m_land->GetMagicP( a_x, a_y );
1438 }
1439 
1440 
1441 
1442 inline int Landscape::MagicMapP2PolyRef( int a_magic )
1443 {
1444  return m_elems[ a_magic ]->GetPoly();
1445 }
1446 
1447 
1448 
1449 inline int Landscape::SupplyDaylength( long a_date )
1450 {
1451  return g_date->DayLength( a_date );
1452 }
1453 
1454 
1455 
1456 inline int Landscape::SupplyDaylength( void )
1457 {
1458  return g_date->DayLength();
1459 }
1460 
1461 inline void Landscape::CorrectCoords(int &x, int &y)
1462 {
1466  x = (m_width10 + x) % m_width;
1467  y = (m_height10 + y) % m_height;
1468 }
1469 
1470 inline APoint Landscape::CorrectCoordsPt(int x, int y)
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 }
1480 
1481 inline void Landscape::CorrectCoordsPointNoWrap(APoint & a_pt)
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 }
1491 
1492 
1493 inline int Landscape::CorrectWidth( int x )
1494 {
1495  return (m_width10+x)%m_width;
1496 }
1497 
1498 
1499 inline int Landscape::CorrectHeight( int y )
1500 {
1501  return (m_height10+y)%m_height;
1502 }
1503 
1504 
1505 inline void Landscape::Warn( std::string a_msg1, std::string a_msg2 )
1506 {
1507  g_msg->Warn( WARN_MSG, a_msg1, a_msg2 );
1508 }
1512 inline int Landscape::SupplyHour( void ) {
1513  return g_date->GetHour();
1514 }
1518 inline int Landscape::SupplyMinute( void ) {
1519  return g_date->GetMinute();
1520 }
1521 
1522 inline int Landscape::SupplyDayInYear( void )
1523 {
1524  return g_date->DayInYear();
1525 }
1526 
1527 inline int Landscape::SupplyMonth( void )
1528 {
1529  return g_date->GetMonth();
1530 }
1531 
1533 {
1534  return g_date->GetDayInMonth();
1535 }
1536 
1537 inline int Landscape::SupplyYear( void )
1538 {
1539  return g_date->GetYear();
1540 }
1541 
1543 {
1544  return g_date->GetYearNumber();
1545 }
1546 
1547 inline long Landscape::SupplyGlobalDate( void )
1548 {
1549  return g_date->Date();
1550 }
1551 
1552 // Outdated.
1553 //inline int Landscape::SupplyMapSize( void )
1554 //{
1555 // return m_land->Size();
1556 //}
1557 
1559 {
1560  return m_width;
1561 }
1562 
1564 {
1565  return m_height;
1566 }
1567 
1569 {
1570  return m_maxextent;
1571 }
1572 
1575 {
1576  return g_letype->TranslateEleTypes( EleReference );
1577 }
1578 
1579 
1580 inline TTypesOfVegetation
1582 {
1583  return g_letype->TranslateVegTypes( VegReference );
1584 }
1585 
1586 
1587 inline int
1589 {
1590  return g_letype->BackTranslateEleTypes( EleReference );
1591 }
1592 
1593 
1594 inline int
1596 {
1597  return g_letype->BackTranslateVegTypes( VegReference );
1598 }
1599 #endif // LANDSCAPE_H
1600 
TTypesOfOptFarms
Definition: farm.h:224
Farm * SupplyFarmPtr(int a_owner)
Definition: landscape.h:331
int SupplyDaylength(void)
Definition: landscape.h:1456
double SupplyLATotal(int a_x, int a_y)
Definition: landscape.h:925
bool GetSnow(long a_date)
Definition: weather.cpp:132
bool SupplyJustMown(int a_polyref)
Definition: landscape.h:1184
double SupplyBirdMaizeForage(int a_x, int a_y)
Returns the maize forage resource as seen from a goose standpoint at an x,y location.
Definition: landscape.h:597
int m_height10
Definition: landscape.h:130
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: landscape.h:1243
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1414
int SupplyTreeHeight(int, int)
Definition: landscape.h:763
int SupplyPolyRefCC(int a_x, int a_y)
Definition: landscape.h:1426
int m_width
Definition: landscape.h:127
const int November
Definition: landscape.h:45
The landscape class containing all environmental and topographical data.
Definition: landscape.h:109
bool SupplyJustMownVector(unsigned int a_index)
Definition: landscape.h:1179
int SupplyElementSubType(int a_polyref)
Definition: landscape.h:1042
int SupplyCentroidY(int a_x, int a_y)
Definition: landscape.h:441
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: elements.cpp:3042
long Date(void)
Definition: calendar.h:57
TTypesOfOptFarms SupplyOptFarmType(int a_x, int a_y)
Definition: landscape.h:1112
int SupplyLargestPolyNumUsed()
Definition: landscape.h:334
const int September
Definition: landscape.h:43
class Pesticide * g_pest
Definition: pesticide.cpp:70
std::string previouscrop
Definition: landscape.h:94
TTypesOfFarm
Definition: farm.h:167
unsigned int LE_Signal
Definition: elements.h:33
double SupplyVegCoverVector(unsigned int a_index)
Definition: landscape.h:974
int SupplyMonth(void)
Definition: landscape.h:1527
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
int SupplyFarmArea(int a_polyref)
Definition: landscape.h:1127
void CorrectCoords(int &x, int &y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1461
double grass[gs_foobar]
Definition: landscape.h:88
TTypesOfFarm SupplyFarmType(int a_polyref)
Definition: landscape.h:1100
double GetRain(long a_date)
Definition: weather.h:423
vector< LE * > 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 SupplyJustSprayed(int a_polyref)
Definition: landscape.h:1196
int hb_core_pixels
Definition: landscape.h:253
std::string lastsownveg
Definition: landscape.h:95
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: landscape.h:1581
bool SupplyIsGrass(int a_polyref)
Definition: landscape.h:1230
int SupplyCountryDesig(int a_x, int a_y)
Definition: landscape.h:1053
vector< LE * > hb_new_hbs
Definition: landscape.h:242
int SupplyJustSprayedVector(unsigned int a_index)
Definition: landscape.h:1191
int SupplyVegDensity(int a_polyref)
Definition: landscape.h:896
TTypesOfVegetation SupplyLastSownVeg(int a_polyref)
Definition: landscape.h:989
double SupplyVegBiomassVector(unsigned int a_index)
Definition: landscape.h:869
int SupplySimAreaMaxExtent(void)
Definition: landscape.h:1568
bool SupplyShouldSpray()
Definition: landscape.h:336
const int July
Definition: landscape.h:41
double GetWind(long a_date)
Definition: weather.h:425
int GetYearNumber(void)
Definition: calendar.h:68
int SupplyTreeAge(int a_Polyref)
Definition: landscape.h:1237
void SetBirdMaizeForage(int a_polyref, double a_fooddensity)
Sets the maize forage resource as seen from a goose standpoint at a polygon.
Definition: landscape.h:499
int SupplyWindDirection(void)
Definition: landscape.h:1349
int SupplyTreeHeight(int)
Definition: landscape.h:765
int SupplyCentroidY(int a_polyref)
Definition: landscape.h:439
void RebuildPolyMapping()
Definition: landscape.h:191
int SupplyHour(void)
Get the hour of the day.
Definition: landscape.h:1512
double SupplyGreenBiomass(int a_polyref)
Definition: landscape.h:938
int SupplyNumberOfFarms()
Definition: landscape.h:1069
int SupplyGrazingPressure(int a_polyref)
Definition: landscape.h:1148
double SupplyHumidity(void)
Definition: landscape.h:1319
double SupplyDaylightProp()
Definition: landscape.h:774
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1031
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
double SupplyBirdMaizeForage(int a_polyref)
Returns the maize forage resource.
Definition: landscape.h:591
int HowManyPonds()
Returns the number of ponds in the landscape.
Definition: landscape.h:315
double GetSnowDepth(void)
Get the current snow depth.
Definition: weather.h:431
RodenticideManager * m_RodenticideManager
Definition: landscape.h:145
TTypeOfDirections
ALMaSS 8 standard directions.
Definition: landscape.h:59
const int December
Definition: landscape.h:46
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: landscape.h:1595
void DumpPublicSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
Definition: landscape.h:730
TTypesOfVegetation
int geesesp[gs_foobar]
Definition: landscape.h:82
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: landscape.h:1574
double SupplyLAGreen(int a_polyref)
Definition: landscape.h:962
Definition: elements.h:81
TTypesOfVegetation vegtype
Definition: landscape.h:89
int SupplySimAreaWidth(void)
Definition: landscape.h:1558
int Get(int a_x, int a_y)
Definition: rastermap.h:86
int SupplyOpenness(int a_x, int a_y)
Get openness for a location.
Definition: landscape.h:419
double SupplySnowDepth(void)
Definition: landscape.h:1370
bool ReadSymbols(const char *a_cfgfile)
double SupplyWind(void)
Definition: landscape.h:1343
double SupplyVegHeightVector(unsigned int a_index)
Definition: landscape.h:852
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
Definition: landscape.h:150
void DumpAllSymbolsAndExit(const char *a_dumpfile)
Definition: landscape.h:734
bool SupplySnowcover(void)
Definition: landscape.h:1363
int m_height
Definition: landscape.h:128
int SupplySoilTypeR(int a_x, int a_y)
Returns the soil type in rabbit warren reference numbers.
Definition: landscape.h:430
void TurnTheWorld(void)
Definition: landscape.h:826
A farm that carries out crop, pesticide and fertilizer planning using simplified optimisation or othe...
Definition: farm.h:1885
Base class for all population managers.
double SupplyNightProp()
Definition: landscape.h:775
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 onl...
Definition: landscape.h:505
int SupplyOpenness(int a_poly)
Get openness for a polygon.
Definition: landscape.h:417
int SupplyGrazingPressureVector(unsigned int a_index)
Definition: landscape.h:1153
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: elements.cpp:2597
const int February
Definition: landscape.h:36
int m_maxextent
Definition: landscape.h:131
A list item entry of field polygon reference numbers with associated openness and goose food scores...
Definition: landscape.h:78
int SupplyUnderGrowthWidth(int)
Definition: landscape.h:766
class Weather * g_weather
Definition: weather.cpp:41
int SupplySoilType(int a_x, int a_y)
Returns the soil type in ALMaSS types reference numbers.
Definition: landscape.h:426
bool SupplyIsCereal(int a_polyref)
Definition: landscape.h:1220
double SupplyTrafficLoad(int a_x, int a_y)
Definition: landscape.h:1214
int SupplyValidY(int a_polyref)
Definition: landscape.h:1407
int hb_height
Definition: landscape.h:248
Landscape * g_map
bool m_DoMissingPolygonsManipulations
Definition: landscape.h:138
void DumpAllSymbolsAndExit(const char *a_dumpfile)
double SupplyWeedBiomass(int a_polyref)
Definition: landscape.h:885
const int October
Definition: landscape.h:44
double GetVegArea(int v)
Definition: landscape.h:154
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
const int April
Definition: landscape.h:38
class LE_TypeClass * g_letype
Definition: elements.cpp:265
APoint CorrectCoordsPt(int x, int y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1470
bool ReadSymbols(const char *a_cfgfile)
Definition: landscape.h:737
The Farm Manager class.
Definition: farm.h:1563
int GetYear(void)
Definition: calendar.h:67
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
void CorrectCoordsPointNoWrap(APoint &a_pt)
Function to prevent wrap around errors with co-ordinates using a APoint.
Definition: landscape.h:1481
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 ba...
Definition: landscape.h:530
The base class for all farm types.
Definition: farm.h:683
int SupplyYearNumber(void)
Definition: landscape.h:1542
Population_Manager * SupplyThePopManager()
Get the pointer to the current main population manager.
Definition: landscape.h:159
TTypesOfVegetation SupplyVegTypeVector(unsigned int a_index)
Definition: landscape.h:1141
int SupplyMinute(void)
Get the minute of the hour.
Definition: landscape.h:1518
int GetDayInMonth(void)
Definition: calendar.h:72
std::string debugveg
Definition: landscape.h:96
int SupplyUnderGrowthWidth(int, int)
Definition: landscape.h:764
int DayInYear(void)
Definition: calendar.h:58
double GetMeanTemp(long a_date, unsigned int a_period)
Definition: weather.cpp:120
bool SupplyIsMatureCereal(int a_polyref)
Definition: landscape.h:1225
int SupplyDayInMonth(void)
Definition: landscape.h:1532
double SupplyDeadBiomass(int a_polyref)
Definition: landscape.h:950
bool SupplyHasTramlines(int a_x, int a_y)
Definition: landscape.h:1173
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:116
double SupplyGlobalRadiation()
Definition: landscape.h:1267
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
Definition: landscape.h:149
double GetGlobalRadiation(long a_date)
Definition: weather.h:414
double SupplyInsects(int a_polyref)
Definition: landscape.h:1009
double SupplyRain(void)
Definition: landscape.h:1291
vector< int > m_PondIndexList
List of pond indexes.
Definition: landscape.h:175
const int June
Definition: landscape.h:40
bool IsFieldType(TTypesOfLandscapeElement a_tole)
Definition: landscape.h:676
double SupplyBirdSeedForage(int a_x, int a_y)
Returns the grain forage resource as seen from a goose standpoint at an x,y location.
Definition: landscape.h:584
int hb_first_free_poly_num
Definition: landscape.h:252
class Configurator * g_cfg
CfgSecureLevel
Definition: configurator.h:59
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
RasterMap * m_land
The big map.
Definition: landscape.h:122
int SupplyCentroidX(int a_polyref)
Definition: landscape.h:436
const int January
Definition: landscape.h:35
int SupplyPesticideCell(int a_polyref)
Definition: landscape.h:1394
FarmManager * SupplyFarmManagerPtr()
Definition: landscape.h:332
int SupplyFarmOwner(int a_x, int a_y)
Definition: landscape.h:1073
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: elements.cpp:2692
int SupplyValidX(int a_polyref)
Definition: landscape.h:1400
int SupplyPondIndex(int a_pondref)
Returns the index of a pond based on pondref or -1 if not found.
Definition: landscape.h:321
void SetThePopManager(Population_Manager *a_ptr)
Set the pointer to the current main population manager.
Definition: landscape.h:161
int SupplySimAreaHeight(void)
Definition: landscape.h:1563
double GetTempPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:297
double GetWindPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:287
int SupplyCentroidX(int a_x, int a_y)
Definition: landscape.h:440
int m_width10
Definition: landscape.h:129
int SupplyRoadWidth(int, int)
Definition: landscape.h:760
double SupplyPolygonArea(int a_polyref)
Definition: landscape.h:487
int GetMinute(void)
Definition: calendar.h:70
int SupplyDayInYear(void)
Definition: landscape.h:1522
int GetWindDirection(void)
Definition: weather.h:427
vector< unsigned > polylist
Definition: farm.h:162
int SupplyVegAge(int a_Polyref)
Definition: landscape.h:999
class Calendar * g_date
Definition: calendar.cpp:38
double SupplyVegBiomass(int a_polyref)
Definition: landscape.h:874
double SupplyDayDegrees(int a_polyref)
Definition: landscape.h:1250
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1082
bool SupplyVegPatchy(int a_polyref)
Definition: landscape.h:907
double GetHumidity(void)
Get the humidity score today.
Definition: weather.h:421
void GrazeVegetationTotal(int a_poly, double a_forage)
Removes grazing forage from a poly and divides this out per m2.
Definition: landscape.h:629
int CorrectWidth(int x)
Definition: landscape.h:1493
int SupplyVegPhase(int a_poly)
Definition: landscape.h:164
double SupplyWindPeriod(long a_date, int a_period)
Definition: landscape.h:1331
vector< int > hb_hedges
Definition: landscape.h:241
double SupplyVegCover(int a_polyref)
Definition: landscape.h:969
const int March
Definition: landscape.h:37
int SupplyYear(void)
Definition: landscape.h:1537
int CorrectHeight(int y)
Definition: landscape.h:1499
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 SupplyTempPeriod(long a_date, int a_period)
Definition: landscape.h:1336
bool m_toxShouldSpray
Definition: landscape.h:295
std::vector< GooseFieldListItem > GooseFieldList
A list of GooseFieldListItem s.
Definition: landscape.h:100
TTypesOfLandscapeElement SupplyElementTypeFromVector(unsigned int a_index)
Definition: landscape.h:1025
TTypesOfVegetation SupplyLastSownVegVector(unsigned int a_index)
Definition: landscape.h:984
const char * SupplyVersion(void)
Definition: landscape.h:727
int hb_min_x
Definition: landscape.h:250
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1505
int SupplyTreeAge(int, int)
Definition: landscape.h:473
double digestability
Definition: landscape.h:92
std::string vegtypechr
Definition: landscape.h:90
int geesespTimed[gs_foobar]
Definition: landscape.h:84
double SupplyBirdSeedForage(int a_polyref)
Returns the grain forage resource.
Definition: landscape.h:577
TTypesOfPesticide SupplyPesticideType(void)
Definition: landscape.h:401
int * SupplyMagicMapP(int a_x, int a_y)
Definition: landscape.h:1435
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
int DayLength(void)
Definition: calendar.h:63
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:857
double SupplyRainPeriod(long a_date, int a_period)
Definition: landscape.h:1277
void SetBirdSeedForage(int a_polyref, double a_fooddensity)
Sets the grain forage resource as seen from a goose standpoint at a polygon.
Definition: landscape.h:492
const int May
Definition: landscape.h:39
int SupplyPolyRefVector(unsigned int a_index)
Definition: landscape.h:1377
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
double * l_vegtype_areas
Definition: landscape.h:141
TTypesOfLandscapeElement SupplyElementTypeCC(int a_x, int a_y)
Definition: landscape.h:1060
void GrazeVegetation(int a_poly, double a_forage)
Removes grazing forage from a poly per m2.
Definition: landscape.h:623
bool SupplyMaleNewtPresent(int a_InPondIndex)
Determines if a male is present in a pond.
Definition: landscape.h:330
TTypesOfLandscapeElement
int * hb_map
Definition: landscape.h:246
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1419
long SupplyGlobalDate(void)
Definition: landscape.h:1547
Population_Manager * m_ThePopManager
a pointer to the current main population manager
Definition: landscape.h:143
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:278
bool m_NeedCentroidCalculation
a flag to ensure centroid calculation on object construction
Definition: landscape.h:134
int GetMonth(void)
Definition: calendar.h:69
int hb_size
Definition: landscape.h:249
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
Curve relatning goose intake rates in KJ/min to vegetation height.
Definition: landscape.h:148
bool m_NeedOpennessCalculation
a flag to ensure openness calculation on object construction
Definition: landscape.h:136
double GetDaylightProportion(void)
Definition: calendar.h:73
RodenticidePredators_Population_Manager * SupplyRodenticidePredatoryManager()
Definition: landscape.h:400
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
unsigned int SupplyNumberOfPolygons(void)
Definition: landscape.h:1387
const int August
Definition: landscape.h:42
double SupplyVegDigestabilityVector(unsigned int a_index)
Definition: landscape.h:835
int le_signal_index
Definition: landscape.h:297
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:146
void DumpPublicSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: elements.cpp:2864
double SupplyMeanTemp(long a_date, unsigned int a_period)
Definition: landscape.h:1298
Farm * GetFarmPtr(int a_owner)
Returns the pointer to a farm with a specific number.
Definition: farm.h:1623
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: landscape.h:1588
int GetHour(void)
Definition: calendar.h:71
int hb_width
Definition: landscape.h:247
double SupplyPolygonAreaVector(int a_polyref)
Returns the area of a polygon using the vector index as a reference.
Definition: landscape.h:1121
vector< int > m_PondRefsList
List of pond polyrefs.
Definition: landscape.h:177
TTypesOfPesticide
Definition: landscape.h:64
int hb_min_y
Definition: landscape.h:251
int hb_border_pixels
Definition: landscape.h:254
int SupplyLastTreatment(int a_polyref, int *a_index)
Definition: landscape.h:1255
double SupplyVegDigestability(int a_polyref)
Definition: landscape.h:840
bool SupplySkScrapes(int a_polyref)
Definition: landscape.h:902
int m_LargestPolyNumUsed
Definition: landscape.h:172
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...
Definition: landscape.h:570
double SupplyTemp(void)
Definition: landscape.h:1312
int SupplyFarmOwnerIndex(int a_x, int a_y)
Definition: landscape.h:1086
void SetMaleNewtPresent(int a_InPondIndex)
Sets a male as being present in a pond.
Definition: landscape.h:328
int MagicMapP2PolyRef(int a_magic)
Definition: landscape.h:1442