QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsmeshmemorydataprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshmemorydataprovider.h
3  ---------------------------
4  begin : April 2018
5  copyright : (C) 2018 by Peter Petrik
6  email : zilolv 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 #ifndef QGSMESHMEMORYDATAPROVIDER_H
19 #define QGSMESHMEMORYDATAPROVIDER_H
20 
21 #define SIP_NO_FILE
22 
24 
25 #include <QString>
26 
27 #include "qgis_core.h"
28 #include "qgis.h"
29 #include "qgsmeshdataprovider.h"
30 #include "qgsrectangle.h"
31 
32 struct QgsMeshMemoryDataset
33 {
34  QMap<QString, QString> metadata;
35  QVector<QgsMeshDatasetValue> values;
36  bool isScalar = true;
37  bool isOnVertices = true;
38  bool valid = false;
39 };
40 
46 class QgsMeshMemoryDataProvider: public QgsMeshDataProvider
47 {
48  Q_OBJECT
49 
50  public:
51 
74  QgsMeshMemoryDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
75 
76  bool isValid() const override;
77  QString name() const override;
78  QString description() const override;
79  QgsCoordinateReferenceSystem crs() const override;
80 
81  int vertexCount() const override;
82  int faceCount() const override;
83  QgsMeshVertex vertex( int index ) const override;
84  QgsMeshFace face( int index ) const override;
85 
86 
110  bool addDataset( const QString &uri ) override;
111  int datasetCount() const override;
112 
113  QgsMeshDatasetMetadata datasetMetadata( int datasetIndex ) const override;
114  QgsMeshDatasetValue datasetValue( int datasetIndex, int valueIndex ) const override;
115 
117  static QString providerKey();
119  static QString providerDescription();
121  static QgsMeshMemoryDataProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
122  private:
123  bool splitMeshSections( const QString &uri );
124  bool addMeshVertices( const QString &def );
125  bool addMeshFaces( const QString &def );
126 
127  bool splitDatasetSections( const QString &uri, QgsMeshMemoryDataset &dataset );
128  bool setDatasetType( const QString &uri, QgsMeshMemoryDataset &dataset );
129  bool addDatasetMetadata( const QString &def, QgsMeshMemoryDataset &dataset );
130  bool addDatasetValues( const QString &def, QgsMeshMemoryDataset &dataset );
131  bool checkDatasetValidity( QgsMeshMemoryDataset &dataset );
132 
133  QVector<QgsMeshVertex> mVertices;
134  QVector<QgsMeshFace> mFaces;
135  QVector<QgsMeshMemoryDataset> mDatasets;
136 
137  bool mIsValid = false;
138 };
139 
141 
142 #endif // QGSMESHMEMORYDATAPROVIDER_H
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
Base class for providing data for QgsMeshLayer.
Setting options for creating vector data providers.
QVector< int > QgsMeshFace
List of vertex indexes.
This class represents a coordinate reference system (CRS).
QgsMeshDatasetValue represents single mesh dataset value.
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is vector or...