Skip to content
Permalink
Browse files

Same for QgsTriangle and fix an error on the WKT parser. A WKT contai…

…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 50249b54ac23061a803be0d16480746d6e231263
Showing with 9 additions and 5 deletions.
  1. +9 −5 src/core/geometry/qgstriangle.cpp
@@ -159,7 +159,6 @@ bool QgsTriangle::fromWkb( QgsConstWkbPtr &wkbPtr )

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

clear();

QPair<QgsWkbTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
@@ -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 );
@@ -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

0 comments on commit 50249b5

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