/src/gdal/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.h
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: KmlSuperOverlay |
4 | | * Purpose: Implements write support for KML superoverlay - KMZ. |
5 | | * Author: Harsh Govind, harsh.govind@spadac.com |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 2010, SPADAC Inc. <harsh.govind@spadac.com> |
9 | | * Copyright (c) 2012, Even Rouault <even dot rouault at spatialys.com> |
10 | | * |
11 | | * SPDX-License-Identifier: MIT |
12 | | ****************************************************************************/ |
13 | | |
14 | | #ifndef KMLSUPEROVERLAYDATASET_H_INCLUDED |
15 | | #define KMLSUPEROVERLAYDATASET_H_INCLUDED |
16 | | |
17 | | #include <array> |
18 | | #include <map> |
19 | | |
20 | | #include "cpl_minixml.h" |
21 | | #include "gdal_pam.h" |
22 | | #include "gdal_priv.h" |
23 | | |
24 | | /************************************************************************/ |
25 | | /* KmlSuperOverlayReadDataset */ |
26 | | /************************************************************************/ |
27 | | class KmlSuperOverlayRasterBand; |
28 | | class KmlSuperOverlayReadDataset; |
29 | | |
30 | | class LinkedDataset; |
31 | | |
32 | | class LinkedDataset |
33 | | { |
34 | | public: |
35 | | KmlSuperOverlayReadDataset *poDS = nullptr; |
36 | | LinkedDataset *psPrev = nullptr; |
37 | | LinkedDataset *psNext = nullptr; |
38 | | CPLString osSubFilename{}; |
39 | | |
40 | 0 | LinkedDataset() = default; |
41 | | |
42 | | private: |
43 | | LinkedDataset(const LinkedDataset &) = delete; |
44 | | LinkedDataset &operator=(const LinkedDataset &) = delete; |
45 | | }; |
46 | | |
47 | | class KmlSuperOverlayReadDataset final : public GDALDataset |
48 | | { |
49 | | friend class KmlSuperOverlayRasterBand; |
50 | | |
51 | | OGRSpatialReference m_oSRS{}; |
52 | | int nFactor = 1; |
53 | | CPLString osFilename{}; |
54 | | CPLXMLNode *psRoot = nullptr; |
55 | | CPLXMLNode *psDocument = nullptr; |
56 | | std::unique_ptr<GDALDataset> poDSIcon{}; |
57 | | GDALGeoTransform m_gt{}; |
58 | | |
59 | | std::vector<std::unique_ptr<KmlSuperOverlayReadDataset>> m_apoOverviewDS{}; |
60 | | bool bIsOvr = false; |
61 | | |
62 | | KmlSuperOverlayReadDataset *poParent = nullptr; |
63 | | |
64 | | std::map<CPLString, LinkedDataset *> oMapChildren{}; |
65 | | LinkedDataset *psFirstLink = nullptr; |
66 | | LinkedDataset *psLastLink = nullptr; |
67 | | |
68 | | KmlSuperOverlayReadDataset(const KmlSuperOverlayReadDataset &) = delete; |
69 | | KmlSuperOverlayReadDataset & |
70 | | operator=(const KmlSuperOverlayReadDataset &) = delete; |
71 | | |
72 | | protected: |
73 | | virtual int CloseDependentDatasets() override; |
74 | | |
75 | | public: |
76 | | KmlSuperOverlayReadDataset(); |
77 | | virtual ~KmlSuperOverlayReadDataset(); |
78 | | |
79 | | static int Identify(GDALOpenInfo *); |
80 | | static GDALDataset *Open(const char *pszFilename, |
81 | | KmlSuperOverlayReadDataset *poParent = nullptr, |
82 | | int nRec = 0); |
83 | | static GDALDataset *Open(GDALOpenInfo *); |
84 | | |
85 | | static const int KMLSO_ContainsOpaquePixels = 0x1; |
86 | | static const int KMLSO_ContainsTransparentPixels = 0x2; |
87 | | static const int KMLSO_ContainsPartiallyTransparentPixels = 0x4; |
88 | | |
89 | | static int DetectTransparency(int rxsize, int rysize, int rx, int ry, |
90 | | int dxsize, int dysize, GDALDataset *poSrcDs); |
91 | | |
92 | | virtual CPLErr GetGeoTransform(GDALGeoTransform >) const override; |
93 | | const OGRSpatialReference *GetSpatialRef() const override; |
94 | | |
95 | | virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, |
96 | | int nXSize, int nYSize, void *pData, int nBufXSize, |
97 | | int nBufYSize, GDALDataType eBufType, |
98 | | int nBandCount, BANDMAP_TYPE panBandMap, |
99 | | GSpacing nPixelSpace, GSpacing nLineSpace, |
100 | | GSpacing nBandSpace, |
101 | | GDALRasterIOExtraArg *psExtraArg) override; |
102 | | }; |
103 | | |
104 | | /************************************************************************/ |
105 | | /* KmlSuperOverlayRasterBand */ |
106 | | /************************************************************************/ |
107 | | |
108 | | class KmlSuperOverlayRasterBand final : public GDALRasterBand |
109 | | { |
110 | | public: |
111 | | KmlSuperOverlayRasterBand(KmlSuperOverlayReadDataset *poDS, int nBand); |
112 | | |
113 | | protected: |
114 | | virtual CPLErr IReadBlock(int, int, void *) override; |
115 | | virtual CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int, |
116 | | GDALDataType, GSpacing nPixelSpace, |
117 | | GSpacing nLineSpace, |
118 | | GDALRasterIOExtraArg *psExtraArg) override; |
119 | | virtual GDALColorInterp GetColorInterpretation() override; |
120 | | |
121 | | virtual int GetOverviewCount() override; |
122 | | virtual GDALRasterBand *GetOverview(int) override; |
123 | | }; |
124 | | |
125 | | #endif /* ndef KMLSUPEROVERLAYDATASET_H_INCLUDED */ |