mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-17 00:04:03 -05:00
Fix GeometryCollect aggregate detection of geometry result type when running from external python applications
This commit is contained in:
parent
b0994a5574
commit
23ed6e9cd0
@ -102,23 +102,31 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag
|
|||||||
QVariant::Type resultType = QVariant::Double;
|
QVariant::Type resultType = QVariant::Double;
|
||||||
if ( attrNum == -1 )
|
if ( attrNum == -1 )
|
||||||
{
|
{
|
||||||
// evaluate first feature, check result type
|
if ( aggregate == GeometryCollect )
|
||||||
QgsFeatureRequest testRequest( request );
|
|
||||||
testRequest.setLimit( 1 );
|
|
||||||
QgsFeature f;
|
|
||||||
QgsFeatureIterator fit = mLayer->getFeatures( testRequest );
|
|
||||||
if ( !fit.nextFeature( f ) )
|
|
||||||
{
|
{
|
||||||
//no matching features
|
// in this case we know the result should be a geometry value, so no need to sniff it out...
|
||||||
if ( ok )
|
resultType = QVariant::UserType;
|
||||||
*ok = true;
|
|
||||||
return defaultValue( aggregate );
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// evaluate first feature, check result type
|
||||||
|
QgsFeatureRequest testRequest( request );
|
||||||
|
testRequest.setLimit( 1 );
|
||||||
|
QgsFeature f;
|
||||||
|
QgsFeatureIterator fit = mLayer->getFeatures( testRequest );
|
||||||
|
if ( !fit.nextFeature( f ) )
|
||||||
|
{
|
||||||
|
//no matching features
|
||||||
|
if ( ok )
|
||||||
|
*ok = true;
|
||||||
|
return defaultValue( aggregate );
|
||||||
|
}
|
||||||
|
|
||||||
if ( context )
|
if ( context )
|
||||||
context->setFeature( f );
|
context->setFeature( f );
|
||||||
QVariant v = expression->evaluate( context );
|
QVariant v = expression->evaluate( context );
|
||||||
resultType = v.type();
|
resultType = v.type();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
resultType = mLayer->fields().at( attrNum ).type();
|
resultType = mLayer->fields().at( attrNum ).type();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user