OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
VcstTileDatabase.h
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * NAME: VcstTileDatabase
4  *
5  **************************************************************************/
6 
7 #ifndef VcstTileDatabase_h
8 #define VcstTileDatabase_h
9 
16 public:
17 
18  /*
19  * Destructor
20  *
21  * Enables safe deleting of derived class object stored in base
22  * class pointer -- otherwise memory leak.
23  */
24  virtual ~VcstTileDatabase();
25 
26  /*
27  * Returns the number of tiles in a row
28  */
29  int getNumOfTileRows() const;
30 
31  /*
32  * Returns the number of tiles in a column
33  */
34  int getNumOfTileCols() const;
35 
36  /*
37  * Returns the number of rows in a tile
38  */
39  int getNumOfRowsPerTile() const;
40 
41  /*
42  * Returns the number of columns in a tile
43  */
44  int getNumOfColsPerTile() const;
45 
46  /*
47  * Returns the total number of rows in the database (grid)
48  */
49  int getNumOfDbRows() const;
50 
51  /*
52  * Returns the total number of columns in the database (grid)
53  */
54  int getNumOfDbCols() const;
55 
56  /*
57  * Maps from database (grid) row to row offset inside tile
58  *
59  * @param aDatabaseRow Overall row in database (grid)
60  * @retval row offset inside tile from database row
61  */
62  virtual int calculateRowInTile(double aDatabaseRow) const;
63 
64  /*
65  * Maps from database (grid) column to column offset inside tile
66  *
67  * @param aDatabaseCol Overall column in database (grid)
68  * @retval column offset inside tile from database column
69  */
70  virtual int calculateColInTile(double aDatabaseCol) const;
71 
72  /*
73  * Maps from database (grid) row to tile row
74  *
75  * @param aDatabaseRow Overall row in database (grid)
76  * @retval tile row from database grid
77  */
78  virtual int calculateTileRow(double aDatabaseRow) const;
79 
80  /*
81  * Maps from database (grid) column to tile column
82  *
83  * @param aDatabaseCol Overall column in database (grid)
84  * @retval tile column from database grid
85  */
86  virtual int calculateTileCol(double aDatabaseCol) const;
87 
88  /*
89  * Maps from database (grid) row and column to tile number
90  *
91  * @param aDatabaseRow Overall row in database (grid)
92  * @param aDatabaseCol Overall column in database (grid)
93  * @retval tile number from database row and column
94  */
95  int calculateTileNum(double aDatabaseRow,
96  double aDatabaseCol) const;
97 
98  /*
99  * Maps from tile row and column to tile number
100  *
101  * @param aTileRow Tile row
102  * @param aTileCol Tile column
103  * @retval tile number from mapped row and column
104  */
105  int calculateTileNum(int aTileRow,
106  int aTileCol) const;
107 
108  /*
109  * Decompose the tile number into tile row/column.
110  * @param aTileNum (in) a tile number to decompose.
111  * @param aTileRow (out) place to put the tile row.
112  * @param aTileCol (out) place to put the tile column.
113  */
114  virtual void decomposeTileNum(int aTileNum, int& aTileRow, int& aTileCol);
115 
116 protected:
117 
118  /*
119  * Constructor is protected forcing into abstract class
120  *
121  * @param aNumOfTileRows Total number of tile rows
122  * @param aNumOfTileCols Total number of tile columns
123  * @param aNumOfRowsPerTile Total number of rows in a tile
124  * @param aNumOfColsPerTile Total number of columns in a tile
125  */
126  VcstTileDatabase(int aNumOfTileRows,
127  int aNumOfTileCols,
128  int aNumOfRowsPerTile,
129  int aNumOfColsPerTile);
130 
134  int theNumOfTileRows_;
155 
156 private:
157 
169  VcstTileDatabase& operator=(const VcstTileDatabase& rhs);
170 
171 };
172 
173 
174 //------------------------------------------------------------------------------
175 
176 inline int
178  return theNumOfTileRows_;
179 }
180 
181 //------------------------------------------------------------------------------
182 
183 inline int
185  return theNumOfTileCols_;
186 }
187 
188 //------------------------------------------------------------------------------
189 
190 inline int
192  return theNumOfRowsPerTile_;
193 }
194 
195 //------------------------------------------------------------------------------
196 
197 inline int
199  return theNumOfColsPerTile_;
200 }
201 
202 //------------------------------------------------------------------------------
203 
204 inline int
206  return theNumOfDbRows_;
207 }
208 
209 //------------------------------------------------------------------------------
210 
211 inline int
213  return theNumOfDbCols_;
214 }
215 
216 //------------------------------------------------------------------------------
217 
218 inline int
220  double aDatabaseCol) const {
221  return calculateTileNum(calculateTileRow(aDatabaseRow),
222  calculateTileCol(aDatabaseCol));
223 }
224 
225 //------------------------------------------------------------------------------
226 
227 inline int
229  int aTileCol) const {
230  return (aTileRow * getNumOfTileCols() + aTileCol);
231 }
232 
233 #endif // VcstTileDatabase_h
int calculateTileNum(double aDatabaseRow, double aDatabaseCol) const
virtual int calculateTileCol(double aDatabaseCol) const
int getNumOfDbCols() const
virtual ~VcstTileDatabase()
VcstTileDatabase(int aNumOfTileRows, int aNumOfTileCols, int aNumOfRowsPerTile, int aNumOfColsPerTile)
int getNumOfTileCols() const
virtual void decomposeTileNum(int aTileNum, int &aTileRow, int &aTileCol)
int getNumOfTileRows() const
int getNumOfDbRows() const
virtual int calculateTileRow(double aDatabaseRow) const
int getNumOfColsPerTile() const
int getNumOfRowsPerTile() const
virtual int calculateRowInTile(double aDatabaseRow) const
virtual int calculateColInTile(double aDatabaseCol) const