ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
elements.cpp
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
24 
25 #define _CRT_SECURE_NO_DEPRECATE
26 
27 
28 
29 #define __WEED_CURVE 99 //99 // 99 is the weed curve
30 
31 // The default no better information values (Mean of the four crop values)
32 #define EL_BUG_PERCENT_A 0.0
33 #define EL_BUG_PERCENT_B 0.2975
34 #define EL_BUG_PERCENT_C 0.095916647275
35 #define EL_BUG_PERCENT_D 0
36 
37 // SBarley
38 #define EL_BUG_PERCENT_SB_A 0
39 #define EL_BUG_PERCENT_SB_B 0.380763296
40 #define EL_BUG_PERCENT_SB_C 0
41 #define EL_BUG_PERCENT_D 0
42 
43 // WWheat
44 #define EL_BUG_PERCENT_WW_A 0.0
45 #define EL_BUG_PERCENT_WW_B 0.1283
46 #define EL_BUG_PERCENT_WW_C 0.0
47 #define EL_BUG_PERCENT_D 0
48 
49 // WRye
50 #define EL_BUG_PERCENT_WRy_A 0.0
51 #define EL_BUG_PERCENT_WRy_B 0.395651915
52 #define EL_BUG_PERCENT_WRy_C 0.0
53 #define EL_BUG_PERCENT_D 0
54 
55 //WRape
56 #define EL_BUG_PERCENT_WR_A 0.0
57 #define EL_BUG_PERCENT_WR_B 0.028271643
58 #define EL_BUG_PERCENT_WR_C 0.0
59 #define EL_BUG_PERCENT_D 0
60 
61 //Cropped/Grazed Grass
62 #define EL_BUG_PERCENT_G_A 4.123817127
63 #define EL_BUG_PERCENT_G_B 0.151015629
64 #define EL_BUG_PERCENT_G_C -0.228228353
65 #define EL_BUG_PERCENT_D 0
66 
67 //Edges
68 #define EL_BUG_PERCENT_Edges_A 10.72459109
69 #define EL_BUG_PERCENT_Edges_B 0.4
70 #define EL_BUG_PERCENT_Edges_C 2.529631141
71 #define EL_BUG_PERCENT_D 0
72 
73 
74 #include <math.h>
75 #include "../Landscape/ls.h"
76 #include "../BatchALMaSS/BoostRandomGenerators.h"
77 
78 extern boost::variate_generator<base_generator_type&, boost::uniform_real<> > g_rand_uni;
79 
80 extern void FloatToDouble(double &, float);
83 using namespace std;
84 
86 CfgBool cfg_calc_pond_pesticide("POND_PEST_CALC_ON", CFG_CUSTOM, false);
88 CfgFloat cfg_pondpesticiderunoff("POND_PEST_RUNOFFFACTOR", CFG_CUSTOM, 10.0);
89 
91 CfgInt cfg_goosecountperiod("GOOSE_GOOSECOUNTPERIOD",CFG_CUSTOM,1);
92 
93 const double c_SolarConversion[ 2 ] [ 81 ] = {
94  {
95  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.28,
96  0.56,0.84,1.12,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,
97  1.4,1.4,1.26,1.12,0.98,0.84,0.7,0.56,0.42,0.28,0.14,0,0,0,0,0,0,0,0,0,0,0,
98  0,0,0,0,0
99  },
100  {
101  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
102  0,0.242857,0.485714,0.728571,0.971429,1.214286,1.457143,1.7,1.7,1.7,1.7,
103  1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,1.7,
104  1.53,1.36,1.19,1.02,0.85,0.68,0.51,0.34,0.17,0,0,0,0,0,0
105  }
106  };
107 
109 static CfgFloat l_pest_productOrchard_amount( "PEST_PRODUCTORCHARD_AMOUNT", CFG_CUSTOM, 0.0 );
115 
116 
117 static CfgFloat cfg_beetlebankinsectscaler("ELE_BBINSECTSCALER",CFG_CUSTOM,1.0); // 1.0 means beetlebank is the same as hedgebank
119 static double g_weed_percent[ tov_Undefined ];
124 static CfgInt cfg_OrchardSprayDay( "TOX_ORCHARDSPRAYDAY", CFG_CUSTOM, 150 );
125 static CfgInt cfg_OrchardSprayDay2( "TOX_ORCHARDSPRAYDAYTWO", CFG_CUSTOM, 200000 );
126 CfgInt cfg_OrchardNoCutsDay( "TOX_ORCHARDNOCUTS", CFG_CUSTOM, -1 );
127 static CfgInt cfg_MownGrassNoCutsDay( "ELE_MOWNGRASSNOCUTS", CFG_CUSTOM, -1 );
128 static CfgInt cfg_UMPatchyChance( "UMPATCHYCHANCE", CFG_CUSTOM, 0 );
130 static CfgFloat cfg_BBPatchyChance( "BEETLEBANKBPATCHYCHANCE", CFG_CUSTOM, 0.5 );
132 static CfgFloat cfg_MGPatchyChance( "MOWNGRASSPATCHYCHANCE", CFG_CUSTOM, 0.5 );
134 static CfgFloat cfg_SetAsidePatchyChance("SETASIDEPATCHYCHANCE", CFG_CUSTOM, 1.0);
135 static CfgFloat cfg_ele_weedscaling( "ELE_WEEDSCALING", CFG_CUSTOM, 1.0 );
137 CfgFloat cfg_PondLarvalFoodBiomassConst("POND_LARVALFOODBIOMASSCONST", CFG_CUSTOM, 255.0);
139 CfgFloat cfg_PondLarvalFoodR("POND_LARVALFOODFOODR", CFG_CUSTOM, 0.04);
140 // Docs in elements.h
141 CfgInt g_el_tramline_decaytime_days( "ELEM_TRAMLINE_DECAYTIME_DAYS", CFG_PRIVATE, 21 );
142 CfgInt g_el_herbicide_delaytime_days( "ELEM_HERBICIDE_DELAYTIME_DAYS", CFG_PRIVATE, 35 );
143 CfgInt g_el_strigling_delaytime_days( "ELEM_STRIGLING_DELAYTIME_DAYS", CFG_PRIVATE, 28 );
144 
145 // Daydegree sum set on an element by ReduceVeg().
146 #define EL_GROWTH_DAYDEG_MAGIC l_el_growth_daydeg_magic.value()
147 static CfgInt l_el_growth_daydeg_magic( "ELEM_GROWTH_DAYDEG_MAGIC", CFG_PRIVATE, 100 );
148 
149 // Date after which ReduceVeg() automatically sets the growth phase
150 // to harvest1. Cannot become a global configuration variable as it
151 // is calculated at runtime.
152 #define EL_GROWTH_DATE_MAGIC (g_date->DayInYear(1,9))
153 
154 // If the fraction used in the call to ReduceVeg() is *below* this
155 // value, then a phase transition to harvest1 is considered if
156 // there has been no previous 'forced' phase transition before this
157 // year.
158 #define EL_GROWTH_PHASE_SHIFT_LEVEL (l_el_growth_phase_shift_level.value())
159 static CfgFloat l_el_growth_phase_shift_level( "ELEM_GROWTH_PHASE_SHIFT_LEVEL", CFG_PRIVATE, 0.5 );
160 
161 
162 // Types of landscape elements. Default is 'unknown'.
163 // The conversion arrays are at the top in 'elements.cpp'!
164 // Change when adding or deleting element types.
165 // Outdated, not used anywhere in the landscape. *FN*
166 //#define EL_MAX_ELEM_TYPES 18
167 
168 // Constant of proportionality between leaf area total and plant
169 // biomass.
170 #define EL_PLANT_BIOMASS (l_el_plant_biomass_proport.value()) // Scaled to dry matter on Spring Barley for 2001 & 2002
171 // All other values are scaled relative to this as of 29/03/05
172 static CfgFloat l_el_plant_biomass_proport( "ELEM_PLANT_BIOMASS_PROPORT", CFG_PRIVATE, 41.45 );
173 
174 // Default starting LAI Total. (NB LAIGreen=LAITotal/4)
175 #define EL_VEG_START_LAIT (l_el_veg_start_lait.value())
176 static CfgFloat l_el_veg_start_lait( "ELEM_VEG_START_LAIT", CFG_PRIVATE, 1.08 );
177 
178 // Constant * biomass to get height
179 #define EL_VEG_HEIGHTSCALE (l_el_veg_heightscale.value())
180 static CfgInt l_el_veg_heightscale( "ELEM_VEG_HEIGHTSCALE", CFG_PRIVATE, 16 );
181 //May+21
182 #define RV_CUT_MAY (l_el_rv_cut_may.value())
183 static CfgInt l_el_rv_cut_may( "ELEM_RV_CUT_MAY", CFG_PRIVATE, 142 );
184 
185 #define RV_CUT_JUN (l_el_rv_cut_jun.value())
186 static CfgInt l_el_rv_cut_jun( "ELEM_RV_CUT_JUN", CFG_PRIVATE, 28 );
187 
188 #define RV_CUT_JUL (l_el_rv_cut_jul.value())
189 static CfgInt l_el_rv_cut_jul( "ELEM_RV_CUT_JUL", CFG_PRIVATE, 35 );
190 
191 #define RV_CUT_AUG (l_el_rv_cut_aug.value())
192 static CfgInt l_el_rv_cut_aug( "ELEM_RV_CUT_AUG", CFG_PRIVATE, 42 );
193 
194 #define RV_CUT_SEP (l_el_rv_cut_sep.value())
195 static CfgInt l_el_rv_cut_sep( "ELEM_RV_CUT_SEP", CFG_PRIVATE, 49 );
196 
197 #define RV_CUT_OCT (l_el_rv_cut_oct.value())
198 static CfgInt l_el_rv_cut_oct( "ELEM_RV_CUT_OCT", CFG_PRIVATE, 49 );
199 
200 #define RV_MAY_1ST (l_el_rv_may_1st.value())
201 static CfgInt l_el_rv_may_1st( "ELEM_RV_MAY_1ST", CFG_PRIVATE, 121 );
202 
203 #define RV_CUT_HEIGHT (l_el_rv_cut_height.value())
204 static CfgFloat l_el_rv_cut_height( "ELEM_RV_CUT_HEIGHT", CFG_PRIVATE, 10.0 );
205 #define RV_CUT_GREEN (l_el_rv_cut_green.value())
206 static CfgFloat l_el_rv_cut_green( "ELEM_RV_CUT_GREEN", CFG_PRIVATE, 1.5 );
207 #define RV_CUT_TOTAL (l_el_rv_cut_total.value())
208 static CfgFloat l_el_rv_cut_total( "ELEM_RV_CUT_TOTAL", CFG_PRIVATE, 2.0 );
209 
210 CfgFloat l_el_o_cut_height( "ELEM_RV_CUT_HEIGHT", CFG_PRIVATE, 10.0 );
211 CfgFloat l_el_o_cut_green( "ELEM_RV_CUT_GREEN", CFG_PRIVATE, 1.5 );
212 CfgFloat l_el_o_cut_total( "ELEM_RV_CUT_TOTAL", CFG_PRIVATE, 2.0 );
213 
214 // Default fraction between crop and weed biomasses.
215 #define EL_WEED_PERCENT (l_el_weed_percent.value())
216 static CfgFloat l_el_weed_percent( "ELEM_WEED_PERCENT", CFG_PRIVATE, 0.1 );
217 
218 // Weed biomass regrowth slope after herbacide application.
219 #define EL_WEED_SLOPE (l_el_weed_slope.value())
220 static CfgFloat l_el_weed_slope( "ELEM_WEED_SLOPE", CFG_PRIVATE, 0.15 );
221 
222 // Bug biomass regrowth slope after insecticide application.
223 #define EL_BUG_SLOPE (l_el_bug_slope.value())
224 static CfgFloat l_el_bug_slope( "ELEM_BUG_SLOPE", CFG_PRIVATE, 0.2 );
225 
226 // Fraction of the weed biomass below which we are in pesticide
227 // regrowth phase, above we are in proportionality mode.
228 // CANNOT be 1.00!
229 #define EL_WEED_GLUE (l_el_weed_glue.value())
230 static CfgFloat l_el_weed_glue( "ELEM_WEED_GLUE", CFG_PRIVATE, 0.99 );
231 
232 // Same as for weed, but bugs this time.
233 #define EL_BUG_GLUE (l_el_bug_glue.value())
234 static CfgFloat l_el_bug_glue( "ELEM_BUG_GLUE", CFG_PRIVATE, 0.50 );
235 
248 // This is inversed prior to use. A multiplication is very much less
249 // expensive compared to a division.
250 //
251 // The original array supplied is:
252 // {1.11,1.06,1.01,0.99,0.96,0.92,0.92,0.93,0.97,0.99,1.02,1.06}
253 double LE::m_monthly_traffic[ 12 ] =
254  {0.9009, 0.9434, 0.9901, 1.0101, 1.0417, 1.0870,
255  1.0870, 1.0753, 1.0753, 1.0101, 0.9804, 0.9434};
256 
257 double LE::m_largeroad_load[ 24 ] =
258  {15,9,4,5,14,54,332,381,252,206,204,215,
259  231,256,335,470,384,270,191,130,91,100,99,60};
260 
261 double LE::m_smallroad_load[ 24 ] =
262  {4,3,1,1,4,15,94,108,71,58,58,61,
263  65,73,95,133,109,76,54,37,26,28,28,17};
264 
266 
267 LE::LE(void) {
268 
272  m_signal_mask = 0;
273  m_lasttreat.resize(1);
274  m_lasttreat[0] = sleep_all_day;
275  m_lastindex = 0;
276  m_running = 0;
277  m_poison = false;
278  m_owner_file = -1;
279  m_owner_index = -1;
280  m_high = false;
281  m_cattle_grazing = 0;
282  m_default_grazing_level = 0; // this means any grazed elements must set this in their constructor.
283  m_pig_grazing = false;
284  m_yddegs = 0.0;
285  m_vegddegs = -1.0;
286  m_olddays = 0;
287  m_days_since_insecticide_spray = 0;
288  m_tramlinesdecay = 0;
289  m_mowndecay = 0;
290  m_herbicidedelay = 0;
291  m_border = NULL;
292  m_unsprayedmarginpolyref = -1;
293  m_valid_x = -1;
294  m_valid_y = -1;
295  m_is_in_map = false;
296  m_squares_in_map = 0;
297  m_management_loop_detect_date = 0;
298  m_management_loop_detect_count = 0;
299  m_repeat_start = false;
300  m_skylarkscrapes = false;
301  m_type = tole_Foobar;
302  SetALMaSSEleType(-1);
303  m_ddegs = 0.0;
304  m_maxx = -1; // a very small number
305  m_maxy = -1;
306  m_minx = 9999999; // a very big number
307  m_miny = 9999999;
308  m_countrydesignation = -1; // default not set
309  m_soiltype = -1;
310  m_area = 0;
311  m_centroidx = -1;
312  m_centroidy = -1;
313  m_vege_danger_store = -1;
314  m_PesticideGridCell = -1;
315  m_subtype = -1;
316  m_owner = NULL;
317  m_rot_index = -1;
318  m_poly = -1;
319  m_map_index = -1;
320  m_almass_le_type = -1;
321  m_farmfunc_tried_to_do = -1;
322  m_birdseedforage = -1;
323  m_birdmaizeforage = -1;
324  m_openness = -1;
325  m_vegage = -1;
326  for (int i = 0; i<10; i++) SetMConstants(i, 1);
327  for (int i = 0; i < 366; i++)
328  {
329  m_gooseNos[i] = 0;
330  m_gooseNosTimed[i] = 0;
331  for (int l = 0; l < gs_foobar; l++)
332  {
333  m_gooseSpNos[i][l] = 0;
334  m_gooseSpNosTimed[i][l] = 0;
335  }
336  }
337  for (int l = 0; l < gs_foobar; l++)
338  {
339  m_goosegrazingforage[l] = 0;
340  }
341  for (int i = 0; i < 25; i++)
342  {
343  MDates[0][i] = -1;
344  MDates[1][i] = -1;
345  }
346  SetLastSownVeg(tov_Undefined);
347 #ifdef FMDEBUG
348  m_pindex = 0;
349  for ( int i = 0; i < 256; i++ ) {
350  m_pdates[ i ] = 0;
351  m_ptrace[ i ] = 0;
352  }
353 #endif
354 }
355 
356 void LE::DoCopy(const LE* a_LE) {
357 
361  m_signal_mask = a_LE->m_signal_mask;
362  m_lasttreat = a_LE->m_lasttreat;
363  m_lastindex = a_LE->m_lastindex;
364  m_running = a_LE->m_running;
365  m_poison = a_LE->m_poison;
366  m_owner_file = a_LE->m_owner_file;
367  m_owner_index = a_LE->m_owner_index;
368  m_high = a_LE->m_high;
369  m_cattle_grazing = a_LE->m_cattle_grazing;
370  m_default_grazing_level = a_LE->m_default_grazing_level; // this means any grazed elements must set this in their constructor.
371  m_pig_grazing = a_LE->m_pig_grazing;
372  m_yddegs = a_LE->m_yddegs;
373  m_olddays = a_LE->m_olddays;
374  m_vegddegs = a_LE->m_vegddegs;
375  m_days_since_insecticide_spray = a_LE->m_days_since_insecticide_spray;
376  m_tramlinesdecay = a_LE->m_tramlinesdecay;
377  m_mowndecay = a_LE->m_mowndecay;
378  m_herbicidedelay = a_LE->m_herbicidedelay;
379  m_border = a_LE->m_border;
380  m_unsprayedmarginpolyref = a_LE->m_unsprayedmarginpolyref;
381  m_valid_x = a_LE->m_valid_x;
382  m_valid_y = a_LE->m_valid_y;
383  m_is_in_map = a_LE->m_is_in_map;
384  m_squares_in_map = a_LE->m_squares_in_map;
385  m_management_loop_detect_date = a_LE->m_management_loop_detect_date;
386  m_management_loop_detect_count = a_LE->m_management_loop_detect_count;
387  m_repeat_start = a_LE->m_repeat_start;
388  m_skylarkscrapes = a_LE->m_skylarkscrapes;
389  m_type = a_LE->m_type;
390  m_birdseedforage = a_LE->m_birdseedforage;
391  m_birdmaizeforage = a_LE->m_birdmaizeforage;
392  m_ddegs = a_LE->m_ddegs;
393  m_maxx = a_LE->m_maxy; // a very small number
394  m_maxy = a_LE->m_maxx;
395  m_minx = a_LE->m_minx; // a very big number
396  m_miny = a_LE->m_miny;
397  m_countrydesignation = a_LE->m_countrydesignation; // default not set
398  m_soiltype = a_LE->m_soiltype;
399  m_area = a_LE->m_area;
400  m_centroidx = a_LE->m_centroidx;
401  m_centroidy = a_LE->m_centroidy;
402  m_vege_danger_store = a_LE->m_vege_danger_store;
403  m_PesticideGridCell = a_LE->m_PesticideGridCell;
404  m_subtype = a_LE->m_subtype;
405  m_owner = a_LE->m_owner;
406  m_rot_index = a_LE->m_rot_index;
407  m_poly = a_LE->m_poly;
408  m_map_index = a_LE->m_map_index;
409  m_almass_le_type = a_LE->m_almass_le_type;
410  m_farmfunc_tried_to_do = a_LE->m_farmfunc_tried_to_do;
411  m_openness = a_LE->m_openness;
412  m_vegage = a_LE->m_vegage;
413  for (int i = 0; i < 366; i++)
414  {
415  m_gooseNos[i] = a_LE->m_gooseNos[i];
416  m_gooseNosTimed[i] = a_LE->m_gooseNosTimed[i];
417  for (int l = 0; l < gs_foobar; l++)
418  {
419  m_gooseSpNos[i][l] = a_LE->m_gooseSpNos[i][l];
420  m_gooseSpNosTimed[i][l] = a_LE->m_gooseSpNosTimed[i][l];
421  }
422  }
423  for (int l = 0; l < gs_foobar; l++)
424  {
425  m_goosegrazingforage[l] = a_LE->m_goosegrazingforage[l];
426  }
427  for (int i = 0; i < 25; i++)
428  {
429  MDates[0][i] = a_LE->MDates[0][i];
430  MDates[1][i] = a_LE->MDates[1][i];
431  }
432  for (int i = 0; i<10; i++) SetMConstants(i, a_LE->MConsts[i]);
433 }
434 
435 
436 LE::~LE( void ) {
437 }
438 
439 
440 #ifdef FMDEBUG
441 void LE::Trace( int a_value ) {
442  m_farmfunc_tried_to_do = a_value;
443 
444  m_pdates[ m_pindex ] = g_date->DayInYear();
445  m_ptrace[ m_pindex++ ] = a_value;
446  m_pindex &= 0xff; // Circular buffer if need be.
447 }
448 
449 void LE::ResetTrace( void ) {
450  m_pindex = 0;
451  for ( int i = 0; i < 256; i++ ) {
452  m_pdates[ i ] = 0;
453  m_ptrace[ i ] = 0;
454  }
455 }
456 
457 #else
458 // Compiles into nothing if FMDEBUG is #undef.
459 void LE::Trace( int a_value ) {
460  m_farmfunc_tried_to_do = a_value;
461 }
462 
463 void LE::ResetTrace( void ) {
464 }
465 
466 #endif
467 
468 void LE::SetCopyTreatment( int a_treatment ) {
469  SetLastTreatment( a_treatment );
470 }
471 
472 void LE::SetLastTreatment( int a_treatment ) {
473  unsigned sz = (int) m_lasttreat.size();
474  if ( m_lastindex == sz )
475  m_lasttreat.resize( m_lastindex + 1 );
476 
477  m_lasttreat[ m_lastindex++ ] = a_treatment;
478 
479  // Count this treatment in the grand scope of things.
480  g_landscape_p->IncTreatCounter( a_treatment );
481  // If we have a field margin then we need to tell it about this
482  // but not if it is an insecticide spray etc..
483  /* if (m_unsprayedmarginpolyref!=-1) { switch (a_treatment) { case herbicide_treat: case growth_regulator:
484  case fungicide_treat: case insecticide_treat: case trial_insecticidetreat: case syninsecticide_treat: case molluscicide:
485  break; // Do not add sprayings default: LE* le=g_landscape_p->SupplyLEPointer(m_unsprayedmarginpolyref);
486  le->SetCopyTreatment(a_treatment); // Now we also need to do something with the treatment
487 
488  break; }
489 
490  } */
491 }
492 
493 int LE::GetLastTreatment( int * a_index ) {
494  if ( * a_index == ( int )m_lastindex )
495  return sleep_all_day;
496  int i = ( * a_index ) ++;
497  int treat = m_lasttreat[ i ];
498  return treat;
499 }
500 
501 void LE::Tick( void ) {
502  m_lastindex = 0;
503  m_lasttreat[ 0 ] = sleep_all_day;
504  if ( m_tramlinesdecay > 0 )
505  m_tramlinesdecay--;
506  if ( m_mowndecay > 0 )
507  m_mowndecay--;
508  if ( m_herbicidedelay > 0 ) m_herbicidedelay--;
509 }
510 
511 
512 
513 void LE::DoDevelopment( void ) {
514 }
515 
517 {
518  APoint p;
519  p.m_x=m_centroidx;
520  p.m_y=m_centroidy;
521  return p;
522 }
523 
529  int geese = 0;
530  for (unsigned i = 1; i <= (unsigned)cfg_goosecountperiod.value( ); i++) {
531  unsigned ind = ((unsigned)g_date->DayInYear( ) - i) % 365;
532  geese += m_gooseNos[ ind ];
533  }
534  return geese;
535 }
536 
541  int geese = 0;
542  for (unsigned i = 0; i < (unsigned)gs_foobar; i++) {
543  geese += m_gooseSpNos[g_date->DayInYear()][i];
544  }
545  return geese;
546 }
547 
552  int geese = 0;
553  for (unsigned i = 0; i < (unsigned)gs_foobar; i++) {
554  geese += m_gooseSpNosTimed[g_date->DayInYear()][i];
555  }
556  return geese;
557 }
558 
560 int LE::GetGooseSpNosToday(GooseSpecies a_goose) {
561  return m_gooseSpNos[g_date->DayInYear()][a_goose];
562 }
563 
565 int LE::GetGooseSpNosTodayTimed(GooseSpecies a_goose) {
566  return m_gooseSpNosTimed[g_date->DayInYear()][a_goose];
567 }
568 
569 
570 //---------------------------------------------------------------------------
571 //---------------------------------------------------------------------------
572 
574  SetVegPatchy(false);
575  m_nutrient_status = 0; // default
576  m_veg_biomass = 0.0;
577  m_weed_biomass = 0.0;
578  m_veg_height = 0.0;
579  m_veg_cover = 0.0;
580  m_insect_pop = 1.0;
583  m_weed_curve_num = 99; // 99 used as zero growth curve
584  m_yddegs = 0.0;
585  m_vegddegs = -1.0;
586  m_ddegs = 0.0;
587  m_LAgreen = 0.0;
588  m_LAtotal = 0.0;
589  m_digestability = 1.0;
590  for (int i = 0; i < 32; i++) m_oldnewgrowth[i] = 0.5;
592  m_newgrowthsum = 8.0;
593  m_forced_phase_shift = false;
594  m_force_growth = false;
596  m_total_biomass = 0.0;
597  m_total_biomass_old = 0.0;
598 
599 
600 
601  g_biomass_scale[tov_Carrots] = 0.7857;
605  g_biomass_scale[ tov_BroadBeans ] = 0.857;
606  g_biomass_scale[ tov_FieldPeas ] = 0.857;
611  g_biomass_scale[tov_Maize] = 1.00;
614  g_biomass_scale[tov_NaturalGrass] = 0.567; //0.567 is scaled for actual yield
615  g_biomass_scale[tov_Heath] = 0.567; //0.567 is scaled for actual yield
617  g_biomass_scale[tov_None] = 0.0;
619  g_biomass_scale[tov_Oats] = 0.857;
621  g_biomass_scale[tov_OSBarleySilage] = 0.857 * 0.8;
622  g_biomass_scale[tov_OCarrots] = 0.7857 * 0.8;
626  g_biomass_scale[tov_OFieldPeas] = 0.857 * 0.8;
627  g_biomass_scale[tov_OFieldPeasSilage] = 0.857 * 0.8;
629  g_biomass_scale[tov_OGrazingPigs] = 0.7857 * 0.8;
630  g_biomass_scale[tov_OOats] = 0.857 * 0.8;
632  g_biomass_scale[tov_OPotatoes] = 0.857 * 0.8;
635  g_biomass_scale[tov_OSetaside] = 0.7857;
636  g_biomass_scale[tov_OSpringBarley] = 0.857 * 0.8;
637  g_biomass_scale[tov_OSpringBarleyExt] = 0.857 * 0.8 * 0.8;
640  g_biomass_scale[tov_OSpringBarleyPigs] = 0.857 * 0.8;
641  g_biomass_scale[tov_OTriticale] = 1.00 * 0.8;
642  g_biomass_scale[tov_OWinterBarley] = 0.857 * 0.8;
643  g_biomass_scale[tov_OWinterBarleyExt] = 0.857 * 0.8 * 0.8;
644  g_biomass_scale[tov_OWinterRape] = 1.071 * 0.8;
645  g_biomass_scale[tov_OWinterRye] = 0.857 * 0.8;
646  g_biomass_scale[ tov_OWinterWheat ] = 1.00 * 0.8;
648  g_biomass_scale[ tov_OWinterWheatUndersownExt ] = 1.00 * 0.8 * 0.8;
653  g_biomass_scale[tov_Potatoes] = 0.857;
659  g_biomass_scale[tov_Setaside] = 0.7857;
674  g_biomass_scale[tov_WinterWheat] = 1.00; // This gives approx 18 tonnes biomass for WW
693  g_biomass_scale[tov_YoungForest] = 0.7857 * 0.67;
694  g_biomass_scale[tov_Wasteland] = 0.7857 * 0.67;
695 
697  //ReadBugPercentageFile();
698  return;
699  }
700 
703  g_weed_percent[ tov_Maize ] = 0.05;
743  g_weed_percent[tov_OOats] = 0.1;
744  g_weed_percent[tov_Oats] = 0.1;
745  g_weed_percent[tov_Heath] = 0.1;
747  g_weed_percent[ tov_FieldPeas ] = 0.1;
764  g_weed_percent[tov_None] = 0.1;
788 
879 
966 
1053 
1139 
1140 
1141  //05.03.13 - modifications for farmer decision making, AM
1144  m_crop_index = 0;
1145 }
1146 
1148  m_ifile=fopen(l_el_bug_percentage_file.value(), "r" );
1149  if ( !m_ifile ) {
1150  g_msg->Warn( WARN_FILE, "CropData::ReadBugPercentageFile(): Unable to open file", l_el_bug_percentage_file.value() );
1151  exit( 1 );
1152  }
1153  for ( int i = 0; i < tov_Undefined; i++ ) {
1154  int vegnum;
1155  // **cjt** modified 31/01/2004
1156  float weedpercent, bugpercent_a, bugpercent_b, bugpercent_c, bugpercent_d;
1157  if ( 2 != fscanf( m_ifile, "%d %f %f %f %f %f", & vegnum, & weedpercent, & bugpercent_a, & bugpercent_b,
1158  & bugpercent_c, & bugpercent_d ) ) {
1159  char vegnums[ 20 ];
1160  sprintf( vegnums, "%d", tov_Undefined );
1161  g_msg->Warn( WARN_FILE,
1162  "VegElement::ReadBugPercentageFile(): Unable to read"
1163  " sufficient number of int/double pairs from bug percentage file."" Lines expected:", vegnums );
1164  exit( 1 );
1165  }
1166  FloatToDouble( g_weed_percent[ vegnum ], weedpercent);
1167  FloatToDouble( g_bug_percent_a[ vegnum ] , bugpercent_a);
1168  FloatToDouble( g_bug_percent_b[ vegnum ] , bugpercent_b);
1169  FloatToDouble( g_bug_percent_c[ vegnum ] , bugpercent_c);
1170  FloatToDouble( g_bug_percent_d[ vegnum ] , bugpercent_d);
1171  }
1172  fclose( m_ifile );
1173 }
1174 
1176 {
1177  switch (m_lastsownvegtype)
1178  {
1179  case tov_SpringBarley:
1180  case tov_SpringBarleySpr:
1181  case tov_WinterBarley:
1182  case tov_SpringWheat:
1183  case tov_WinterWheat:
1184  case tov_WinterRye:
1185  case tov_Oats:
1186  case tov_Triticale:
1187  case tov_SpringBarleySeed:
1194  case tov_OWinterBarley:
1195  case tov_OWinterBarleyExt:
1196  case tov_OWinterRye:
1197  case tov_SpringBarleyGrass:
1201  case tov_OSpringBarley:
1202  case tov_OSpringBarleyPigs:
1204  case tov_OWinterWheat:
1205  case tov_OOats:
1206  case tov_OTriticale:
1207  case tov_WWheatPControl:
1209  case tov_WWheatPTreatment:
1213  case tov_OSpringBarleyExt:
1215  case tov_OSBarleySilage:
1217  return true;
1218  default: // No matching code so is should not be cereal
1219  return false;
1220  }
1221 }
1222 
1224 {
1225  switch (m_vege_type)
1226  {
1227  case tov_SpringBarley:
1228  case tov_SpringBarleySpr:
1229  case tov_WinterBarley:
1230  case tov_SpringWheat:
1231  case tov_WinterWheat:
1232  case tov_WinterRye:
1233  case tov_Oats:
1234  case tov_Triticale:
1235  case tov_SpringBarleySeed:
1242  case tov_OWinterBarley:
1243  case tov_OWinterBarleyExt:
1244  case tov_OWinterRye:
1245  case tov_SpringBarleyGrass:
1248  case tov_OSpringBarley:
1249  case tov_OSpringBarleyPigs:
1251  case tov_OWinterWheat:
1252  case tov_OOats:
1253  case tov_OTriticale:
1254  case tov_WWheatPControl:
1256  case tov_WWheatPTreatment:
1260  case tov_OSpringBarleyExt:
1263  return true;
1264  default: // No matching code so is should not be mature cereal
1265  return false;
1266  }
1267 }
1268 
1270 {
1272  switch (m_vege_type)
1273  {
1274  case tov_Maize:
1275  case tov_OMaizeSilage:
1276  case tov_MaizeSilage:
1277  return true;
1278  default: // No matching code so is should not be maize
1279  return false;
1280  }
1281 }
1282 
1283 
1284 inline bool VegElement::IsGrass()
1285 {
1286  switch (m_vege_type)
1287  {
1288  case tov_NaturalGrass:
1292  case tov_PermanentSetaside:
1293  case tov_Setaside:
1294  case tov_SeedGrass1:
1295  case tov_SeedGrass2:
1296  case tov_OSeedGrass1:
1297  case tov_OSeedGrass2:
1302  case tov_OrchardCrop:
1303  case tov_YoungForest:
1304  case tov_FodderGrass:
1305  case tov_Heath:
1306  return true;
1307  default: return false;
1308  }
1309 }
1310 
1312  switch (m_vege_type) {
1313  case tov_NaturalGrass:
1317  return true;
1318  default: break;
1319  }
1320  switch (m_lastsownvegtype) {
1321  case tov_SeedGrass1:
1322  case tov_SeedGrass2:
1323  case tov_OSeedGrass1:
1324  case tov_OSeedGrass2:
1329  case tov_FodderGrass:
1330  return true;
1331  default:
1332  return false;
1333  }
1334 
1335 }
1336 
1337 
1338 
1340 
1341  double newgrowth=0;
1342  m_veg_cover = 1.0 - ( exp( m_LAtotal * -0.6 ) ); // Beer's Law to give cover
1343  double usefull_veg_cover = 1.0 - ( exp( m_LAgreen * -0.4 ) ); // This is used to calc growth rate
1344  // Need gloabal radiation today
1345  double glrad = g_landscape_p->SupplyGlobalRadiation();
1346  // This is different for maize (a C4 plant)
1347  int ptype;
1348  if (( m_vege_type == tov_Maize ) || ( m_vege_type == tov_OMaizeSilage ) || (m_vege_type == tov_MaizeSilage) || (m_vege_type == tov_MaizeStrigling)) ptype = 1; else ptype = 0;
1349  int index = ( int )floor( 0.5 + g_landscape_p->SupplyTemp() ) + 30; // There are 30 negative temps
1350  double radconv = c_SolarConversion[ ptype ] [ index ];
1351  if ( m_LAtotal >= m_oldLAtotal ) {
1352  // we are in positive growth so grow depending on our equation
1353  newgrowth = usefull_veg_cover * glrad * radconv * g_biomass_scale[ m_vege_type ];
1354  if (m_owner_index != -1) { // This only works because only crops and similar structures have owners
1355  int fintensity = g_landscape_p->SupplyFarmIntensity(m_poly);
1356  if (fintensity==1) {
1357  // 1 means extensive, so reduce vegetation biomass by 20%
1358  // NB this cannot be used with extensive crop types otherwise you get an additional 20% reduction
1359  // This way of doing things provides a quick and dirty general effect.
1360  m_veg_biomass += newgrowth * 0.8;
1361  } else m_veg_biomass += newgrowth;
1362  } else m_veg_biomass += newgrowth;
1363  } else {
1364  // Negative growth - so shrink proportional to the loss in LAI Total
1365  if ( m_oldLAtotal > 0 ) {
1367  }
1368  }
1372  // For geese that eat spilled grain and maize we need to remove some of this daily (loss to other things than geese)
1373  m_birdseedforage *= cfg_goose_GrainDecayRate.value();
1374  if (m_birdseedforage <0.01) m_birdseedforage = 0.0;
1375  m_birdmaizeforage *= cfg_goose_GrainDecayRate.value();
1376  if (m_birdmaizeforage <0.01) m_birdmaizeforage = 0.0;
1377  // Another thing to do is to calculate mean vegetation digestability
1378  // This is a 32-day running average of the amount of new growth per day divided by veg biomass
1379  // With a minimum value of 0.5
1380  ++m_newoldgrowthindex &= 31;
1381  if (m_veg_biomass>0 ) {
1382  switch (m_vege_type) {
1383  case tov_NoGrowth:
1384  case tov_None:
1385  case tov_OFirstYearDanger:
1386  m_digestability=0.0;
1387  break;
1388  case tov_OPotatoes:
1389  case tov_Maize:
1390  case tov_MaizeSilage:
1391  case tov_OMaizeSilage:
1392  case tov_MaizeStrigling:
1393  case tov_Potatoes:
1394  case tov_PotatoesIndustry:
1395  m_digestability=0.5;
1396  break;
1397  default:
1398  //m_oldnewgrowth[m_newoldgrowthindex]=(newgrowth/m_veg_biomass);
1399  m_oldnewgrowth[m_newoldgrowthindex]=(newgrowth);
1400  m_newgrowthsum=0.0;
1401  for (int i=0; i<32; i++) {
1403  }
1405  m_digestability+=0.5;
1406  if (m_digestability>0.8) m_digestability=0.8;
1407  }
1408  }
1409  else {
1411  m_digestability = 0.0;
1412  }
1413  // We also need to calculate non-grain forage for geese
1414  if (IsCereal()) {
1415  if (m_green_biomass > 0.5) //Testing if this could be a suitable fix for the cereals
1416  {
1417  for (unsigned i = 0; i < gs_foobar; i++) {
1418  //m_goosegrazingforage[ i ] = 0.0;
1420  m_goosegrazingforage[ i ] = g_landscape_p->SupplyGooseGrazingForageH( m_veg_height, (GooseSpecies)i ) * 1.0325;
1421  }
1422  }
1423  else for (unsigned i = 0; i < gs_foobar; i++) {
1424  m_goosegrazingforage[i] = 0.0;
1425  }
1426  }
1428  else if (IsGooseGrass()) {
1429  for (unsigned i = 0; i < gs_foobar; i++) {
1430  //m_goosegrazingforage[ i ] = 0.0;
1432  }
1433  }
1434  else for (unsigned i = 0; i < gs_foobar; i++) m_goosegrazingforage[ i ] = 0.0;
1435 
1436  // NB The m_weed_biomass is calculated directly from the curve in Curves.pre
1437  // rather than going through the rigmorole of converting leaf-area index
1438  // The insect calculation part
1439  // Bugmass = a + b(biomass) + c(height)
1440  double temp_bugmass = //g_bug_percent_d[ m_vege_type ] // This was used as a scaler - now not used
1443  // Set a minimum value (regressions will otherwise sometimes give a -ve value
1444  if ( temp_bugmass < 0.05 ) temp_bugmass = 0.05;
1445  // Now need to check for deviations caused by management
1446  // First spot the deviation - this is easy because the only deviation that does
1447  // not affect the vegetation too is insecticide spraying
1448  if ( m_days_since_insecticide_spray > 0 ) {
1449  // Need to change insects still, so grow towards the target, but only when 21 days from zero effect
1452  }
1453  else {
1454  m_insect_pop = temp_bugmass;
1455  }
1456  m_veg_density = (int) (floor( 0.5 + ( m_veg_biomass / ( 1 + m_veg_height ) ) ));
1457  if ( m_veg_density > 100 ) m_veg_density = 100; // to stop array bounds problems
1458  if (m_LAtotal == 0.0) m_green_biomass = 0.0;
1461  }
1462 
1463 void VegElement::RandomVegStartValues( double * a_LAtotal, double * a_LAgreen, double * a_veg_height, double * a_weed_biomass ) {
1464  * a_LAtotal = EL_VEG_START_LAIT * ( ( ( ( double )( random( 21 ) - 10 ) ) / 100.0 ) + 1.0 ); // +/- 10%
1465  * a_LAgreen = * a_LAtotal / 4.0;
1466  * a_veg_height = * a_LAgreen * EL_VEG_HEIGHTSCALE;
1467  * a_weed_biomass = * a_LAgreen * 0.1; // 10% weeds by biomass
1468 }
1469 
1470 
1471 void VegElement::SetGrowthPhase(int a_phase) {
1472 
1473  if (a_phase == sow) {
1474  m_vegddegs = 0.0;
1475  }
1476  else if (a_phase == harvest) m_vegddegs = -1;
1477  if (a_phase == janfirst) {
1478  m_forced_phase_shift = false;
1483  if (g_crops->StartValid(m_curve_num, a_phase)) {
1484  double temp_veg_height = g_crops->GetStartValue(m_curve_num, a_phase, 2);
1485  if (temp_veg_height < m_veg_height) { // Otherwise we are better off with the numbers we have to start with
1486  m_LAgreen = g_crops->GetStartValue(m_curve_num, a_phase, 0);
1487  m_LAtotal = g_crops->GetStartValue(m_curve_num, a_phase, 1);
1489  }
1490  }
1491 
1492  }
1493  else if (g_crops->StartValid(m_curve_num, a_phase)) {
1494  m_LAgreen = g_crops->GetStartValue(m_curve_num, a_phase, 0);
1495  m_LAtotal = g_crops->GetStartValue(m_curve_num, a_phase, 1);
1497  }
1498  else if (!m_force_growth) {
1499  // If we are in forced growth mode (which is very likely),
1500  // then do not choose a new set of starting values, as we have
1501  // already calculated our way to a reasonable set of values.
1502  //RandomVegStartValues( & m_LAtotal, & m_LAgreen, & m_veg_height, & m_weed_biomass ); // **CJT** Testing removal 17/02/2015
1503  }
1504  m_veg_phase = a_phase;
1505  m_yddegs = 0.0;
1507  m_force_growth = false;
1508 
1509  if (m_veg_phase == janfirst) {
1510  // For some growth curves there is no growth in the first
1511  // two months of the year. This will more likely than
1512  // not cause a discontinuous jump in the growth curves
1513  // come March first. ForceGrowthSpringTest() tries
1514  // to avoid that by checking for positive growth values
1515  // for the January growth phase. If none are found, then
1516  // it initializes a forced growth/transition to the March
1517  // 1st starting values.
1518  ForceGrowthSpringTest(); // Removal of this causes continuous increase in vegetation growth year on year for any curve that does not have a hard reset (e.g. harvest).
1519  }
1520 }
1521 
1522 
1524  // Called whenever the farmer does something 'destructive' to a
1525  // field, that reduced the vegetaion.
1526  if ( g_date->DayInYear() >= g_date->DayInYear( 1, 11 )
1527  || ( g_date->DayInYear() < g_date->DayInYear( 1, 3 ) && m_force_growth ) ) {
1529  }
1530 }
1531 
1532 
1533 
1535  // Unless we are on the list of special growth curves where we have worked
1536  // out vegetation declines (grasses), then
1537  // check if there are any positive growth differentials in the curve
1538  // for the first two months of the year. Do nothing if there is.
1539  //if (IsGrass()) return;
1540  // If we have any positive growth then no need to force either
1541  if (g_crops->GetLAgreenDiff(90000.0, 0.0, m_curve_num, janfirst) > 0.001
1542  || g_crops->GetLAtotalDiff(90000.0, 0.0, m_curve_num, janfirst) > 0.001
1543  || g_crops->GetHeightDiff(90000.0, 0.0, m_curve_num, janfirst) > 0.001) {
1544  return;
1545  }
1546 
1547  // No growth, force it.
1549 }
1550 
1551 
1552 
1554  double LAgreen_target;
1555  double Weed_target;
1556  double LAtotal_target;
1557  double veg_height_target;
1558  int next_phase, daysleft;
1559 
1560  // Figure out what our target phase is.
1561  if ( g_date->DayInYear() < g_date->DayInYear( 3, 1 ) ) {
1562  daysleft = g_date->DayInYear( 1, 3 ) - g_date->DayInYear();
1563  next_phase = marchfirst;
1564  } else if ( g_date->DayInYear() >= g_date->DayInYear( 1, 11 ) ) {
1565  daysleft = 365 - g_date->DayInYear();
1566  next_phase = janfirst;
1567  } else {
1568  return;
1569  }
1570  if ( daysleft <= 0 )
1571  // Uh! Oh! This really shouldn't happen.
1572  return;
1573 
1574  if ( !g_crops->StartValid( m_curve_num, next_phase ) ) {
1575  // If no valid starting values for next phase, then
1576  // preinitialize the random starting values! Ie. make the
1577  // choice here and then do not choose another set come
1578  // next phase transition, but use the values we already
1579  // got at that point in time.
1580  RandomVegStartValues( & LAtotal_target, & LAgreen_target, & veg_height_target, & Weed_target );
1581  } else {
1582  Weed_target = g_crops->GetStartValue( m_weed_curve_num, next_phase, 0 );
1583  LAgreen_target = g_crops->GetStartValue( m_curve_num, next_phase, 0 );
1584  LAtotal_target = g_crops->GetStartValue( m_curve_num, next_phase, 1 );
1585  veg_height_target = g_crops->GetStartValue( m_curve_num, next_phase, 2 );
1586  }
1587 
1588  m_force_growth = true;
1589  m_force_Weed = ( Weed_target - m_weed_biomass ) / ( double )daysleft;
1590  m_force_LAgreen = ( LAgreen_target - m_LAgreen ) / ( double )daysleft;
1591  m_force_LAtotal = ( LAtotal_target - m_LAtotal ) / ( double )daysleft;
1592  m_force_veg_height = ( veg_height_target - m_veg_height ) / ( double )daysleft;
1593 }
1594 
1595 
1597  //if ( m_herbicidedelay == 0 ) m_weed_biomass += m_force_Weed; // ***CJT*** 12th Sept 2008 - rather than force growth, weeds might be allowed to grow on their own
1601  // RecalculateBugsNStuff(); REMOVED BY CJT 3/2/2015 If no problems occur then we can delete permanantly
1602 }
1603 
1604 
1605 
1606 void VegElement::ZeroVeg( void ) {
1607  m_LAgreen = 0.0;
1608  m_LAtotal = 0.0;
1609  m_veg_height = 0.0;
1610  m_veg_cover = 0.0;
1611  m_veg_biomass = 0.0;
1612  m_weed_biomass = 0.0;
1613  m_birdseedforage = 0.0;
1614  m_birdmaizeforage = 0.0;
1615 
1616  ForceGrowthTest();
1618 }
1619 
1620 
1622  if ( m_force_growth ) {
1625  ResetGeese();
1626  return;
1627  }
1628 
1629  m_yddegs = m_ddegs;
1631  if (m_vegddegs != -1.0) m_vegddegs += m_ddegs; // Sum up the vegetation day degrees since sowing
1632  m_ddegs += m_yddegs; // and sum up the phase ddegs
1633 
1637 
1638  m_LAgreen += dLAG;
1639  if ( m_LAgreen < 0.0 )
1640  m_LAgreen = 0.0;
1641 
1642  m_LAtotal += dLAT;
1643  if ( m_LAtotal < 0.0 )
1644  m_LAtotal = 0.0;
1645  int fintensity = 0;
1646 #ifdef __EXTSHRINKSHEIGHT
1647  if (this->m_owner_index != -1) { // This only works because only crops and similar structures have owners
1648  fintensity = g_landscape_p->SupplyFarmIntensity(m_poly);
1649  if (fintensity==1) {
1650  // 1 means extensive, so reduce vegetation height by 10%
1651  dHgt *=0.9;
1652  }
1653  }
1654 #endif
1655 
1656 
1657  m_veg_height += dHgt;
1658  if ( m_veg_height < 0.0 ) m_veg_height = 0.0;
1659  if ( m_herbicidedelay == 0 ) {
1661  m_weed_biomass += dWee * cfg_ele_weedscaling.value()* (1+fintensity);
1662  }
1663  if ( m_weed_biomass < 0.0 ) m_weed_biomass = 0.0;
1665  // Here we need to set today's goose numbers to zero in case they are not written by the goose population manager (the normal situation)
1666  ResetGeese();
1667 }
1668 
1670  m_gooseNos[ g_date->DayInYear() ] = 0;
1671  for (unsigned i = 0; i < gs_foobar; i++) {
1672  m_gooseSpNos[ g_date->DayInYear() ][ (GooseSpecies)i ] = 0;
1673  m_gooseSpNosTimed[ g_date->DayInYear() ][ (GooseSpecies)i ] = 0;
1674  }
1675 }
1676 
1677 void VegElement::GrazeVegetationTotal( double a_grams )
1678 {
1679  GrazeVegetation( a_grams/m_area, true );
1680 }
1681 
1682 void VegElement::GrazeVegetation( double a_reduc, bool a_force )
1683 {
1695  if (!a_force) a_reduc *= m_default_grazing_level;
1696  if (a_reduc >= m_veg_biomass) return;
1697  double propreduc = 1.0 - (a_reduc / m_veg_biomass);
1698  m_veg_height *= propreduc;
1699  m_weed_biomass *= propreduc;
1700  m_veg_biomass -= a_reduc;
1701  // Need to do something with the LA too -
1702  m_LAgreen *= propreduc;
1703  m_LAtotal *= propreduc;
1704  m_oldLAtotal = m_LAtotal; // this stops double reduction of biomass later in RecalculateBugsNStuff();
1705 }
1706 
1707 void VegElement::ReduceVeg(double a_reduc) {
1708  m_LAgreen *= a_reduc;
1709  m_LAtotal *= a_reduc;
1710  m_veg_height *= a_reduc;
1711  m_veg_biomass *= a_reduc;
1712  m_weed_biomass *= a_reduc;
1713 
1714  ForceGrowthTest();
1715  m_oldLAtotal = m_LAtotal; // this stops double reduction of biomass later in RecalculateBugsNStuff();
1716 }
1717 
1718 void VegElement::ReduceVeg_Extended(double a_reduc) {
1719  m_LAgreen *= a_reduc;
1720  m_LAtotal *= a_reduc;
1721  m_veg_height *= a_reduc;
1722  m_veg_biomass *= a_reduc;
1723  m_weed_biomass *= a_reduc;
1724 
1725  if ( a_reduc < EL_GROWTH_PHASE_SHIFT_LEVEL ) {
1726  m_yddegs = 0.0;
1728  }
1729 
1732  m_forced_phase_shift = true;
1733  }
1734 
1735  ForceGrowthTest();
1736  m_oldLAtotal = m_LAtotal; // this stops double reduction of biomass later in RecalculateBugsNStuff();
1737 }
1738 
1739 //---------------------------------------------------------------------------
1740 //---------------------------------------------------------------------------
1741 
1742 
1744  m_type = tole_Field;
1747 }
1748 
1749 
1750 
1752  //05.03.13 AM
1754 
1755  m_CropDataStorage[index].taken = false;
1758  m_CropDataStorage[index].harvested = false;
1759  m_CropDataStorage[index].area = 0;
1760  m_CropDataStorage[index].no_herb_app = 0;
1762  m_CropDataStorage[index].no_fi_app = 0;
1763  m_CropDataStorage[index].missed_fi_app = 0;
1764 }
1765 
1766 
1767 void Field::DoDevelopment( void ) {
1769  SetSprayedToday(false); // Reset the overspray flag in case it is set
1770  // Now if we have an unsprayed field margin, we need to transfer the crop
1771  // data to it.
1772  if ( GetUnsprayedMarginPolyRef() != -1 ) {
1779  }
1780 }
1781 
1782 
1784  return m_owner->GetPreviousCrop(a_index);
1785 }
1786 
1787 
1788 void VegElement::SetCropData( double a_veg_height, double a_LAtotal, double a_LAgreen, TTypesOfVegetation a_veg,
1789  double a_cover, int a_grazed ) {
1790  m_veg_height = a_veg_height;
1791  m_LAtotal = a_LAtotal;
1792  m_LAgreen = a_LAgreen;
1793  m_vege_type = a_veg;
1794  m_veg_cover = a_cover;
1795  m_cattle_grazing = a_grazed;
1796 }
1797 
1798 void VegElement::SetCropDataAll( double a_veg_height, double a_biomass, double a_LAtotal, double a_LAgreen,
1799  TTypesOfVegetation a_veg, double a_wb, double a_cover, int a_grazed, double a_ins, bool a_patchy, double a_dens ) {
1800  m_veg_height = a_veg_height;
1801  m_veg_biomass = a_biomass;
1802  m_LAtotal = a_LAtotal;
1803  m_LAgreen = a_LAgreen;
1804  m_vege_type = a_veg;
1805  m_weed_biomass = a_wb;
1806  m_veg_cover = a_cover;
1807  m_cattle_grazing = a_grazed;
1808  m_insect_pop = a_ins;
1809  m_veg_density = (int) a_dens;
1810  m_veg_patchy = a_patchy;
1811 }
1812 
1813 void VegElement::InsectMortality( double a_fraction ) {
1814  m_insect_pop *= a_fraction;
1815 }
1816 
1818  // Vegetation type set by the farm manager.
1821  m_veg_patchy = false;
1823 }
1824 
1826  // Vegetation type set by the farm manager.
1829  m_veg_patchy = false;
1831 }
1832 
1833 
1835  // Vegetation type set by the farm manager.
1838  m_veg_patchy = true;
1839  m_digestability+=0.2;
1840  if (m_digestability>0.8) m_digestability=0.8;
1842 }
1843 
1844 
1850  if (g_rand_uni() < cfg_SetAsidePatchyChance.value()) m_veg_patchy = true; else m_veg_patchy = false;
1851  m_digestability+=0.2;
1852  if (m_digestability>0.8) m_digestability=0.8;
1853 
1854 }
1855 
1856 
1858  LE::SetHigh( true );
1859  //default to tall - later will depend on height recorded in polygon data
1862  m_type = tole_Hedges;
1864  SetSubType(0);
1865 }
1866 
1867 
1873  SetSubType(0);
1874 }
1875 
1876 
1882  if (g_rand_uni() < cfg_BBPatchyChance.value()) m_veg_patchy = true; else m_veg_patchy = false;
1883 }
1884 
1885 
1890  m_veg_patchy = true;
1891 }
1892 
1895  // Add cutting functionality when ready.
1896  long today = g_date->DayInYear();
1897 
1898  if ( g_date->JanFirst() ) {
1899  // beginning of year so restart the cutting
1900  m_DateCut = 0;
1901  }
1902 
1903  if ( today > RV_MAY_1ST ) // No cutting before May 1st
1904  {
1905  long SinceCut = today - m_DateCut; // how many days since last cut
1906  int month = g_date->GetMonth();
1907  switch ( month ) {
1908  case 5:
1909  if ( random( 14 ) + SinceCut > RV_CUT_MAY ) Cutting( today );
1910  break;
1911  case 6:
1912  if ( random( 14 ) + SinceCut > RV_CUT_JUN ) Cutting( today );
1913  break;
1914  case 7:
1915  if ( random( 14 ) + SinceCut > RV_CUT_JUL ) Cutting( today );
1916  break;
1917  case 8:
1918  if ( random( 14 ) + SinceCut > RV_CUT_AUG ) Cutting( today );
1919  break;
1920  case 9:
1921  if ( random( 14 ) + SinceCut > RV_CUT_SEP ) Cutting( today );
1922  break;
1923  case 10:
1924  if ( random( 14 ) + SinceCut > RV_CUT_OCT ) Cutting( today );
1925  break;
1926  default:
1927  break;
1928  }
1929  }
1930 }
1931 
1932 void RoadsideVerge::Cutting( int a_today )
1933 {
1934  SetLastTreatment( mow );
1935  m_DateCut = a_today;
1940 }
1941 
1946  m_veg_patchy = true;
1947 }
1948 
1950 {
1952 }
1953 
1954 //---------------------------------------------------------------------------
1955 //---------------------------------------------------------------------------
1956 
1958  m_veg_patchy = false;
1959 }
1960 
1961 
1964 }
1965 
1966 
1968  LE::SetHigh( true );
1969  m_type = tole_Scrub;
1971 }
1972 
1973 
1977  m_type = tole_Marsh;
1979 }
1980 
1984 }
1985 
1986 
1990  m_type = tole_Heath;
1992  m_veg_patchy = true;
1993 }
1994 
1996  LE::SetHigh( true );
2001 }
2002 
2008  if (g_rand_uni() < cfg_MGPatchyChance.value()) m_veg_patchy = true; else m_veg_patchy = false;
2009 }
2010 
2012  LE::SetHigh( true );
2017  m_LastSprayed = 99999;
2018 }
2019 
2022  long today = g_date->DayInYear();
2023  // Spraying
2024  //int sprayday = cfg_OrchardSprayDay.value();
2025  int sprayday2 = cfg_pest_productapplic_startdate2.value();
2026  int sprayday3 = cfg_pest_productapplic_startdate3.value();
2027  int sprayday=cfg_pest_productapplic_startdate.value();
2028  //sprayday+=random(cfg_pest_productapplic_period.value());
2029  if ( ( today == sprayday ) || ( today == sprayday2 ) || ( today == sprayday3 ) )
2030  if ( g_landscape_p->SupplyShouldSpray() ) {
2031  //g_pest->DailyQueueAdd( this, l_pest_insecticide_amount.value() );
2032  g_pest->DailyQueueAdd( this, l_pest_productOrchard_amount.value() );
2033  }
2034  // Cutting functionality
2035  if ( g_date->JanFirst() ) {
2036  // beginning of year so restart the cutting
2037  m_DateCut = 0;
2038  }
2039 
2040  switch ( cfg_OrchardNoCutsDay.value() ) {
2041  case 99:
2042  if ( today == ( sprayday - 7 ) ) Cutting( today );
2043  break;
2044  case 4:
2045  if ( ( today == 259 ) || ( today == 122 ) || ( today == 92 ) || ( today == 196 ) )
2046  Cutting( today );
2047  break;
2048  case 3:
2049  if ( ( today == 259 ) || ( today == 122 ) || ( today == 92 ) ) Cutting( today );
2050  break;
2051  case 2:
2052  if ( ( today == 259 ) || ( today == 122 ) ) Cutting( today );
2053  break;
2054  case 1:
2055  if ( ( today == 259 ) ) Cutting( today );
2056  break;
2057  default: // No cut
2058  break;
2059  }
2060 }
2061 
2062 void Orchard::Cutting( int a_today ) {
2063  SetLastTreatment( mow );
2064  SetMownDecay( 12 ); // 12 days of not suitable
2066  m_DateCut = a_today;
2070 }
2071 
2074  long today = g_date->DayInYear();
2075  // Cutting functionality
2076  if ( g_date->JanFirst() ) {
2077  // beginning of year so restart the cutting
2078  m_DateCut = 0;
2079  }
2080  switch ( cfg_MownGrassNoCutsDay.value() ) {
2081  case 99:
2082  // Use to define special cutting behaviour e.g. cutting every 14 days after 1st May
2083  if ( ( today >= ( March + 15 ) ) && ( today % 42 == 0 )) {
2084  if (today < October) Cutting( today );
2085  }
2086  break;
2087  case 5:
2088  if ( ( today == 151 ) ) // 1st June
2089  Cutting( today );
2090  break;
2091  case 4:
2092  if ( ( today == 259 ) || ( today == 122 ) || ( today == 92 ) || ( today == 196 ) )
2093  Cutting( today );
2094  break;
2095  case 3:
2096  if ( ( today == 259 ) || ( today == 122 ) || ( today == 92 ) ) Cutting( today );
2097  break;
2098  case 2:
2099  if ( ( today == 259 ) || ( today == 122 ) ) Cutting( today );
2100  break;
2101  case 1:
2102  if ( ( today == 259 ) ) Cutting( today );
2103  break;
2104  default: // No cut
2105  break;
2106  }
2107 }
2108 
2109 void MownGrass::Cutting( int a_today ) {
2110  SetLastTreatment( mow );
2111  SetMownDecay( 21 ); // 21 days of not suitable
2113  m_DateCut = a_today;
2117 }
2118 
2119 
2122  long today = g_date->DayInYear();
2123  if (m_LastSprayed<today) {
2125  if (m_herbicidedelay > 5) m_herbicidedelay = 5;
2126  else if (m_herbicidedelay < 0) m_herbicidedelay = 0;
2127  this->ReduceVeg(0.9);
2128  if ((today == 0) || (today-m_LastSprayed > 90)) m_LastSprayed = 999999;
2129  }
2130  // Spraying
2131  int sprayday2 = cfg_pest_productapplic_startdate2.value();
2132  int sprayday3 = cfg_pest_productapplic_startdate3.value();
2133  int sprayday=cfg_pest_productapplic_startdate.value();
2134  //sprayday+=random(cfg_pest_productapplic_period.value());
2135  if ( ( today == sprayday ) || ( today == sprayday2 ) || ( today == sprayday3 ) ) {
2136  if ( g_landscape_p->SupplyShouldSpray() ) {
2137  g_pest->DailyQueueAdd( this, l_pest_productOrchard_amount.value() );
2138  }
2139  m_LastSprayed = today; // Regardless of whether we spray our test compound, we want to have the herbicide effect
2140 
2141  }
2142 }
2143 
2147 }
2148 
2149 
2153  m_veg_patchy=true;
2156 }
2157 
2161  m_veg_patchy=true;
2164 }
2165 
2169  m_veg_patchy = true;
2172 }
2173 
2176  // The assumption is that natural grass has a range of species, which means
2177  // there should be good food all year - but still it should vary with season
2178  // So we add a constant to the digestability of 0.2
2179  m_digestability+=0.2;
2180  if (m_digestability>0.8) m_digestability=0.8;
2181 }
2182 
2185  // The assumption is that natural grass has a range of species, which means
2186  // there should be good food all year - but still it should vary with season
2187  // So we add a constant to the digestability of 0.2
2188  m_digestability+=0.2;
2189  if (m_digestability>0.8) m_digestability=0.8;
2190 }
2191 
2193  // The assumption is that natural grass has a range of species, which means
2194  // there should be good food all year - but still it should vary with season
2195  // So we add a constant to the digestability of 0.2
2196  m_digestability += 0.2;
2198  if (m_digestability>0.8) m_digestability = 0.8;
2199 }
2200 
2206 }
2207 
2213  if (random(100) < cfg_UMPatchyChance.value()) m_veg_patchy = true; else
2214  m_veg_patchy = false;
2215 }
2216 
2218  m_yddegs = m_ddegs;
2221  m_weed_biomass += dWee;
2222  if ( m_weed_biomass < 0.0 ) m_weed_biomass = 0.0;
2223  double temp_biomass = m_LAtotal * EL_PLANT_BIOMASS * 0.9 * g_biomass_scale[ m_vege_type ];
2224  // Calculate vegdensity here so that excess weeds do not make the density greater
2225  // They are in the patches which are not calculated in the 0.1 reduc.
2226  m_veg_density = ( int )floor( 0.5 + ( temp_biomass / ( 1 + m_veg_height ) ) );
2227  if ( m_veg_density > 100 ) m_veg_density = 100; // to stop array bounds problems
2228  double temp_bugmass = g_bug_percent_d[ m_vege_type ] * g_bug_percent_a[ m_vege_type ]
2229  + ( ( temp_biomass + m_weed_biomass ) * g_bug_percent_b[ m_vege_type ] )
2231  // Set a minimum value (regressions will otherwise give a -ve value
2232  if ( temp_bugmass < 0.05 ) temp_bugmass = 0.05;
2233  m_veg_biomass = m_weed_biomass + ( temp_biomass * 0.9 );
2234  m_insect_pop = temp_bugmass;
2235  m_veg_density = ( int )floor( 0.5 + ( m_veg_biomass / ( 1 + m_veg_height ) ) );
2236  if ( m_veg_density > 100 ) m_veg_density = 100; // to stop array bounds problems
2237 }
2238 
2239 
2241  LE::SetHigh( true );
2244 }
2245 
2246 
2248  m_type = tole_Railway;
2250 }
2251 
2253 {
2257 }
2258 
2259 
2261  LE::SetHigh(true);
2265 }
2266 //---------------------------------------------------------------------------
2267 //---------------------------------------------------------------------------
2268 
2269 
2271  LE::SetHigh( true ); // default to tall
2272 }
2273 
2274 
2276  m_type = tole_Copse;
2278 }
2279 
2280 
2284 }
2285 
2286 
2290 }
2291 
2292 
2295 }
2296 
2302  m_veg_patchy = true;
2303  LE::SetHigh( false ); // default to tall
2304 }
2305 
2308 }
2309 
2312 }
2313 
2316 }
2317 
2318 //---------------------------------------------------------------------------
2319 //---------------------------------------------------------------------------
2320 
2322  ;
2323 }
2324 
2325 
2329 }
2330 
2332  LE::SetHigh(true);
2333  m_type = tole_Garden;
2334 }
2335 
2336 
2338  LE::SetHigh( true );
2341  m_countrydesignation = 0; // default = 0 = town
2342 }
2343 
2344 
2346  LE::SetHigh( true );
2349 }
2350 
2351 
2353  LE::SetHigh( true );
2356 }
2357 
2358 
2362 }
2363 
2364 
2368 }
2369 
2370 
2374 }
2375 
2376 
2377 Pond::Pond( void ) : Freshwater() {
2378  m_type = tole_Pond;
2380  m_LarvalFood = 0.01;
2381  m_MaleNewtPresent = false;
2382 }
2383 
2385 {
2388  CalcLarvalFood();
2389  m_MaleNewtPresent = false;
2390 }
2391 
2393 {
2402  m_pondpesticide = 0.0;
2404  {
2405  return;
2406  }
2411  for (int x = m_minx; x <= m_maxx; x++)
2412  for (int y = m_miny; y <= m_maxy; y++)
2413  {
2415  }
2421 }
2422 
2424 {
2437  double area = m_area;
2438  if (m_area > 400) area = 400;
2439  const double LarvalFoodMonthlyK[12] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
2440  // Back calculate the scaler
2441  if (m_LarvalFood < 0.01) m_LarvalFood = 0.01;
2443  // Calculate the new scaler
2445  // Calculate the new food biomass
2447 }
2448 
2449 bool Pond::SubtractLarvalFood(double a_food)
2450 {
2455  if (g_rand_uni() > m_LarvalFoodScaler * 2) return false;
2456  else
2457  {
2458  m_LarvalFood -= a_food;
2459  return true;
2460  }
2461 }
2462 
2464  m_type = tole_River;
2466 }
2467 
2468 
2470  m_type = tole_Coast;
2472 }
2473 
2474 
2478 }
2479 
2480 
2484 }
2485 
2486 
2490 }
2491 
2492 
2496 }
2497 
2498 
2500  LE::SetHigh( true );
2503 }
2504 
2505 
2509 }
2510 
2511 
2513  LE::SetHigh( true );
2516 }
2517 
2518 
2520  LE::SetHigh( true );
2523 }
2524 
2525 
2529 }
2530 
2531 
2534 }
2535 
2536 
2540 }
2541 
2542 
2545 }
2546 
2547 
2549  m_type = tole_Track;
2551 }
2552 
2554  m_type = tole_Stream;
2556 }
2557 
2561 }
2562 
2564  m_type = tole_Carpark;
2566 }
2567 
2571 }
2572 
2576 }
2577 
2579  LE::SetHigh(true);
2580  m_type = tole_Pylon;
2582 }
2583 
2584 
2586  LE::SetHigh(true);
2587  m_type = tole_Pylon;
2589 }
2590 
2591 
2592 
2593 
2594 
2595 //--------------------------------------------------------------------
2596 // created 25/08/00
2598  static char error_num[ 20 ];
2599 
2600  // This returns the vegetation type (or crop type) as applicable
2601  switch ( EleReference ) {
2602  case 5: return tole_Building;
2603  case 6:
2604  case 8: // Rural residential
2605  case 10: return tole_UrbanNoVeg;
2606  case 11: return tole_Garden;
2607  case 12: return tole_AmenityGrass;
2608  case 13: return tole_RoadsideVerge;
2609  case 14: return tole_Parkland;
2610  case 15: return tole_StoneWall;
2611  case 16: return tole_BuiltUpWithParkland;
2612  case 17: return tole_UrbanPark;
2613  case 20: return tole_Field;
2614  case 26: return tole_PermPastureLowYield;
2615  case 27: return tole_PermPastureTussocky;
2616  case 30: return tole_Field;
2617  case 31: return tole_UnsprayedFieldMargin;
2618  case 33: return tole_PermanentSetaside;
2619  case 35: return tole_PermPasture;
2620  case 40: return tole_DeciduousForest;
2621  case 41: return tole_Copse;
2622  case 50: return tole_ConiferousForest;
2623  case 55: return tole_YoungForest;
2624  case 56: return tole_Orchard;
2625  case 57: return tole_OrchardBand;
2626  case 58: return tole_MownGrass;
2627  case 69: return tole_BareRock;
2628  case 60: return tole_MixedForest;
2629  case 70: return tole_Scrub;
2630  case 71: return tole_PlantNursery;
2631  case 75: return tole_PitDisused;
2632  case 80: return tole_Saltwater;
2633  case 90: return tole_Freshwater;
2634  case 94: return tole_Heath;
2635  case 95: return tole_Marsh;
2636  case 99:// This is stream less than 2m
2637  case 96: return tole_River;
2638  case 97: return tole_RiversideTrees;
2639  case 98: return tole_RiversidePlants;
2640  case 100: return tole_Coast;
2641  case 101: return tole_SandDune;
2642  case 110: return tole_NaturalGrassDry;
2643  case 115: return tole_ActivePit;
2644  case 118: return tole_Railway;
2645  case 120:
2646  case 121: return tole_LargeRoad;
2647  case 122: return tole_SmallRoad;
2648  case 123: return tole_Track;
2649  case 130: return tole_Hedges;
2650  case 140: return tole_HedgeBank;
2651  case 141: return tole_BeetleBank;
2652  case 150: return tole_Chameleon;
2653  case 160: return tole_FieldBoundary;
2654  case 201: return tole_RoadsideSlope;
2655  case 202: return tole_MetalledPath;
2656  case 203: return tole_Carpark;
2657  case 204: return tole_Churchyard;
2658  case 205: return tole_NaturalGrassWet;
2659  case 206: return tole_Saltmarsh;
2660  case 207: return tole_Stream;
2661  case 208: return tole_HeritageSite;
2662  case 209: return tole_Wasteland;
2663  case 210: return tole_NaturalGrassDry;
2664  case 211: return tole_WindTurbine;
2665  case 212: return tole_IndividualTree; // TODO This is a windmill
2666  case 214: return tole_PlantNursery;
2667  case 213: return tole_IndividualTree;
2668  case 215: return tole_Vildtager;
2669  case 216: return tole_WoodyEnergyCrop;
2670  case 217: return tole_WoodlandMargin;
2671  case 218: return tole_PermPastureTussockyWet;
2672  case 219: return tole_Pond;
2673  case 220: return tole_FishFarm;
2674  case 6000:
2675  case 2112:
2676  case 2300:
2677  case 2430: return tole_Missing;
2678 
2679  // case 999: return tole_Foobar;
2680  // !! type unknown - should not happen
2681  default:
2682  sprintf( error_num, "%d", EleReference );
2683  g_msg->Warn( WARN_FILE, "LE_TypeClass::TranslateEleTypes(): ""Unknown landscape element type:", error_num );
2684  exit( 1 );
2685  }
2686 }
2687 
2688 
2689 
2690 //----------------------------------------------------------------------
2691 // created 24/08/00
2693  char error_num[ 20 ];
2694 
2695  // This returns the vegetation type (or crop type) as applicable
2696  switch ( VegReference ) {
2697  case 1:
2698  return tov_SpringBarley;
2699  case 2:
2700  return tov_WinterBarley;
2701  case 3:
2702  return tov_SpringWheat;
2703  case 4:
2704  return tov_WinterWheat;
2705  case 5:
2706  return tov_WinterRye;
2707  case 6:
2708  return tov_Oats;
2709  case 7:
2710  return tov_Triticale;
2711  case 8:
2712  return tov_Maize;
2713  case 13:
2714  return tov_SpringBarleySeed;
2715  case 14: return tov_SpringBarleyStrigling;
2716  case 15: return tov_SpringBarleyStriglingSingle;
2717  case 16: return tov_SpringBarleyStriglingCulm;
2718  case 17: return tov_WinterWheatStrigling;
2719  case 18: return tov_WinterWheatStriglingSingle;
2720  case 19: return tov_WinterWheatStriglingCulm;
2721  case 21:
2722  return tov_SpringRape;
2723  case 22:
2724  return tov_WinterRape;
2725  case 30:
2726  return tov_FieldPeas;
2727  case 31:
2728  return tov_FieldPeasSilage; //ok?
2729  case 32:
2730  return tov_BroadBeans;
2731  case 50:
2732  return tov_Setaside;
2733  case 54:
2734  return tov_PermanentSetaside;
2735  case 55:
2736  return tov_YoungForest;
2737  case 60:
2738  return tov_FodderBeet;
2739  case 61:
2740  return tov_SugarBeet;
2741  case 65:
2742  return tov_CloverGrassGrazed1;
2743  case 92:
2744  return tov_PotatoesIndustry;
2745  case 93:
2746  return tov_Potatoes;
2747  case 94:
2748  return tov_SeedGrass1;
2749  case 102:
2750  return tov_OWinterBarley;
2751  case 611:
2752  return tov_OWinterBarleyExt;
2753  case 103:
2754  return tov_OSBarleySilage;
2755  case 105:
2756  return tov_OWinterRye;
2757  case 106:
2758  return tov_OFieldPeasSilage;
2759  case 107:
2760  return tov_SpringBarleyGrass;
2761  case 108:
2763  case 109:
2764  return tov_SpringBarleySpr;
2765  case 113:
2767  case 114:
2769  case 115:
2770  return tov_SpringBarleySilage;
2771  case 122:
2772  return tov_OWinterRape;
2773  case 140:
2774  return tov_PermanentGrassGrazed;
2775  case 141:
2777  case 142:
2779  case 165:
2780  return tov_CloverGrassGrazed2;
2781  case 194:
2782  return tov_SeedGrass2;
2783  case 201:
2784  return tov_OSpringBarley;
2785  case 204:
2787  case 205:
2788  return tov_OWinterWheat;
2789  case 206:
2790  return tov_OOats;
2791  case 207:
2792  return tov_OTriticale;
2793  case 230:
2794  return tov_OFieldPeas;
2795  case 26:
2796  return tov_OFodderBeet;
2797  case 265:
2798  return tov_OCloverGrassGrazed1;
2799  case 270:
2800  return tov_OCarrots;
2801  case 271:
2802  return tov_Carrots;
2803  case 273:
2804  return tov_OGrazingPigs;
2805  case 293:
2806  return tov_OPotatoes;
2807  case 294:
2808  return tov_OSeedGrass1;
2809  case 306:
2810  return tov_OSpringBarleyPigs;
2811  case 307:
2812  return tov_OSpringBarleyGrass;
2813  case 308:
2814  return tov_OSpringBarleyClover;
2815  case 340:
2817  case 365:
2818  return tov_OCloverGrassGrazed2;
2819  case 366:
2820  return tov_OCloverGrassSilage1;
2821  case 394:
2822  return tov_OSeedGrass2;
2823  case 400:
2824  return tov_NaturalGrass;
2825  case 401:
2826  return tov_None;
2827  case 601:
2828  return tov_WWheatPControl;
2829  case 602:
2830  return tov_WWheatPToxicControl;
2831  case 603:
2832  return tov_WWheatPTreatment;
2833  case 604:
2835  case 605:
2836  return tov_WinterWheatShort;
2837  case 606:
2838  return tov_MaizeSilage;
2839  case 607:
2840  return tov_FodderGrass;
2841  case 608:
2843  case 609:
2844  return tov_OSpringBarleyExt;
2845  case 610:
2846  return tov_OMaizeSilage;
2847  case 612:
2849  case 613:
2850  return tov_Heath;
2851  case 700:
2852  return tov_OrchardCrop;
2853  case 999:
2854  return tov_Undefined;
2855  default: // No matching code so we need an error message of some kind
2856  sprintf( error_num, "%d", VegReference );
2857  g_msg->Warn( WARN_FILE, "LE_TypeClass::TranslateVegTypes(): ""Unknown vegetation type:", error_num );
2858  exit( 1 );
2859  }
2860 }
2861 
2862 //-----------------------------------------------------------------------
2863 // created 25/08/00
2865  char error_num[ 20 ];
2866 
2867  // This returns the vegetation type (or crop type) as applicable
2868  switch ( VegReference ) {
2869  case tov_SpringBarley:
2870  return 1;
2871  case tov_WinterBarley:
2872  return 2;
2873  case tov_SpringWheat:
2874  return 3;
2875  case tov_WinterWheat:
2876  return 4;
2877  case tov_WinterRye:
2878  return 5;
2879  case tov_Oats:
2880  return 6;
2881  case tov_Triticale:
2882  return 7;
2883  case tov_Maize:
2884  return 8;
2885  case tov_SpringBarleySeed:
2886  return 13;
2888  return 14;
2890  return 15;
2892  return 16;
2894  return 17;
2896  return 18;
2898  return 19;
2899  case tov_SpringRape:
2900  return 21;
2901  case tov_WinterRape:
2902  return 22;
2903  case tov_FieldPeas:
2904  return 30;
2905  case tov_FieldPeasSilage:
2906  return 31;
2907  case tov_BroadBeans:
2908  return 32;
2909  case tov_Setaside:
2910  return 50;
2911  case tov_PermanentSetaside:
2912  return 54;
2913  case tov_YoungForest:
2914  return 55;
2915  case tov_FodderBeet:
2916  return 60;
2917  case tov_SugarBeet:
2918  return 61;
2920  return 65;
2921  case tov_PotatoesIndustry:
2922  return 92;
2923  case tov_Potatoes:
2924  return 93;
2925  case tov_SeedGrass1:
2926  return 94;
2927  case tov_OWinterBarley:
2928  return 102;
2929  case tov_OWinterBarleyExt:
2930  return 611;
2931  case tov_OWinterRye:
2932  return 105;
2933  case tov_SpringBarleyGrass:
2934  return 107;
2936  return 108;
2937  case tov_SpringBarleySpr:
2938  return 109;
2939  case tov_OSBarleySilage:
2940  return 103;
2942  return 113;
2944  return 114;
2946  return 115;
2947  case tov_OWinterRape:
2948  return 122;
2950  return 140;
2952  return 141;
2954  return 142;
2956  return 165;
2957  case tov_SeedGrass2:
2958  return 194;
2959  case tov_OSpringBarley:
2960  return 201;
2962  return 204;
2963  case tov_OWinterWheat:
2964  return 205;
2965  case tov_OOats:
2966  return 206;
2967  case tov_OTriticale:
2968  return 207;
2969  case tov_OFieldPeas:
2970  return 230;
2971  case tov_OFieldPeasSilage:
2972  return 106;
2973  case tov_OFodderBeet:
2974  return 260;
2976  return 265;
2977  case tov_OCarrots:
2978  return 270;
2979  case tov_Carrots:
2980  return 271;
2981  case tov_OPotatoes:
2982  return 293;
2983  case tov_OSeedGrass1:
2984  return 294;
2985  case tov_OSpringBarleyPigs:
2986  return 306;
2988  return 307;
2990  return 308;
2992  return 340;
2994  return 365;
2996  return 366;
2997  case tov_OSeedGrass2:
2998  return 394;
2999  case tov_NaturalGrass:
3000  return 400;
3001  case tov_None:
3002  return 401;
3003  case tov_NoGrowth:
3004  return 402;
3005  case tov_WWheatPControl:
3006  return 601;
3008  return 602;
3009  case tov_WWheatPTreatment:
3010  return 603;
3012  return 604;
3013  case tov_WinterWheatShort:
3014  return 605;
3015  case tov_MaizeSilage:
3016  return 606;
3017  case tov_FodderGrass:
3018  return 607;
3020  return 608;
3021  case tov_OSpringBarleyExt:
3022  return 609;
3023  case tov_OMaizeSilage:
3024  return 610;
3026  return 612;
3027  case tov_Heath:
3028  return 613;
3029  case tov_OrchardCrop:
3030  return 700;
3031  case tov_Undefined:
3032  return 999;
3033  default: // No matching code so we need an error message of some kind
3034  sprintf( error_num, "%d", VegReference );
3035  g_msg->Warn( WARN_FILE, "LE_TypeClass::BackTranslateVegTypes(): ""Unknown vegetation type:", error_num );
3036  exit( 1 );
3037  }
3038 }
3039 
3040 //-----------------------------------------------------------------------
3041 // created 25/08/00
3043  static char error_num[ 20 ];
3044 
3045  // This returns the vegetation type (or crop type) as applicable
3046  switch ( EleReference )
3047  {
3048  case tole_Building: return 5;
3049  case tole_UrbanNoVeg: return 6;
3050  case tole_Garden: return 11;
3051  case tole_AmenityGrass: return 12;
3052  case tole_RoadsideVerge: return 13;
3053  case tole_Parkland: return 14;
3054  case tole_StoneWall: return 15;
3055  case tole_BuiltUpWithParkland: return 16;
3056  case tole_UrbanPark: return 17;
3057  case tole_Field: return 20;
3058  case tole_PermPastureTussocky: return 27;
3059  case tole_PermPastureLowYield: return 26;
3060  case tole_UnsprayedFieldMargin: return 31;
3061  case tole_PermanentSetaside: return 35;
3062  case tole_PermPasture: return 35;
3063  case tole_DeciduousForest: return 40;
3064  case tole_Copse: return 41;
3065  case tole_ConiferousForest: return 50;
3066  case tole_YoungForest: return 55;
3067  case tole_Orchard: return 56;
3068  case tole_BareRock: return 69;
3069  case tole_OrchardBand: return 57;
3070  case tole_MownGrass: return 58;
3071  case tole_MixedForest: return 60;
3072  case tole_Scrub: return 70;
3073  case tole_PitDisused: return 75;
3074  case tole_Saltwater: return 80;
3075  case tole_Freshwater: return 90;
3076  case tole_Heath: return 94;
3077  case tole_Marsh: return 95;
3078  case tole_River: return 96;
3079  case tole_RiversideTrees: return 97;
3080  case tole_RiversidePlants: return 98;
3081  case tole_Coast: return 100;
3082  case tole_SandDune: return 101;
3083  case tole_NaturalGrassDry: return 110;
3084  case tole_ActivePit: return 115;
3085  case tole_Railway: return 118;
3086  case tole_LargeRoad: return 121;
3087  case tole_SmallRoad: return 122;
3088  case tole_Track: return 123;
3089  case tole_Hedges: return 130;
3090  case tole_HedgeBank: return 140;
3091  case tole_BeetleBank: return 141;
3092  case tole_Chameleon: return 150;
3093  case tole_FieldBoundary: return 160;
3094  case tole_RoadsideSlope: return 201;
3095  case tole_MetalledPath: return 202;
3096  case tole_Carpark: return 203;
3097  case tole_Churchyard: return 204;
3098  case tole_NaturalGrassWet: return 205;
3099  case tole_Saltmarsh: return 206;
3100  case tole_Stream: return 207;
3101  case tole_HeritageSite: return 208;
3102  case tole_Wasteland: return 209;
3103  //case tole_NaturalGrassDry: return 210; This is a place holder for overdrev
3104  case tole_WindTurbine: return 211;
3105  case tole_Pylon: return 212;
3106  case tole_IndividualTree: return 213;
3107  case tole_PlantNursery: return 214;
3108  case tole_Vildtager: return 215;
3109  case tole_WoodyEnergyCrop: return 216;
3110  case tole_WoodlandMargin: return 217;
3111  case tole_PermPastureTussockyWet: return 218;
3112  case tole_Pond: return 219;
3113  case tole_FishFarm: return 220;
3114  case tole_Missing: return 2112;
3115 
3116  //case tole_Foobar: return 999;
3117  // !! type unknown - should not happen
3118  default:
3119  sprintf( error_num, "%d", EleReference );
3120  g_msg->Warn( WARN_FILE, "LE_TypeClass::BackTranslateEleTypes(): ""Unknown vegetation type:", error_num );
3121  exit( 1 );
3122  }
3123 }
3124 
3125 //------------------------------------------------------------------------
3126 
3129  m_insect_pop = m_insect_pop * 3.0;
3130 }
3131 
3134  m_insect_pop = m_insect_pop * cfg_beetlebankinsectscaler.value()*3.0;
3135 }
3136 
3137 
virtual void DoDevelopment(void)
Definition: elements.cpp:3127
ChameleonLE(void)
Definition: elements.cpp:2326
virtual void ZeroVeg(void)
Definition: elements.cpp:1606
PermPasture(void)
Definition: elements.cpp:1817
MixedForest(void)
Definition: elements.cpp:2293
static CfgInt cfg_OrchardSprayDay2("TOX_ORCHARDSPRAYDAYTWO", CFG_CUSTOM, 200000)
Heath(void)
Definition: elements.cpp:1987
static double m_monthly_traffic[]
Used for birds that feed on grain on cereal fields 3% spill is expected.
Definition: elements.h:462
#define RV_CUT_JUN
Definition: elements.cpp:185
static CfgFloat l_el_weed_glue("ELEM_WEED_GLUE", CFG_PRIVATE, 0.99)
static CfgFloat cfg_BBPatchyChance("BEETLEBANKBPATCHYCHANCE", CFG_CUSTOM, 0.5)
The chance that a beetlebank being created is patchy or not.
Copse(void)
Definition: elements.cpp:2275
int m_veg_density
Definition: elements.h:620
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1414
static CfgBool l_el_read_bug_percentage_file("ELEM_READ_BUG_PERCENTAGE_FILE", CFG_CUSTOM, false)
LE(void)
Definition: elements.cpp:267
CfgFloat l_el_o_cut_height("ELEM_RV_CUT_HEIGHT", CFG_PRIVATE, 10.0)
int m_minx
Definition: elements.h:403
#define EL_BUG_PERCENT_WR_A
Definition: elements.cpp:56
River(void)
Definition: elements.cpp:2463
static double g_bug_percent_c[tov_Undefined]
Definition: elements.cpp:122
int VegTypeToCurveNum(TTypesOfVegetation VegReference)
Definition: plants.cpp:231
#define RV_CUT_GREEN
Definition: elements.cpp:205
int m_unsprayedmarginpolyref
Definition: elements.h:388
CropActualValues m_CropDataStorage[2]
Keeps data on pesticide applications, biomass at harvest etc. Data for maximum two crops can be store...
Definition: elements.h:642
int GetGooseNos()
For goose model functionality, returns the number of geese yesterday.
Definition: elements.cpp:524
virtual bool IsGrass()
Definition: elements.cpp:1284
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: elements.cpp:3042
#define RV_MAY_1ST
Definition: elements.cpp:200
double m_vegddegs
Definition: elements.h:455
#define RV_CUT_SEP
Definition: elements.cpp:194
long Date(void)
Definition: calendar.h:57
class Pesticide * g_pest
Definition: pesticide.cpp:70
RoadsideSlope(void)
Definition: elements.cpp:1942
void IncTreatCounter(int a_treat)
Definition: Landscape.cpp:3339
int m_valid_y
Definition: elements.h:393
#define EL_BUG_PERCENT_Edges_C
Definition: elements.cpp:70
virtual ~LE(void)
Definition: elements.cpp:436
#define EL_BUG_PERCENT_C
Definition: elements.cpp:34
GreenElement(void)
Definition: elements.cpp:1957
static double m_largeroad_load[]
Definition: elements.h:463
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1020
AmenityGrass(void)
Definition: elements.cpp:2487
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:313
#define EL_BUG_PERCENT_WR_C
Definition: elements.cpp:58
double m_birdmaizeforage
The maize forage present in KJ/m2.
Definition: elements.h:440
#define EL_BUG_PERCENT_A
Definition: elements.cpp:32
static CfgInt l_el_rv_cut_jul("ELEM_RV_CUT_JUL", CFG_PRIVATE, 35)
double GetLAtotalDiff(double a_ddegs, double a_yddegs, int a_plant, int a_phase)
Definition: plants.cpp:109
double m_oldLAtotal
Definition: elements.h:610
int m_squares_in_map
Definition: elements.h:86
Freshwater(void)
Definition: elements.cpp:2365
StoneWall(void)
Definition: elements.cpp:2345
virtual void DoDevelopment(void)
Definition: elements.cpp:2020
#define RV_CUT_TOTAL
Definition: elements.cpp:207
class CropData * g_crops
Definition: plants.cpp:39
static CfgFloat l_el_weed_slope("ELEM_WEED_SLOPE", CFG_PRIVATE, 0.15)
NaturalGrassDry(void)
Definition: elements.cpp:2150
CfgInt cfg_pest_productapplic_startdate3
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
bool m_force_growth
Definition: elements.h:632
int m_newoldgrowthindex
Definition: elements.h:626
virtual void DoDevelopment()
Definition: elements.cpp:2192
long m_running
Definition: elements.h:376
bool SubtractLarvalFood(double a_food)
Called by a larva when feeding, removes an age specific amount of larval food.
Definition: elements.cpp:2449
int m_gooseNos[366]
The number of geese each day.
Definition: elements.h:430
bool m_MaleNewtPresent
Flag for presence of a male newt.
Definition: elements.h:1091
void FloatToDouble(double &, float)
int m_default_grazing_level
Definition: elements.h:453
bool m_poison
Definition: elements.h:451
bool SupplyShouldSpray()
Definition: landscape.h:336
FILE * m_ifile
Definition: elements.h:633
int m_maxx
Definition: elements.h:402
static CfgFloat l_el_rv_cut_height("ELEM_RV_CUT_HEIGHT", CFG_PRIVATE, 10.0)
LE_Signal m_signal_mask
Definition: elements.h:467
Pylon(void)
Definition: elements.cpp:2578
SandDune(void)
Definition: elements.cpp:2481
int m_nutrient_status
Definition: elements.h:608
WoodlandMargin(void)
Definition: elements.cpp:2306
#define RV_CUT_HEIGHT
Definition: elements.cpp:203
LargeRoad(void)
Definition: elements.cpp:2526
int m_mowndecay
Definition: elements.h:425
int m_PesticideGridCell
Definition: elements.h:397
double m_LarvalFood
The amount of larval food present.
Definition: elements.h:1085
virtual void SetCropData(double, double, double, TTypesOfVegetation, double, int)
Definition: elements.cpp:1788
Integer configurator entry class.
Definition: configurator.h:85
double m_pondpesticide
Holds the pesticide content per unit pond water.
Definition: elements.h:1089
#define RV_CUT_OCT
Definition: elements.cpp:197
HedgeBank(void)
Definition: elements.cpp:1868
static CfgInt l_el_rv_cut_oct("ELEM_RV_CUT_OCT", CFG_PRIVATE, 49)
HeritageSite(void)
Definition: elements.cpp:2568
#define EL_BUG_PERCENT_WW_A
Definition: elements.cpp:44
void DailyQueueAdd(LE *a_element_sprayed, double a_amount)
Definition: pesticide.cpp:105
Scrub(void)
Definition: elements.cpp:1967
static CfgFloat cfg_ele_weedscaling("ELE_WEEDSCALING", CFG_CUSTOM, 1.0)
static double g_bug_percent_b[tov_Undefined]
Definition: elements.cpp:121
double m_newgrowthsum
Definition: elements.h:627
RoadsideVerge(void)
Definition: elements.cpp:1886
static CfgFloat l_el_veg_start_lait("ELEM_VEG_START_LAIT", CFG_PRIVATE, 1.08)
Building(void)
Definition: elements.cpp:2337
static CfgFloat cfg_beetlebankinsectscaler("ELE_BBINSECTSCALER", CFG_CUSTOM, 1.0)
int m_vegage
Definition: elements.h:447
bool m_is_in_map
Definition: elements.h:399
#define EL_PLANT_BIOMASS
Definition: elements.cpp:170
static CfgInt cfg_OrchardSprayDay("TOX_ORCHARDSPRAYDAY", CFG_CUSTOM, 150)
virtual void SetVegPatchy(bool p)
Definition: elements.h:506
static double g_bug_percent_a[tov_Undefined]
Definition: elements.cpp:120
static double g_bug_percent_d[tov_Undefined]
Definition: elements.cpp:123
Churchyard(void)
Definition: elements.cpp:2558
CfgInt g_el_herbicide_delaytime_days("ELEM_HERBICIDE_DELAYTIME_DAYS", CFG_PRIVATE, 35)
double m_LAtotal
Definition: elements.h:609
int GetGooseNosToday()
For goose model functionality, returns the number of geese today.
Definition: elements.cpp:537
CfgFloat cfg_pondpesticiderunoff("POND_PEST_RUNOFFFACTOR", CFG_CUSTOM, 10.0)
The multiplication factor assumed to account for ingress of pesticide from run-off and soil water to ...
CfgFloat l_el_o_cut_total("ELEM_RV_CUT_TOTAL", CFG_PRIVATE, 2.0)
void Cutting(int a_today)
Definition: elements.cpp:2062
CfgFloat l_pest_insecticide_amount
#define EL_BUG_PERCENT_G_B
Definition: elements.cpp:63
virtual bool IsCereal()
Definition: elements.cpp:1175
static CfgStr l_el_bug_percentage_file("ELEM_BUG_PERCENTAGE_FILE", CFG_CUSTOM,"bugpercents.txt")
TTypesOfVegetation
long m_management_loop_detect_date
Definition: elements.h:407
static CfgFloat cfg_SetAsidePatchyChance("SETASIDEPATCHYCHANCE", CFG_CUSTOM, 1.0)
The chance that a setaside being created is patchy or not.
double value(void)
Definition: configurator.h:107
double m_force_Weed
Definition: elements.h:628
Definition: elements.h:81
virtual void DoDevelopment(void)
Definition: elements.cpp:1893
static CfgInt cfg_MownGrassNoCutsDay("ELE_MOWNGRASSNOCUTS", CFG_CUSTOM,-1)
static CfgInt l_el_growth_daydeg_magic("ELEM_GROWTH_DAYDEG_MAGIC", CFG_PRIVATE, 100)
FishFarm(void)
Definition: elements.cpp:2371
BeetleBank(void)
Definition: elements.cpp:1877
double m_digestability
Definition: elements.h:624
bool m_repeat_start
Definition: elements.h:106
#define EL_BUG_PERCENT_B
Definition: elements.cpp:33
double m_total_biomass
Definition: elements.h:614
void Cutting(int a_today)
Definition: elements.cpp:2109
TTypesOfVegetation m_lastsownvegtype
Records the last vegegetation type that was sown on the element.
Definition: elements.h:444
Marsh(void)
Definition: elements.cpp:1974
static CfgFloat l_el_bug_slope("ELEM_BUG_SLOPE", CFG_PRIVATE, 0.2)
#define EL_BUG_PERCENT_WR_B
Definition: elements.cpp:57
Vildtager(void)
Definition: elements.cpp:2252
void SetSprayedToday(bool a_didit)
Definition: elements.h:297
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
void SetMownDecay(int a_decaytime_days)
Definition: elements.h:308
double m_force_LAtotal
Definition: elements.h:630
virtual void SetCropData(double, double, double, TTypesOfVegetation, double, int)
Definition: elements.h:167
int m_almass_le_type
This holds the ALMaSS element type reference number.
Definition: elements.h:422
double m_veg_cover
Definition: elements.h:622
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: elements.cpp:2597
#define EL_BUG_PERCENT_G_C
Definition: elements.cpp:64
Hedges(void)
Definition: elements.cpp:1857
double SupplyPesticide(int a_x, int a_y)
Gets total pesticide for a location.
Definition: Landscape.cpp:481
class Weather * g_weather
Definition: weather.cpp:41
#define EL_BUG_PERCENT_WW_B
Definition: elements.cpp:45
Pond(void)
Definition: elements.cpp:2377
Carpark(void)
Definition: elements.cpp:2563
RiversideTrees(void)
Definition: elements.cpp:2240
int m_soiltype
Definition: elements.h:448
const int October
Definition: landscape.h:44
UrbanNoVeg(void)
Definition: elements.cpp:2499
int m_herbicidedelay
Definition: elements.h:426
const char * value(void)
Definition: configurator.h:139
virtual void SetGrowthPhase(int a_phase)
Definition: elements.cpp:1471
CfgInt g_el_strigling_delaytime_days("ELEM_STRIGLING_DELAYTIME_DAYS", CFG_PRIVATE, 28)
static double g_biomass_scale[tov_Undefined]
Definition: elements.cpp:118
Stream(void)
Definition: elements.cpp:2553
class LE_TypeClass * g_letype
Definition: elements.cpp:265
static CfgFloat l_pest_productOrchard_amount("PEST_PRODUCTORCHARD_AMOUNT", CFG_CUSTOM, 0.0)
long m_LastSprayed
Definition: elements.h:917
int m_valid_x
Definition: elements.h:392
Orchard(void)
Definition: elements.cpp:1995
TTypesOfVegetation m_vege_type
Definition: elements.h:604
virtual void DoDevelopment(void)
Definition: elements.cpp:1767
CfgInt cfg_pest_productapplic_startdate
Definition: elements.cpp:110
bool m_skylarkscrapes
For management testing of skylark scrapes.
Definition: elements.h:88
class MapErrorMsg * g_msg
Definition: maperrormsg.cpp:38
virtual void GrazeVegetationTotal(double a_grams)
Definition: elements.cpp:1677
bool m_high
Definition: elements.h:450
double GetDDDegs(long a_date)
Definition: weather.cpp:155
vector< int > m_lasttreat
Definition: elements.h:459
double GetHeightDiff(double a_ddegs, double a_yddegs, int a_plant, int a_phase)
Definition: plants.cpp:116
static double m_smallroad_load[]
Definition: elements.h:464
UrbanPark(void)
Definition: elements.cpp:2506
bool m_forced_phase_shift
Definition: elements.h:623
bool value(void)
Definition: configurator.h:123
int MDates[2][25]
Definition: elements.h:465
CfgBool cfg_calc_pond_pesticide("POND_PEST_CALC_ON", CFG_CUSTOM, false)
Flag to determine whether to calculate pond pesticide concentration.
double m_insect_pop
Definition: elements.h:612
virtual void DoDevelopment(void)
Definition: elements.cpp:2072
Saltmarsh(void)
Definition: elements.cpp:1981
virtual void SetCropDataAll(double, double, double, double, TTypesOfVegetation, double, double, int, double, bool, double)
Definition: elements.h:168
double m_LarvalFoodScaler
The proportion of larval food per m2.
Definition: elements.h:1087
int DayInYear(void)
Definition: calendar.h:58
PlantNursery(void)
Definition: elements.cpp:2260
static CfgInt l_el_veg_heightscale("ELEM_VEG_HEIGHTSCALE", CFG_PRIVATE, 16)
int GetGooseNosTodayTimed()
For goose model functionality, returns the number of geese today at a predefined time.
Definition: elements.cpp:548
WoodyEnergyCrop(void)
Definition: elements.cpp:2314
double m_dead_biomass
Definition: elements.h:617
OrchardBand(void)
Definition: elements.cpp:2011
CfgFloat l_el_o_cut_green("ELEM_RV_CUT_GREEN", CFG_PRIVATE, 1.5)
Track(void)
Definition: elements.cpp:2548
double m_goosegrazingforage[gs_foobar]
The grazing forage present in KJ/min.
Definition: elements.h:442
bool StartValid(int a_veg_type, int a_phase)
Definition: plants.cpp:364
long m_olddays
Definition: elements.h:406
int m_map_index
Definition: elements.h:420
virtual void DoDevelopment(void)
Definition: elements.cpp:513
virtual void ReduceVeg(double a_reduc)
Definition: elements.cpp:1707
double SupplyGlobalRadiation()
Definition: landscape.h:1267
static CfgFloat l_el_growth_phase_shift_level("ELEM_GROWTH_PHASE_SHIFT_LEVEL", CFG_PRIVATE, 0.5)
static CfgFloat l_el_rv_cut_total("ELEM_RV_CUT_TOTAL", CFG_PRIVATE, 2.0)
virtual void DoDevelopment(void)
Definition: elements.cpp:3132
void SetSubType(int a_subtype)
Definition: elements.h:110
virtual double GetTrafficLoad(void)
Definition: elements.cpp:2543
#define EL_GROWTH_PHASE_SHIFT_LEVEL
Definition: elements.cpp:158
double m_weed_biomass
Definition: elements.h:618
virtual void DoDevelopment(void)
Definition: elements.cpp:2384
static double g_weed_percent[tov_Undefined]
Definition: elements.cpp:119
BareRock(void)
Definition: elements.cpp:2475
Field(void)
Definition: elements.cpp:1743
RiversidePlants(void)
Definition: elements.cpp:2144
double m_ddegs
Definition: elements.h:457
virtual void ReduceVeg_Extended(double a_reduc)
Definition: elements.cpp:1718
Definition: plants.h:51
double m_total_biomass_old
Definition: elements.h:615
virtual void SetCropDataAll(double, double, double, double, TTypesOfVegetation, double, double, int, double, bool, double)
Definition: elements.cpp:1798
static CfgInt cfg_UMPatchyChance("UMPATCHYCHANCE", CFG_CUSTOM, 0)
virtual APoint GetCentroid()
Definition: elements.cpp:516
virtual void DoDevelopment(void)
Definition: elements.cpp:1621
#define EL_GROWTH_DAYDEG_MAGIC
Definition: elements.cpp:146
double m_green_biomass
Definition: elements.h:616
Definition: treatment.h:82
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: elements.cpp:2692
int GetLastTreatment(int *a_index)
Definition: elements.cpp:493
int m_centroidx
Definition: elements.h:394
CfgInt g_el_tramline_decaytime_days("ELEM_TRAMLINE_DECAYTIME_DAYS", CFG_PRIVATE, 21)
LE * m_border
Definition: elements.h:387
YoungForest(void)
Definition: elements.cpp:2297
VegElement(void)
Definition: elements.cpp:573
Bool configurator entry class.
Definition: configurator.h:116
unsigned int m_lastindex
Definition: elements.h:460
#define EL_BUG_PERCENT_WRy_A
Definition: elements.cpp:50
Farm * m_owner
Definition: elements.h:409
static CfgFloat l_el_bug_glue("ELEM_BUG_GLUE", CFG_PRIVATE, 0.50)
IndividualTree(void)
Definition: elements.cpp:2310
Parkland(void)
Definition: elements.cpp:2493
class Calendar * g_date
Definition: calendar.cpp:38
int m_gooseSpNos[366][gs_foobar]
The number of geese of each species each day.
Definition: elements.h:432
virtual void DoDevelopment(void)
Definition: elements.cpp:2120
#define RV_CUT_JUL
Definition: elements.cpp:188
virtual void ForceGrowthTest(void)
Definition: elements.cpp:1523
virtual void DoDevelopment(void)
Definition: elements.cpp:2217
int MConsts[10]
Definition: elements.h:466
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:472
void Tick(void)
Definition: elements.cpp:501
#define EL_BUG_PERCENT_SB_C
Definition: elements.cpp:40
double m_oldnewgrowth[32]
Definition: elements.h:625
static CfgInt l_el_rv_cut_may("ELEM_RV_CUT_MAY", CFG_PRIVATE, 142)
virtual void InsectMortality(double a_fraction)
Definition: elements.cpp:1813
int m_centroidy
Definition: elements.h:395
virtual void DoDevelopment()
Definition: elements.cpp:2183
MownGrass(void)
Definition: elements.cpp:2003
int m_miny
Definition: elements.h:405
double m_force_veg_height
Definition: elements.h:631
Garden(void)
Definition: elements.cpp:2331
int m_tramlinesdecay
Definition: elements.h:424
double m_birdseedforage
The grain forage present in KJ/m2.
Definition: elements.h:438
virtual void GrazeVegetation(double a_grams, bool a_force)
Definition: elements.cpp:1682
CfgInt cfg_pest_productapplic_startdate2
#define RV_CUT_AUG
Definition: elements.cpp:191
NonVegElement(void)
Definition: elements.cpp:2321
const int March
Definition: landscape.h:37
double GetStartValue(int a_veg_type, int a_phase, int a_type)
Definition: plants.h:105
bool JanFirst(void)
Definition: calendar.h:74
double m_LAgreen
Definition: elements.h:611
ConiferousForest(void)
Definition: elements.cpp:2287
void ResetTrace(void)
Definition: elements.cpp:463
int m_farmfunc_tried_to_do
Definition: elements.h:423
bool m_pig_grazing
Definition: elements.h:454
void DoCopy(const LE *a_Le)
a copy function to be used because a copy constuctor won&#39;t work
Definition: elements.cpp:356
TTypesOfVegetation GetPreviousCrop(int a_index)
Definition: farm.h:811
virtual double GetTrafficLoad(void)
Definition: elements.cpp:2532
CfgFloat cfg_goose_GrainDecayRate
static CfgFloat cfg_MGPatchyChance("MOWNGRASSPATCHYCHANCE", CFG_CUSTOM, 0.5)
The chance that a beetlebank being created is patchy or not.
#define EL_GROWTH_DATE_MAGIC
Definition: elements.cpp:152
TTypesOfVegetation GetPreviousCrop(int a_index)
Definition: elements.cpp:1783
int m_veg_phase
Definition: elements.h:607
int m_countrydesignation
Definition: elements.h:410
static CfgInt l_el_rv_cut_aug("ELEM_RV_CUT_AUG", CFG_PRIVATE, 42)
ActivePit(void)
Definition: elements.cpp:2519
int m_owner_index
Definition: elements.h:412
int GetGooseSpNosToday(GooseSpecies a_goose)
For goose model functionality, returns the number of geese per species yesterday. ...
Definition: elements.cpp:560
int m_gooseNosTimed[366]
The number of geese at a predefined time per day.
Definition: elements.h:434
double m_yddegs
Definition: elements.h:456
int m_rot_index
Definition: elements.h:413
virtual void ForceGrowthInitialize(void)
Definition: elements.cpp:1553
double m_veg_height
Definition: elements.h:619
#define EL_BUG_PERCENT_SB_A
Definition: elements.cpp:38
int value(void)
Definition: configurator.h:92
int m_poly
The polyref number for this polygon.
Definition: elements.h:417
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
FieldBoundary(void)
Definition: elements.cpp:2201
int m_weed_curve_num
Definition: elements.h:606
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:56
#define EL_BUG_PERCENT_G_A
Definition: elements.cpp:62
int m_owner_file
Definition: elements.h:411
#define EL_VEG_HEIGHTSCALE
Definition: elements.cpp:179
NaturalGrassWet(void)
Definition: elements.cpp:2158
ForestElement(void)
Definition: elements.cpp:2270
Coast(void)
Definition: elements.cpp:2469
void RandomVegStartValues(double *a_LAtotal, double *a_LAgreen, double *a_veg_height, double *a_weed_biomass)
Definition: elements.cpp:1463
void ForceGrowthSpringTest(void)
Definition: elements.cpp:1534
void SetCopyTreatment(int a_treatment)
Definition: elements.cpp:468
double m_veg_biomass
Definition: elements.h:613
double biomass_at_harvest
Definition: elements.h:477
int m_vege_danger_store
Definition: elements.h:396
const double c_SolarConversion[2][81]
Definition: elements.cpp:93
int SupplyFarmIntensity(int a_x, int a_y)
Definition: Landscape.cpp:619
void CalcPondPesticide()
Calculates the amount of pesticide per unit pond water.
Definition: elements.cpp:2392
#define EL_BUG_PERCENT_Edges_A
Definition: elements.cpp:68
TTypesOfLandscapeElement
void ReadBugPercentageFile(void)
Definition: elements.cpp:1147
#define EL_BUG_PERCENT_WRy_C
Definition: elements.cpp:52
virtual void DoDevelopment(void)
Definition: elements.cpp:1949
int m_crop_index
Definition: elements.h:643
CfgInt cfg_OrchardNoCutsDay("TOX_ORCHARDNOCUTS", CFG_CUSTOM,-1)
static CfgInt l_el_rv_cut_sep("ELEM_RV_CUT_SEP", CFG_PRIVATE, 49)
int m_subtype
Definition: elements.h:401
virtual bool IsMatureCereal()
Definition: elements.cpp:1223
double GetLAgreenDiff(double a_ddegs, double a_yddegs, int a_plant, int a_phase)
Definition: plants.cpp:102
static CfgFloat l_el_rv_cut_green("ELEM_RV_CUT_GREEN", CFG_PRIVATE, 1.5)
TTypesOfLandscapeElement m_type
Definition: elements.h:427
CfgInt cfg_goosecountperiod("GOOSE_GOOSECOUNTPERIOD", CFG_CUSTOM, 1)
The number of days a goose count can be used.
int GetMonth(void)
Definition: calendar.h:69
CfgFloat cfg_PondLarvalFoodR("POND_LARVALFOODFOODR", CFG_CUSTOM, 0.04)
The instanteous rate of growth for larval food (r from logistic equation)
#define EL_BUG_PERCENT_Edges_B
Definition: elements.cpp:69
Railway(void)
Definition: elements.cpp:2247
#define EL_BUG_PERCENT_D
Definition: elements.cpp:71
int GetGooseSpNosTodayTimed(GooseSpecies a_goose)
For goose model functionality, returns the number of geese per species yesterday at a predefined time...
Definition: elements.cpp:565
Wasteland(void)
Definition: elements.cpp:2166
void ResetGeese(void)
Reset geese numbers to zero in case this was not done by the population manager (the normal situation...
Definition: elements.cpp:1669
virtual bool IsMaize()
Definition: elements.cpp:1269
int m_cattle_grazing
Definition: elements.h:452
WindTurbine(void)
Definition: elements.cpp:2585
PitDisused(void)
Definition: elements.cpp:2352
CfgFloat cfg_PondLarvalFoodBiomassConst("POND_LARVALFOODBIOMASSCONST", CFG_CUSTOM, 255.0)
A constant relating the proportion of food units per m2. The value is calibrated to estimates of newt...
int m_days_since_insecticide_spray
Definition: elements.h:449
virtual void DoDevelopment(void)
Definition: elements.cpp:1962
DeciduousForest(void)
Definition: elements.cpp:2281
static CfgFloat l_el_weed_percent("ELEM_WEED_PERCENT", CFG_PRIVATE, 0.1)
Double configurator entry class.
Definition: configurator.h:100
int m_gooseSpNosTimed[366][gs_foobar]
The number of geese of each species at a predefined time per day.
Definition: elements.h:436
static CfgInt l_el_rv_cut_jun("ELEM_RV_CUT_JUN", CFG_PRIVATE, 28)
double m_area
Definition: elements.h:428
long m_management_loop_detect_count
Definition: elements.h:408
bool m_veg_patchy
Definition: elements.h:621
#define EL_VEG_START_LAIT
Definition: elements.cpp:175
CfgInt cfg_pest_productapplic_period
Definition: elements.cpp:113
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: elements.cpp:2864
static CfgInt l_el_rv_may_1st("ELEM_RV_MAY_1ST", CFG_PRIVATE, 121)
virtual bool IsGooseGrass()
Definition: elements.cpp:1311
SmallRoad(void)
Definition: elements.cpp:2537
Saltwater(void)
Definition: elements.cpp:2359
int m_curve_num
Definition: elements.h:605
int GetHour(void)
Definition: calendar.h:71
static CfgFloat l_el_plant_biomass_proport("ELEM_PLANT_BIOMASS_PROPORT", CFG_PRIVATE, 41.45)
int m_openness
The openness metric for a field (if any)
Definition: elements.h:446
void Cutting(int a_today)
Definition: elements.cpp:1932
virtual void RecalculateBugsNStuff(void)
Definition: elements.cpp:1339
#define EL_BUG_PERCENT_WW_C
Definition: elements.cpp:46
#define RV_CUT_MAY
Definition: elements.cpp:182
long m_DateCut
Definition: elements.h:720
virtual void ForceGrowthDevelopment(void)
Definition: elements.cpp:1596
void Trace(int a_value)
Definition: elements.cpp:459
int m_maxy
Definition: elements.h:404
#define EL_BUG_PERCENT_SB_B
Definition: elements.cpp:39
#define EL_BUG_PERCENT_WRy_B
Definition: elements.cpp:51
virtual void DoDevelopment()
Definition: elements.cpp:2174
TTypesOfVegetation tov_type
Definition: elements.h:476
class Landscape * g_landscape_p
Definition: Landscape.cpp:238
double m_force_LAgreen
Definition: elements.h:629
MetalledPath(void)
Definition: elements.cpp:2573
void SetHigh(bool a_high)
Definition: elements.h:219
double SupplyTemp(void)
Definition: landscape.h:1312
void CalcLarvalFood()
Calculates the amount of larval food present.
Definition: elements.cpp:2423
void Clean_CropDataStorage(int index)
Definition: elements.cpp:1751