1 : /******************************************************************************
2 : * $Id: memdataset.h 21803 2011-02-22 22:12:22Z warmerdam $
3 : *
4 : * Project: Memory Array Translator
5 : * Purpose: Declaration of MEMDataset, and MEMRasterBand.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2000, Frank Warmerdam
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 : #ifndef MEMDATASET_H_INCLUDED
31 : #define MEMDATASET_H_INCLUDED
32 :
33 : #include "gdal_pam.h"
34 : #include "gdal_priv.h"
35 :
36 : CPL_C_START
37 : void GDALRegister_MEM(void);
38 : GDALRasterBandH CPL_DLL MEMCreateRasterBand( GDALDataset *, int, GByte *,
39 : GDALDataType, int, int, int );
40 : CPL_C_END
41 :
42 : /************************************************************************/
43 : /* MEMDataset */
44 : /************************************************************************/
45 :
46 : class MEMRasterBand;
47 :
48 : class CPL_DLL MEMDataset : public GDALDataset
49 : {
50 : int bGeoTransformSet;
51 : double adfGeoTransform[6];
52 :
53 : char *pszProjection;
54 :
55 : int nGCPCount;
56 : GDAL_GCP *pasGCPs;
57 : CPLString osGCPProjection;
58 :
59 : public:
60 : MEMDataset();
61 : virtual ~MEMDataset();
62 :
63 : virtual const char *GetProjectionRef(void);
64 : virtual CPLErr SetProjection( const char * );
65 :
66 : virtual CPLErr GetGeoTransform( double * );
67 : virtual CPLErr SetGeoTransform( double * );
68 :
69 : virtual void *GetInternalHandle( const char * );
70 :
71 : virtual int GetGCPCount();
72 : virtual const char *GetGCPProjection();
73 : virtual const GDAL_GCP *GetGCPs();
74 : virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
75 : const char *pszGCPProjection );
76 :
77 : virtual CPLErr AddBand( GDALDataType eType,
78 : char **papszOptions=NULL );
79 :
80 : static GDALDataset *Open( GDALOpenInfo * );
81 : static GDALDataset *Create( const char * pszFilename,
82 : int nXSize, int nYSize, int nBands,
83 : GDALDataType eType, char ** papszParmList );
84 : };
85 :
86 : /************************************************************************/
87 : /* MEMRasterBand */
88 : /************************************************************************/
89 :
90 : class CPL_DLL MEMRasterBand : public GDALPamRasterBand
91 : {
92 : protected:
93 :
94 : GByte *pabyData;
95 : int nPixelOffset;
96 : int nLineOffset;
97 : int bOwnData;
98 :
99 : int bNoDataSet;
100 : double dfNoData;
101 :
102 : GDALColorTable *poColorTable;
103 : GDALColorInterp eColorInterp;
104 :
105 : char *pszUnitType;
106 : char **papszCategoryNames;
107 :
108 : double dfOffset;
109 : double dfScale;
110 :
111 : CPLXMLNode *psSavedHistograms;
112 : public:
113 :
114 : MEMRasterBand( GDALDataset *poDS, int nBand,
115 : GByte *pabyData, GDALDataType eType,
116 : int nPixelOffset, int nLineOffset,
117 : int bAssumeOwnership, const char * pszPixelType = NULL);
118 : virtual ~MEMRasterBand();
119 :
120 : // should override RasterIO eventually.
121 :
122 : virtual CPLErr IReadBlock( int, int, void * );
123 : virtual CPLErr IWriteBlock( int, int, void * );
124 :
125 : virtual double GetNoDataValue( int *pbSuccess = NULL );
126 : virtual CPLErr SetNoDataValue( double );
127 :
128 : virtual GDALColorInterp GetColorInterpretation();
129 : virtual GDALColorTable *GetColorTable();
130 : virtual CPLErr SetColorTable( GDALColorTable * );
131 :
132 : virtual CPLErr SetColorInterpretation( GDALColorInterp );
133 :
134 : virtual const char *GetUnitType();
135 : CPLErr SetUnitType( const char * );
136 :
137 : virtual char **GetCategoryNames();
138 : virtual CPLErr SetCategoryNames( char ** );
139 :
140 : virtual double GetOffset( int *pbSuccess = NULL );
141 : CPLErr SetOffset( double );
142 : virtual double GetScale( int *pbSuccess = NULL );
143 : CPLErr SetScale( double );
144 :
145 : virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
146 : int nBuckets, int *panHistogram );
147 : virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
148 : int *pnBuckets, int ** ppanHistogram,
149 : int bForce,
150 : GDALProgressFunc, void *pProgressData);
151 :
152 : // allow access to MEM driver's private internal memory buffer
153 0 : GByte *GetData(void) const {return(pabyData);}
154 : };
155 :
156 : #endif /* ndef MEMDATASET_H_INCLUDED */
157 :
|