Skip to content

Commit

Permalink
Same for QgsTriangle and fix an error on the WKT parser. A WKT contai…
Browse files Browse the repository at this point in the history
…ning 3 or 4 coordinates (if the start and end points match) will be allowed
  • Loading branch information
lbartoletti committed Aug 24, 2020
1 parent d349fc4 commit 50249b5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/geometry/qgstriangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ bool QgsTriangle::fromWkb( QgsConstWkbPtr &wkbPtr )

bool QgsTriangle::fromWkt( const QString &wkt )
{

clear();

QPair<QgsWkbTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
Expand All @@ -169,12 +168,12 @@ bool QgsTriangle::fromWkt( const QString &wkt )

mWkbType = parts.first;

if ( parts.second.compare( QLatin1String( "EMPTY" ), Qt::CaseInsensitive ) == 0 )
QString secondWithoutParentheses = parts.second;
secondWithoutParentheses = secondWithoutParentheses.simplified().remove( ' ' );
if ( ( parts.second.compare( QLatin1String( "EMPTY" ), Qt::CaseInsensitive ) == 0 ) ||
secondWithoutParentheses.isEmpty() )
return true;

if ( parts.second.compare( QLatin1String( "NULL" ), Qt::CaseInsensitive ) == 0 )
return false;

QString defaultChildWkbType = QStringLiteral( "LineString%1%2" ).arg( is3D() ? QStringLiteral( "Z" ) : QString(), isMeasure() ? QStringLiteral( "M" ) : QString() );

const QStringList blocks = QgsGeometryUtils::wktGetChildBlocks( parts.second, defaultChildWkbType );
Expand Down Expand Up @@ -203,6 +202,11 @@ bool QgsTriangle::fromWkt( const QString &wkt )
return false;
}
mExteriorRing.reset( mInteriorRings.takeFirst() );
if ( ( mExteriorRing->numPoints() < 3 ) || ( mExteriorRing->numPoints() > 4 ) || ( mExteriorRing->numPoints() == 4 && mExteriorRing->startPoint() != mExteriorRing->endPoint() ) )
{
clear();
return false;
}

//scan through rings and check if dimensionality of rings is different to CurvePolygon.
//if so, update the type dimensionality of the CurvePolygon to match
Expand Down

0 comments on commit 50249b5

Please sign in to comment.