Skip to content
Permalink
Browse files

Order tile requests according to their distance from view center

... so we first receive tiles in the middle rather those at the border
  • Loading branch information
wonder-sk committed Sep 1, 2016
1 parent b919198 commit a5039d6d73efc582640083b6cf542f035e5e86d2
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/providers/wms/qgswmsprovider.cpp
@@ -79,6 +79,18 @@ static QString DEFAULT_LATLON_CRS = "CRS:84";

QMap<QString, QgsWmsStatistics::Stat> QgsWmsStatistics::sData;

//! a helper class for ordering tile requests according to the distance from view center
struct LessThanTileRequest
{
QgsPoint center;
bool operator()( const QgsWmsTiledImageDownloadHandler::TileRequest &req1, const QgsWmsTiledImageDownloadHandler::TileRequest &req2 )
{
QPointF p1 = req1.rect.center();
QPointF p2 = req2.rect.center();
return center.distance( p1.x(), p1.y() ) < center.distance( p2.x(), p2.y() );
}
};


QgsWmsProvider::QgsWmsProvider( QString const& uri, const QgsWmsCapabilities* capabilities )
: QgsRasterDataProvider( uri )
@@ -887,6 +899,11 @@ QImage *QgsWmsProvider::draw( QgsRectangle const & viewExtent, int pixelWidth, i
if ( feedback && memCached + diskCached > 0 )
feedback->onNewData();

// order tile requests according to the distance from view center
LessThanTileRequest cmp;
cmp.center = viewExtent.center();
qSort( requestsFinal.begin(), requestsFinal.end(), cmp );

QgsWmsTiledImageDownloadHandler handler( dataSourceUri(), mSettings.authorization(), mTileReqNo, requestsFinal, image, viewExtent, mSettings.mSmoothPixmapTransform, feedback );
handler.downloadBlocking();
}

0 comments on commit a5039d6

Please sign in to comment.
You can’t perform that action at this time.