mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-19 00:07:15 -04:00
test without different CRS
and add some const
This commit is contained in:
parent
836246eab9
commit
0f70883b6d
@ -73,11 +73,11 @@ void QgsTinMeshCreationAlgorithm::initAlgorithm( const QVariantMap &configuratio
|
|||||||
bool QgsTinMeshCreationAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
|
bool QgsTinMeshCreationAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
|
||||||
{
|
{
|
||||||
Q_UNUSED( feedback );
|
Q_UNUSED( feedback );
|
||||||
QVariant layersVariant = parameters.value( parameterDefinition( QStringLiteral( "SOURCE_DATA" ) )->name() );
|
const QVariant layersVariant = parameters.value( parameterDefinition( QStringLiteral( "SOURCE_DATA" ) )->name() );
|
||||||
if ( layersVariant.type() != QVariant::List )
|
if ( layersVariant.type() != QVariant::List )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QVariantList layersList = layersVariant.toList();
|
const QVariantList layersList = layersVariant.toList();
|
||||||
|
|
||||||
QgsCoordinateReferenceSystem destinationCrs = parameterAsCrs( parameters, QStringLiteral( "CRS_OUTPUT" ), context );
|
QgsCoordinateReferenceSystem destinationCrs = parameterAsCrs( parameters, QStringLiteral( "CRS_OUTPUT" ), context );
|
||||||
if ( !destinationCrs.isValid() )
|
if ( !destinationCrs.isValid() )
|
||||||
@ -87,9 +87,9 @@ bool QgsTinMeshCreationAlgorithm::prepareAlgorithm( const QVariantMap ¶meter
|
|||||||
{
|
{
|
||||||
if ( layer.type() != QVariant::Map )
|
if ( layer.type() != QVariant::Map )
|
||||||
continue;
|
continue;
|
||||||
QVariantMap layerMap = layer.toMap();
|
const QVariantMap layerMap = layer.toMap();
|
||||||
QString layerId = layerMap.value( QStringLiteral( "Id" ) ).toString();
|
const QString layerId = layerMap.value( QStringLiteral( "Id" ) ).toString();
|
||||||
QgsProcessingParameterTinInputLayers::Type type =
|
const QgsProcessingParameterTinInputLayers::Type type =
|
||||||
static_cast<QgsProcessingParameterTinInputLayers::Type>( layerMap.value( QStringLiteral( "Type" ) ).toInt() );
|
static_cast<QgsProcessingParameterTinInputLayers::Type>( layerMap.value( QStringLiteral( "Type" ) ).toInt() );
|
||||||
int attributeIndex = layerMap.value( QStringLiteral( "AttributeIndex" ) ).toInt();
|
int attributeIndex = layerMap.value( QStringLiteral( "AttributeIndex" ) ).toInt();
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ bool QgsTinMeshCreationAlgorithm::prepareAlgorithm( const QVariantMap ¶meter
|
|||||||
if ( !vectorLayer || !vectorLayer->isValid() )
|
if ( !vectorLayer || !vectorLayer->isValid() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QgsCoordinateTransform transform( vectorLayer->crs(), destinationCrs, context.transformContext() );
|
const QgsCoordinateTransform transform( vectorLayer->crs(), destinationCrs, context.transformContext() );
|
||||||
int featureCount = vectorLayer->featureCount();
|
int featureCount = vectorLayer->featureCount();
|
||||||
switch ( type )
|
switch ( type )
|
||||||
{
|
{
|
||||||
@ -129,12 +129,12 @@ QVariantMap QgsTinMeshCreationAlgorithm::processAlgorithm( const QVariantMap &pa
|
|||||||
for ( Layer &l : mBreakLinesLayer )
|
for ( Layer &l : mBreakLinesLayer )
|
||||||
triangulation.addBreakLines( l.fit, l.attributeIndex, l.transform, feedback, l.featureCount );
|
triangulation.addBreakLines( l.fit, l.attributeIndex, l.transform, feedback, l.featureCount );
|
||||||
|
|
||||||
QString fileName = parameterAsFile( parameters, QStringLiteral( "OUTPUT_MESH" ), context );
|
const QString fileName = parameterAsFile( parameters, QStringLiteral( "OUTPUT_MESH" ), context );
|
||||||
int driverIndex = parameterAsEnum( parameters, QStringLiteral( "MESH_FORMAT" ), context );
|
int driverIndex = parameterAsEnum( parameters, QStringLiteral( "MESH_FORMAT" ), context );
|
||||||
QString driver = mAvailableFormat.at( driverIndex );
|
const QString driver = mAvailableFormat.at( driverIndex );
|
||||||
QgsMesh mesh = triangulation.triangulatedMesh();
|
const QgsMesh mesh = triangulation.triangulatedMesh();
|
||||||
|
|
||||||
QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "mdal" ) );
|
const QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "mdal" ) );
|
||||||
if ( providerMetadata )
|
if ( providerMetadata )
|
||||||
providerMetadata->createMeshData( mesh, fileName, driver, destinationCrs );
|
providerMetadata->createMeshData( mesh, fileName, driver, destinationCrs );
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ Email : vcloarec at gmail dot com
|
|||||||
#include "qgsmeshtriangulation.h"
|
#include "qgsmeshtriangulation.h"
|
||||||
#include "qgsvectorlayer.h"
|
#include "qgsvectorlayer.h"
|
||||||
|
|
||||||
|
#include "qgsprovidermetadata.h"
|
||||||
|
#include "qgsproviderregistry.h"
|
||||||
|
|
||||||
class TestQgsTriangulation : public QObject
|
class TestQgsTriangulation : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -38,7 +41,10 @@ class TestQgsTriangulation : public QObject
|
|||||||
};
|
};
|
||||||
|
|
||||||
void TestQgsTriangulation::initTestCase()
|
void TestQgsTriangulation::initTestCase()
|
||||||
{}
|
{
|
||||||
|
QgsApplication::init();
|
||||||
|
QgsApplication::initQgis();
|
||||||
|
}
|
||||||
|
|
||||||
void TestQgsTriangulation::cleanupTestCase()
|
void TestQgsTriangulation::cleanupTestCase()
|
||||||
{}
|
{}
|
||||||
@ -162,7 +168,7 @@ void TestQgsTriangulation::meshTriangulation()
|
|||||||
|
|
||||||
meshTri.setCrs( QgsCoordinateReferenceSystem( "EPSG:32620" ) );
|
meshTri.setCrs( QgsCoordinateReferenceSystem( "EPSG:32620" ) );
|
||||||
|
|
||||||
QgsVectorLayer *mLayerPointZ = new QgsVectorLayer( QStringLiteral( "PointZ?crs=IGNF:GUAD48UTM20" ),
|
QgsVectorLayer *mLayerPointZ = new QgsVectorLayer( QStringLiteral( "PointZ?crs=EPSG:32620" ),
|
||||||
QStringLiteral( "point Z" ),
|
QStringLiteral( "point Z" ),
|
||||||
QStringLiteral( "memory" ) );
|
QStringLiteral( "memory" ) );
|
||||||
|
|
||||||
@ -197,14 +203,14 @@ void TestQgsTriangulation::meshTriangulation()
|
|||||||
QCOMPARE( mesh.vertexCount(), 4 );
|
QCOMPARE( mesh.vertexCount(), 4 );
|
||||||
QCOMPARE( mesh.faceCount(), 2 );
|
QCOMPARE( mesh.faceCount(), 2 );
|
||||||
|
|
||||||
QCOMPARE( mesh.vertex( 0 ), QgsMeshVertex( 684063.6227548943, 1760993.6560628675, 1 ) );
|
QCOMPARE( mesh.vertex( 0 ), QgsMeshVertex( 684486.0, 1761297.0, 1 ) );
|
||||||
QCOMPARE( mesh.vertex( 1 ), QgsMeshVertex( 683853.6219030637, 1761005.6564316382, 2 ) );
|
QCOMPARE( mesh.vertex( 1 ), QgsMeshVertex( 684276.0, 1761309.0, 2 ) );
|
||||||
QCOMPARE( mesh.vertex( 2 ), QgsMeshVertex( 683675.6212958666, 1761097.6571173898, 3 ) );
|
QCOMPARE( mesh.vertex( 2 ), QgsMeshVertex( 684098.0, 1761401.0, 3 ) );
|
||||||
QCOMPARE( mesh.vertex( 3 ), QgsMeshVertex( 683869.6222287047, 1761102.6569346827, 4 ) );
|
QCOMPARE( mesh.vertex( 3 ), QgsMeshVertex( 684292.0, 1761406.0, 4 ) );
|
||||||
QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 3, 1} ) ) );
|
QVERIFY( QgsMesh::compareFaces( mesh.face( 0 ), QgsMeshFace( {0, 3, 1} ) ) );
|
||||||
QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( {1, 3, 2} ) ) );
|
QVERIFY( QgsMesh::compareFaces( mesh.face( 1 ), QgsMeshFace( {1, 3, 2} ) ) );
|
||||||
|
|
||||||
QString wkt5 = "LineStringZ (683675.6212958666 1761097.6571173898 3,683787.86359334166627377 1761044.579075972083956 7,683921.42213789699599147 1761070.09025864000432193 8,684063.6227548943 1760993.6560628675 1)";
|
QString wkt5 = "LineStringZ (684098.0 1761401.0 3,684210.24 1761347.92 7,684343.8 1761373.4 8,684486.0 1761297.0 1)";
|
||||||
|
|
||||||
QgsVectorLayer *mLayerBreakLine = new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=EPSG:32620" ),
|
QgsVectorLayer *mLayerBreakLine = new QgsVectorLayer( QStringLiteral( "LineStringZ?crs=EPSG:32620" ),
|
||||||
QStringLiteral( "line" ),
|
QStringLiteral( "line" ),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user