25using namespace Qt::StringLiterals;
29QgsRectangle QgsGlobeUtils::nodeIdToLonLatRect( QgsChunkNodeId
id )
34 const double tileSize = 180.0 / std::pow( 2.0,
id.d - 1 );
35 const double lonMin =
id.x * tileSize - 180.0;
36 const double latMin =
id.y * tileSize - 90.0;
37 return QgsRectangle( lonMin, latMin, lonMin + tileSize, latMin + tileSize );
40QgsChunkNodeId QgsGlobeUtils::findSmallestIdContainingExtent(
const QgsRectangle &lonLatExtent )
42 QgsChunkNodeId id( 0, 0, 0 );
46 bool descended =
true;
50 const int childCount =
id.d == 0 ? 2 : 4;
51 for (
int i = 0; i < childCount; ++i )
53 const int dx = i & 1, dy =
id.d == 0 ? 0 : !!( i & 2 );
54 const QgsChunkNodeId childId(
id.d + 1,
id.x * 2 + dx,
id.y * 2 + dy );
55 if ( nodeIdToLonLatRect( childId ).contains( lonLatExtent ) )
77 Q_ASSERT(
id.d >= 2 );
80 const QVector<QgsVector3D> corners = {
93 box3D.
combineWith( transformed.
x(), transformed.
y(), transformed.
z() );
97 QgsDebugError( u
"Failed to transform tile corner to globe CRS"_s );
@ Reverse
Reverse/inverse transform (from destination to source).
A 3-dimensional box composed of x, y, z coordinates.
void combineWith(const QgsBox3D &box)
Expands the bbox so that it covers both the original rectangle and the given rectangle.
Custom exception class for Coordinate Reference System related exceptions.
A rectangle specified with double values.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.
#define QgsDebugError(str)