30 #include <QTextStream>
35 static QgsFields createFields(
const QList<QgsMeshDatasetGroupMetadata> &groupMetadataList,
int vectorOption )
40 if ( meta.isVector() )
42 if ( vectorOption == 0 || vectorOption == 2 )
44 fields.
append( QStringLiteral(
"%1_x" ).arg( meta.name() ) );
45 fields.
append( QStringLiteral(
"%1_y" ).arg( meta.name() ) );
48 if ( vectorOption == 1 || vectorOption == 2 )
50 fields.
append( QStringLiteral(
"%1_mag" ).arg( meta.name() ) );
51 fields.
append( QStringLiteral(
"%1_dir" ).arg( meta.name() ) );
55 fields.
append( meta.name() );
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,
123 bool faceActive = activeFaces.
active( nativeFaceIndex );
135 value = datasetValues.
value( nativeFaceIndex );
142 const int v1 = face[0], v2 = face[1], v3 = face[2];
147 const double x = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.
x(), val2.
x(), val3.
x(), point );
148 double y = std::numeric_limits<double>::quiet_NaN();
149 bool isVector = metadata.
isVector();
151 y = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.
y(), val2.
y(), val3.
y(), point );
162 QString QgsExportMeshOnElement::group()
const
164 return QObject::tr(
"Mesh" );
167 QString QgsExportMeshOnElement::groupId()
const
169 return QStringLiteral(
"mesh" );
172 QString QgsExportMeshVerticesAlgorithm::shortHelpString()
const
174 return QObject::tr(
"Exports mesh layer's vertices to a point vector layer, with the dataset values on vertices as attribute values" );
177 QString QgsExportMeshVerticesAlgorithm::name()
const
179 return QStringLiteral(
"exportmeshvertices" );
182 QString QgsExportMeshVerticesAlgorithm::displayName()
const
184 return QObject::tr(
"Export mesh vertices" );
189 return new QgsExportMeshVerticesAlgorithm();
192 QgsGeometry QgsExportMeshVerticesAlgorithm::meshElement(
int index )
const
197 void QgsExportMeshOnElement::initAlgorithm(
const QVariantMap &configuration )
199 Q_UNUSED( configuration );
205 QStringLiteral(
"DATASET_GROUPS" ),
206 QObject::tr(
"Dataset groups" ),
207 QStringLiteral(
"INPUT" ),
208 supportedDataType(),
true ) );
211 QStringLiteral(
"DATASET_TIME" ),
212 QObject::tr(
"Dataset time" ),
213 QStringLiteral(
"INPUT" ),
214 QStringLiteral(
"DATASET_GROUPS" ) ) );
216 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS_OUTPUT" ), QObject::tr(
"Output coordinate system" ), QVariant(),
true ) );
218 QStringList exportVectorOptions;
219 exportVectorOptions << QObject::tr(
"Cartesian (x,y)" )
220 << QObject::tr(
"Polar (magnitude,degree)" )
221 << QObject::tr(
"Cartesian and Polar" );
222 addParameter(
new QgsProcessingParameterEnum( QStringLiteral(
"VECTOR_OPTION" ), QObject::tr(
"Export vector option" ), exportVectorOptions,
false, 0 ) );
232 if ( timeType == QLatin1String(
"dataset-time-step" ) )
237 else if ( timeType == QLatin1String(
"defined-date-time" ) )
240 if ( dateTime.isValid() )
241 relativeTime =
QgsInterval( layerReferenceTime.secsTo( dateTime ) );
243 else if ( timeType == QLatin1String(
"current-context-time" ) )
246 if ( dateTime.isValid() )
247 relativeTime =
QgsInterval( layerReferenceTime.secsTo( dateTime ) );
256 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
258 if ( !meshLayer || !meshLayer->
isValid() )
270 QList<int> datasetGroups =
279 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
280 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
282 switch ( meshElementType() )
285 mElementCount = mNativeMesh.faceCount();
288 mElementCount = mNativeMesh.vertexCount();
291 mElementCount = mNativeMesh.edgeCount();
295 for (
int i = 0; i < datasetGroups.count(); ++i )
297 int groupIndex = datasetGroups.at( i );
302 if ( supportedDataType().contains( dataGroup.metadata.dataType() ) )
304 dataGroup.datasetValues = meshLayer->
datasetValues( datasetIndex, 0, mElementCount );
305 mDataPerGroup.append( dataGroup );
308 feedback->
setProgress( 100 * i / datasetGroups.count() );
311 mExportVectorOption = parameterAsInt( parameters, QStringLiteral(
"VECTOR_OPTION" ), context );
321 return QVariantMap();
323 feedback->
setProgressText( QObject::tr(
"Creating output vector layer" ) );
326 QList<QgsMeshDatasetGroupMetadata> metaList;
327 metaList.reserve( mDataPerGroup.size() );
328 for (
const DataGroup &dataGroup : mDataPerGroup )
329 metaList.append( dataGroup.metadata );
330 QgsFields fields = createFields( metaList, mExportVectorOption );
335 QStringLiteral(
"OUTPUT" ),
342 return QVariantMap();
347 return QVariantMap();
349 feedback->
setProgressText( QObject::tr(
"Creating points for each vertices" ) );
352 for (
int i = 0; i < mElementCount; ++i )
355 for (
const DataGroup &dataGroup : std::as_const( mDataPerGroup ) )
358 addAttributes( value, attributes, dataGroup.metadata.isVector(), mExportVectorOption );
369 geom = meshElement( i );
370 feedback->
reportError( QObject::tr(
"Could not transform point to destination CRS" ) );
380 return QVariantMap();
386 ret[QStringLiteral(
"OUTPUT" )] = identifier;
391 QString QgsExportMeshFacesAlgorithm::shortHelpString()
const
393 return QObject::tr(
"Exports mesh layer's faces to a polygon vector layer, with the dataset values on faces as attribute values" );
396 QString QgsExportMeshFacesAlgorithm::name()
const
398 return QStringLiteral(
"exportmeshfaces" );
401 QString QgsExportMeshFacesAlgorithm::displayName()
const
403 return QObject::tr(
"Export mesh faces" );
408 return new QgsExportMeshFacesAlgorithm();
411 QgsGeometry QgsExportMeshFacesAlgorithm::meshElement(
int index )
const
413 const QgsMeshFace &face = mNativeMesh.face( index );
414 QVector<QgsPoint> vertices( face.size() );
415 for (
int i = 0; i < face.size(); ++i )
416 vertices[i] = mNativeMesh.vertex( face.at( i ) );
417 std::unique_ptr<QgsPolygon> polygon = std::make_unique<QgsPolygon>();
422 QString QgsExportMeshEdgesAlgorithm::shortHelpString()
const
424 return QObject::tr(
"Exports mesh layer's edges to a line vector layer, with the dataset values on edges as attribute values" );
427 QString QgsExportMeshEdgesAlgorithm::name()
const
429 return QStringLiteral(
"exportmeshedges" );
432 QString QgsExportMeshEdgesAlgorithm::displayName()
const
434 return QObject::tr(
"Export mesh edges" );
439 return new QgsExportMeshEdgesAlgorithm();
442 QgsGeometry QgsExportMeshEdgesAlgorithm::meshElement(
int index )
const
444 const QgsMeshEdge &edge = mNativeMesh.edge( index );
445 QVector<QgsPoint> vertices( 2 );
446 vertices[0] = mNativeMesh.vertex( edge.first );
447 vertices[1] = mNativeMesh.vertex( edge.second );
452 QString QgsExportMeshOnGridAlgorithm::name()
const {
return QStringLiteral(
"exportmeshongrid" );}
454 QString QgsExportMeshOnGridAlgorithm::displayName()
const {
return QObject::tr(
"Export mesh on grid" );}
456 QString QgsExportMeshOnGridAlgorithm::group()
const {
return QObject::tr(
"Mesh" );}
458 QString QgsExportMeshOnGridAlgorithm::groupId()
const {
return QStringLiteral(
"mesh" );}
460 QString QgsExportMeshOnGridAlgorithm::shortHelpString()
const
462 return QObject::tr(
"Exports mesh layer's dataset values to a gridded point vector layer, with the dataset values on this point as attribute values.\n"
463 "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"
464 "1D meshes are not supported." );
469 return new QgsExportMeshOnGridAlgorithm();
472 void QgsExportMeshOnGridAlgorithm::initAlgorithm(
const QVariantMap &configuration )
474 Q_UNUSED( configuration );
479 QStringLiteral(
"DATASET_GROUPS" ),
480 QObject::tr(
"Dataset groups" ),
481 QStringLiteral(
"INPUT" ),
482 supportedDataType() ) );
485 QStringLiteral(
"DATASET_TIME" ),
486 QObject::tr(
"Dataset time" ),
487 QStringLiteral(
"INPUT" ),
488 QStringLiteral(
"DATASET_GROUPS" ) ) );
492 addParameter(
new QgsProcessingParameterDistance( QStringLiteral(
"GRID_SPACING" ), QObject::tr(
"Grid spacing" ), 10, QStringLiteral(
"INPUT" ),
false ) );
494 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS_OUTPUT" ), QObject::tr(
"Output coordinate system" ), QVariant(),
true ) );
496 QStringList exportVectorOptions;
497 exportVectorOptions << QObject::tr(
"Cartesian (x,y)" )
498 << QObject::tr(
"Polar (magnitude,degree)" )
499 << QObject::tr(
"Cartesian and Polar" );
500 addParameter(
new QgsProcessingParameterEnum( QStringLiteral(
"VECTOR_OPTION" ), QObject::tr(
"Export vector option" ), exportVectorOptions,
false, 0 ) );
504 static void extractDatasetValues(
const QList<int> &datasetGroups,
509 const QSet<int> supportedDataType,
510 QList<DataGroup> &datasetPerGroup,
513 for (
int i = 0; i < datasetGroups.count(); ++i )
515 int groupIndex = datasetGroups.at( i );
520 if ( supportedDataType.contains( dataGroup.metadata.dataType() ) )
524 dataGroup.datasetValues = meshLayer->
datasetValues( datasetIndex, 0, valueCount );
528 dataGroup.dataset3dStakedValue = meshLayer->
dataset3dValues( datasetIndex, 0, valueCount );
530 datasetPerGroup.append( dataGroup );
533 feedback->
setProgress( 100 * i / datasetGroups.count() );
539 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
541 if ( !meshLayer || !meshLayer->
isValid() )
554 QList<int> datasetGroups =
563 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
564 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
566 extractDatasetValues( datasetGroups, meshLayer, mTriangularMesh, nativeMesh, relativeTime, supportedDataType(), mDataPerGroup, feedback );
568 mExportVectorOption = parameterAsInt( parameters, QStringLiteral(
"VECTOR_OPTION" ), context );
578 return QVariantMap();
580 feedback->
setProgressText( QObject::tr(
"Creating output vector layer" ) );
585 for ( DataGroup &dataGroup : mDataPerGroup )
587 if ( dataGroup.dataset3dStakedValue.isValid() )
588 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
591 QList<QgsMeshDatasetGroupMetadata> metaList;
592 metaList.reserve( mDataPerGroup.size() );
593 for (
const DataGroup &dataGroup : std::as_const( mDataPerGroup ) )
594 metaList.append( dataGroup.metadata );
595 QgsFields fields = createFields( metaList, mExportVectorOption );
601 QStringLiteral(
"OUTPUT" ),
608 return QVariantMap();
613 return QVariantMap();
619 double gridSpacing = parameterAsDouble( parameters, QStringLiteral(
"GRID_SPACING" ), context );
620 QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral(
"EXTENT" ), context );
622 extent = mTriangularMesh.extent();
623 int pointXCount = int( extent.
width() / gridSpacing ) + 1;
624 int pointYCount = int( extent.
height() / gridSpacing ) + 1;
626 for (
int ix = 0; ix < pointXCount; ++ix )
628 for (
int iy = 0; iy < pointYCount; ++iy )
631 int triangularFaceIndex = mTriangularMesh.faceIndexForPoint_v2( point );
632 if ( triangularFaceIndex >= 0 )
636 int nativeFaceIndex = mTriangularMesh.trianglesToNativeFaces().at( triangularFaceIndex );
637 for (
int i = 0; i < mDataPerGroup.count(); ++i )
639 const DataGroup &dataGroup = mDataPerGroup.at( i );
640 bool faceActive = dataGroup.activeFaces.active( nativeFaceIndex );
648 dataGroup.activeFaces,
649 dataGroup.datasetValues,
650 dataGroup.metadata );
652 if ( dataGroup.metadata.isVector() )
654 QVector<double> vector = vectorValue( dataGroup.datasetValues.value( i ), mExportVectorOption );
655 for (
double v : vector )
657 attributes.append( v );
661 attributes.append( value.
scalar() );
672 feedback->
reportError( QObject::tr(
"Could not transform point to destination CRS" ) );
683 ret[QStringLiteral(
"OUTPUT" )] = identifier;
688 QSet<int> QgsExportMeshOnGridAlgorithm::supportedDataType()
697 QString QgsMeshRasterizeAlgorithm::name()
const
699 return QStringLiteral(
"meshrasterize" );
702 QString QgsMeshRasterizeAlgorithm::displayName()
const
704 return QObject::tr(
"Rasterize mesh dataset" );
707 QString QgsMeshRasterizeAlgorithm::group()
const
709 return QObject::tr(
"Mesh" );
712 QString QgsMeshRasterizeAlgorithm::groupId()
const
714 return QStringLiteral(
"mesh" );
717 QString QgsMeshRasterizeAlgorithm::shortHelpString()
const
719 return QObject::tr(
"Create a raster layer from a mesh dataset.\n"
720 "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"
721 "1D meshes are not supported." );
726 return new QgsMeshRasterizeAlgorithm();
729 void QgsMeshRasterizeAlgorithm::initAlgorithm(
const QVariantMap &configuration )
731 Q_UNUSED( configuration );
736 QStringLiteral(
"DATASET_GROUPS" ),
737 QObject::tr(
"Dataset groups" ),
738 QStringLiteral(
"INPUT" ),
743 QStringLiteral(
"DATASET_TIME" ),
744 QObject::tr(
"Dataset time" ),
745 QStringLiteral(
"INPUT" ),
746 QStringLiteral(
"DATASET_GROUPS" ) ) );
750 addParameter(
new QgsProcessingParameterDistance( QStringLiteral(
"PIXEL_SIZE" ), QObject::tr(
"Pixel size" ), 1, QStringLiteral(
"INPUT" ),
false ) );
752 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS_OUTPUT" ), QObject::tr(
"Output coordinate system" ), QVariant(),
true ) );
759 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
761 if ( !meshLayer || !meshLayer->
isValid() )
773 QList<int> datasetGroups =
782 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
783 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
785 extractDatasetValues( datasetGroups, meshLayer, mTriangularMesh, *meshLayer->
nativeMesh(), relativeTime, supportedDataType(), mDataPerGroup, feedback );
797 return QVariantMap();
804 for ( DataGroup &dataGroup : mDataPerGroup )
806 if ( dataGroup.dataset3dStakedValue.isValid() )
807 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
811 double pixelSize = parameterAsDouble( parameters, QStringLiteral(
"PIXEL_SIZE" ), context );
812 QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral(
"EXTENT" ), context );
814 extent = mTriangularMesh.extent();
816 int width = extent.
width() / pixelSize;
817 int height = extent.
height() / pixelSize;
819 QString fileName = parameterAsOutputLayer( parameters, QStringLiteral(
"OUTPUT" ), context );
820 QFileInfo fileInfo( fileName );
823 rasterFileWriter.setOutputProviderKey( QStringLiteral(
"gdal" ) );
824 rasterFileWriter.setOutputFormat( outputFormat );
826 std::unique_ptr<QgsRasterDataProvider> rasterDataProvider(
827 rasterFileWriter.createMultiBandRaster(
Qgis::DataType::Float64, width, height, extent, mTransform.destinationCrs(), mDataPerGroup.count() ) );
828 rasterDataProvider->setEditable(
true );
830 for (
int i = 0; i < mDataPerGroup.count(); ++i )
832 const DataGroup &dataGroup = mDataPerGroup.at( i );
837 if ( dataGroup.datasetValues.isValid() )
841 dataGroup.datasetValues,
842 dataGroup.activeFaces,
843 dataGroup.metadata.dataType(),
847 &rasterBlockFeedBack );
849 rasterDataProvider->writeBlock( block, i + 1 );
850 rasterDataProvider->setNoDataValue( i + 1, block->
noDataValue() );
853 rasterDataProvider->setNoDataValue( i + 1, std::numeric_limits<double>::quiet_NaN() );
858 return QVariantMap();
859 feedback->
setProgress( 100 * i / mDataPerGroup.count() );
863 rasterDataProvider->setEditable(
false );
869 ret[QStringLiteral(
"OUTPUT" )] = fileName;
874 QSet<int> QgsMeshRasterizeAlgorithm::supportedDataType()
883 QString QgsMeshContoursAlgorithm::name()
const
885 return QStringLiteral(
"meshcontours" );
888 QString QgsMeshContoursAlgorithm::displayName()
const
890 return QObject::tr(
"Export contours" );
893 QString QgsMeshContoursAlgorithm::group()
const
895 return QObject::tr(
"Mesh" );
898 QString QgsMeshContoursAlgorithm::groupId()
const
900 return QStringLiteral(
"mesh" );
903 QString QgsMeshContoursAlgorithm::shortHelpString()
const
905 return QObject::tr(
"Creates contours as vector layer from mesh scalar dataset" );
910 return new QgsMeshContoursAlgorithm();
913 void QgsMeshContoursAlgorithm::initAlgorithm(
const QVariantMap &configuration )
915 Q_UNUSED( configuration );
920 QStringLiteral(
"DATASET_GROUPS" ),
921 QObject::tr(
"Dataset groups" ),
922 QStringLiteral(
"INPUT" ),
923 supportedDataType() ) );
926 QStringLiteral(
"DATASET_TIME" ),
927 QObject::tr(
"Dataset time" ),
928 QStringLiteral(
"INPUT" ),
929 QStringLiteral(
"DATASET_GROUPS" ) ) );
940 QStringLiteral(
"CONTOUR_LEVEL_LIST" ), QObject::tr(
"List of contours level" ), QVariant(),
false,
true ) );
942 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS_OUTPUT" ), QObject::tr(
"Output coordinate system" ), QVariant(),
true ) );
951 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
953 if ( !meshLayer || !meshLayer->
isValid() )
969 QString levelsString = parameterAsString( parameters, QStringLiteral(
"CONTOUR_LEVEL_LIST" ), context );
970 if ( ! levelsString.isEmpty() )
972 QStringList levelStringList = levelsString.split(
',' );
973 if ( !levelStringList.isEmpty() )
975 for (
const QString &stringVal : levelStringList )
978 double val = stringVal.toDouble( &ok );
980 mLevels.append( val );
982 throw QgsProcessingException( QObject::tr(
"Invalid format for level values, must be numbers separated with comma" ) );
984 if ( mLevels.count() >= 2 )
985 if ( mLevels.last() <= mLevels.at( mLevels.count() - 2 ) )
986 throw QgsProcessingException( QObject::tr(
"Invalid format for level values, must be different numbers and in increasing order" ) );
991 if ( mLevels.isEmpty() )
993 double minimum = parameterAsDouble( parameters, QStringLiteral(
"MINIMUM" ), context );
994 double maximum = parameterAsDouble( parameters, QStringLiteral(
"MAXIMUM" ), context );
995 double interval = parameterAsDouble( parameters, QStringLiteral(
"INCREMENT" ), context );
1000 if ( minimum >= maximum )
1001 throw QgsProcessingException( QObject::tr(
"Invalid minimum and maximum values, minimum must be lesser than maximum" ) );
1003 if ( interval > ( maximum - minimum ) )
1004 throw QgsProcessingException( QObject::tr(
"Invalid minimum, maximum and interval values, difference between minimum and maximum must be greater or equal than interval" ) );
1006 int intervalCount = ( maximum - minimum ) / interval;
1008 mLevels.reserve( intervalCount );
1009 for (
int i = 0; i < intervalCount; ++i )
1011 mLevels.append( minimum + i * interval );
1016 QList<int> datasetGroups =
1025 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
1026 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
1030 extractDatasetValues( datasetGroups, meshLayer, mTriangularMesh, mNativeMesh, relativeTime, supportedDataType(), mDataPerGroup, feedback );
1041 for ( DataGroup &dataGroup : mDataPerGroup )
1043 if ( dataGroup.dataset3dStakedValue.isValid() )
1044 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
1050 polygonFields.
append( QObject::tr(
"group" ) );
1051 polygonFields.
append( QObject::tr(
"time" ) );
1052 polygonFields.
append( QObject::tr(
"min_value" ) );
1053 polygonFields.
append( QObject::tr(
"max_value" ) );
1054 lineFields.
append( QObject::tr(
"group" ) );
1055 lineFields.
append( QObject::tr(
"time" ) );
1056 lineFields.
append( QObject::tr(
"value" ) );
1060 QString lineIdentifier;
1061 QString polygonIdentifier;
1063 QStringLiteral(
"OUTPUT_POLYGONS" ),
1070 QStringLiteral(
"OUTPUT_LINES" ),
1077 if ( !sinkLines || !sinkPolygons )
1078 return QVariantMap();
1081 for (
int i = 0; i < mDataPerGroup.count(); ++i )
1083 DataGroup dataGroup = mDataPerGroup.at( i );
1085 int count = scalarDataOnVertices ? mNativeMesh.vertices.count() : mNativeMesh.faces.count();
1087 QVector<double> values;
1088 if ( dataGroup.datasetValues.isValid() )
1091 values = QgsMeshLayerUtils::calculateMagnitudes( dataGroup.datasetValues );
1095 values = QVector<double>( count, std::numeric_limits<double>::quiet_NaN() );
1098 if ( ( !scalarDataOnVertices ) )
1100 values = QgsMeshLayerUtils::interpolateFromFacesData(
1103 &dataGroup.activeFaces,
1108 QgsMeshContours contoursExported( mTriangularMesh, mNativeMesh, values, dataGroup.activeFaces );
1111 firstAttributes.append( dataGroup.metadata.name() );
1112 firstAttributes.append( mDateTimeString );
1114 for (
double level : std::as_const( mLevels ) )
1116 QgsGeometry line = contoursExported.exportLines( level, feedback );
1118 return QVariantMap();
1122 lineAttributes.append( level );
1132 for (
int l = 0; l < mLevels.count() - 1; ++l )
1134 QgsGeometry polygon = contoursExported.exportPolygons( mLevels.at( l ), mLevels.at( l + 1 ), feedback );
1136 return QVariantMap();
1141 polygonAttributes.append( mLevels.at( l ) );
1142 polygonAttributes.append( mLevels.at( l + 1 ) );
1152 feedback->
setProgress( 100 * i / mDataPerGroup.count() );
1157 ret[QStringLiteral(
"OUTPUT_LINES" )] = lineIdentifier;
1158 ret[QStringLiteral(
"OUTPUT_POLYGONS" )] = polygonIdentifier;
1163 QString QgsMeshExportCrossSection::name()
const
1165 return QStringLiteral(
"meshexportcrosssection" );
1168 QString QgsMeshExportCrossSection::displayName()
const
1170 return QObject::tr(
"Export cross section dataset values on lines from mesh" );
1173 QString QgsMeshExportCrossSection::group()
const
1175 return QObject::tr(
"Mesh" );
1178 QString QgsMeshExportCrossSection::groupId()
const
1180 return QStringLiteral(
"mesh" );
1183 QString QgsMeshExportCrossSection::shortHelpString()
const
1185 return QObject::tr(
"This algorithm extracts mesh's dataset values from line contained in a vector layer.\n"
1186 "Each line is discretized with a resolution distance parameter for extraction of values on its vertices." );
1191 return new QgsMeshExportCrossSection();
1194 void QgsMeshExportCrossSection::initAlgorithm(
const QVariantMap &configuration )
1196 Q_UNUSED( configuration );
1201 QStringLiteral(
"DATASET_GROUPS" ),
1202 QObject::tr(
"Dataset groups" ),
1203 QStringLiteral(
"INPUT" ),
1204 supportedDataType() ) );
1207 QStringLiteral(
"DATASET_TIME" ),
1208 QObject::tr(
"Dataset time" ),
1209 QStringLiteral(
"INPUT" ),
1210 QStringLiteral(
"DATASET_GROUPS" ) ) );
1212 QList<int> datatype;
1215 QStringLiteral(
"INPUT_LINES" ), QObject::tr(
"Lines for data export" ), datatype, QVariant(),
false ) );
1218 QStringLiteral(
"RESOLUTION" ), QObject::tr(
"Line segmentation resolution" ), 10.0, QStringLiteral(
"INPUT_LINES" ),
false, 0 ) );
1227 QStringLiteral(
"OUTPUT" ), QObject::tr(
"Exported data CSV file" ), QObject::tr(
"CSV file (*.csv)" ) ) );
1232 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
1234 if ( !meshLayer || !meshLayer->
isValid() )
1237 mMeshLayerCrs = meshLayer->
crs();
1240 QList<int> datasetGroups =
1249 QVariant parameterTimeVariant = parameters.value( QStringLiteral(
"DATASET_TIME" ) );
1250 QgsInterval relativeTime = datasetRelativetime( parameterTimeVariant, meshLayer, context );
1252 extractDatasetValues( datasetGroups, meshLayer, mTriangularMesh, *meshLayer->
nativeMesh(), relativeTime, supportedDataType(), mDataPerGroup, feedback );
1265 for ( DataGroup &dataGroup : mDataPerGroup )
1267 if ( dataGroup.dataset3dStakedValue.isValid() )
1268 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
1270 double resolution = parameterAsDouble( parameters, QStringLiteral(
"RESOLUTION" ), context );
1271 int datasetDigits = parameterAsInt( parameters, QStringLiteral(
"DATASET_DIGITS" ), context );
1272 int coordDigits = parameterAsInt( parameters, QStringLiteral(
"COORDINATES_DIGITS" ), context );
1275 if ( !featureSource )
1280 QString outputFileName = parameterAsFileOutput( parameters, QStringLiteral(
"OUTPUT" ), context );
1281 QFile file( outputFileName );
1282 if ( ! file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
1285 QTextStream textStream( &file );
1286 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1287 textStream.setCodec(
"UTF-8" );
1290 header << QStringLiteral(
"fid" ) << QStringLiteral(
"x" ) << QStringLiteral(
"y" ) << QObject::tr(
"offset" );
1291 for (
const DataGroup &datagroup : std::as_const( mDataPerGroup ) )
1292 header << datagroup.metadata.name();
1293 textStream << header.join(
',' ) << QStringLiteral(
"\n" );
1296 long long featCounter = 0;
1310 feedback->
reportError( QObject::tr(
"Could not transform line to mesh CRS" ) );
1316 while ( offset <= line.
length() )
1319 return QVariantMap();
1321 QStringList textLine;
1323 int triangularFaceIndex = mTriangularMesh.faceIndexForPoint_v2( point );
1324 textLine << QString::number( fid ) << QString::number( point.
x(),
'f', coordDigits ) << QString::number( point.
y(),
'f', coordDigits ) << QString::number( offset,
'f', coordDigits );
1325 if ( triangularFaceIndex >= 0 )
1329 int nativeFaceIndex = mTriangularMesh.trianglesToNativeFaces().at( triangularFaceIndex );
1330 for (
int i = 0; i < mDataPerGroup.count(); ++i )
1332 const DataGroup &dataGroup = mDataPerGroup.at( i );
1333 bool faceActive = dataGroup.activeFaces.active( nativeFaceIndex );
1339 triangularFaceIndex,
1341 dataGroup.activeFaces,
1342 dataGroup.datasetValues,
1343 dataGroup.metadata );
1345 if ( abs( value.
x() ) == std::numeric_limits<double>::quiet_NaN() )
1346 textLine << QString(
' ' );
1348 textLine << QString::number( value.
scalar(),
'f', datasetDigits );
1352 for (
int i = 0; i < mDataPerGroup.count(); ++i )
1353 textLine << QString(
' ' );
1355 textStream << textLine.join(
',' ) << QStringLiteral(
"\n" );
1357 offset += resolution;
1362 feedback->
setProgress( 100.0 * featCounter / featCount );
1364 return QVariantMap();
1371 ret[QStringLiteral(
"OUTPUT" )] = outputFileName;
1375 QString QgsMeshExportTimeSeries::name()
const
1377 return QStringLiteral(
"meshexporttimeseries" );
1380 QString QgsMeshExportTimeSeries::displayName()
const
1382 return QObject::tr(
"Export time series values from points of a mesh dataset" );
1385 QString QgsMeshExportTimeSeries::group()
const
1387 return QObject::tr(
"Mesh" );
1390 QString QgsMeshExportTimeSeries::groupId()
const
1392 return QStringLiteral(
"mesh" );
1395 QString QgsMeshExportTimeSeries::shortHelpString()
const
1397 return QObject::tr(
"This algorithm extracts mesh's dataset time series values from points contained in a vector layer.\n"
1398 "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" );
1403 return new QgsMeshExportTimeSeries();
1406 void QgsMeshExportTimeSeries::initAlgorithm(
const QVariantMap &configuration )
1408 Q_UNUSED( configuration );
1413 QStringLiteral(
"DATASET_GROUPS" ),
1414 QObject::tr(
"Dataset groups" ),
1415 QStringLiteral(
"INPUT" ),
1416 supportedDataType() ) );
1419 QStringLiteral(
"STARTING_TIME" ),
1420 QObject::tr(
"Starting time" ),
1421 QStringLiteral(
"INPUT" ),
1422 QStringLiteral(
"DATASET_GROUPS" ) ) );
1425 QStringLiteral(
"FINISHING_TIME" ),
1426 QObject::tr(
"Finishing time" ),
1427 QStringLiteral(
"INPUT" ),
1428 QStringLiteral(
"DATASET_GROUPS" ) ) );
1433 QList<int> datatype;
1436 QStringLiteral(
"INPUT_POINTS" ), QObject::tr(
"Points for data export" ), datatype, QVariant(),
false ) );
1445 QStringLiteral(
"OUTPUT" ), QObject::tr(
"Exported data CSV file" ), QObject::tr(
"CSV file (*.csv)" ) ) );
1450 QgsMeshLayer *meshLayer = parameterAsMeshLayer( parameters, QStringLiteral(
"INPUT" ), context );
1452 if ( !meshLayer || !meshLayer->
isValid() )
1455 mMeshLayerCrs = meshLayer->
crs();
1458 QList<int> datasetGroups =
1467 QVariant parameterStartTimeVariant = parameters.value( QStringLiteral(
"STARTING_TIME" ) );
1468 QgsInterval relativeStartTime = datasetRelativetime( parameterStartTimeVariant, meshLayer, context );
1470 QVariant parameterEndTimeVariant = parameters.value( QStringLiteral(
"FINISHING_TIME" ) );
1471 QgsInterval relativeEndTime = datasetRelativetime( parameterEndTimeVariant, meshLayer, context );
1474 qint64 timeStepInterval = parameterAsDouble( parameters, QStringLiteral(
"TIME_STEP" ), context ) * 1000 * 3600;
1475 if ( timeStepInterval == 0 )
1478 for (
int groupIndex : datasetGroups )
1492 mRelativeTimeSteps.clear();
1493 mTimeStepString.clear();
1494 if ( timeStepInterval != 0 )
1496 mRelativeTimeSteps.append( relativeStartTime.
seconds() * 1000 );
1497 while ( mRelativeTimeSteps.last() < relativeEndTime.
seconds() * 1000 )
1498 mRelativeTimeSteps.append( mRelativeTimeSteps.last() + timeStepInterval );
1500 for ( qint64 relativeTimeStep : std::as_const( mRelativeTimeSteps ) )
1502 mTimeStepString.append( meshLayer->
formatTime( relativeTimeStep / 3600.0 / 1000.0 ) );
1507 for (
int i = 0; i < datasetGroups.count(); ++i )
1509 int groupIndex = datasetGroups.at( i );
1511 if ( supportedDataType().contains( meta.
dataType() ) )
1513 mGroupIndexes.append( groupIndex );
1514 mGroupsMetadata[groupIndex] = meta;
1518 if ( !mRelativeTimeSteps.isEmpty() )
1522 for ( qint64 relativeTimeStep : mRelativeTimeSteps )
1524 QMap<int, int> &groupIndexToData = mRelativeTimeToData[relativeTimeStep];
1525 QgsInterval timeStepInterval( relativeTimeStep / 1000.0 );
1527 if ( !datasetIndex.
isValid() )
1529 if ( datasetIndex != lastDatasetIndex )
1531 DataGroup dataGroup;
1532 dataGroup.metadata = meta;
1533 dataGroup.datasetValues = meshLayer->
datasetValues( datasetIndex, 0, valueCount );
1537 dataGroup.dataset3dStakedValue = meshLayer->
dataset3dValues( datasetIndex, 0, valueCount );
1539 mDatasets.append( dataGroup );
1540 lastDatasetIndex = datasetIndex;
1542 groupIndexToData[groupIndex] = mDatasets.count() - 1;
1548 QMap<int, int> &groupIndexToData = mRelativeTimeToData[0];
1550 DataGroup dataGroup;
1551 dataGroup.metadata = meta;
1552 dataGroup.datasetValues = meshLayer->
datasetValues( datasetIndex, 0, valueCount );
1556 dataGroup.dataset3dStakedValue = meshLayer->
dataset3dValues( datasetIndex, 0, valueCount );
1558 mDatasets.append( dataGroup );
1559 groupIndexToData[groupIndex] = mDatasets.
count() - 1;
1564 feedback->
setProgress( 100 * i / datasetGroups.count() );
1580 for ( DataGroup &dataGroup : mDatasets )
1582 if ( dataGroup.dataset3dStakedValue.isValid() )
1583 dataGroup.datasetValues = avgMethod->
calculate( dataGroup.dataset3dStakedValue );
1586 int datasetDigits = parameterAsInt( parameters, QStringLiteral(
"DATASET_DIGITS" ), context );
1587 int coordDigits = parameterAsInt( parameters, QStringLiteral(
"COORDINATES_DIGITS" ), context );
1590 if ( !featureSource )
1595 QString outputFileName = parameterAsFileOutput( parameters, QStringLiteral(
"OUTPUT" ), context );
1596 QFile file( outputFileName );
1597 if ( ! file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
1600 QTextStream textStream( &file );
1601 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1602 textStream.setCodec(
"UTF-8" );
1605 header << QStringLiteral(
"fid" ) << QStringLiteral(
"x" ) << QStringLiteral(
"y" ) << QObject::tr(
"time" );
1607 for (
int gi : std::as_const( mGroupIndexes ) )
1608 header << mGroupsMetadata.value( gi ).name();
1610 textStream << header.join(
',' ) << QStringLiteral(
"\n" );
1613 long long featCounter = 0;
1627 feedback->
reportError( QObject::tr(
"Could not transform line to mesh CRS" ) );
1634 int triangularFaceIndex = mTriangularMesh.faceIndexForPoint_v2( point );
1636 if ( triangularFaceIndex >= 0 )
1638 int nativeFaceIndex = mTriangularMesh.trianglesToNativeFaces().at( triangularFaceIndex );
1639 if ( !mRelativeTimeSteps.isEmpty() )
1641 for (
int timeIndex = 0; timeIndex < mRelativeTimeSteps.count(); ++timeIndex )
1643 qint64 timeStep = mRelativeTimeSteps.at( timeIndex );
1644 QStringList textLine;
1645 textLine << QString::number( fid )
1646 << QString::number( point.
x(),
'f', coordDigits )
1647 << QString::number( point.
y(),
'f', coordDigits )
1648 << mTimeStepString.at( timeIndex );
1650 if ( mRelativeTimeToData.contains( timeStep ) )
1652 const QMap<int, int> &groupToData = mRelativeTimeToData.value( timeStep );
1653 for (
int groupIndex : std::as_const( mGroupIndexes ) )
1655 if ( !groupToData.contains( groupIndex ) )
1657 int dataIndex = groupToData.value( groupIndex );
1658 if ( dataIndex < 0 || dataIndex > mDatasets.count() - 1 )
1661 const DataGroup &dataGroup = mDatasets.at( dataIndex );
1664 triangularFaceIndex,
1666 dataGroup.activeFaces,
1667 dataGroup.datasetValues,
1668 dataGroup.metadata );
1669 if ( abs( value.
x() ) == std::numeric_limits<double>::quiet_NaN() )
1670 textLine << QString(
' ' );
1672 textLine << QString::number( value.
scalar(),
'f', datasetDigits ) ;
1675 textStream << textLine.join(
',' ) << QStringLiteral(
"\n" );
1680 QStringList textLine;
1681 textLine << QString::number( fid )
1682 << QString::number( point.
x(),
'f', coordDigits )
1683 << QString::number( point.
y(),
'f', coordDigits )
1684 << QObject::tr(
"static dataset" );
1685 const QMap<int, int> &groupToData = mRelativeTimeToData.value( 0 );
1686 for (
int groupIndex : std::as_const( mGroupIndexes ) )
1688 if ( !groupToData.contains( groupIndex ) )
1690 int dataIndex = groupToData.value( groupIndex );
1691 if ( dataIndex < 0 || dataIndex > mDatasets.count() - 1 )
1693 const DataGroup &dataGroup = mDatasets.at( dataIndex );
1696 triangularFaceIndex,
1698 dataGroup.activeFaces,
1699 dataGroup.datasetValues,
1700 dataGroup.metadata );
1701 if ( abs( value.
x() ) == std::numeric_limits<double>::quiet_NaN() )
1702 textLine << QString(
' ' );
1704 textLine << QString::number( value.
scalar(),
'f', datasetDigits );
1706 textStream << textLine.join(
',' ) << QStringLiteral(
"\n" );
1712 feedback->
setProgress( 100.0 * featCounter / featCount );
1714 return QVariantMap();
1721 ret[QStringLiteral(
"OUTPUT" )] = outputFileName;
@ Float64
Sixty four bit floating point (double)
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)
An interface for objects which accept features via addFeature(s) methods.
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())
Adds a single feature to the sink.
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.
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 ...
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
Container of fields for a vector layer.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
A geometry is the spatial representation of a feature.
double length() const
Returns the planar, 2-dimensional length of geometry.
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...
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
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.
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.
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.
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.
QgsTriangularMesh * triangularMesh(double minimumTriangleSize=0) const
Returns triangular mesh (nullptr before rendering or calling to updateMesh).
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.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request, Flags flags) const
Returns an iterator for the features in the source, respecting the supplied feature flags.
QgsCoordinateReferenceSystem sourceCrs() const override
Returns the coordinate reference system for features in the source.
long long featureCount() const override
Returns the number of features contained in the source, or -1 if the feature count is unknown.
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.
@ Double
Double/float values.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
A string parameter for processing algorithms.
@ TypeVectorLine
Vector line layers.
@ TypeVectorPolygon
Vector polygon layers.
@ TypeVectorPoint
Vector point layers.
Feedback object tailored for raster block reading.
double noDataValue() const SIP_HOLDGIL
Returns no data value.
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.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
bool isEmpty() const
Returns true if the rectangle is empty.
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.
void clear()
Remove all vertices, edges and faces.
int faceCount() const
Returns number of faces.