QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
34 QVector< double > x { p1.
x(), p2.
x(), p3.
x(), p1.
x() };
35 QVector< double > y { p1.
y(), p2.
y(), p3.
y(), p1.
y() };
39 z = { p1.
z(), p2.
z(), p3.
z(), p1.
z() };
44 m = {p1.
m(), p2.
m(), p3.
m(), p1.
m() };
53 QVector< double > x { p1.
x(), p2.
x(), p3.
x(), p1.
x() };
54 QVector< double > y {p1.
y(), p2.
y(), p3.
y(), p1.
y() };
63 QVector< double > x{ p1.x(), p2.x(), p3.x(), p1.x() };
64 QVector< double > y{ p1.y(), p2.y(), p3.y(), p1.y() };
93 return QStringLiteral(
"Triangle" );
98 auto result = qgis::make_unique< QgsTriangle >();
100 return result.release();
154 line->fromWkbPoints( ringType, wkbPtr );
172 if (
parts.second.compare( QLatin1String(
"EMPTY" ), Qt::CaseInsensitive ) == 0 )
175 QString defaultChildWkbType = QStringLiteral(
"LineString%1%2" ).arg(
is3D() ? QStringLiteral(
"Z" ) : QString(),
isMeasure() ? QStringLiteral(
"M" ) : QString() );
178 for (
const QString &childWkt : blocks )
224 QDomElement elemTriangle = doc.createElementNS( ns, QStringLiteral(
"Triangle" ) );
229 QDomElement elemExterior = doc.createElementNS( ns, QStringLiteral(
"exterior" ) );
231 if ( curveElem.tagName() == QLatin1String(
"LineString" ) )
233 curveElem.setTagName( QStringLiteral(
"LinearRing" ) );
235 elemExterior.appendChild( curveElem );
236 elemTriangle.appendChild( elemExterior );
248 std::unique_ptr<QgsCurvePolygon> curvePolygon(
new QgsCurvePolygon() );
251 return curvePolygon.release();
385 double ax, ay, bx, by, cx, cy;
398 angles.append( ( a1 > M_PI_2 ? a1 - M_PI_2 : a1 ) );
399 angles.append( ( a2 > M_PI_2 ? a2 - M_PI_2 : a2 ) );
400 angles.append( ( a3 > M_PI_2 ? a3 - M_PI_2 : a3 ) );
420 QVector<double> sides =
lengths();
421 bool ab_bc =
qgsDoubleNear( sides.at( 0 ), sides.at( 1 ), lengthTolerance );
422 bool bc_ca =
qgsDoubleNear( sides.at( 1 ), sides.at( 2 ), lengthTolerance );
423 bool ca_ab =
qgsDoubleNear( sides.at( 2 ), sides.at( 0 ), lengthTolerance );
425 return ( ab_bc || bc_ca || ca_ab );
432 QVector<double> sides =
lengths();
433 bool ab_bc =
qgsDoubleNear( sides.at( 0 ), sides.at( 1 ), lengthTolerance );
434 bool bc_ca =
qgsDoubleNear( sides.at( 1 ), sides.at( 2 ), lengthTolerance );
435 bool ca_ab =
qgsDoubleNear( sides.at( 2 ), sides.at( 0 ), lengthTolerance );
437 return ( ab_bc && bc_ca && ca_ab );
444 QVector<double> a =
angles();
445 QVector<double>::iterator ita = a.begin();
446 while ( ita != a.end() )
464 QVector<QgsLineString> alt;
477 QVector<QgsLineString> med;
496 QVector<QgsLineString> bis;
505 bool intersection =
false;
538 QVector<QgsLineString> alt =
altitudes();
577 double x = ( l.at( 0 ) *
vertexAt( 2 ).
x() +
580 double y = ( l.at( 0 ) *
vertexAt( 2 ).
y() +
Abstract base class for curved geometry type.
QgsTriangle * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
bool addMValue(double mValue=0) override
Adds a measure to the geometry, initialized to a preset value.
QgsCircle circumscribedCircle() const
Circumscribed circle of the triangle.
void clearCache() const override
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
void clear() override
Clears the geometry, ie reset it to a null geometry.
virtual QgsPolygon * toPolygon(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a new polygon geometry corresponding to a segmentized approximation of the curve.
bool operator==(const QgsTriangle &other) const
QgsPoint circumscribedCenter() const
Center of the circumscribed circle of the triangle.
void setPoints(const QgsPointSequence &points)
Resets the line string to match the specified list of points.
QVector< double > angles() const
Returns the three angles of the triangle.
static QgsPoint midpoint(const QgsPoint &pt1, const QgsPoint &pt2)
Returns a middle point between points pt1 and pt2.
Point geometry type, with support for z-dimension and m-values.
Curve polygon geometry type.
QgsGeometryConstPartIterator parts() const
Returns Java-style iterator for traversal of parts of the geometry.
bool deleteVertex(QgsVertexId position) override
Inherited method not used. You cannot delete or insert a vertex directly. Returns always false.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
bool operator!=(const QgsTriangle &other) const
Type
The WKB type describes the number of dimensions a geometry has.
static void circleCenterRadius(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double &radius, double ¢erX, double ¢erY)
Returns radius and center of the circle through pt1, pt2, pt3.
QgsWkbTypes::Type mWkbType
QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const override
Returns a GML3 representation of the geometry.
Line string geometry type, with support for z-dimension and m-values.
static QgsLineString perpendicularSegment(const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2)
Create a perpendicular line segment from p to segment [s1, s2].
friend class QgsCurvePolygon
double inscribedRadius() const
Radius of the inscribed circle of the triangle.
QgsTriangle medial() const
Medial (or midpoint) triangle of a triangle ABC is the triangle with vertices at the midpoints of the...
double area() const override
Returns the planar, 2-dimensional area of the geometry.
bool isIsocele(double lengthTolerance=0.0001) const
Is the triangle isocele (two sides with the same length)?
bool fromWkb(QgsConstWkbPtr &wkbPtr) override
Sets the geometry from a WKB string.
std::unique_ptr< QgsCurve > mExteriorRing
void addInteriorRing(QgsCurve *ring) override
Inherited method not used. You cannot add an interior ring into a triangle.
QgsCurve * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
AxisOrder
Axis order for GML generation.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
QgsPoint inscribedCenter() const
Center of the inscribed circle of the triangle.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
static double angleBetweenThreePoints(double x1, double y1, double x2, double y2, double x3, double y3)
Calculates the angle between the lines AB and BC, where AB and BC described by points a,...
QgsTriangle * clone() const override
Clones the geometry by performing a deep copy.
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
bool isDegenerate()
Convenient method checking if the geometry is degenerate (have duplicate or colinear point(s)).
QVector< QgsLineString > altitudes() const
An altitude is a segment (defined by a QgsLineString) from a vertex to the opposite side (or,...
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
bool isEmpty() const override
Returns true if the geometry is empty.
bool insertVertex(QgsVertexId position, const QgsPoint &vertex) override
Inherited method not used. You cannot delete or insert a vertex directly. Returns always false.
QVector< double > lengths() const
Returns the three lengths of the triangle.
double perimeter() const override
Returns the planar, 2-dimensional perimeter of the geometry.
QVector< QgsLineString > medians() const
A median is a segment (defined by a QgsLineString) from a vertex to the midpoint of the opposite side...
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
static QStringList wktGetChildBlocks(const QString &wkt, const QString &defaultType=QString())
Parses a WKT string and returns of list of blocks contained in the WKT.
QVector< QgsLineString > bisectors(double lengthTolerance=0.0001) const
The segment (defined by a QgsLineString) returned bisect the angle of a vertex to the opposite side.
virtual QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML3 representation of the geometry.
void clear() override
Clears the geometry, ie reset it to a null geometry.
virtual bool isClosed() const
Returns true if the curve is closed.
bool isEquilateral(double lengthTolerance=0.0001) const
Is the triangle equilateral (three sides with the same length)?
bool isScalene(double lengthTolerance=0.0001) const
Is the triangle scalene (all sides have different lengths)?
double circumscribedRadius() const
Radius of the circumscribed circle of the triangle.
QgsCurvePolygon * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsCurvePolygon.
QVector< QgsPoint > QgsPointSequence
void close()
Closes the line string by appending the first point to the end of the line, if it is not already clos...
bool moveVertex(QgsVertexId vId, const QgsPoint &newPos) override
Moves a vertex within the geometry.
bool isRight(double angleTolerance=0.0001) const
Is the triangle right-angled?
Utility class for identifying a unique vertex within a geometry.
static int leftOfLine(const double x, const double y, const double x1, const double y1, const double x2, const double y2)
Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> (x2, y2).
bool isMeasure() const
Returns true if the geometry contains m values.
QVector< QgsCurve * > mInteriorRings
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)
Compute the intersection between two segments.
virtual int numPoints() const =0
Returns the number of points in the curve.
QgsWkbTypes::Type readHeader() const
readHeader
static QPair< QgsWkbTypes::Type, QString > wktReadBlock(const QString &wkt)
Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents (...
static bool setZValueFromPoints(const QgsPointSequence &points, QgsPoint &point)
A Z dimension is added to point if one of the point in the list points is in 3D.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
QgsPoint orthocenter(double lengthTolerance=0.0001) const
An orthocenter is the point of intersection of the altitudes of a triangle.
bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
static Type flatType(Type type)
Returns the flat type for a WKB type.
QgsCircle inscribedCircle() const
Inscribed circle of the triangle.
QgsPolygon * surfaceToPolygon() const override
Gets a polygon representation of this surface.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
QString geometryType() const override
Returns a unique string representing the geometry type.