Skip to content
Permalink
Browse files

[Geometry checker] Make polyLineSize survive empty geometries

(cherry-picked from 34bd124)
  • Loading branch information
manisandro authored and nyalldawson committed Mar 15, 2016
1 parent 342a754 commit 0bde7852992dffbe584b015b7d53ae5c8fca808e
Showing with 16 additions and 7 deletions.
  1. +16 −7 src/plugins/geometry_checker/utils/qgsgeomutils.h
@@ -39,13 +39,22 @@ namespace QgsGeomUtils
*/
inline int polyLineSize( const QgsAbstractGeometryV2* geom, int iPart, int iRing, bool* isClosed = nullptr )
{
int nVerts = geom->vertexCount( iPart, iRing );
QgsPointV2 front = geom->vertexAt( QgsVertexId( iPart, iRing, 0 ) );
QgsPointV2 back = geom->vertexAt( QgsVertexId( iPart, iRing, nVerts - 1 ) );
bool closed = back == front;
if ( isClosed )
*isClosed = closed;
return closed ? nVerts - 1 : nVerts;
if ( !geom->isEmpty() )
{
int nVerts = geom->vertexCount( iPart, iRing );
QgsPointV2 front = geom->vertexAt( QgsVertexId( iPart, iRing, 0 ) );
QgsPointV2 back = geom->vertexAt( QgsVertexId( iPart, iRing, nVerts - 1 ) );
bool closed = back == front;
if ( isClosed )
*isClosed = closed;
return closed ? nVerts - 1 : nVerts;
}
else
{
if ( isClosed )
*isClosed = true;
return 0;
}
}

double sharedEdgeLength( const QgsAbstractGeometryV2* geom1, const QgsAbstractGeometryV2* geom2, double tol );

0 comments on commit 0bde785

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