Skip to content
Permalink
Browse files

merge import_layer branch

  • Loading branch information
brushtyler committed Sep 13, 2011
2 parents f2b6876 + 6eb406b commit 262ec3f8f5e181f013b9b97da71fead7b21664ec
@@ -84,6 +84,7 @@
%Include qgsvectordataprovider.sip
%Include qgsvectorfilewriter.sip
%Include qgsvectorlayer.sip
%Include qgsvectorlayerimport.sip
%Include qgsvectoroverlay.sip

%Include qgsnetworkaccessmanager.sip
@@ -60,8 +60,6 @@ class QgsProviderRegistry
* @note this method was added in QGIS 1.1
*/
virtual QString protocolDrivers() const;



private:

@@ -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();
};

@@ -101,6 +101,7 @@ SET(QGIS_CORE_SRCS
qgsvectordataprovider.cpp
qgsvectorfilewriter.cpp
qgsvectorlayer.cpp
qgsvectorlayerimport.cpp
qgsvectorlayerjoinbuffer.cpp
qgsvectorlayerundocommand.cpp
qgsvectoroverlay.cpp
@@ -333,6 +334,7 @@ SET(QGIS_CORE_HDRS
qgsvectordataprovider.h
qgsvectorfilewriter.h
qgsvectorlayer.h
qgsvectorlayerimport.h
qgsvectoroverlay.h
qgstolerance.h

@@ -30,6 +30,7 @@
#include "qgslogger.h"
#include "qgsmessageoutput.h"
#include "qgsprovidermetadata.h"
#include "qgsvectorlayer.h"


// typedefs for provider plugin functions of interest
@@ -468,7 +469,7 @@ void * QgsProviderRegistry::function( QString const & providerKey,
return 0;
}

QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey )
QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey ) const
{
QString lib = library( providerKey );

@@ -28,7 +28,8 @@

class QgsDataProvider;
class QgsProviderMetadata;

class QgsVectorLayer;
class QgsCoordinateReferenceSystem;


/** \ingroup core
@@ -78,7 +79,7 @@ class CORE_EXPORT QgsProviderRegistry
void *function( const QString & providerKey,
const QString & functionName );

QLibrary *providerLibrary( const QString & providerKey );
QLibrary *providerLibrary( const QString & providerKey ) const;

/** Return list of available providers by their keys */
QStringList providerList() const;
@@ -116,6 +116,8 @@ class CORE_EXPORT QgsVectorFileWriter
/** add feature to the currently opened shapefile */
bool addFeature( QgsFeature& feature );

QMap<int, int> attrIdxToOgrIdx() { return mAttrIdxToOgrIdx; }

/** close opened shapefile for writing */
~QgsVectorFileWriter();

0 comments on commit 262ec3f

Please sign in to comment.
You can’t perform that action at this time.