22 QgsQuadtreeChunkLoaderFactory::QgsQuadtreeChunkLoaderFactory() =
default;
24 QgsQuadtreeChunkLoaderFactory::~QgsQuadtreeChunkLoaderFactory() =
default;
26 void QgsQuadtreeChunkLoaderFactory::setupQuadtree(
const QgsAABB &rootBbox,
float rootError,
int maxLevel )
29 mRootError = rootError;
33 QgsChunkNode *QgsQuadtreeChunkLoaderFactory::createRootNode()
const
35 return new QgsChunkNode( QgsChunkNodeId( 0, 0, 0 ), mRootBbox, mRootError );
38 QVector<QgsChunkNode *> QgsQuadtreeChunkLoaderFactory::createChildren( QgsChunkNode *node )
const
40 QVector<QgsChunkNode *> children;
42 if ( node->level() >= mMaxLevel )
45 const QgsChunkNodeId nodeId = node->tileId();
46 const float childError = node->error() / 2;
47 const QgsAABB bbox = node->bbox();
50 for (
int i = 0; i < 4; ++i )
52 int dx = i & 1, dy = !!( i & 2 );
53 const QgsChunkNodeId childId( nodeId.d + 1, nodeId.x * 2 + dx, nodeId.y * 2 + ( dy ? 0 : 1 ) );
57 const float chXMin = dx ? xc : bbox.
xMin;
58 const float chXMax = dx ? bbox.
xMax : xc;
59 const float chZMin = dy ? zc : bbox.
zMin;
60 const float chZMax = dy ? bbox.
zMax : zc;
61 const float chYMin = bbox.
yMin;
62 const float chYMax = bbox.
yMax;
63 children <<
new QgsChunkNode( childId,
QgsAABB( chXMin, chYMin, chZMin, chXMax, chYMax, chZMax ), childError, node );
float xCenter() const
Returns center in X axis.
float zCenter() const
Returns center in Z axis.