QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
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 () SIP_HOLDGIL | |
Constructor for an empty quadrilateral geometry. More... | |
QgsQuadrilateral (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, const QgsPoint &p4) SIP_HOLDGIL | |
Construct a QgsQuadrilateral from four QgsPoint. More... | |
QgsQuadrilateral (const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3, const QgsPointXY &p4) SIP_HOLDGIL | |
Construct a QgsQuadrilateral from four QgsPointXY. More... | |
double | area () const SIP_HOLDGIL |
Returns the area of the quadrilateral, or 0 if the quadrilateral is empty. More... | |
bool | equals (const QgsQuadrilateral &other, double epsilon=4 *std::numeric_limits< double >::epsilon()) const SIP_HOLDGIL |
Compares two QgsQuadrilateral, allowing specification of the maximum allowable difference between points. More... | |
bool | isValid () const SIP_HOLDGIL |
Convenient method to determine if a QgsQuadrilateral is valid. More... | |
bool | operator!= (const QgsQuadrilateral &other) const SIP_HOLDGIL |
bool | operator== (const QgsQuadrilateral &other) const SIP_HOLDGIL |
double | perimeter () const SIP_HOLDGIL |
Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty. More... | |
QgsPointSequence | points () const |
Returns a list including the vertices of the quadrilateral. More... | |
bool | setPoint (const QgsPoint &newPoint, Point index) SIP_HOLDGIL |
Sets the point newPoint at the index. More... | |
bool | setPoints (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, const QgsPoint &p4) SIP_HOLDGIL |
Set all points Returns false if the QgsQuadrilateral is not valid: More... | |
QgsLineString * | toLineString (bool force2D=false) const |
Returns the quadrilateral as a new linestring. More... | |
QgsPolygon * | toPolygon (bool force2D=false) const |
Returns the quadrilateral as a new polygon. More... | |
QString | toString (int pointPrecision=17) const |
Returns a string representation of the quadrilateral. More... | |
Static Public Member Functions | |
static QgsQuadrilateral | fromRectangle (const QgsRectangle &rectangle) SIP_HOLDGIL |
Construct a QgsQuadrilateral as a rectangle from a QgsRectangle. More... | |
static QgsQuadrilateral | rectangleFrom3Points (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, ConstructionOption mode) SIP_HOLDGIL |
Construct a QgsQuadrilateral as a Rectangle from 3 points. More... | |
static QgsQuadrilateral | rectangleFromCenterPoint (const QgsPoint ¢er, const QgsPoint &point) SIP_HOLDGIL |
Construct a QgsQuadrilateral as a rectangle from center point center and another point point. More... | |
static QgsQuadrilateral | rectangleFromExtent (const QgsPoint &p1, const QgsPoint &p2) SIP_HOLDGIL |
Construct a QgsQuadrilateral as a rectangle from an extent, defined by two opposite corner points. More... | |
static QgsQuadrilateral | squareFromDiagonal (const QgsPoint &p1, const QgsPoint &p2) SIP_HOLDGIL |
Construct a QgsQuadrilateral as a square from a diagonal. More... | |
Static Public Attributes | |
static constexpr auto & | rectangleFromDiagonal = rectangleFromExtent |
Alias for rectangleFromDiagonal. More... | |
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 35 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 69 of file qgsquadrilateral.h.
Simple enumeration to ensure indices in setPoint.
Enumerator | |
---|---|
Point1 | |
Point2 | |
Point3 | |
Point4 |
Definition at line 152 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 416 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 229 of file qgsquadrilateral.cpp.
|
static |
Construct a QgsQuadrilateral as a rectangle from a QgsRectangle.
rectangle | rectangle |
Definition at line 202 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 313 of file qgsquadrilateral.cpp.
bool QgsQuadrilateral::operator!= | ( | const QgsQuadrilateral & | other | ) | const |
Definition at line 250 of file qgsquadrilateral.cpp.
bool QgsQuadrilateral::operator== | ( | const QgsQuadrilateral & | other | ) | const |
Definition at line 245 of file qgsquadrilateral.cpp.
double QgsQuadrilateral::perimeter | ( | ) | const |
Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty.
Definition at line 421 of file qgsquadrilateral.cpp.
QgsPointSequence QgsQuadrilateral::points | ( | ) | const |
Returns a list including the vertices of the quadrilateral.
Definition at line 360 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.
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 is taken from center point.
center | center point |
point | corner point |
Definition at line 189 of file qgsquadrilateral.cpp.
|
static |
Construct a QgsQuadrilateral as a rectangle from an extent, defined by two opposite corner points.
Z is taken from point p1.
p1 | first point |
p2 | second point |
Definition at line 117 of file qgsquadrilateral.cpp.
Sets the point newPoint at the index.
Returns false
if the QgsQuadrilateral is not valid.
Definition at line 318 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 347 of file qgsquadrilateral.cpp.
|
static |
Construct a QgsQuadrilateral as a square from a diagonal.
Z is taken from point p1.
p1 | first point |
p2 | second point |
Definition at line 159 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 382 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 369 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 401 of file qgsquadrilateral.cpp.
|
staticconstexpr |
Alias for rectangleFromDiagonal.
Definition at line 104 of file qgsquadrilateral.h.