mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Make QgsVectorLayerImport use QgsCoordinateReferenceSystem
references, not pointers
This commit is contained in:
parent
e683101b10
commit
a2efab0485
@ -41,6 +41,15 @@ objects are implicitly shared, returning a copy helps simplify and make code mor
|
|||||||
only affects third party c++ providers, and does not affect PyQGIS scripts.</li>
|
only affects third party c++ providers, and does not affect PyQGIS scripts.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
\subsection qgis_api_break_3_0_QgsVectorLayerImport QgsVectorLayerImport
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>QgsVectorLayerImport now takes references instead of pointers to QgsCoordinateReferenceSystem objects. Since
|
||||||
|
QgsCoordinateReferenceSystem is now implicitly shared, using references to QgsCoordinateReferenceSystem rather than
|
||||||
|
pointers makes for more robust, safer code. Use an invalid (default constructed) QgsCoordinateReferenceSystem
|
||||||
|
in code which previously passed a null pointer to QgsVectorLayerImport.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
\subsection qgis_api_break_3_0_QgsVectorFileWriter QgsVectorFileWriter
|
\subsection qgis_api_break_3_0_QgsVectorFileWriter QgsVectorFileWriter
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -31,27 +31,50 @@ class QProgressDialog;
|
|||||||
ErrUserCancelled, /*!< User cancelled the import*/
|
ErrUserCancelled, /*!< User cancelled the import*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Write contents of vector layer to a different datasource */
|
/**
|
||||||
|
* 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,
|
static ImportError importLayer( QgsVectorLayer* layer,
|
||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QString& providerKey,
|
const QString& providerKey,
|
||||||
const QgsCoordinateReferenceSystem *destCRS,
|
const QgsCoordinateReferenceSystem& destCRS,
|
||||||
bool onlySelected = false,
|
bool onlySelected = false,
|
||||||
QString *errorMessage /Out/ = 0,
|
QString *errorMessage /Out/ = nullptr,
|
||||||
bool skipAttributeCreation = false,
|
bool skipAttributeCreation = false,
|
||||||
QMap<QString, QVariant> *options = 0,
|
QMap<QString, QVariant> *options = nullptr,
|
||||||
QProgressDialog *progress = 0
|
QProgressDialog *progress = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Create a empty layer and add fields to it */
|
/** 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,
|
QgsVectorLayerImport( const QString &uri,
|
||||||
const QString &provider,
|
const QString &provider,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType geometryType,
|
QGis::WkbType geometryType,
|
||||||
const QgsCoordinateReferenceSystem* crs,
|
const QgsCoordinateReferenceSystem& crs,
|
||||||
bool overwrite = false,
|
bool overwrite = false,
|
||||||
const QMap<QString, QVariant> *options = 0,
|
const QMap<QString, QVariant> *options = nullptr,
|
||||||
QProgressDialog *progress = 0
|
QProgressDialog *progress = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Checks whether there were any errors */
|
/** Checks whether there were any errors */
|
||||||
|
@ -34,7 +34,7 @@ typedef QgsVectorLayerImport::ImportError createEmptyLayer_t(
|
|||||||
const QString &uri,
|
const QString &uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType geometryType,
|
QGis::WkbType geometryType,
|
||||||
const QgsCoordinateReferenceSystem *destCRS,
|
const QgsCoordinateReferenceSystem &destCRS,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdx,
|
QMap<int, int> *oldToNewAttrIdx,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
@ -46,7 +46,7 @@ QgsVectorLayerImport::QgsVectorLayerImport( const QString &uri,
|
|||||||
const QString &providerKey,
|
const QString &providerKey,
|
||||||
const QgsFields& fields,
|
const QgsFields& fields,
|
||||||
QGis::WkbType geometryType,
|
QGis::WkbType geometryType,
|
||||||
const QgsCoordinateReferenceSystem* crs,
|
const QgsCoordinateReferenceSystem& crs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
const QMap<QString, QVariant> *options,
|
const QMap<QString, QVariant> *options,
|
||||||
QProgressDialog *progress )
|
QProgressDialog *progress )
|
||||||
@ -206,21 +206,21 @@ QgsVectorLayerImport::ImportError
|
|||||||
QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,
|
QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,
|
||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QString& providerKey,
|
const QString& providerKey,
|
||||||
const QgsCoordinateReferenceSystem *destCRS,
|
const QgsCoordinateReferenceSystem& destCRS,
|
||||||
bool onlySelected,
|
bool onlySelected,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
bool skipAttributeCreation,
|
bool skipAttributeCreation,
|
||||||
QMap<QString, QVariant> *options,
|
QMap<QString, QVariant> *options,
|
||||||
QProgressDialog *progress )
|
QProgressDialog *progress )
|
||||||
{
|
{
|
||||||
const QgsCoordinateReferenceSystem* outputCRS;
|
QgsCoordinateReferenceSystem outputCRS;
|
||||||
QgsCoordinateTransform* ct = nullptr;
|
QgsCoordinateTransform* ct = nullptr;
|
||||||
bool shallTransform = false;
|
bool shallTransform = false;
|
||||||
|
|
||||||
if ( !layer )
|
if ( !layer )
|
||||||
return ErrInvalidLayer;
|
return ErrInvalidLayer;
|
||||||
|
|
||||||
if ( destCRS && destCRS->isValid() )
|
if ( destCRS.isValid() )
|
||||||
{
|
{
|
||||||
// This means we should transform
|
// This means we should transform
|
||||||
outputCRS = destCRS;
|
outputCRS = destCRS;
|
||||||
@ -229,7 +229,7 @@ QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This means we shouldn't transform, use source CRS as output (if defined)
|
// This means we shouldn't transform, use source CRS as output (if defined)
|
||||||
outputCRS = &layer->crs();
|
outputCRS = layer->crs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -314,8 +314,8 @@ QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,
|
|||||||
const QgsFeatureIds& ids = layer->selectedFeaturesIds();
|
const QgsFeatureIds& ids = layer->selectedFeaturesIds();
|
||||||
|
|
||||||
// Create our transform
|
// Create our transform
|
||||||
if ( destCRS )
|
if ( destCRS.isValid() )
|
||||||
ct = new QgsCoordinateTransform( layer->crs(), *destCRS );
|
ct = new QgsCoordinateTransform( layer->crs(), destCRS );
|
||||||
|
|
||||||
// Check for failure
|
// Check for failure
|
||||||
if ( !ct )
|
if ( !ct )
|
||||||
|
@ -51,11 +51,24 @@ class CORE_EXPORT QgsVectorLayerImport
|
|||||||
ErrUserCancelled, /*!< User cancelled the import*/
|
ErrUserCancelled, /*!< User cancelled the import*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Write contents of vector layer to a different datasource */
|
/**
|
||||||
|
* 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,
|
static ImportError importLayer( QgsVectorLayer* layer,
|
||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QString& providerKey,
|
const QString& providerKey,
|
||||||
const QgsCoordinateReferenceSystem *destCRS,
|
const QgsCoordinateReferenceSystem& destCRS,
|
||||||
bool onlySelected = false,
|
bool onlySelected = false,
|
||||||
QString *errorMessage = nullptr,
|
QString *errorMessage = nullptr,
|
||||||
bool skipAttributeCreation = false,
|
bool skipAttributeCreation = false,
|
||||||
@ -63,12 +76,22 @@ class CORE_EXPORT QgsVectorLayerImport
|
|||||||
QProgressDialog *progress = nullptr
|
QProgressDialog *progress = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Create a empty layer and add fields to it */
|
/** 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,
|
QgsVectorLayerImport( const QString &uri,
|
||||||
const QString &provider,
|
const QString &provider,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType geometryType,
|
QGis::WkbType geometryType,
|
||||||
const QgsCoordinateReferenceSystem* crs,
|
const QgsCoordinateReferenceSystem& crs,
|
||||||
bool overwrite = false,
|
bool overwrite = false,
|
||||||
const QMap<QString, QVariant> *options = nullptr,
|
const QMap<QString, QVariant> *options = nullptr,
|
||||||
QProgressDialog *progress = nullptr
|
QProgressDialog *progress = nullptr
|
||||||
|
@ -270,14 +270,14 @@ QString QgsNewVectorLayerDialog::runAndCreateLayer( QWidget* parent, QString* pE
|
|||||||
QgsDebugMsg( "ogr provider loaded" );
|
QgsDebugMsg( "ogr provider loaded" );
|
||||||
|
|
||||||
typedef bool ( *createEmptyDataSourceProc )( const QString&, const QString&, const QString&, QGis::WkbType,
|
typedef bool ( *createEmptyDataSourceProc )( const QString&, const QString&, const QString&, QGis::WkbType,
|
||||||
const QList< QPair<QString, QString> >&, const QgsCoordinateReferenceSystem * );
|
const QList< QPair<QString, QString> >&, const QgsCoordinateReferenceSystem & );
|
||||||
createEmptyDataSourceProc createEmptyDataSource = ( createEmptyDataSourceProc ) cast_to_fptr( myLib->resolve( "createEmptyDataSource" ) );
|
createEmptyDataSourceProc createEmptyDataSource = ( createEmptyDataSourceProc ) cast_to_fptr( myLib->resolve( "createEmptyDataSource" ) );
|
||||||
if ( createEmptyDataSource )
|
if ( createEmptyDataSource )
|
||||||
{
|
{
|
||||||
if ( geometrytype != QGis::WKBUnknown )
|
if ( geometrytype != QGis::WKBUnknown )
|
||||||
{
|
{
|
||||||
QgsCoordinateReferenceSystem srs = QgsCRSCache::instance()->crsBySrsId( crsId );
|
QgsCoordinateReferenceSystem srs = QgsCRSCache::instance()->crsBySrsId( crsId );
|
||||||
if ( !createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, &srs ) )
|
if ( !createEmptyDataSource( fileName, fileformat, enc, geometrytype, attributes, srs ) )
|
||||||
{
|
{
|
||||||
return QString::null;
|
return QString::null;
|
||||||
}
|
}
|
||||||
|
@ -245,13 +245,13 @@ bool QgsGeometryCheckerResultTab::exportErrorsDo( const QString& file )
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
typedef bool ( *createEmptyDataSourceProc )( const QString&, const QString&, const QString&, QGis::WkbType, const QList< QPair<QString, QString> >&, const QgsCoordinateReferenceSystem * );
|
typedef bool ( *createEmptyDataSourceProc )( const QString&, const QString&, const QString&, QGis::WkbType, const QList< QPair<QString, QString> >&, const QgsCoordinateReferenceSystem& );
|
||||||
createEmptyDataSourceProc createEmptyDataSource = ( createEmptyDataSourceProc ) cast_to_fptr( ogrLib.resolve( "createEmptyDataSource" ) );
|
createEmptyDataSourceProc createEmptyDataSource = ( createEmptyDataSourceProc ) cast_to_fptr( ogrLib.resolve( "createEmptyDataSource" ) );
|
||||||
if ( !createEmptyDataSource )
|
if ( !createEmptyDataSource )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( !createEmptyDataSource( file, "ESRI Shapefile", mFeaturePool->getLayer()->dataProvider()->encoding(), QGis::WKBPoint, attributes, &mFeaturePool->getLayer()->crs() ) )
|
if ( !createEmptyDataSource( file, "ESRI Shapefile", mFeaturePool->getLayer()->dataProvider()->encoding(), QGis::WKBPoint, attributes, mFeaturePool->getLayer()->crs() ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ bool QgsDb2ConnectionItem::handleDrop( const QMimeData* data, const QString& toS
|
|||||||
|
|
||||||
QgsVectorLayerImport::ImportError err;
|
QgsVectorLayerImport::ImportError err;
|
||||||
QString importError;
|
QString importError;
|
||||||
err = QgsVectorLayerImport::importLayer( srcLayer, uri, "DB2", &srcLayer->crs(), false, &importError, false, nullptr, progress );
|
err = QgsVectorLayerImport::importLayer( srcLayer, uri, "DB2", srcLayer->crs(), false, &importError, false, nullptr, progress );
|
||||||
if ( err == QgsVectorLayerImport::NoError )
|
if ( err == QgsVectorLayerImport::NoError )
|
||||||
{
|
{
|
||||||
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
|
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
|
||||||
|
@ -1263,11 +1263,10 @@ bool QgsDb2Provider::changeGeometryValues( const QgsGeometryMap &geometry_map )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsVectorLayerImport::ImportError QgsDb2Provider::createEmptyLayer(
|
QgsVectorLayerImport::ImportError QgsDb2Provider::createEmptyLayer( const QString& uri,
|
||||||
const QString& uri,
|
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
@ -1297,8 +1296,8 @@ QgsVectorLayerImport::ImportError QgsDb2Provider::createEmptyLayer(
|
|||||||
// srs->posgisSrid() seems to return the authority id which is
|
// srs->posgisSrid() seems to return the authority id which is
|
||||||
// most often the EPSG id. Hopefully DB2 has defined an SRS using this
|
// most often the EPSG id. Hopefully DB2 has defined an SRS using this
|
||||||
// value as the srid / srs_id. If not, we are out of luck.
|
// value as the srid / srs_id. If not, we are out of luck.
|
||||||
QgsDebugMsg( "srs: " + srs->toWkt() );
|
QgsDebugMsg( "srs: " + srs.toWkt() );
|
||||||
long srid = srs->postgisSrid();
|
long srid = srs.postgisSrid();
|
||||||
QgsDebugMsg( QString( "srid: %1" ).arg( srid ) );
|
QgsDebugMsg( QString( "srid: %1" ).arg( srid ) );
|
||||||
if ( srid >= 0 )
|
if ( srid >= 0 )
|
||||||
{
|
{
|
||||||
@ -1740,7 +1739,7 @@ QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem &srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
|
@ -124,7 +124,7 @@ class QgsDb2Provider : public QgsVectorDataProvider
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage = nullptr,
|
QString *errorMessage = nullptr,
|
||||||
|
@ -426,7 +426,7 @@ bool QgsMssqlConnectionItem::handleDrop( const QMimeData* data, const QString& t
|
|||||||
|
|
||||||
QgsVectorLayerImport::ImportError err;
|
QgsVectorLayerImport::ImportError err;
|
||||||
QString importError;
|
QString importError;
|
||||||
err = QgsVectorLayerImport::importLayer( srcLayer, uri, "mssql", &srcLayer->crs(), false, &importError, false, nullptr, progress );
|
err = QgsVectorLayerImport::importLayer( srcLayer, uri, "mssql", srcLayer->crs(), false, &importError, false, nullptr, progress );
|
||||||
if ( err == QgsVectorLayerImport::NoError )
|
if ( err == QgsVectorLayerImport::NoError )
|
||||||
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
|
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
|
||||||
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
|
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
|
||||||
|
@ -1650,11 +1650,10 @@ QGis::WkbType QgsMssqlProvider::getWkbType( const QString& geometryType, int dim
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsVectorLayerImport::ImportError QgsMssqlProvider::createEmptyLayer(
|
QgsVectorLayerImport::ImportError QgsMssqlProvider::createEmptyLayer( const QString& uri,
|
||||||
const QString& uri,
|
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
@ -1758,23 +1757,23 @@ QgsVectorLayerImport::ImportError QgsMssqlProvider::createEmptyLayer(
|
|||||||
|
|
||||||
// set up spatial reference id
|
// set up spatial reference id
|
||||||
int srid = 0;
|
int srid = 0;
|
||||||
if ( srs->isValid() )
|
if ( srs.isValid() )
|
||||||
{
|
{
|
||||||
srid = srs->srsid();
|
srid = srs.srsid();
|
||||||
QString auth_srid = "null";
|
QString auth_srid = "null";
|
||||||
QString auth_name = "null";
|
QString auth_name = "null";
|
||||||
QStringList sl = srs->authid().split( ':' );
|
QStringList sl = srs.authid().split( ':' );
|
||||||
if ( sl.length() == 2 )
|
if ( sl.length() == 2 )
|
||||||
{
|
{
|
||||||
auth_name = '\'' + sl[0] + '\'';
|
auth_name = '\'' + sl[0] + '\'';
|
||||||
auth_srid = sl[1];
|
auth_srid = sl[1];
|
||||||
}
|
}
|
||||||
sql = QString( "IF NOT EXISTS (SELECT * FROM spatial_ref_sys WHERE srid=%1) INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text) VALUES (%1, %2, %3, '%4', '%5')" )
|
sql = QString( "IF NOT EXISTS (SELECT * FROM spatial_ref_sys WHERE srid=%1) INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text) VALUES (%1, %2, %3, '%4', '%5')" )
|
||||||
.arg( srs->srsid() )
|
.arg( srs.srsid() )
|
||||||
.arg( auth_name,
|
.arg( auth_name,
|
||||||
auth_srid,
|
auth_srid,
|
||||||
srs->toWkt(),
|
srs.toWkt(),
|
||||||
srs->toProj4() );
|
srs.toProj4() );
|
||||||
if ( !q.exec( sql ) )
|
if ( !q.exec( sql ) )
|
||||||
{
|
{
|
||||||
if ( errorMessage )
|
if ( errorMessage )
|
||||||
@ -1958,7 +1957,7 @@ QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem &srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
|
@ -192,7 +192,7 @@ class QgsMssqlProvider : public QgsVectorDataProvider
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem &srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage = nullptr,
|
QString *errorMessage = nullptr,
|
||||||
|
@ -196,11 +196,10 @@ void QgsOgrProvider::repack()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QgsVectorLayerImport::ImportError QgsOgrProvider::createEmptyLayer(
|
QgsVectorLayerImport::ImportError QgsOgrProvider::createEmptyLayer( const QString& uri,
|
||||||
const QString& uri,
|
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
@ -2438,7 +2437,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
|
|||||||
const QString &encoding,
|
const QString &encoding,
|
||||||
QGis::WkbType vectortype,
|
QGis::WkbType vectortype,
|
||||||
const QList< QPair<QString, QString> > &attributes,
|
const QList< QPair<QString, QString> > &attributes,
|
||||||
const QgsCoordinateReferenceSystem *srs = nullptr )
|
const QgsCoordinateReferenceSystem& srs = QgsCoordinateReferenceSystem() )
|
||||||
{
|
{
|
||||||
QgsDebugMsg( QString( "Creating empty vector layer with format: %1" ).arg( format ) );
|
QgsDebugMsg( QString( "Creating empty vector layer with format: %1" ).arg( format ) );
|
||||||
|
|
||||||
@ -2493,9 +2492,9 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
|
|||||||
OGRSpatialReferenceH reference = nullptr;
|
OGRSpatialReferenceH reference = nullptr;
|
||||||
|
|
||||||
QgsCoordinateReferenceSystem mySpatialRefSys;
|
QgsCoordinateReferenceSystem mySpatialRefSys;
|
||||||
if ( srs )
|
if ( srs.isValid() )
|
||||||
{
|
{
|
||||||
mySpatialRefSys = *srs;
|
mySpatialRefSys = srs;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3335,7 +3334,7 @@ QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem &srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
|
@ -54,7 +54,7 @@ class QgsOgrProvider : public QgsVectorDataProvider
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem &srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage = nullptr,
|
QString *errorMessage = nullptr,
|
||||||
|
@ -233,7 +233,7 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData * data, QString toSchema )
|
|||||||
|
|
||||||
QgsVectorLayerImport::ImportError err;
|
QgsVectorLayerImport::ImportError err;
|
||||||
QString importError;
|
QString importError;
|
||||||
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri( false ), "postgres", &srcLayer->crs(), false, &importError, false, nullptr, progress );
|
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri( false ), "postgres", srcLayer->crs(), false, &importError, false, nullptr, progress );
|
||||||
if ( err == QgsVectorLayerImport::NoError )
|
if ( err == QgsVectorLayerImport::NoError )
|
||||||
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
|
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
|
||||||
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
|
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
|
||||||
|
@ -3462,11 +3462,10 @@ bool QgsPostgresProvider::convertField( QgsField &field, const QMap<QString, QVa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
|
QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer( const QString& uri,
|
||||||
const QString& uri,
|
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
@ -3615,7 +3614,7 @@ QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
|
|||||||
|
|
||||||
// get geometry type, dim and srid
|
// get geometry type, dim and srid
|
||||||
int dim = 2;
|
int dim = 2;
|
||||||
long srid = srs->postgisSrid();
|
long srid = srs.postgisSrid();
|
||||||
|
|
||||||
QgsPostgresConn::postgisWkbType( wkbType, geometryType, dim );
|
QgsPostgresConn::postgisWkbType( wkbType, geometryType, dim );
|
||||||
|
|
||||||
@ -3854,7 +3853,7 @@ QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
|
@ -58,7 +58,7 @@ class QgsPostgresProvider : public QgsVectorDataProvider
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem &srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage = nullptr,
|
QString *errorMessage = nullptr,
|
||||||
|
@ -232,7 +232,7 @@ bool QgsSLConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction )
|
|||||||
QgsDebugMsg( "URI " + destUri.uri() );
|
QgsDebugMsg( "URI " + destUri.uri() );
|
||||||
QgsVectorLayerImport::ImportError err;
|
QgsVectorLayerImport::ImportError err;
|
||||||
QString importError;
|
QString importError;
|
||||||
err = QgsVectorLayerImport::importLayer( srcLayer, destUri.uri(), "spatialite", &srcLayer->crs(), false, &importError, false, nullptr, progress );
|
err = QgsVectorLayerImport::importLayer( srcLayer, destUri.uri(), "spatialite", srcLayer->crs(), false, &importError, false, nullptr, progress );
|
||||||
if ( err == QgsVectorLayerImport::NoError )
|
if ( err == QgsVectorLayerImport::NoError )
|
||||||
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
|
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
|
||||||
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
|
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
|
||||||
|
@ -93,11 +93,10 @@ bool QgsSpatiaLiteProvider::convertField( QgsField &field )
|
|||||||
|
|
||||||
|
|
||||||
QgsVectorLayerImport::ImportError
|
QgsVectorLayerImport::ImportError
|
||||||
QgsSpatiaLiteProvider::createEmptyLayer(
|
QgsSpatiaLiteProvider::createEmptyLayer( const QString& uri,
|
||||||
const QString& uri,
|
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
@ -224,7 +223,7 @@ QgsSpatiaLiteProvider::createEmptyLayer(
|
|||||||
|
|
||||||
// get geometry type, dim and srid
|
// get geometry type, dim and srid
|
||||||
int dim = 2;
|
int dim = 2;
|
||||||
long srid = srs->postgisSrid();
|
long srid = srs.postgisSrid();
|
||||||
|
|
||||||
switch ( wkbType )
|
switch ( wkbType )
|
||||||
{
|
{
|
||||||
@ -5075,7 +5074,7 @@ QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage,
|
QString *errorMessage,
|
||||||
|
@ -59,7 +59,7 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
|
|||||||
const QString& uri,
|
const QString& uri,
|
||||||
const QgsFields &fields,
|
const QgsFields &fields,
|
||||||
QGis::WkbType wkbType,
|
QGis::WkbType wkbType,
|
||||||
const QgsCoordinateReferenceSystem *srs,
|
const QgsCoordinateReferenceSystem& srs,
|
||||||
bool overwrite,
|
bool overwrite,
|
||||||
QMap<int, int> *oldToNewAttrIdxMap,
|
QMap<int, int> *oldToNewAttrIdxMap,
|
||||||
QString *errorMessage = nullptr,
|
QString *errorMessage = nullptr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user