Skip to content
Permalink
Browse files
Removed asking to validate projections of raster file, when reading a…
… project.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9403 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Sep 24, 2008
1 parent 17ed363 commit 317291f6976e961e860afcc53d966ee4aebc9db7
Showing with 59 additions and 10 deletions.
  1. +1 −1 src/app/qgisapp.cpp
  2. +22 −3 src/core/qgscoordinatereferencesystem.cpp
  3. +14 −0 src/core/qgscoordinatereferencesystem.h
  4. +22 −6 src/core/qgsmaplayer.cpp
@@ -270,7 +270,7 @@ static void customSrsValidation_( QgsCoordinateReferenceSystem* srs )
//it in the ctor of the layer projection selector

QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector();
mySelector->setMessage(); //shows a generic message
mySelector->setMessage( srs->validationHint() ); //shows a generic message, if not speficied
proj4String = QgsProject::instance()->readEntry( "SpatialRefSys", "//ProjectCRSProj4String", GEOPROJ4 );
QgsCoordinateReferenceSystem defaultCRS;
if ( defaultCRS.createFromProj4( proj4String ) )
@@ -45,14 +45,16 @@ CUSTOM_CRS_VALIDATION QgsCoordinateReferenceSystem::mCustomSrsValidation = NULL;

QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem()
: mMapUnits( QGis::UNKNOWN ),
mIsValidFlag( 0 )
mIsValidFlag( 0 ),
mValidationHint ( 0 )
{
mCRS = OSRNewSpatialReference( NULL );
}

QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem( QString theWkt )
: mMapUnits( QGis::UNKNOWN ),
mIsValidFlag( 0 )
mIsValidFlag( 0 ),
mValidationHint ( 0 )
{
mCRS = OSRNewSpatialReference( NULL );
createFromWkt( theWkt );
@@ -61,7 +63,8 @@ QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem( QString theWkt )

QgsCoordinateReferenceSystem::QgsCoordinateReferenceSystem( const long theId, CRS_TYPE theType )
: mMapUnits( QGis::UNKNOWN ),
mIsValidFlag( 0 )
mIsValidFlag( 0 ),
mValidationHint ( 0 )
{
mCRS = OSRNewSpatialReference( NULL );
createFromId( theId, theType );
@@ -138,6 +141,7 @@ QgsCoordinateReferenceSystem& QgsCoordinateReferenceSystem::operator=( const Qgs
mSRID = srs.mSRID;
mEpsg = srs.mEpsg;
mIsValidFlag = srs.mIsValidFlag;
mValidationHint = srs.mValidationHint;
if ( mIsValidFlag )
{
OSRDestroySpatialReference( mCRS );
@@ -1099,6 +1103,11 @@ void QgsCoordinateReferenceSystem::setCustomSrsValidation( CUSTOM_CRS_VALIDATION
mCustomSrsValidation = f;
}

CUSTOM_CRS_VALIDATION QgsCoordinateReferenceSystem::customSrsValidation()
{
return mCustomSrsValidation;
}

void QgsCoordinateReferenceSystem::debugPrint()
{
QgsDebugMsg( "***SpatialRefSystem***" );
@@ -1107,3 +1116,13 @@ void QgsCoordinateReferenceSystem::debugPrint()
QgsDebugMsg( "* Proj4 : " + proj4String() );
QgsDebugMsg( "* Desc. : " + mDescription );
}

void QgsCoordinateReferenceSystem::setValidationHint( QString html )
{
mValidationHint = html;
}

QString QgsCoordinateReferenceSystem::validationHint()
{
return mValidationHint;
}
@@ -248,6 +248,10 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
*/
static void setCustomSrsValidation( CUSTOM_CRS_VALIDATION f );

/** Gets custom function
*/
static CUSTOM_CRS_VALIDATION customSrsValidation();

// Accessors -----------------------------------

/*! Get the SrsId - if possible
@@ -336,6 +340,14 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
/*! Print the description if debugging
*/
void debugPrint();

/*! Set user hint for validation
*/
void setValidationHint( QString html );

/*! Get user hint for validation
*/
QString validationHint();
private:
// Open SQLite db and show message if ccannot be opened
// returns the same code as sqlite3_open
@@ -367,6 +379,8 @@ class CORE_EXPORT QgsCoordinateReferenceSystem

bool loadFromDb( QString db, QString field, long id );

QString mValidationHint;

static CUSTOM_CRS_VALIDATION mCustomSrsValidation;
};

@@ -140,6 +140,10 @@ void QgsMapLayer::drawLabels( QgsRenderContext& rendererContext )

bool QgsMapLayer::readXML( QDomNode & layer_node )
{
QgsCoordinateReferenceSystem savedCRS;
CUSTOM_CRS_VALIDATION savedValidation;
bool layerError;

QDomElement element = layer_node.toElement();

// XXX not needed? QString type = element.attribute("type");
@@ -149,15 +153,31 @@ bool QgsMapLayer::readXML( QDomNode & layer_node )
QDomElement mne = mnl.toElement();
mDataSource = mne.text();

// Set the CRS so that we don't ask the user.
// Set the CRS from project file, asking the user if necessary.
// Make it the saved CRS to have WMS layer projected correctly.
// We will still overwrite whatever GDAL etc picks up anyway
// further down this function.
QDomNode srsNode = layer_node.namedItem( "srs" );
mCRS->readXML( srsNode );
mCRS->validate();
savedCRS = *mCRS;

// Do not validate any projections in children, they will be overwritten anyway.
// No need to ask the user for a projections when it is overwritten, is there?
savedValidation = QgsCoordinateReferenceSystem::customSrsValidation();
QgsCoordinateReferenceSystem::setCustomSrsValidation( NULL );

// now let the children grab what they need from the Dom node.
if ( !readXml( layer_node ) )
layerError = !readXml( layer_node );

// overwrite CRS with what we read from project file before the raster/vector
// file readnig functions changed it. They will if projections is specfied in the file.
// FIXME: is this necessary?
QgsCoordinateReferenceSystem::setCustomSrsValidation( savedValidation );
*mCRS = savedCRS;

// Abort if any error in layer, such as not found.
if ( layerError )
{
return false;
}
@@ -195,10 +215,6 @@ bool QgsMapLayer::readXML( QDomNode & layer_node )
mne = mnl.toElement();
setLayerName( mne.text() );

// overwrite srs
// FIXME: is this necessary?
mCRS->readXML( srsNode );

//read transparency level
QDomNode transparencyNode = layer_node.namedItem( "transparencyLevelInt" );
if ( ! transparencyNode.isNull() )

0 comments on commit 317291f

Please sign in to comment.