Skip to content

Commit

Permalink
Use switch instead of else if
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent 29db8db commit 55d3faf
Showing 1 changed file with 29 additions and 15 deletions.
Expand Up @@ -72,28 +72,42 @@ void QgsGeometryMissingVertexCheck::fixError( const QMap<QString, QgsFeaturePool
{
Q_UNUSED( featurePools )
Q_UNUSED( changes )
if ( method == NoChange )

QMetaEnum metaEnum = QMetaEnum::fromType<QgsGeometryMissingVertexCheck::ResolutionMethod>();
if ( !metaEnum.isValid() || !metaEnum.valueToKey( method ) )
{
error->setFixed( method );
error->setFixFailed( tr( "Unknown method" ) );
}
if ( method == AddMissingVertex )
else
{
QgsFeaturePool *featurePool = featurePools[ error->layerId() ];
ResolutionMethod methodValue = static_cast<ResolutionMethod>( method );
switch ( methodValue )
{
case NoChange:
error->setFixed( method );
break;

case AddMissingVertex:
{
QgsFeaturePool *featurePool = featurePools[ error->layerId() ];

QgsFeature feature;
featurePool->getFeature( error->featureId(), feature );
QgsFeature feature;
featurePool->getFeature( error->featureId(), feature );

QgsPointXY pointOnSegment; // Should be equal to location
int vertexIndex;
QgsGeometry geometry = feature.geometry();
geometry.closestSegmentWithContext( error->location(), pointOnSegment, vertexIndex );
geometry.insertVertex( QgsPoint( error->location() ), vertexIndex );
feature.setGeometry( geometry );
QgsPointXY pointOnSegment; // Should be equal to location
int vertexIndex;
QgsGeometry geometry = feature.geometry();
geometry.closestSegmentWithContext( error->location(), pointOnSegment, vertexIndex );
geometry.insertVertex( QgsPoint( error->location() ), vertexIndex );
feature.setGeometry( geometry );

featurePool->updateFeature( feature );
// TODO update "changes" structure
featurePool->updateFeature( feature );
// TODO update "changes" structure

error->setFixed( method );
error->setFixed( method );
}
break;
}
}
}

Expand Down

0 comments on commit 55d3faf

Please sign in to comment.