Skip to content

Commit 8868c95

Browse files
author
mhugent
committedNov 18, 2010
Also write features without geometry in vector filewriter
git-svn-id: http://svn.osgeo.org/qgis/trunk@14712 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2a3a087 commit 8868c95

File tree

1 file changed

+103
-112
lines changed

1 file changed

+103
-112
lines changed
 

‎src/core/qgsvectorfilewriter.cpp

Lines changed: 103 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ QgsVectorFileWriter::QgsVectorFileWriter(
5353
const QStringList &datasourceOptions,
5454
const QStringList &layerOptions
5555
)
56-
: mDS( NULL )
57-
, mLayer( NULL )
58-
, mGeom( NULL )
59-
, mError( NoError )
56+
: mDS( NULL )
57+
, mLayer( NULL )
58+
, mGeom( NULL )
59+
, mError( NoError )
6060
{
6161
QString vectorFileName = theVectorFileName;
6262
QString fileEncoding = theFileEncoding;
@@ -66,7 +66,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
6666
QgsApplication::registerOgrDrivers();
6767
poDriver = OGRGetDriverByName( driverName.toLocal8Bit().data() );
6868

69-
if( poDriver == NULL )
69+
if ( poDriver == NULL )
7070
{
7171
mErrorMessage = QObject::tr( "OGR driver for '%1' not found (OGR error: %2)" )
7272
.arg( driverName )
@@ -75,20 +75,20 @@ QgsVectorFileWriter::QgsVectorFileWriter(
7575
return;
7676
}
7777

78-
if( driverName == "ESRI Shapefile" )
78+
if ( driverName == "ESRI Shapefile" )
7979
{
80-
if( !vectorFileName.endsWith( ".shp", Qt::CaseInsensitive ) )
80+
if ( !vectorFileName.endsWith( ".shp", Qt::CaseInsensitive ) )
8181
{
8282
vectorFileName += ".shp";
8383
}
8484

8585
// check for unique fieldnames
8686
QSet<QString> fieldNames;
8787
QgsFieldMap::const_iterator fldIt;
88-
for( fldIt = fields.begin(); fldIt != fields.end(); ++fldIt )
88+
for ( fldIt = fields.begin(); fldIt != fields.end(); ++fldIt )
8989
{
9090
QString name = fldIt.value().name().left( 10 );
91-
if( fieldNames.contains( name ) )
91+
if ( fieldNames.contains( name ) )
9292
{
9393
mErrorMessage = QObject::tr( "trimming attribute name '%1' to ten significant characters produces duplicate column name." )
9494
.arg( fldIt.value().name() );
@@ -100,14 +100,14 @@ QgsVectorFileWriter::QgsVectorFileWriter(
100100

101101
deleteShapeFile( vectorFileName );
102102
}
103-
else if( driverName == "KML" )
103+
else if ( driverName == "KML" )
104104
{
105-
if( !vectorFileName.endsWith( ".kml", Qt::CaseInsensitive ) )
105+
if ( !vectorFileName.endsWith( ".kml", Qt::CaseInsensitive ) )
106106
{
107107
vectorFileName += ".kml";
108108
}
109109

110-
if( fileEncoding.compare( "UTF-8", Qt::CaseInsensitive ) != 0 )
110+
if ( fileEncoding.compare( "UTF-8", Qt::CaseInsensitive ) != 0 )
111111
{
112112
QgsDebugMsg( "forced UTF-8 encoding for KML" );
113113
fileEncoding = "UTF-8";
@@ -121,10 +121,10 @@ QgsVectorFileWriter::QgsVectorFileWriter(
121121
}
122122

123123
char **options = NULL;
124-
if( !datasourceOptions.isEmpty() )
124+
if ( !datasourceOptions.isEmpty() )
125125
{
126126
options = new char *[ datasourceOptions.size()+1 ];
127-
for( int i = 0; i < datasourceOptions.size(); i++ )
127+
for ( int i = 0; i < datasourceOptions.size(); i++ )
128128
{
129129
options[i] = CPLStrdup( datasourceOptions[i].toLocal8Bit().data() );
130130
}
@@ -134,15 +134,15 @@ QgsVectorFileWriter::QgsVectorFileWriter(
134134
// create the data source
135135
mDS = OGR_Dr_CreateDataSource( poDriver, vectorFileName.toLocal8Bit().data(), options );
136136

137-
if( options )
137+
if ( options )
138138
{
139-
for( int i = 0; i < datasourceOptions.size(); i++ )
139+
for ( int i = 0; i < datasourceOptions.size(); i++ )
140140
CPLFree( options[i] );
141141
delete [] options;
142142
options = NULL;
143143
}
144144

145-
if( mDS == NULL )
145+
if ( mDS == NULL )
146146
{
147147
mError = ErrCreateDataSource;
148148
mErrorMessage = QObject::tr( "creation of data source failed (OGR error:%1)" )
@@ -154,13 +154,13 @@ QgsVectorFileWriter::QgsVectorFileWriter(
154154

155155
// use appropriate codec
156156
mCodec = QTextCodec::codecForName( fileEncoding.toLocal8Bit().data() );
157-
if( !mCodec )
157+
if ( !mCodec )
158158
{
159159
QSettings settings;
160160
QString enc = settings.value( "/UI/encoding", QString( "System" ) ).toString();
161161
QgsDebugMsg( "error finding QTextCodec for " + fileEncoding );
162162
mCodec = QTextCodec::codecForName( enc.toLocal8Bit().data() );
163-
if( !mCodec )
163+
if ( !mCodec )
164164
{
165165
QgsDebugMsg( "error finding QTextCodec for " + enc );
166166
mCodec = QTextCodec::codecForLocale();
@@ -169,7 +169,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
169169

170170
// consider spatial reference system of the layer
171171
OGRSpatialReferenceH ogrRef = NULL;
172-
if( srs )
172+
if ( srs )
173173
{
174174
QString srsWkt = srs->toWkt();
175175
QgsDebugMsg( "WKT to save as is " + srsWkt );
@@ -180,10 +180,10 @@ QgsVectorFileWriter::QgsVectorFileWriter(
180180
QString layerName = QFileInfo( vectorFileName ).baseName();
181181
OGRwkbGeometryType wkbType = static_cast<OGRwkbGeometryType>( geometryType );
182182

183-
if( !layerOptions.isEmpty() )
183+
if ( !layerOptions.isEmpty() )
184184
{
185185
options = new char *[ layerOptions.size()+1 ];
186-
for( int i = 0; i < layerOptions.size(); i++ )
186+
for ( int i = 0; i < layerOptions.size(); i++ )
187187
{
188188
options[i] = CPLStrdup( layerOptions[i].toLocal8Bit().data() );
189189
}
@@ -192,21 +192,21 @@ QgsVectorFileWriter::QgsVectorFileWriter(
192192

193193
mLayer = OGR_DS_CreateLayer( mDS, QFile::encodeName( layerName ).data(), ogrRef, wkbType, options );
194194

195-
if( options )
195+
if ( options )
196196
{
197-
for( int i = 0; i < layerOptions.size(); i++ )
197+
for ( int i = 0; i < layerOptions.size(); i++ )
198198
CPLFree( options[i] );
199199
delete [] options;
200200
options = NULL;
201201
}
202202

203-
if( srs )
203+
if ( srs )
204204
{
205-
if( driverName == "ESRI Shapefile" )
205+
if ( driverName == "ESRI Shapefile" )
206206
{
207207
QString layerName = vectorFileName.left( vectorFileName.indexOf( ".shp", Qt::CaseInsensitive ) );
208208
QFile prjFile( layerName + ".qpj" );
209-
if( prjFile.open( QIODevice::WriteOnly ) )
209+
if ( prjFile.open( QIODevice::WriteOnly ) )
210210
{
211211
QTextStream prjStream( &prjFile );
212212
prjStream << srs->toWkt().toLocal8Bit().data() << endl;
@@ -221,7 +221,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
221221
OSRDestroySpatialReference( ogrRef );
222222
}
223223

224-
if( mLayer == NULL )
224+
if ( mLayer == NULL )
225225
{
226226
mErrorMessage = QObject::tr( "creation of layer failed (OGR error:%1)" )
227227
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
@@ -240,14 +240,14 @@ QgsVectorFileWriter::QgsVectorFileWriter(
240240
mAttrIdxToOgrIdx.clear();
241241

242242
QgsFieldMap::const_iterator fldIt;
243-
for( fldIt = fields.begin(); fldIt != fields.end(); ++fldIt )
243+
for ( fldIt = fields.begin(); fldIt != fields.end(); ++fldIt )
244244
{
245245
const QgsField& attrField = fldIt.value();
246246

247247
OGRFieldType ogrType = OFTString; //default to string
248248
int ogrWidth = fldIt->length();
249249
int ogrPrecision = fldIt->precision();
250-
switch( attrField.type() )
250+
switch ( attrField.type() )
251251
{
252252
case QVariant::LongLong:
253253
ogrType = OFTString;
@@ -257,7 +257,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
257257

258258
case QVariant::String:
259259
ogrType = OFTString;
260-
if( ogrWidth < 0 || ogrWidth > 255 )
260+
if ( ogrWidth < 0 || ogrWidth > 255 )
261261
ogrWidth = 255;
262262
break;
263263

@@ -281,12 +281,12 @@ QgsVectorFileWriter::QgsVectorFileWriter(
281281

282282
// create field definition
283283
OGRFieldDefnH fld = OGR_Fld_Create( mCodec->fromUnicode( attrField.name() ), ogrType );
284-
if( ogrWidth > 0 )
284+
if ( ogrWidth > 0 )
285285
{
286286
OGR_Fld_SetWidth( fld, ogrWidth );
287287
}
288288

289-
if( ogrPrecision >= 0 )
289+
if ( ogrPrecision >= 0 )
290290
{
291291
OGR_Fld_SetPrecision( fld, ogrPrecision );
292292
}
@@ -296,7 +296,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
296296
" type " + QString( QVariant::typeToName( attrField.type() ) ) +
297297
" width " + QString::number( ogrWidth ) +
298298
" precision " + QString::number( ogrPrecision ) );
299-
if( OGR_L_CreateField( mLayer, fld, true ) != OGRERR_NONE )
299+
if ( OGR_L_CreateField( mLayer, fld, true ) != OGRERR_NONE )
300300
{
301301
QgsDebugMsg( "error creating field " + attrField.name() );
302302
mErrorMessage = QObject::tr( "creation of field %1 failed (OGR error: %2)" )
@@ -307,24 +307,24 @@ QgsVectorFileWriter::QgsVectorFileWriter(
307307
}
308308

309309
int ogrIdx = OGR_FD_GetFieldIndex( defn, mCodec->fromUnicode( attrField.name() ) );
310-
if( ogrIdx < 0 )
310+
if ( ogrIdx < 0 )
311311
{
312312
// if we didn't find our new column, assume it's name was truncated and
313313
// it was the last one added (like for shape files)
314314
int fieldCount = OGR_FD_GetFieldCount( defn );
315315

316316
OGRFieldDefnH fdefn = OGR_FD_GetFieldDefn( defn, fieldCount - 1 );
317-
if( fdefn )
317+
if ( fdefn )
318318
{
319319
const char *fieldName = OGR_Fld_GetNameRef( fdefn );
320320

321-
if( attrField.name().left( strlen( fieldName ) ) == fieldName )
321+
if ( attrField.name().left( strlen( fieldName ) ) == fieldName )
322322
{
323323
ogrIdx = fieldCount - 1;
324324
}
325325
}
326326

327-
if( ogrIdx < 0 )
327+
if ( ogrIdx < 0 )
328328
{
329329
QgsDebugMsg( "error creating field " + attrField.name() );
330330
mErrorMessage = QObject::tr( "created field %1 not found (OGR error: %2)" )
@@ -370,15 +370,15 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
370370

371371
// attribute handling
372372
QgsFieldMap::const_iterator fldIt;
373-
for( fldIt = mFields.begin(); fldIt != mFields.end(); ++fldIt )
373+
for ( fldIt = mFields.begin(); fldIt != mFields.end(); ++fldIt )
374374
{
375-
if( !feature.attributeMap().contains( fldIt.key() ) )
375+
if ( !feature.attributeMap().contains( fldIt.key() ) )
376376
{
377377
QgsDebugMsg( QString( "no attribute for field %1" ).arg( fldIt.key() ) );
378378
continue;
379379
}
380380

381-
if( !mAttrIdxToOgrIdx.contains( fldIt.key() ) )
381+
if ( !mAttrIdxToOgrIdx.contains( fldIt.key() ) )
382382
{
383383
QgsDebugMsg( QString( "no ogr field for field %1" ).arg( fldIt.key() ) );
384384
continue;
@@ -387,7 +387,7 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
387387
const QVariant& attrValue = feature.attributeMap()[ fldIt.key()];
388388
int ogrField = mAttrIdxToOgrIdx[ fldIt.key()];
389389

390-
switch( attrValue.type() )
390+
switch ( attrValue.type() )
391391
{
392392
case QVariant::Int:
393393
OGR_F_SetFieldInteger( poFeature, ogrField, attrValue.toInt() );
@@ -413,16 +413,7 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
413413

414414
// build geometry from WKB
415415
QgsGeometry *geom = feature.geometry();
416-
if( !geom )
417-
{
418-
QgsDebugMsg( "invalid geometry" );
419-
mErrorMessage = QObject::tr( "Invalid feature geometry" );
420-
mError = ErrFeatureWriteFailed;
421-
OGR_F_Destroy( poFeature );
422-
return false;
423-
}
424-
425-
if( geom->wkbType() != mWkbType )
416+
if ( geom && geom->wkbType() != mWkbType )
426417
{
427418
// there's a problem when layer type is set as wkbtype Polygon
428419
// although there are also features of type MultiPolygon
@@ -435,7 +426,7 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
435426

436427
OGRGeometryH mGeom2 = createEmptyGeometry( geom->wkbType() );
437428

438-
if( !mGeom2 )
429+
if ( !mGeom2 )
439430
{
440431
QgsDebugMsg( QString( "Failed to create empty geometry for type %1 (OGR error: %2)" ).arg( geom->wkbType() ).arg( CPLGetLastErrorMsg() ) );
441432
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
@@ -446,7 +437,7 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
446437
}
447438

448439
OGRErr err = OGR_G_ImportFromWkb( mGeom2, geom->asWkb(), geom->wkbSize() );
449-
if( err != OGRERR_NONE )
440+
if ( err != OGRERR_NONE )
450441
{
451442
QgsDebugMsg( QString( "Failed to import geometry from WKB: %1 (OGR error: %2)" ).arg( err ).arg( CPLGetLastErrorMsg() ) );
452443
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
@@ -459,10 +450,10 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
459450
// pass ownership to geometry
460451
OGR_F_SetGeometryDirectly( poFeature, mGeom2 );
461452
}
462-
else
453+
else if ( geom )
463454
{
464455
OGRErr err = OGR_G_ImportFromWkb( mGeom, geom->asWkb(), geom->wkbSize() );
465-
if( err != OGRERR_NONE )
456+
if ( err != OGRERR_NONE )
466457
{
467458
QgsDebugMsg( QString( "Failed to import geometry from WKB: %1 (OGR error: %2)" ).arg( err ).arg( CPLGetLastErrorMsg() ) );
468459
mErrorMessage = QObject::tr( "Feature geometry not imported (OGR error: %1)" )
@@ -477,7 +468,7 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
477468
}
478469

479470
// put the created feature to layer
480-
if( OGR_L_CreateFeature( mLayer, poFeature ) != OGRERR_NONE )
471+
if ( OGR_L_CreateFeature( mLayer, poFeature ) != OGRERR_NONE )
481472
{
482473
mErrorMessage = QObject::tr( "Feature creation error (OGR error: %1)" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
483474
mError = ErrFeatureWriteFailed;
@@ -494,12 +485,12 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature )
494485

495486
QgsVectorFileWriter::~QgsVectorFileWriter()
496487
{
497-
if( mGeom )
488+
if ( mGeom )
498489
{
499490
OGR_G_DestroyGeometry( mGeom );
500491
}
501492

502-
if( mDS )
493+
if ( mDS )
503494
{
504495
OGR_DS_Destroy( mDS );
505496
}
@@ -537,7 +528,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
537528
QgsCoordinateTransform* ct = 0;
538529
int shallTransform = false;
539530

540-
if( destCRS && destCRS->isValid() )
531+
if ( destCRS && destCRS->isValid() )
541532
{
542533
// This means we should transform
543534
outputCRS = destCRS;
@@ -553,15 +544,15 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
553544

554545
// check whether file creation was successful
555546
WriterError err = writer->hasError();
556-
if( err != NoError )
547+
if ( err != NoError )
557548
{
558-
if( errorMessage )
549+
if ( errorMessage )
559550
*errorMessage = writer->errorMessage();
560551
delete writer;
561552
return err;
562553
}
563554

564-
if( errorMessage )
555+
if ( errorMessage )
565556
{
566557
errorMessage->clear();
567558
}
@@ -574,68 +565,68 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
574565
const QgsFeatureIds& ids = layer->selectedFeaturesIds();
575566

576567
// Create our transform
577-
if( destCRS )
568+
if ( destCRS )
578569
{
579570
ct = new QgsCoordinateTransform( layer->srs(), *destCRS );
580571
}
581572

582573
// Check for failure
583-
if( ct == NULL )
574+
if ( ct == NULL )
584575
{
585576
shallTransform = false;
586577
}
587578

588579
int n = 0, errors = 0;
589580

590581
// write all features
591-
while( layer->nextFeature( fet ) )
582+
while ( layer->nextFeature( fet ) )
592583
{
593-
if( onlySelected && !ids.contains( fet.id() ) )
584+
if ( onlySelected && !ids.contains( fet.id() ) )
594585
continue;
595586

596-
if( shallTransform )
587+
if ( shallTransform )
597588
{
598589
try
599590
{
600-
if( fet.geometry() )
591+
if ( fet.geometry() )
601592
{
602593
fet.geometry()->transform( *ct );
603594
}
604595
}
605-
catch( QgsCsException &e )
596+
catch ( QgsCsException &e )
606597
{
607598
delete ct;
608599
delete writer;
609600

610601
QString msg = QObject::tr( "Failed to transform a point while drawing a feature of type '%1'. Writing stopped. (Exception: %2)" )
611602
.arg( fet.typeName() ).arg( e.what() );
612603
QgsLogger::warning( msg );
613-
if( errorMessage )
604+
if ( errorMessage )
614605
*errorMessage = msg;
615606

616607
return ErrProjection;
617608
}
618609
}
619-
if( skipAttributeCreation )
610+
if ( skipAttributeCreation )
620611
{
621612
fet.clearAttributeMap();
622613
}
623-
if( !writer->addFeature( fet ) )
614+
if ( !writer->addFeature( fet ) )
624615
{
625616
WriterError err = writer->hasError();
626-
if( err != NoError && errorMessage )
617+
if ( err != NoError && errorMessage )
627618
{
628-
if( errorMessage->isEmpty() )
619+
if ( errorMessage->isEmpty() )
629620
{
630621
*errorMessage = QObject::tr( "Feature write errors:" );
631622
}
632623
*errorMessage += "\n" + writer->errorMessage();
633624
}
634625
errors++;
635626

636-
if( errors > 1000 )
627+
if ( errors > 1000 )
637628
{
638-
if( errorMessage )
629+
if ( errorMessage )
639630
{
640631
*errorMessage += QObject::tr( "Stopping after %1 errors" ).arg( errors );
641632
}
@@ -649,12 +640,12 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
649640

650641
delete writer;
651642

652-
if( shallTransform )
643+
if ( shallTransform )
653644
{
654645
delete ct;
655646
}
656647

657-
if( errors > 0 && errorMessage && n > 0 )
648+
if ( errors > 0 && errorMessage && n > 0 )
658649
{
659650
*errorMessage += QObject::tr( "\nOnly %1 of %2 features written." ).arg( n - errors ).arg( n );
660651
}
@@ -670,15 +661,15 @@ bool QgsVectorFileWriter::deleteShapeFile( QString theFileName )
670661

671662
QStringList filter;
672663
const char *suffixes[] = { ".shp", ".shx", ".dbf", ".prj", ".qix", ".qpj" };
673-
for( std::size_t i = 0; i < sizeof( suffixes ) / sizeof( *suffixes ); i++ )
664+
for ( std::size_t i = 0; i < sizeof( suffixes ) / sizeof( *suffixes ); i++ )
674665
{
675666
filter << fi.completeBaseName() + suffixes[i];
676667
}
677668

678669
bool ok = true;
679670
foreach( QString file, dir.entryList( filter ) )
680671
{
681-
if( !QFile::remove( dir.canonicalPath() + "/" + file ) )
672+
if ( !QFile::remove( dir.canonicalPath() + "/" + file ) )
682673
{
683674
QgsDebugMsg( "Removing file failed : " + file );
684675
ok = false;
@@ -695,16 +686,16 @@ QMap< QString, QString> QgsVectorFileWriter::supportedFiltersAndFormats()
695686
QgsApplication::registerOgrDrivers();
696687
int const drvCount = OGRGetDriverCount();
697688

698-
for( int i = 0; i < drvCount; ++i )
689+
for ( int i = 0; i < drvCount; ++i )
699690
{
700691
OGRSFDriverH drv = OGRGetDriver( i );
701-
if( drv )
692+
if ( drv )
702693
{
703694
QString drvName = OGR_Dr_GetName( drv );
704-
if( OGR_Dr_TestCapability( drv, "CreateDataSource" ) != 0 )
695+
if ( OGR_Dr_TestCapability( drv, "CreateDataSource" ) != 0 )
705696
{
706697
QString filterString = filterForDriver( drvName );
707-
if( filterString.isEmpty() )
698+
if ( filterString.isEmpty() )
708699
continue;
709700

710701
resultMap.insert( filterString, drvName );
@@ -722,16 +713,16 @@ QMap<QString, QString> QgsVectorFileWriter::ogrDriverList()
722713
QgsApplication::registerOgrDrivers();
723714
int const drvCount = OGRGetDriverCount();
724715

725-
for( int i = 0; i < drvCount; ++i )
716+
for ( int i = 0; i < drvCount; ++i )
726717
{
727718
OGRSFDriverH drv = OGRGetDriver( i );
728-
if( drv )
719+
if ( drv )
729720
{
730721
QString drvName = OGR_Dr_GetName( drv );
731-
if( OGR_Dr_TestCapability( drv, "CreateDataSource" ) != 0 )
722+
if ( OGR_Dr_TestCapability( drv, "CreateDataSource" ) != 0 )
732723
{
733724
QPair<QString, QString> p = nameAndGlob( drvName );
734-
if( p.first.isEmpty() )
725+
if ( p.first.isEmpty() )
735726
continue;
736727

737728
resultMap.insert( p.first, drvName );
@@ -747,9 +738,9 @@ QString QgsVectorFileWriter::fileFilterString()
747738
QString filterString;
748739
QMap< QString, QString> driverFormatMap = supportedFiltersAndFormats();
749740
QMap< QString, QString>::const_iterator it = driverFormatMap.constBegin();
750-
for( ; it != driverFormatMap.constEnd(); ++it )
741+
for ( ; it != driverFormatMap.constEnd(); ++it )
751742
{
752-
if( filterString.isEmpty() )
743+
if ( filterString.isEmpty() )
753744
filterString += ";;";
754745

755746
filterString += it.key();
@@ -761,7 +752,7 @@ QString QgsVectorFileWriter::filterForDriver( const QString& driverName )
761752
{
762753
QPair<QString, QString> p = nameAndGlob( driverName );
763754

764-
if( p.first.isEmpty() || p.second.isEmpty() )
755+
if ( p.first.isEmpty() || p.second.isEmpty() )
765756
return "";
766757

767758
return "[OGR] " + p.first + " (" + p.second.toLower() + " " + p.second.toUpper() + ")";
@@ -772,102 +763,102 @@ QPair<QString, QString> QgsVectorFileWriter::nameAndGlob( QString driverName )
772763
QString longName;
773764
QString glob;
774765

775-
if( driverName.startsWith( "AVCE00" ) )
766+
if ( driverName.startsWith( "AVCE00" ) )
776767
{
777768
longName = "Arc/Info ASCII Coverage";
778769
glob = "*.e00";
779770
}
780-
else if( driverName.startsWith( "BNA" ) )
771+
else if ( driverName.startsWith( "BNA" ) )
781772
{
782773
longName = "Atlas BNA";
783774
glob = "*.bna";
784775
}
785-
else if( driverName.startsWith( "CSV" ) )
776+
else if ( driverName.startsWith( "CSV" ) )
786777
{
787778
longName = "Comma Separated Value";
788779
glob = "*.csv";
789780
}
790-
else if( driverName.startsWith( "ESRI" ) )
781+
else if ( driverName.startsWith( "ESRI" ) )
791782
{
792783
longName = "ESRI Shapefile";
793784
glob = "*.shp";
794785
}
795-
else if( driverName.startsWith( "FMEObjects Gateway" ) )
786+
else if ( driverName.startsWith( "FMEObjects Gateway" ) )
796787
{
797788
longName = "FMEObjects Gateway";
798789
glob = "*.fdd";
799790
}
800-
else if( driverName.startsWith( "GeoJSON" ) )
791+
else if ( driverName.startsWith( "GeoJSON" ) )
801792
{
802793
longName = "GeoJSON";
803794
glob = "*.geojson";
804795
}
805-
else if( driverName.startsWith( "GeoRSS" ) )
796+
else if ( driverName.startsWith( "GeoRSS" ) )
806797
{
807798
longName = "GeoRSS";
808799
glob = "*.xml";
809800
}
810-
else if( driverName.startsWith( "GML" ) )
801+
else if ( driverName.startsWith( "GML" ) )
811802
{
812803
longName = "Geography Markup Language (GML)";
813804
glob = "*.gml";
814805
}
815-
else if( driverName.startsWith( "GMT" ) )
806+
else if ( driverName.startsWith( "GMT" ) )
816807
{
817808
longName = "Generic Mapping Tools (GMT)";
818809
glob = "*.gmt";
819810
}
820-
else if( driverName.startsWith( "GPX" ) )
811+
else if ( driverName.startsWith( "GPX" ) )
821812
{
822813
longName = "GPS eXchange Format";
823814
glob = "*.gpx";
824815
}
825-
else if( driverName.startsWith( "Interlis 1" ) )
816+
else if ( driverName.startsWith( "Interlis 1" ) )
826817
{
827818
longName = "INTERLIS 1";
828819
glob = "*.itf *.xml *.ili";
829820
}
830-
else if( driverName.startsWith( "Interlis 2" ) )
821+
else if ( driverName.startsWith( "Interlis 2" ) )
831822
{
832823
longName = "INTERLIS 2";
833824
glob = "*.itf *.xml *.ili";
834825
}
835-
else if( driverName.startsWith( "KML" ) )
826+
else if ( driverName.startsWith( "KML" ) )
836827
{
837828
longName = "Keyhole Markup Language (KML)";
838829
glob = "*.kml" ;
839830
}
840-
else if( driverName.startsWith( "MapInfo File" ) )
831+
else if ( driverName.startsWith( "MapInfo File" ) )
841832
{
842833
longName = "Mapinfo File";
843834
glob = "*.mif *.tab";
844835
}
845-
else if( driverName.startsWith( "DGN" ) )
836+
else if ( driverName.startsWith( "DGN" ) )
846837
{
847838
longName = "Microstation DGN";
848839
glob = "*.dgn";
849840
}
850-
else if( driverName.startsWith( "S57" ) )
841+
else if ( driverName.startsWith( "S57" ) )
851842
{
852843
longName = "S-57 Base file";
853844
glob = "*.000";
854845
}
855-
else if( driverName.startsWith( "SDTS" ) )
846+
else if ( driverName.startsWith( "SDTS" ) )
856847
{
857848
longName = "Spatial Data Transfer Standard (SDTS)";
858849
glob = "*catd.ddf";
859850
}
860-
else if( driverName.startsWith( "SQLite" ) )
851+
else if ( driverName.startsWith( "SQLite" ) )
861852
{
862853
longName = "SQLite";
863854
glob = "*.sqlite";
864855
}
865-
else if( driverName.startsWith( "DXF" ) )
856+
else if ( driverName.startsWith( "DXF" ) )
866857
{
867858
longName = "AutoCAD DXF";
868859
glob = "*.dxf";
869860
}
870-
else if( driverName.startsWith( "Geoconcept" ) )
861+
else if ( driverName.startsWith( "Geoconcept" ) )
871862
{
872863
longName = "Geoconcept";
873864
glob = "*.gxt *.txt";

0 commit comments

Comments
 (0)
Please sign in to comment.