Skip to content
Permalink
Browse files

[Geometry checker] Introduce QgsGeometryCheckerUtils::polygonRings

  • Loading branch information
manisandro committed Sep 28, 2017
1 parent 7bb5583 commit e5e3fde66332cba01df5f45d9affeb51126764d0
@@ -18,10 +18,11 @@
#include "qgsgeometry.h"
#include "qgsgeometryutils.h"
#include "qgsfeaturepool.h"
#include <qmath.h>
#include "qgspolygon.h"
#include "qgsgeos.h"
#include "qgsgeometrycollection.h"
#include "qgssurface.h"
#include <qmath.h>

namespace QgsGeometryCheckerUtils
{
@@ -196,6 +197,23 @@ namespace QgsGeometryCheckerUtils
return geom;
}

QList<const QgsLineString *> polygonRings( const QgsPolygonV2 *polygon )
{
QList<const QgsLineString *> rings;
if ( const QgsLineString *exterior = dynamic_cast<const QgsLineString *>( polygon->exteriorRing() ) )
{
rings.append( exterior );
}
for ( int iInt = 0, nInt = polygon->numInteriorRings(); iInt < nInt; ++iInt )
{
if ( const QgsLineString *interior = dynamic_cast<const QgsLineString *>( polygon->interiorRing( iInt ) ) )
{
rings.append( interior );
}
}
return rings;
}

void filter1DTypes( QgsAbstractGeometry *geom )
{
if ( dynamic_cast<QgsGeometryCollection *>( geom ) )
@@ -102,6 +102,8 @@ namespace QgsGeometryCheckerUtils
QgsAbstractGeometry *getGeomPart( QgsAbstractGeometry *geom, int partIdx );
const QgsAbstractGeometry *getGeomPart( const QgsAbstractGeometry *geom, int partIdx );

QList<const QgsLineString *> polygonRings( const QgsPolygonV2 *polygon );

void filter1DTypes( QgsAbstractGeometry *geom );

/**
@@ -57,19 +57,7 @@ void QgsGeometryLineLayerIntersectionCheck::collectErrors( QList<QgsGeometryChec
}
else if ( const QgsPolygonV2 *polygon = dynamic_cast<const QgsPolygonV2 *>( part ) )
{
QList<const QgsLineString *> rings;
if ( const QgsLineString *exterior = dynamic_cast<const QgsLineString *>( polygon->exteriorRing() ) )
{
rings.append( exterior );
}
for ( int iInt = 0, nInt = polygon->numInteriorRings(); iInt < nInt; ++iInt )
{
if ( const QgsLineString *interior = dynamic_cast<const QgsLineString *>( polygon->interiorRing( iInt ) ) )
{
rings.append( interior );
}
}
for ( const QgsLineString *ring : rings )
for ( const QgsLineString *ring : QgsGeometryCheckerUtils::polygonRings( polygon ) )
{
if ( QgsGeometryCheckerUtils::linesIntersect( ring, testLine, mContext->tolerance, inter ) )
{

0 comments on commit e5e3fde

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