Skip to content
Permalink
Browse files

mesh layer expose datasetIndexAtTime() (#37197)

mesh layer expose datasetIndexAtTime()
  • Loading branch information
vcloarec committed Jun 15, 2020
1 parent 4fd98e3 commit b5d61594eeb13bf916c4aef0759066aa72783408
@@ -280,6 +280,24 @@ Returns the value of 1D mesh dataset defined on edge that are in the search area
outside the mesh layer and in case triangular mesh was not previously used for rendering


.. versionadded:: 3.14
%End


QgsMeshDatasetIndex datasetIndexAtTime( const QgsDateTimeRange &timeRange, int datasetGroupIndex ) const;
%Docstring
Returns dataset index from datasets group depending on the time range.
If the temporal properties is not active, returns invalid dataset index

:param timeRange: the time range

:return: dataset index

.. note::

the returned dataset index depends on the matching method, see setTemporalMatchingMethod()


.. versionadded:: 3.14
%End

@@ -410,11 +410,15 @@ int QgsMeshDataset3dGeometry::extractDataset( QVector<double> &verticalMagnitude

//extract the scalar dataset used to render vertical magnitude of geometry
//define the vertical magnitude datasetIndex
int verticalDataSetIndexNumber = 0;
verticalDataSetIndexNumber = scalarDatasetIndex.dataset();
verticalDataSetIndexNumber = std::min( verticalDataSetIndexNumber, layer->dataProvider()->datasetCount( mVerticalGroupDatasetIndex ) - 1 );
QgsMeshDatasetIndex verticalMagDatasetIndex( mVerticalGroupDatasetIndex, verticalDataSetIndexNumber );

QgsMeshDatasetIndex verticalMagDatasetIndex;
verticalMagDatasetIndex = layer->datasetIndexAtTime( mTimeRange, mVerticalGroupDatasetIndex );
if ( !verticalMagDatasetIndex.isValid() )
{
//if invalid (for example, static mode) use the scalar dataset index
int vertDataSetIndex = scalarDatasetIndex.dataset();
vertDataSetIndex = std::min( vertDataSetIndex, layer->dataProvider()->datasetCount( mVerticalGroupDatasetIndex ) - 1 );
verticalMagDatasetIndex = QgsMeshDatasetIndex( vertDataSetIndex, mVerticalGroupDatasetIndex );
}
//define the active face for vertical magnitude, the inactive faces will not be rendered
// The active face flag values are defined based on the vertival magnitude dataset
activeFaceFlagValues = layer->dataProvider()->areFacesActive( verticalMagDatasetIndex, 0, nativeMesh.faces.count() );
@@ -428,6 +428,9 @@ void QgsMeshLayer::setTransformContext( const QgsCoordinateTransformContext &tra

QgsMeshDatasetIndex QgsMeshLayer::datasetIndexAtTime( const QgsDateTimeRange &timeRange, int datasetGroupIndex ) const
{
if ( ! mTemporalProperties->isActive() )
return QgsMeshDatasetIndex( datasetGroupIndex, -1 );

const QDateTime layerReferenceTime = mTemporalProperties->referenceTime();
qint64 startTime = layerReferenceTime.msecsTo( timeRange.begin() );

@@ -326,6 +326,20 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
*/
QgsMeshDatasetValue dataset1dValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius ) const;


/**
* Returns dataset index from datasets group depending on the time range.
* If the temporal properties is not active, returns invalid dataset index
*
* \param timeRange the time range
* \returns dataset index
*
* \note the returned dataset index depends on the matching method, see setTemporalMatchingMethod()
*
* \since QGIS 3.14
*/
QgsMeshDatasetIndex datasetIndexAtTime( const QgsDateTimeRange &timeRange, int datasetGroupIndex ) const;

/**
* Returns dataset index from active scalar group depending on the time range.
* If the temporal properties is not active, return the static dataset
@@ -522,8 +536,6 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer

bool hasSimplifiedMeshes() const;

QgsMeshDatasetIndex datasetIndexAtTime( const QgsDateTimeRange &timeRange, int datasetGroupIndex ) const;

//! Changes scalar settings for classified scalar value (information about is in the metadata
void applyClassificationOnScalarSettings( const QgsMeshDatasetGroupMetadata &meta, QgsMeshRendererScalarSettings &scalarSettings ) const;

0 comments on commit b5d6159

Please sign in to comment.
You can’t perform that action at this time.