mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Move parent tile ID filter to QgsTiledMeshRequest
This commit is contained in:
parent
c42407143e
commit
ce0358ef74
@ -69,12 +69,10 @@ Returns a list of the tile IDs of any children for the tile with matching ``id``
|
||||
.. seealso:: :py:func:`parentTileId`
|
||||
%End
|
||||
|
||||
QStringList getTiles( const QgsTiledMeshRequest &request, const QString &parentId = QString() );
|
||||
QStringList getTiles( const QgsTiledMeshRequest &request );
|
||||
%Docstring
|
||||
Returns the list of tile IDs which match the given ``request``.
|
||||
|
||||
An optional ``parentID`` can be used to limit the results to children of a specific tile.
|
||||
|
||||
May return an empty list if no data satisfies the request.
|
||||
%End
|
||||
|
||||
|
||||
@ -81,6 +81,20 @@ Returns the feedback object that can be queried regularly by the request to chec
|
||||
if it should be canceled, if set.
|
||||
|
||||
.. seealso:: :py:func:`setFeedback`
|
||||
%End
|
||||
|
||||
QString parentTileId() const;
|
||||
%Docstring
|
||||
Returns the parent tile ID, if filtering is limited to children of a specific tile.
|
||||
|
||||
.. seealso:: :py:func:`setParentTileId`
|
||||
%End
|
||||
|
||||
void setParentTileId( const QString &id );
|
||||
%Docstring
|
||||
Sets the parent tile ``id``, if filtering is to be limited to children of a specific tile.
|
||||
|
||||
.. seealso:: :py:func:`parentTileId`
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
@ -66,7 +66,7 @@ class QgsCesiumTiledMeshIndex final : public QgsAbstractTiledMeshIndex
|
||||
QgsTiledMeshTile getTile( const QString &id ) final;
|
||||
QString parentTileId( const QString &id ) const final;
|
||||
QStringList childTileIds( const QString &id ) const final;
|
||||
QStringList getTiles( const QgsTiledMeshRequest &request, const QString &parentId = QString() ) final;
|
||||
QStringList getTiles( const QgsTiledMeshRequest &request ) final;
|
||||
bool tileCanRefine( const QString &id ) const final;
|
||||
bool refineAsync( const QString &id, QgsFeedback *feedback = nullptr ) final;
|
||||
|
||||
@ -311,7 +311,7 @@ QStringList QgsCesiumTiledMeshIndex::childTileIds( const QString &id ) const
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList QgsCesiumTiledMeshIndex::getTiles( const QgsTiledMeshRequest &request, const QString &parentId )
|
||||
QStringList QgsCesiumTiledMeshIndex::getTiles( const QgsTiledMeshRequest &request )
|
||||
{
|
||||
QStringList results;
|
||||
|
||||
@ -361,14 +361,14 @@ QStringList QgsCesiumTiledMeshIndex::getTiles( const QgsTiledMeshRequest &reques
|
||||
};
|
||||
|
||||
QgsReadWriteLocker locker( mLock, QgsReadWriteLocker::Read );
|
||||
if ( parentId.isEmpty() )
|
||||
if ( request.parentTileId().isEmpty() )
|
||||
{
|
||||
if ( mRootNode )
|
||||
traverseNode( mRootNode.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = mNodeMap.constFind( parentId );
|
||||
auto it = mNodeMap.constFind( request.parentTileId() );
|
||||
if ( it != mNodeMap.constEnd() )
|
||||
{
|
||||
traverseNode( it.value() );
|
||||
|
||||
@ -110,12 +110,12 @@ QStringList QgsTiledMeshIndex::childTileIds( const QString &id ) const
|
||||
return mIndex->childTileIds( id );
|
||||
}
|
||||
|
||||
QStringList QgsTiledMeshIndex::getTiles( const QgsTiledMeshRequest &request, const QString &parentId )
|
||||
QStringList QgsTiledMeshIndex::getTiles( const QgsTiledMeshRequest &request )
|
||||
{
|
||||
if ( !mIndex )
|
||||
return {};
|
||||
|
||||
return mIndex->getTiles( request, parentId );
|
||||
return mIndex->getTiles( request );
|
||||
}
|
||||
|
||||
bool QgsTiledMeshIndex::tileCanRefine( const QString &id ) const
|
||||
|
||||
@ -80,11 +80,9 @@ class CORE_EXPORT QgsAbstractTiledMeshIndex
|
||||
/**
|
||||
* Returns the tile IDs which match the given \a request.
|
||||
*
|
||||
* An optional \a parentID can be used to limit the results to children of a specific tile.
|
||||
*
|
||||
* May return an empty list if no data satisfies the request.
|
||||
*/
|
||||
virtual QStringList getTiles( const QgsTiledMeshRequest &request, const QString &parentId = QString() ) = 0;
|
||||
virtual QStringList getTiles( const QgsTiledMeshRequest &request ) = 0;
|
||||
|
||||
/**
|
||||
* Retrieves index content for the specified \a uri.
|
||||
@ -197,11 +195,9 @@ class CORE_EXPORT QgsTiledMeshIndex
|
||||
/**
|
||||
* Returns the list of tile IDs which match the given \a request.
|
||||
*
|
||||
* An optional \a parentID can be used to limit the results to children of a specific tile.
|
||||
*
|
||||
* May return an empty list if no data satisfies the request.
|
||||
*/
|
||||
QStringList getTiles( const QgsTiledMeshRequest &request, const QString &parentId = QString() );
|
||||
QStringList getTiles( const QgsTiledMeshRequest &request );
|
||||
|
||||
/**
|
||||
* Returns TRUE if the tile with the given \a id can be further refined.
|
||||
|
||||
@ -28,4 +28,3 @@ QgsFeedback *QgsTiledMeshRequest::feedback() const
|
||||
{
|
||||
return mFeedback;
|
||||
}
|
||||
|
||||
|
||||
@ -95,11 +95,26 @@ class CORE_EXPORT QgsTiledMeshRequest
|
||||
*/
|
||||
QgsFeedback *feedback() const;
|
||||
|
||||
/**
|
||||
* Returns the parent tile ID, if filtering is limited to children of a specific tile.
|
||||
*
|
||||
* \see setParentTileId()
|
||||
*/
|
||||
QString parentTileId() const { return mParentTileId; }
|
||||
|
||||
/**
|
||||
* Sets the parent tile \a id, if filtering is to be limited to children of a specific tile.
|
||||
*
|
||||
* \see parentTileId()
|
||||
*/
|
||||
void setParentTileId( const QString &id ) { mParentTileId = id; }
|
||||
|
||||
private:
|
||||
|
||||
QgsOrientedBox3D mFilterBox;
|
||||
QgsFeedback *mFeedback = nullptr;
|
||||
double mRequiredGeometricError = 0;
|
||||
QString mParentTileId;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -956,7 +956,8 @@ class TestQgsCesiumTiledMeshLayer(unittest.TestCase):
|
||||
QgsOrientedBox3D([-5061003.9912, 2571496.4091, -2824930.1882], [-21.0400, -41.2528, 0.0000, -7.3541, 3.7508, -4.1454, -14.9480, 7.6239, 33.4168]))
|
||||
|
||||
# restrict request to one parent tile
|
||||
tile_ids = index.getTiles(request, parent_id)
|
||||
request.setParentTileId(parent_id)
|
||||
tile_ids = index.getTiles(request)
|
||||
self.assertEqual(len(tile_ids), 1)
|
||||
tile = index.getTile(tile_ids[0])
|
||||
self.assertEqual(tile.resources(),
|
||||
|
||||
@ -48,6 +48,10 @@ class TestQgsTiledMeshRequest(QgisTestCase):
|
||||
QgsOrientedBox3D([1, 2, 3], [1, 0, 0, 0, 2, 0, 0, 0, 3])
|
||||
)
|
||||
|
||||
self.assertFalse(request.parentTileId())
|
||||
request.setParentTileId('parent')
|
||||
self.assertEqual(request.parentTileId(), 'parent')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user