Skip to content
Permalink
Browse files

- 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 d5431b3035e7dcd34dc338dfed67162c200bee8d
<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"/>
@@ -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 );
@@ -198,7 +199,6 @@ void myMessageOutput( QtMsgType type, const char *msg )
}
}


int main( int argc, char *argv[] )
{
QgsDebugMsg( QString( "Starting qgis main" ) );
@@ -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>
@@ -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
}
}
}
@@ -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;
}
@@ -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;
}
@@ -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 );
@@ -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
{

0 comments on commit d5431b3

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