Skip to content

Commit

Permalink
Introduce QgsTiledMeshIndex
Browse files Browse the repository at this point in the history
This is an equivalent of the point cloud index class, with some
notable differences:

- The class is designed to be thread safe. There's a shallow copy
QgsTiledMeshIndex class, which contains an implicitly shared
QgsAbstractTiledMeshIndex object. Tiled mesh data providers will
be accompanied by a concrete class of QgsAbstractTiledMeshIndex.
- The QgsTiledMeshIndex class takes care of thread safety by
protecting the underlying QgsAbstractTiledMeshIndex via a read/write
lock
- Callers can request tiled mesh nodes from the index by calling
QgsTiledMeshIndex::getNodes along with a QgsTiledMeshRequest object.
This will return the tree structure of nodes matching the request.
Currently only geometric error based filtering is supported
by QgsTiledMeshRequest, but bounding box based filtering will
also be introduced.
- Clients can request tile content by calling
  QgsTiledMeshIndex::retrieveContent. This will either return
a cached version of the content (if available), or retrieve and cache
the content for future retrieval. Currently this uses a custom caching
mechanism, but this will be replaced in future with
QgsTileDownloadManager. (Currently QgsTileDownloadManager lacks support
for blocking gets which is required by the index to avoid use
of local event loops)

The api is implemented by the cesium tiles data provider, which
builds the index dynamically as required from the underlying
cesium tiles tileset.json definitions. (The node index is NOT built
upfront in order to minimize memory requirements for large
tilesets). Currently the cesium index implementation only handles
single-file tilesets, with support for sub tilesets to be introduced
later.
  • Loading branch information
nyalldawson committed Jul 26, 2023
1 parent 1e49449 commit 52d8311
Show file tree
Hide file tree
Showing 15 changed files with 1,627 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ This corresponds to the root node bounding volume.
Coordinates in the returned volume are in the :py:func:`~QgsTiledMeshDataProvider.meshCrs` reference system, not the :py:func:`QgsDataProvider.crs()` system.
%End

virtual QgsTiledMeshIndex index() const = 0;
%Docstring
Returns the provider's tile index.

This is a shallow copy, implicitly shared container for an underlying :py:class:`QgsAbstractTiledMeshIndex`
implementation.

The index is thread safe and can be used safely across multiple threads or transferred between
threads.
%End

};

/************************************************************************
Expand Down
79 changes: 79 additions & 0 deletions python/core/auto_generated/tiledmesh/qgstiledmeshindex.sip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/tiledmesh/qgstiledmeshindex.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/







class QgsTiledMeshIndex
{
%Docstring(signature="appended")
An index for tiled mesh data providers.

This is a shallow copy, implicitly shared container for an underlying :py:class:`QgsAbstractTiledMeshIndex`
implementation.

The class is thread safe and can be used safely across multiple threads or transferred between
threads.

.. versionadded:: 3.34
%End

%TypeHeaderCode
#include "qgstiledmeshindex.h"
%End
public:


~QgsTiledMeshIndex();

QgsTiledMeshIndex( const QgsTiledMeshIndex &other );
%Docstring
Copy constructor
%End

bool isValid() const;
%Docstring
Returns ``True`` if the index is valid.
%End

QgsTiledMeshNode rootNode() const;
%Docstring
Returns the root node for the index.
%End

QgsTiledMeshNode *getNodes( const QgsTiledMeshRequest &request ) /Factory/;
%Docstring
Returns a node tree containing all nodes matching the given ``request``.

Caller takes ownership of the returned node.

May return ``None`` if no data satisfies the request.
%End

QByteArray retrieveContent( const QString &uri, QgsFeedback *feedback = 0 );
%Docstring
Retrieves index content for the specified ``uri``.

The content is cached within the index, so multiple calls are potentially cost-free.

The optional ``feedback`` argument can be used the cancel the request early.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/tiledmesh/qgstiledmeshindex.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
77 changes: 77 additions & 0 deletions python/core/auto_generated/tiledmesh/qgstiledmeshrequest.sip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/tiledmesh/qgstiledmeshrequest.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsTiledMeshRequest
{
%Docstring(signature="appended")

Tiled mesh data request.

.. versionadded:: 3.34
%End

%TypeHeaderCode
#include "qgstiledmeshrequest.h"
%End
public:

QgsTiledMeshRequest();

double requiredGeometricError() const;
%Docstring
Returns the required geometric error treshold for the returned nodes, in
mesh CRS units.

If the error is 0 then no geometric error filtering will be applied.

.. seealso:: :py:func:`setRequiredGeometricError`
%End

void setRequiredGeometricError( double error );
%Docstring
Sets the required geometric ``error`` treshold for the returned nodes, in
mesh CRS units.

If the ``error`` is 0 then no geometric error filtering will be applied.

.. seealso:: :py:func:`requiredGeometricError`
%End

void setFeedback( QgsFeedback *feedback );
%Docstring
Attach a ``feedback`` object that can be queried regularly by the request to check
if it should be canceled.

Ownership of ``feedback`` is NOT transferred, and the caller must take care that it exists
for the lifetime of the request.

.. seealso:: :py:func:`feedback`
%End

QgsFeedback *feedback() const;
%Docstring
Returns the feedback object that can be queried regularly by the request to check
if it should be canceled, if set.

.. seealso:: :py:func:`setFeedback`
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/tiledmesh/qgstiledmeshrequest.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2 changes: 2 additions & 0 deletions python/core/core_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,10 @@
%Include auto_generated/tiledmesh/qgscesiumutils.sip
%Include auto_generated/tiledmesh/qgstiledmeshboundingvolume.sip
%Include auto_generated/tiledmesh/qgstiledmeshdataprovider.sip
%Include auto_generated/tiledmesh/qgstiledmeshindex.sip
%Include auto_generated/tiledmesh/qgstiledmeshlayer.sip
%Include auto_generated/tiledmesh/qgstiledmeshnode.sip
%Include auto_generated/tiledmesh/qgstiledmeshrequest.sip
%Include auto_generated/sensor/qgssensormodel.sip
%Include auto_generated/sensor/qgssensormanager.sip
%Include auto_generated/sensor/qgssensorregistry.sip
Expand Down
4 changes: 4 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,12 @@ set(QGIS_CORE_SRCS
tiledmesh/qgstiledmeshconnection.cpp
tiledmesh/qgstiledmeshdataitems.cpp
tiledmesh/qgstiledmeshdataprovider.cpp
tiledmesh/qgstiledmeshindex.cpp
tiledmesh/qgstiledmeshlayer.cpp
tiledmesh/qgstiledmeshlayerrenderer.cpp
tiledmesh/qgstiledmeshnode.cpp
tiledmesh/qgstiledmeshprovidermetadata.cpp
tiledmesh/qgstiledmeshrequest.cpp

sensor/qgssensormodel.cpp
sensor/qgssensormanager.cpp
Expand Down Expand Up @@ -1910,10 +1912,12 @@ set(QGIS_CORE_HDRS
tiledmesh/qgstiledmeshconnection.h
tiledmesh/qgstiledmeshdataprovider.h
tiledmesh/qgstiledmeshdataitems.h
tiledmesh/qgstiledmeshindex.h
tiledmesh/qgstiledmeshlayer.h
tiledmesh/qgstiledmeshlayerrenderer.h
tiledmesh/qgstiledmeshnode.h
tiledmesh/qgstiledmeshprovidermetadata.h
tiledmesh/qgstiledmeshrequest.h

sensor/qgssensormodel.h
sensor/qgssensormanager.h
Expand Down
Loading

0 comments on commit 52d8311

Please sign in to comment.