gdal_rat.h

00001 /******************************************************************************
00002  * $Id: gdal_rat.h 10646 2007-01-18 02:38:10Z warmerdam $
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 /************************************************************************/
00036 /*                       GDALRasterAttributeField                       */
00037 /*                                                                      */
00038 /*      (private)                                                       */
00039 /************************************************************************/
00040 
00041 class GDALRasterAttributeField
00042 {
00043 public:
00044     CPLString         sName;
00045 
00046     GDALRATFieldType  eType;
00047 
00048     GDALRATFieldUsage eUsage;
00049 
00050     std::vector<GInt32> anValues;
00051     std::vector<double> adfValues;
00052     std::vector<CPLString> aosValues;
00053 };
00054 
00055 /************************************************************************/
00056 /*                       GDALRasterAttributeTable                       */
00057 /************************************************************************/
00058 
00060 
00061 class CPL_DLL GDALRasterAttributeTable 
00062 {
00063     friend const char * CPL_STDCALL GDALRATGetNameOfCol( GDALRasterAttributeTableH, int );
00064     friend const char * CPL_STDCALL GDALRATGetValueAsString( GDALRasterAttributeTableH, int, int );
00065 
00066 private:
00067     std::vector<GDALRasterAttributeField> aoFields;
00068 
00069     int bLinearBinning;
00070     double dfRow0Min;
00071     double dfBinSize;
00072 
00073     void  AnalyseColumns();
00074     int   bColumnsAnalysed;
00075     int   nMinCol;
00076     int   nMaxCol;
00077 
00078     int   nRowCount;
00079 
00080     CPLString     osWorkingResult;
00081 
00082 public:
00083     GDALRasterAttributeTable();
00084     GDALRasterAttributeTable(const GDALRasterAttributeTable&);
00085     ~GDALRasterAttributeTable();
00086 
00087     GDALRasterAttributeTable *Clone() const;
00088     
00089     int           GetColumnCount() const;
00090 
00091     const char   *GetNameOfCol( int ) const;
00092     GDALRATFieldUsage GetUsageOfCol( int ) const;
00093     GDALRATFieldType GetTypeOfCol( int ) const;
00094     
00095     int           GetColOfUsage( GDALRATFieldUsage ) const;
00096 
00097     int           GetRowCount() const;
00098 
00099     const char   *GetValueAsString( int iRow, int iField ) const;
00100     int           GetValueAsInt( int iRow, int iField ) const;
00101     double        GetValueAsDouble( int iRow, int iField ) const;
00102 
00103     void          SetValue( int iRow, int iField, const char *pszValue );
00104     void          SetValue( int iRow, int iField, double dfValue);
00105     void          SetValue( int iRow, int iField, int nValue );
00106     void          SetRowCount( int iCount );
00107 
00108     int           GetRowOfValue( double dfValue ) const;
00109     int           GetRowOfValue( int nValue ) const;
00110     int           GetColorOfValue( double dfValue, GDALColorEntry *psEntry ) const;
00111 
00112     double        GetRowMin( int iRow ) const;
00113     double        GetRowMax( int iRow ) const;
00114 
00115     CPLErr        CreateColumn( const char *pszFieldName, 
00116                                 GDALRATFieldType eFieldType, 
00117                                 GDALRATFieldUsage eFieldUsage );
00118     CPLErr        SetLinearBinning( double dfRow0Min, double dfBinSize );
00119     int           GetLinearBinning( double *pdfRow0Min, double *pdfBinSize ) const;
00120 
00121     CPLXMLNode   *Serialize() const;
00122     CPLErr        XMLInit( CPLXMLNode *, const char * );
00123 
00124     CPLErr        InitializeFromColorTable( const GDALColorTable * );
00125     GDALColorTable *TranslateToColorTable( int nEntryCount = -1 );
00126     
00127     void          DumpReadable( FILE * = NULL );
00128 };
00129 
00130 #endif /* ndef GDAL_RAT_H_INCLUDED */

Generated for GDAL by doxygen 1.5.2.