|
QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
|
Quadrilateral geometry type. More...
#include <qgsquadrilateral.h>
Public Types | |
| enum | ConstructionOption { Distance , Projected } |
| A quadrilateral can be constructed from 3 points where the second distance can be determined by the third point. More... | |
| enum | Point { Point1 , Point2 , Point3 , Point4 } |
| Simple enumeration to ensure indices in setPoint. More... | |
Public Member Functions | |
| QgsQuadrilateral () | |
| Constructor for an empty quadrilateral geometry. | |
| QgsQuadrilateral (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, const QgsPoint &p4) | |
| Construct a QgsQuadrilateral from four QgsPoint. | |
| QgsQuadrilateral (const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3, const QgsPointXY &p4) | |
| Construct a QgsQuadrilateral from four QgsPointXY. | |
| double | area () const |
| Returns the area of the quadrilateral, or 0 if the quadrilateral is empty. | |
| bool | equals (const QgsQuadrilateral &other, double epsilon=4 *std::numeric_limits< double >::epsilon()) const |
| Compares two QgsQuadrilateral, allowing specification of the maximum allowable difference between points. | |
| bool | isValid () const |
| Convenient method to determine if a QgsQuadrilateral is valid. | |
| bool | operator!= (const QgsQuadrilateral &other) const |
| bool | operator== (const QgsQuadrilateral &other) const |
| double | perimeter () const |
| Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty. | |
| QgsPointSequence | points () const |
| Returns a list including the vertices of the quadrilateral. | |
| bool | setPoint (const QgsPoint &newPoint, Point index) |
| Sets the point newPoint at the index. | |
| bool | setPoints (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, const QgsPoint &p4) |
Set all points Returns false if the QgsQuadrilateral is not valid: | |
| QgsLineString * | toLineString (bool force2D=false) const |
| Returns the quadrilateral as a new linestring. | |
| QgsPolygon * | toPolygon (bool force2D=false) const |
| Returns the quadrilateral as a new polygon. | |
| QString | toString (int pointPrecision=17) const |
| Returns a string representation of the quadrilateral. | |
Static Public Member Functions | |
| static QgsQuadrilateral | fromRectangle (const QgsRectangle &rectangle) |
| Construct a QgsQuadrilateral as a rectangle from a QgsRectangle. | |
| static QgsQuadrilateral | rectangleFrom3Points (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, ConstructionOption mode) |
| Construct a QgsQuadrilateral as a Rectangle from 3 points. | |
| static QgsQuadrilateral | rectangleFromCenterPoint (const QgsPoint ¢er, const QgsPoint &point) |
| Construct a QgsQuadrilateral as a rectangle from center point center and another point point. | |
| static QgsQuadrilateral | rectangleFromExtent (const QgsPoint &p1, const QgsPoint &p2) |
| Construct a QgsQuadrilateral as a rectangle from an extent, defined by two opposite corner points. | |
| static QgsQuadrilateral | squareFromDiagonal (const QgsPoint &p1, const QgsPoint &p2) |
| Construct a QgsQuadrilateral as a square from a diagonal. | |
Static Public Attributes | |
| static constexpr auto & | rectangleFromDiagonal = rectangleFromExtent |
| Alias for rectangleFromDiagonal. | |
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).
Definition at line 36 of file qgsquadrilateral.h.
A quadrilateral can be constructed from 3 points where the second distance can be determined by the third point.
Definition at line 70 of file qgsquadrilateral.h.
Simple enumeration to ensure indices in setPoint.
| Enumerator | |
|---|---|
| Point1 | |
| Point2 | |
| Point3 | |
| Point4 | |
Definition at line 157 of file qgsquadrilateral.h.
|
default |
Constructor for an empty quadrilateral geometry.
| QgsQuadrilateral::QgsQuadrilateral | ( | const QgsPoint & | p1, |
| const QgsPoint & | p2, | ||
| const QgsPoint & | p3, | ||
| const QgsPoint & | p4 | ||
| ) |
Construct a QgsQuadrilateral from four QgsPoint.
| p1 | first point |
| p2 | second point |
| p3 | third point |
| p4 | fourth point |
Definition at line 23 of file qgsquadrilateral.cpp.
|
explicit |
Construct a QgsQuadrilateral from four QgsPointXY.
| p1 | first point |
| p2 | second point |
| p3 | third point |
| p4 | fourth point |
Definition at line 28 of file qgsquadrilateral.cpp.
| double QgsQuadrilateral::area | ( | ) | const |
Returns the area of the quadrilateral, or 0 if the quadrilateral is empty.
Definition at line 436 of file qgsquadrilateral.cpp.
| bool QgsQuadrilateral::equals | ( | const QgsQuadrilateral & | other, |
| double | epsilon = 4 * std::numeric_limits<double>::epsilon() |
||
| ) | const |
Compares two QgsQuadrilateral, allowing specification of the maximum allowable difference between points.
| other | the QgsQuadrilateral to compare |
| epsilon | the maximum difference allowed / tolerance |
Definition at line 246 of file qgsquadrilateral.cpp.
|
static |
Construct a QgsQuadrilateral as a rectangle from a QgsRectangle.
| rectangle | rectangle |
Definition at line 219 of file qgsquadrilateral.cpp.
| bool QgsQuadrilateral::isValid | ( | ) | const |
Convenient method to determine if a QgsQuadrilateral is valid.
A QgsQuadrilateral must be simple (not self-intersecting) and cannot have collinear points.
Definition at line 330 of file qgsquadrilateral.cpp.
| bool QgsQuadrilateral::operator!= | ( | const QgsQuadrilateral & | other | ) | const |
Definition at line 267 of file qgsquadrilateral.cpp.
| bool QgsQuadrilateral::operator== | ( | const QgsQuadrilateral & | other | ) | const |
Definition at line 262 of file qgsquadrilateral.cpp.
| double QgsQuadrilateral::perimeter | ( | ) | const |
Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty.
Definition at line 442 of file qgsquadrilateral.cpp.
| QgsPointSequence QgsQuadrilateral::points | ( | ) | const |
Returns a list including the vertices of the quadrilateral.
Definition at line 377 of file qgsquadrilateral.cpp.
|
static |
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. M is taken from point p1.
| p1 | first point |
| p2 | second point |
| p3 | third point |
| mode | Construction mode to construct the rectangle from 3 points |
Definition at line 33 of file qgsquadrilateral.cpp.
|
static |
Construct a QgsQuadrilateral as a rectangle from center point center and another point point.
Z and M are taken from point p1. QgsQuadrilateral will have the same dimension as center dimension.
| center | center point |
| point | corner point |
Definition at line 206 of file qgsquadrilateral.cpp.
|
static |
Construct a QgsQuadrilateral as a rectangle from an extent, defined by two opposite corner points.
Z and M are taken from point p1. QgsQuadrilateral will have the same dimension as p1 dimension.
| p1 | first point |
| p2 | second point |
Definition at line 134 of file qgsquadrilateral.cpp.
Sets the point newPoint at the index.
Returns false if the QgsQuadrilateral is not valid.
Definition at line 335 of file qgsquadrilateral.cpp.
| bool QgsQuadrilateral::setPoints | ( | const QgsPoint & | p1, |
| const QgsPoint & | p2, | ||
| const QgsPoint & | p3, | ||
| const QgsPoint & | p4 | ||
| ) |
Set all points Returns false if the QgsQuadrilateral is not valid:
Definition at line 364 of file qgsquadrilateral.cpp.
|
static |
Construct a QgsQuadrilateral as a square from a diagonal.
Z and M are taken from point p1. QgsQuadrilateral will have the same dimension as p1 dimension.
| p1 | first point |
| p2 | second point |
Definition at line 177 of file qgsquadrilateral.cpp.
| QgsLineString * QgsQuadrilateral::toLineString | ( | bool | force2D = false | ) | const |
Returns the quadrilateral as a new linestring.
Ownership is transferred to the caller.
Definition at line 399 of file qgsquadrilateral.cpp.
| QgsPolygon * QgsQuadrilateral::toPolygon | ( | bool | force2D = false | ) | const |
Returns the quadrilateral as a new polygon.
Ownership is transferred to the caller.
Definition at line 386 of file qgsquadrilateral.cpp.
| QString QgsQuadrilateral::toString | ( | int | pointPrecision = 17 | ) | const |
Returns a string representation of the quadrilateral.
Members will be truncated to the specified precision.
Definition at line 421 of file qgsquadrilateral.cpp.
|
staticconstexpr |
Alias for rectangleFromDiagonal.
Definition at line 107 of file qgsquadrilateral.h.