17#include "moc_qgschunkloader.cpp"
23QgsQuadtreeChunkLoaderFactory::QgsQuadtreeChunkLoaderFactory() =
default;
25QgsQuadtreeChunkLoaderFactory::~QgsQuadtreeChunkLoaderFactory() =
default;
27void QgsQuadtreeChunkLoaderFactory::setupQuadtree(
const QgsBox3D &rootBox3D,
float rootError,
int maxLevel,
const QgsBox3D &clippingBox3D )
29 mRootBox3D = rootBox3D;
30 mRootError = rootError;
32 mClippingBox3D = clippingBox3D;
35QgsChunkNode *QgsQuadtreeChunkLoaderFactory::createRootNode()
const
37 return new QgsChunkNode( QgsChunkNodeId( 0, 0, 0 ), mRootBox3D, mRootError );
40QVector<QgsChunkNode *> QgsQuadtreeChunkLoaderFactory::createChildren( QgsChunkNode *node )
const
42 QVector<QgsChunkNode *> children;
44 if ( node->level() >= mMaxLevel )
47 const QgsChunkNodeId nodeId = node->tileId();
48 const float childError = node->error() / 2;
49 const QgsBox3D box3D = node->box3D();
52 for (
int i = 0; i < 4; ++i )
54 int dx = i & 1, dy = !!( i & 2 );
55 const QgsChunkNodeId childId( nodeId.d + 1, nodeId.x * 2 + dx, nodeId.y * 2 + dy );
57 const double chXMin = dx ? center.
x() : box3D.
xMinimum();
58 const double chXMax = dx ? box3D.
xMaximum() : center.
x();
59 const double chYMin = dy ? center.
y() : box3D.
yMinimum();
60 const double chYMax = dy ? box3D.
yMaximum() : center.
y();
61 const double chZMin = box3D.
zMinimum();
62 const double chZMax = box3D.
zMaximum();
63 const QgsBox3D childBox3D( chXMin, chYMin, chZMin, chXMax, chYMax, chZMax );
65 if ( mClippingBox3D.isEmpty() || childBox3D.intersects( mClippingBox3D ) )
66 children <<
new QgsChunkNode( childId, childBox3D, childError, node );
A 3-dimensional box composed of x, y, z coordinates.
double yMaximum() const
Returns the maximum y value.
double xMinimum() const
Returns the minimum x value.
double zMaximum() const
Returns the maximum z value.
QgsVector3D center() const
Returns the center of the box as a vector.
double xMaximum() const
Returns the maximum x value.
double zMinimum() const
Returns the minimum z value.
double yMinimum() const
Returns the minimum y value.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
double y() const
Returns Y coordinate.
double x() const
Returns X coordinate.