My Project
pcidskdataset2.h
1 /******************************************************************************
2  * $Id: pcidskdataset2.h 36501 2016-11-25 14:09:24Z rouault $
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 
45 using namespace PCIDSK;
46 
47 class OGRPCIDSKLayer;
48 
49 /************************************************************************/
50 /* PCIDSK2Dataset */
51 /************************************************************************/
52 
53 class PCIDSK2Dataset : 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 = NULL );
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 
112 class PCIDSK2Band : 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( PCIDSK2Dataset *, PCIDSK::PCIDSKFile *, int );
136  explicit PCIDSK2Band( PCIDSK::PCIDSKChannel * );
137  virtual ~PCIDSK2Band();
138 
139  virtual CPLErr IReadBlock( int, int, void * ) override;
140  virtual CPLErr IWriteBlock( int, int, void * ) override;
141 
142  virtual int GetOverviewCount() override;
143  virtual GDALRasterBand *GetOverview(int) override;
144 
145  virtual GDALColorInterp GetColorInterpretation() override;
146  virtual GDALColorTable *GetColorTable() override;
147  virtual CPLErr SetColorTable( GDALColorTable * ) override;
148 
149  virtual void SetDescription( const char * ) override;
150 
151  virtual char **GetMetadataDomainList() override;
152  CPLErr SetMetadata( char **, const char * ) override;
153  char **GetMetadata( const char* ) override;
154  CPLErr SetMetadataItem(const char*,const char*,const char*) override;
155  const char *GetMetadataItem( const char*, const char*) override;
156 
157  virtual char **GetCategoryNames() override;
158 };
159 
160 /************************************************************************/
161 /* OGRPCIDSKLayer */
162 /************************************************************************/
163 
164 class OGRPCIDSKLayer : public OGRLayer
165 {
166  PCIDSK::PCIDSKVectorSegment *poVecSeg;
167  PCIDSK::PCIDSKSegment *poSeg;
168 
169  OGRFeatureDefn *poFeatureDefn;
170 
171  OGRFeature * GetNextUnfilteredFeature();
172 
173  int iRingStartField;
174  PCIDSK::ShapeId hLastShapeId;
175 
176  bool bUpdateAccess;
177 
178  OGRSpatialReference *poSRS;
179 
180  public:
181  OGRPCIDSKLayer( PCIDSK::PCIDSKSegment*, PCIDSK::PCIDSKVectorSegment *, bool bUpdate );
182  virtual ~OGRPCIDSKLayer();
183 
184  void ResetReading() override;
185  OGRFeature * GetNextFeature() override;
186  OGRFeature *GetFeature( GIntBig nFeatureId ) override;
187  virtual OGRErr ISetFeature( OGRFeature *poFeature ) override;
188 
189  OGRFeatureDefn * GetLayerDefn() override { return poFeatureDefn; }
190 
191  int TestCapability( const char * ) override;
192 
193  OGRErr DeleteFeature( GIntBig nFID ) override;
194  virtual OGRErr ICreateFeature( OGRFeature *poFeature ) override;
195  virtual OGRErr CreateField( OGRFieldDefn *poField,
196  int bApproxOK = TRUE ) override;
197 
198  GIntBig GetFeatureCount( int ) override;
199  OGRErr GetExtent( OGREnvelope *psExtent, int bForce ) override;
200  virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce) override
201  { return OGRLayer::GetExtent(iGeomField, psExtent, bForce); }
202 };
203 
204 #endif /* PCIDSKDATASET2_H_INCLUDED */
Definition: pcidskdataset2.h:164
Definition: pcidskdataset2.h:112
Definition: pcidskdataset2.h:53