Skip to content

Class GeometryUtils

ClassList > GeometryUtils

Inherits the following classes: QObject

Public Types

Type Name
enum int GeometryOperationResult

Public Functions

Type Name
GeometryUtils (QObject * parent=nullptr)

Public Static Functions

Type Name
Q_INVOKABLE GeometryOperationResult addRingFromRubberband (QgsVectorLayer * layer, QgsFeatureId fid, RubberbandModel * rubberBandModel)
Adds a ring to a polygon with given fid using the ring in the rubberband model.
Q_INVOKABLE QgsRectangle boundingBox (const QgsGeometry & geometry)
Returns the bounding box of a given geometry .
Q_INVOKABLE QgsPoint centroid (const QgsGeometry & geometry)
Creates a centroid point from a given geometry .
Q_INVOKABLE QgsPoint coordinateToPoint (const QGeoCoordinate & coor)
Converts QGeoCoordinate to QgsPoint.
Q_INVOKABLE QgsGeometry createGeometryFromWkt (const QString & wkt)
Creates a geometry from a WKT string.
Q_INVOKABLE QgsRectangle createRectangleFromPoints (const QgsPoint & p1, const QgsPoint & p2)
Returns a rectangle from two points.
Q_INVOKABLE double distanceBetweenPoints (const QgsPoint & start, const QgsPoint & end)
Returns the distance between a pair of start and__end points.
Q_INVOKABLE QgsPoint emptyPoint ()
Returns an empty (i.e. null) point.
Q_INVOKABLE GeometryOperationResult eraseFromRubberband (QgsVectorLayer * layer, QgsFeatureId fid, RubberbandModel * rubberBandModel)
Reshape a polygon with given__fid using the ring in the rubberband model.
Q_INVOKABLE QgsGeometry lineFromRubberband (RubberbandModel * rubberBandModel, const QgsCoordinateReferenceSystem & crs, Qgis::WkbType wkbType=Qgis::WkbType::Unknown)
Returns a QgsGeometry with a line by using the point sequence in the rubberband model.
Q_INVOKABLE QgsPoint point (double x, double y, double z=std::numeric_limits< double >::quiet_NaN(), double m=std::numeric_limits< double >::quiet_NaN())
Creates a point from x and__y with optional__z and__values .
Q_INVOKABLE QgsGeometry polygonFromRubberband (RubberbandModel * rubberBandModel, const QgsCoordinateReferenceSystem & crs, Qgis::WkbType wkbType=Qgis::WkbType::Unknown)
Returns a QgsGeometry with a polygon by using the point sequence in the rubberband model.
Q_INVOKABLE QgsPoint reprojectPoint (const QgsPoint & point, const QgsCoordinateReferenceSystem & sourceCrs, const QgsCoordinateReferenceSystem & destinationCrs)
Returns a reprojected point from the stated__sourceCrs to a__destinationCrs .
Q_INVOKABLE QgsPoint reprojectPointToWgs84 (const QgsPoint & point, const QgsCoordinateReferenceSystem & crs)
Returns a reprojected point from the stated__crs to WGS84.
Q_INVOKABLE QgsRectangle reprojectRectangle (const QgsRectangle & rectangle, const QgsCoordinateReferenceSystem & sourceCrs, const QgsCoordinateReferenceSystem & destinationCrs)
Returns a reprojected rectangle from the stated__sourceCrs to a__destinationCrs .
Q_INVOKABLE GeometryOperationResult reshapeFromRubberband (QgsVectorLayer * layer, QgsFeatureId fid, RubberbandModel * rubberBandModel)
Reshape a polygon with given__fid using the ring in the rubberband model.
Q_INVOKABLE GeometryOperationResult splitFeatureFromRubberband (QgsVectorLayer * layer, QgsFeatureId fid, RubberbandModel * rubberBandModel)
Q_INVOKABLE QgsGeometry variableWidthBufferByMFromRubberband (RubberbandModel * rubberBandModel, const QgsCoordinateReferenceSystem & crs)
Creates a variable width buffer polygon using M values from a rubberband model.

Public Types Documentation

enum GeometryOperationResult

enum GeometryUtils::GeometryOperationResult {
    Success = 0,
    NothingHappened = 1000,
    InvalidBaseGeometry,
    InvalidInputGeometryType,
    SelectionIsEmpty,
    SelectionIsGreaterThanOne,
    GeometryEngineError,
    LayerNotEditable,
    AddPartSelectedGeometryNotFound,
    AddPartNotMultiGeometry,
    AddRingNotClosed,
    AddRingNotValid,
    AddRingCrossesExistingRings,
    AddRingNotInExistingFeature,
    SplitCannotSplitPoint
};

Public Functions Documentation

function GeometryUtils

explicit GeometryUtils::GeometryUtils (
    QObject * parent=nullptr
) 

Public Static Functions Documentation

function addRingFromRubberband

Adds a ring to a polygon with given fid using the ring in the rubberband model.

static Q_INVOKABLE GeometryOperationResult GeometryUtils::addRingFromRubberband (
    QgsVectorLayer * layer,
    QgsFeatureId fid,
    RubberbandModel * rubberBandModel
) 

function boundingBox

Returns the bounding box of a given geometry .

static inline Q_INVOKABLE QgsRectangle GeometryUtils::boundingBox (
    const QgsGeometry & geometry
) 

function centroid

Creates a centroid point from a given geometry .

static Q_INVOKABLE QgsPoint GeometryUtils::centroid (
    const QgsGeometry & geometry
) 

function coordinateToPoint

Converts QGeoCoordinate to QgsPoint.

static Q_INVOKABLE QgsPoint GeometryUtils::coordinateToPoint (
    const QGeoCoordinate & coor
) 

function createGeometryFromWkt

Creates a geometry from a WKT string.

static Q_INVOKABLE QgsGeometry GeometryUtils::createGeometryFromWkt (
    const QString & wkt
) 

function createRectangleFromPoints

Returns a rectangle from two points.

static Q_INVOKABLE QgsRectangle GeometryUtils::createRectangleFromPoints (
    const QgsPoint & p1,
    const QgsPoint & p2
) 

function distanceBetweenPoints

Returns the distance between a pair of start and__end points.

static Q_INVOKABLE double GeometryUtils::distanceBetweenPoints (
    const QgsPoint & start,
    const QgsPoint & end
) 

function emptyPoint

Returns an empty (i.e. null) point.

static inline Q_INVOKABLE QgsPoint GeometryUtils::emptyPoint () 

function eraseFromRubberband

Reshape a polygon with given__fid using the ring in the rubberband model.

static Q_INVOKABLE GeometryOperationResult GeometryUtils::eraseFromRubberband (
    QgsVectorLayer * layer,
    QgsFeatureId fid,
    RubberbandModel * rubberBandModel
) 

function lineFromRubberband

Returns a QgsGeometry with a line by using the point sequence in the rubberband model.

static Q_INVOKABLE QgsGeometry GeometryUtils::lineFromRubberband (
    RubberbandModel * rubberBandModel,
    const QgsCoordinateReferenceSystem & crs,
    Qgis::WkbType wkbType=Qgis::WkbType::Unknown
) 

function point

Creates a point from x and__y with optional__z and__values .

static inline Q_INVOKABLE QgsPoint GeometryUtils::point (
    double x,
    double y,
    double z=std::numeric_limits< double >::quiet_NaN(),
    double m=std::numeric_limits< double >::quiet_NaN()
) 

function polygonFromRubberband

Returns a QgsGeometry with a polygon by using the point sequence in the rubberband model.

static Q_INVOKABLE QgsGeometry GeometryUtils::polygonFromRubberband (
    RubberbandModel * rubberBandModel,
    const QgsCoordinateReferenceSystem & crs,
    Qgis::WkbType wkbType=Qgis::WkbType::Unknown
) 

function reprojectPoint

Returns a reprojected point from the stated__sourceCrs to a__destinationCrs .

static Q_INVOKABLE QgsPoint GeometryUtils::reprojectPoint (
    const QgsPoint & point,
    const QgsCoordinateReferenceSystem & sourceCrs,
    const QgsCoordinateReferenceSystem & destinationCrs
) 

function reprojectPointToWgs84

Returns a reprojected point from the stated__crs to WGS84.

static Q_INVOKABLE QgsPoint GeometryUtils::reprojectPointToWgs84 (
    const QgsPoint & point,
    const QgsCoordinateReferenceSystem & crs
) 

function reprojectRectangle

Returns a reprojected rectangle from the stated__sourceCrs to a__destinationCrs .

static Q_INVOKABLE QgsRectangle GeometryUtils::reprojectRectangle (
    const QgsRectangle & rectangle,
    const QgsCoordinateReferenceSystem & sourceCrs,
    const QgsCoordinateReferenceSystem & destinationCrs
) 

function reshapeFromRubberband

Reshape a polygon with given__fid using the ring in the rubberband model.

static Q_INVOKABLE GeometryOperationResult GeometryUtils::reshapeFromRubberband (
    QgsVectorLayer * layer,
    QgsFeatureId fid,
    RubberbandModel * rubberBandModel
) 

function splitFeatureFromRubberband

static Q_INVOKABLE GeometryOperationResult GeometryUtils::splitFeatureFromRubberband (
    QgsVectorLayer * layer,
    QgsFeatureId fid,
    RubberbandModel * rubberBandModel
) 

Performs a split using the line in the rubberband model.


function variableWidthBufferByMFromRubberband

Creates a variable width buffer polygon using M values from a rubberband model.

static Q_INVOKABLE QgsGeometry GeometryUtils::variableWidthBufferByMFromRubberband (
    RubberbandModel * rubberBandModel,
    const QgsCoordinateReferenceSystem & crs
) 


The documentation for this class was generated from the following file src/core/utils/geometryutils.h