QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgstiledsceneindex.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstiledsceneindex.cpp
3 --------------------
4 begin : June 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgstiledsceneindex.h"
19
20#include "qgsfeedback.h"
21#include "qgstiledscenetile.h"
22
23//
24// QgsAbstractTiledSceneIndex
25//
26
28{
29 mContentCache.setMaxCost( 10000 );
30}
31
33
34QByteArray QgsAbstractTiledSceneIndex::retrieveContent( const QString &uri, QgsFeedback *feedback )
35{
36 QMutexLocker locker( &mCacheMutex );
37 if ( QByteArray *cachedData = mContentCache.object( uri ) )
38 {
39 return *cachedData;
40 }
41 locker.unlock();
42
43 const QByteArray res = fetchContent( uri, feedback );
44 if ( feedback && feedback->isCanceled() )
45 return QByteArray();
46
47 locker.relock();
48 mContentCache.insert( uri, new QByteArray( res ) );
49 return res;
50}
51
52//
53// QgsTiledSceneIndex
54//
55
61
63
65 : mIndex( other.mIndex )
66{
67
68}
69
71 : mIndex( std::move( other.mIndex ) )
72{
73
74}
75
77{
78 if ( this == &other )
79 return *this;
80
81 mIndex = other.mIndex;
82 return *this;
83}
84
86{
87 if ( this == &other )
88 return *this;
89
90 mIndex = std::move( other.mIndex );
91 return *this;
92}
93
95{
96 return static_cast< bool >( mIndex.get() );
97}
98
100{
101 if ( !mIndex )
102 return QgsTiledSceneTile();
103
104 return mIndex->rootTile();
105}
106
108{
109 if ( !mIndex )
110 return QgsTiledSceneTile();
111
112 return mIndex->getTile( id );
113}
114
115long long QgsTiledSceneIndex::parentTileId( long long id ) const
116{
117 if ( !mIndex )
118 return -1;
119
120 return mIndex->parentTileId( id );
121}
122
123QVector< long long > QgsTiledSceneIndex::childTileIds( long long id ) const
124{
125 if ( !mIndex )
126 return {};
127
128 return mIndex->childTileIds( id );
129}
130
131QVector< long long > QgsTiledSceneIndex::getTiles( const QgsTiledSceneRequest &request )
132{
133 if ( !mIndex )
134 return {};
135
136 return mIndex->getTiles( request );
137}
138
140{
141 if ( !mIndex )
143
144 return mIndex->childAvailability( id );
145}
146
147bool QgsTiledSceneIndex::fetchHierarchy( long long id, QgsFeedback *feedback )
148{
149 if ( !mIndex )
150 return {};
151
152 return mIndex->fetchHierarchy( id, feedback );
153}
154
155QByteArray QgsTiledSceneIndex::retrieveContent( const QString &uri, QgsFeedback *feedback )
156{
157 if ( !mIndex )
158 return QByteArray();
159
160 return mIndex->retrieveContent( uri, feedback );
161}
162
TileChildrenAvailability
Possible availability states for a tile's children.
Definition qgis.h:5668
@ NoChildren
Tile is known to have no children.
Definition qgis.h:5669
An abstract base class for tiled scene data provider indices.
virtual ~QgsAbstractTiledSceneIndex()
QByteArray retrieveContent(const QString &uri, QgsFeedback *feedback=nullptr)
Retrieves index content for the specified uri.
virtual QByteArray fetchContent(const QString &uri, QgsFeedback *feedback=nullptr)=0
Fetches index content for the specified uri.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
bool isCanceled() const
Tells whether the operation has been canceled already.
Definition qgsfeedback.h:53
Qgis::TileChildrenAvailability childAvailability(long long id) const
Returns the availability for a tile's children.
QgsTiledSceneTile rootTile() const
Returns the root tile for the index.
QByteArray retrieveContent(const QString &uri, QgsFeedback *feedback=nullptr)
Retrieves index content for the specified uri.
bool fetchHierarchy(long long id, QgsFeedback *feedback=nullptr)
Populates the tile with the given id by fetching any sub datasets attached to the tile.
QVector< long long > childTileIds(long long id) const
Returns a list of the tile IDs of any children for the tile with matching id.
QgsTiledSceneIndex(QgsAbstractTiledSceneIndex *index=nullptr)
Constructor for QgsTiledSceneIndex.
QgsTiledSceneTile getTile(long long id)
Returns the tile with matching id, or an invalid tile if the matching tile is not available.
QgsTiledSceneIndex & operator=(const QgsTiledSceneIndex &other)
QVector< long long > getTiles(const QgsTiledSceneRequest &request)
Returns the list of tile IDs which match the given request.
long long parentTileId(long long id) const
Returns the tile ID of the parent tile of the tile with matching id, or -1 if the tile has no parent.
bool isValid() const
Returns true if the index is valid.
Tiled scene data request.
Represents an individual tile from a tiled scene data source.