Skip to content
Permalink
Browse files

call saveAsUserCRS after each call to createFromProj4

  • Loading branch information
leyan committed Apr 16, 2013
1 parent cc6b010 commit 989514124bc665f3bf2b38fcb145962aacc12aab
@@ -134,6 +134,17 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString theDefinition
if ( reCrsStr.cap( 1 ).toLower() == "proj4" )
{
result = createFromProj4( reCrsStr.cap( 2 ) );
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS(myName);
}
}
else
{
@@ -460,6 +471,17 @@ bool QgsCoordinateReferenceSystem::createFromWkt( QString theWkt )

createFromProj4( proj4src );
}
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( mSrsId == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS(myName);
}

CPLFree( proj4src );

@@ -1190,6 +1212,18 @@ bool QgsCoordinateReferenceSystem::readXML( QDomNode & theNode )
//@TODO this srs needs to be validated!!!
mIsValidFlag = true; //shamelessly hard coded for now
}
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( mSrsId == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( toProj4() );
saveAsUserCRS(myName);
}

}
}
else
@@ -212,6 +212,18 @@ bool QgsDistanceArea::setEllipsoid( const QString& ellipsoid )
QString proj4 = "+proj=longlat +ellps=" + ellipsoid + " +no_defs";
QgsCoordinateReferenceSystem destCRS;
destCRS.createFromProj4( proj4 );
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( destCRS.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( destCRS.toProj4() );
destCRS.saveAsUserCRS(myName);
}
//

// set transformation from project CRS to ellipsoid coordinates
mCoordTransform->setDestCRS( destCRS );
@@ -81,6 +81,20 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
// No? Skip this entry
continue;
}
else
{
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( crs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( crs.toProj4() );
crs.saveAsUserCRS(myName);
}
}
}
mRecentProjections << QString::number( crs.srsid() );
}
@@ -1524,6 +1524,18 @@ void QgsSLDParser::setCrsForLayer( const QDomElement& layerElem, QgsMapLayer* ml
{
QgsCoordinateReferenceSystem srs;
srs.createFromProj4( projString );
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( srs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( srs.toProj4() );
srs.saveAsUserCRS(myName);
}

ml->setCrs( srs );
}
}
@@ -221,6 +221,17 @@ int GRASS_LIB_EXPORT QgsGrassGisLib::G__gisinit( const char * version, const cha
{
fatal( "Cannot create CRS from QGIS_GRASS_CRS: " + crsStr );
}
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( mCrs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( mCrs.toProj4() );
mCrs.saveAsUserCRS(myName);
}
}
mDistanceArea.setSourceCrs( mCrs.srsid() );

@@ -3200,6 +3200,18 @@ QgsCoordinateReferenceSystem QgsSpatiaLiteProvider::crs()
if ( !srs.isValid() )
{
srs.createFromProj4( mProj4text );
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( srs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( srs.toProj4() );
srs.saveAsUserCRS(myName);
}

}
return srs;
}
@@ -1886,6 +1886,17 @@ QgsSqlAnywhereProvider::checkSrs()
SaDebugMsg( "Failed to create CRS from Proj4 description. Trying WKT." );
mCrs.createFromWkt( srsWkt );
}
//TODO: createFromProj4 used to save to the user database any new CRS
// this behavior was changed in order to separate creation and saving.
// Not sure if it necessary to save it here, should be checked by someone
// familiar with the code (should also give a more descriptive name to the generated CRS)
if( mCrs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( mCrs.toProj4() );
mCrs.saveAsUserCRS(myName);
}

return true;
} // QgsSqlAnywhereProvider::checkSrs()

0 comments on commit 9895141

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