徐水网站建设公司,做网站 站内搜索引擎,凡科手机网站设置问题,免费模型网站前文链接#xff1a;QGraphicsView实现简易地图7『异步加载-多瓦片-无底图』 前7篇的地图加载#xff0c;都采用最少瓦片数量的算法#xff0c;即用最少数量的瓦片覆盖视口#xff0c;以获得最快的加载速度。但是这样会带来一个问题#xff0c;那就是每当移动地图时#…前文链接QGraphicsView实现简易地图7『异步加载-多瓦片-无底图』 前7篇的地图加载都采用最少瓦片数量的算法即用最少数量的瓦片覆盖视口以获得最快的加载速度。但是这样会带来一个问题那就是每当移动地图时视口周边的瓦片才会加载这样会造成地图的延时甚至卡顿而这会令用户感到非常反感。为此需要在之前的算法上进行改进加载覆盖视口的最少瓦片后立即加载视口周边瓦片加载过的瓦片离开视口后不再删除以加快下次进入视口后的渲染。 1、动态演示效果 2、获取视口及周边瓦片代码以视口宽高的一半向四周扩展
QRect CommonUtility::getViewAndAroundTileCoords(int tempTileTop, int tileLeft, int tempTileBottom, int tileRight, int level, vectorTileCoord vecTileCoord)
{// 1 视口for (int row tempTileTop; row tempTileBottom; row){for (int col tileLeft; col tileRight; col){vecTileCoord.push_back(TileCoord(col, row));}}int mapSize pow(2, level);int tileW tileRight - tileLeft 1;int tileH tempTileBottom - tempTileTop 1;int tempTileT, tempTileL, tempTileB, tempTileR;int tileT, tileL, tileB, tileR;// 2 上侧tileT tempTileT qMax(tempTileTop - tileH / 2, 0);tempTileB tempTileTop - 1;tempTileL qMax(tileLeft - tileW / 2, 0); tempTileR qMin(tileRight tileW / 2, mapSize - 1);for (int row tempTileT; row tempTileB; row){for (int col tempTileL; col tempTileR; col){vecTileCoord.push_back(TileCoord(col, row));}}// 3 下侧tempTileT tempTileBottom 1;tileB tempTileB qMin(tempTileBottom tileH / 2, mapSize - 1);tempTileL qMax(tileLeft - tileW / 2, 0);tempTileR qMin(tileRight tileW / 2, mapSize - 1);for (int row tempTileT; row tempTileB; row){for (int col tempTileL; col tempTileR; col){vecTileCoord.push_back(TileCoord(col, row));}}// 4 左侧tileL tempTileL qMax(tileLeft - tileW / 2, 0);tempTileR tileLeft - 1;for (int row tempTileTop; row tempTileBottom; row){for (int col tempTileL; col tempTileR; col){vecTileCoord.push_back(TileCoord(col, row));}}// 5 右侧tempTileL tileRight 1;tileR tempTileR qMin(tileRight tileW / 2, mapSize - 1);for (int row tempTileTop; row tempTileBottom; row){for (int col tempTileL; col tempTileR; col){vecTileCoord.push_back(TileCoord(col, row));}}return QRect(tileL, tileT, (tileR - tileL 1), (tileB - tileT 1));
}