gdal_rat.h

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

Generated for GDAL by doxygen 1.5.1.