32 return QStringLiteral(
"MultiPolygon" );
43 auto result = qgis::make_unique< QgsMultiPolygon >();
45 return result.release();
61 QDomElement elemMultiPolygon = doc.createElementNS( ns, QStringLiteral(
"MultiPolygon" ) );
64 return elemMultiPolygon;
68 if ( qgsgeometry_cast<const QgsPolygon *>( geom ) )
70 QDomElement elemPolygonMember = doc.createElementNS( ns, QStringLiteral(
"polygonMember" ) );
71 elemPolygonMember.appendChild( geom->asGml2( doc, precision, ns, axisOrder ) );
72 elemMultiPolygon.appendChild( elemPolygonMember );
76 return elemMultiPolygon;
81 QDomElement elemMultiSurface = doc.createElementNS( ns, QStringLiteral(
"MultiPolygon" ) );
84 return elemMultiSurface;
88 if ( qgsgeometry_cast<const QgsPolygon *>( geom ) )
90 QDomElement elemSurfaceMember = doc.createElementNS( ns, QStringLiteral(
"polygonMember" ) );
91 elemSurfaceMember.appendChild( geom->asGml3( doc, precision, ns, axisOrder ) );
92 elemMultiSurface.appendChild( elemSurfaceMember );
96 return elemMultiSurface;
102 QString json = QStringLiteral(
"{\"type\": \"MultiPolygon\", \"coordinates\": [" );
105 if ( qgsgeometry_cast<const QgsPolygon *>( geom ) )
113 exteriorLineString->points( exteriorPts );
116 std::unique_ptr< QgsLineString > interiorLineString;
121 interiorLineString->points( interiorPts );
124 if ( json.endsWith( QLatin1String(
", " ) ) )
129 json += QLatin1String(
"], " );
132 if ( json.endsWith( QLatin1String(
", " ) ) )
136 json += QLatin1String(
"] }" );
142 if ( !qgsgeometry_cast<QgsPolygon *>( g ) )
166 if ( !g || !qgsgeometry_cast< QgsPolygon * >( g ) )
194 if (
QgsLineString *lineStringBoundary = qgsgeometry_cast< QgsLineString * >( polygonBoundary ) )
196 multiLine->addGeometry( lineStringBoundary );
198 else if (
QgsMultiLineString *multiLineStringBoundary = qgsgeometry_cast< QgsMultiLineString * >( polygonBoundary ) )
200 for (
int j = 0; j < multiLineStringBoundary->numGeometries(); ++j )
202 multiLine->addGeometry( multiLineStringBoundary->geometryN( j )->clone() );
204 delete multiLineStringBoundary;
208 delete polygonBoundary;
212 if ( multiLine->numGeometries() == 0 )
216 return multiLine.release();
bool isMeasure() const
Returns true if the geometry contains m values.
static QString pointsToJSON(const QgsPointSequence &points, int precision)
Returns a geoJSON coordinates string.
const QgsCurve * interiorRing(int i) const
Multi line string geometry collection.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
QgsMultiPolygon * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership...
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
void clear() override
Clears the geometry, ie reset it to a null geometry.
Multi surface geometry collection.
QgsWkbTypes::Type mWkbType
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
QDomElement asGml2(QDomDocument &doc, int precision=17, const QString &ns="gml", QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const override
Returns a GML2 representation of the geometry.
QgsMultiSurface * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsMultiSurface.
bool isEmpty() const override
Returns true if the geometry is empty.
int numInteriorRings() const
QgsMultiPolygon * clone() const override
Clones the geometry by performing a deep copy.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
QString geometryType() const override
Returns a unique string representing the geometry type.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
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.
QString asJson(int precision=17) const override
Returns a GeoJSON representation of the geometry.
Abstract base class for all geometries.
bool fromCollectionWkt(const QString &wkt, const QVector< QgsAbstractGeometry *> &subtypes, const QString &defaultChildWkbType=QString())
Reads a collection from a WKT string.
AxisOrder
Axis order for GML generation.
bool wktOmitChildType() const override
Returns whether child type names are omitted from Wkt representations of the collection.
QVector< QgsPoint > QgsPointSequence
QVector< QgsAbstractGeometry *> mGeometries
Multi polygon geometry collection.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
Line string geometry type, with support for z-dimension and m-values.
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...
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
const QgsCurve * exteriorRing() const
void clear() override
Clears the geometry, ie reset it to a null geometry.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.