Class: 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).
Added in version 3.6.
Methods
Returns the area of the quadrilateral, or 0 if the quadrilateral is empty.  | 
|
Compares two   | 
|
Convenient method to determine if a   | 
|
Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty.  | 
|
Returns a list including the vertices of the quadrilateral.  | 
|
Sets the point newPoint at the index.  | 
|
Set all points Returns   | 
|
Returns the quadrilateral as a new linestring.  | 
|
Returns the quadrilateral as a new polygon.  | 
|
Returns a string representation of the quadrilateral.  | 
Static Methods
Construct a   | 
|
Construct a   | 
|
Construct a   | 
|
Construct a   | 
|
Construct a   | 
Attributes
- class qgis.core.QgsQuadrilateral[source]¶
 Bases:
object- __init__()
 Constructor for an empty quadrilateral geometry.
- __init__(p1: QgsPoint, p2: QgsPoint, p3: QgsPoint, p4: QgsPoint)
 Construct a QgsQuadrilateral from four
QgsPoint.- Parameters:
 
See also
- __init__(p1: QgsPointXY, p2: QgsPointXY, p3: QgsPointXY, p4: QgsPointXY)
 Construct a QgsQuadrilateral from four
QgsPointXY.- Parameters:
 p1 (QgsPointXY) – first point
p2 (QgsPointXY) – second point
p3 (QgsPointXY) – third point
p4 (QgsPointXY) – fourth point
See also
- __init__(a0: QgsQuadrilateral)
 - Parameters:
 a0 (QgsQuadrilateral)
- class ConstructionOption¶
 Bases:
int
- Distance = 0¶
 
- class Point¶
 Bases:
int
- Point1 = 0¶
 
- Point2 = 1¶
 
- Point3 = 2¶
 
- Point4 = 3¶
 
- Projected = 1¶
 
- area(self) float[source]¶
 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[source]¶
 Compares two
QgsQuadrilateral, allowing specification of the maximum allowable difference between points.- Parameters:
 other (QgsQuadrilateral) – the
QgsQuadrilateralto compareepsilon (float = 4*DBL_EPSILON) – the maximum difference allowed / tolerance
- Return type:
 bool
- static fromRectangle(rectangle: QgsRectangle) QgsQuadrilateral[source]¶
 Construct a
QgsQuadrilateralas a rectangle from aQgsRectangle.- Parameters:
 rectangle (QgsRectangle) – rectangle
- Return type:
 
- isValid(self) bool[source]¶
 Convenient method to determine if a
QgsQuadrilateralis valid. AQgsQuadrilateralmust be simple (not self-intersecting) and cannot have collinear points.- Return type:
 bool
- perimeter(self) float[source]¶
 Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty.
- Return type:
 float
- points(self) List[QgsPoint][source]¶
 Returns a list including the vertices of the quadrilateral.
- Return type:
 List[QgsPoint]
- static rectangleFrom3Points(p1: QgsPoint, p2: QgsPoint, p3: QgsPoint, mode: QgsQuadrilateral.ConstructionOption) QgsQuadrilateral[source]¶
 Construct a
QgsQuadrilateralas 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. M is taken from pointp1.- Parameters:
 p1 (QgsPoint) – first point
p2 (QgsPoint) – second point
p3 (QgsPoint) – third point
mode (QgsQuadrilateral.ConstructionOption) – Construction mode to construct the rectangle from 3 points
See also
ConstructionOption
- Return type:
 
- static rectangleFromCenterPoint(center: QgsPoint, point: QgsPoint) QgsQuadrilateral[source]¶
 Construct a
QgsQuadrilateralas a rectangle from center pointcenterand another pointpoint. Z and M are taken from pointp1.QgsQuadrilateralwill have the same dimension ascenterdimension.- Parameters:
 - Return type:
 
- static rectangleFromExtent(p1: QgsPoint, p2: QgsPoint) QgsQuadrilateral[source]¶
 Construct a
QgsQuadrilateralas a rectangle from an extent, defined by two opposite corner points. Z and M are taken from pointp1.QgsQuadrilateralwill have the same dimension asp1dimension.- Parameters:
 - Return type:
 
- setPoint(self, newPoint: QgsPoint, index: QgsQuadrilateral.Point) bool[source]¶
 Sets the point
newPointat theindex. ReturnsFalseif theQgsQuadrilateralis not valid.See also
Point
- Parameters:
 newPoint (QgsPoint)
index (QgsQuadrilateral.Point)
- Return type:
 bool
- setPoints(self, p1: QgsPoint, p2: QgsPoint, p3: QgsPoint, p4: QgsPoint) bool[source]¶
 Set all points Returns
Falseif theQgsQuadrilateralis 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
- static squareFromDiagonal(p1: QgsPoint, p2: QgsPoint) QgsQuadrilateral[source]¶
 Construct a
QgsQuadrilateralas a square from a diagonal. Z and M are taken from pointp1.QgsQuadrilateralwill have the same dimension asp1dimension.- Parameters:
 - Return type:
 
- toLineString(self, force2D: bool = False) QgsLineString | None[source]¶
 Returns the quadrilateral as a new linestring. Ownership is transferred to the caller.
- Parameters:
 force2D (bool = False)
- Return type:
 Optional[QgsLineString]
- toPolygon(self, force2D: bool = False) QgsPolygon | None[source]¶
 Returns the quadrilateral as a new polygon. Ownership is transferred to the caller.
- Parameters:
 force2D (bool = False)
- Return type:
 Optional[QgsPolygon]