mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-24 00:47:57 -05:00
- more API cleanups - single click (instead of drag) to select a feature (fixes #1154) - fixes for topological editing git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9471 c8812cc2-4d05-0410-92ff-de0c093fc19c
58 lines
1.8 KiB
Plaintext
58 lines
1.8 KiB
Plaintext
|
|
/**
|
|
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,
|
|
const QgsCoordinateReferenceSystem*,
|
|
bool onlySelected = FALSE);
|
|
|
|
|
|
/** create shapefile and initialize it */
|
|
QgsVectorFileWriter(const QString& shapefileName,
|
|
const QString& fileEncoding,
|
|
const QMap<int, QgsField>& fields,
|
|
QGis::WkbType geometryType,
|
|
const QgsCoordinateReferenceSystem* 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();
|
|
|
|
/** Delete a shapefile (and its accompanying shx / dbf / prf)
|
|
* @param QString theFileName - /path/to/file.shp
|
|
* @return bool true if the file was deleted successfully
|
|
*/
|
|
static bool deleteShapeFile(QString theFileName);
|
|
};
|
|
|