QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
37 double z = std::numeric_limits< double >::quiet_NaN();
38 double m = std::numeric_limits< double >::quiet_NaN();
50 if ( p2.
is3D() && std::isnan( z ) )
52 if ( p3.
is3D() && std::isnan( z ) )
54 if ( !std::isnan( z ) )
65 const QgsPoint point1( pType, p1.
x(), p1.
y(), std::isnan( p1.
z() ) ? z : p1.
z() );
66 const QgsPoint point2( pType, p2.
x(), p2.
y(), std::isnan( p2.
z() ) ? z : p2.
z() );
67 const QgsPoint point3( pType, p3.
x(), p3.
y(), std::isnan( p3.
z() ) ? z : p3.
z() );
70 double inclination = 90.0;
77 if ( point2.
is3D() && point3.
is3D() )
84 distance = point2.
distance( point3 );
92 QgsVector3D( point2.
x(), point2.
y(), std::isnan( point2.
z() ) ? z : point2.
z() ),
93 QgsVector3D( point3.
x(), point3.
y(), std::isnan( point3.
z() ) ? z : point3.
z() ) );
94 const QgsPoint pV3( pType, v3.
x(), v3.
y(), v3.
z() );
121 if ( !std::isnan( m ) )
140 const double z = p1.
z();
141 const double m = p1.
m();
143 double xMin = 0, xMax = 0, yMin = 0, yMax = 0;
145 if ( p1.
x() < p2.
x() )
157 if ( p1.
y() < p2.
y() )
183 const double z = p1.
z();
184 const double m = p1.
m();
189 const double azimuth = p1.
azimuth( point3 ) + 90.0;
190 const double distance = p1.
distance( point3 ) / 2.0;
193 point2 = midPoint.
project( -distance, azimuth );
194 point4 = midPoint.
project( distance, azimuth );
201 quad.
setPoints( p1, point2, point3, point4 );
210 const double xOffset = std::fabs( point.
x() - center.
x() );
211 const double yOffset = std::fabs( point.
y() - center.
y() );
214 QgsPoint( center.
wkbType(), center.
x() - xOffset, center.
y() + yOffset, center.
z(), center.
m() ),
215 QgsPoint( center.
wkbType(), center.
x() + xOffset, center.
y() + yOffset, center.
z(), center.
m() ),
216 QgsPoint( center.
wkbType(), center.
x() + xOffset, center.
y() - yOffset, center.
z(), center.
m() ) );
233 static bool equalPoint(
const QgsPoint &p1,
const QgsPoint &p2,
double epsilon )
239 equal &=
qgsDoubleNear( p1.
z(), p2.
z(), epsilon ) || ( std::isnan( p1.
z() ) && std::isnan( p2.
z() ) );
241 equal &=
qgsDoubleNear( p1.
m(), p2.
m(), epsilon ) || ( std::isnan( p1.
m() ) && std::isnan( p2.
m() ) );
256 return ( ( equalPoint( mPoint1, other.mPoint1, epsilon ) ) &&
257 ( equalPoint( mPoint2, other.mPoint2, epsilon ) ) &&
258 ( equalPoint( mPoint3, other.mPoint3, epsilon ) ) &&
259 ( equalPoint( mPoint4, other.mPoint4, epsilon ) ) );
288 return !( isIntersection1234 || isIntersection2341 );
293 const bool isCollinear =
307 const bool doublePoints =
309 ( p1 == p2 ) || ( p1 == p3 ) || ( p1 == p4 ) || ( p2 == p3 ) || ( p2 == p4 ) || ( p3 == p4 ) );
311 return !doublePoints;
323 haveSameType( p1, p2, p3, p4 ) &&
324 notHaveDoublePoints( p1, p2, p3, p4 ) &&
325 isNotAntiParallelogram( p1, p2, p3, p4 ) &&
326 isNotCollinear( p1, p2, p3, p4 )
332 return validate( mPoint1, mPoint2, mPoint3, mPoint4 );
340 if ( validate( newPoint, mPoint2, mPoint3, mPoint4 ) ==
false )
345 if ( validate( mPoint1, newPoint, mPoint3, mPoint4 ) ==
false )
350 if ( validate( mPoint1, mPoint2, newPoint, mPoint4 ) ==
false )
355 if ( validate( mPoint1, mPoint2, mPoint3, newPoint ) ==
false )
366 if ( validate( p1, p2, p3, p4 ) ==
false )
381 pts << mPoint1 << mPoint2 << mPoint3 << mPoint4 << mPoint1;
388 std::unique_ptr<QgsPolygon> polygon = std::make_unique< QgsPolygon >();
391 return polygon.release();
396 return polygon.release();
401 std::unique_ptr<QgsLineString> ext = std::make_unique< QgsLineString>();
404 return ext.release();
410 ext->setPoints( pts );
418 return ext.release();
425 rep = QStringLiteral(
"Empty" );
427 rep = QStringLiteral(
"Quadrilateral (Point 1: %1, Point 2: %2, Point 3: %3, Point 4: %4)" )
428 .arg( mPoint1.
asWkt( pointPrecision ), 0,
's' )
429 .arg( mPoint2.
asWkt( pointPrecision ), 0,
's' )
430 .arg( mPoint3.
asWkt( pointPrecision ), 0,
's' )
431 .arg( mPoint4.
asWkt( pointPrecision ), 0,
's' );
bool isValid() const SIP_HOLDGIL
Convenient method to determine if a QgsQuadrilateral is valid.
Point
Simple enumeration to ensure indices in setPoint.
static int segmentSide(const QgsPoint &pt1, const QgsPoint &pt3, const QgsPoint &pt2) SIP_HOLDGIL
For line defined by points pt1 and pt3, find out on which side of the line is point pt3.
double distance(double x, double y) const SIP_HOLDGIL
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
Quadrilateral geometry type.
Point geometry type, with support for z-dimension and m-values.
QString asWkt(int precision=17) const override
Returns a WKT representation of the geometry.
double y() const
Returns Y coordinate.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
ConstructionOption
A quadrilateral can be constructed from 3 points where the second distance can be determined by the t...
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
static Type addZ(Type type) SIP_HOLDGIL
Adds the z dimension to a WKB type and returns the new type.
QString toString(int pointPrecision=17) const
Returns a string representation of the quadrilateral.
@ Projected
Second distance is equal to the distance of the perpendicular projection of the 3rd point on the segm...
Type
The WKB type describes the number of dimensions a geometry has.
QgsPointSequence points() const
Returns a list including the vertices of the quadrilateral.
bool setPoint(const QgsPoint &newPoint, Point index) SIP_HOLDGIL
Sets the point newPoint at the index.
static int leftOfLine(const double x, const double y, const double x1, const double y1, const double x2, const double y2) SIP_HOLDGIL
Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> (x2, y2).
Line string geometry type, with support for z-dimension and m-values.
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 poi...
QgsLineString * toLineString(bool force2D=false) const
Returns the quadrilateral as a new linestring.
A rectangle specified with double values.
QgsPoint project(double distance, double azimuth, double inclination=90.0) const SIP_HOLDGIL
Returns a new point which corresponds to this point projected by a specified distance with specified ...
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:
@ Distance
Second distance is equal to the distance between 2nd and 3rd point.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
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.
static QgsQuadrilateral squareFromDiagonal(const QgsPoint &p1, const QgsPoint &p2) SIP_HOLDGIL
Construct a QgsQuadrilateral as a square from a diagonal.
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.
bool operator!=(const QgsQuadrilateral &other) const SIP_HOLDGIL
bool addMValue(double mValue=0) override
Adds a measure to the geometry, initialized to a preset value.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
double z() const
Returns Z coordinate.
static QgsVector3D perpendicularPoint(const QgsVector3D &v1, const QgsVector3D &v2, const QgsVector3D &vp)
Returns the perpendicular point of vector vp from [v1 - v2].
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
double azimuth(const QgsPoint &other) const SIP_HOLDGIL
Calculates Cartesian azimuth between this point and other one (clockwise in degree,...
double area() const override SIP_HOLDGIL
Returns the planar, 2-dimensional area of the geometry.
bool dropZValue() override
Drops any z-dimensions which exist in the geometry.
double perimeter() const SIP_HOLDGIL
Returns the perimeter of the quadrilateral, or 0 if the quadrilateral is empty.
QgsQuadrilateral() SIP_HOLDGIL
Constructor for an empty quadrilateral geometry.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double perimeter() const override SIP_HOLDGIL
Returns the planar, 2-dimensional perimeter of the geometry.
static bool segmentIntersection(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance=1e-8, bool acceptImproperIntersection=false) SIP_HOLDGIL
Compute the intersection between two segments.
static QgsQuadrilateral fromRectangle(const QgsRectangle &rectangle) SIP_HOLDGIL
Construct a QgsQuadrilateral as a rectangle from a QgsRectangle.
double inclination(const QgsPoint &other) const SIP_HOLDGIL
Calculates Cartesian inclination between this point and other one (starting from zenith = 0 to nadir ...
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
A class to represent a 2D point.
static QgsPoint midpoint(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Returns a middle point between points pt1 and pt2.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
QVector< QgsPoint > QgsPointSequence
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.
double area() const SIP_HOLDGIL
Returns the area of the quadrilateral, or 0 if the quadrilateral is empty.
bool operator==(const QgsQuadrilateral &other) const SIP_HOLDGIL
double x() const
Returns X coordinate.
double distance3D(double x, double y, double z) const SIP_HOLDGIL
Returns the Cartesian 3D distance between this point and a specified x, y, z coordinate.
QgsPolygon * toPolygon(bool force2D=false) const
Returns the quadrilateral as a new polygon.