1 : /******************************************************************************
2 : * $Id: rasterlitedataset.h 17720 2009-09-30 22:32:20Z 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 : private:
70 :
71 : int bMustFree;
72 : RasterliteDataset* poMainDS;
73 : int nLevel;
74 :
75 : char** papszMetadata;
76 : char** papszImageStructure;
77 : char** papszSubDatasets;
78 :
79 : int nResolutions;
80 : double* padfXResolutions, *padfYResolutions;
81 : RasterliteDataset** papoOverviews;
82 : int nLimitOvrCount;
83 :
84 : int bValidGeoTransform;
85 : double adfGeoTransform[6];
86 : char* pszSRS;
87 :
88 : GDALColorTable* poCT;
89 :
90 : CPLString osTableName;
91 : CPLString osFileName;
92 :
93 : int bCheckForExistingOverview;
94 : CPLString osOvrFileName;
95 :
96 : OGRDataSourceH hDS;
97 :
98 : void AddSubDataset( const char* pszDSName);
99 : int GetBlockParams(OGRLayerH hRasterLyr, int nLevel, int* pnBands,
100 : GDALDataType* peDataType,
101 : int* pnBlockXSize, int* pnBlockYSize);
102 : CPLErr CleanOverviews();
103 : CPLErr CleanOverviewLevel(int nOvrFactor);
104 : CPLErr ReloadOverviews();
105 : CPLErr CreateOverviewLevel(int nOvrFactor,
106 : GDALProgressFunc pfnProgress,
107 : void * pProgressData);
108 : };
109 :
110 : /************************************************************************/
111 : /* ==================================================================== */
112 : /* RasterliteBand */
113 : /* ==================================================================== */
114 : /************************************************************************/
115 :
116 : class RasterliteBand: public GDALPamRasterBand
117 57 : {
118 : friend class RasterliteDataset;
119 :
120 : public:
121 : RasterliteBand( RasterliteDataset* poDS, int nBand,
122 : GDALDataType eDataType,
123 : int nBlockXSize, int nBlockYSize);
124 :
125 : virtual GDALColorInterp GetColorInterpretation();
126 : virtual GDALColorTable* GetColorTable();
127 :
128 : virtual int GetOverviewCount();
129 : virtual GDALRasterBand* GetOverview(int nLevel);
130 :
131 : virtual CPLErr IReadBlock( int, int, void * );
132 : };
133 :
134 : GDALDataset *
135 : RasterliteCreateCopy( const char * pszFilename, GDALDataset *poSrcDS,
136 : int bStrict, char ** papszOptions,
137 : GDALProgressFunc pfnProgress, void * pProgressData );
138 :
139 : CPLErr RasterliteDelete(const char* pszFilename);
140 :
141 : #endif // RASTERLITE_DATASET_INCLUDED
|