Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and nyalldawson committed Nov 25, 2019
1 parent 8255932 commit 3e63d65
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/analysis/raster/qgskde.cpp
Expand Up @@ -94,11 +94,9 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::prepare()
return FileCreationError;
}

int dataTypeSize = QgsRasterBlock::typeSize( Qgis::Float32 );
std::vector<float> line( cols );
std::fill( line.begin(), line.end(), NO_DATA );
QgsRasterBlock block( Qgis::Float32, cols, 1 );
block.setData( QByteArray::fromRawData( ( char * )&line[0], dataTypeSize * cols ) );
block.setNoDataValue( NO_DATA );
block.setIsNoData();
for ( int i = 0; i < rows ; i++ )
{
mProvider->writeBlock( &block, 1, 0, i );
Expand Down Expand Up @@ -173,7 +171,7 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::addFeature( const
QgsRectangle extent( ( *pointIt ).x() - radius, ( *pointIt ).y() - radius, ( *pointIt ).x() + radius, ( *pointIt ).y() + radius );

// get the data
QgsRasterBlock *block = mProvider->block( 1, extent, blockSize, blockSize );
std::unique_ptr< QgsRasterBlock > block( mProvider->block( 1, extent, blockSize, blockSize ) );
QByteArray blockData = block->data();
float *dataBuffer = ( float * ) blockData.data();

Expand Down Expand Up @@ -203,12 +201,10 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::addFeature( const
}

block->setData( blockData );
if ( !mProvider->writeBlock( block, 1, xPosition, yPositionIO ) )
if ( !mProvider->writeBlock( block.get(), 1, xPosition, yPositionIO ) )
{
result = RasterIoError;
}

delete block;
}

return result;
Expand Down

0 comments on commit 3e63d65

Please sign in to comment.