root/tags/gdal_1_3_2/gcore/gdal_pam.h

Revision 9131, 11.1 kB (checked in by fwarmerdam, 3 years ago)

expose some PAM histo stuff for VRT, fixed InitFromXML() hist bug

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /******************************************************************************
2  * $Id$
3  *
4  * Project:  GDAL Core
5  * Purpose:  Declaration for Peristable Auxilary Metadata classes.
6  * Author:   Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ******************************************************************************
29  *
30  * $Log$
31  * Revision 1.8  2006/02/08 06:03:40  fwarmerdam
32  * expose some PAM histo stuff for VRT, fixed InitFromXML() hist bug
33  *
34  * Revision 1.7  2005/10/13 01:19:57  fwarmerdam
35  * moved GDALMultiDomainMetadata into GDALMajorObject
36  *
37  * Revision 1.6  2005/09/24 19:02:15  fwarmerdam
38  * added RasterAttributeTable support
39  *
40  * Revision 1.5  2005/09/11 18:03:34  fwarmerdam
41  * added Clear() method on multidomainmetadata
42  *
43  * Revision 1.4  2005/05/22 08:14:06  fwarmerdam
44  * added multidomain metadata support
45  *
46  * Revision 1.3  2005/05/13 18:19:04  fwarmerdam
47  * Added SetDefaultHistogram
48  *
49  * Revision 1.2  2005/05/11 14:04:21  fwarmerdam
50  * added getdefaulthistogram
51  *
52  * Revision 1.1  2005/04/27 16:27:44  fwarmerdam
53  * New
54  *
55  */
56
57 #ifndef GDAL_PAM_H_INCLUDED
58 #define GDAL_PAM_H_INCLUDED
59
60 #include "gdal_priv.h"
61
62 class GDALPamRasterBand;
63
64 /* Clone Info Flags */
65
66 #define GCIF_GEOTRANSFORM       0x01
67 #define GCIF_PROJECTION         0x02
68 #define GCIF_METADATA           0x04
69 #define GCIF_GCPS               0x08
70
71 #define GCIF_NODATA             0x001000
72 #define GCIF_CATEGORYNAMES      0x002000
73 #define GCIF_MINMAX             0x004000
74 #define GCIF_SCALEOFFSET        0x008000
75 #define GCIF_UNITTYPE           0x010000
76 #define GCIF_COLORTABLE         0x020000
77 #define GCIF_COLORINTERP        0x020000
78 #define GCIF_BAND_METADATA      0x040000
79 #define GCIF_RAT                0x080000
80
81 #define GCIF_ONLY_IF_MISSING    0x10000000
82 #define GCIF_PROCESS_BANDS      0x20000000
83
84 #define GCIF_PAM_DEFAULT        (GCIF_GEOTRANSFORM | GCIF_PROJECTION |     \
85                                  GCIF_METADATA | GCIF_GCPS |               \
86                                  GCIF_NODATA | GCIF_CATEGORYNAMES |        \
87                                  GCIF_MINMAX | GCIF_SCALEOFFSET |          \
88                                  GCIF_UNITTYPE | GCIF_COLORTABLE |         \
89                                  GCIF_COLORINTERP | GCIF_BAND_METADATA |   \
90                                  GCIF_RAT |                                \
91                                  GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS )
92
93 /* GDAL PAM Flags */
94 #define GPF_DIRTY               0x01  // .pam file needs to be written on close
95 #define GPF_TRIED_READ_FAILED   0x02  // no need to keep trying to read .pam.
96 #define GPF_DISABLED            0x04  // do not try any PAM stuff.
97 #define GPF_AUXMODE             0x08  // store info in .aux (HFA) file.
98
99 /* ==================================================================== */
100 /*      GDALDatasetPamInfo                                              */
101 /*                                                                      */
102 /*      We make these things a seperate structure of information        */
103 /*      primarily so we can modify it without altering the size of      */
104 /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
105 /*      driver plugins.                                                 */
106 /* ==================================================================== */
107 typedef struct {
108     char       *pszPamFilename;
109
110     char        *pszProjection;
111
112     int         bHaveGeoTransform;
113     double      adfGeoTransform[6];
114
115     int         nGCPCount;
116     GDAL_GCP   *pasGCPList;
117     char       *pszGCPProjection;
118
119 } GDALDatasetPamInfo;
120
121 /* ******************************************************************** */
122 /*                           GDALPamDataset                             */
123 /* ******************************************************************** */
124
125 class CPL_DLL GDALPamDataset : public GDALDataset
126 {
127     friend class GDALPamRasterBand;
128
129   protected:
130                 GDALPamDataset(void);
131
132     int         nPamFlags;
133     GDALDatasetPamInfo *psPam;
134
135     virtual CPLXMLNode *SerializeToXML( const char *);
136     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
137    
138     virtual CPLErr TryLoadXML();
139     virtual CPLErr TrySaveXML();
140
141     CPLErr  TryLoadAux();
142     CPLErr  TrySaveAux();
143
144     virtual const char *BuildPamFilename();
145
146     void   PamInitialize();
147     void   PamClear();
148
149   public:
150     virtual     ~GDALPamDataset();
151
152     virtual void FlushCache(void);
153
154     virtual const char *GetProjectionRef(void);
155     virtual CPLErr SetProjection( const char * );
156
157     virtual CPLErr GetGeoTransform( double * );
158     virtual CPLErr SetGeoTransform( double * );
159
160     virtual int    GetGCPCount();
161     virtual const char *GetGCPProjection();
162     virtual const GDAL_GCP *GetGCPs();
163     virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
164                             const char *pszGCPProjection );
165
166     virtual CPLErr      SetMetadata( char ** papszMetadata,
167                                      const char * pszDomain = "" );
168     virtual CPLErr      SetMetadataItem( const char * pszName,
169                                          const char * pszValue,
170                                          const char * pszDomain = "" );
171
172     virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags );
173
174
175     // "semi private" methods.
176     void   MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
177     GDALDatasetPamInfo *GetPamInfo() { return psPam; }
178 };
179
180 /* ==================================================================== */
181 /*      GDALDatasetPamInfo                                              */
182 /*                                                                      */
183 /*      We make these things a seperate structure of information        */
184 /*      primarily so we can modify it without altering the size of      */
185 /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
186 /*      driver plugins.                                                 */
187 /* ==================================================================== */
188 typedef struct {
189     GDALPamDataset *poParentDS;
190
191     int            bNoDataValueSet;
192     double         dfNoDataValue;
193
194     GDALColorTable *poColorTable;
195
196     GDALColorInterp eColorInterp;
197
198     char           *pszUnitType;
199     char           **papszCategoryNames;
200    
201     double         dfOffset;
202     double         dfScale;
203
204     int            bHaveMinMax;
205     double         dfMin;
206     double         dfMax;
207
208     int            bHaveStats;
209     double         dfMean;
210     double         dfStdDev;
211
212     CPLXMLNode     *psSavedHistograms;
213
214     GDALRasterAttributeTable *poDefaultRAT;
215
216 } GDALRasterBandPamInfo;
217
218 /* ******************************************************************** */
219 /*                          GDALPamRasterBand                           */
220 /* ******************************************************************** */
221 class CPL_DLL GDALPamRasterBand : public GDALRasterBand
222 {
223     friend class GDALPamDataset;
224
225   protected:
226
227     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
228     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
229    
230     void   PamInitialize();
231     void   PamClear();
232
233     GDALRasterBandPamInfo *psPam;
234
235   public:
236                 GDALPamRasterBand();
237     virtual     ~GDALPamRasterBand();
238
239     virtual CPLErr SetNoDataValue( double );
240     virtual double GetNoDataValue( int *pbSuccess = NULL );
241
242     virtual CPLErr SetColorTable( GDALColorTable * );
243     virtual GDALColorTable *GetColorTable();
244
245     virtual CPLErr SetColorInterpretation( GDALColorInterp );
246     virtual GDALColorInterp GetColorInterpretation();
247
248     virtual const char *GetUnitType();
249     CPLErr SetUnitType( const char * );
250
251     virtual char **GetCategoryNames();
252     virtual CPLErr SetCategoryNames( char ** );
253
254     virtual double GetOffset( int *pbSuccess = NULL );
255     CPLErr SetOffset( double );
256     virtual double GetScale( int *pbSuccess = NULL );
257     CPLErr SetScale( double );
258
259     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
260                           int nBuckets, int * panHistogram,
261                           int bIncludeOutOfRange, int bApproxOK,
262                           GDALProgressFunc, void *pProgressData );
263
264     virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
265                                         int *pnBuckets, int ** ppanHistogram,
266                                         int bForce,
267                                         GDALProgressFunc, void *pProgressData);
268
269     virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
270                                         int nBuckets, int *panHistogram );
271
272     virtual CPLErr      SetMetadata( char ** papszMetadata,
273                                      const char * pszDomain = "" );
274     virtual CPLErr      SetMetadataItem( const char * pszName,
275                                          const char * pszValue,
276                                          const char * pszDomain = "" );
277
278     virtual const GDALRasterAttributeTable *GetDefaultRAT();
279     virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
280
281     // new in GDALPamRasterBand.
282     virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags );
283
284     // "semi private" methods.
285     GDALRasterBandPamInfo *GetPamInfo() { return psPam; }
286 };
287
288 // These are mainly helper functions for internal use.
289 int CPL_DLL PamApplyMetadata( CPLXMLNode *psTree, GDALMajorObject *poMO );
290 CPLXMLNode CPL_DLL *PamSerializeMetadata( GDALMajorObject *poMO );
291 int CPL_DLL PamParseHistogram( CPLXMLNode *psHistItem,
292                                double *pdfMin, double *pdfMax,
293                                int *pnBuckets, int **ppanHistogram,
294                                int *pbIncludeOutOfRange, int *pbApproxOK );
295 CPLXMLNode CPL_DLL *
296 PamFindMatchingHistogram( CPLXMLNode *psSavedHistograms,
297                           double dfMin, double dfMax, int nBuckets,
298                           int bIncludeOutOfRange, int bApproxOK );
299 CPLXMLNode CPL_DLL *
300 PamHistogramToXMLTree( double dfMin, double dfMax,
301                        int nBuckets, int * panHistogram,
302                        int bIncludeOutOfRange, int bApprox );
303
304 #endif /* ndef GDAL_PAM_H_INCLUDED */
Note: See TracBrowser for help on using the browser.