-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Import a vector layer from a datasource to a different one
Merge of another part of my Summer of Code work (remote-tracking branch 'brushtyler/import_layer')
- Loading branch information
Showing
15 changed files
with
1,547 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
/** | ||
There are two possibilities how to use this class: | ||
1. static call to QgsVectorLayerImport::importLayer(...) which saves the whole vector layer | ||
2. create an instance of the class and issue calls to addFeature(...) | ||
*/ | ||
class QgsVectorLayerImport | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsvectorlayerimport.h> | ||
#include <qgsfield.h> | ||
%End | ||
|
||
public: | ||
|
||
enum ImportError | ||
{ | ||
NoError = 0, | ||
ErrDriverNotFound, | ||
ErrCreateDataSource, | ||
ErrCreateLayer, | ||
ErrAttributeTypeUnsupported, | ||
ErrAttributeCreationFailed, | ||
ErrProjection, | ||
ErrFeatureWriteFailed, | ||
ErrInvalidLayer, | ||
ErrInvalidProvider, | ||
ErrProviderUnsupportedFeature, | ||
ErrConnectionFailed | ||
}; | ||
|
||
/** Write contents of vector layer to a different datasource */ | ||
static ImportError importLayer( QgsVectorLayer* layer, | ||
const QString& uri, | ||
const QString& providerKey, | ||
const QgsCoordinateReferenceSystem *destCRS, | ||
bool onlySelected = FALSE, | ||
QString *errorMessage /Out/ = 0, | ||
bool skipAttributeCreation = FALSE, | ||
QMap<QString, QVariant> *options = 0 | ||
); | ||
|
||
/** create a empty layer and add fields to it */ | ||
QgsVectorLayerImport( const QString &uri, | ||
const QString &provider, | ||
const QgsFieldMap& fields, | ||
QGis::WkbType geometryType, | ||
const QgsCoordinateReferenceSystem* crs, | ||
bool overwrite = false, | ||
const QMap<QString, QVariant> *options = 0 | ||
); | ||
|
||
/** checks whether there were any errors */ | ||
ImportError hasError(); | ||
|
||
/** retrieves error message */ | ||
QString errorMessage(); | ||
|
||
/** add feature to the new created layer */ | ||
bool addFeature( QgsFeature& feature ); | ||
|
||
/** close the new created layer */ | ||
~QgsVectorLayerImport(); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.