Skip to content

Commit

Permalink
Loads of debug output. Shouldn't affect functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
homann committed Aug 23, 2012
1 parent 4be392a commit dd4de85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/app/qgsmeasuredialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void QgsMeasureDialog::mouseMove( QgsPoint &point )
convertMeasurement( d, myDisplayUnits, false );
QTreeWidgetItem *item = mTable->topLevelItem( mTable->topLevelItemCount() - 1 );
item->setText( 0, QLocale::system().toString( d, 'f', decimalPlaces ) );
QgsDebugMsg( QString( "Final result is %1" ).arg( item->text( 0 ) ) );
}
}

Expand Down Expand Up @@ -257,18 +258,20 @@ void QgsMeasureDialog::convertMeasurement( double &measure, QGis::UnitType &u, b
// The parameter &u is out only...

QGis::UnitType myUnits = mTool->canvas()->mapUnits();
QgsDebugMsg( QString( "Canvas units are %1" ).arg( QgsDistanceArea::textUnit( 1.0, 1, myUnits, false, true ) ) );
if (( myUnits == QGis::Degrees || myUnits == QGis::Feet ) &&
mcbProjectionEnabled->isChecked() )
{
// Measuring on an ellipsoid returns meters, and so does using projections???
myUnits = QGis::Meters;
QgsDebugMsg( "We're measuring on an ellipsoid or using projections, the system is returning meters" );
QgsDebugMsg( "We were measuring on an ellipsoid, the calculation returned meters" );
QgsDebugMsg( QString( "Set new units to %1" ).arg( QgsDistanceArea::textUnit( 1.0, 1, myUnits, false, true ) ) );
}

// Get the units for display
QSettings settings;
QString myDisplayUnitsTxt = settings.value( "/qgis/measure/displayunits", "meters" ).toString();

QgsDebugMsg( QString( "Preferred display units are %1" ).arg( myDisplayUnitsTxt ) );
// Only convert between meters and feet
if ( myUnits == QGis::Meters && myDisplayUnitsTxt == "feet" )
{
Expand Down
17 changes: 14 additions & 3 deletions src/core/qgsdistancearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,26 +372,37 @@ double QgsDistanceArea::measureLine( const QList<QgsPoint>& points )

double QgsDistanceArea::measureLine( const QgsPoint& p1, const QgsPoint& p2 )
{
double result;

try
{
QgsPoint pp1 = p1, pp2 = p2;

QgsDebugMsg( QString( "Measuring from %1 to %2" ).arg( p1.toString( 4 ) ).arg( p2.toString( 4 ) ) );
if ( mProjectionsEnabled && ( mEllipsoid != "NONE" ) )
{
QgsDebugMsg( QString( "Ellipsoidal calculations is enabled, using ellipsoid %1" ).arg( mEllipsoid ) );
QgsDebugMsg( QString( "From proj4 : %1" ).arg( mCoordTransform->sourceCrs().toProj4() ) );
QgsDebugMsg( QString( "To proj4 : %1" ).arg( mCoordTransform->destCRS().toProj4() ) );
pp1 = mCoordTransform->transform( p1 );
pp2 = mCoordTransform->transform( p2 );
return computeDistanceBearing( pp1, pp2 );
QgsDebugMsg( QString( "New points are %1 and %2, calculating..." ).arg( pp1.toString( 4 ) ).arg( pp2.toString( 4 ) ) );
result = computeDistanceBearing( pp1, pp2 );
}
else
{
return sqrt(( p2.x() - p1.x() )*( p2.x() - p1.x() ) + ( p2.y() - p1.y() )*( p2.y() - p1.y() ) );
QgsDebugMsg( "Cartesian calculation on canvas coordinates" );
result = sqrt(( p2.x() - p1.x() ) * ( p2.x() - p1.x() ) + ( p2.y() - p1.y() ) * ( p2.y() - p1.y() ) );
}
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse );
QgsMessageLog::logMessage( QObject::tr( "Caught a coordinate system exception while trying to transform a point. Unable to calculate line length." ) );
return 0.0;
result = 0.0;
}
QgsDebugMsg( QString( "The result was %1" ).arg( result ) );
return result;
}


Expand Down

0 comments on commit dd4de85

Please sign in to comment.