Skip to content

Commit bcbc59d

Browse files
author
jef
committedJun 4, 2010
wms provider fix: shift tile requests a bit NE
git-svn-id: http://svn.osgeo.org/qgis/trunk@13652 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b655635 commit bcbc59d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed
 

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,8 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
556556
double ymax = std::min( viewExtent.yMaximum(), layerExtent.yMaximum() );
557557

558558
// snap to tile coordinates
559-
double x0 = floor(( xmin - layerExtent.xMinimum() ) / mTileWidth / tres ) * mTileWidth * tres + layerExtent.xMinimum();
560-
double y0 = floor(( ymin - layerExtent.yMinimum() ) / mTileHeight / tres ) * mTileHeight * tres + layerExtent.yMinimum();
559+
double x0 = floor(( xmin - layerExtent.xMinimum() ) / mTileWidth / tres ) * mTileWidth * tres + layerExtent.xMinimum() + mTileWidth * tres * 0.001;
560+
double y0 = floor(( ymin - layerExtent.yMinimum() ) / mTileHeight / tres ) * mTileHeight * tres + layerExtent.yMinimum() + mTileHeight * tres * 0.001;
561561

562562
#ifdef QGISDEBUG
563563
// calculate number of tiles
@@ -633,17 +633,17 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
633633
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
634634
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
635635
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ), mTileReqNo );
636-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ), j );
636+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ), i );
637637
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 2 ), QRectF( x, y, mTileWidth * tres, mTileHeight * tres ) );
638638

639639
QgsDebugMsg( QString( "gettile: %1" ).arg( turl ) );
640640
QNetworkReply *reply = QgsNetworkAccessManager::instance()->get( request );
641641
tileReplies << reply;
642642
connect( reply, SIGNAL( finished() ), this, SLOT( tileReplyFinished() ) );
643643

644-
x = x0 + k++*mTileWidth * tres;
644+
x = x0 + ++k * mTileWidth * tres;
645645
}
646-
y = y0 + j++*mTileHeight * tres;
646+
y = y0 + ++j * mTileHeight * tres;
647647
}
648648

649649
mWaiting = true;
@@ -750,8 +750,14 @@ void QgsWmsProvider::tileReplyFinished()
750750
QPainter p( cachedImage );
751751
p.drawImage( dst, myLocalImage );
752752

753-
// p.drawRect( dst ); // show tile bounds
754-
// p.drawText( dst.center(), QString( "(%1)\n%2,%3\n%4x%5" ).arg( tileNo ).arg( r.left() ).arg( r.bottom() ).arg( r.width() ).arg( r.height() ) );
753+
#if 0
754+
p.drawRect( dst ); // show tile bounds
755+
p.drawText( dst, Qt::AlignCenter, QString( "(%1)\n%2,%3\n%4,%5\n%6x%7" )
756+
.arg( tileNo )
757+
.arg( r.left() ).arg( r.bottom() )
758+
.arg( r.right() ).arg( r.top() )
759+
.arg( r.width() ).arg( r.height() ) );
760+
#endif
755761
}
756762

757763
tileReplies.removeOne( reply );
@@ -770,7 +776,7 @@ void QgsWmsProvider::tileReplyFinished()
770776
mErrors++;
771777
}
772778

773-
#if QGISDEBUG
779+
#ifdef QGISDEBUG
774780
emit statusChanged( tr( "%n tile requests in background", "tile request count", tileReplies.count() )
775781
+ tr( ", %n cache hits", "tile cache hits", mCacheHits )
776782
+ tr( ", %n cache misses.", "tile cache missed", mCacheMisses )

0 commit comments

Comments
 (0)
Please sign in to comment.