Skip to content
Permalink
Browse files
- 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
  • Loading branch information
vmora authored and m-kuhn committed Jul 18, 2013
1 parent ba35b23 commit f04abe05a082634f5b584d7f004ede7e74b69b11
Showing with 18 additions and 10 deletions.
  1. +7 −7 src/core/qgsdistancearea.cpp
  2. +11 −3 src/gui/qgshighlight.cpp
@@ -463,20 +463,20 @@ double QgsDistanceArea::measureLine( const QgsPoint& p1, const QgsPoint& p2 )
{
QgsPoint pp1 = p1, pp2 = p2;

QgsDebugMsg( QString( "Measuring from %1 to %2" ).arg( p1.toString( 4 ) ).arg( p2.toString( 4 ) ) );
QgsDebugMsgLevel( QString( "Measuring from %1 to %2" ).arg( p1.toString( 4 ) ).arg( p2.toString( 4 ) ), 3 );
if ( mEllipsoidalMode && ( mEllipsoid != GEO_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() ) );
QgsDebugMsgLevel( QString( "Ellipsoidal calculations is enabled, using ellipsoid %1" ).arg( mEllipsoid ), 4 );
QgsDebugMsgLevel( QString( "From proj4 : %1" ).arg( mCoordTransform->sourceCrs().toProj4() ), 4 );
QgsDebugMsgLevel( QString( "To proj4 : %1" ).arg( mCoordTransform->destCRS().toProj4() ), 4 );
pp1 = mCoordTransform->transform( p1 );
pp2 = mCoordTransform->transform( p2 );
QgsDebugMsg( QString( "New points are %1 and %2, calculating..." ).arg( pp1.toString( 4 ) ).arg( pp2.toString( 4 ) ) );
QgsDebugMsgLevel( QString( "New points are %1 and %2, calculating..." ).arg( pp1.toString( 4 ) ).arg( pp2.toString( 4 ) ), 4 );
result = computeDistanceBearing( pp1, pp2 );
}
else
{
QgsDebugMsg( "Cartesian calculation on canvas coordinates" );
QgsDebugMsgLevel( "Cartesian calculation on canvas coordinates", 4 );
result = sqrt(( p2.x() - p1.x() ) * ( p2.x() - p1.x() ) + ( p2.y() - p1.y() ) * ( p2.y() - p1.y() ) );
}
}
@@ -486,7 +486,7 @@ double QgsDistanceArea::measureLine( const QgsPoint& p1, const QgsPoint& p2 )
QgsMessageLog::logMessage( QObject::tr( "Caught a coordinate system exception while trying to transform a point. Unable to calculate line length." ) );
result = 0.0;
}
QgsDebugMsg( QString( "The result was %1" ).arg( result ) );
QgsDebugMsgLevel( QString( "The result was %1" ).arg( result ), 3 );
return result;
}

@@ -100,14 +100,22 @@ void QgsHighlight::paintPolygon( QPainter *p, QgsPolygon polygon )

for ( int i = 0; i < polygon.size(); i++ )
{
QPolygonF ring( polygon[i].size() + 1 );
if ( polygon[i].empty() ) continue;

QPolygonF ring;
ring.reserve( polygon[i].size() + 1 );

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

ring[ polygon[i].size()] = ring[ 0 ];
ring.push_back( ring[ 0 ] );

path.addPolygon( ring );
}

0 comments on commit f04abe0

Please sign in to comment.