qgscoordtransform.patch

Merged my and Jef's patch in translator-friendly way. It doesn't fix this issue, just part of it. - marisn -, 2009-12-24 04:14 AM

Download (4.14 KB)

View differences:

src/core/qgscoordinatetransform.cpp (working copy)
22 22
//qt includes
23 23
#include <QDomNode>
24 24
#include <QDomElement>
25
#include <QTextStream>
26 25
#include <QApplication>
27 26
#include "qgslogger.h"
28 27

  
......
227 226
  catch ( QgsCsException &cse )
228 227
  {
229 228
    // rethrow the exception
230
    QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
229
    QgsDebugMsg( "rethrowing exception" );
231 230
    throw cse;
232 231
  }
233 232

  
......
244 243
  catch ( QgsCsException &cse )
245 244
  {
246 245
    // rethrow the exception
247
    QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
246
    QgsDebugMsg( "rethrowing exception" );
248 247
    throw cse;
249 248
  }
250 249
}
......
270 269
  catch ( QgsCsException &cse )
271 270
  {
272 271
    // rethrow the exception
273
    QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
272
    QgsDebugMsg( "rethrowing exception" );
274 273
    throw cse;
275 274
  }
276 275

  
......
304 303
  catch ( QgsCsException &cse )
305 304
  {
306 305
    // rethrow the exception
307
    QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
306
    QgsDebugMsg( "rethrowing exception" );
308 307
    throw cse;
309 308
  }
310 309
}
......
330 329
  catch ( QgsCsException &cse )
331 330
  {
332 331
    // rethrow the exception
333
    QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
332
    QgsDebugMsg( "rethrowing exception" );
334 333
    throw cse;
335 334
  }
336 335
}
......
394 393
  catch ( QgsCsException &cse )
395 394
  {
396 395
    // rethrow the exception
397
    QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
396
    QgsDebugMsg( "rethrowing exception" );
398 397
    throw cse;
399 398
  }
400 399

  
......
436 435
#endif
437 436

  
438 437
  // use proj4 to do the transform
439
  QString dir;
440 438
  // if the source/destination projection is lat/long, convert the points to radians
441 439
  // prior to transforming
442 440
  if (( pj_is_latlong( mDestinationProjection ) && ( direction == ReverseTransform ) )
......
454 452
  if ( direction == ReverseTransform )
455 453
  {
456 454
    projResult = pj_transform( mDestinationProjection, mSourceProjection, numPoints, 0, x, y, z );
457
    dir = "inverse";
458 455
  }
459 456
  else
460 457
  {
461 458
    assert( mSourceProjection != 0 );
462 459
    assert( mDestinationProjection != 0 );
463 460
    projResult = pj_transform( mSourceProjection, mDestinationProjection, numPoints, 0, x, y, z );
464
    dir = "forward";
465 461
  }
466 462

  
467 463
  if ( projResult != 0 )
468 464
  {
469 465
    //something bad happened....
470 466
    QString msg;
471
    QTextStream pjErr( &msg );
467
    QString points;
472 468

  
473
    pjErr << tr( "Failed" ) << " " << dir << " " << tr( "transform of" ) << '\n';
474 469
    for ( int i = 0; i < numPoints; ++i )
475 470
    {
476 471
      if ( direction == ForwardTransform )
477 472
      {
478
        pjErr << "(" << x[i] << ", " << y[i] << ")\n";
473
        points += QString( "(%1, %2)\n" ).arg( x[i] ).arg( y[i] );
479 474
      }
480 475
      else
481 476
      {
482
        pjErr << "(" << x[i] * RAD_TO_DEG << ", " << y[i] * RAD_TO_DEG << ")\n";
477
        points += QString( "(%1, %2)\n" ).arg( x[i] * RAD_TO_DEG ).arg( y[i] * RAD_TO_DEG );
483 478
      }
484 479
    }
485 480

  
486
    pjErr << tr( "with error: " ) << QString::fromUtf8( pj_strerrno( projResult ) ) << '\n';
481
    if ( direction == ForwardTransform )
482
    {
483
      QString msg = tr( "Forward transform of\n%2\nfailed with error: %3\n" )
484
                    .arg( points )
485
                    .arg( pj_strerrno( projResult ) );
486
    }
487
    else
488
    {
489
      QString msg = tr( "Inverse transform of\n%2\nfailed with error: %3\n" )
490
                    .arg( points )
491
                    .arg( pj_strerrno( projResult ) );
492
    }
487 493

  
488
    QgsDebugMsg( "Projection failed emitting invalid transform signal: " + QString( msg.toLocal8Bit().data() ) );
494
    QgsDebugMsg( "Projection failed emitting invalid transform signal: " + msg );
489 495

  
490 496
    emit invalidTransformInput();
491 497

  
492
    QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
498
    QgsDebugMsg( "throwing exception" );
499

  
493 500
    throw  QgsCsException( msg );
494 501
  }
495 502