GDAL
gdal_rat.h
1 /******************************************************************************
2  * $Id: gdal_rat.h 29243 2015-05-24 15:53:26Z 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 void *SerializeJSON() const;
258  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
259 
260  virtual CPLErr InitializeFromColorTable( const GDALColorTable * );
261  virtual GDALColorTable *TranslateToColorTable( int nEntryCount = -1 );
262 
263  virtual void DumpReadable( FILE * = NULL );
264 };
265 
266 /************************************************************************/
267 /* GDALRasterAttributeField */
268 /* */
269 /* (private) */
270 /************************************************************************/
271 
273 {
274 public:
275  CPLString sName;
276 
277  GDALRATFieldType eType;
278 
279  GDALRATFieldUsage eUsage;
280 
281  std::vector<GInt32> anValues;
282  std::vector<double> adfValues;
283  std::vector<CPLString> aosValues;
284 };
285 
286 /************************************************************************/
287 /* GDALDefaultRasterAttributeTable */
288 /************************************************************************/
289 
291 
293 {
294 private:
295  std::vector<GDALRasterAttributeField> aoFields;
296 
297  int bLinearBinning;
298  double dfRow0Min;
299  double dfBinSize;
300 
301  void AnalyseColumns();
302  int bColumnsAnalysed;
303  int nMinCol;
304  int nMaxCol;
305 
306  int nRowCount;
307 
308  CPLString osWorkingResult;
309 
310 public:
314 
316 
317  virtual int GetColumnCount() const;
318 
319  virtual const char *GetNameOfCol( int ) const;
320  virtual GDALRATFieldUsage GetUsageOfCol( int ) const;
321  virtual GDALRATFieldType GetTypeOfCol( int ) const;
322 
323  virtual int GetColOfUsage( GDALRATFieldUsage ) const;
324 
325  virtual int GetRowCount() const;
326 
327  virtual const char *GetValueAsString( int iRow, int iField ) const;
328  virtual int GetValueAsInt( int iRow, int iField ) const;
329  virtual double GetValueAsDouble( int iRow, int iField ) const;
330 
331  virtual void SetValue( int iRow, int iField, const char *pszValue );
332  virtual void SetValue( int iRow, int iField, double dfValue);
333  virtual void SetValue( int iRow, int iField, int nValue );
334 
335  virtual int ChangesAreWrittenToFile();
336  virtual void SetRowCount( int iCount );
337 
338  virtual int GetRowOfValue( double dfValue ) const;
339  virtual int GetRowOfValue( int nValue ) const;
340 
341  virtual CPLErr CreateColumn( const char *pszFieldName,
342  GDALRATFieldType eFieldType,
343  GDALRATFieldUsage eFieldUsage );
344  virtual CPLErr SetLinearBinning( double dfRow0Min, double dfBinSize );
345  virtual int GetLinearBinning( double *pdfRow0Min, double *pdfBinSize ) const;
346 
347 };
348 
349 #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
virtual int GetValueAsInt(int iRow, int iField) const =0
Fetch field value as a integer.
Raster Attribute Table container.
Definition: gdal_rat.h:292
Document node structure.
Definition: cpl_minixml.h:65
Definitions for CPL mini XML Parser/Serializer.
Definition: gdal_rat.h:272
GDALRATFieldType
Field type of raster attribute table.
Definition: gdal.h:903
virtual void SetValue(int iRow, int iField, const char *pszValue)=0
Set field value from string.
virtual void SetRowCount(int iCount)
Set row count.
Definition: gdal_rat.cpp:282
GDALRWFlag
Definition: gdal.h:101
virtual const char * GetNameOfCol(int) const =0
Fetch name of indicated column.
Convenient string class based on std::string.
Definition: cpl_string.h:236
virtual GDALDefaultRasterAttributeTable * Clone() const =0
Copy Raster Attribute Table.
virtual int GetRowCount() const =0
Fetch row count.
virtual int GetLinearBinning(double *pdfRow0Min, double *pdfBinSize) const
Get linear binning information.
Definition: gdal_rat.cpp:470
virtual int ChangesAreWrittenToFile()=0
Determine whether changes made to this RAT are reflected directly in the dataset. ...
virtual CPLErr SetLinearBinning(double dfRow0Min, double dfBinSize)
Set linear binning information.
Definition: gdal_rat.cpp:427
virtual GDALRATFieldUsage GetUsageOfCol(int) const =0
Fetch column usage value.
virtual double GetValueAsDouble(int iRow, int iField) const =0
Fetch field value as a double.
virtual CPLErr CreateColumn(const char *pszFieldName, GDALRATFieldType eFieldType, GDALRATFieldUsage eFieldUsage)
Create new column.
Definition: gdal_rat.cpp:379
GDALRATFieldUsage
Field usage of raster attribute table.
Definition: gdal.h:910
virtual int GetColumnCount() const =0
Fetch table column count.
virtual const char * GetValueAsString(int iRow, int iField) const =0
Fetch field value as a string.
Definition: gdal_priv.h:582
virtual GDALRATFieldType GetTypeOfCol(int) const =0
Fetch column type.
virtual int GetColOfUsage(GDALRATFieldUsage) const =0
Fetch column index for given usage.

Generated for GDAL by doxygen 1.8.8.