00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef GDAL_RAT_H_INCLUDED
00043 #define GDAL_RAT_H_INCLUDED
00044
00045 #include "cpl_minixml.h"
00046
00047
00048
00049
00050
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
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