GDAL
gdal_rat.h
1 /******************************************************************************
2  * $Id: gdal_rat.h 26117 2013-06-29 20:22:34Z rouault $
3  *
4  * Project: GDAL Core
5  * Purpose: GDALRasterAttributeTable class declarations.
6  * Author: Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #ifndef GDAL_RAT_H_INCLUDED
31 #define GDAL_RAT_H_INCLUDED
32 
33 #include "cpl_minixml.h"
34 
35 // Clone and Serialize are allowed to fail if GetRowCount()*GetColCount() greater
36 // than this number
37 #define RAT_MAX_ELEM_FOR_CLONE 1000000
38 
39 /************************************************************************/
40 /* GDALRasterAttributeTable */
41 /************************************************************************/
42 
45 
47 {
48 public:
49  virtual ~GDALRasterAttributeTable();
62  virtual GDALDefaultRasterAttributeTable *Clone() const = 0;
63 
71  virtual int GetColumnCount() const = 0;
72 
82  virtual const char *GetNameOfCol( int ) const = 0;
83 
93  virtual GDALRATFieldUsage GetUsageOfCol( int ) const = 0;
94 
104  virtual GDALRATFieldType GetTypeOfCol( int ) const = 0;
105 
118  virtual int GetColOfUsage( GDALRATFieldUsage ) const = 0;
119 
127  virtual int GetRowCount() const = 0;
128 
146  virtual const char *GetValueAsString( int iRow, int iField ) const = 0;
147 
162  virtual int GetValueAsInt( int iRow, int iField ) const = 0;
163 
178  virtual double GetValueAsDouble( int iRow, int iField ) const = 0;
179 
193  virtual void SetValue( int iRow, int iField, const char *pszValue ) = 0;
194 
208  virtual void SetValue( int iRow, int iField, int nValue ) = 0;
209 
223  virtual void SetValue( int iRow, int iField, double dfValue) = 0;
224 
234  virtual int ChangesAreWrittenToFile() = 0;
235 
236  virtual CPLErr ValuesIO(GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, double *pdfData);
237  virtual CPLErr ValuesIO(GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, int *pnData);
238  virtual CPLErr ValuesIO(GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, char **papszStrList);
239 
240  virtual void SetRowCount( int iCount );
241  virtual int GetRowOfValue( double dfValue ) const;
242  virtual int GetRowOfValue( int nValue ) const;
243 
244  virtual CPLErr CreateColumn( const char *pszFieldName,
245  GDALRATFieldType eFieldType,
246  GDALRATFieldUsage eFieldUsage );
247  virtual CPLErr SetLinearBinning( double dfRow0Min, double dfBinSize );
248  virtual int GetLinearBinning( double *pdfRow0Min, double *pdfBinSize ) const;
249 
256  virtual CPLXMLNode *Serialize() const;
257  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
258 
259  virtual CPLErr InitializeFromColorTable( const GDALColorTable * );
260  virtual GDALColorTable *TranslateToColorTable( int nEntryCount = -1 );
261 
262  virtual void DumpReadable( FILE * = NULL );
263 };
264 
265 /************************************************************************/
266 /* GDALRasterAttributeField */
267 /* */
268 /* (private) */
269 /************************************************************************/
270 
272 {
273 public:
274  CPLString sName;
275 
276  GDALRATFieldType eType;
277 
278  GDALRATFieldUsage eUsage;
279 
280  std::vector<GInt32> anValues;
281  std::vector<double> adfValues;
282  std::vector<CPLString> aosValues;
283 };
284 
285 /************************************************************************/
286 /* GDALDefaultRasterAttributeTable */
287 /************************************************************************/
288 
290 
292 {
293 private:
294  std::vector<GDALRasterAttributeField> aoFields;
295 
296  int bLinearBinning;
297  double dfRow0Min;
298  double dfBinSize;
299 
300  void AnalyseColumns();
301  int bColumnsAnalysed;
302  int nMinCol;
303  int nMaxCol;
304 
305  int nRowCount;
306 
307  CPLString osWorkingResult;
308 
309 public:
313 
314  GDALDefaultRasterAttributeTable *Clone() const;
315 
316  virtual int GetColumnCount() const;
317 
318  virtual const char *GetNameOfCol( int ) const;
319  virtual GDALRATFieldUsage GetUsageOfCol( int ) const;
320  virtual GDALRATFieldType GetTypeOfCol( int ) const;
321 
322  virtual int GetColOfUsage( GDALRATFieldUsage ) const;
323 
324  virtual int GetRowCount() const;
325 
326  virtual const char *GetValueAsString( int iRow, int iField ) const;
327  virtual int GetValueAsInt( int iRow, int iField ) const;
328  virtual double GetValueAsDouble( int iRow, int iField ) const;
329 
330  virtual void SetValue( int iRow, int iField, const char *pszValue );
331  virtual void SetValue( int iRow, int iField, double dfValue);
332  virtual void SetValue( int iRow, int iField, int nValue );
333 
334  virtual int ChangesAreWrittenToFile();
335  virtual void SetRowCount( int iCount );
336 
337  virtual int GetRowOfValue( double dfValue ) const;
338  virtual int GetRowOfValue( int nValue ) const;
339 
340  virtual CPLErr CreateColumn( const char *pszFieldName,
341  GDALRATFieldType eFieldType,
342  GDALRATFieldUsage eFieldUsage );
343  virtual CPLErr SetLinearBinning( double dfRow0Min, double dfBinSize );
344  virtual int GetLinearBinning( double *pdfRow0Min, double *pdfBinSize ) const;
345 
346 };
347 
348 #endif /* ndef GDAL_RAT_H_INCLUDED */
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:46
Raster Attribute Table container.
Definition: gdal_rat.h:291
Document node structure.
Definition: cpl_minixml.h:65
Definitions for CPL mini XML Parser/Serializer.
Definition: gdal_rat.h:271
GDALRATFieldType
Field type of raster attribute table.
Definition: gdal.h:672
GDALRWFlag
Definition: gdal.h:99
Convenient string class based on std::string.
Definition: cpl_string.h:226
GDALRATFieldUsage
Field usage of raster attribute table.
Definition: gdal.h:679
Definition: gdal_priv.h:447

Generated for GDAL by doxygen 1.8.11.