Skip to content
Permalink
Browse files

[Geometry checker] Don't make line intersection test report symmetric…

… errors twice
  • Loading branch information
manisandro committed Sep 28, 2017
1 parent 07dc429 commit 7bb5583be324b3997393f117cd9e51e3edcba96d
Showing with 18 additions and 8 deletions.
  1. +18 −8 src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.cpp
@@ -19,10 +19,14 @@
void QgsGeometryLineIntersectionCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
QMap<QString, QgsFeatureIds> featureIds = ids.isEmpty() ? allLayerFeatureIds() : ids;
QgsGeometryCheckerUtils::LayerFeatures layerFeatures( mContext->featurePools, featureIds, mCompatibleGeometryTypes, progressCounter, true );
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeature : layerFeatures )
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesA( mContext->featurePools, featureIds, mCompatibleGeometryTypes, progressCounter, true );
QList<QString> layerIds = featureIds.keys();
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureA : layerFeaturesA )
{
const QgsAbstractGeometry *geom = layerFeature.geometry();
// Ensure each pair of layers only gets compared once: remove the current layer from the layerIds, but add it to the layerList for layerFeaturesB
layerIds.removeOne( layerFeatureA.layer().id() );

const QgsAbstractGeometry *geom = layerFeatureA.geometry();
for ( int iPart = 0, nParts = geom->partCount(); iPart < nParts; ++iPart )
{
const QgsLineString *line = dynamic_cast<const QgsLineString *>( QgsGeometryCheckerUtils::getGeomPart( geom, iPart ) );
@@ -33,17 +37,23 @@ void QgsGeometryLineIntersectionCheck::collectErrors( QList<QgsGeometryCheckErro
}

// Check whether the line intersects with any other lines
QgsGeometryCheckerUtils::LayerFeatures checkFeatures( mContext->featurePools, featureIds.keys(), line->boundingBox(), {QgsWkbTypes::LineGeometry} );
for ( const QgsGeometryCheckerUtils::LayerFeature &checkFeature : checkFeatures )
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( mContext->featurePools, QList<QString>() << layerFeatureA.layer().id() << layerIds, line->boundingBox(), {QgsWkbTypes::LineGeometry} );
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureB : layerFeaturesB )
{
if ( checkFeature == layerFeature )
// > : only report intersections within same layer once
if ( layerFeatureA.layer().id() == layerFeatureB.layer().id() && layerFeatureB.feature().id() > layerFeatureA.feature().id() )
{
// Skip current feature
continue;
}
const QgsAbstractGeometry *testGeom = checkFeature.geometry();

const QgsAbstractGeometry *testGeom = layerFeatureB.geometry();
for ( int jPart = 0, mParts = testGeom->partCount(); jPart < mParts; ++jPart )
{
// Skip current feature part, only report intersections within same part once
if ( layerFeatureB.feature().id() == layerFeatureA.feature().id() && iPart >= jPart )
{
continue;
}
const QgsLineString *testLine = dynamic_cast<const QgsLineString *>( QgsGeometryCheckerUtils::getGeomPart( testGeom, jPart ) );
if ( !testLine )
{

0 comments on commit 7bb5583

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