Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- log addition of user coordinate systems
- include proj.4 definitions in CRS exceptions
- raster layer: catch exception on extent transformation errors (fixes freeze in #4583)
  • Loading branch information
jef-n committed Jan 9, 2012
1 parent 2647e1d commit d5431b3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion i18n/qgis_de.ts
Expand Up @@ -12958,7 +12958,7 @@ Sollen die vorhandenen Klassen vor der Klassifizierung gelöscht werden?</transl
<message>
<location filename="../src/core/qgscoordinatetransform.cpp" line="553"/>
<source>forward transform</source>
<translation>Transformation</translation>
<translation>Vorwärtstransformation</translation>
</message>
<message>
<location filename="../src/core/qgscoordinatetransform.cpp" line="573"/>
Expand Down
4 changes: 2 additions & 2 deletions src/app/main.cpp
Expand Up @@ -187,8 +187,9 @@ void myMessageOutput( QtMsgType type, const char *msg )
break;
case QtFatalMsg:
{
fprintf( stderr, "Fatal: %s\nStacktrace (run through c++filt):\n", msg );
fprintf( stderr, "Fatal: %s\n", msg );
#ifdef linux
fprintf( stderr, "Stacktrace (run through c++filt):\n" );
void *buffer[256];
int nptrs = backtrace( buffer, sizeof( buffer ) / sizeof( *buffer ) );
backtrace_symbols_fd( buffer, nptrs, STDERR_FILENO );
Expand All @@ -198,7 +199,6 @@ void myMessageOutput( QtMsgType type, const char *msg )
}
}


int main( int argc, char *argv[] )
{
QgsDebugMsg( QString( "Starting qgis main" ) );
Expand Down
18 changes: 9 additions & 9 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -29,7 +29,7 @@
#include "qgsapplication.h"
#include "qgscrscache.h"
#include "qgslogger.h"
#include "qgsmessageoutput.h"
#include "qgsmessagelog.h"
#include "qgis.h" //const vals declared here

#include <sqlite3.h>
Expand Down Expand Up @@ -1094,7 +1094,7 @@ bool QgsCoordinateReferenceSystem::readXML( QDomNode & theNode )
setMapUnits();

//@TODO this srs needs to be validated!!!
mIsValidFlag = true;//shamelessly hard coded for now
mIsValidFlag = true; //shamelessly hard coded for now
}
}
}
Expand Down Expand Up @@ -1238,13 +1238,10 @@ int QgsCoordinateReferenceSystem::openDb( QString path, sqlite3 **db )
// XXX This will likely never happen since on open, sqlite creates the
// database if it does not exist.
// ... unfortunately it happens on Windows
QgsMessageOutput* output = QgsMessageOutput::createMessageOutput();
output->setTitle( "Error" );
output->setMessage( QObject::tr( "Could not open CRS database %1<br>Error(%2): %3" )
.arg( path )
.arg( myResult )
.arg( sqlite3_errmsg( *db ) ), QgsMessageOutput::MessageText );
output->showMessage();
QgsMessageLog::logMessage( QObject::tr( "Could not open CRS database %1\nError(%2): %3" )
.arg( path )
.arg( myResult )
.arg( sqlite3_errmsg( *db ) ), QObject::tr( "CRS" ) );
}
return myResult;
}
Expand Down Expand Up @@ -1346,6 +1343,9 @@ bool QgsCoordinateReferenceSystem::saveAsUserCRS()
QgsDebugMsg( QString( "Update or insert sql \n%1" ).arg( mySql ) );
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail );
sqlite3_step( myPreparedStatement );

QgsMessageLog::logMessage( QObject::tr( "Saved user CRS [%1]" ).arg( toProj4() ), QObject::tr( "CRS" ) );

// XXX Need to free memory from the error msg if one is set
return myResult == SQLITE_OK;
}
Expand Down
10 changes: 7 additions & 3 deletions src/core/qgscoordinatetransform.cpp
Expand Up @@ -562,17 +562,21 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
{
if ( direction == ForwardTransform )
{
points += QString( "(%1, %2)\n" ).arg( x[i] ).arg( y[i] );
points += QString( "(%1, %2)\n" ).arg( x[i], 0, 'f' ).arg( y[i], 0, 'f' );
}
else
{
points += QString( "(%1, %2)\n" ).arg( x[i] * RAD_TO_DEG ).arg( y[i] * RAD_TO_DEG );
points += QString( "(%1, %2)\n" ).arg( x[i] * RAD_TO_DEG, 0, 'f' ).arg( y[i] * RAD_TO_DEG, 0, 'f' );
}
}

QString msg = tr( "%1 of\n%2\nfailed with error: %3\n" )
QString msg = tr( "%1 of\n"
"%2"
"PROJ.4: %3 +to %4\n"
"Error: %5" )
.arg( dir )
.arg( points )
.arg( mSourceCRS.toProj4() ).arg( mDestCRS.toProj4() )
.arg( QString::fromUtf8( pj_strerrno( projResult ) ) );

QgsDebugMsg( "Projection failed emitting invalid transform signal: " + msg );
Expand Down
23 changes: 19 additions & 4 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -649,10 +649,25 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
if ( rendererContext.coordinateTransform() )
{
QgsDebugMsg( "coordinateTransform set -> project extents." );
myProjectedViewExtent = rendererContext.coordinateTransform()->transformBoundingBox(
rendererContext.extent() );
myProjectedLayerExtent = rendererContext.coordinateTransform()->transformBoundingBox(
mLayerExtent );
try
{
myProjectedViewExtent = rendererContext.coordinateTransform()->transformBoundingBox( rendererContext.extent() );
}
catch ( QgsCsException &cs )
{
QgsMessageLog::logMessage( tr( "Could not reproject view extent: %1" ).arg( cs.what() ), tr( "Raster" ) );
myProjectedViewExtent = rendererContext.extent();
}

try
{
myProjectedLayerExtent = rendererContext.coordinateTransform()->transformBoundingBox( mLayerExtent );
}
catch ( QgsCsException &cs )
{
QgsMessageLog::logMessage( tr( "Could not reproject layer extent: %1" ).arg( cs.what() ), tr( "Raster" ) );
myProjectedLayerExtent = mLayerExtent;
}
}
else
{
Expand Down

0 comments on commit d5431b3

Please sign in to comment.