/
qgsvectorfilewriter.sip
50 lines (38 loc) · 1.44 KB
/
qgsvectorfilewriter.sip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
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.
*/
class QgsVectorFileWriter
{
%TypeHeaderCode
#include <qgsvectorfilewriter.h>
#include <qgsfield.h>
%End
public:
enum WriterError
{
NoError = 0,
ErrDriverNotFound,
ErrCreateDataSource,
ErrCreateLayer
};
/** Write contents of vector layer to a shapefile */
static WriterError writeAsShapefile(QgsVectorLayer* layer,
const QString& shapefileName,
const QString& fileEncoding);
/** create shapefile and initialize it */
QgsVectorFileWriter(const QString& shapefileName,
const QString& fileEncoding,
const QMap<int, QgsField>& fields,
QGis::WKBTYPE geometryType,
const QgsSpatialRefSys* srs);
/** checks whether there were any errors in constructor */
WriterError hasError();
/** add feature to the currently opened shapefile */
bool addFeature(QgsFeature& feature);
/** close opened shapefile for writing */
~QgsVectorFileWriter();
};