1 : /******************************************************************************
2 : * $Id: memdataset.h 17601 2009-09-02 02:46:59Z 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 : public:
112 :
113 : MEMRasterBand( GDALDataset *poDS, int nBand,
114 : GByte *pabyData, GDALDataType eType,
115 : int nPixelOffset, int nLineOffset,
116 : int bAssumeOwnership );
117 : virtual ~MEMRasterBand();
118 :
119 : // should override RasterIO eventually.
120 :
121 : virtual CPLErr IReadBlock( int, int, void * );
122 : virtual CPLErr IWriteBlock( int, int, void * );
123 :
124 : virtual double GetNoDataValue( int *pbSuccess = NULL );
125 : virtual CPLErr SetNoDataValue( double );
126 :
127 : virtual GDALColorInterp GetColorInterpretation();
128 : virtual GDALColorTable *GetColorTable();
129 : virtual CPLErr SetColorTable( GDALColorTable * );
130 :
131 : virtual CPLErr SetColorInterpretation( GDALColorInterp );
132 :
133 : virtual const char *GetUnitType();
134 : CPLErr SetUnitType( const char * );
135 :
136 : virtual char **GetCategoryNames();
137 : virtual CPLErr SetCategoryNames( char ** );
138 :
139 : virtual double GetOffset( int *pbSuccess = NULL );
140 : CPLErr SetOffset( double );
141 : virtual double GetScale( int *pbSuccess = NULL );
142 : CPLErr SetScale( double );
143 :
144 : // allow access to MEM driver's private internal memory buffer
145 0 : GByte *GetData(void) const {return(pabyData);}
146 : };
147 :
148 : #endif /* ndef MEMDATASET_H_INCLUDED */
149 :
|