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

Movement maps are used for rapid computing of animal movement. More...

#include <MovementMap.h>

Public Member Functions

int GetMapValue (unsigned x, unsigned y)
 
void SetMapValue (unsigned x, unsigned y, unsigned value)
 
void SetMapValue0 (unsigned x, unsigned y)
 
void SetMapValue1 (unsigned x, unsigned y)
 
void SetMapValue2 (unsigned x, unsigned y)
 
void SetMapValue3 (unsigned x, unsigned y)
 
 MovementMap (Landscape *L, int spref)
 
 ~MovementMap ()
 

Public Attributes

uint32m_TheMap
 
uint32 maxx
 
uint32 maxy
 

Protected Member Functions

void Init (int spref)
 

Protected Attributes

Landscapem_ALandscape
 

Detailed Description

Movement maps are used for rapid computing of animal movement.

Constructor & Destructor Documentation

◆ MovementMap()

MovementMap::MovementMap ( Landscape L,
int  spref 
)
51 {
52  m_ALandscape = L;
53  // must make sure that we have whole words
56  m_TheMap = new uint32[ maxx*maxy ];
57 
58  Init(spref);
59 }

References Init(), m_ALandscape, m_TheMap, maxx, maxy, Landscape::SupplySimAreaHeight(), and Landscape::SupplySimAreaWidth().

◆ ~MovementMap()

MovementMap::~MovementMap ( )
63 {
64  delete m_TheMap;
65 }

References m_TheMap.

Member Function Documentation

◆ GetMapValue()

int MovementMap::GetMapValue ( unsigned  x,
unsigned  y 
)
410 {
411  uint32 theBit=x & 15;
412  // Multiply by two
413  theBit=theBit<<1;
414  // divide by 16
415  uint32 index= (x>>4)+(maxx*y);
416  return ((m_TheMap[index] >> theBit) & 0x03); // 0-3
417 }

References m_TheMap, and maxx.

◆ Init()

void MovementMap::Init ( int  spref)
protected
70 {
71  char error_num[20];
72  for (int y=0; y<m_ALandscape->SupplySimAreaHeight(); y++)
73  {
74  for (int x=0; x<m_ALandscape->SupplySimAreaWidth(); x++)
75  {
76  TTypesOfLandscapeElement tole;
78  uint32 colour=0;
79  if (spref==0)
80  {
81  // Beetle
82  switch (tole)
83  {
84 
85  case tole_Hedges: // 130
86  case tole_RoadsideVerge: // 13
87  case tole_FieldBoundary: // 160
88  case tole_HedgeBank:
89  case tole_BeetleBank:
90  case tole_NaturalGrassWet:
91  case tole_RoadsideSlope:
92  case tole_WaterBufferZone:
93  colour=1;
94  break;
95  case tole_Marsh: // 95
96  case tole_Scrub: // 70
97  case tole_Railway: // 118
98  case tole_PermanentSetaside: // 33
99  case tole_RiversidePlants: // 98
100  case tole_PitDisused: // 75
101  case tole_Garden: //11
102  case tole_Track: // 123
103  case tole_SmallRoad: // 122
104  case tole_LargeRoad: // 121
105  case tole_MetalledPath:
106  case tole_Carpark:
107  case tole_Churchyard:
108  case tole_Saltmarsh:
109  case tole_PlantNursery:
110  case tole_Vildtager:
111  case tole_HeritageSite: colour = 2;
112  case tole_Copse:
113  case tole_WoodyEnergyCrop:
114  case tole_WoodlandMargin:
115  case tole_IndividualTree:
116  case tole_RiversideTrees: // 97
117  case tole_DeciduousForest: // 40
118  case tole_MixedForest: // 60
119  case tole_ConiferousForest: // 50
120  case tole_YoungForest:
121  case tole_StoneWall: // 15
122  case tole_ActivePit: // 115
123  case tole_Fence: // 225
124  break;
125  case tole_Field: // 20 & 30
126  case tole_UnsprayedFieldMargin :
127  case tole_PermPasture: // 35
128  case tole_PermPastureLowYield: // 35
129  case tole_PermPastureTussocky: // 26
130  case tole_PermPastureTussockyWet:
131  case tole_Heath:
132  case tole_NaturalGrassDry: // 110
133  case tole_AmenityGrass:
134  case tole_Parkland:
135  case tole_Orchard:
136  case tole_OrchardBand:
137  case tole_MownGrass:
138  case tole_Wasteland: // 209
139  case tole_UnknownGrass:
140  colour=0;
141  break;
142  case tole_Building: // 5
143  case tole_Freshwater: // 90
144  case tole_FishFarm: // 220
145  case tole_Pond:
146  case tole_River: // 96
147  case tole_Saltwater: // 80
148  case tole_Coast: // 100
149  case tole_BareRock: // 59
150  case tole_UrbanNoVeg:
151  case tole_UrbanVeg:
152  case tole_UrbanPark:
153  case tole_BuiltUpWithParkland:
154  case tole_SandDune:
155  case tole_Stream:
156  case tole_Pylon:
157  case tole_WindTurbine:
158  case tole_DrainageDitch:
159  case tole_Canal:
160  colour = 3;
161  break;
162  case tole_Foobar: // 999 !! type unknown - should not happen
163  default:
164  sprintf( error_num, "%d", tole );
165  g_msg->Warn( WARN_FILE,
166  "MovementMap::Init(): Unknown landscape element type:",
167  error_num );
168  exit( 1 );
169  }
170  }
171  else if (spref==1) { // Partridge
172  switch (tole)
173  {
174  case tole_Hedges: // 130
175  case tole_PermanentSetaside: // 33
176  case tole_RoadsideVerge: // 13
177  case tole_FieldBoundary: // 160
178  case tole_HedgeBank:
179  case tole_BeetleBank:
180  case tole_UnsprayedFieldMargin: // 31
181  case tole_Vildtager:
182  case tole_WaterBufferZone:
183  colour=3;
184  break;
185  case tole_Railway: // 118
186  case tole_Scrub: // 70
187  case tole_Field: // 20 & 30
188  case tole_PermPasture: // 35
189  case tole_NaturalGrassDry: // 110
190  case tole_RiversidePlants: // 98
191  case tole_RoadsideSlope:
192  case tole_RiversideTrees: // 97
193  case tole_YoungForest: //55
194  case tole_Wasteland:
195  case tole_UnknownGrass:
196  colour=2;
197  break;
198  case tole_PitDisused: // 75
199  case tole_NaturalGrassWet:
200  case tole_Marsh: // 95
201  case tole_Garden: //11
202  case tole_Track: // 123
203  case tole_SmallRoad: // 122
204  case tole_LargeRoad: // 121
205  colour=1;
206  break;
207  case tole_IndividualTree:
208  case tole_PlantNursery:
209  case tole_WindTurbine:
210  case tole_WoodyEnergyCrop:
211  case tole_WoodlandMargin:
212  case tole_Pylon:
213  case tole_DeciduousForest: // 40
214  case tole_MixedForest: // 60
215  case tole_ConiferousForest: // 50
216  case tole_StoneWall: // 15
217  case tole_Fence: // 225
218  case tole_Building: // 5
219  case tole_ActivePit: // 115
220  case tole_Pond:
221  case tole_Freshwater: // 90
222  case tole_FishFarm:
223  case tole_River: // 96
224  case tole_Saltwater: // 80
225  case tole_Coast: // 100
226  case tole_BareRock: // 59
227  case tole_AmenityGrass:
228  case tole_Parkland:
229  case tole_UrbanNoVeg:
230  case tole_UrbanPark:
231  case tole_BuiltUpWithParkland:
232  case tole_SandDune:
233  case tole_Copse:
234  case tole_MetalledPath:
235  case tole_Carpark:
236  case tole_Churchyard:
237  case tole_Saltmarsh:
238  case tole_Stream:
239  case tole_HeritageSite:
240  colour=0;
241  break;
242  case tole_Foobar: // 999 !! type unknown - should not happen
243  default:
244  sprintf( error_num, "%d", tole );
245  g_msg->Warn( WARN_FILE,
246  "MovementMap::Init(): Unknown landscape element type:",
247  error_num );
248  exit( 1 );
249  }
250  } // End partridge
251  else if (spref==2)
252  { // Spider
253  switch ( tole )
254  {
255  case tole_IndividualTree:
256  case tole_WindTurbine:
257  case tole_WoodyEnergyCrop:
258  case tole_WoodlandMargin:
259  case tole_Pylon:
260  case tole_NaturalGrassWet:
261  case tole_MetalledPath:
262  case tole_Carpark:
263  case tole_Churchyard:
264  case tole_Saltmarsh:
265  case tole_HeritageSite:
266  case tole_Hedges:
267  case tole_HedgeBank:
268  case tole_BeetleBank:
269  case tole_Marsh:
270  case tole_PermanentSetaside:
271  case tole_NaturalGrassDry:
272  case tole_RiversidePlants:
273  case tole_RiversideTrees:
274  case tole_DeciduousForest:
275  case tole_MixedForest:
276  case tole_ConiferousForest:
277  case tole_YoungForest:
278  case tole_StoneWall:
279  case tole_Fence:
280  case tole_Building:
281  case tole_ActivePit:
282  case tole_PitDisused:
283  case tole_Scrub:
284  case tole_Track:
285  case tole_SmallRoad:
286  case tole_LargeRoad:
287  case tole_BareRock:
288  case tole_UrbanNoVeg:
289  case tole_SandDune:
290  case tole_Copse:
291  case tole_MownGrass:
292  colour = 2;
293  break;
294  case tole_PlantNursery:
295  case tole_Vildtager:
296  case tole_RoadsideSlope:
297  case tole_PermPasture: //moved from case 2 to case 3
298  case tole_PermPastureLowYield:
299  case tole_PermPastureTussocky: //moved from case 2 to case 3
300  case tole_RoadsideVerge:
301  case tole_Railway:
302  case tole_FieldBoundary:
303  case tole_Garden:
304  case tole_Coast:
305  case tole_Heath:
306  case tole_AmenityGrass:
307  case tole_Parkland:
308  case tole_BuiltUpWithParkland:
309  case tole_UrbanPark:
310  case tole_Wasteland:
311  case tole_WaterBufferZone:
312  colour = 3;
313  break;
314  case tole_Pond:
315  case tole_Freshwater:
316  case tole_FishFarm:
317  case tole_River:
318  case tole_Saltwater:
319  case tole_Stream:
320  colour=0;
321  break;
322  case tole_Field: // Special case
323  case tole_UnsprayedFieldMargin: // Special case
324  colour=1;
325  break;
326  default:
327  sprintf( error_num, "%d", tole );
328  g_msg->Warn( WARN_FILE,
329  "MovementMap::Init(): Unknown landscape element type:",
330  error_num );
331  exit( 1 );
332  }// End spider
333  }
334  SetMapValue(x,y,colour);
335  }
336  }
337 }

References m_ALandscape, SetMapValue(), Landscape::SupplyElementType(), Landscape::SupplySimAreaHeight(), and Landscape::SupplySimAreaWidth().

Referenced by MovementMap().

◆ SetMapValue()

void MovementMap::SetMapValue ( unsigned  x,
unsigned  y,
unsigned  value 
)
342 {
343 
344  uint32 theBit= x & 15; // Identify the bit within 16 possibilities
345 
346  // Multiply by two
347  theBit=theBit<<1; // Double it because we use two bits per location
348 
349  // divide by 16
350  // Calculate index:
351  uint32 index= (x>>4)+(y*maxx); // maxx is the number of uints per row + x/16 because there are 16 locations per uint
352 
353  value &= 0x03;
354  uint32 NewVal = m_TheMap[index] & ~( 0x03 << theBit ); // Make a hole two bits wide at the right location
355  m_TheMap[index] = NewVal | (value << theBit); // Fill the hole
356 
357 }

References m_TheMap, and maxx.

Referenced by Init().

◆ SetMapValue0()

void MovementMap::SetMapValue0 ( unsigned  x,
unsigned  y 
)
362 {
363  uint32 theBit=x & 15;
364  theBit=theBit<<1; // Multiply by two
365  // divide by 16
366  uint32 index= (x>>4)+(y*maxx);
367  m_TheMap[index] &= ~(0x03<< theBit);
368 }

References m_TheMap, and maxx.

◆ SetMapValue1()

void MovementMap::SetMapValue1 ( unsigned  x,
unsigned  y 
)
373 {
374  uint32 theBit=x & 15;
375  theBit=theBit<<1; // Multiply by two
376  // divide by 16
377  uint32 index= (x>>4)+(maxx*y);
378  m_TheMap[index] &= ~(0x03 << theBit);
379  m_TheMap[index] |= (0x01 << theBit);
380 }

References m_TheMap, and maxx.

◆ SetMapValue2()

void MovementMap::SetMapValue2 ( unsigned  x,
unsigned  y 
)
385 {
386  uint32 theBit=x & 15;
387  // Multiply by two
388  theBit=theBit<<1;
389  // divide by 16
390  uint32 index= (x>>4)+(maxx*y);
391  m_TheMap[index] &= ~(0x03 << theBit);
392  m_TheMap[index] |= (0x02 << theBit);
393 }

References m_TheMap, and maxx.

◆ SetMapValue3()

void MovementMap::SetMapValue3 ( unsigned  x,
unsigned  y 
)
398 {
399  uint32 theBit=x & 15;
400  // Multiply by two
401  theBit=theBit<<1;
402  // divide by 16
403  uint32 index= (x>>4)+(maxx*y);
404  m_TheMap[index] |= (0x03 << theBit);
405 }

References m_TheMap, and maxx.

Member Data Documentation

◆ m_ALandscape

Landscape* MovementMap::m_ALandscape
protected

Referenced by Init(), and MovementMap().

◆ m_TheMap

◆ maxx

◆ maxy

uint32 MovementMap::maxy

Referenced by MovementMap().


The documentation for this class was generated from the following files:
Landscape::SupplyElementType
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
uint32
unsigned int uint32
Definition: ALMaSS_Setup.h:34
MovementMap::m_TheMap
uint32 * m_TheMap
Definition: MovementMap.h:53
MovementMap::SetMapValue
void SetMapValue(unsigned x, unsigned y, unsigned value)
Definition: MovementMap.cpp:341
Landscape::SupplySimAreaHeight
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
Landscape::SupplySimAreaWidth
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
MovementMap::maxy
uint32 maxy
Definition: MovementMap.h:55
MovementMap::Init
void Init(int spref)
Definition: MovementMap.cpp:69
MovementMap::m_ALandscape
Landscape * m_ALandscape
Definition: MovementMap.h:65
MovementMap::maxx
uint32 maxx
Definition: MovementMap.h:54