Skip to content
Permalink
Browse files

Add debugging method

  • Loading branch information
nyalldawson committed Mar 14, 2021
1 parent 64b869e commit 81f8e4979c42091e3abc45455517ec3e17baeb19
Showing with 34 additions and 0 deletions.
  1. +29 −0 src/core/pal/pointset.cpp
  2. +5 −0 src/core/pal/pointset.h
@@ -1041,3 +1041,32 @@ bool PointSet::isClosed() const
{
return qgsDoubleNear( x[0], x[nbPoints - 1] ) && qgsDoubleNear( y[0], y[nbPoints - 1] );
}

QString PointSet::toWkt() const
{
if ( !mGeos )
createGeosGeom();

GEOSContextHandle_t geosctxt = QgsGeos::getGEOSHandler();

try
{
GEOSWKTWriter *writer = GEOSWKTWriter_create_r( geosctxt );

char *wkt = GEOSWKTWriter_write_r( geosctxt, writer, mGeos );
const QString res( wkt );

GEOSFree_r( geosctxt, wkt );

GEOSWKTWriter_destroy_r( geosctxt, writer );
writer = nullptr;

return res;
}
catch ( GEOSException &e )
{
qWarning( "GEOS exception: %s", e.what() );
QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) );
return QString();
}
}
@@ -200,6 +200,11 @@ namespace pal
*/
bool isClosed() const;

/**
* Returns a WKT representation of the point set.
*/
QString toWkt() const;

int nbPoints;
std::vector< double > x;
std::vector< double > y; // points order is counterclockwise

0 comments on commit 81f8e49

Please sign in to comment.