QGIS API Documentation
2.6.0-Brighton
|
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 | WriterError { NoError = 0, ErrDriverNotFound, ErrCreateDataSource, ErrCreateLayer, ErrAttributeTypeUnsupported, ErrAttributeCreationFailed, ErrProjection, ErrFeatureWriteFailed, ErrInvalidLayer } |
enum | SymbologyExport { NoSymbology = 0, FeatureSymbology, SymbolLayerSymbology } |
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 | |
WriterError | hasError () |
checks whether there were any errors in constructor | |
QString | errorMessage () |
retrieves error message | |
bool | addFeature (QgsFeature &feature, QgsFeatureRendererV2 *renderer=0, QGis::UnitType outputUnit=QGis::Meters) |
add feature to the currently opened shapefile | |
QMap< int, int > | attrIdxToOgrIdx () |
~QgsVectorFileWriter () | |
close opened shapefile for writing | |
SymbologyExport | symbologyExport () const |
void | setSymbologyExport (SymbologyExport symExport) |
double | symbologyScaleDenominator () const |
void | setSymbologyScaleDenominator (double d) |
Static Public Member Functions | |
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) |
static QMap< QString, QString > | supportedFiltersAndFormats () |
Returns map with format filter string as key and OGR format key as value. | |
static QMap< QString, QString > | ogrDriverList () |
Returns driver list that can be used for dialogs. | |
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 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) |
Protected Member Functions | |
OGRGeometryH | createEmptyGeometry (QGis::WkbType wkbType) |
Protected Attributes | |
OGRDataSourceH | mDS |
OGRLayerH | mLayer |
OGRGeometryH | mGeom |
QgsFields | mFields |
WriterError | mError |
contains error value if construction was not successful | |
QString | mErrorMessage |
QTextCodec * | mCodec |
QGis::WkbType | mWkbType |
geometry type which is being used | |
QMap< int, int > | mAttrIdxToOgrIdx |
map attribute indizes to OGR field indexes | |
SymbologyExport | mSymbologyExport |
double | mSymbologyScaleDenominator |
Scale for symbology export (e.g. |
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.
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
QgsVectorFileWriter::~QgsVectorFileWriter | ( | ) |
close opened shapefile for writing
bool QgsVectorFileWriter::addFeature | ( | QgsFeature & | feature, |
QgsFeatureRendererV2 * | renderer = 0 , |
||
QGis::UnitType | outputUnit = QGis::Meters |
||
) |
add feature to the currently opened shapefile
|
inline |
|
static |
Converts codec name to string passed to ENCODING layer creation option of OGR Shapefile.
|
protected |
|
static |
Delete a shapefile (and its accompanying shx / dbf / prf)
theFileName | /path/to/file.shp |
|
static |
QString QgsVectorFileWriter::errorMessage | ( | ) |
retrieves error message
|
static |
Returns filter string that can be used for dialogs.
|
static |
Creates a filter for an OGR driver key.
QgsVectorFileWriter::WriterError QgsVectorFileWriter::hasError | ( | ) |
checks whether there were any errors in constructor
|
static |
Returns driver list that can be used for dialogs.
It contains all OGR drivers
|
inline |
|
inline |
|
static |
Returns map with format filter string as key and OGR format key as value.
|
inline |
|
inline |
|
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 |
|
static |
|
protected |
map attribute indizes to OGR field indexes
|
protected |
|
protected |
|
protected |
contains error value if construction was not successful
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Scale for symbology export (e.g.
for symbols units in map units)
|
protected |
geometry type which is being used