14
14
***************************************************************************/
15
15
16
16
#include " qgskde.h"
17
- #include " qgsvectorlayer.h"
17
+ #include " qgsfeaturesource.h"
18
+ #include " qgsfeatureiterator.h"
18
19
#include " qgsgeometry.h"
19
20
20
21
#define NO_DATA -9999
24
25
#endif
25
26
26
27
QgsKernelDensityEstimation::QgsKernelDensityEstimation ( const QgsKernelDensityEstimation::Parameters ¶meters, const QString &outputFile, const QString &outputFormat )
27
- : mInputLayer ( parameters.vectorLayer )
28
+ : mSource ( parameters.source )
28
29
, mOutputFile( outputFile )
29
30
, mOutputFormat( outputFormat )
30
31
, mRadiusField( -1 )
@@ -39,9 +40,9 @@ QgsKernelDensityEstimation::QgsKernelDensityEstimation( const QgsKernelDensityEs
39
40
, mRasterBandH( nullptr )
40
41
{
41
42
if ( !parameters.radiusField .isEmpty () )
42
- mRadiusField = mInputLayer ->fields ().lookupField ( parameters.radiusField );
43
+ mRadiusField = mSource ->fields ().lookupField ( parameters.radiusField );
43
44
if ( !parameters.weightField .isEmpty () )
44
- mWeightField = mInputLayer ->fields ().lookupField ( parameters.weightField );
45
+ mWeightField = mSource ->fields ().lookupField ( parameters.weightField );
45
46
}
46
47
47
48
QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::run ()
@@ -58,7 +59,7 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::run()
58
59
if ( mWeightField >= 0 )
59
60
requiredAttributes << mWeightField ;
60
61
61
- QgsFeatureIterator fit = mInputLayer ->getFeatures ( QgsFeatureRequest ().setSubsetOfAttributes ( requiredAttributes ) );
62
+ QgsFeatureIterator fit = mSource ->getFeatures ( QgsFeatureRequest ().setSubsetOfAttributes ( requiredAttributes ) );
62
63
63
64
QgsFeature f;
64
65
while ( fit.nextFeature ( f ) )
@@ -79,7 +80,7 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::prepare()
79
80
return DriverError;
80
81
}
81
82
82
- if ( !mInputLayer )
83
+ if ( !mSource )
83
84
return InvalidParameters;
84
85
85
86
mBounds = calculateBounds ();
@@ -235,7 +236,7 @@ bool QgsKernelDensityEstimation::createEmptyLayer( GDALDriverH driver, const Qgs
235
236
return false ;
236
237
237
238
// Set the projection on the raster destination to match the input layer
238
- if ( GDALSetProjection ( emptyDataset, mInputLayer -> crs ().toWkt ().toLocal8Bit ().data () ) != CE_None )
239
+ if ( GDALSetProjection ( emptyDataset, mSource -> sourceCrs ().toWkt ().toLocal8Bit ().data () ) != CE_None )
239
240
return false ;
240
241
241
242
GDALRasterBandH poBand = GDALGetRasterBand ( emptyDataset, 1 );
@@ -399,16 +400,16 @@ double QgsKernelDensityEstimation::triangularKernel( const double distance, cons
399
400
400
401
QgsRectangle QgsKernelDensityEstimation::calculateBounds () const
401
402
{
402
- if ( !mInputLayer )
403
+ if ( !mSource )
403
404
return QgsRectangle ();
404
405
405
- QgsRectangle bbox = mInputLayer -> extent ();
406
+ QgsRectangle bbox = mSource -> sourceExtent ();
406
407
407
408
double radius = 0 ;
408
409
if ( mRadiusField >= 0 )
409
410
{
410
411
// if radius is using a field, find the max value
411
- radius = mInputLayer ->maximumValue ( mRadiusField ).toDouble ();
412
+ radius = mSource ->maximumValue ( mRadiusField ).toDouble ();
412
413
}
413
414
else
414
415
{
0 commit comments