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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jan 2 16:31:52 EST 2010


Author: jef
Date: 2010-01-02 16:31:51 -0500 (Sat, 02 Jan 2010)
New Revision: 12665

Modified:
   trunk/qgis/src/app/legend/qgslegendlayer.cpp
   trunk/qgis/src/core/qgsvectorfilewriter.cpp
   trunk/qgis/src/core/qgsvectorfilewriter.h
   trunk/qgis/src/core/qgsvectorlayer.cpp
Log:
catch more projection errors

Modified: trunk/qgis/src/app/legend/qgslegendlayer.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegendlayer.cpp	2010-01-02 19:09:13 UTC (rev 12664)
+++ trunk/qgis/src/app/legend/qgslegendlayer.cpp	2010-01-02 21:31:51 UTC (rev 12665)
@@ -606,6 +606,11 @@
       QMessageBox::warning( 0, tr( "Error" ),
                             tr( "Creation of an attribute failed" ) );
       break;
+
+    case QgsVectorFileWriter::ErrProjection:
+      QMessageBox::warning( 0, tr( "Error" ),
+                            tr( "Reprojection failed" ) );
+      break;
   }
 }
 

Modified: trunk/qgis/src/core/qgsvectorfilewriter.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorfilewriter.cpp	2010-01-02 19:09:13 UTC (rev 12664)
+++ trunk/qgis/src/core/qgsvectorfilewriter.cpp	2010-01-02 21:31:51 UTC (rev 12665)
@@ -422,7 +422,22 @@
 
     if ( shallTransform )
     {
-      fet.geometry()->transform( *ct );
+      try
+      {
+        fet.geometry()->transform( *ct );
+      }
+      catch ( QgsCsException &e )
+      {
+        delete ct;
+        delete writer;
+
+        QString msg( "Failed to transform a point while drawing a feature of type '"
+                     + fet.typeName() + "'. Writing stopped." );
+        msg += cse.what();
+        QgsLogger::warning( msg );
+
+        return ErrProjection;
+      }
     }
     writer->addFeature( fet );
   }

Modified: trunk/qgis/src/core/qgsvectorfilewriter.h
===================================================================
--- trunk/qgis/src/core/qgsvectorfilewriter.h	2010-01-02 19:09:13 UTC (rev 12664)
+++ trunk/qgis/src/core/qgsvectorfilewriter.h	2010-01-02 21:31:51 UTC (rev 12665)
@@ -49,7 +49,8 @@
       ErrCreateDataSource,
       ErrCreateLayer,
       ErrAttributeTypeUnsupported,
-      ErrAttributeCreationFailed
+      ErrAttributeCreationFailed,
+      ErrProjection // added in 1.5
     };
 
     /** Write contents of vector layer to a shapefile */

Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp	2010-01-02 19:09:13 UTC (rev 12664)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp	2010-01-02 21:31:51 UTC (rev 12665)
@@ -1024,11 +1024,11 @@
     catch ( QgsCsException &cse )
     {
       QString msg( "Failed to transform a point while drawing a feature of type '"
-                   + fet.typeName() + "'. Ignoring this feature." );
+                   + fet.typeName() + "'. Rendering stopped." );
       msg += cse.what();
       QgsLogger::warning( msg );
+      return false;
     }
-
   }
   else
   {
@@ -1040,7 +1040,7 @@
     QgsDebugMsg( QString( "Cached %1 geometries." ).arg( mCachedGeometries.count() ) );
   }
 
-  return TRUE; // Assume success always
+  return true; // Assume success always
 }
 
 void QgsVectorLayer::deleteCachedGeometries()
@@ -1942,7 +1942,7 @@
   }
 
   //look if id of selected feature belongs to an added feature
-  /*
+#if 0
   for ( QgsFeatureList::iterator addedIt = mAddedFeatures.begin(); addedIt != mAddedFeatures.end(); ++addedIt )
   {
     if ( addedIt->id() == selectedFeatureId )
@@ -1951,7 +1951,7 @@
       mCachedGeometries[selectedFeatureId] = *addedIt->geometry();
     }
   }
-  */
+#endif
 
   //is the feature contained in the view extent (mCachedGeometries) ?
   QgsGeometryMap::iterator cachedIt = mCachedGeometries.find( selectedFeatureId );
@@ -2000,7 +2000,7 @@
   }
 
   //look if id of selected feature belongs to an added feature
-  /*
+#if 0
   for ( QgsFeatureList::iterator addedIt = mAddedFeatures.begin(); addedIt != mAddedFeatures.end(); ++addedIt )
   {
     if ( addedIt->id() == featureId )
@@ -2008,7 +2008,7 @@
       return addedIt->geometry()->translate( dx, dy );
     }
   }
-  */
+#endif
 
   //else look in mCachedGeometries to make access faster
   QgsGeometryMap::iterator cachedIt = mCachedGeometries.find( featureId );



More information about the QGIS-commit mailing list