[QGIS Commit] r9403 - in trunk/qgis/src: app core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Sep 24 10:00:55 EDT 2008


Author: homann
Date: 2008-09-24 10:00:55 -0400 (Wed, 24 Sep 2008)
New Revision: 9403

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/core/qgscoordinatereferencesystem.cpp
   trunk/qgis/src/core/qgscoordinatereferencesystem.h
   trunk/qgis/src/core/qgsmaplayer.cpp
Log:
Removed asking to validate projections of raster file, when reading a project.

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2008-09-24 12:03:21 UTC (rev 9402)
+++ trunk/qgis/src/app/qgisapp.cpp	2008-09-24 14:00:55 UTC (rev 9403)
@@ -270,7 +270,7 @@
     //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 ) )

Modified: trunk/qgis/src/core/qgscoordinatereferencesystem.cpp
===================================================================
--- trunk/qgis/src/core/qgscoordinatereferencesystem.cpp	2008-09-24 12:03:21 UTC (rev 9402)
+++ trunk/qgis/src/core/qgscoordinatereferencesystem.cpp	2008-09-24 14:00:55 UTC (rev 9403)
@@ -45,14 +45,16 @@
 
 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( 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 @@
     mSRID = srs.mSRID;
     mEpsg = srs.mEpsg;
     mIsValidFlag = srs.mIsValidFlag;
+    mValidationHint = srs.mValidationHint;
     if ( mIsValidFlag )
     {
       OSRDestroySpatialReference( mCRS );
@@ -1099,6 +1103,11 @@
   mCustomSrsValidation = f;
 }
 
+CUSTOM_CRS_VALIDATION QgsCoordinateReferenceSystem::customSrsValidation()
+{
+  return mCustomSrsValidation;
+}
+
 void QgsCoordinateReferenceSystem::debugPrint()
 {
   QgsDebugMsg( "***SpatialRefSystem***" );
@@ -1107,3 +1116,13 @@
   QgsDebugMsg( "* Proj4 : " + proj4String() );
   QgsDebugMsg( "* Desc. : " + mDescription );
 }
+
+void QgsCoordinateReferenceSystem::setValidationHint( QString html )
+{
+  mValidationHint = html;
+}
+
+QString QgsCoordinateReferenceSystem::validationHint()
+{
+  return mValidationHint;
+}

Modified: trunk/qgis/src/core/qgscoordinatereferencesystem.h
===================================================================
--- trunk/qgis/src/core/qgscoordinatereferencesystem.h	2008-09-24 12:03:21 UTC (rev 9402)
+++ trunk/qgis/src/core/qgscoordinatereferencesystem.h	2008-09-24 14:00:55 UTC (rev 9403)
@@ -248,6 +248,10 @@
      */
     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 @@
     /*! 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 @@
 
     bool loadFromDb( QString db, QString field, long id );
 
+    QString mValidationHint;
+
     static CUSTOM_CRS_VALIDATION mCustomSrsValidation;
 };
 

Modified: trunk/qgis/src/core/qgsmaplayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsmaplayer.cpp	2008-09-24 12:03:21 UTC (rev 9402)
+++ trunk/qgis/src/core/qgsmaplayer.cpp	2008-09-24 14:00:55 UTC (rev 9403)
@@ -140,6 +140,10 @@
 
 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 @@
   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 @@
   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() )



More information about the QGIS-commit mailing list