Quantum GIS API Documentation  1.8
src/core/qgsvectorlayerimport.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsvectorlayerimport.cpp
00003                           vector layer importer
00004                              -------------------
00005     begin                : Thu Aug 25 2011
00006     copyright            : (C) 2011 by Giuseppe Sucameli
00007     email                : brush.tyler at gmail.com
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef _QGSVECTORLAYERIMPORT_H_
00020 #define _QGSVECTORLAYERIMPORT_H_
00021 
00022 #include "qgsvectordataprovider.h"
00023 #include "qgsvectorlayer.h"
00024 
00034 class CORE_EXPORT QgsVectorLayerImport
00035 {
00036   public:
00037 
00038     enum ImportError
00039     {
00040       NoError = 0,
00041       ErrDriverNotFound,
00042       ErrCreateDataSource,
00043       ErrCreateLayer,
00044       ErrAttributeTypeUnsupported,
00045       ErrAttributeCreationFailed,
00046       ErrProjection,
00047       ErrFeatureWriteFailed,
00048       ErrInvalidLayer,
00049       ErrInvalidProvider,
00050       ErrProviderUnsupportedFeature,
00051       ErrConnectionFailed
00052     };
00053 
00054 
00056     static ImportError importLayer( QgsVectorLayer* layer,
00057                                     const QString& uri,
00058                                     const QString& providerKey,
00059                                     const QgsCoordinateReferenceSystem *destCRS,
00060                                     bool onlySelected = false,
00061                                     QString *errorMessage = 0,
00062                                     bool skipAttributeCreation = false,
00063                                     QMap<QString, QVariant> *options = 0
00064                                   );
00065 
00067     QgsVectorLayerImport( const QString &uri,
00068                           const QString &provider,
00069                           const QgsFieldMap& fields,
00070                           QGis::WkbType geometryType,
00071                           const QgsCoordinateReferenceSystem* crs,
00072                           bool overwrite = false,
00073                           const QMap<QString, QVariant> *options = 0
00074                         );
00075 
00077     ImportError hasError();
00078 
00080     QString errorMessage();
00081 
00082     int errorCount() const { return mErrorCount; }
00083 
00085     bool addFeature( QgsFeature& feature );
00086 
00088     ~QgsVectorLayerImport();
00089 
00090   protected:
00092     bool flushBuffer();
00093 
00095     ImportError mError;
00096     QString mErrorMessage;
00097 
00098     int mErrorCount;
00099 
00100     QgsVectorDataProvider *mProvider;
00101 
00103     QMap<int, int> mOldToNewAttrIdx;
00104 
00105     QgsFeatureList mFeatureBuffer;
00106 };
00107 
00108 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines