1 : /******************************************************************************
2 : * $Id: rasterlitedataset.h 21723 2011-02-15 19:52:18Z rouault $
3 : *
4 : * Project: GDAL Rasterlite driver
5 : * Purpose: Implement GDAL Rasterlite support using OGR SQLite driver
6 : * Author: Even Rouault, <even dot rouault at mines dash paris dot org>
7 : *
8 : **********************************************************************
9 : * Copyright (c) 2009, Even Rouault, <even dot rouault at mines dash paris dot org>
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 RASTERLITE_DATASET_INCLUDED
31 : #define RASTERLITE_DATASET_INCLUDED
32 :
33 : #include "gdal_pam.h"
34 :
35 : class RasterliteBand;
36 :
37 : /************************************************************************/
38 : /* ==================================================================== */
39 : /* RasterliteDataset */
40 : /* ==================================================================== */
41 : /************************************************************************/
42 :
43 : class RasterliteDataset : public GDALPamDataset
44 : {
45 : friend class RasterliteBand;
46 :
47 : public:
48 : RasterliteDataset();
49 : RasterliteDataset(RasterliteDataset* poMainDS, int nLevel);
50 :
51 : virtual ~RasterliteDataset();
52 :
53 : virtual char **GetMetadata( const char *pszDomain );
54 : virtual const char *GetMetadataItem( const char *pszName,
55 : const char *pszDomain );
56 : virtual CPLErr GetGeoTransform( double* padfGeoTransform );
57 : virtual const char* GetProjectionRef();
58 :
59 : virtual char** GetFileList();
60 :
61 : virtual CPLErr IBuildOverviews( const char * pszResampling,
62 : int nOverviews, int * panOverviewList,
63 : int nBands, int * panBandList,
64 : GDALProgressFunc pfnProgress, void * pProgressData );
65 :
66 : static GDALDataset *Open( GDALOpenInfo * );
67 : static int Identify( GDALOpenInfo * );
68 :
69 : protected:
70 : virtual int CloseDependentDatasets();
71 :
72 : private:
73 :
74 : int bMustFree;
75 : RasterliteDataset* poMainDS;
76 : int nLevel;
77 :
78 : char** papszMetadata;
79 : char** papszImageStructure;
80 : char** papszSubDatasets;
81 :
82 : int nResolutions;
83 : double* padfXResolutions, *padfYResolutions;
84 : RasterliteDataset** papoOverviews;
85 : int nLimitOvrCount;
86 :
87 : int bValidGeoTransform;
88 : double adfGeoTransform[6];
89 : char* pszSRS;
90 :
91 : GDALColorTable* poCT;
92 :
93 : CPLString osTableName;
94 : CPLString osFileName;
95 :
96 : int bCheckForExistingOverview;
97 : CPLString osOvrFileName;
98 :
99 : OGRDataSourceH hDS;
100 :
101 : void AddSubDataset( const char* pszDSName);
102 : int GetBlockParams(OGRLayerH hRasterLyr, int nLevel, int* pnBands,
103 : GDALDataType* peDataType,
104 : int* pnBlockXSize, int* pnBlockYSize);
105 : CPLErr CleanOverviews();
106 : CPLErr CleanOverviewLevel(int nOvrFactor);
107 : CPLErr ReloadOverviews();
108 : CPLErr CreateOverviewLevel(int nOvrFactor,
109 : GDALProgressFunc pfnProgress,
110 : void * pProgressData);
111 : };
112 :
113 : /************************************************************************/
114 : /* ==================================================================== */
115 : /* RasterliteBand */
116 : /* ==================================================================== */
117 : /************************************************************************/
118 :
119 : class RasterliteBand: public GDALPamRasterBand
120 53 : {
121 : friend class RasterliteDataset;
122 :
123 : public:
124 : RasterliteBand( RasterliteDataset* poDS, int nBand,
125 : GDALDataType eDataType,
126 : int nBlockXSize, int nBlockYSize);
127 :
128 : virtual GDALColorInterp GetColorInterpretation();
129 : virtual GDALColorTable* GetColorTable();
130 :
131 : virtual int GetOverviewCount();
132 : virtual GDALRasterBand* GetOverview(int nLevel);
133 :
134 : virtual CPLErr IReadBlock( int, int, void * );
135 : };
136 :
137 : GDALDataset *
138 : RasterliteCreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
139 : int bStrict, char ** papszOptions,
140 : GDALProgressFunc pfnProgress, void * pProgressData );
141 :
142 : CPLErr RasterliteDelete(const char* pszFilename);
143 :
144 : #endif // RASTERLITE_DATASET_INCLUDED
|