QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
44 return QStringLiteral(
"Polygon" );
49 auto result = std::make_unique< QgsPolygon >();
51 return result.release();
102 for (
int i = 0; i < nRings; ++i )
104 std::unique_ptr< QgsLineString > line(
new QgsLineString() );
105 line->fromWkbPoints( ringType, wkbPtr );
126 int binarySize =
sizeof( char ) +
sizeof( quint32 ) +
sizeof( quint32 );
135 binarySize +=
sizeof( quint32 ) + curve->numPoints() * ( 2 + curve->is3D() + curve->isMeasure() ) *
sizeof(
double );
169 wkb << static_cast<quint32>( type );
181 curve->points( pts );
201 QgsLineString *lineString = qgsgeometry_cast< QgsLineString *>( ring );
202 if ( lineString && !lineString->
isClosed() )
234 QgsLineString *lineString = qgsgeometry_cast< QgsLineString *>( ring );
235 if ( lineString && !lineString->
isClosed() )
267 multiLine->
reserve( nInteriorRings + 1 );
269 for (
int i = 0; i < nInteriorRings; ++i )
280 return std::numeric_limits< double >::quiet_NaN();
283 double minimumDistance = std::numeric_limits<double>::max();
284 double minDistX = 0.0;
285 double minDistY = 0.0;
288 for (
int ringIndex = 0; ringIndex < numRings; ++ringIndex )
293 for (
int i = 0, j = len - 1; i < len; j = i++ )
295 double aX = ring->
xAt( i );
296 double aY = ring->
yAt( i );
297 double bX = ring->
xAt( j );
298 double bY = ring->
yAt( j );
300 if ( ( ( aY > y ) != ( bY > y ) ) &&
301 ( x < ( bX - aX ) * ( y - aY ) / ( bY - aY ) + aX ) )
304 minimumDistance = std::min( minimumDistance,
QgsGeometryUtils::sqrDistToLine( x, y, aX, aY, bX, bY, minDistX, minDistY, 4 * std::numeric_limits<double>::epsilon() ) );
308 return ( inside ? 1 : -1 ) * std::sqrt( minimumDistance );
321 for (
int i = 0; i < nInteriorRings; ++i )
Abstract base class for curved geometry type.
int wkbSize(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const override
Returns the length of the QByteArray returned by asWkb()
void clearCache() const override
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
double xAt(int index) const override
Returns the x-coordinate of the specified node in the line string.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QByteArray asWkb(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const override
bool fromWkb(QgsConstWkbPtr &wkb) override
Sets the geometry from a WKB string.
QgsPolygon * clone() const override
Clones the geometry by performing a deep copy.
void clear() override
Clears the geometry, ie reset it to a null geometry.
virtual void setExteriorRing(QgsCurve *ring)
Sets the exterior ring of the polygon.
double yAt(int index) const override
Returns the y-coordinate of the specified node in the line string.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
Curve polygon geometry type.
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
QgsCurvePolygon * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsCurvePolygon.
static double sqrDistToLine(double ptX, double ptY, double x1, double y1, double x2, double y2, double &minDistX, double &minDistY, double epsilon) SIP_HOLDGIL
Returns the squared distance between a point and a line.
Multi line string geometry collection.
Type
The WKB type describes the number of dimensions a geometry has.
QgsWkbTypes::Type mWkbType
Line string geometry type, with support for z-dimension and m-values.
friend class QgsCurvePolygon
std::unique_ptr< QgsCurve > mExteriorRing
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
static void pointsToWKB(QgsWkbPtr &wkb, const QgsPointSequence &points, bool is3D, bool isMeasure)
Returns a LinearRing { uint32 numPoints; Point points[numPoints]; }.
virtual void addInteriorRing(QgsCurve *ring)
Adds an interior ring to the geometry (takes ownership)
static endian_t endian()
Returns whether this machine uses big or little endian.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
Abstract base class for all geometries.
double pointDistanceToBoundary(double x, double y) const
Returns the distance from a point to the boundary of the polygon (either the exterior ring or any clo...
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...
QgsPolygon * surfaceToPolygon() const override
Gets a polygon representation of this surface.
@ FlagExportTrianglesAsPolygons
Triangles should be exported as polygon geometries.
virtual bool convertTo(QgsWkbTypes::Type type)
Converts the geometry to a specified type.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
QVector< QgsCurve * > mInteriorRings
bool isClosed() const override SIP_HOLDGIL
Returns true if the curve is closed.
QgsWkbTypes::Type readHeader() const
readHeader
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.
int numPoints() const override SIP_HOLDGIL
Returns the number of points in the curve.
void reserve(int size) SIP_HOLDGIL
Attempts to allocate memory for at least size geometries.
virtual QgsLineString * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve.
QgsPolygon * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
void addInteriorRing(QgsCurve *ring) override
Adds an interior ring to the geometry (takes ownership)
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
QString geometryType() const override SIP_HOLDGIL
Returns a unique string representing the geometry type.
QgsPolygon() SIP_HOLDGIL
Constructor for an empty polygon geometry.