ALMaSS Vole ODDox  1.1
The vole model description following ODdox protocol
TrapLineMap Class Reference

A class for simulation virtual traplines. More...

#include <VolePopulationManager.h>

Public Member Functions

 TrapLineMap (unsigned int a_width, unsigned int a_height, unsigned int a_resolution, const char *a_file)
 TrapLineMap constructor. More...
 
 ~TrapLineMap ()
 TrapLineMap destructor. More...
 
bool IsTrap (unsigned a_x, unsigned a_y)
 Is there a trap at this x,y? More...
 
void Output (InTrapPosition a_tp, int a_day, int a_sex, bool a_terr, int a_age, int a_bx, int a_by, int a_ID)
 

Protected Member Functions

void Init (const char *a_inifile)
 Reads in the trap coords, creates the map and sets up the output files. More...
 

Protected Attributes

unsigned m_noTraps
 The total number of traps. More...
 
vector< APoint > m_TrapCoords
 List of trap co-ordinates. More...
 
FILE * m_ofile
 

Detailed Description

A class for simulation virtual traplines.

Definition at line 94 of file VolePopulationManager.h.

Constructor & Destructor Documentation

◆ TrapLineMap()

TrapLineMap::TrapLineMap ( unsigned int  a_width,
unsigned int  a_height,
unsigned int  a_resolution,
const char *  a_file 
)

TrapLineMap constructor.

Definition at line 3945 of file VolePopulationManager.cpp.

3945  : BinaryMapBase(a_width, a_height, a_resolution, 2 )
3946 {
3947  Init(a_file);
3948 }

References Init().

◆ ~TrapLineMap()

TrapLineMap::~TrapLineMap ( )

TrapLineMap destructor.

Definition at line 3950 of file VolePopulationManager.cpp.

3951 {
3952  fclose(m_ofile);
3953 }

References m_ofile.

Member Function Documentation

◆ Init()

void TrapLineMap::Init ( const char *  a_inifile)
protected

Reads in the trap coords, creates the map and sets up the output files.

Clears the map then reads the list of co-ordinates from the text file, saves these in m_TrapList. At the same time this creates the trap map by putting 1s at each co-ordinate.

Definition at line 3959 of file VolePopulationManager.cpp.

3960 {
3961  ClearMap();
3962  FILE * inpfile=fopen(a_inifile, "r" );
3963  if (!inpfile) {
3964  g_msg->Warn( WARN_FILE, " TrapLineMap::Init Unable to open file ", a_inifile );
3965  exit( 1 );
3966  }
3967  APoint pt;
3968  unsigned input, x, y;
3969  fscanf( inpfile, "%d\n", & input );
3970  m_noTraps = input;
3971  for (unsigned i=0; i< m_noTraps; i++)
3972  {
3973  fscanf( inpfile, "%d\t%d\n", &x, &y );
3974  pt.m_x = x;
3975  pt.m_y = y;
3976  m_TrapCoords.push_back(pt);
3977  SetValue( x, y, 1 );
3978  }
3979  fclose(inpfile);
3980  // Open the output file
3981  m_ofile = fopen("VoleTrapCounts.txt","w");
3982  if (!m_ofile) {
3983  g_msg->Warn( WARN_FILE, " TrapLineMap::Init Unable to open output file ", "VoleTrapCounts.txt" );
3984  exit( 1 );
3985  }
3986  fprintf(m_ofile, "Day\tx\ty\tElement\tVegType\tSex\tTerritorial\tAge\tBornX\tBornY\tID no\n");
3987 }

References m_noTraps, m_ofile, and m_TrapCoords.

Referenced by TrapLineMap().

◆ IsTrap()

bool TrapLineMap::IsTrap ( unsigned  a_x,
unsigned  a_y 
)
inline

Is there a trap at this x,y?

Definition at line 102 of file VolePopulationManager.h.

102  {
103  if (GetValue( a_x, a_y ) == 1) return true;
104  return false;
105  };

Referenced by Vole_Population_Manager::IsTrap().

◆ Output()

void TrapLineMap::Output ( InTrapPosition  a_tp,
int  a_day,
int  a_sex,
bool  a_terr,
int  a_age,
int  a_bx,
int  a_by,
int  a_ID 
)

Definition at line 3989 of file VolePopulationManager.cpp.

3990 {
3991  char terr;
3992  if (a_terr) terr='Y'; else terr = 'N';
3993  fprintf(m_ofile, "%d\t%d\t%d\t%d\t%d\t%d\t%c\t%d\t%d\t%d\t%d\n", a_day, a_tp.m_x, a_tp.m_y, a_tp.m_EleType, a_tp.m_VegType, a_sex, terr, a_age, a_bx, a_by, a_ID);
3994  fflush(m_ofile);
3995 }

References AnimalPosition::m_EleType, m_ofile, AnimalPosition::m_VegType, AnimalPosition::m_x, and AnimalPosition::m_y.

Referenced by Vole_Population_Manager::DoFirst().

Member Data Documentation

◆ m_noTraps

unsigned TrapLineMap::m_noTraps
protected

The total number of traps.

Definition at line 111 of file VolePopulationManager.h.

Referenced by Init().

◆ m_ofile

FILE* TrapLineMap::m_ofile
protected

Definition at line 114 of file VolePopulationManager.h.

Referenced by Init(), Output(), and ~TrapLineMap().

◆ m_TrapCoords

vector< APoint > TrapLineMap::m_TrapCoords
protected

List of trap co-ordinates.

Definition at line 113 of file VolePopulationManager.h.

Referenced by Init().


The documentation for this class was generated from the following files:
TrapLineMap::m_TrapCoords
vector< APoint > m_TrapCoords
List of trap co-ordinates.
Definition: VolePopulationManager.h:113
TrapLineMap::Init
void Init(const char *a_inifile)
Reads in the trap coords, creates the map and sets up the output files.
Definition: VolePopulationManager.cpp:3959
AnimalPosition::m_x
unsigned m_x
Definition: PopulationManager.h:172
TrapLineMap::m_noTraps
unsigned m_noTraps
The total number of traps.
Definition: VolePopulationManager.h:111
BinaryMapBase
AnimalPosition::m_EleType
TTypesOfLandscapeElement m_EleType
Definition: PopulationManager.h:174
AnimalPosition::m_y
unsigned m_y
Definition: PopulationManager.h:173
TrapLineMap::m_ofile
FILE * m_ofile
Definition: VolePopulationManager.h:114
AnimalPosition::m_VegType
TTypesOfVegetation m_VegType
Definition: PopulationManager.h:175