Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix some more truncation of feature count to int
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
  • Loading branch information
rouault and nyalldawson committed Jun 15, 2021
1 parent 92fc435 commit 404b756
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/analysis/interpolation/qgstininterpolator.cpp
Expand Up @@ -92,8 +92,8 @@ void QgsTinInterpolator::initialize()
}

//get number of features if we use a progress bar
int nFeatures = 0;
int nProcessedFeatures = 0;
long long nFeatures = 0;
long long nProcessedFeatures = 0;
if ( mFeedback )
{
for ( const LayerData &layer : std::as_const( mLayerData ) )
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmexportmesh.cpp
Expand Up @@ -1292,8 +1292,8 @@ QVariantMap QgsMeshExportCrossSection::processAlgorithm( const QVariantMap &para
header << datagroup.metadata.name();
textStream << header.join( ',' ) << QStringLiteral( "\n" );

int featCount = featureSource->featureCount();
int featCounter = 0;
long long featCount = featureSource->featureCount();
long long featCounter = 0;
QgsFeatureIterator featIt = featureSource->getFeatures();
QgsFeature feat;
while ( featIt.nextFeature( feat ) )
Expand Down
Expand Up @@ -117,7 +117,7 @@ QVariantMap QgsNearestNeighbourAnalysisAlgorithm::processAlgorithm( const QVaria
feedback->setProgress( i * step );
}

int count = source->featureCount() > 0 ? source->featureCount() : 1;
long long count = source->featureCount() > 0 ? source->featureCount() : 1;
double observedDistance = sumDist / count;
double expectedDistance = 0.5 / std::sqrt( count / area );
double nnIndex = observedDistance / expectedDistance;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmtinmeshcreation.cpp
Expand Up @@ -106,7 +106,7 @@ bool QgsTinMeshCreationAlgorithm::prepareAlgorithm( const QVariantMap &parameter
continue;

const QgsCoordinateTransform transform( featureSource->sourceCrs(), destinationCrs, context.transformContext() );
int featureCount = featureSource->featureCount();
long long featureCount = featureSource->featureCount();
switch ( type )
{
case QgsProcessingParameterTinInputLayers::Vertices:
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmtinmeshcreation.h
Expand Up @@ -51,7 +51,7 @@ class QgsTinMeshCreationAlgorithm: public QgsProcessingAlgorithm
QgsFeatureIterator fit;
QgsCoordinateTransform transform;
int attributeIndex;
int featureCount;
long long featureCount;
};

QList<Layer> mVerticesLayer;
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/vector/qgsgeometrysnappersinglesource.cpp
Expand Up @@ -49,7 +49,7 @@ struct AnchorAlongSegment
};


static void buildSnapIndex( QgsFeatureIterator &fi, QgsSpatialIndex &index, QVector<AnchorPoint> &pnts, QgsFeedback *feedback, int &count, int totalCount )
static void buildSnapIndex( QgsFeatureIterator &fi, QgsSpatialIndex &index, QVector<AnchorPoint> &pnts, QgsFeedback *feedback, long long &count, long long totalCount )
{
QgsFeature f;
int pntId = 0;
Expand Down Expand Up @@ -305,8 +305,8 @@ int QgsGeometrySnapperSingleSource::run( const QgsFeatureSource &source, QgsFeat
{
// the logic here comes from GRASS implementation of Vect_snap_lines_list()

int count = 0;
int totalCount = source.featureCount() * 2;
long long count = 0;
long long totalCount = source.featureCount() * 2;

// step 1: record all point locations in a spatial index + extra data structure to keep
// reference to which other point they have been snapped to (in the next phase).
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgssnappingutils.cpp
Expand Up @@ -496,7 +496,7 @@ void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest> &layers
// first time the layer is used? - let's set an initial guess about indexing
if ( !mHybridMaxAreaPerLayer.contains( vl->id() ) )
{
int totalFeatureCount = vl->featureCount();
long long totalFeatureCount = vl->featureCount();
if ( totalFeatureCount < mHybridPerLayerFeatureLimit )
{
// index the whole layer
Expand Down
8 changes: 4 additions & 4 deletions src/gui/symbology/qgsrulebasedrendererwidget.cpp
Expand Up @@ -647,10 +647,10 @@ void QgsRuleBasedRendererWidget::countFeatures()
req.setSubsetOfAttributes( mRenderer->usedAttributes( renderContext ), mLayer->fields() );
QgsFeatureIterator fit = mLayer->getFeatures( req );

int nFeatures = mLayer->featureCount();
QProgressDialog p( tr( "Calculating feature count." ), tr( "Abort" ), 0, nFeatures );
long long nFeatures = mLayer->featureCount();
QProgressDialog p( tr( "Calculating feature count." ), tr( "Abort" ), 0, 100 );
p.setWindowModality( Qt::WindowModal );
int featuresCounted = 0;
long long featuresCounted = 0;

QgsFeature f;
while ( fit.nextFeature( f ) )
Expand Down Expand Up @@ -680,7 +680,7 @@ void QgsRuleBasedRendererWidget::countFeatures()
{
p.setMaximum( 0 );
}
p.setValue( featuresCounted );
p.setValue( static_cast< double >( featuresCounted ) / nFeatures * 100.0 );
if ( p.wasCanceled() )
{
return;
Expand Down

0 comments on commit 404b756

Please sign in to comment.