QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
44 return QStringLiteral(
"Polygon" );
49 auto result = qgis::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 );
139 wkbArray.resize( binarySize );
164 wkb << static_cast<quint32>( type );
176 curve->points( pts );
196 QgsLineString *lineString = qgsgeometry_cast< QgsLineString *>( ring );
197 if ( lineString && !lineString->
isClosed() )
229 QgsLineString *lineString = qgsgeometry_cast< QgsLineString *>( ring );
230 if ( lineString && !lineString->
isClosed() )
262 multiLine->
reserve( nInteriorRings + 1 );
264 for (
int i = 0; i < nInteriorRings; ++i )
275 return std::numeric_limits< double >::quiet_NaN();
278 double minimumDistance = std::numeric_limits<double>::max();
279 double minDistX = 0.0;
280 double minDistY = 0.0;
283 for (
int ringIndex = 0; ringIndex < numRings; ++ringIndex )
288 for (
int i = 0, j = len - 1; i < len; j = i++ )
290 double aX = ring->
xAt( i );
291 double aY = ring->
yAt( i );
292 double bX = ring->
xAt( j );
293 double bY = ring->
yAt( j );
295 if ( ( ( aY > y ) != ( bY > y ) ) &&
296 ( x < ( bX - aX ) * ( y - aY ) / ( bY - aY ) + aX ) )
299 minimumDistance = std::min( minimumDistance,
QgsGeometryUtils::sqrDistToLine( x, y, aX, aY, bX, bY, minDistX, minDistY, 4 * std::numeric_limits<double>::epsilon() ) );
303 return ( inside ? 1 : -1 ) * std::sqrt( minimumDistance );
316 for (
int i = 0; i < nInteriorRings; ++i )
Abstract base class for curved geometry type.
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.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
QByteArray asWkb(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const override
bool fromWkb(QgsConstWkbPtr &wkb) override
Sets the geometry from a WKB string.
void reserve(int size)
Attempts to allocate memory for at least size geometries.
QgsPolygon * clone() const override
Clones the geometry by performing a deep copy.
int numPoints() const override
Returns the number of points in the curve.
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.
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.
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
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.
static double sqrDistToLine(double ptX, double ptY, double x1, double y1, double x2, double y2, double &minDistX, double &minDistY, double epsilon)
Returns the squared distance between a point and a line.
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...
virtual bool isClosed() const
Returns true if the curve is closed.
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
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.
QString geometryType() const override
Returns a unique string representing the geometry type.
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...
static Type flatType(Type type)
Returns the flat type for a WKB type.