Skip to content
Permalink
Browse files

Simplify code

  • Loading branch information
nyalldawson committed Oct 15, 2020
1 parent f8222f0 commit bf319fdb38883cdd1d88a0731b0e15c0cdb006e5
Showing with 2 additions and 12 deletions.
  1. +2 −12 src/analysis/processing/qgsalgorithmsplitwithlines.cpp
@@ -102,24 +102,14 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par
if ( !sink )
throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) );

QMap< QgsFeatureId, QgsGeometry > splitGeoms;
QgsFeatureRequest request;
request.setNoAttributes();
request.setDestinationCrs( source->sourceCrs(), context.transformContext() );

QgsFeatureIterator splitLines = linesSource->getFeatures( request );
QgsFeature aSplitFeature;

QgsSpatialIndex spatialIndex( splitLines, [&]( const QgsFeature & aSplitFeature )-> bool
{
if ( feedback->isCanceled() )
{
return false;
}

splitGeoms.insert( aSplitFeature.id(), aSplitFeature.geometry() );
return true;
} );
QgsSpatialIndex spatialIndex( splitLines, feedback, QgsSpatialIndex::FlagStoreFeatureGeometries );

QgsFeature outFeat;
QgsFeatureIterator features = source->getFeatures();
@@ -160,7 +150,7 @@ QVariantMap QgsSplitWithLinesAlgorithm::processAlgorithm( const QVariantMap &par
if ( sameLayer && inFeatureA.id() == line )
continue;

QgsGeometry splitGeom = splitGeoms.value( line );
QgsGeometry splitGeom = spatialIndex.geometry( line );
if ( !engine )
{
engine.reset( QgsGeometry::createGeometryEngine( inGeom.constGet() ) );

0 comments on commit bf319fd

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