GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

gdal_rat.h
1 /******************************************************************************
2 * $Id$
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 #include "gdal_priv.h"
35
36 // Clone and Serialize are allowed to fail if GetRowCount()*GetColCount()
37 // greater than this number
38 #define RAT_MAX_ELEM_FOR_CLONE 1000000
39
40 /************************************************************************/
41 /* GDALRasterAttributeTable */
42 /************************************************************************/
43
45 class GDALDefaultRasterAttributeTable;
46
47 class CPL_DLL GDALRasterAttributeTable
48 {
49 public:
50 virtual ~GDALRasterAttributeTable();
63 virtual GDALDefaultRasterAttributeTable *Clone() const = 0;
64
72 virtual int GetColumnCount() const = 0;
73
83 virtual const char *GetNameOfCol( int iCol ) const = 0;
84
94 virtual GDALRATFieldUsage GetUsageOfCol( int iCol ) const = 0;
95
105 virtual GDALRATFieldType GetTypeOfCol( int iCol ) const = 0;
106
119 virtual int GetColOfUsage( GDALRATFieldUsage eUsage ) const = 0;
120
128 virtual int GetRowCount() const = 0;
129
147 virtual const char *GetValueAsString( int iRow, int iField ) const = 0;
148
163 virtual int GetValueAsInt( int iRow, int iField ) const = 0;
164
179 virtual double GetValueAsDouble( int iRow, int iField ) const = 0;
180
194 virtual void SetValue( int iRow, int iField,
195 const char *pszValue ) = 0;
196
210 virtual void SetValue( int iRow, int iField, int nValue ) = 0;
211
225 virtual void SetValue( int iRow, int iField, double dfValue) = 0;
226
239 virtual int ChangesAreWrittenToFile() = 0;
240
241 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField,
242 int iStartRow, int iLength,
243 double *pdfData);
244 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField,
245 int iStartRow, int iLength, int *pnData);
246 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField,
247 int iStartRow, int iLength,
248 char **papszStrList);
249
250 virtual void SetRowCount( int iCount );
251 virtual int GetRowOfValue( double dfValue ) const;
252 virtual int GetRowOfValue( int nValue ) const;
253
254 virtual CPLErr CreateColumn( const char *pszFieldName,
255 GDALRATFieldType eFieldType,
256 GDALRATFieldUsage eFieldUsage );
257 virtual CPLErr SetLinearBinning( double dfRow0Min,
258 double dfBinSize );
259 virtual int GetLinearBinning( double *pdfRow0Min,
260 double *pdfBinSize ) const;
261
268 virtual CPLXMLNode *Serialize() const;
269 virtual void *SerializeJSON() const;
270 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
271
272 virtual CPLErr InitializeFromColorTable( const GDALColorTable * );
273 virtual GDALColorTable *TranslateToColorTable( int nEntryCount = -1 );
274
275 virtual void DumpReadable( FILE * = nullptr );
276
280 static inline GDALRasterAttributeTableH ToHandle(GDALRasterAttributeTable* poRAT)
281 { return static_cast<GDALRasterAttributeTableH>(poRAT); }
282
286 static inline GDALRasterAttributeTable* FromHandle(GDALRasterAttributeTableH hRAT)
287 { return static_cast<GDALRasterAttributeTable*>(hRAT); }
288 };
289
290 /************************************************************************/
291 /* GDALRasterAttributeField */
292 /* */
293 /* (private) */
294 /************************************************************************/
296 class GDALRasterAttributeField
297 {
298 public:
299 CPLString sName;
300
301 GDALRATFieldType eType;
302
303 GDALRATFieldUsage eUsage;
304
305 std::vector<GInt32> anValues;
306 std::vector<double> adfValues;
307 std::vector<CPLString> aosValues;
308 };
310
311 /************************************************************************/
312 /* GDALDefaultRasterAttributeTable */
313 /************************************************************************/
314
316
317 // cppcheck-suppress copyCtorAndEqOperator
318 class CPL_DLL GDALDefaultRasterAttributeTable : public GDALRasterAttributeTable
319 {
320 private:
321 std::vector<GDALRasterAttributeField> aoFields;
322
323 int bLinearBinning; // TODO(schwehr): Can this be a bool?
324 double dfRow0Min;
325 double dfBinSize;
326
327 void AnalyseColumns();
328 int bColumnsAnalysed; // TODO(schwehr): Can this be a bool?
329 int nMinCol;
330 int nMaxCol;
331
332 int nRowCount;
333
334 CPLString osWorkingResult;
335
336 public:
337 GDALDefaultRasterAttributeTable();
338 GDALDefaultRasterAttributeTable( const GDALDefaultRasterAttributeTable& );
339 ~GDALDefaultRasterAttributeTable() override;
340
341 GDALDefaultRasterAttributeTable *Clone() const override;
342
343 int GetColumnCount() const override;
344
345 const char *GetNameOfCol( int ) const override;
346 GDALRATFieldUsage GetUsageOfCol( int ) const override;
347 GDALRATFieldType GetTypeOfCol( int ) const override;
348
349 int GetColOfUsage( GDALRATFieldUsage ) const override;
350
351 int GetRowCount() const override;
352
353 const char *GetValueAsString( int iRow, int iField ) const override;
354 int GetValueAsInt( int iRow, int iField ) const override;
355 double GetValueAsDouble( int iRow, int iField ) const override;
356
357 void SetValue( int iRow, int iField,
358 const char *pszValue ) override;
359 void SetValue( int iRow, int iField, double dfValue) override;
360 void SetValue( int iRow, int iField, int nValue ) override;
361
362 int ChangesAreWrittenToFile() override;
363 void SetRowCount( int iCount ) override;
364
365 int GetRowOfValue( double dfValue ) const override;
366 int GetRowOfValue( int nValue ) const override;
367
368 CPLErr CreateColumn( const char *pszFieldName,
369 GDALRATFieldType eFieldType,
370 GDALRATFieldUsage eFieldUsage ) override;
371 CPLErr SetLinearBinning( double dfRow0Min,
372 double dfBinSize ) override;
373 int GetLinearBinning( double *pdfRow0Min,
374 double *pdfBinSize ) const override;
375 };
376
377 #endif /* ndef GDAL_RAT_H_INCLUDED */
GDALRasterAttributeTable::ToHandle
static GDALRasterAttributeTableH ToHandle(GDALRasterAttributeTable *poRAT)
Convert a GDALRasterAttributeTable* to a GDALRasterAttributeTableH.
Definition: gdal_rat.h:280
GDALRasterAttributeTable
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:47
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:318
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:66
cpl_minixml.h
Definitions for CPL mini XML Parser/Serializer.
gdal_priv.h
C++ GDAL entry points.
GDALRasterAttributeTable::GetTypeOfCol
virtual GDALRATFieldType GetTypeOfCol(int iCol) const =0
Fetch column type.
GDALRATFieldType
GDALRATFieldType
Field type of raster attribute table.
Definition: gdal.h:1076
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:362
GDALRasterAttributeTable::SetRowCount
virtual void SetRowCount(int iCount)
Set row count.
Definition: gdal_rat.cpp:316
GDALRasterAttributeTable::GetColOfUsage
virtual int GetColOfUsage(GDALRATFieldUsage eUsage) const =0
Fetch column index for given usage.
GDALRWFlag
GDALRWFlag
Definition: gdal.h:119
GDALRasterAttributeTable::GetUsageOfCol
virtual GDALRATFieldUsage GetUsageOfCol(int iCol) const =0
Fetch column usage value.
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:336
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:531
GDALRasterAttributeTable::FromHandle
static GDALRasterAttributeTable * FromHandle(GDALRasterAttributeTableH hRAT)
Convert a GDALRasterAttributeTableH to a GDALRasterAttributeTable*.
Definition: gdal_rat.h:286
GDALRasterAttributeTableH
void * GDALRasterAttributeTableH
Opaque type used for the C bindings of the C++ GDALRasterAttributeTable class.
Definition: gdal.h:267
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:487
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:439
GDALRasterAttributeTable::GetNameOfCol
virtual const char * GetNameOfCol(int iCol) const =0
Fetch name of indicated column.
GDALRATFieldUsage
GDALRATFieldUsage
Field usage of raster attribute table.
Definition: gdal.h:1083
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
A color table / palette.
Definition: gdal_priv.h:949
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:52

Generated for GDAL by 1.8.8.