Skip to content

Commit 21613cd

Browse files
PeterPetrikwonder-sk
authored andcommitted
use MDAL Groups instead of guessing them from dataset names
1 parent 245d6e2 commit 21613cd

32 files changed

+757
-389
lines changed

python/core/auto_generated/mesh/qgsmeshdataprovider.sip.in

Lines changed: 125 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,43 @@
1010

1111

1212

13+
class QgsMeshDatasetIndex
14+
{
15+
%Docstring
16+
17+
QgsMeshDatasetIndex is index that identifies the dataset group (e.g. wind speed)
18+
and a dataset in this group (e.g. magnitude of wind speed in particular time)
19+
20+
.. note::
21+
22+
The API is considered EXPERIMENTAL and can be changed without a notice
23+
24+
.. versionadded:: 3.4
25+
%End
26+
27+
%TypeHeaderCode
28+
#include "qgsmeshdataprovider.h"
29+
%End
30+
public:
31+
QgsMeshDatasetIndex( int group = -1, int dataset = -1 );
32+
%Docstring
33+
Creates an index. -1 represents invalid group/dataset
34+
%End
35+
int group() const;
36+
%Docstring
37+
Returns a group index
38+
%End
39+
int dataset() const;
40+
%Docstring
41+
Returns a dataset index within group()
42+
%End
43+
bool isValid() const;
44+
%Docstring
45+
Returns whether index is valid, ie at least groups is set
46+
%End
47+
bool operator == ( const QgsMeshDatasetIndex &other ) const;
48+
};
49+
1350
typedef QgsPoint QgsMeshVertex;
1451

1552
typedef QVector<int> QgsMeshFace;
@@ -18,7 +55,7 @@ class QgsMeshDatasetValue
1855
{
1956
%Docstring
2057

21-
QgsMeshDatasetValue represents single mesh dataset value
58+
QgsMeshDatasetValue represents single dataset value
2259

2360
could be scalar or vector. Nodata values are represented by NaNs.
2461

@@ -85,63 +122,104 @@ Returns y value
85122

86123
};
87124

88-
89-
90-
class QgsMeshDatasetMetadata
125+
class QgsMeshDatasetGroupMetadata
91126
{
92127
%Docstring
93128

94-
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such
95-
as whether the data is vector or scalar, etc.
129+
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata
130+
such as whether the data is vector or scalar, name
96131

97132
.. note::
98133

99134
The API is considered EXPERIMENTAL and can be changed without a notice
100135

101-
.. versionadded:: 3.2
136+
.. versionadded:: 3.4
102137
%End
103138

104139
%TypeHeaderCode
105140
#include "qgsmeshdataprovider.h"
106141
%End
107142
public:
108-
QgsMeshDatasetMetadata();
143+
QgsMeshDatasetGroupMetadata();
109144
%Docstring
110145
Constructs an empty metadata object
111146
%End
112147

113-
QgsMeshDatasetMetadata( bool isScalar,
114-
bool isValid,
115-
bool isOnVertices,
116-
const QMap<QString, QString> &extraOptions );
148+
QgsMeshDatasetGroupMetadata( const QString &name,
149+
bool isScalar,
150+
bool isOnVertices,
151+
const QMap<QString, QString> &extraOptions );
117152
%Docstring
118153
Constructs a valid metadata object
119154

155+
:param name: name of the dataset group
120156
:param isScalar: dataset contains scalar data, specifically the y-value of QgsMeshDatasetValue is NaN
121-
:param isValid: dataset is loadad and valid for fetching the data
122157
:param isOnVertices: dataset values are defined on mesh's vertices. If false, values are defined on faces.
123158
:param extraOptions: dataset's extra options stored by the provider. Usually contains the name, time value, time units, data file vendor, ...
159+
%End
160+
161+
QString name() const;
162+
%Docstring
163+
Returns name of the dataset group
124164
%End
125165

126166
QMap<QString, QString> extraOptions() const;
127167
%Docstring
128-
Returns extra metadata options
129-
Usually including name, description or time variable
168+
Returns extra metadata options, for example description
130169
%End
131170

132171
bool isVector() const;
133172
%Docstring
134-
Returns whether dataset has vector data
173+
Returns whether dataset group has vector data
135174
%End
136175

137176
bool isScalar() const;
138177
%Docstring
139-
Returns whether dataset has scalar data
178+
Returns whether dataset group has scalar data
140179
%End
141180

142181
bool isOnVertices() const;
143182
%Docstring
144-
Returns whether dataset data is defined on vertices
183+
Returns whether dataset group data is defined on vertices
184+
%End
185+
186+
};
187+
188+
class QgsMeshDatasetMetadata
189+
{
190+
%Docstring
191+
192+
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such
193+
as whether the data is valid or associated time for the dataset
194+
195+
.. note::
196+
197+
The API is considered EXPERIMENTAL and can be changed without a notice
198+
199+
.. versionadded:: 3.2
200+
%End
201+
202+
%TypeHeaderCode
203+
#include "qgsmeshdataprovider.h"
204+
%End
205+
public:
206+
QgsMeshDatasetMetadata();
207+
%Docstring
208+
Constructs an empty metadata object
209+
%End
210+
211+
QgsMeshDatasetMetadata( double time,
212+
bool isValid );
213+
%Docstring
214+
Constructs a valid metadata object
215+
216+
:param time: a time which this dataset represents in the dataset group
217+
:param isValid: dataset is loadad and valid for fetching the data
218+
%End
219+
220+
double time() const;
221+
%Docstring
222+
Returns the time value for this dataset
145223
%End
146224

147225
bool isValid() const;
@@ -157,7 +235,7 @@ class QgsMeshDataSourceInterface /Abstract/
157235

158236
Interface for mesh data sources
159237

160-
Mesh is a collection of vertices and faces in 2D or 3D space
238+
Mesh is a collection of vertices and faces in 2D or 3D space
161239
- vertex - XY(Z) point (in the mesh's coordinate reference system)
162240
- faces - sets of vertices forming a closed shape - typically triangles or quadrilaterals
163241

@@ -205,12 +283,15 @@ Returns the mesh face at index
205283
class QgsMeshDatasetSourceInterface /Abstract/
206284
{
207285
%Docstring
208-
Interface for mesh datasets
286+
Interface for mesh datasets and dataset groups
209287

210288
Dataset is a collection of vector or scalar values on vertices or faces of the mesh.
211289
Based on the underlying data provider/format, whole dataset is either stored in memory
212290
or read on demand
213291

292+
Datasets are grouped in the dataset groups. A dataset group represents a measured quantity
293+
(e.g. depth or wind speed), dataset represents values of the quantity in a particular time.
294+
214295
.. note::
215296

216297
The API is considered EXPERIMENTAL and can be changed without a notice
@@ -231,17 +312,37 @@ Associate dataset with the mesh
231312
emits dataChanged when successful
232313
%End
233314

234-
virtual int datasetCount() const = 0;
315+
virtual int datasetGroupCount( ) const = 0;
316+
%Docstring
317+
Returns number of datasets groups loaded
318+
%End
319+
320+
virtual int datasetCount( int groupIndex ) const = 0;
321+
%Docstring
322+
Returns number of datasets loaded in the group
323+
%End
324+
325+
int datasetCount( QgsMeshDatasetIndex index ) const;
326+
%Docstring
327+
Returns number of datasets loaded in the group
328+
%End
329+
330+
virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
331+
%Docstring
332+
Returns dataset group metadata
333+
%End
334+
335+
QgsMeshDatasetGroupMetadata datasetGroupMetadata( QgsMeshDatasetIndex index ) const;
235336
%Docstring
236-
Returns number of datasets loaded
337+
Returns dataset group metadata
237338
%End
238339

239-
virtual QgsMeshDatasetMetadata datasetMetadata( int datasetIndex ) const = 0;
340+
virtual QgsMeshDatasetMetadata datasetMetadata( QgsMeshDatasetIndex index ) const = 0;
240341
%Docstring
241342
Returns dataset metadata
242343
%End
243344

244-
virtual QgsMeshDatasetValue datasetValue( int datasetIndex, int valueIndex ) const = 0;
345+
virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
245346
%Docstring
246347
Returns vector/scalar value associated with the index from the dataset
247348

python/core/auto_generated/mesh/qgsmeshlayer.sip.in

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111

1212

13-
const int NO_ACTIVE_MESH_DATASET;
14-
1513

1614
class QgsMeshLayer : QgsMapLayer
1715
{
@@ -171,24 +169,24 @@ Returns renderer settings
171169
Sets new renderer settings, triggers repaint
172170
%End
173171

174-
void setActiveScalarDataset( int index = NO_ACTIVE_MESH_DATASET );
172+
void setActiveScalarDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() );
175173
%Docstring
176174
Sets active scalar dataset for rendering
177175

178176
Triggers repaint
179177
%End
180-
int activeScalarDataset() const;
178+
QgsMeshDatasetIndex activeScalarDataset() const;
181179
%Docstring
182180
Returns active scalar dataset
183181
%End
184182

185-
void setActiveVectorDataset( int index = NO_ACTIVE_MESH_DATASET );
183+
void setActiveVectorDataset( QgsMeshDatasetIndex index = QgsMeshDatasetIndex() );
186184
%Docstring
187185
Sets active vector dataset for rendering.
188186

189187
If dataset is not vector based, do nothing. Triggers repaint
190188
%End
191-
int activeVectorDataset() const;
189+
QgsMeshDatasetIndex activeVectorDataset() const;
192190
%Docstring
193191
Returns active vector dataset
194192
%End

0 commit comments

Comments
 (0)