QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
59
61
63 : mIndex( other.mIndex )
64{}
65
67 : mIndex( std::move( other.mIndex ) )
68{}
69
71{
72 if ( this == &other )
73 return *this;
74
75 mIndex = other.mIndex;
76 return *this;
77}
78
80{
81 if ( this == &other )
82 return *this;
83
84 mIndex = std::move( other.mIndex );
85 return *this;
86}
87
89{
90 return static_cast< bool >( mIndex.get() );
91}
92
94{
95 if ( !mIndex )
96 return QgsTiledSceneTile();
97
98 return mIndex->rootTile();
99}
100
102{
103 if ( !mIndex )
104 return QgsTiledSceneTile();
105
106 return mIndex->getTile( id );
107}
108
109long long QgsTiledSceneIndex::parentTileId( long long id ) const
110{
111 if ( !mIndex )
112 return -1;
113
114 return mIndex->parentTileId( id );
115}
116
117QVector< long long > QgsTiledSceneIndex::childTileIds( long long id ) const
118{
119 if ( !mIndex )
120 return {};
121
122 return mIndex->childTileIds( id );
123}
124
125QVector< long long > QgsTiledSceneIndex::getTiles( const QgsTiledSceneRequest &request )
126{
127 if ( !mIndex )
128 return {};
129
130 return mIndex->getTiles( request );
131}
132
134{
135 if ( !mIndex )
137
138 return mIndex->childAvailability( id );
139}
140
141bool QgsTiledSceneIndex::fetchHierarchy( long long id, QgsFeedback *feedback )
142{
143 if ( !mIndex )
144 return {};
145
146 return mIndex->fetchHierarchy( id, feedback );
147}
148
149QByteArray QgsTiledSceneIndex::retrieveContent( const QString &uri, QgsFeedback *feedback )
150{
151 if ( !mIndex )
152 return QByteArray();
153
154 return mIndex->retrieveContent( uri, feedback );
155}
TileChildrenAvailability
Possible availability states for a tile's children.
Definition qgis.h:6024
@ NoChildren
Tile is known to have no children.
Definition qgis.h:6025
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:56
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.