- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# gdal_rat.h

    00001 /******************************************************************************
    00002  * $Id: gdal_rat.h 26117 2013-06-29 20:22:34Z rouault $
    00003  *
    00004  * Project:  GDAL Core
    00005  * Purpose:  GDALRasterAttributeTable class declarations.
    00006  * Author:   Frank Warmerdam, warmerdam@pobox.com
    00007  *
    00008  ******************************************************************************
    00009  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
    00010  *
    00011  * Permission is hereby granted, free of charge, to any person obtaining a
    00012  * copy of this software and associated documentation files (the "Software"),
    00013  * to deal in the Software without restriction, including without limitation
    00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00015  * and/or sell copies of the Software, and to permit persons to whom the
    00016  * Software is furnished to do so, subject to the following conditions:
    00017  *
    00018  * The above copyright notice and this permission notice shall be included
    00019  * in all copies or substantial portions of the Software.
    00020  *
    00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00027  * DEALINGS IN THE SOFTWARE.
    00028  ****************************************************************************/
    00029
    00030 #ifndef GDAL_RAT_H_INCLUDED
    00031 #define GDAL_RAT_H_INCLUDED
    00032
    00033 #include "cpl_minixml.h"
    00034
    00035 // Clone and Serialize are allowed to fail if GetRowCount()*GetColCount() greater
    00036 // than this number
    00037 #define RAT_MAX_ELEM_FOR_CLONE  1000000
    00038
    00039 /************************************************************************/
    00040 /*                       GDALRasterAttributeTable                       */
    00041 /************************************************************************/
    00042
    00044 class GDALDefaultRasterAttributeTable;
    00045
    00046 class CPL_DLL GDALRasterAttributeTable
    00047 {
    00048 public:
    00049     virtual ~GDALRasterAttributeTable();
    00062     virtual GDALDefaultRasterAttributeTable *Clone() const = 0;
    00063
    00071     virtual int           GetColumnCount() const = 0;
    00072
    00082     virtual const char   *GetNameOfCol( int ) const = 0;
    00083
    00093     virtual GDALRATFieldUsage GetUsageOfCol( int ) const = 0;
    00094
    00104     virtual GDALRATFieldType GetTypeOfCol( int ) const = 0;
    00105
    00118     virtual int           GetColOfUsage( GDALRATFieldUsage ) const = 0;
    00119
    00127     virtual int           GetRowCount() const = 0;
    00128
    00146     virtual const char   *GetValueAsString( int iRow, int iField ) const = 0;
    00147
    00162     virtual int           GetValueAsInt( int iRow, int iField ) const = 0;
    00163
    00178     virtual double        GetValueAsDouble( int iRow, int iField ) const = 0;
    00179
    00193     virtual void          SetValue( int iRow, int iField, const char *pszValue ) = 0;
    00194
    00208     virtual void          SetValue( int iRow, int iField, int nValue ) = 0;
    00209
    00223     virtual void          SetValue( int iRow, int iField, double dfValue) = 0;
    00224
    00234     virtual int           ChangesAreWrittenToFile() = 0;
    00235
    00236     virtual CPLErr        ValuesIO(GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, double *pdfData);
    00237     virtual CPLErr        ValuesIO(GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, int *pnData);
    00238     virtual CPLErr        ValuesIO(GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, char **papszStrList);
    00239
    00240     virtual void          SetRowCount( int iCount );
    00241     virtual int           GetRowOfValue( double dfValue ) const;
    00242     virtual int           GetRowOfValue( int nValue ) const;
    00243
    00244     virtual CPLErr        CreateColumn( const char *pszFieldName,
    00245                                 GDALRATFieldType eFieldType,
    00246                                 GDALRATFieldUsage eFieldUsage );
    00247     virtual CPLErr        SetLinearBinning( double dfRow0Min, double dfBinSize );
    00248     virtual int           GetLinearBinning( double *pdfRow0Min, double *pdfBinSize ) const;
    00249
    00256     virtual CPLXMLNode   *Serialize() const;
    00257     virtual CPLErr        XMLInit( CPLXMLNode *, const char * );
    00258
    00259     virtual CPLErr        InitializeFromColorTable( const GDALColorTable * );
    00260     virtual GDALColorTable *TranslateToColorTable( int nEntryCount = -1 );
    00261
    00262     virtual void          DumpReadable( FILE * = NULL );
    00263 };
    00264
    00265 /************************************************************************/
    00266 /*                       GDALRasterAttributeField                       */
    00267 /*                                                                      */
    00268 /*      (private)                                                       */
    00269 /************************************************************************/
    00270
    00271 class GDALRasterAttributeField
    00272 {
    00273 public:
    00274     CPLString         sName;
    00275
    00276     GDALRATFieldType  eType;
    00277
    00278     GDALRATFieldUsage eUsage;
    00279
    00280     std::vector<GInt32> anValues;
    00281     std::vector<double> adfValues;
    00282     std::vector<CPLString> aosValues;
    00283 };
    00284
    00285 /************************************************************************/
    00286 /*                    GDALDefaultRasterAttributeTable                   */
    00287 /************************************************************************/
    00288
    00290
    00291 class CPL_DLL GDALDefaultRasterAttributeTable : public GDALRasterAttributeTable
    00292 {
    00293 private:
    00294     std::vector<GDALRasterAttributeField> aoFields;
    00295
    00296     int bLinearBinning;
    00297     double dfRow0Min;
    00298     double dfBinSize;
    00299
    00300     void  AnalyseColumns();
    00301     int   bColumnsAnalysed;
    00302     int   nMinCol;
    00303     int   nMaxCol;
    00304
    00305     int   nRowCount;
    00306
    00307     CPLString osWorkingResult;
    00308
    00309 public:
    00310     GDALDefaultRasterAttributeTable();
    00311     GDALDefaultRasterAttributeTable(const GDALDefaultRasterAttributeTable&);
    00312     ~GDALDefaultRasterAttributeTable();
    00313
    00314     GDALDefaultRasterAttributeTable *Clone() const;
    00315
    00316     virtual int           GetColumnCount() const;
    00317
    00318     virtual const char   *GetNameOfCol( int ) const;
    00319     virtual GDALRATFieldUsage GetUsageOfCol( int ) const;
    00320     virtual GDALRATFieldType GetTypeOfCol( int ) const;
    00321
    00322     virtual int           GetColOfUsage( GDALRATFieldUsage ) const;
    00323
    00324     virtual int           GetRowCount() const;
    00325
    00326     virtual const char   *GetValueAsString( int iRow, int iField ) const;
    00327     virtual int           GetValueAsInt( int iRow, int iField ) const;
    00328     virtual double        GetValueAsDouble( int iRow, int iField ) const;
    00329
    00330     virtual void          SetValue( int iRow, int iField, const char *pszValue );
    00331     virtual void          SetValue( int iRow, int iField, double dfValue);
    00332     virtual void          SetValue( int iRow, int iField, int nValue );
    00333
    00334     virtual int           ChangesAreWrittenToFile();
    00335     virtual void          SetRowCount( int iCount );
    00336
    00337     virtual int           GetRowOfValue( double dfValue ) const;
    00338     virtual int           GetRowOfValue( int nValue ) const;
    00339
    00340     virtual CPLErr        CreateColumn( const char *pszFieldName,
    00341                                 GDALRATFieldType eFieldType,
    00342                                 GDALRATFieldUsage eFieldUsage );
    00343     virtual CPLErr        SetLinearBinning( double dfRow0Min, double dfBinSize );
    00344     virtual int           GetLinearBinning( double *pdfRow0Min, double *pdfBinSize ) const;
    00345
    00346 };
    00347
    00348 #endif /* ndef GDAL_RAT_H_INCLUDED */

Generated for GDAL by 1.7.1.