Skip to content

Commit

Permalink
do not zoom to feature if no extent
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and m-kuhn committed Oct 15, 2018
1 parent 579c97e commit d4ac9a7
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 deletions.
Expand Up @@ -10,7 +10,6 @@




class QgsGeometryCheck
{
%Docstring
Expand Down
2 changes: 0 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometrycheck.h
Expand Up @@ -31,8 +31,6 @@
class QgsGeometryCheckError;
class QgsFeaturePool;

#define FEATUREID_NULL std::numeric_limits<QgsFeatureId>::min()

class ANALYSIS_EXPORT QgsGeometryCheck
{
Q_GADGET
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h
Expand Up @@ -20,6 +20,7 @@

#include "qgsgeometrycheck.h"
#include "qgsgeometrycheckerror.h"
#include "qgsfeatureid.h"

class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
{
Expand All @@ -30,7 +31,7 @@ class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
const QMap<QString, QgsFeatureIds> &neighbors,
double area,
const QgsRectangle &gapAreaBBox )
: QgsGeometryCheckError( check, layerId, FEATUREID_NULL, geometry, geometry.constGet()->centroid(), QgsVertexId(), area, ValueArea )
: QgsGeometryCheckError( check, layerId, FID_NULL, geometry, geometry.constGet()->centroid(), QgsVertexId(), area, ValueArea )
, mNeighbors( neighbors )
, mGapAreaBBox( gapAreaBBox )
{
Expand Down
7 changes: 5 additions & 2 deletions src/app/qgsgeometryvalidationdock.cpp
Expand Up @@ -110,8 +110,11 @@ void QgsGeometryValidationDock::zoomToFeature()
return;

QgsRectangle featureExtent = currentIndex().data( QgsGeometryValidationModel::FeatureExtentRole ).value<QgsRectangle>();
QgsRectangle mapExtent = mLayerTransform.transform( featureExtent );
mMapCanvas->zoomToFeatureExtent( mapExtent );
if ( !featureExtent.isEmpty() )
{
QgsRectangle mapExtent = mLayerTransform.transform( featureExtent );
mMapCanvas->zoomToFeatureExtent( mapExtent );
}
}

void QgsGeometryValidationDock::triggerTopologyChecks()
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsgeometryvalidationmodel.cpp
Expand Up @@ -74,6 +74,8 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
case FeatureExtentRole:
{
const QgsFeatureId fid = topologyError->featureId();
if ( FID_IS_NULL( fid ) )
return QgsRectangle();
const QgsFeature feature = mCurrentLayer->getFeature( fid ); // TODO: this should be cached!
return feature.geometry().boundingBox();
}
Expand Down
Expand Up @@ -81,7 +81,7 @@ void QgsGeometryCheckerFixSummaryDialog::addError( QTableWidget *table, QgsGeome
table->insertRow( row );
table->setItem( row, 0, new QTableWidgetItem( !error->layerId().isEmpty() ? mChecker->featurePools()[error->layerId()]->layer()->name() : "" ) );
QTableWidgetItem *idItem = new QTableWidgetItem();
idItem->setData( Qt::EditRole, error->featureId() != FEATUREID_NULL ? QVariant( error->featureId() ) : QVariant() );
idItem->setData( Qt::EditRole, error->featureId() != FID_NULL ? QVariant( error->featureId() ) : QVariant() );
table->setItem( row, 1, idItem );
table->setItem( row, 2, new QTableWidgetItem( error->description() ) );
table->setItem( row, 3, new QTableWidgetItem( posStr ) );
Expand Down
Expand Up @@ -151,7 +151,7 @@ void QgsGeometryCheckerResultTab::addError( QgsGeometryCheckError *error )

ui.tableWidgetErrors->insertRow( row );
QTableWidgetItem *idItem = new QTableWidgetItem();
idItem->setData( Qt::EditRole, error->featureId() != FEATUREID_NULL ? QVariant( error->featureId() ) : QVariant() );
idItem->setData( Qt::EditRole, error->featureId() != FID_NULL ? QVariant( error->featureId() ) : QVariant() );
ui.tableWidgetErrors->setItem( row, 0, new QTableWidgetItem( !error->layerId().isEmpty() ? mChecker->featurePools()[error->layerId()]->layer()->name() : "" ) );
ui.tableWidgetErrors->setItem( row, 1, idItem );
ui.tableWidgetErrors->setItem( row, 2, new QTableWidgetItem( error->description() ) );
Expand Down

0 comments on commit d4ac9a7

Please sign in to comment.