Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1186 from ahuarte47/Issue_9360R2
Bug #9360: Whole layer not rendered (when simplify geometry activated)
  • Loading branch information
wonder-sk committed Feb 18, 2014
2 parents 49fbfba + f4f450f commit dc50304
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -716,22 +716,38 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
// resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
if ( ct && !(( QgsCoordinateTransform* )ct )->isShortCircuited() )
{
QgsPoint center = rendererContext.extent().center();
double rectSize = ct->sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
try
{
QgsPoint center = rendererContext.extent().center();
double rectSize = ct->sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;

QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
QgsRectangle targetRect = ct->transform( sourceRect );

QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
QgsRectangle targetRect = ct->transform( sourceRect );
QgsDebugMsg( QString( "Simplify - SourceTransformRect=%1" ).arg( sourceRect.toString( 16 ) ) );
QgsDebugMsg( QString( "Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );

if ( !sourceRect.isEmpty() && sourceRect.isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
{
QgsPoint minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
QgsPoint maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );

QgsPoint minimumSrcPoint( sourceRect.xMinimum(), sourceRect.yMinimum() );
QgsPoint maximumSrcPoint( sourceRect.xMaximum(), sourceRect.yMaximum() );
QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );

double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
QgsDebugMsg( QString( "Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ) );
QgsDebugMsg( QString( "Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ) );

if ( targetHypothenuse != 0 )
map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
if ( targetHypothenuse != 0 )
map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
}
}
catch ( QgsCsException &cse )
{
QgsMessageLog::logMessage( tr( "Simplify transform error caught: %1" ).arg( cse.what() ), tr( "CRS" ) );
}
}

QgsSimplifyMethod simplifyMethod;
Expand Down

0 comments on commit dc50304

Please sign in to comment.