mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	* Remove deprecated Qgis::WKBType and API cleanup Renames QgsWKBTypes to QgsWkbTypes Replaces usage of the enums: * Qgis::WKBType with QgsWkbTypes::Type * Qgis::GeometryType with QgsWkbTypes::GeometryType Their values should be forward compatible (a fact that was already explited up to now by casting between the types) Renames some SSLxxx to SslXxx and URIxxx to UriXxx * Fix build warnings and simplify type handling * Add a fixer to rewrite imports * The forgotten rebase conflictThe forgotten rebase conflicts * QgsDataSourcURI > QgsDataSourceUri * QgsWKBTypes > QgsWkbTypes * Qgis.WKBGeom > QgsWkbTypes.Geom * Further python fixes * Guess what... Qgis::wkbDimensions != QgsWkbTypes::wkbDimensions * Fix tests * Python 3 updates * [travis] pull request caching cannot be disabled so at least use it in r/w mode * Fix python3 print in plugins
		
			
				
	
	
		
			105 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			3.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(...)
 | 
						|
 */
 | 
						|
class QgsVectorLayerImport
 | 
						|
{
 | 
						|
%TypeHeaderCode
 | 
						|
#include <qgsvectorlayerimport.h>
 | 
						|
#include <qgsfield.h>
 | 
						|
class QProgressDialog;
 | 
						|
%End
 | 
						|
 | 
						|
  public:
 | 
						|
 | 
						|
    enum ImportError
 | 
						|
    {
 | 
						|
      NoError,
 | 
						|
      ErrDriverNotFound,
 | 
						|
      ErrCreateDataSource,
 | 
						|
      ErrCreateLayer,
 | 
						|
      ErrAttributeTypeUnsupported,
 | 
						|
      ErrAttributeCreationFailed,
 | 
						|
      ErrProjection,
 | 
						|
      ErrFeatureWriteFailed,
 | 
						|
      ErrInvalidLayer,
 | 
						|
      ErrInvalidProvider,
 | 
						|
      ErrProviderUnsupportedFeature,
 | 
						|
      ErrConnectionFailed,
 | 
						|
      ErrUserCancelled, /*!< User cancelled the import*/
 | 
						|
    };
 | 
						|
 | 
						|
     /**
 | 
						|
     * Writes the contents of vector layer to a different datasource.
 | 
						|
     * @param layer source layer
 | 
						|
     * @param uri URI for destination data source
 | 
						|
     * @param providerKey string key for destination data provider
 | 
						|
     * @param destCRS destination CRS, or an invalid (default constructed) CRS if
 | 
						|
     * not available
 | 
						|
     * @param onlySelected set to true to export only selected features
 | 
						|
     * @param errorMessage if non-null, will be set to any error messages
 | 
						|
     * @param skipAttributeCreation set to true to skip exporting feature attributes
 | 
						|
     * @param options optional provider dataset options
 | 
						|
     * @param progress optional progress dialog to show progress of export
 | 
						|
     * @returns NoError for a successful export, or encountered error
 | 
						|
     */
 | 
						|
    static ImportError importLayer( QgsVectorLayer* layer,
 | 
						|
                                    const QString& uri,
 | 
						|
                                    const QString& providerKey,
 | 
						|
                                    const QgsCoordinateReferenceSystem& destCRS,
 | 
						|
                                    bool onlySelected = false,
 | 
						|
                                    QString *errorMessage /Out/ = nullptr,
 | 
						|
                                    bool skipAttributeCreation = false,
 | 
						|
                                    QMap<QString, QVariant> *options = nullptr,
 | 
						|
                                    QProgressDialog *progress = nullptr
 | 
						|
                                  );
 | 
						|
 | 
						|
    /** Constructor for QgsVectorLayerImport.
 | 
						|
     * @param uri URI for destination data source
 | 
						|
     * @param provider string key for destination data provider
 | 
						|
     * @param fields fields to include in created layer
 | 
						|
     * @param geometryType destination geometry type
 | 
						|
     * @param crs desired CRS, or an invalid (default constructed) CRS if
 | 
						|
     * not available
 | 
						|
     * @param overwrite set to true to overwrite any existing data source
 | 
						|
     * @param options optional provider dataset options
 | 
						|
     * @param progress optional progress dialog to show progress of export
 | 
						|
     */
 | 
						|
    QgsVectorLayerImport( const QString &uri,
 | 
						|
                          const QString &provider,
 | 
						|
                          const QgsFields &fields,
 | 
						|
                          QgsWkbTypes::Type geometryType,
 | 
						|
                          const QgsCoordinateReferenceSystem& crs,
 | 
						|
                          bool overwrite = false,
 | 
						|
                          const QMap<QString, QVariant> *options = nullptr,
 | 
						|
                          QProgressDialog *progress = nullptr
 | 
						|
                        );
 | 
						|
 | 
						|
    /** Checks whether there were any errors */
 | 
						|
    ImportError hasError();
 | 
						|
 | 
						|
    /** Retrieves error message */
 | 
						|
    QString errorMessage();
 | 
						|
 | 
						|
    int errorCount() const;
 | 
						|
 | 
						|
    /** Add feature to the new created layer */
 | 
						|
    bool addFeature( QgsFeature& feature );
 | 
						|
 | 
						|
    /** Close the new created layer */
 | 
						|
    ~QgsVectorLayerImport();
 | 
						|
 | 
						|
  protected:
 | 
						|
    /** Flush the buffer writing the features to the new layer */
 | 
						|
    bool flushBuffer();
 | 
						|
 | 
						|
    /** Create index */
 | 
						|
    bool createSpatialIndex();
 | 
						|
 | 
						|
  private:
 | 
						|
 | 
						|
    QgsVectorLayerImport( const QgsVectorLayerImport& rh );
 | 
						|
};
 |