Skip to content

Commit

Permalink
Remove single part shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed Nov 29, 2021
1 parent 74b594b commit e8a7a1d
Showing 1 changed file with 32 additions and 67 deletions.
99 changes: 32 additions & 67 deletions src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -6757,106 +6757,71 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
{
const QgsGeometry intersection { geometry.intersection( feat2.geometry() ) };

// overlap and inscribed circle tests must be checked both (if the valuea are != -1)
switch ( intersection.type() )
{
case QgsWkbTypes::GeometryType::PolygonGeometry:
{
// Check min overlap for intersection (if set)
if ( intersection.isMultipart() )

bool testResult { false };
for ( auto it = intersection.const_parts_begin(); ! testResult && it != intersection.const_parts_end(); ++it )
{
bool testResult { false };
for ( auto it = intersection.const_parts_begin(); ! testResult && it != intersection.const_parts_end(); ++it )
const QgsCurvePolygon *geom = qgsgeometry_cast< const QgsCurvePolygon * >( *it );
// Check min overlap for intersection (if set)
if ( minOverlap != -1 )
{
const QgsCurvePolygon *geom = qgsgeometry_cast< const QgsCurvePolygon * >( *it );
if ( minOverlap != -1 )
if ( geom->area() >= minOverlap )
{
if ( geom->area() >= minOverlap )
{
testResult = true;
}
else
{
continue;
}
testResult = true;
}

// Check min inscribed circle radius for intersection (if set)
if ( minInscribedCircleRadius != -1 )
else
{
const QgsRectangle bbox = geom->boundingBox();
const double width = bbox.width();
const double height = bbox.height();
const double size = width > height ? width : height;
const double tolerance = size / 1000.0;
testResult = QgsGeos( geom ).maximumInscribedCircle( tolerance )->length() >= minInscribedCircleRadius;
continue;
}
}

if ( ! testResult )
{
continue;
}

}
else
{
if ( minOverlap != -1 && intersection.area() < minOverlap )
{
continue;
}

// Check min inscribed circle radius for intersection (if set)
if ( minInscribedCircleRadius != -1 )
{
const QgsAbstractGeometry *geom { intersection.constGet() };
const QgsRectangle bbox = geom->boundingBox();
const double width = bbox.width();
const double height = bbox.height();
const double size = width > height ? width : height;
const double tolerance = size / 1000.0;
// qDebug() << "Inscribed circle radius" << feat2.id() << QgsGeos( geom ).maximumInscribedCircle( tolerance )->length();
if ( QgsGeos( geom ).maximumInscribedCircle( tolerance )->length() < minInscribedCircleRadius )
{
continue;
}
testResult = QgsGeos( geom ).maximumInscribedCircle( tolerance )->length() >= minInscribedCircleRadius;
}
}

if ( ! testResult )
{
continue;
}

break;
}
case QgsWkbTypes::GeometryType::LineGeometry:
{
// Check min overlap for intersection (if set)
if ( intersection.isMultipart() )
bool testResult { false };
for ( auto it = intersection.const_parts_begin(); ! testResult && it != intersection.const_parts_end(); ++it )
{
bool testResult { false };
for ( auto it = intersection.const_parts_begin(); ! testResult && it != intersection.const_parts_end(); ++it )
const QgsCurve *geom = qgsgeometry_cast< const QgsCurve * >( *it );
// Check min overlap for intersection (if set)
if ( minOverlap != -1 )
{
const QgsCurve *geom = qgsgeometry_cast< const QgsCurve * >( *it );
if ( minOverlap != -1 )
if ( geom->length() >= minOverlap )
{
if ( geom->length() >= minOverlap )
{
testResult = true;
}
else
{
continue;
}
testResult = true;
}
else
{
continue;
}
}

if ( ! testResult )
{
continue;
}

}
else

if ( ! testResult )
{
if ( minOverlap != -1 && intersection.length() < minOverlap )
{
continue;
}
continue;
}
break;
}
Expand Down

0 comments on commit e8a7a1d

Please sign in to comment.