Skip to content

Commit f04abe0

Browse files
vmoram-kuhn
authored andcommittedJul 18, 2013
- fix issue4819
- modify polygon render to exclude consectuvie points that are less than a pixel appart - moved inner loop debug prints to level 3 and 4 since they where slowing down too much the code in debug
1 parent ba35b23 commit f04abe0

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed
 

‎src/core/qgsdistancearea.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,20 +463,20 @@ double QgsDistanceArea::measureLine( const QgsPoint& p1, const QgsPoint& p2 )
463463
{
464464
QgsPoint pp1 = p1, pp2 = p2;
465465

466-
QgsDebugMsg( QString( "Measuring from %1 to %2" ).arg( p1.toString( 4 ) ).arg( p2.toString( 4 ) ) );
466+
QgsDebugMsgLevel( QString( "Measuring from %1 to %2" ).arg( p1.toString( 4 ) ).arg( p2.toString( 4 ) ), 3 );
467467
if ( mEllipsoidalMode && ( mEllipsoid != GEO_NONE ) )
468468
{
469-
QgsDebugMsg( QString( "Ellipsoidal calculations is enabled, using ellipsoid %1" ).arg( mEllipsoid ) );
470-
QgsDebugMsg( QString( "From proj4 : %1" ).arg( mCoordTransform->sourceCrs().toProj4() ) );
471-
QgsDebugMsg( QString( "To proj4 : %1" ).arg( mCoordTransform->destCRS().toProj4() ) );
469+
QgsDebugMsgLevel( QString( "Ellipsoidal calculations is enabled, using ellipsoid %1" ).arg( mEllipsoid ), 4 );
470+
QgsDebugMsgLevel( QString( "From proj4 : %1" ).arg( mCoordTransform->sourceCrs().toProj4() ), 4 );
471+
QgsDebugMsgLevel( QString( "To proj4 : %1" ).arg( mCoordTransform->destCRS().toProj4() ), 4 );
472472
pp1 = mCoordTransform->transform( p1 );
473473
pp2 = mCoordTransform->transform( p2 );
474-
QgsDebugMsg( QString( "New points are %1 and %2, calculating..." ).arg( pp1.toString( 4 ) ).arg( pp2.toString( 4 ) ) );
474+
QgsDebugMsgLevel( QString( "New points are %1 and %2, calculating..." ).arg( pp1.toString( 4 ) ).arg( pp2.toString( 4 ) ), 4 );
475475
result = computeDistanceBearing( pp1, pp2 );
476476
}
477477
else
478478
{
479-
QgsDebugMsg( "Cartesian calculation on canvas coordinates" );
479+
QgsDebugMsgLevel( "Cartesian calculation on canvas coordinates", 4 );
480480
result = sqrt(( p2.x() - p1.x() ) * ( p2.x() - p1.x() ) + ( p2.y() - p1.y() ) * ( p2.y() - p1.y() ) );
481481
}
482482
}
@@ -486,7 +486,7 @@ double QgsDistanceArea::measureLine( const QgsPoint& p1, const QgsPoint& p2 )
486486
QgsMessageLog::logMessage( QObject::tr( "Caught a coordinate system exception while trying to transform a point. Unable to calculate line length." ) );
487487
result = 0.0;
488488
}
489-
QgsDebugMsg( QString( "The result was %1" ).arg( result ) );
489+
QgsDebugMsgLevel( QString( "The result was %1" ).arg( result ), 3 );
490490
return result;
491491
}
492492

‎src/gui/qgshighlight.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,22 @@ void QgsHighlight::paintPolygon( QPainter *p, QgsPolygon polygon )
100100

101101
for ( int i = 0; i < polygon.size(); i++ )
102102
{
103-
QPolygonF ring( polygon[i].size() + 1 );
103+
if ( polygon[i].empty() ) continue;
104+
105+
QPolygonF ring;
106+
ring.reserve( polygon[i].size() + 1 );
104107

105108
for ( int j = 0; j < polygon[i].size(); j++ )
106109
{
107-
ring[ j ] = toCanvasCoordinates( polygon[i][j] ) - pos();
110+
//adding point only if it is more than a pixel appart from the previous one
111+
const QPointF cur = toCanvasCoordinates( polygon[i][j] ) - pos();
112+
if ( 0 == j || std::abs( ring.back().x() - cur.x() ) > 1 || std::abs( ring.back().y() - cur.y() ) > 1 )
113+
{
114+
ring.push_back( cur );
115+
}
108116
}
109117

110-
ring[ polygon[i].size()] = ring[ 0 ];
118+
ring.push_back( ring[ 0 ] );
111119

112120
path.addPolygon( ring );
113121
}

0 commit comments

Comments
 (0)
Please sign in to comment.