GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

gdal_rat.h
1 /******************************************************************************
2 * $Id: gdal_rat.h 33773 2016-03-23 18:39:47Z goatbar $
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()
36 // greater than this number
37 #define RAT_MAX_ELEM_FOR_CLONE 1000000
38
39 /************************************************************************/
40 /* GDALRasterAttributeTable */
41 /************************************************************************/
42
44 class GDALDefaultRasterAttributeTable;
45
46 class CPL_DLL GDALRasterAttributeTable
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,
194 const char *pszValue ) = 0;
195
209 virtual void SetValue( int iRow, int iField, int nValue ) = 0;
210
224 virtual void SetValue( int iRow, int iField, double dfValue) = 0;
225
238 virtual int ChangesAreWrittenToFile() = 0;
239
240 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField,
241 int iStartRow, int iLength,
242 double *pdfData);
243 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField,
244 int iStartRow, int iLength, int *pnData);
245 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField,
246 int iStartRow, int iLength,
247 char **papszStrList);
248
249 virtual void SetRowCount( int iCount );
250 virtual int GetRowOfValue( double dfValue ) const;
251 virtual int GetRowOfValue( int nValue ) const;
252
253 virtual CPLErr CreateColumn( const char *pszFieldName,
254 GDALRATFieldType eFieldType,
255 GDALRATFieldUsage eFieldUsage );
256 virtual CPLErr SetLinearBinning( double dfRow0Min,
257 double dfBinSize );
258 virtual int GetLinearBinning( double *pdfRow0Min,
259 double *pdfBinSize ) const;
260
267 virtual CPLXMLNode *Serialize() const;
268 virtual void *SerializeJSON() const;
269 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
270
271 virtual CPLErr InitializeFromColorTable( const GDALColorTable * );
272 virtual GDALColorTable *TranslateToColorTable( int nEntryCount = -1 );
273
274 virtual void DumpReadable( FILE * = NULL );
275 };
276
277 /************************************************************************/
278 /* GDALRasterAttributeField */
279 /* */
280 /* (private) */
281 /************************************************************************/
282
283 class GDALRasterAttributeField
284 {
285 public:
286 CPLString sName;
287
288 GDALRATFieldType eType;
289
290 GDALRATFieldUsage eUsage;
291
292 std::vector<GInt32> anValues;
293 std::vector<double> adfValues;
294 std::vector<CPLString> aosValues;
295 };
296
297 /************************************************************************/
298 /* GDALDefaultRasterAttributeTable */
299 /************************************************************************/
300
302
303 class CPL_DLL GDALDefaultRasterAttributeTable : public GDALRasterAttributeTable
304 {
305 private:
306 std::vector<GDALRasterAttributeField> aoFields;
307
308 int bLinearBinning; // TODO(schwehr): Can this be a bool?
309 double dfRow0Min;
310 double dfBinSize;
311
312 void AnalyseColumns();
313 int bColumnsAnalysed; // TODO(schwehr): Can this be a bool?
314 int nMinCol;
315 int nMaxCol;
316
317 int nRowCount;
318
319 CPLString osWorkingResult;
320
321 public:
322 GDALDefaultRasterAttributeTable();
323 GDALDefaultRasterAttributeTable( const GDALDefaultRasterAttributeTable& );
324 ~GDALDefaultRasterAttributeTable();
325
326 GDALDefaultRasterAttributeTable *Clone() const;
327
328 virtual int GetColumnCount() const;
329
330 virtual const char *GetNameOfCol( int ) const;
331 virtual GDALRATFieldUsage GetUsageOfCol( int ) const;
332 virtual GDALRATFieldType GetTypeOfCol( int ) const;
333
334 virtual int GetColOfUsage( GDALRATFieldUsage ) const;
335
336 virtual int GetRowCount() const;
337
338 virtual const char *GetValueAsString( int iRow, int iField ) const;
339 virtual int GetValueAsInt( int iRow, int iField ) const;
340 virtual double GetValueAsDouble( int iRow, int iField ) const;
341
342 virtual void SetValue( int iRow, int iField,
343 const char *pszValue );
344 virtual void SetValue( int iRow, int iField, double dfValue);
345 virtual void SetValue( int iRow, int iField, int nValue );
346
347 virtual int ChangesAreWrittenToFile();
348 virtual void SetRowCount( int iCount );
349
350 virtual int GetRowOfValue( double dfValue ) const;
351 virtual int GetRowOfValue( int nValue ) const;
352
353 virtual CPLErr CreateColumn( const char *pszFieldName,
354 GDALRATFieldType eFieldType,
355 GDALRATFieldUsage eFieldUsage );
356 virtual CPLErr SetLinearBinning( double dfRow0Min,
357 double dfBinSize );
358 virtual int GetLinearBinning( double *pdfRow0Min,
359 double *pdfBinSize ) const;
360 };
361
362 #endif /* ndef GDAL_RAT_H_INCLUDED */
GDALRasterAttributeTable
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:46
GDALRasterAttributeTable::GetValueAsInt
virtual int GetValueAsInt(int iRow, int iField) const =0
Fetch field value as a integer.
GDALDefaultRasterAttributeTable
Raster Attribute Table container.
Definition: gdal_rat.h:303
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:65
cpl_minixml.h
Definitions for CPL mini XML Parser/Serializer.
GDALRasterAttributeField
Definition: gdal_rat.h:283
GDALRATFieldType
GDALRATFieldType
Field type of raster attribute table.
Definition: gdal.h:957
GDALRasterAttributeTable::SetValue
virtual void SetValue(int iRow, int iField, const char *pszValue)=0
Set field value from string.
GDALRasterAttributeTable::GetRowOfValue
virtual int GetRowOfValue(double dfValue) const
Get row for pixel value.
Definition: gdal_rat.cpp:331
GDALRasterAttributeTable::SetRowCount
virtual void SetRowCount(int iCount)
Set row count.
Definition: gdal_rat.cpp:292
GDALRWFlag
GDALRWFlag
Definition: gdal.h:104
GDALRasterAttributeTable::GetNameOfCol
virtual const char * GetNameOfCol(int) const =0
Fetch name of indicated column.
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:283
GDALRasterAttributeTable::Clone
virtual GDALDefaultRasterAttributeTable * Clone() const =0
Copy Raster Attribute Table.
GDALRasterAttributeTable::GetRowCount
virtual int GetRowCount() const =0
Fetch row count.
GDALRasterAttributeTable::GetLinearBinning
virtual int GetLinearBinning(double *pdfRow0Min, double *pdfBinSize) const
Get linear binning information.
Definition: gdal_rat.cpp:482
GDALRasterAttributeTable::ChangesAreWrittenToFile
virtual int ChangesAreWrittenToFile()=0
Determine whether changes made to this RAT are reflected directly in the dataset. ...
GDALRasterAttributeTable::SetLinearBinning
virtual CPLErr SetLinearBinning(double dfRow0Min, double dfBinSize)
Set linear binning information.
Definition: gdal_rat.cpp:438
GDALRasterAttributeTable::GetUsageOfCol
virtual GDALRATFieldUsage GetUsageOfCol(int) const =0
Fetch column usage value.
GDALRasterAttributeTable::GetValueAsDouble
virtual double GetValueAsDouble(int iRow, int iField) const =0
Fetch field value as a double.
GDALRasterAttributeTable::CreateColumn
virtual CPLErr CreateColumn(const char *pszFieldName, GDALRATFieldType eFieldType, GDALRATFieldUsage eFieldUsage)
Create new column.
Definition: gdal_rat.cpp:390
GDALRATFieldUsage
GDALRATFieldUsage
Field usage of raster attribute table.
Definition: gdal.h:964
GDALRasterAttributeTable::GetColumnCount
virtual int GetColumnCount() const =0
Fetch table column count.
GDALRasterAttributeTable::GetValueAsString
virtual const char * GetValueAsString(int iRow, int iField) const =0
Fetch field value as a string.
GDALColorTable
Definition: gdal_priv.h:659
GDALRasterAttributeTable::GetTypeOfCol
virtual GDALRATFieldType GetTypeOfCol(int) const =0
Fetch column type.
GDALRasterAttributeTable::GetColOfUsage
virtual int GetColOfUsage(GDALRATFieldUsage) const =0
Fetch column index for given usage.

Generated for GDAL by 1.8.8.