Skip to content

Commit

Permalink
wms provider fix: shift tile requests a bit NE
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13652 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 4, 2010
1 parent b655635 commit bcbc59d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
double ymax = std::min( viewExtent.yMaximum(), layerExtent.yMaximum() );

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

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

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

x = x0 + k++*mTileWidth * tres;
x = x0 + ++k * mTileWidth * tres;
}
y = y0 + j++*mTileHeight * tres;
y = y0 + ++j * mTileHeight * tres;
}

mWaiting = true;
Expand Down Expand Up @@ -750,8 +750,14 @@ void QgsWmsProvider::tileReplyFinished()
QPainter p( cachedImage );
p.drawImage( dst, myLocalImage );

// p.drawRect( dst ); // show tile bounds
// 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() ) );
#if 0
p.drawRect( dst ); // show tile bounds
p.drawText( dst, Qt::AlignCenter, QString( "(%1)\n%2,%3\n%4,%5\n%6x%7" )
.arg( tileNo )
.arg( r.left() ).arg( r.bottom() )
.arg( r.right() ).arg( r.top() )
.arg( r.width() ).arg( r.height() ) );
#endif
}

tileReplies.removeOne( reply );
Expand All @@ -770,7 +776,7 @@ void QgsWmsProvider::tileReplyFinished()
mErrors++;
}

#if QGISDEBUG
#ifdef QGISDEBUG
emit statusChanged( tr( "%n tile requests in background", "tile request count", tileReplies.count() )
+ tr( ", %n cache hits", "tile cache hits", mCacheHits )
+ tr( ", %n cache misses.", "tile cache missed", mCacheMisses )
Expand Down

0 comments on commit bcbc59d

Please sign in to comment.