|
GDAL
|
00001 /****************************************************************************** 00002 * $Id: gdal_rat.h 36501 2016-11-25 14:09:24Z 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() 00036 // greater 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 iCol ) const = 0; 00083 00093 virtual GDALRATFieldUsage GetUsageOfCol( int iCol ) const = 0; 00094 00104 virtual GDALRATFieldType GetTypeOfCol( int iCol ) const = 0; 00105 00118 virtual int GetColOfUsage( GDALRATFieldUsage eUsage ) 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, 00194 const char *pszValue ) = 0; 00195 00209 virtual void SetValue( int iRow, int iField, int nValue ) = 0; 00210 00224 virtual void SetValue( int iRow, int iField, double dfValue) = 0; 00225 00238 virtual int ChangesAreWrittenToFile() = 0; 00239 00240 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField, 00241 int iStartRow, int iLength, 00242 double *pdfData); 00243 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField, 00244 int iStartRow, int iLength, int *pnData); 00245 virtual CPLErr ValuesIO( GDALRWFlag eRWFlag, int iField, 00246 int iStartRow, int iLength, 00247 char **papszStrList); 00248 00249 virtual void SetRowCount( int iCount ); 00250 virtual int GetRowOfValue( double dfValue ) const; 00251 virtual int GetRowOfValue( int nValue ) const; 00252 00253 virtual CPLErr CreateColumn( const char *pszFieldName, 00254 GDALRATFieldType eFieldType, 00255 GDALRATFieldUsage eFieldUsage ); 00256 virtual CPLErr SetLinearBinning( double dfRow0Min, 00257 double dfBinSize ); 00258 virtual int GetLinearBinning( double *pdfRow0Min, 00259 double *pdfBinSize ) const; 00260 00267 virtual CPLXMLNode *Serialize() const; 00268 virtual void *SerializeJSON() const; 00269 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00270 00271 virtual CPLErr InitializeFromColorTable( const GDALColorTable * ); 00272 virtual GDALColorTable *TranslateToColorTable( int nEntryCount = -1 ); 00273 00274 virtual void DumpReadable( FILE * = NULL ); 00275 }; 00276 00277 /************************************************************************/ 00278 /* GDALRasterAttributeField */ 00279 /* */ 00280 /* (private) */ 00281 /************************************************************************/ 00283 class GDALRasterAttributeField 00284 { 00285 public: 00286 CPLString sName; 00287 00288 GDALRATFieldType eType; 00289 00290 GDALRATFieldUsage eUsage; 00291 00292 std::vector<GInt32> anValues; 00293 std::vector<double> adfValues; 00294 std::vector<CPLString> aosValues; 00295 }; 00297 00298 /************************************************************************/ 00299 /* GDALDefaultRasterAttributeTable */ 00300 /************************************************************************/ 00301 00303 00304 class CPL_DLL GDALDefaultRasterAttributeTable : public GDALRasterAttributeTable 00305 { 00306 private: 00307 std::vector<GDALRasterAttributeField> aoFields; 00308 00309 int bLinearBinning; // TODO(schwehr): Can this be a bool? 00310 double dfRow0Min; 00311 double dfBinSize; 00312 00313 void AnalyseColumns(); 00314 int bColumnsAnalysed; // TODO(schwehr): Can this be a bool? 00315 int nMinCol; 00316 int nMaxCol; 00317 00318 int nRowCount; 00319 00320 CPLString osWorkingResult; 00321 00322 public: 00323 GDALDefaultRasterAttributeTable(); 00324 GDALDefaultRasterAttributeTable( const GDALDefaultRasterAttributeTable& ); 00325 virtual ~GDALDefaultRasterAttributeTable(); 00326 00327 GDALDefaultRasterAttributeTable *Clone() const CPL_OVERRIDE; 00328 00329 virtual int GetColumnCount() const CPL_OVERRIDE; 00330 00331 virtual const char *GetNameOfCol( int ) const CPL_OVERRIDE; 00332 virtual GDALRATFieldUsage GetUsageOfCol( int ) const CPL_OVERRIDE; 00333 virtual GDALRATFieldType GetTypeOfCol( int ) const CPL_OVERRIDE; 00334 00335 virtual int GetColOfUsage( GDALRATFieldUsage ) const CPL_OVERRIDE; 00336 00337 virtual int GetRowCount() const CPL_OVERRIDE; 00338 00339 virtual const char *GetValueAsString( int iRow, int iField ) const CPL_OVERRIDE; 00340 virtual int GetValueAsInt( int iRow, int iField ) const CPL_OVERRIDE; 00341 virtual double GetValueAsDouble( int iRow, int iField ) const CPL_OVERRIDE; 00342 00343 virtual void SetValue( int iRow, int iField, 00344 const char *pszValue ) CPL_OVERRIDE; 00345 virtual void SetValue( int iRow, int iField, double dfValue) CPL_OVERRIDE; 00346 virtual void SetValue( int iRow, int iField, int nValue ) CPL_OVERRIDE; 00347 00348 virtual int ChangesAreWrittenToFile() CPL_OVERRIDE; 00349 virtual void SetRowCount( int iCount ) CPL_OVERRIDE; 00350 00351 virtual int GetRowOfValue( double dfValue ) const CPL_OVERRIDE; 00352 virtual int GetRowOfValue( int nValue ) const CPL_OVERRIDE; 00353 00354 virtual CPLErr CreateColumn( const char *pszFieldName, 00355 GDALRATFieldType eFieldType, 00356 GDALRATFieldUsage eFieldUsage ) CPL_OVERRIDE; 00357 virtual CPLErr SetLinearBinning( double dfRow0Min, 00358 double dfBinSize ) CPL_OVERRIDE; 00359 virtual int GetLinearBinning( double *pdfRow0Min, 00360 double *pdfBinSize ) const CPL_OVERRIDE; 00361 }; 00362 00363 #endif /* ndef GDAL_RAT_H_INCLUDED */
1.7.6.1.