102
117
PCIDSK::PCIDSKSegment *segobj;
104
poFile = PCIDSK::Open( pszFilename, "r", NULL );
118
const char *pszAccess = "r";
123
poFile = PCIDSK::Open( pszFilename, pszAccess,
124
PCIDSK2GetInterfaces() );
106
126
for( segobj = poFile->GetSegment( PCIDSK::SEG_VEC, "" );
108
128
segobj = poFile->GetSegment( PCIDSK::SEG_VEC, "",
109
129
segobj->GetSegmentNumber() ) )
111
apoLayers.push_back( new OGRPCIDSKLayer( segobj ) );
131
apoLayers.push_back( new OGRPCIDSKLayer( segobj, bUpdate ) );
134
/* Check if this is a raster-only PCIDSK file */
135
if ( !bUpdate && apoLayers.size() == 0 && poFile->GetChannels() != 0 )
115
139
/* -------------------------------------------------------------------- */
131
/* -------------------------------------------------------------------- */
132
/* We presume that this is indeed intended to be a PCIDSK */
133
/* datasource if over half the files were .csv files. */
134
/* -------------------------------------------------------------------- */
158
/************************************************************************/
160
/************************************************************************/
163
OGRPCIDSKDataSource::CreateLayer( const char * pszLayerName,
164
OGRSpatialReference *poSRS,
165
OGRwkbGeometryType eType,
166
char ** papszOptions )
169
/* -------------------------------------------------------------------- */
170
/* Verify we are in update mode. */
171
/* -------------------------------------------------------------------- */
174
CPLError( CE_Failure, CPLE_NoWriteAccess,
175
"Data source %s opened read-only.\n"
176
"New layer %s cannot be created.\n",
177
osName.c_str(), pszLayerName );
182
/* -------------------------------------------------------------------- */
183
/* Figure out what type of layer we need. */
184
/* -------------------------------------------------------------------- */
185
std::string osLayerType;
187
switch( wkbFlatten(eType) )
190
osLayerType = "POINTS";
194
osLayerType = "ARCS";
198
osLayerType = "WHOLE_POLYGONS";
202
osLayerType = "TABLE";
209
/* -------------------------------------------------------------------- */
210
/* Create the segment. */
211
/* -------------------------------------------------------------------- */
212
int nSegNum = poFile->CreateSegment( pszLayerName, "",
213
PCIDSK::SEG_VEC, 0L );
214
PCIDSK::PCIDSKSegment *poSeg = poFile->GetSegment( nSegNum );
215
PCIDSK::PCIDSKVectorSegment *poVecSeg =
216
dynamic_cast<PCIDSK::PCIDSKVectorSegment*>( poSeg );
218
if( osLayerType != "" )
219
poSeg->SetMetadataValue( "LAYER_TYPE", osLayerType );
221
/* -------------------------------------------------------------------- */
222
/* Do we need to apply a coordinate system? */
223
/* -------------------------------------------------------------------- */
224
char *pszGeosys = NULL;
225
char *pszUnits = NULL;
226
double *padfPrjParams = NULL;
229
&& poSRS->exportToPCI( &pszGeosys, &pszUnits,
230
&padfPrjParams ) == OGRERR_NONE )
234
std::vector<double> adfPCIParameters;
237
for( i = 0; i < 17; i++ )
238
adfPCIParameters.push_back( padfPrjParams[i] );
240
if( EQUALN(pszUnits,"FOOT",4) )
241
adfPCIParameters.push_back(
242
(double)(int) PCIDSK::UNIT_US_FOOT );
243
else if( EQUALN(pszUnits,"INTL FOOT",9) )
244
adfPCIParameters.push_back(
245
(double)(int) PCIDSK::UNIT_INTL_FOOT );
246
else if( EQUALN(pszUnits,"DEGREE",6) )
247
adfPCIParameters.push_back(
248
(double)(int) PCIDSK::UNIT_DEGREE );
250
adfPCIParameters.push_back(
251
(double)(int) PCIDSK::UNIT_METER );
253
poVecSeg->SetProjection( pszGeosys, adfPCIParameters );
255
catch( PCIDSK::PCIDSKException ex )
257
CPLError( CE_Failure, CPLE_AppDefined,
261
CPLFree( pszGeosys );
263
CPLFree( padfPrjParams );
266
/* -------------------------------------------------------------------- */
267
/* Create the layer object. */
268
/* -------------------------------------------------------------------- */
269
apoLayers.push_back( new OGRPCIDSKLayer( poSeg, TRUE ) );
271
return apoLayers[apoLayers.size()-1];