Skip to content
Permalink
Browse files

Expose control over whether custom projections are stored using proj …

…or WKT strings
  • Loading branch information
nyalldawson committed Dec 17, 2019
1 parent 67f25fe commit 8bfca7f2c8467d17d64cea8d8b961f4002461d7f
@@ -696,11 +696,14 @@ Update proj.4 parameters in our database from proj.4
This is used internally and should not be necessary to call in client code
%End

long saveAsUserCrs( const QString &name );
long saveAsUserCrs( const QString &name, bool storeWkt = true );
%Docstring
Saves the CRS as a custom ("USER") CRS.

Returns the new CRS srsid(), or -1 if the CRS could not be saved.

If ``storeWkt`` is ``True`` then the WKT representation of the CRS will be stored in the database.
If it is ``False``, then only the lossy PROJ string representation of the CRS will be stored (not recommended).
%End

QString geographicCrsAuthId() const;
@@ -2117,7 +2117,7 @@ QString QgsCoordinateReferenceSystem::validationHint()
/// Copied from QgsCustomProjectionDialog ///
/// Please refactor into SQL handler !!! ///

long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name )
long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name, bool storeWkt )
{
if ( !d->mIsValid )
{
@@ -2153,9 +2153,9 @@ long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name )
+ ',' + QgsSqliteUtils::quotedString( name )
+ ',' + ( !d->mProjectionAcronym.isEmpty() ? QgsSqliteUtils::quotedString( d->mProjectionAcronym ) : QStringLiteral( "''" ) )
+ ',' + quotedEllipsoidString
+ ',' + QgsSqliteUtils::quotedString( toProj4() )
+ ',' + ( !proj4String.isEmpty() ? QgsSqliteUtils::quotedString( proj4String ) : QStringLiteral( "''" ) )
+ ",0," // <-- is_geo shamelessly hard coded for now
+ QgsSqliteUtils::quotedString( wktString )
+ ( storeWkt ? QgsSqliteUtils::quotedString( wktString ) : QStringLiteral( "''" ) )
+ ')';
}
else
@@ -2164,9 +2164,9 @@ long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name )
+ QgsSqliteUtils::quotedString( name )
+ ',' + ( !d->mProjectionAcronym.isEmpty() ? QgsSqliteUtils::quotedString( d->mProjectionAcronym ) : QStringLiteral( "''" ) )
+ ',' + quotedEllipsoidString
+ ',' + QgsSqliteUtils::quotedString( toProj4() )
+ ',' + ( !proj4String.isEmpty() ? QgsSqliteUtils::quotedString( proj4String ) : QStringLiteral( "''" ) )
+ ",0," // <-- is_geo shamelessly hard coded for now
+ QgsSqliteUtils::quotedString( wktString )
+ ( storeWkt ? QgsSqliteUtils::quotedString( wktString ) : QStringLiteral( "''" ) )
+ ')';
}
sqlite3_database_unique_ptr database;
@@ -658,8 +658,11 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
* Saves the CRS as a custom ("USER") CRS.
*
* Returns the new CRS srsid(), or -1 if the CRS could not be saved.
*
* If \a storeWkt is TRUE then the WKT representation of the CRS will be stored in the database.
* If it is FALSE, then only the lossy PROJ string representation of the CRS will be stored (not recommended).
*/
long saveAsUserCrs( const QString &name );
long saveAsUserCrs( const QString &name, bool storeWkt = true );

//! Returns auth id of related geographic CRS
QString geographicCrsAuthId() const;

0 comments on commit 8bfca7f

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