Skip to content

Commit

Permalink
Merge pull request #453 from nyalldawson/gradfixes
Browse files Browse the repository at this point in the history
Don't treat null values as zero for graduated symbology (Fix #6096)
  • Loading branch information
NathanW2 committed Mar 4, 2013
2 parents ea0c87e + 58a7edb commit 7c0746b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
Expand Up @@ -192,7 +192,11 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForFeature( QgsFeature& feature
return NULL;
}

// find the right category
// Null values should not be categorized
if ( attrs[mAttrNum].isNull() )
return NULL;

// find the right category
QgsSymbolV2* symbol = symbolForValue( attrs[mAttrNum].toDouble() );
if ( symbol == NULL )
return NULL;
Expand Down Expand Up @@ -802,8 +806,12 @@ QgsGraduatedSymbolRendererV2* QgsGraduatedSymbolRendererV2::createRenderer(
lst.append( attrNum );

QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( lst ) );

// create list of non-null attribute values
while ( fit.nextFeature( f ) )
values.append( f.attribute( attrNum ).toDouble() );
if ( !f.attribute( attrNum ).isNull() )
values.append( f.attribute( attrNum ).toDouble() );

// calculate the breaks
if ( mode == Quantile )
{
Expand Down

0 comments on commit 7c0746b

Please sign in to comment.