QGIS API Documentation
2.8.2-Wien
|
A convenience class for writing vector files to disk. More...
#include <qgsvectorfilewriter.h>
Classes | |
class | BoolOption |
class | HiddenOption |
class | IntOption |
struct | MetaData |
class | Option |
class | SetOption |
class | StringOption |
Public Types | |
enum | OptionType { Set, String, Int, Hidden } |
enum | SymbologyExport { NoSymbology = 0, FeatureSymbology, SymbolLayerSymbology } |
enum | WriterError { NoError = 0, ErrDriverNotFound, ErrCreateDataSource, ErrCreateLayer, ErrAttributeTypeUnsupported, ErrAttributeCreationFailed, ErrProjection, ErrFeatureWriteFailed, ErrInvalidLayer } |
Public Member Functions | |
QgsVectorFileWriter (const QString &vectorFileName, const QString &fileEncoding, const QgsFields &fields, QGis::WkbType geometryType, const QgsCoordinateReferenceSystem *srs, const QString &driverName="ESRI Shapefile", const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QString *newFilename=0, SymbologyExport symbologyExport=NoSymbology) | |
create shapefile and initialize it | |
~QgsVectorFileWriter () | |
close opened shapefile for writing | |
bool | addFeature (QgsFeature &feature, QgsFeatureRendererV2 *renderer=0, QGis::UnitType outputUnit=QGis::Meters) |
add feature to the currently opened shapefile | |
QMap< int, int > | attrIdxToOgrIdx () |
QString | errorMessage () |
retrieves error message | |
WriterError | hasError () |
checks whether there were any errors in constructor | |
void | setSymbologyExport (SymbologyExport symExport) |
void | setSymbologyScaleDenominator (double d) |
SymbologyExport | symbologyExport () const |
double | symbologyScaleDenominator () const |
Static Public Member Functions | |
static QString | convertCodecNameForEncodingOption (const QString &codecName) |
Converts codec name to string passed to ENCODING layer creation option of OGR Shapefile. | |
static bool | deleteShapeFile (QString theFileName) |
Delete a shapefile (and its accompanying shx / dbf / prf) | |
static bool | driverMetadata (const QString &driverName, MetaData &driverMetadata) |
static QString | fileFilterString () |
Returns filter string that can be used for dialogs. | |
static QString | filterForDriver (const QString &driverName) |
Creates a filter for an OGR driver key. | |
static QMap< QString, QString > | ogrDriverList () |
Returns driver list that can be used for dialogs. | |
static QMap< QString, QString > | supportedFiltersAndFormats () |
Returns map with format filter string as key and OGR format key as value. | |
static WriterError | writeAsVectorFormat (QgsVectorLayer *layer, const QString &fileName, const QString &fileEncoding, const QgsCoordinateReferenceSystem *destCRS, const QString &driverName="ESRI Shapefile", bool onlySelected=false, QString *errorMessage=0, const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), bool skipAttributeCreation=false, QString *newFilename=0, SymbologyExport symbologyExport=NoSymbology, double symbologyScale=1.0, const QgsRectangle *filterExtent=0) |
Write contents of vector layer to an (OGR supported) vector formt. | |
static WriterError | writeAsVectorFormat (QgsVectorLayer *layer, const QString &fileName, const QString &fileEncoding, const QgsCoordinateTransform *ct, const QString &driverName="ESRI Shapefile", bool onlySelected=false, QString *errorMessage=0, const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), bool skipAttributeCreation=false, QString *newFilename=0, SymbologyExport symbologyExport=NoSymbology, double symbologyScale=1.0, const QgsRectangle *filterExtent=0) |
Protected Member Functions | |
OGRGeometryH | createEmptyGeometry (QGis::WkbType wkbType) |
Protected Attributes | |
QMap< int, int > | mAttrIdxToOgrIdx |
map attribute indizes to OGR field indexes | |
QTextCodec * | mCodec |
OGRDataSourceH | mDS |
WriterError | mError |
contains error value if construction was not successful | |
QString | mErrorMessage |
QgsFields | mFields |
OGRGeometryH | mGeom |
OGRLayerH | mLayer |
SymbologyExport | mSymbologyExport |
double | mSymbologyScaleDenominator |
Scale for symbology export (e.g. | |
QGis::WkbType | mWkbType |
geometry type which is being used |
A convenience class for writing vector files to disk.
There are two possibilities how to use this class:
Currently supports only writing to shapefiles, but shouldn't be a problem to add capability to support other OGR-writable formats.
Definition at line 42 of file qgsvectorfilewriter.h.
Definition at line 45 of file qgsvectorfilewriter.h.
Definition at line 156 of file qgsvectorfilewriter.h.
NoError | |
ErrDriverNotFound | |
ErrCreateDataSource | |
ErrCreateLayer | |
ErrAttributeTypeUnsupported | |
ErrAttributeCreationFailed | |
ErrProjection | |
ErrFeatureWriteFailed | |
ErrInvalidLayer |
Definition at line 143 of file qgsvectorfilewriter.h.
QgsVectorFileWriter::QgsVectorFileWriter | ( | const QString & | vectorFileName, |
const QString & | fileEncoding, | ||
const QgsFields & | fields, | ||
QGis::WkbType | geometryType, | ||
const QgsCoordinateReferenceSystem * | srs, | ||
const QString & | driverName = "ESRI Shapefile" , |
||
const QStringList & | datasourceOptions = QStringList() , |
||
const QStringList & | layerOptions = QStringList() , |
||
QString * | newFilename = 0 , |
||
SymbologyExport | symbologyExport = NoSymbology |
||
) |
create shapefile and initialize it
Definition at line 57 of file qgsvectorfilewriter.cpp.
QgsVectorFileWriter::~QgsVectorFileWriter | ( | ) |
close opened shapefile for writing
Definition at line 1783 of file qgsvectorfilewriter.cpp.
bool QgsVectorFileWriter::addFeature | ( | QgsFeature & | feature, |
QgsFeatureRendererV2 * | renderer = 0 , |
||
QGis::UnitType | outputUnit = QGis::Meters |
||
) |
add feature to the currently opened shapefile
Definition at line 1560 of file qgsvectorfilewriter.cpp.
|
inline |
Definition at line 253 of file qgsvectorfilewriter.h.
|
static |
Converts codec name to string passed to ENCODING layer creation option of OGR Shapefile.
Definition at line 2205 of file qgsvectorfilewriter.cpp.
|
protected |
Definition at line 493 of file qgsvectorfilewriter.cpp.
|
static |
Delete a shapefile (and its accompanying shx / dbf / prf)
theFileName | /path/to/file.shp |
Definition at line 2054 of file qgsvectorfilewriter.cpp.
|
static |
Definition at line 1531 of file qgsvectorfilewriter.cpp.
QString QgsVectorFileWriter::errorMessage | ( | ) |
retrieves error message
Definition at line 1555 of file qgsvectorfilewriter.cpp.
|
static |
Returns filter string that can be used for dialogs.
Definition at line 2178 of file qgsvectorfilewriter.cpp.
|
static |
Creates a filter for an OGR driver key.
Definition at line 2193 of file qgsvectorfilewriter.cpp.
QgsVectorFileWriter::WriterError QgsVectorFileWriter::hasError | ( | ) |
checks whether there were any errors in constructor
Definition at line 1550 of file qgsvectorfilewriter.cpp.
|
static |
Returns driver list that can be used for dialogs.
It contains all OGR drivers
Definition at line 2106 of file qgsvectorfilewriter.cpp.
|
inline |
Definition at line 265 of file qgsvectorfilewriter.h.
|
inline |
Definition at line 268 of file qgsvectorfilewriter.h.
|
static |
Returns map with format filter string as key and OGR format key as value.
Definition at line 2079 of file qgsvectorfilewriter.cpp.
|
inline |
Definition at line 264 of file qgsvectorfilewriter.h.
|
inline |
Definition at line 267 of file qgsvectorfilewriter.h.
|
static |
Write contents of vector layer to an (OGR supported) vector formt.
layer | layer to write |
fileName | file name to write to |
fileEncoding | encoding to use |
destCRS | pointer to CRS to reproject exported geometries to |
driverName | OGR driver to use |
onlySelected | write only selected features of layer |
errorMessage | pointer to buffer fo error message |
datasourceOptions | list of OGR data source creation options |
layerOptions | list of OGR layer creation options |
skipAttributeCreation | only write geometries |
newFilename | QString pointer which will contain the new file name created (in case it is different to fileName). |
symbologyExport | symbology to export |
symbologyScale | scale of symbology |
filterExtent | if not a null pointer, only features intersecting the extent will be saved |
Definition at line 1797 of file qgsvectorfilewriter.cpp.
|
static |
Definition at line 1824 of file qgsvectorfilewriter.cpp.
|
protected |
map attribute indizes to OGR field indexes
Definition at line 292 of file qgsvectorfilewriter.h.
|
protected |
Definition at line 286 of file qgsvectorfilewriter.h.
|
protected |
Definition at line 276 of file qgsvectorfilewriter.h.
|
protected |
contains error value if construction was not successful
Definition at line 283 of file qgsvectorfilewriter.h.
|
protected |
Definition at line 284 of file qgsvectorfilewriter.h.
|
protected |
Definition at line 280 of file qgsvectorfilewriter.h.
|
protected |
Definition at line 278 of file qgsvectorfilewriter.h.
|
protected |
Definition at line 277 of file qgsvectorfilewriter.h.
|
protected |
Definition at line 294 of file qgsvectorfilewriter.h.
|
protected |
Scale for symbology export (e.g.
for symbols units in map units)
Definition at line 301 of file qgsvectorfilewriter.h.
|
protected |
geometry type which is being used
Definition at line 289 of file qgsvectorfilewriter.h.