Skip to content
Permalink
Browse files
Slight improvement to WKT -> geometry conversion
  • Loading branch information
nyalldawson committed Nov 4, 2021
1 parent 9694981 commit 2f90e286e8a851d2a58470d9526dc46991364e4b
Showing with 11 additions and 7 deletions.
  1. +11 −7 src/core/geometry/qgsgeometryutils.cpp
@@ -1368,28 +1368,32 @@ QStringList QgsGeometryUtils::wktGetChildBlocks( const QString &wkt, const QStri
{
int level = 0;
QString block;
block.reserve( wkt.size() );
QStringList blocks;
for ( int i = 0, n = wkt.length(); i < n; ++i )

const QChar *wktData = wkt.data();
const int wktLength = wkt.length();
for ( int i = 0, n = wktLength; i < n; ++i, ++wktData )
{
if ( ( wkt[i].isSpace() || wkt[i] == '\n' || wkt[i] == '\t' ) && level == 0 )
if ( ( wktData->isSpace() || *wktData == '\n' || *wktData == '\t' ) && level == 0 )
continue;

if ( wkt[i] == ',' && level == 0 )
if ( *wktData == ',' && level == 0 )
{
if ( !block.isEmpty() )
{
if ( block.startsWith( '(' ) && !defaultType.isEmpty() )
block.prepend( defaultType + ' ' );
blocks.append( block );
}
block.clear();
block.resize( 0 );
continue;
}
if ( wkt[i] == '(' )
if ( *wktData == '(' )
++level;
else if ( wkt[i] == ')' )
else if ( *wktData == ')' )
--level;
block += wkt[i];
block += *wktData;
}
if ( !block.isEmpty() )
{

0 comments on commit 2f90e28

Please sign in to comment.