Support point and rectangle as geometry parameter values

This commit is contained in:
David Marteau 2020-09-08 21:33:46 +02:00 committed by Nyall Dawson
parent 4eb779798e
commit f2b8e6970b
12 changed files with 393 additions and 36 deletions

View File

@ -86,8 +86,6 @@ Constructor for QgsReferencedGeometry.
};
class QgsReferencedRectangle : QgsRectangle, QgsReferencedGeometryBase
{
%Docstring

View File

@ -851,6 +851,26 @@ Returns the coordinate reference system associated with an point parameter value
.. seealso:: :py:func:`parameterAsPoint`
%End
QgsGeometry parameterAsGeometry( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context,
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a geometry.
If ``crs`` is set then the geometry will be automatically
reprojected so that it is in the specified ``crs``.
.. seealso:: :py:func:`parameterAsGeometryCrs`
%End
QgsCoordinateReferenceSystem parameterAsGeometryCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
%Docstring
Returns the coordinate reference system associated with a geometry parameter value.
.. seealso:: :py:func:`parameterAsGeometry`
%End
QString parameterAsFile( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const;
%Docstring
Evaluates the parameter with matching ``name`` to a file/folder name.

View File

@ -1174,17 +1174,35 @@ Returns the coordinate reference system associated with an point parameter value
.. versionadded:: 3.8
%End
static QgsGeometry parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
static QgsGeometry parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
%Docstring
Evaluates the parameter with matching ``definition`` to a geometry.
.. versionadded:: 3.16
%End
static QgsGeometry parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
static QgsGeometry parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
%Docstring
Evaluates the parameter with matching ``definition`` and ``value`` to a geometry.
.. versionadded:: 3.16
%End
static QgsCoordinateReferenceSystem parameterAsGeometryCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
%Docstring
Returns the coordinate reference system associated with a geometry parameter value.
.. seealso:: :py:func:`parameterAsGeometry`
.. versionadded:: 3.16
%End
static QgsCoordinateReferenceSystem parameterAsGeometryCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
%Docstring
Returns the coordinate reference system associated with an point parameter value.
.. seealso:: :py:func:`parameterAsGeometry`
.. versionadded:: 3.16
%End

View File

@ -103,8 +103,6 @@ class CORE_EXPORT QgsReferencedGeometry : public QgsGeometry, public QgsReferenc
Q_DECLARE_METATYPE( QgsReferencedGeometry )
/**
* \ingroup core
* A QgsRectangle with associated coordinate reference system.

View File

@ -267,6 +267,20 @@ bool QgsProcessingAlgorithm::validateInputCrs( const QVariantMap &parameters, Qg
crs = pointCrs;
}
}
else if ( def->type() == QgsProcessingParameterGeometry::typeName() )
{
QgsCoordinateReferenceSystem geomCrs = QgsProcessingParameters::parameterAsGeometryCrs( def, parameters, context );
if ( foundCrs && geomCrs.isValid() && crs != geomCrs )
{
return false;
}
else if ( !foundCrs && geomCrs.isValid() )
{
foundCrs = true;
crs = geomCrs;
}
}
}
return true;
}
@ -693,6 +707,16 @@ QgsCoordinateReferenceSystem QgsProcessingAlgorithm::parameterAsPointCrs( const
return QgsProcessingParameters::parameterAsPointCrs( parameterDefinition( name ), parameters, context );
}
QgsGeometry QgsProcessingAlgorithm::parameterAsGeometry( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs ) const
{
return QgsProcessingParameters::parameterAsGeometry( parameterDefinition( name ), parameters, context, crs );
}
QgsCoordinateReferenceSystem QgsProcessingAlgorithm::parameterAsGeometryCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context )
{
return QgsProcessingParameters::parameterAsGeometryCrs( parameterDefinition( name ), parameters, context );
}
QString QgsProcessingAlgorithm::parameterAsFile( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context ) const
{
return QgsProcessingParameters::parameterAsFile( parameterDefinition( name ), parameters, context );

View File

@ -855,6 +855,26 @@ class CORE_EXPORT QgsProcessingAlgorithm
*/
QgsCoordinateReferenceSystem parameterAsPointCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
/**
* Evaluates the parameter with matching \a name to a geometry.
*
* If \a crs is set then the geometry will be automatically
* reprojected so that it is in the specified \a crs.
*
* \see parameterAsGeometryCrs()
*/
QgsGeometry parameterAsGeometry( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context,
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() ) const;
/**
* Returns the coordinate reference system associated with a geometry parameter value.
*
* \see parameterAsGeometry()
*/
QgsCoordinateReferenceSystem parameterAsGeometryCrs( const QVariantMap &parameters, const QString &name, QgsProcessingContext &context );
/**
* Evaluates the parameter with matching \a name to a file/folder name.
*/

View File

@ -1,5 +1,5 @@
/***************************************************************************
qgsprocessingparameters.cpp
q+gsprocessingparameters.cpp
---------------------------
begin : April 2017
copyright : (C) 2017 by Nyall Dawson
@ -1417,15 +1417,15 @@ QgsCoordinateReferenceSystem QgsProcessingParameters::parameterAsPointCrs( const
return QgsCoordinateReferenceSystem();
}
QgsGeometry QgsProcessingParameters::parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
QgsGeometry QgsProcessingParameters::parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs )
{
if ( !definition )
return QgsGeometry();
return parameterAsGeometry( definition, parameters.value( definition->name() ), context );
return parameterAsGeometry( definition, parameters.value( definition->name() ), context, crs );
}
QgsGeometry QgsProcessingParameters::parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
QgsGeometry QgsProcessingParameters::parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs )
{
if ( !definition )
return QgsGeometry();
@ -1436,15 +1436,165 @@ QgsGeometry QgsProcessingParameters::parameterAsGeometry( const QgsProcessingPar
return val.value<QgsGeometry>();
}
QString valueAsString = parameterAsString( definition, value, context );
if ( !valueAsString.isEmpty() )
if ( val.canConvert< QgsPointXY >() )
{
return QgsGeometry::fromWkt( valueAsString );
return QgsGeometry::fromPointXY( val.value<QgsPointXY>() );
}
if ( val.canConvert< QgsRectangle >() )
{
return QgsGeometry::fromRect( val.value<QgsRectangle>() );
}
if ( val.canConvert< QgsReferencedPointXY >() )
{
QgsReferencedPointXY rp = val.value<QgsReferencedPointXY>();
if ( crs.isValid() && rp.crs().isValid() && crs != rp.crs() )
{
QgsCoordinateTransform ct( rp.crs(), crs, context.project() );
try
{
return QgsGeometry::fromPointXY( ct.transform( rp ) );
}
catch ( QgsCsException & )
{
QgsMessageLog::logMessage( QObject::tr( "Error transforming point geometry" ) );
}
}
return QgsGeometry::fromPointXY( rp );
}
if ( val.canConvert< QgsReferencedRectangle >() )
{
QgsReferencedRectangle rr = val.value<QgsReferencedRectangle>();
QgsGeometry g = QgsGeometry::fromRect( rr );
if ( crs.isValid() && rr.crs().isValid() && crs != rr.crs() )
{
g = g.densifyByCount( 20 );
QgsCoordinateTransform ct( rr.crs(), crs, context.project() );
try
{
g.transform( ct );
}
catch ( QgsCsException & )
{
QgsMessageLog::logMessage( QObject::tr( "Error transforming rectangle geometry" ) );
}
}
return g;
}
if ( val.canConvert< QgsReferencedGeometry >() )
{
QgsReferencedGeometry rg = val.value<QgsReferencedGeometry>();
if ( crs.isValid() && rg.crs().isValid() && crs != rg.crs() )
{
QgsCoordinateTransform ct( rg.crs(), crs, context.project() );
try
{
rg.transform( ct );
}
catch ( QgsCsException & )
{
QgsMessageLog::logMessage( QObject::tr( "Error transforming geometry" ) );
}
}
return rg;
}
QString valueAsString = parameterAsString( definition, value, context );
if ( valueAsString.isEmpty() )
valueAsString = definition->defaultValue().toString();
if ( valueAsString.isEmpty() )
return QgsGeometry();
// Match against EWKT
QRegularExpression rx( QStringLiteral( "^\\s*(?:SRID=(.*);)?(.*)$" ) );
QRegularExpressionMatch match = rx.match( valueAsString );
if ( match.hasMatch() )
{
QgsGeometry g = QgsGeometry::fromWkt( match.captured( 2 ) );
if ( !g.isNull() )
{
QgsCoordinateReferenceSystem geomCrs( QStringLiteral( "EPSG:%1" ).arg( match.captured( 1 ) ) );
if ( crs.isValid() && geomCrs.isValid() && crs != geomCrs )
{
QgsCoordinateTransform ct( geomCrs, crs, context.project() );
try
{
g.transform( ct );
}
catch ( QgsCsException & )
{
QgsMessageLog::logMessage( QObject::tr( "Error transforming geometry" ) );
}
}
return g;
}
}
return QgsGeometry();
}
QgsCoordinateReferenceSystem QgsProcessingParameters::parameterAsGeometryCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
{
QVariant val = parameters.value( definition->name() );
return parameterAsGeometryCrs( definition, val, context );
}
QgsCoordinateReferenceSystem QgsProcessingParameters::parameterAsGeometryCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
{
if ( value.canConvert< QgsReferencedGeometry >() )
{
QgsReferencedGeometry rg = value.value<QgsReferencedGeometry>();
if ( rg.crs().isValid() )
{
return rg.crs();
}
}
if ( value.canConvert< QgsReferencedPointXY >() )
{
QgsReferencedPointXY rp = value.value<QgsReferencedPointXY>();
if ( rp.crs().isValid() )
{
return rp.crs();
}
}
if ( value.canConvert< QgsReferencedRectangle >() )
{
QgsReferencedRectangle rr = value.value<QgsReferencedRectangle>();
if ( rr.crs().isValid() )
{
return rr.crs();
}
}
// Match against EWKT
QRegularExpression rx( QStringLiteral( "^\\s*(?:SRID=(.*);)?(.*)$" ) );
QString valueAsString = parameterAsString( definition, value, context );
QRegularExpressionMatch match = rx.match( valueAsString );
if ( match.hasMatch() )
{
QgsCoordinateReferenceSystem crs( QStringLiteral( "EPSG:%1" ).arg( match.captured( 1 ) ) );
if ( crs.isValid() )
return crs;
}
if ( context.project() )
return context.project()->crs();
else
return QgsCoordinateReferenceSystem();
}
QString QgsProcessingParameters::parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context )
{
if ( !definition )
@ -2827,23 +2977,54 @@ bool QgsProcessingParameterGeometry::checkValueIsAcceptable( const QVariant &inp
return true;
}
if ( input.canConvert< QgsReferencedGeometry >() )
{
return true;
}
if ( input.canConvert< QgsPointXY >() )
{
return true;
}
if ( input.canConvert< QgsRectangle >() )
{
return true;
}
if ( input.canConvert< QgsReferencedPointXY >() )
{
return true;
}
if ( input.canConvert< QgsReferencedRectangle >() )
{
return true;
}
if ( input.type() == QVariant::String )
{
if ( input.toString().isEmpty() )
return mFlags & FlagOptional;
}
QgsGeometry g = QgsGeometry::fromWkt( input.toString() );
if ( ! g.isNull() )
{
return true;
}
else
{
QgsMessageLog::logMessage( QObject::tr( "Error creating geometry: \"%1\"" ).arg( g.lastError() ), QObject::tr( "Processing" ) );
return false;
}
// Match against EWKT
QRegularExpression rx( QStringLiteral( "^\\s*(?:SRID=(.*);)?(.*)$" ) );
QRegularExpressionMatch match = rx.match( input.toString() );
if ( match.hasMatch() )
{
QgsGeometry g = QgsGeometry::fromWkt( match.captured( 2 ) );
if ( ! g.isNull() )
{
return true;
}
else
{
QgsMessageLog::logMessage( QObject::tr( "Error creating geometry: \"%1\"" ).arg( g.lastError() ), QObject::tr( "Processing" ) );
}
}
return false;
}
QString QgsProcessingParameterGeometry::valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const

View File

@ -1254,14 +1254,30 @@ class CORE_EXPORT QgsProcessingParameters
*
* \since QGIS 3.16
*/
static QgsGeometry parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
static QgsGeometry parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
/**
* Evaluates the parameter with matching \a definition and \a value to a geometry.
*
* \since QGIS 3.16
*/
static QgsGeometry parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
static QgsGeometry parameterAsGeometry( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
/**
* Returns the coordinate reference system associated with a geometry parameter value.
*
* \see parameterAsGeometry()
* \since QGIS 3.16
*/
static QgsCoordinateReferenceSystem parameterAsGeometryCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, QgsProcessingContext &context );
/**
* Returns the coordinate reference system associated with an point parameter value.
*
* \see parameterAsGeometry()
* \since QGIS 3.16
*/
static QgsCoordinateReferenceSystem parameterAsGeometryCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
/**
* Evaluates the parameter with matching \a definition to a file/folder name.

View File

@ -3226,8 +3226,11 @@ void QgsProcessingGeometryWidgetWrapper::setWidgetValue( const QVariant &value,
{
if ( mLineEdit )
{
QString v = QgsProcessingParameters::parameterAsString( parameterDefinition(), value, context );
mLineEdit->setText( v );
QgsGeometry g = QgsProcessingParameters::parameterAsGeometry( parameterDefinition(), value, context );
if ( !g.isNull() )
mLineEdit->setText( g.asWkt() );
else
mLineEdit->clear();
}
}
@ -3243,7 +3246,9 @@ QStringList QgsProcessingGeometryWidgetWrapper::compatibleParameterTypes() const
{
return QStringList()
<< QgsProcessingParameterGeometry::typeName()
<< QgsProcessingParameterString::typeName();
<< QgsProcessingParameterString::typeName()
<< QgsProcessingParameterPoint::typeName()
<< QgsProcessingParameterExtent::typeName();
}
QStringList QgsProcessingGeometryWidgetWrapper::compatibleOutputTypes() const

View File

@ -3396,6 +3396,10 @@ void TestQgsProcessing::parameterGeometry()
QVERIFY( def->checkValueIsAcceptable( QString( "LineString(10 10, 20 20)" ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsGeometry::fromPointXY( QgsPointXY( 1, 2 ) ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsGeometry::fromWkt( QStringLiteral( "LineString(10 10, 20 20)" ) ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsPointXY( 1, 2 ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsReferencedPointXY( QgsPointXY( 1, 2 ), QgsCoordinateReferenceSystem( "EPSG:4326" ) ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsRectangle( 10, 10, 20, 20 ) ) );
QVERIFY( def->checkValueIsAcceptable( QgsReferencedRectangle( QgsRectangle( 10, 10, 20, 20 ), QgsCoordinateReferenceSystem( "EPSG:4326" ) ) ) );
// string representing a geometry
QVariantMap params;
@ -3404,6 +3408,86 @@ void TestQgsProcessing::parameterGeometry()
QgsGeometry geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context );
QCOMPARE( geometry.asWkt(), QStringLiteral( "LineString (10 10, 20 20)" ) );
// with target CRS - should make no difference, because source CRS is unknown
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
QCOMPARE( geometry.asWkt(), QStringLiteral( "LineString (10 10, 20 20)" ) );
// with CRS as string
params.insert( "non_optional", QString( "SRID=4326;Point ( 1.1 2.2 )" ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context );
QPointF point = geometry.asQPointF();
QGSCOMPARENEAR( point.x(), 1.1, 0.001 );
QGSCOMPARENEAR( point.y(), 2.2, 0.001 );
QCOMPARE( QgsProcessingParameters::parameterAsGeometryCrs( def.get(), params, context ).authid(), QStringLiteral( "EPSG:4326" ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
point = geometry.asQPointF();
QGSCOMPARENEAR( point.x(), 122451, 100 );
QGSCOMPARENEAR( point.y(), 244963, 100 );
// QgsReferencedGeometry
params.insert( "non_optional", QgsReferencedGeometry( QgsGeometry::fromPointXY( QgsPointXY( 1.1, 2.2 ) ), QgsCoordinateReferenceSystem( "EPSG:4326" ) ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context );
point = geometry.asQPointF();
QGSCOMPARENEAR( point.x(), 1.1, 0.001 );
QGSCOMPARENEAR( point.y(), 2.2, 0.001 );
QCOMPARE( QgsProcessingParameters::parameterAsGeometryCrs( def.get(), params, context ).authid(), QStringLiteral( "EPSG:4326" ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
point = geometry.asQPointF();
QGSCOMPARENEAR( point.x(), 122451, 100 );
QGSCOMPARENEAR( point.y(), 244963, 100 );
// QgsPointXY
params.insert( "non_optional", QgsPointXY( 11.1, 12.2 ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context );
point = geometry.asQPointF();
QGSCOMPARENEAR( point.x(), 11.1, 0.001 );
QGSCOMPARENEAR( point.y(), 12.2, 0.001 );
// with target CRS - should make no difference, because source CRS is unknown
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
point = geometry.asQPointF();
QGSCOMPARENEAR( point.x(), 11.1, 0.001 );
QGSCOMPARENEAR( point.y(), 12.2, 0.001 );
// QgsReferencedPointXY
params.insert( "non_optional", QgsReferencedPointXY( QgsPointXY( 1.1, 2.2 ), QgsCoordinateReferenceSystem( "EPSG:4326" ) ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context );
point = geometry.asQPointF();
QGSCOMPARENEAR( point.x(), 1.1, 0.001 );
QGSCOMPARENEAR( point.y(), 2.2, 0.001 );
QCOMPARE( QgsProcessingParameters::parameterAsGeometryCrs( def.get(), params, context ).authid(), QStringLiteral( "EPSG:4326" ) );
// with target CRS
params.insert( "non_optional", QgsReferencedPointXY( QgsPointXY( 1.1, 2.2 ), QgsCoordinateReferenceSystem( "EPSG:4326" ) ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
point = geometry.asQPointF();
QGSCOMPARENEAR( point.x(), 122451, 100 );
QGSCOMPARENEAR( point.y(), 244963, 100 );
// QgsRectangle
params.insert( "non_optional", QgsRectangle( 11.1, 12.2, 13.3, 14.4 ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context );
QCOMPARE( geometry.asWkt( 1 ), QStringLiteral( "Polygon ((11.1 12.2, 13.3 12.2, 13.3 14.4, 11.1 14.4, 11.1 12.2))" ) );
// with target CRS - should make no difference, because source CRS is unknown
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
QCOMPARE( geometry.asWkt( 1 ), QStringLiteral( "Polygon ((11.1 12.2, 13.3 12.2, 13.3 14.4, 11.1 14.4, 11.1 12.2))" ) );
// QgsReferenced Rectangle
params.insert( "non_optional", QgsReferencedRectangle( QgsRectangle( 11.1, 12.2, 13.3, 14.4 ), QgsCoordinateReferenceSystem( "EPSG:4326" ) ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context );
QCOMPARE( geometry.asWkt( 1 ), QStringLiteral( "Polygon ((11.1 12.2, 13.3 12.2, 13.3 14.4, 11.1 14.4, 11.1 12.2))" ) );
QCOMPARE( QgsProcessingParameters::parameterAsGeometryCrs( def.get(), params, context ).authid(), QStringLiteral( "EPSG:4326" ) );
// with target CRS
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context, QgsCoordinateReferenceSystem( "EPSG:3785" ) );
QCOMPARE( geometry.constGet()->vertexCount(), 85 );
QgsRectangle ext = geometry.boundingBox();
QGSCOMPARENEAR( ext.xMinimum(), 1235646, 100 );
QGSCOMPARENEAR( ext.xMaximum(), 1480549, 100 );
QGSCOMPARENEAR( ext.yMinimum(), 1368478, 100 );
QGSCOMPARENEAR( ext.yMaximum(), 1620147, 100 );
// nonsense string
params.insert( "non_optional", QString( "i'm not a geometry, and nothing you can do will make me one" ) );
geometry = QgsProcessingParameters::parameterAsGeometry( def.get(), params, context );

View File

@ -4760,13 +4760,6 @@ void TestProcessingGui::testGeometryWrapper()
QVERIFY( !wrapper2.widgetValue().isValid() );
QVERIFY( static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->text().isEmpty() );
// check signals
wrapper2.setWidgetValue( "1,3", context );
QCOMPARE( spy2.count(), 5 );
static_cast< QLineEdit * >( wrapper2.wrappedWidget() )->clear();
QCOMPARE( spy2.count(), 6 );
delete w;
};

View File

@ -139,7 +139,7 @@ class TestPython__repr__(unittest.TestCase):
self.assertEqual(r.__repr__(), '<QgsReferencedRectangle: 1 2, 3 4 (EPSG:4326)>')
def testQgsReferencedGeometryRepr(self):
g = QgsReferencedGeometry(QgsGeometry.fromPoint(QgsPointXY(1, 2)), QgsCoordinateReferenceSystem('EPSG:4326'))
g = QgsReferencedGeometry(QgsGeometry.fromPointXY(QgsPointXY(1, 2)), QgsCoordinateReferenceSystem('EPSG:4326'))
self.assertEqual(g.__repr__(), '<QgsReferencedGeometry: Point (1 2) (EPSG:4326)>')
def testQgsCoordinateReferenceSystem(self):