My Project
pcidskdataset2.h
1/******************************************************************************
2 * $Id$
3 *
4 * Project: PCIDSK Database File
5 * Purpose: Read/write PCIDSK Database File used by the PCI software, using
6 * the external PCIDSK library.
7 * Author: Frank Warmerdam, warmerdam@pobox.com
8 *
9 ******************************************************************************
10 * Copyright (c) 2009, Frank Warmerdam <warmerdam@pobox.com>
11 * Copyright (c) 2009-2013, Even Rouault <even dot rouault at mines-paris dot org>
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included
21 * in all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 * DEALINGS IN THE SOFTWARE.
30 ****************************************************************************/
31
32#ifndef PCIDSKDATASET2_H_INCLUDED
33#define PCIDSKDATASET2_H_INCLUDED
34
35#define GDAL_PCIDSK_DRIVER
36
37#include "cpl_string.h"
38#include "gdal_pam.h"
39#include "ogrsf_frmts.h"
40#include "ogr_spatialref.h"
41#include "pcidsk.h"
42#include "pcidsk_pct.h"
43#include "pcidsk_vectorsegment.h"
44
45using namespace PCIDSK;
46
47class OGRPCIDSKLayer;
48
49/************************************************************************/
50/* PCIDSK2Dataset */
51/************************************************************************/
52
53class PCIDSK2Dataset final: public GDALPamDataset
54{
55 friend class PCIDSK2Band;
56
57 CPLString osSRS;
58 CPLString osLastMDValue;
59 char **papszLastMDListValue;
60
61 PCIDSK::PCIDSKFile *poFile;
62
63 std::vector<OGRPCIDSKLayer*> apoLayers;
64
65 static GDALDataType PCIDSKTypeToGDAL( PCIDSK::eChanType eType );
66 void ProcessRPC();
67
68 public:
70 virtual ~PCIDSK2Dataset();
71
72 static int Identify( GDALOpenInfo * );
73 static GDALDataset *Open( GDALOpenInfo * );
74 static GDALDataset *LLOpen( const char *pszFilename, PCIDSK::PCIDSKFile *,
75 GDALAccess eAccess,
76 char** papszSiblingFiles = nullptr );
77 static GDALDataset *Create( const char * pszFilename,
78 int nXSize, int nYSize, int nBands,
79 GDALDataType eType,
80 char **papszParmList );
81
82 char **GetFileList() override;
83 CPLErr GetGeoTransform( double * padfTransform ) override;
84 CPLErr SetGeoTransform( double * ) override;
85 const char *GetProjectionRef() override;
86 CPLErr SetProjection( const char * ) override;
87
88 virtual char **GetMetadataDomainList() override;
89 CPLErr SetMetadata( char **, const char * ) override;
90 char **GetMetadata( const char* ) override;
91 CPLErr SetMetadataItem(const char*,const char*,const char*) override;
92 const char *GetMetadataItem( const char*, const char*) override;
93
94 virtual void FlushCache() override;
95
96 virtual CPLErr IBuildOverviews( const char *, int, int *,
97 int, int *, GDALProgressFunc, void * ) override;
98
99 virtual int GetLayerCount() override { return (int) apoLayers.size(); }
100 virtual OGRLayer *GetLayer( int ) override;
101
102 virtual int TestCapability( const char * ) override;
103
104 virtual OGRLayer *ICreateLayer( const char *, OGRSpatialReference *,
105 OGRwkbGeometryType, char ** ) override;
106};
107
108/************************************************************************/
109/* PCIDSK2Band */
110/************************************************************************/
111
112class PCIDSK2Band final: public GDALPamRasterBand
113{
114 friend class PCIDSK2Dataset;
115
116 PCIDSK::PCIDSKChannel *poChannel;
117 PCIDSK::PCIDSKFile *poFile;
118
119 void RefreshOverviewList();
120 std::vector<PCIDSK2Band*> apoOverviews;
121
122 CPLString osLastMDValue;
123 char **papszLastMDListValue;
124
125 bool CheckForColorTable();
126 GDALColorTable *poColorTable;
127 bool bCheckedForColorTable;
128 int nPCTSegNumber;
129
130 char **papszCategoryNames;
131
132 void Initialize();
133
134 public:
135 PCIDSK2Band( PCIDSK::PCIDSKFile *poFileIn,
136 PCIDSK::PCIDSKChannel *poChannelIn );
137 explicit PCIDSK2Band( PCIDSK::PCIDSKChannel * );
138 virtual ~PCIDSK2Band();
139
140 virtual CPLErr IReadBlock( int, int, void * ) override;
141 virtual CPLErr IWriteBlock( int, int, void * ) override;
142
143 virtual int GetOverviewCount() override;
144 virtual GDALRasterBand *GetOverview(int) override;
145
146 virtual GDALColorInterp GetColorInterpretation() override;
147 virtual GDALColorTable *GetColorTable() override;
148 virtual CPLErr SetColorTable( GDALColorTable * ) override;
149
150 virtual void SetDescription( const char * ) override;
151
152 virtual char **GetMetadataDomainList() override;
153 CPLErr SetMetadata( char **, const char * ) override;
154 char **GetMetadata( const char* ) override;
155 CPLErr SetMetadataItem(const char*,const char*,const char*) override;
156 const char *GetMetadataItem( const char*, const char*) override;
157
158 virtual char **GetCategoryNames() override;
159};
160
161/************************************************************************/
162/* OGRPCIDSKLayer */
163/************************************************************************/
164
165class OGRPCIDSKLayer final: public OGRLayer
166{
167 PCIDSK::PCIDSKVectorSegment *poVecSeg;
168 PCIDSK::PCIDSKSegment *poSeg;
169
170 OGRFeatureDefn *poFeatureDefn;
171
172 OGRFeature * GetNextUnfilteredFeature();
173
174 int iRingStartField;
175 PCIDSK::ShapeId hLastShapeId;
176
177 bool bUpdateAccess;
178
179 OGRSpatialReference *poSRS;
180
181 public:
182 OGRPCIDSKLayer( PCIDSK::PCIDSKSegment*, PCIDSK::PCIDSKVectorSegment *, bool bUpdate );
183 virtual ~OGRPCIDSKLayer();
184
185 void ResetReading() override;
186 OGRFeature * GetNextFeature() override;
187 OGRFeature *GetFeature( GIntBig nFeatureId ) override;
188 virtual OGRErr ISetFeature( OGRFeature *poFeature ) override;
189
190 OGRFeatureDefn * GetLayerDefn() override { return poFeatureDefn; }
191
192 int TestCapability( const char * ) override;
193
194 OGRErr DeleteFeature( GIntBig nFID ) override;
195 virtual OGRErr ICreateFeature( OGRFeature *poFeature ) override;
196 virtual OGRErr CreateField( OGRFieldDefn *poField,
197 int bApproxOK = TRUE ) override;
198
199 GIntBig GetFeatureCount( int ) override;
200 OGRErr GetExtent( OGREnvelope *psExtent, int bForce ) override;
201 virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce) override
202 { return OGRLayer::GetExtent(iGeomField, psExtent, bForce); }
203};
204
205#endif /* PCIDSKDATASET2_H_INCLUDED */
Definition: pcidskdataset2.h:166
Definition: pcidskdataset2.h:113
Definition: pcidskdataset2.h:54