Skip to content
Permalink
Browse files

Use switch instead of else if

  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent 29db8db commit 55d3faf7f53b2b589011099a27b038e88db6e573
Showing with 29 additions and 15 deletions.
  1. +29 −15 src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp
@@ -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;
}
}
}

0 comments on commit 55d3faf

Please sign in to comment.
You can’t perform that action at this time.