1 : /******************************************************************************
2 : * $Id: kmlsuperoverlaydataset.h
3 : *
4 : * Project: KmlSuperOverlay
5 : * Purpose: Implements write support for KML superoverlay - KMZ.
6 : * Author: Harsh Govind, harsh.govind@spadac.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2010, SPADAC Inc. <harsh.govind@spadac.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 : #ifndef KMLSUPEROVERLAYDATASET_H_INCLUDED
31 : #define KMLSUPEROVERLAYDATASET_H_INCLUDED
32 :
33 : #include "gdal_pam.h"
34 : #include "gdal_priv.h"
35 : #include "cpl_minixml.h"
36 : #include <map>
37 :
38 : CPL_C_START
39 : void CPL_DLL GDALRegister_KMLSUPEROVERLAY(void);
40 : CPL_C_END
41 :
42 : /************************************************************************/
43 : /* KmlSuperOverlayReadDataset */
44 : /************************************************************************/
45 : class KmlSuperOverlayRasterBand;
46 : class KmlSuperOverlayReadDataset;
47 :
48 : class LinkedDataset;
49 : class LinkedDataset
50 8 : {
51 : public:
52 : KmlSuperOverlayReadDataset* poDS;
53 : LinkedDataset* psPrev;
54 : LinkedDataset* psNext;
55 : CPLString osSubFilename;
56 : };
57 :
58 : class KmlSuperOverlayReadDataset : public GDALDataset
59 : {
60 : friend class KmlSuperOverlayRasterBand;
61 :
62 : int nFactor;
63 : CPLString osFilename;
64 : CPLXMLNode *psRoot;
65 : CPLXMLNode *psDocument;
66 : GDALDataset *poDSIcon;
67 : double adfGeoTransform[6];
68 :
69 : int nOverviewCount;
70 : KmlSuperOverlayReadDataset** papoOverviewDS;
71 : int bIsOvr;
72 :
73 : KmlSuperOverlayReadDataset* poParent;
74 :
75 : std::map<CPLString, LinkedDataset*> oMapChildren;
76 : LinkedDataset *psFirstLink;
77 : LinkedDataset *psLastLink;
78 :
79 : protected:
80 : virtual int CloseDependentDatasets();
81 :
82 : public:
83 : KmlSuperOverlayReadDataset();
84 : virtual ~KmlSuperOverlayReadDataset();
85 :
86 : static int Identify(GDALOpenInfo *);
87 : static GDALDataset *Open(const char* pszFilename, KmlSuperOverlayReadDataset* poParent = NULL, int nRec = 0);
88 : static GDALDataset *Open(GDALOpenInfo *);
89 :
90 : virtual CPLErr GetGeoTransform( double * );
91 : virtual const char *GetProjectionRef();
92 :
93 : virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
94 : int nXOff, int nYOff, int nXSize, int nYSize,
95 : void * pData, int nBufXSize, int nBufYSize,
96 : GDALDataType eBufType,
97 : int nBandCount, int *panBandMap,
98 : int nPixelSpace, int nLineSpace, int nBandSpace);
99 : };
100 :
101 : /************************************************************************/
102 : /* KmlSuperOverlayRasterBand */
103 : /************************************************************************/
104 :
105 : class KmlSuperOverlayRasterBand: public GDALRasterBand
106 100 : {
107 : public:
108 : KmlSuperOverlayRasterBand(KmlSuperOverlayReadDataset* poDS, int nBand);
109 : protected:
110 :
111 : virtual CPLErr IReadBlock( int, int, void * );
112 : virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
113 : void *, int, int, GDALDataType,
114 : int, int );
115 : virtual GDALColorInterp GetColorInterpretation();
116 :
117 : virtual int GetOverviewCount();
118 : virtual GDALRasterBand *GetOverview(int);
119 : };
120 :
121 : #endif /* ndef KMLSUPEROVERLAYDATASET_H_INCLUDED */
122 :
|