Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

gdal_rat.h

00001 /******************************************************************************
00002  * $Id: gdal_rat.h,v 1.4 2006/10/24 18:49:22 fwarmerdam Exp $
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  * $Log: gdal_rat.h,v $
00031  * Revision 1.4  2006/10/24 18:49:22  fwarmerdam
00032  * avoid using CPLString in arguments and return from RAT API
00033  *
00034  * Revision 1.3  2006/10/07 02:00:38  fwarmerdam
00035  * added RAT translation to ColorTable, and a few other fixes
00036  *
00037  * Revision 1.2  2005/09/28 21:29:30  fwarmerdam
00038  * added RAT documentation
00039  *
00040  */
00041 
00042 #ifndef GDAL_RAT_H_INCLUDED
00043 #define GDAL_RAT_H_INCLUDED
00044 
00045 #include "cpl_minixml.h"
00046 
00047 /************************************************************************/
00048 /*                       GDALRasterAttributeField                       */
00049 /*                                                                      */
00050 /*      (private)                                                       */
00051 /************************************************************************/
00052 
00053 class GDALRasterAttributeField
00054 {
00055 public:
00056     CPLString         sName;
00057 
00058     GDALRATFieldType  eType;
00059 
00060     GDALRATFieldUsage eUsage;
00061 
00062     std::vector<GInt32> anValues;
00063     std::vector<double> adfValues;
00064     std::vector<CPLString> aosValues;
00065 };
00066 
00067 /************************************************************************/
00068 /*                       GDALRasterAttributeTable                       */
00069 /************************************************************************/
00070 
00072 
00073 class CPL_DLL GDALRasterAttributeTable 
00074 {
00075     friend const char * CPL_STDCALL GDALRATGetNameOfCol( GDALRasterAttributeTableH, int );
00076     friend const char * CPL_STDCALL GDALRATGetValueAsString( GDALRasterAttributeTableH, int, int );
00077 
00078 private:
00079     std::vector<GDALRasterAttributeField> aoFields;
00080 
00081     int bLinearBinning;
00082     double dfRow0Min;
00083     double dfBinSize;
00084 
00085     void  AnalyseColumns();
00086     int   bColumnsAnalysed;
00087     int   nMinCol;
00088     int   nMaxCol;
00089 
00090     int   nRowCount;
00091 
00092     CPLString     osWorkingResult;
00093 
00094 public:
00095     GDALRasterAttributeTable();
00096     GDALRasterAttributeTable(const GDALRasterAttributeTable&);
00097     ~GDALRasterAttributeTable();
00098 
00099     GDALRasterAttributeTable *Clone() const;
00100     
00101     int           GetColumnCount() const;
00102 
00103     const char   *GetNameOfCol( int ) const;
00104     GDALRATFieldUsage GetUsageOfCol( int ) const;
00105     GDALRATFieldType GetTypeOfCol( int ) const;
00106     
00107     int           GetColOfUsage( GDALRATFieldUsage ) const;
00108 
00109     int           GetRowCount() const;
00110 
00111     const char   *GetValueAsString( int iRow, int iField ) const;
00112     int           GetValueAsInt( int iRow, int iField ) const;
00113     double        GetValueAsDouble( int iRow, int iField ) const;
00114 
00115     void          SetValue( int iRow, int iField, const char *pszValue );
00116     void          SetValue( int iRow, int iField, double dfValue);
00117     void          SetValue( int iRow, int iField, int nValue );
00118     void          SetRowCount( int iCount );
00119 
00120     int           GetRowOfValue( double dfValue ) const;
00121     int           GetRowOfValue( int nValue ) const;
00122     int           GetColorOfValue( double dfValue, GDALColorEntry *psEntry ) const;
00123 
00124     double        GetRowMin( int iRow ) const;
00125     double        GetRowMax( int iRow ) const;
00126 
00127     CPLErr        CreateColumn( const char *pszFieldName, 
00128                                 GDALRATFieldType eFieldType, 
00129                                 GDALRATFieldUsage eFieldUsage );
00130     CPLErr        SetLinearBinning( double dfRow0Min, double dfBinSize );
00131     int           GetLinearBinning( double *pdfRow0Min, double *pdfBinSize ) const;
00132 
00133     CPLXMLNode   *Serialize() const;
00134     CPLErr        XMLInit( CPLXMLNode *, const char * );
00135 
00136     CPLErr        InitializeFromColorTable( const GDALColorTable * );
00137     GDALColorTable *TranslateToColorTable( int nEntryCount = -1 );
00138     
00139     void          DumpReadable( FILE * = NULL );
00140 };
00141 
00142 #endif /* ndef GDAL_RAT_H_INCLUDED */

Generated for GDAL by doxygen 1.4.4.