Class: QgsQuadrilateral

class qgis.core.QgsQuadrilateral

Bases: sip.wrapper

Constructor for an empty quadrilateral geometry.

QgsQuadrilateral(p1: QgsPoint, p2: QgsPoint, p3: QgsPoint, p4: QgsPoint) Construct a QgsQuadrilateral from four QgsPoint.

Parameters
  • p1 – first point

  • p2 – second point

  • p3 – third point

  • p4 – fourth point

See also

setPoints()

QgsQuadrilateral(p1: QgsPointXY, p2: QgsPointXY, p3: QgsPointXY, p4: QgsPointXY) Construct a QgsQuadrilateral from four QgsPointXY.

Parameters
  • p1 – first point

  • p2 – second point

  • p3 – third point

  • p4 – fourth point

See also

setPoints()

QgsQuadrilateral(QgsQuadrilateral)

Quadrilateral geometry type.

A quadrilateral is a polygon with four edges (or sides) and four vertices or corners. This class allows the creation of simple quadrilateral (which does not self-intersect).

New in version 3.6:

Methods

area

Returns the area of the quadrilateral, or 0 if the quadrilateral is empty.

equals

Compares two QgsQuadrilateral, allowing specification of the maximum allowable difference between points.

fromRectangle

Construct a QgsQuadrilateral as a rectangle from a QgsRectangle.

isValid

Convenient method to determine if a QgsQuadrilateral is valid.

perimeter

Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty.

points

Returns a list including the vertices of the quadrilateral.

rectangleFrom3Points

Construct a QgsQuadrilateral as a Rectangle from 3 points.

rectangleFromCenterPoint

Construct a QgsQuadrilateral as a rectangle from center point center and another point point.

rectangleFromExtent

Construct a QgsQuadrilateral as a rectangle from an extent, defined by two opposite corner points.

setPoint

Sets the point newPoint at the index.

setPoints

Set all points Returns False if the QgsQuadrilateral is not valid:

squareFromDiagonal

Construct a QgsQuadrilateral as a square from a diagonal.

toLineString

Returns the quadrilateral as a new linestring.

toPolygon

Returns the quadrilateral as a new polygon.

toString

Returns a string representation of the quadrilateral.

Attributes

Distance

Point1

Point2

Point3

Point4

Projected

class ConstructionOption

Bases: int

Distance = 0
class Point

Bases: int

Point1 = 0
Point2 = 1
Point3 = 2
Point4 = 3
Projected = 1
area(self) float

Returns the area of the quadrilateral, or 0 if the quadrilateral is empty.

Return type

float

equals(self, other: QgsQuadrilateral, epsilon: float = 4 * DBL_EPSILON) bool

Compares two QgsQuadrilateral, allowing specification of the maximum allowable difference between points.

Parameters
Return type

bool

fromRectangle(rectangle: QgsRectangle) QgsQuadrilateral

Construct a QgsQuadrilateral as a rectangle from a QgsRectangle.

Parameters

rectangle (QgsRectangle) – rectangle

Return type

QgsQuadrilateral

isValid(self) bool

Convenient method to determine if a QgsQuadrilateral is valid. A QgsQuadrilateral must be simple (not self-intersecting) and cannot have collinear points.

Return type

bool

perimeter(self) float

Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty.

Return type

float

points(self) List[QgsPoint]

Returns a list including the vertices of the quadrilateral.

Return type

List[QgsPoint]

rectangleFrom3Points(p1: QgsPoint, p2: QgsPoint, p3: QgsPoint, mode: QgsQuadrilateral.ConstructionOption) QgsQuadrilateral

Construct a QgsQuadrilateral as a Rectangle from 3 points. In the case where one of the points is of type PointZ. The other points will also be of type Z, even if they are of type Point. In addition, the z used will be the one of the first point with a Z. This ensures consistency in point types and the ability to export to a Polygon or LineString.

Parameters

See also

ConstructionOption

Return type

QgsQuadrilateral

rectangleFromCenterPoint(center: QgsPoint, point: QgsPoint) QgsQuadrilateral

Construct a QgsQuadrilateral as a rectangle from center point center and another point point. Z is taken from center point.

Parameters
Return type

QgsQuadrilateral

rectangleFromExtent(p1: QgsPoint, p2: QgsPoint) QgsQuadrilateral

Construct a QgsQuadrilateral as a rectangle from an extent, defined by two opposite corner points. Z is taken from point p1.

Parameters
Return type

QgsQuadrilateral

setPoint(self, newPoint: QgsPoint, index: QgsQuadrilateral.Point) bool

Sets the point newPoint at the index. Returns False if the QgsQuadrilateral is not valid.

See also

Point

Parameters
Return type

bool

setPoints(self, p1: QgsPoint, p2: QgsPoint, p3: QgsPoint, p4: QgsPoint) bool

Set all points Returns False if the QgsQuadrilateral is not valid:

  • The points do not have the same type

  • The quadrilateral would have auto intersections

  • The quadrilateral has double points

  • The quadrilateral has collinear points

Parameters
Return type

bool

squareFromDiagonal(p1: QgsPoint, p2: QgsPoint) QgsQuadrilateral

Construct a QgsQuadrilateral as a square from a diagonal. Z is taken from point p1.

Parameters
Return type

QgsQuadrilateral

toLineString(self, force2D: bool = False) QgsLineString

Returns the quadrilateral as a new linestring. Ownership is transferred to the caller.

Parameters

force2D (bool = False) –

Return type

QgsLineString

toPolygon(self, force2D: bool = False) QgsPolygon

Returns the quadrilateral as a new polygon. Ownership is transferred to the caller.

Parameters

force2D (bool = False) –

Return type

QgsPolygon

toString(self, pointPrecision: int = 17) str

Returns a string representation of the quadrilateral. Members will be truncated to the specified precision.

Parameters

pointPrecision (int = 17) –

Return type

str