Skip to content

Commit d66d66e

Browse files
committedJan 25, 2021
Followup #41109: fix algorithms
Check for NULL instead of valid (because NULL is valid). The old behavior was relying on the fact that a NULL attribute was stored by OGR as an empty string instead of a NULL QVariant of the corresponding field type, the conversion of the QVariant( QString()) to a numeric field was checked (and it was failing) so everything worked (at least for non-string types).
1 parent 13ed787 commit d66d66e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎src/analysis/processing/qgsalgorithmpointslayerfromtable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ QVariantMap QgsPointsLayerFromTableAlgorithm::processAlgorithm( const QVariantMa
132132
double x = attrs.at( xFieldIndex ).toDouble( &xOk );
133133
double y = attrs.at( yFieldIndex ).toDouble( &yOk );
134134

135-
if ( xOk && yOk )
135+
if ( ! attrs.at( xFieldIndex ).isNull() && ! attrs.at( yFieldIndex ).isNull() && xOk && yOk )
136136
{
137137
QgsPoint point( x, y );
138138

139-
if ( zFieldIndex >= 0 )
139+
if ( zFieldIndex >= 0 && ! attrs.at( zFieldIndex ).isNull() )
140140
point.addZValue( attrs.at( zFieldIndex ).toDouble() );
141141

142-
if ( mFieldIndex >= 0 )
142+
if ( mFieldIndex >= 0 && ! attrs.at( mFieldIndex ).isNull() )
143143
point.addMValue( attrs.at( mFieldIndex ).toDouble() );
144144

145145
f.setGeometry( QgsGeometry( point.clone() ) );

‎src/core/qgsdatetimestatisticalsummary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ void QgsDateTimeStatisticalSummary::addValue( const QVariant &value )
6565
else if ( value.type() == QVariant::Date )
6666
{
6767
QDate date = value.toDate();
68-
testDateTime( date.isValid() ? QDateTime( date, QTime( 0, 0, 0 ) )
68+
testDateTime( ! date.isNull() ? QDateTime( date, QTime( 0, 0, 0 ) )
6969
: QDateTime() );
7070
}
7171
else if ( value.type() == QVariant::Time )
7272
{
7373
mIsTimes = true;
7474
QTime time = value.toTime();
75-
testDateTime( time.isValid() ? QDateTime( QDate::fromJulianDay( 0 ), time )
75+
testDateTime( ! time.isNull() ? QDateTime( QDate::fromJulianDay( 0 ), time )
7676
: QDateTime() );
7777
}
7878
else //not a date

0 commit comments

Comments
 (0)
Please sign in to comment.