Quantum GIS API Documentation  1.8
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
QgsVectorLayerImport Class Reference

A convenience class for writing vector files to disk. More...

#include <qgsvectorlayerimport.h>

Collaboration diagram for QgsVectorLayerImport:
Collaboration graph
[legend]

List of all members.

Public Types

enum  ImportError {
  NoError = 0, ErrDriverNotFound, ErrCreateDataSource, ErrCreateLayer,
  ErrAttributeTypeUnsupported, ErrAttributeCreationFailed, ErrProjection, ErrFeatureWriteFailed,
  ErrInvalidLayer, ErrInvalidProvider, ErrProviderUnsupportedFeature, ErrConnectionFailed
}

Public Member Functions

 QgsVectorLayerImport (const QString &uri, const QString &provider, const QgsFieldMap &fields, QGis::WkbType geometryType, const QgsCoordinateReferenceSystem *crs, bool overwrite=false, const QMap< QString, QVariant > *options=0)
 create a empty layer and add fields to it
ImportError hasError ()
 checks whether there were any errors
QString errorMessage ()
 retrieves error message
int errorCount () const
bool addFeature (QgsFeature &feature)
 add feature to the new created layer
 ~QgsVectorLayerImport ()
 close the new created layer

Static Public Member Functions

static ImportError importLayer (QgsVectorLayer *layer, const QString &uri, const QString &providerKey, const QgsCoordinateReferenceSystem *destCRS, bool onlySelected=false, QString *errorMessage=0, bool skipAttributeCreation=false, QMap< QString, QVariant > *options=0)
 Write contents of vector layer to a different datasource.

Protected Member Functions

bool flushBuffer ()
 flush the buffer writing the features to the new layer

Protected Attributes

ImportError mError
 contains error value
QString mErrorMessage
int mErrorCount
QgsVectorDataProvidermProvider
QMap< int, int > mOldToNewAttrIdx
 map attribute indexes to new field indexes
QgsFeatureList mFeatureBuffer

Detailed Description

A convenience class for writing vector files to disk.

There are two possibilities how to use this class: 1. static call to QgsVectorFileWriter::writeAsShapefile(...) which saves the whole vector layer 2. create an instance of the class and issue calls to addFeature(...)

Currently supports only writing to shapefiles, but shouldn't be a problem to add capability to support other OGR-writable formats.

Definition at line 34 of file qgsvectorlayerimport.h.


Member Enumeration Documentation

Enumerator:
NoError 
ErrDriverNotFound 
ErrCreateDataSource 
ErrCreateLayer 
ErrAttributeTypeUnsupported 
ErrAttributeCreationFailed 
ErrProjection 
ErrFeatureWriteFailed 
ErrInvalidLayer 
ErrInvalidProvider 
ErrProviderUnsupportedFeature 
ErrConnectionFailed 

Definition at line 38 of file qgsvectorlayerimport.h.


Constructor & Destructor Documentation

QgsVectorLayerImport::QgsVectorLayerImport ( const QString &  uri,
const QString &  provider,
const QgsFieldMap fields,
QGis::WkbType  geometryType,
const QgsCoordinateReferenceSystem crs,
bool  overwrite = false,
const QMap< QString, QVariant > *  options = 0 
)

close the new created layer

Definition at line 101 of file qgsvectorlayerimport.cpp.

References flushBuffer(), and mProvider.


Member Function Documentation

int QgsVectorLayerImport::errorCount ( ) const [inline]

Definition at line 82 of file qgsvectorlayerimport.h.

Referenced by importLayer().

retrieves error message

Definition at line 114 of file qgsvectorlayerimport.cpp.

References mErrorMessage.

Referenced by importLayer().

bool QgsVectorLayerImport::flushBuffer ( ) [protected]

checks whether there were any errors

Definition at line 109 of file qgsvectorlayerimport.cpp.

References mError.

Referenced by importLayer(), and QgsVectorLayerImport().

QgsVectorLayerImport::ImportError QgsVectorLayerImport::importLayer ( QgsVectorLayer layer,
const QString &  uri,
const QString &  providerKey,
const QgsCoordinateReferenceSystem destCRS,
bool  onlySelected = false,
QString *  errorMessage = 0,
bool  skipAttributeCreation = false,
QMap< QString, QVariant > *  options = 0 
) [static]

Member Data Documentation

contains error value

Definition at line 95 of file qgsvectorlayerimport.h.

Referenced by flushBuffer(), hasError(), and QgsVectorLayerImport().

Definition at line 98 of file qgsvectorlayerimport.h.

Referenced by flushBuffer().

Definition at line 96 of file qgsvectorlayerimport.h.

Referenced by errorMessage(), flushBuffer(), and QgsVectorLayerImport().

Definition at line 105 of file qgsvectorlayerimport.h.

Referenced by addFeature(), and flushBuffer().

QMap<int, int> QgsVectorLayerImport::mOldToNewAttrIdx [protected]

map attribute indexes to new field indexes

Definition at line 103 of file qgsvectorlayerimport.h.

Referenced by addFeature(), and QgsVectorLayerImport().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines