QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsvectorlayerimport.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerimport.cpp
3  vector layer importer
4  -------------------
5  begin : Thu Aug 25 2011
6  copyright : (C) 2011 by Giuseppe Sucameli
7  email : brush.tyler at gmail.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef _QGSVECTORLAYERIMPORT_H_
20 #define _QGSVECTORLAYERIMPORT_H_
21 
22 #include "qgsvectordataprovider.h"
23 #include "qgsvectorlayer.h"
24 
25 class QProgressDialog;
26 
36 class CORE_EXPORT QgsVectorLayerImport
37 {
38  public:
39 
41  {
42  NoError = 0,
53  ErrConnectionFailed
54  };
55 
57  static ImportError importLayer( QgsVectorLayer* layer,
58  const QString& uri,
59  const QString& providerKey,
60  const QgsCoordinateReferenceSystem *destCRS,
61  bool onlySelected = false,
62  QString *errorMessage = 0,
63  bool skipAttributeCreation = false,
64  QMap<QString, QVariant> *options = 0,
65  QProgressDialog *progress = 0
66  );
67 
69  QgsVectorLayerImport( const QString &uri,
70  const QString &provider,
71  const QgsFields &fields,
72  QGis::WkbType geometryType,
74  bool overwrite = false,
75  const QMap<QString, QVariant> *options = 0,
76  QProgressDialog *progress = 0
77  );
78 
80  ImportError hasError();
81 
83  QString errorMessage();
84 
85  int errorCount() const { return mErrorCount; }
86 
88  bool addFeature( QgsFeature& feature );
89 
92 
93  protected:
95  bool flushBuffer();
96 
98  bool createSpatialIndex();
99 
102  QString mErrorMessage;
103 
105 
107 
109  QMap<int, int> mOldToNewAttrIdx;
111 
113  QProgressDialog *mProgress;
114 };
115 
116 #endif
Definition: qgsvectorlayerimport.h:44
QMap< int, int > mOldToNewAttrIdx
map attribute indexes to new field indexes
Definition: qgsvectorlayerimport.h:109
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:322
Definition: qgsvectorlayerimport.h:48
QString mErrorMessage
Definition: qgsvectorlayerimport.h:102
QgsVectorDataProvider * mProvider
Definition: qgsvectorlayerimport.h:106
Container of fields for a vector layer.
Definition: qgsfield.h:172
Definition: qgsvectorlayerimport.h:51
WkbType
Used for symbology operations.
Definition: qgis.h:53
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:113
ImportError
Definition: qgsvectorlayerimport.h:40
Definition: qgsvectorlayerimport.h:46
Definition: qgsvectorlayerimport.h:50
int errorCount() const
Definition: qgsvectorlayerimport.h:85
int mErrorCount
Definition: qgsvectorlayerimport.h:104
A convenience class for writing vector files to disk.
Definition: qgsvectorlayerimport.h:36
Definition: qgsvectorlayerimport.h:47
int mAttributeCount
Definition: qgsvectorlayerimport.h:110
ImportError mError
contains error value
Definition: qgsvectorlayerimport.h:101
Definition: qgsvectorlayerimport.h:52
Class for storing a coordinate reference system (CRS)
Definition: qgscoordinatereferencesystem.h:50
Definition: qgsvectorlayerimport.h:43
Definition: qgsvectorlayerimport.h:45
This is the base class for vector data providers.
Definition: qgsvectordataprovider.h:48
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:468
QProgressDialog * mProgress
Definition: qgsvectorlayerimport.h:113
QgsFeatureList mFeatureBuffer
Definition: qgsvectorlayerimport.h:112
Definition: qgsvectorlayerimport.h:49