Skip to content

Commit

Permalink
Add an invokable function to create QgsGeometry objects from WKT strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jun 16, 2024
1 parent 0d7eb1c commit 1322276
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/utils/geometryutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,7 @@ QgsPoint GeometryUtils::reprojectPoint( const QgsPoint &point, const QgsCoordina
point.is3D() ? point.z() : std::numeric_limits<double>::quiet_NaN(),
point.isMeasure() ? point.m() : std::numeric_limits<double>::quiet_NaN() );
}
QgsGeometry GeometryUtils::createGeometryFromWkt( const QString &wkt )
{
return QgsGeometry::fromWkt( wkt );
}
3 changes: 3 additions & 0 deletions src/core/utils/geometryutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class QFIELD_CORE_EXPORT GeometryUtils : public QObject

//! Creates a point from \a x and \a y.
static Q_INVOKABLE QgsPoint point( double x, double y ) { return QgsPoint( x, y ); }

//! Creates a geometry from a WKT string.
static Q_INVOKABLE QgsGeometry createGeometryFromWkt( const QString &wkt );
};

#endif // GEOMETRYUTILS_H

0 comments on commit 1322276

Please sign in to comment.