35static QgsFields createFields(
const QList<QgsMeshDatasetGroupMetadata> &groupMetadataList,
int vectorOption )
40 if ( meta.isVector() )
42 if ( vectorOption == 0 || vectorOption == 2 )
44 fields.
append(
QgsField( QStringLiteral(
"%1_x" ).arg( meta.name() ), QMetaType::Type::Double ) );
45 fields.
append(
QgsField( QStringLiteral(
"%1_y" ).arg( meta.name() ), QMetaType::Type::Double ) );
48 if ( vectorOption == 1 || vectorOption == 2 )
50 fields.
append(
QgsField( QStringLiteral(
"%1_mag" ).arg( meta.name() ), QMetaType::Type::Double ) );
51 fields.
append(
QgsField( QStringLiteral(
"%1_dir" ).arg( meta.name() ), QMetaType::Type::Double ) );
62 QVector<double> ret( exportOption == 2 ? 4 : 2 );
64 if ( exportOption == 0 || exportOption == 2 )
69 if ( exportOption == 1 || exportOption == 2 )
73 double magnitude = sqrt( x * x + y * y );
74 double direction = ( asin( x / magnitude ) ) / M_PI * 180;
76 direction = 180 - direction;
78 if ( exportOption == 1 )
83 if ( exportOption == 2 )
96 QVector<double> vectorValues = vectorValue( value, vectorOption );
97 for (
double v : vectorValues )
99 if ( v == std::numeric_limits<double>::quiet_NaN() )
100 attributes.append( QVariant() );
102 attributes.append( v );
107 if ( value.
scalar() == std::numeric_limits<double>::quiet_NaN() )
108 attributes.append( QVariant() );
110 attributes.append( value.
scalar() );
117 int triangularFaceIndex,
124 bool faceActive = activeFaces.
active( nativeFaceIndex );
136 value = datasetValues.
value( nativeFaceIndex );
143 const int v1 = face[0], v2 = face[1], v3 = face[2];
148 const double x = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.
x(), val2.
x(), val3.
x(), point );
149 double y = std::numeric_limits<double>::quiet_NaN();
150 bool isVector = metadata.
isVector();
152 y = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.
y(), val2.
y(), val3.
y(), point );
163QString QgsExportMeshOnElement::group()
const
165 return QObject::tr(
"Mesh" );
168QString QgsExportMeshOnElement::groupId()
const
170 return QStringLiteral(
"mesh" );
173QString QgsExportMeshVerticesAlgorithm::shortHelpString()
const
175 return QObject::tr(
"This algorithm exports a mesh layer's vertices to a point vector layer, with the dataset values on vertices as attribute values." );
178QString QgsExportMeshVerticesAlgorithm::shortDescription()
const
180 return QObject::tr(
"Exports mesh vertices to a point vector layer" );
183QString QgsExportMeshVerticesAlgorithm::name()
const
185 return QStringLiteral(
"exportmeshvertices" );
188QString QgsExportMeshVerticesAlgorithm::displayName()
const
190 return QObject::tr(
"Export mesh vertices" );
195 return new QgsExportMeshVerticesAlgorithm();
198QgsGeometry QgsExportMeshVerticesAlgorithm::meshElement(
int index )
const
203void QgsExportMeshOnElement::initAlgorithm(
const QVariantMap &configuration )
205 Q_UNUSED( configuration );
211 QStringLiteral(
"DATASET_GROUPS" ),
212 QObject::tr(
"Dataset groups" ),
213 QStringLiteral(
"INPUT" ),
214 supportedDataType(),
true
218 QStringLiteral(
"DATASET_TIME" ),
219 QObject::tr(
"Dataset time" ),
220 QStringLiteral(
"INPUT" ),
221 QStringLiteral(
"DATASET_GROUPS" )
224 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS_OUTPUT" ), QObject::tr(
"Output coordinate system" ), QVariant(),
true ) );
226 QStringList exportVectorOptions;
227 exportVectorOptions << QObject::tr(
"Cartesian (x,y)" )
228 << QObject::tr(
"Polar (magnitude,degree)" )
229 << QObject::tr(
"Cartesian and Polar" );
230 addParameter(
new QgsProcessingParameterEnum( QStringLiteral(
"VECTOR_OPTION" ), QObject::tr(
"Export vector option" ), exportVectorOptions,
false, 0 ) );
240 if ( timeType == QLatin1String(
"dataset-time-step" ) )
245 else if ( timeType == QLatin1String(
"defined-date-time" ) )
248 if ( dateTime.isValid() )
249 relativeTime =
QgsInterval( layerReferenceTime.secsTo( dateTime ) );
251 else if ( timeType == QLatin1String(
"current-context-time" ) )
254 if ( dateTime.isValid() )
255 relativeTime =
QgsInterval( layerReferenceTime.secsTo( dateTime ) );
264 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
266 if ( !meshLayer || !meshLayer->
isValid() )
289 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
290 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
292 switch ( meshElementType() )
295 mElementCount = mNativeMesh.faceCount();
298 mElementCount = mNativeMesh.vertexCount();
301 mElementCount = mNativeMesh.edgeCount();
305 for (
int i = 0; i < datasetGroups.count(); ++i )
307 int groupIndex = datasetGroups.at( i );
312 if ( supportedDataType().contains( dataGroup.metadata.dataType() ) )
314 dataGroup.datasetValues = meshLayer->
datasetValues( datasetIndex, 0, mElementCount );
315 mDataPerGroup.append( dataGroup );
318 feedback->
setProgress( 100 * i / datasetGroups.count() );
321 mExportVectorOption = parameterAsInt( parameters, QStringLiteral(
"VECTOR_OPTION" ), context );
331 return QVariantMap();
333 feedback->
setProgressText( QObject::tr(
"Creating output vector layer" ) );
336 QList<QgsMeshDatasetGroupMetadata> metaList;
337 metaList.reserve( mDataPerGroup.size() );
338 for (
const DataGroup &dataGroup : std::as_const( mDataPerGroup ) )
339 metaList.append( dataGroup.metadata );
340 QgsFields fields = createFields( metaList, mExportVectorOption );
344 std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, identifier, fields, sinkGeometryType(),
outputCrs ) );
346 return QVariantMap();
351 return QVariantMap();
353 feedback->
setProgressText( QObject::tr(
"Creating points for each vertices" ) );
356 for (
int i = 0; i < mElementCount; ++i )
359 for (
const DataGroup &dataGroup : std::as_const( mDataPerGroup ) )
362 addAttributes( value, attributes, dataGroup.metadata.isVector(), mExportVectorOption );
373 geom = meshElement( i );
375 feedback->
reportError( QObject::tr(
"Could not transform point to destination CRS" ) );
386 return QVariantMap();
394 ret[QStringLiteral(
"OUTPUT" )] = identifier;
399QString QgsExportMeshFacesAlgorithm::shortHelpString()
const
401 return QObject::tr(
"This algorithm exports a mesh layer's faces to a polygon vector layer, with the dataset values on faces as attribute values." );
404QString QgsExportMeshFacesAlgorithm::shortDescription()
const
406 return QObject::tr(
"Exports mesh faces to a polygon vector layer" );
409QString QgsExportMeshFacesAlgorithm::name()
const
411 return QStringLiteral(
"exportmeshfaces" );
414QString QgsExportMeshFacesAlgorithm::displayName()
const
416 return QObject::tr(
"Export mesh faces" );
421 return new QgsExportMeshFacesAlgorithm();
424QgsGeometry QgsExportMeshFacesAlgorithm::meshElement(
int index )
const
426 const QgsMeshFace &face = mNativeMesh.face( index );
427 QVector<QgsPoint> vertices( face.size() );
428 for (
int i = 0; i < face.size(); ++i )
429 vertices[i] = mNativeMesh.vertex( face.at( i ) );
430 std::unique_ptr<QgsPolygon> polygon = std::make_unique<QgsPolygon>();
435QString QgsExportMeshEdgesAlgorithm::shortHelpString()
const
437 return QObject::tr(
"This algorithm exports a mesh layer's edges to a line vector layer, with the dataset values on edges as attribute values." );
440QString QgsExportMeshEdgesAlgorithm::shortDescription()
const
442 return QObject::tr(
"Exports mesh edges to a line vector layer" );
445QString QgsExportMeshEdgesAlgorithm::name()
const
447 return QStringLiteral(
"exportmeshedges" );
450QString QgsExportMeshEdgesAlgorithm::displayName()
const
452 return QObject::tr(
"Export mesh edges" );
457 return new QgsExportMeshEdgesAlgorithm();
460QgsGeometry QgsExportMeshEdgesAlgorithm::meshElement(
int index )
const
462 const QgsMeshEdge &edge = mNativeMesh.edge( index );
463 QVector<QgsPoint> vertices( 2 );
464 vertices[0] = mNativeMesh.vertex( edge.first );
465 vertices[1] = mNativeMesh.vertex( edge.second );
470QString QgsExportMeshOnGridAlgorithm::name()
const {
return QStringLiteral(
"exportmeshongrid" ); }
472QString QgsExportMeshOnGridAlgorithm::displayName()
const {
return QObject::tr(
"Export mesh on grid" ); }
474QString QgsExportMeshOnGridAlgorithm::group()
const {
return QObject::tr(
"Mesh" ); }
476QString QgsExportMeshOnGridAlgorithm::groupId()
const {
return QStringLiteral(
"mesh" ); }
478QString QgsExportMeshOnGridAlgorithm::shortHelpString()
const
480 return QObject::tr(
"This algorithm exports a mesh layer's dataset values to a gridded point vector layer, with the dataset values on each point as attribute values.\n"
481 "For data on volume (3D stacked dataset values), the exported dataset values are averaged on faces using the method defined in the mesh layer properties (default is Multi level averaging method).\n"
482 "1D meshes are not supported." );
485QString QgsExportMeshOnGridAlgorithm::shortDescription()
const
487 return QObject::tr(
"Exports mesh dataset values to a gridded point vector layer" );
492 return new QgsExportMeshOnGridAlgorithm();
495void QgsExportMeshOnGridAlgorithm::initAlgorithm(
const QVariantMap &configuration )
497 Q_UNUSED( configuration );
502 QStringLiteral(
"DATASET_GROUPS" ),
503 QObject::tr(
"Dataset groups" ),
504 QStringLiteral(
"INPUT" ),
509 QStringLiteral(
"DATASET_TIME" ),
510 QObject::tr(
"Dataset time" ),
511 QStringLiteral(
"INPUT" ),
512 QStringLiteral(
"DATASET_GROUPS" )
517 addParameter(
new QgsProcessingParameterDistance( QStringLiteral(
"GRID_SPACING" ), QObject::tr(
"Grid spacing" ), 10, QStringLiteral(
"INPUT" ),
false ) );
519 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS_OUTPUT" ), QObject::tr(
"Output coordinate system" ), QVariant(),
true ) );
521 QStringList exportVectorOptions;
522 exportVectorOptions << QObject::tr(
"Cartesian (x,y)" )
523 << QObject::tr(
"Polar (magnitude,degree)" )
524 << QObject::tr(
"Cartesian and Polar" );
525 addParameter(
new QgsProcessingParameterEnum( QStringLiteral(
"VECTOR_OPTION" ), QObject::tr(
"Export vector option" ), exportVectorOptions,
false, 0 ) );
529static void extractDatasetValues(
const QList<int> &datasetGroups,
QgsMeshLayer *meshLayer,
const QgsMesh &nativeMesh,
const QgsInterval &relativeTime,
const QSet<int> supportedDataType, QList<DataGroup> &datasetPerGroup,
QgsProcessingFeedback *feedback )
531 for (
int i = 0; i < datasetGroups.count(); ++i )
533 int groupIndex = datasetGroups.at( i );
538 if ( supportedDataType.contains( dataGroup.metadata.dataType() ) )
541 dataGroup.datasetValues = meshLayer->
datasetValues( datasetIndex, 0, valueCount );
545 dataGroup.dataset3dStakedValue = meshLayer->
dataset3dValues( datasetIndex, 0, valueCount );
547 datasetPerGroup.append( dataGroup );
550 feedback->
setProgress( 100 * i / datasetGroups.count() );
556 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
558 if ( !meshLayer || !meshLayer->
isValid() )
578 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
579 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
581 extractDatasetValues( datasetGroups, meshLayer, nativeMesh, relativeTime, supportedDataType(), mDataPerGroup, feedback );
582 mTriangularMesh.update( meshLayer->
nativeMesh(), mTransform );
584 mExportVectorOption = parameterAsInt( parameters, QStringLiteral(
"VECTOR_OPTION" ), context );
594 return QVariantMap();
596 feedback->
setProgressText( QObject::tr(
"Creating output vector layer" ) );
601 for ( DataGroup &dataGroup : mDataPerGroup )
603 if ( dataGroup.dataset3dStakedValue.isValid() )
604 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
607 QList<QgsMeshDatasetGroupMetadata> metaList;
608 metaList.reserve( mDataPerGroup.size() );
609 for (
const DataGroup &dataGroup : std::as_const( mDataPerGroup ) )
610 metaList.append( dataGroup.metadata );
611 QgsFields fields = createFields( metaList, mExportVectorOption );
616 std::unique_ptr<QgsFeatureSink> sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, identifier, fields,
Qgis::WkbType::Point,
outputCrs ) );
618 return QVariantMap();
623 return QVariantMap();
629 double gridSpacing = parameterAsDouble( parameters, QStringLiteral(
"GRID_SPACING" ), context );
630 QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral(
"EXTENT" ), context );
632 extent = mTriangularMesh.extent();
633 int pointXCount = int( extent.
width() / gridSpacing ) + 1;
634 int pointYCount = int( extent.
height() / gridSpacing ) + 1;
636 for (
int ix = 0; ix < pointXCount; ++ix )
638 for (
int iy = 0; iy < pointYCount; ++iy )
641 int triangularFaceIndex = mTriangularMesh.faceIndexForPoint_v2( point );
642 if ( triangularFaceIndex >= 0 )
646 int nativeFaceIndex = mTriangularMesh.trianglesToNativeFaces().at( triangularFaceIndex );
647 for (
int i = 0; i < mDataPerGroup.count(); ++i )
649 const DataGroup &dataGroup = mDataPerGroup.at( i );
650 bool faceActive = dataGroup.activeFaces.active( nativeFaceIndex );
658 dataGroup.activeFaces,
659 dataGroup.datasetValues,
663 if ( dataGroup.metadata.isVector() )
665 QVector<double> vector = vectorValue( dataGroup.datasetValues.value( i ), mExportVectorOption );
666 for (
double v : vector )
668 attributes.append( v );
672 attributes.append( value.
scalar() );
683 feedback->
reportError( QObject::tr(
"Could not transform point to destination CRS" ) );
688 sink->addFeature( feat );
696 ret[QStringLiteral(
"OUTPUT" )] = identifier;
701QSet<int> QgsExportMeshOnGridAlgorithm::supportedDataType()
710QString QgsMeshRasterizeAlgorithm::name()
const
712 return QStringLiteral(
"meshrasterize" );
715QString QgsMeshRasterizeAlgorithm::displayName()
const
717 return QObject::tr(
"Rasterize mesh dataset" );
720QString QgsMeshRasterizeAlgorithm::group()
const
722 return QObject::tr(
"Mesh" );
725QString QgsMeshRasterizeAlgorithm::groupId()
const
727 return QStringLiteral(
"mesh" );
730QString QgsMeshRasterizeAlgorithm::shortHelpString()
const
732 return QObject::tr(
"This algorithm creates a raster layer from a mesh dataset.\n"
733 "For data on volume (3D stacked dataset values), the exported dataset values are averaged on faces using the method defined in the mesh layer properties (default is Multi level averaging method).\n"
734 "1D meshes are not supported." );
737QString QgsMeshRasterizeAlgorithm::shortDescription()
const
739 return QObject::tr(
"Creates a raster layer from a mesh dataset" );
744 return new QgsMeshRasterizeAlgorithm();
747void QgsMeshRasterizeAlgorithm::initAlgorithm(
const QVariantMap &configuration )
749 Q_UNUSED( configuration );
754 QStringLiteral(
"DATASET_GROUPS" ),
755 QObject::tr(
"Dataset groups" ),
756 QStringLiteral(
"INPUT" ),
762 QStringLiteral(
"DATASET_TIME" ),
763 QObject::tr(
"Dataset time" ),
764 QStringLiteral(
"INPUT" ),
765 QStringLiteral(
"DATASET_GROUPS" )
769 addParameter(
new QgsProcessingParameterDistance( QStringLiteral(
"PIXEL_SIZE" ), QObject::tr(
"Pixel size" ), 1, QStringLiteral(
"INPUT" ),
false ) );
770 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS_OUTPUT" ), QObject::tr(
"Output coordinate system" ), QVariant(),
true ) );
772 std::unique_ptr<QgsProcessingParameterString> createOptsParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral(
"CREATE_OPTIONS" ), QObject::tr(
"Creation options" ), QVariant(),
false,
true );
773 createOptsParam->setMetadata( QVariantMap( { { QStringLiteral(
"widget_wrapper" ), QVariantMap( { { QStringLiteral(
"widget_type" ), QStringLiteral(
"rasteroptions" ) } } ) } } ) );
775 addParameter( createOptsParam.release() );
782 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
784 if ( !meshLayer || !meshLayer->
isValid() )
794 mTriangularMesh.update( meshLayer->
nativeMesh(), mTransform );
804 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
805 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
807 extractDatasetValues( datasetGroups, meshLayer, *meshLayer->
nativeMesh(), relativeTime, supportedDataType(), mDataPerGroup, feedback );
819 return QVariantMap();
826 for ( DataGroup &dataGroup : mDataPerGroup )
828 if ( dataGroup.dataset3dStakedValue.isValid() )
829 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
833 double pixelSize = parameterAsDouble( parameters, QStringLiteral(
"PIXEL_SIZE" ), context );
834 QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral(
"EXTENT" ), context );
836 extent = mTriangularMesh.extent();
838 int width = extent.
width() / pixelSize;
839 int height = extent.
height() / pixelSize;
841 const QString createOptions = parameterAsString( parameters, QStringLiteral(
"CREATE_OPTIONS" ), context ).trimmed();
842 const QString fileName = parameterAsOutputLayer( parameters, QStringLiteral(
"OUTPUT" ), context );
843 const QFileInfo fileInfo( fileName );
846 rasterFileWriter.setOutputProviderKey( QStringLiteral(
"gdal" ) );
847 if ( !createOptions.isEmpty() )
849 rasterFileWriter.setCreateOptions( createOptions.split(
'|' ) );
851 rasterFileWriter.setOutputFormat( outputFormat );
853 std::unique_ptr<QgsRasterDataProvider> rasterDataProvider(
854 rasterFileWriter.createMultiBandRaster(
Qgis::DataType::Float64, width, height, extent, mTransform.destinationCrs(), mDataPerGroup.count() )
856 rasterDataProvider->setEditable(
true );
858 for (
int i = 0; i < mDataPerGroup.count(); ++i )
860 const DataGroup &dataGroup = mDataPerGroup.at( i );
865 if ( dataGroup.datasetValues.isValid() )
869 dataGroup.datasetValues,
870 dataGroup.activeFaces,
871 dataGroup.metadata.dataType(),
878 rasterDataProvider->writeBlock( block.get(), i + 1 );
879 rasterDataProvider->setNoDataValue( i + 1, block->noDataValue() );
882 rasterDataProvider->setNoDataValue( i + 1, std::numeric_limits<double>::quiet_NaN() );
887 return QVariantMap();
888 feedback->
setProgress( 100 * i / mDataPerGroup.count() );
892 rasterDataProvider->setEditable(
false );
898 ret[QStringLiteral(
"OUTPUT" )] = fileName;
903QSet<int> QgsMeshRasterizeAlgorithm::supportedDataType()
912QString QgsMeshContoursAlgorithm::name()
const
914 return QStringLiteral(
"meshcontours" );
917QString QgsMeshContoursAlgorithm::displayName()
const
919 return QObject::tr(
"Export contours" );
922QString QgsMeshContoursAlgorithm::group()
const
924 return QObject::tr(
"Mesh" );
927QString QgsMeshContoursAlgorithm::groupId()
const
929 return QStringLiteral(
"mesh" );
932QString QgsMeshContoursAlgorithm::shortHelpString()
const
934 return QObject::tr(
"This algorithm creates contours as a vector layer from a mesh scalar dataset." );
937QString QgsMeshContoursAlgorithm::shortDescription()
const
939 return QObject::tr(
"Creates contours as vector layer from mesh scalar dataset" );
944 return new QgsMeshContoursAlgorithm();
947void QgsMeshContoursAlgorithm::initAlgorithm(
const QVariantMap &configuration )
949 Q_UNUSED( configuration );
954 QStringLiteral(
"DATASET_GROUPS" ),
955 QObject::tr(
"Dataset groups" ),
956 QStringLiteral(
"INPUT" ),
961 QStringLiteral(
"DATASET_TIME" ),
962 QObject::tr(
"Dataset time" ),
963 QStringLiteral(
"INPUT" ),
964 QStringLiteral(
"DATASET_GROUPS" )
978 std::unique_ptr<QgsProcessingParameterString> contourLevelList = std::make_unique<QgsProcessingParameterString>(
979 QStringLiteral(
"CONTOUR_LEVEL_LIST" ), QObject::tr(
"List of contours level" ), QVariant(),
false,
true
981 contourLevelList->setHelp( QObject::tr(
"Comma separated list of values to export. If filled, the increment, minimum and maximum settings are ignored." ) );
982 addParameter( contourLevelList.release() );
984 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS_OUTPUT" ), QObject::tr(
"Output coordinate system" ), QVariant(),
true ) );
993 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
995 if ( !meshLayer || !meshLayer->
isValid() )
1005 mTriangularMesh.update( meshLayer->
nativeMesh(), mTransform );
1011 QString levelsString = parameterAsString( parameters, QStringLiteral(
"CONTOUR_LEVEL_LIST" ), context );
1012 if ( !levelsString.isEmpty() )
1014 QStringList levelStringList = levelsString.split(
',' );
1015 if ( !levelStringList.isEmpty() )
1017 for (
const QString &stringVal : levelStringList )
1020 double val = stringVal.toDouble( &ok );
1022 mLevels.append( val );
1024 throw QgsProcessingException( QObject::tr(
"Invalid format for level values, must be numbers separated with comma" ) );
1026 if ( mLevels.count() >= 2 )
1027 if ( mLevels.last() <= mLevels.at( mLevels.count() - 2 ) )
1028 throw QgsProcessingException( QObject::tr(
"Invalid format for level values, must be different numbers and in increasing order" ) );
1033 if ( mLevels.isEmpty() )
1035 double minimum = parameterAsDouble( parameters, QStringLiteral(
"MINIMUM" ), context );
1036 double maximum = parameterAsDouble( parameters, QStringLiteral(
"MAXIMUM" ), context );
1037 double interval = parameterAsDouble( parameters, QStringLiteral(
"INCREMENT" ), context );
1039 if ( interval <= 0 )
1042 if ( minimum >= maximum )
1043 throw QgsProcessingException( QObject::tr(
"Invalid minimum and maximum values, minimum must be lesser than maximum" ) );
1045 if ( interval > ( maximum - minimum ) )
1046 throw QgsProcessingException( QObject::tr(
"Invalid minimum, maximum and interval values, difference between minimum and maximum must be greater or equal than interval" ) );
1048 int intervalCount = ( maximum - minimum ) / interval;
1050 mLevels.reserve( intervalCount );
1051 for (
int i = 0; i < intervalCount; ++i )
1053 mLevels.append( minimum + i * interval );
1066 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
1067 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
1071 extractDatasetValues( datasetGroups, meshLayer, mNativeMesh, relativeTime, supportedDataType(), mDataPerGroup, feedback );
1082 for ( DataGroup &dataGroup : mDataPerGroup )
1084 if ( dataGroup.dataset3dStakedValue.isValid() )
1085 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
1091 polygonFields.
append(
QgsField( QObject::tr(
"group" ), QMetaType::Type::QString ) );
1092 polygonFields.
append(
QgsField( QObject::tr(
"time" ), QMetaType::Type::QString ) );
1093 polygonFields.
append(
QgsField( QObject::tr(
"min_value" ), QMetaType::Type::Double ) );
1094 polygonFields.
append(
QgsField( QObject::tr(
"max_value" ), QMetaType::Type::Double ) );
1095 lineFields.
append(
QgsField( QObject::tr(
"group" ), QMetaType::Type::QString ) );
1096 lineFields.
append(
QgsField( QObject::tr(
"time" ), QMetaType::Type::QString ) );
1097 lineFields.
append(
QgsField( QObject::tr(
"value" ), QMetaType::Type::Double ) );
1101 QString lineIdentifier;
1102 QString polygonIdentifier;
1103 std::unique_ptr<QgsFeatureSink> sinkPolygons( parameterAsSink(
1105 QStringLiteral(
"OUTPUT_POLYGONS" ),
1112 std::unique_ptr<QgsFeatureSink> sinkLines( parameterAsSink(
1114 QStringLiteral(
"OUTPUT_LINES" ),
1122 if ( !sinkLines || !sinkPolygons )
1123 return QVariantMap();
1126 for (
int i = 0; i < mDataPerGroup.count(); ++i )
1128 DataGroup dataGroup = mDataPerGroup.at( i );
1130 int count = scalarDataOnVertices ? mNativeMesh.vertices.count() : mNativeMesh.faces.count();
1132 QVector<double> values;
1133 if ( dataGroup.datasetValues.isValid() )
1136 values = QgsMeshLayerUtils::calculateMagnitudes( dataGroup.datasetValues );
1140 values = QVector<double>( count, std::numeric_limits<double>::quiet_NaN() );
1143 if ( ( !scalarDataOnVertices ) )
1145 values = QgsMeshLayerUtils::interpolateFromFacesData(
1148 &dataGroup.activeFaces,
1153 QgsMeshContours contoursExported( mTriangularMesh, mNativeMesh, values, dataGroup.activeFaces );
1156 firstAttributes.append( dataGroup.metadata.name() );
1157 firstAttributes.append( mDateTimeString );
1159 for (
double level : std::as_const( mLevels ) )
1161 QgsGeometry line = contoursExported.exportLines( level, feedback );
1163 return QVariantMap();
1167 lineAttributes.append( level );
1174 throw QgsProcessingException( writeFeatureError( sinkLines.get(), parameters, QStringLiteral(
"OUTPUT_LINES" ) ) );
1177 for (
int l = 0; l < mLevels.count() - 1; ++l )
1179 QgsGeometry polygon = contoursExported.exportPolygons( mLevels.at( l ), mLevels.at( l + 1 ), feedback );
1181 return QVariantMap();
1186 polygonAttributes.append( mLevels.at( l ) );
1187 polygonAttributes.append( mLevels.at( l + 1 ) );
1192 sinkPolygons->addFeature( polygonFeature );
1197 feedback->
setProgress( 100 * i / mDataPerGroup.count() );
1202 sinkPolygons->finalize();
1204 sinkLines->finalize();
1207 ret[QStringLiteral(
"OUTPUT_LINES" )] = lineIdentifier;
1208 ret[QStringLiteral(
"OUTPUT_POLYGONS" )] = polygonIdentifier;
1213QString QgsMeshExportCrossSection::name()
const
1215 return QStringLiteral(
"meshexportcrosssection" );
1218QString QgsMeshExportCrossSection::displayName()
const
1220 return QObject::tr(
"Export cross section dataset values on lines from mesh" );
1223QString QgsMeshExportCrossSection::group()
const
1225 return QObject::tr(
"Mesh" );
1228QString QgsMeshExportCrossSection::groupId()
const
1230 return QStringLiteral(
"mesh" );
1233QString QgsMeshExportCrossSection::shortHelpString()
const
1235 return QObject::tr(
"This algorithm extracts mesh's dataset values from line contained in a vector layer.\n"
1236 "Each line is discretized with a resolution distance parameter for extraction of values on its vertices." );
1239QString QgsMeshExportCrossSection::shortDescription()
const
1241 return QObject::tr(
"Extracts a mesh dataset's values from lines contained in a vector layer" );
1246 return new QgsMeshExportCrossSection();
1249void QgsMeshExportCrossSection::initAlgorithm(
const QVariantMap &configuration )
1251 Q_UNUSED( configuration );
1256 QStringLiteral(
"DATASET_GROUPS" ),
1257 QObject::tr(
"Dataset groups" ),
1258 QStringLiteral(
"INPUT" ),
1263 QStringLiteral(
"DATASET_TIME" ),
1264 QObject::tr(
"Dataset time" ),
1265 QStringLiteral(
"INPUT" ),
1266 QStringLiteral(
"DATASET_GROUPS" )
1269 QList<int> datatype;
1272 QStringLiteral(
"INPUT_LINES" ), QObject::tr(
"Lines for data export" ), datatype, QVariant(),
false
1276 QStringLiteral(
"RESOLUTION" ), QObject::tr(
"Line segmentation resolution" ), 10.0, QStringLiteral(
"INPUT_LINES" ),
false, 0
1288 QStringLiteral(
"OUTPUT" ), QObject::tr(
"Exported data CSV file" ), QObject::tr(
"CSV file (*.csv)" )
1294 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
1296 if ( !meshLayer || !meshLayer->
isValid() )
1299 mMeshLayerCrs = meshLayer->
crs();
1300 mTriangularMesh.update( meshLayer->
nativeMesh() );
1309 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
1310 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
1312 extractDatasetValues( datasetGroups, meshLayer, *meshLayer->
nativeMesh(), relativeTime, supportedDataType(), mDataPerGroup, feedback );
1325 for ( DataGroup &dataGroup : mDataPerGroup )
1327 if ( dataGroup.dataset3dStakedValue.isValid() )
1328 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
1330 double resolution = parameterAsDouble( parameters, QStringLiteral(
"RESOLUTION" ), context );
1331 int datasetDigits = parameterAsInt( parameters, QStringLiteral(
"DATASET_DIGITS" ), context );
1332 int coordDigits = parameterAsInt( parameters, QStringLiteral(
"COORDINATES_DIGITS" ), context );
1334 std::unique_ptr<QgsProcessingFeatureSource> featureSource( parameterAsSource( parameters, QStringLiteral(
"INPUT_LINES" ), context ) );
1335 if ( !featureSource )
1340 QString outputFileName = parameterAsFileOutput( parameters, QStringLiteral(
"OUTPUT" ), context );
1341 QFile file( outputFileName );
1342 if ( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
1345 QTextStream textStream( &file );
1346#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
1347 textStream.setCodec(
"UTF-8" );
1350 header << QStringLiteral(
"fid" ) << QStringLiteral(
"x" ) << QStringLiteral(
"y" ) << QObject::tr(
"offset" );
1351 for (
const DataGroup &datagroup : std::as_const( mDataPerGroup ) )
1352 header << datagroup.metadata.name();
1353 textStream << header.join(
',' ) << QStringLiteral(
"\n" );
1355 long long featCount = featureSource->featureCount();
1356 long long featCounter = 0;
1370 feedback->
reportError( QObject::tr(
"Could not transform line to mesh CRS" ) );
1376 while ( offset <= line.
length() )
1379 return QVariantMap();
1381 QStringList textLine;
1383 int triangularFaceIndex = mTriangularMesh.faceIndexForPoint_v2( point );
1384 textLine << QString::number( fid ) << QString::number( point.
x(),
'f', coordDigits ) << QString::number( point.
y(),
'f', coordDigits ) << QString::number( offset,
'f', coordDigits );
1385 if ( triangularFaceIndex >= 0 )
1389 int nativeFaceIndex = mTriangularMesh.trianglesToNativeFaces().at( triangularFaceIndex );
1390 for (
int i = 0; i < mDataPerGroup.count(); ++i )
1392 const DataGroup &dataGroup = mDataPerGroup.at( i );
1393 bool faceActive = dataGroup.activeFaces.active( nativeFaceIndex );
1399 triangularFaceIndex,
1401 dataGroup.activeFaces,
1402 dataGroup.datasetValues,
1406 if ( abs( value.
x() ) == std::numeric_limits<double>::quiet_NaN() )
1407 textLine << QString(
' ' );
1409 textLine << QString::number( value.
scalar(),
'f', datasetDigits );
1413 for (
int i = 0; i < mDataPerGroup.count(); ++i )
1414 textLine << QString(
' ' );
1416 textStream << textLine.join(
',' ) << QStringLiteral(
"\n" );
1418 offset += resolution;
1423 feedback->
setProgress( 100.0 * featCounter / featCount );
1425 return QVariantMap();
1432 ret[QStringLiteral(
"OUTPUT" )] = outputFileName;
1436QString QgsMeshExportTimeSeries::name()
const
1438 return QStringLiteral(
"meshexporttimeseries" );
1441QString QgsMeshExportTimeSeries::displayName()
const
1443 return QObject::tr(
"Export time series values from points of a mesh dataset" );
1446QString QgsMeshExportTimeSeries::group()
const
1448 return QObject::tr(
"Mesh" );
1451QString QgsMeshExportTimeSeries::groupId()
const
1453 return QStringLiteral(
"mesh" );
1456QString QgsMeshExportTimeSeries::shortHelpString()
const
1458 return QObject::tr(
"This algorithm extracts mesh's dataset time series values from points contained in a vector layer.\n"
1459 "If the time step is kept to its default value (0 hours), the time step used is the one of the two first datasets of the first selected dataset group." );
1462QString QgsMeshExportTimeSeries::shortDescription()
const
1464 return QObject::tr(
"Extracts a mesh dataset's time series values from points contained in a vector layer" );
1469 return new QgsMeshExportTimeSeries();
1472void QgsMeshExportTimeSeries::initAlgorithm(
const QVariantMap &configuration )
1474 Q_UNUSED( configuration );
1479 QStringLiteral(
"DATASET_GROUPS" ),
1480 QObject::tr(
"Dataset groups" ),
1481 QStringLiteral(
"INPUT" ),
1486 QStringLiteral(
"STARTING_TIME" ),
1487 QObject::tr(
"Starting time" ),
1488 QStringLiteral(
"INPUT" ),
1489 QStringLiteral(
"DATASET_GROUPS" )
1493 QStringLiteral(
"FINISHING_TIME" ),
1494 QObject::tr(
"Finishing time" ),
1495 QStringLiteral(
"INPUT" ),
1496 QStringLiteral(
"DATASET_GROUPS" )
1503 QList<int> datatype;
1506 QStringLiteral(
"INPUT_POINTS" ), QObject::tr(
"Points for data export" ), datatype, QVariant(),
false
1518 QStringLiteral(
"OUTPUT" ), QObject::tr(
"Exported data CSV file" ), QObject::tr(
"CSV file (*.csv)" )
1524 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
1526 if ( !meshLayer || !meshLayer->
isValid() )
1529 mMeshLayerCrs = meshLayer->
crs();
1530 mTriangularMesh.update( meshLayer->
nativeMesh() );
1540 QVariant parameterStartTimeVariant = parameters.value( QStringLiteral(
"STARTING_TIME" ) );
1541 QgsInterval relativeStartTime = datasetRelativetime( parameterStartTimeVariant, meshLayer, context );
1543 QVariant parameterEndTimeVariant = parameters.value( QStringLiteral(
"FINISHING_TIME" ) );
1544 QgsInterval relativeEndTime = datasetRelativetime( parameterEndTimeVariant, meshLayer, context );
1547 qint64 timeStepInterval = parameterAsDouble( parameters, QStringLiteral(
"TIME_STEP" ), context ) * 1000 * 3600;
1548 if ( timeStepInterval == 0 )
1551 for (
int groupIndex : datasetGroups )
1565 mRelativeTimeSteps.clear();
1566 mTimeStepString.clear();
1567 if ( timeStepInterval != 0 )
1569 mRelativeTimeSteps.append( relativeStartTime.
seconds() * 1000 );
1570 while ( mRelativeTimeSteps.last() < relativeEndTime.
seconds() * 1000 )
1571 mRelativeTimeSteps.append( mRelativeTimeSteps.last() + timeStepInterval );
1573 for ( qint64 relativeTimeStep : std::as_const( mRelativeTimeSteps ) )
1575 mTimeStepString.append( meshLayer->
formatTime( relativeTimeStep / 3600.0 / 1000.0 ) );
1580 for (
int i = 0; i < datasetGroups.count(); ++i )
1582 int groupIndex = datasetGroups.at( i );
1584 if ( supportedDataType().contains( meta.
dataType() ) )
1586 mGroupIndexes.append( groupIndex );
1587 mGroupsMetadata[groupIndex] = meta;
1590 if ( !mRelativeTimeSteps.isEmpty() )
1594 for ( qint64 relativeTimeStep : std::as_const( mRelativeTimeSteps ) )
1596 QMap<int, int> &groupIndexToData = mRelativeTimeToData[relativeTimeStep];
1597 QgsInterval timeStepInterval( relativeTimeStep / 1000.0 );
1599 if ( !datasetIndex.
isValid() )
1601 if ( datasetIndex != lastDatasetIndex )
1603 DataGroup dataGroup;
1604 dataGroup.metadata = meta;
1605 dataGroup.datasetValues = meshLayer->
datasetValues( datasetIndex, 0, valueCount );
1609 dataGroup.dataset3dStakedValue = meshLayer->
dataset3dValues( datasetIndex, 0, valueCount );
1611 mDatasets.append( dataGroup );
1612 lastDatasetIndex = datasetIndex;
1614 groupIndexToData[groupIndex] = mDatasets.count() - 1;
1620 QMap<int, int> &groupIndexToData = mRelativeTimeToData[0];
1622 DataGroup dataGroup;
1623 dataGroup.metadata = meta;
1624 dataGroup.datasetValues = meshLayer->
datasetValues( datasetIndex, 0, valueCount );
1628 dataGroup.dataset3dStakedValue = meshLayer->
dataset3dValues( datasetIndex, 0, valueCount );
1630 mDatasets.append( dataGroup );
1631 groupIndexToData[groupIndex] = mDatasets.
count() - 1;
1636 feedback->
setProgress( 100 * i / datasetGroups.count() );
1652 for ( DataGroup &dataGroup : mDatasets )
1654 if ( dataGroup.dataset3dStakedValue.isValid() )
1655 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
1658 int datasetDigits = parameterAsInt( parameters, QStringLiteral(
"DATASET_DIGITS" ), context );
1659 int coordDigits = parameterAsInt( parameters, QStringLiteral(
"COORDINATES_DIGITS" ), context );
1661 std::unique_ptr<QgsProcessingFeatureSource> featureSource( parameterAsSource( parameters, QStringLiteral(
"INPUT_POINTS" ), context ) );
1662 if ( !featureSource )
1667 QString outputFileName = parameterAsFileOutput( parameters, QStringLiteral(
"OUTPUT" ), context );
1668 QFile file( outputFileName );
1669 if ( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
1672 QTextStream textStream( &file );
1673#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
1674 textStream.setCodec(
"UTF-8" );
1677 header << QStringLiteral(
"fid" ) << QStringLiteral(
"x" ) << QStringLiteral(
"y" ) << QObject::tr(
"time" );
1679 for (
int gi : std::as_const( mGroupIndexes ) )
1680 header << mGroupsMetadata.value( gi ).name();
1682 textStream << header.join(
',' ) << QStringLiteral(
"\n" );
1684 long long featCount = featureSource->featureCount();
1685 long long featCounter = 0;
1699 feedback->
reportError( QObject::tr(
"Could not transform line to mesh CRS" ) );
1706 int triangularFaceIndex = mTriangularMesh.faceIndexForPoint_v2( point );
1708 if ( triangularFaceIndex >= 0 )
1710 int nativeFaceIndex = mTriangularMesh.trianglesToNativeFaces().at( triangularFaceIndex );
1711 if ( !mRelativeTimeSteps.isEmpty() )
1713 for (
int timeIndex = 0; timeIndex < mRelativeTimeSteps.count(); ++timeIndex )
1715 qint64 timeStep = mRelativeTimeSteps.at( timeIndex );
1716 QStringList textLine;
1717 textLine << QString::number( fid )
1718 << QString::number( point.
x(),
'f', coordDigits )
1719 << QString::number( point.
y(),
'f', coordDigits )
1720 << mTimeStepString.at( timeIndex );
1722 if ( mRelativeTimeToData.contains( timeStep ) )
1724 const QMap<int, int> &groupToData = mRelativeTimeToData.value( timeStep );
1725 for (
int groupIndex : std::as_const( mGroupIndexes ) )
1727 if ( !groupToData.contains( groupIndex ) )
1729 int dataIndex = groupToData.value( groupIndex );
1730 if ( dataIndex < 0 || dataIndex > mDatasets.count() - 1 )
1733 const DataGroup &dataGroup = mDatasets.at( dataIndex );
1734 QgsMeshDatasetValue value = extractDatasetValue( point, nativeFaceIndex, triangularFaceIndex, mTriangularMesh, dataGroup.activeFaces, dataGroup.datasetValues, dataGroup.metadata );
1735 if ( abs( value.
x() ) == std::numeric_limits<double>::quiet_NaN() )
1736 textLine << QString(
' ' );
1738 textLine << QString::number( value.
scalar(),
'f', datasetDigits );
1741 textStream << textLine.join(
',' ) << QStringLiteral(
"\n" );
1746 QStringList textLine;
1747 textLine << QString::number( fid )
1748 << QString::number( point.
x(),
'f', coordDigits )
1749 << QString::number( point.
y(),
'f', coordDigits )
1750 << QObject::tr(
"static dataset" );
1751 const QMap<int, int> &groupToData = mRelativeTimeToData.value( 0 );
1752 for (
int groupIndex : std::as_const( mGroupIndexes ) )
1754 if ( !groupToData.contains( groupIndex ) )
1756 int dataIndex = groupToData.value( groupIndex );
1757 if ( dataIndex < 0 || dataIndex > mDatasets.count() - 1 )
1759 const DataGroup &dataGroup = mDatasets.at( dataIndex );
1760 QgsMeshDatasetValue value = extractDatasetValue( point, nativeFaceIndex, triangularFaceIndex, mTriangularMesh, dataGroup.activeFaces, dataGroup.datasetValues, dataGroup.metadata );
1761 if ( abs( value.
x() ) == std::numeric_limits<double>::quiet_NaN() )
1762 textLine << QString(
' ' );
1764 textLine << QString::number( value.
scalar(),
'f', datasetDigits );
1766 textStream << textLine.join(
',' ) << QStringLiteral(
"\n" );
1772 feedback->
setProgress( 100.0 * featCounter / featCount );
1774 return QVariantMap();
1781 ret[QStringLiteral(
"OUTPUT" )] = outputFileName;
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ Float64
Sixty four bit floating point (double)
@ LineStringZ
LineStringZ.
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
@ Double
Double/float values.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Custom exception class for Coordinate Reference System related exceptions.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool isCanceled() const
Tells whether the operation has been canceled already.
void canceled()
Internal routines can connect to this signal if they use event loop.
void cancel()
Tells the internal routines that the current operation should be canceled. This should be run by the ...
void setProgress(double progress)
Sets the current progress for the feedback object.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
A geometry is the spatial representation of a feature.
double length() const
Returns the planar, 2-dimensional length of geometry.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
QgsGeometry interpolate(double distance) const
Returns an interpolated point on the geometry at the specified distance.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
A representation of the interval between two datetime values.
double seconds() const
Returns the interval duration in seconds.
double hours() const
Returns the interval duration in hours.
Line string geometry type, with support for z-dimension and m-values.
QgsCoordinateReferenceSystem crs
Abstract class to interpolate 3d stacked mesh data to 2d data.
QgsMeshDataBlock calculate(const QgsMesh3DDataBlock &block3d, QgsFeedback *feedback=nullptr) const
Calculated 2d block values from 3d stacked mesh values.
int count() const
Number of 2d faces for which the volume data is stored in the block.
Exporter of contours lines or polygons from a mesh layer.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
bool active(int index) const
Returns a value for active flag by the index For scalar and vector 2d the behavior is undefined.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
bool isValid() const
Returns whether index is valid, ie at least groups is set.
QgsMeshDatasetValue represents single dataset value.
double y() const
Returns y value.
double scalar() const
Returns magnitude of vector for vector data or scalar value for scalar data.
double x() const
Returns x value.
Implementation of map layer temporal properties for mesh layers.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
int datasetCount(const QgsMeshDatasetIndex &index) const
Returns the dataset count in the dataset groups.
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
void updateTriangularMesh(const QgsCoordinateTransform &transform=QgsCoordinateTransform())
Gets native mesh and updates (creates if it doesn't exist) the base triangular mesh.
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering or calling to updateMesh)
QgsMeshDatasetIndex datasetIndexAtRelativeTime(const QgsInterval &relativeTime, int datasetGroupIndex) const
Returns dataset index from datasets group depending on the relative time from the layer reference tim...
QgsMeshDataBlock datasetValues(const QgsMeshDatasetIndex &index, int valueIndex, int count) const
Returns N vector/scalar values from the index from the dataset.
bool isEditable() const override
Returns true if the layer can be edited.
QgsMeshDataBlock areFacesActive(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns whether the faces are active for particular dataset.
QgsInterval datasetRelativeTime(const QgsMeshDatasetIndex &index)
Returns the relative time of the dataset from the reference time of its group.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
qint64 datasetRelativeTimeInMilliseconds(const QgsMeshDatasetIndex &index)
Returns the relative time (in milliseconds) of the dataset from the reference time of its group.
QgsMesh3DDataBlock dataset3dValues(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes.
QString formatTime(double hours)
Returns (date) time in hours formatted to human readable form.
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset groups metadata.
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
A class to represent a 2D point.
Point geometry type, with support for z-dimension and m-values.
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
QgsDateTimeRange currentTimeRange() const
Returns the current time range to use for temporal operations.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
virtual void setProgressText(const QString &text)
Sets a progress report text string.
A coordinate reference system parameter for processing algorithms.
A double numeric parameter for distance values.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
A rectangular map extent parameter for processing algorithms.
A feature sink output for processing algorithms.
An input feature source (such as vector layers) parameter for processing algorithms.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
A parameter for processing algorithms that need a list of mesh dataset groups.
static QList< int > valueAsDatasetGroup(const QVariant &value)
Returns the value as a list if dataset group indexes.
A parameter for processing algorithms that need a list of mesh dataset index from time parameter.
static QString valueAsTimeType(const QVariant &value)
Returns the dataset value time type as a string : current-context-time : the time is store in the pro...
static QgsMeshDatasetIndex timeValueAsDatasetIndex(const QVariant &value)
Returns the value as a QgsMeshDatasetIndex if the value has "dataset-time-step" type.
static QDateTime timeValueAsDefinedDateTime(const QVariant &value)
Returns the value as a QDateTime if the value has "defined-date-time" type.
A mesh layer parameter for processing algorithms.
A numeric parameter for processing algorithms.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
Feedback object tailored for raster block reading.
The raster file writer which allows you to save a raster to a new file.
static QString driverForExtension(const QString &extension)
Returns the GDAL driver name for a specified file extension.
A rectangle specified with double values.
T begin() const
Returns the beginning of the range.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
const QVector< QgsMeshFace > & triangles() const
Returns triangles.
const QVector< QgsMeshVertex > & vertices() const
Returns vertices in map coordinate system.
CORE_EXPORT QgsRasterBlock * exportRasterBlock(const QgsMeshLayer &layer, const QgsMeshDatasetIndex &datasetIndex, const QgsCoordinateReferenceSystem &destinationCrs, const QgsCoordinateTransformContext &transformContext, double mapUnitsPerPixel, const QgsRectangle &extent, QgsRasterBlockFeedback *feedback=nullptr)
Exports mesh layer's dataset values as raster block.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QVector< int > QgsMeshFace
List of vertex indexes.
QPair< int, int > QgsMeshEdge
Edge is a straight line seqment between 2 points.
const QgsCoordinateReferenceSystem & outputCrs
Mesh - vertices, edges and faces.
QVector< QgsMeshVertex > vertices
void clear()
Remove all vertices, edges and faces.
int faceCount() const
Returns number of faces.