00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef PCIDSKDATASET2_H_INCLUDED
00033 #define PCIDSKDATASET2_H_INCLUDED
00034
00035 #define GDAL_PCIDSK_DRIVER
00036
00037 #include "cpl_string.h"
00038 #include "gdal_pam.h"
00039 #include "ogrsf_frmts.h"
00040 #include "ogr_spatialref.h"
00041 #include "pcidsk.h"
00042 #include "pcidsk_pct.h"
00043 #include "pcidsk_vectorsegment.h"
00044
00045 using namespace PCIDSK;
00046
00047 class OGRPCIDSKLayer;
00048
00049
00050
00051
00052
00053 class PCIDSK2Dataset : public GDALPamDataset
00054 {
00055 friend class PCIDSK2Band;
00056
00057 CPLString osSRS;
00058 CPLString osLastMDValue;
00059 char **papszLastMDListValue;
00060
00061 PCIDSK::PCIDSKFile *poFile;
00062
00063 std::vector<OGRPCIDSKLayer*> apoLayers;
00064
00065 static GDALDataType PCIDSKTypeToGDAL( PCIDSK::eChanType eType );
00066 void ProcessRPC();
00067
00068 public:
00069 PCIDSK2Dataset();
00070 ~PCIDSK2Dataset();
00071
00072 static int Identify( GDALOpenInfo * );
00073 static GDALDataset *Open( GDALOpenInfo * );
00074 static GDALDataset *LLOpen( const char *pszFilename, PCIDSK::PCIDSKFile *,
00075 GDALAccess eAccess,
00076 char** papszSiblingFiles = NULL );
00077 static GDALDataset *Create( const char * pszFilename,
00078 int nXSize, int nYSize, int nBands,
00079 GDALDataType eType,
00080 char **papszParmList );
00081
00082 char **GetFileList(void);
00083 CPLErr GetGeoTransform( double * padfTransform );
00084 CPLErr SetGeoTransform( double * );
00085 const char *GetProjectionRef();
00086 CPLErr SetProjection( const char * );
00087
00088 virtual char **GetMetadataDomainList();
00089 CPLErr SetMetadata( char **, const char * );
00090 char **GetMetadata( const char* );
00091 CPLErr SetMetadataItem(const char*,const char*,const char*);
00092 const char *GetMetadataItem( const char*, const char*);
00093
00094 virtual void FlushCache(void);
00095
00096 virtual CPLErr IBuildOverviews( const char *, int, int *,
00097 int, int *, GDALProgressFunc, void * );
00098
00099 virtual int GetLayerCount() { return (int) apoLayers.size(); }
00100 virtual OGRLayer *GetLayer( int );
00101
00102 virtual int TestCapability( const char * );
00103
00104 virtual OGRLayer *ICreateLayer( const char *, OGRSpatialReference *,
00105 OGRwkbGeometryType, char ** );
00106 };
00107
00108
00109
00110
00111
00112 class PCIDSK2Band : public GDALPamRasterBand
00113 {
00114 friend class PCIDSK2Dataset;
00115
00116 PCIDSK::PCIDSKChannel *poChannel;
00117 PCIDSK::PCIDSKFile *poFile;
00118
00119 void RefreshOverviewList();
00120 std::vector<PCIDSK2Band*> apoOverviews;
00121
00122 CPLString osLastMDValue;
00123 char **papszLastMDListValue;
00124
00125 bool CheckForColorTable();
00126 GDALColorTable *poColorTable;
00127 bool bCheckedForColorTable;
00128 int nPCTSegNumber;
00129
00130 char **papszCategoryNames;
00131
00132 void Initialize();
00133
00134 public:
00135 PCIDSK2Band( PCIDSK2Dataset *, PCIDSK::PCIDSKFile *, int );
00136 PCIDSK2Band( PCIDSK::PCIDSKChannel * );
00137 ~PCIDSK2Band();
00138
00139 virtual CPLErr IReadBlock( int, int, void * );
00140 virtual CPLErr IWriteBlock( int, int, void * );
00141
00142 virtual int GetOverviewCount();
00143 virtual GDALRasterBand *GetOverview(int);
00144
00145 virtual GDALColorInterp GetColorInterpretation();
00146 virtual GDALColorTable *GetColorTable();
00147 virtual CPLErr SetColorTable( GDALColorTable * );
00148
00149 virtual void SetDescription( const char * );
00150
00151 virtual char **GetMetadataDomainList();
00152 CPLErr SetMetadata( char **, const char * );
00153 char **GetMetadata( const char* );
00154 CPLErr SetMetadataItem(const char*,const char*,const char*);
00155 const char *GetMetadataItem( const char*, const char*);
00156
00157 virtual char **GetCategoryNames();
00158 };
00159
00160
00161
00162
00163
00164 class OGRPCIDSKLayer : public OGRLayer
00165 {
00166 PCIDSK::PCIDSKVectorSegment *poVecSeg;
00167 PCIDSK::PCIDSKSegment *poSeg;
00168
00169 OGRFeatureDefn *poFeatureDefn;
00170
00171 OGRFeature * GetNextUnfilteredFeature();
00172
00173 int iRingStartField;
00174 PCIDSK::ShapeId hLastShapeId;
00175
00176 bool bUpdateAccess;
00177
00178 OGRSpatialReference *poSRS;
00179
00180 public:
00181 OGRPCIDSKLayer( PCIDSK::PCIDSKSegment*, PCIDSK::PCIDSKVectorSegment *, bool bUpdate );
00182 ~OGRPCIDSKLayer();
00183
00184 void ResetReading();
00185 OGRFeature * GetNextFeature();
00186 OGRFeature *GetFeature( GIntBig nFeatureId );
00187 virtual OGRErr ISetFeature( OGRFeature *poFeature );
00188
00189 OGRFeatureDefn * GetLayerDefn() { return poFeatureDefn; }
00190
00191 int TestCapability( const char * );
00192
00193 OGRErr DeleteFeature( GIntBig nFID );
00194 virtual OGRErr ICreateFeature( OGRFeature *poFeature );
00195 virtual OGRErr CreateField( OGRFieldDefn *poField,
00196 int bApproxOK = TRUE );
00197
00198 GIntBig GetFeatureCount( int );
00199 OGRErr GetExtent( OGREnvelope *psExtent, int bForce );
00200 virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce)
00201 { return OGRLayer::GetExtent(iGeomField, psExtent, bForce); }
00202 };
00203
00204 #endif