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 QgsChunkNodeId nodeId = node->tileId();
46 float childError = node->error() / 2;
50 for (
int i = 0; i < 4; ++i )
52 int dx = i & 1, dy = !!( i & 2 );
53 QgsChunkNodeId childId( nodeId.d + 1, nodeId.x * 2 + dx, nodeId.y * 2 + ( dy ? 0 : 1 ) );
57 float chXMin = dx ? xc : bbox.
xMin;
58 float chXMax = dx ? bbox.
xMax : xc;
59 float chZMin = dy ? zc : bbox.
zMin;
60 float chZMax = dy ? bbox.
zMax : zc;
61 float chYMin = bbox.
yMin;
62 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.