QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
25 #include <QJsonObject>
26 #include <nlohmann/json.hpp>
35 return QStringLiteral(
"MultiPolygon" );
46 auto result = qgis::make_unique< QgsMultiPolygon >();
48 return result.release();
64 QDomElement elemMultiPolygon = doc.createElementNS( ns, QStringLiteral(
"MultiPolygon" ) );
67 return elemMultiPolygon;
71 if ( qgsgeometry_cast<const QgsPolygon *>( geom ) )
73 QDomElement elemPolygonMember = doc.createElementNS( ns, QStringLiteral(
"polygonMember" ) );
74 elemPolygonMember.appendChild( geom->asGml2( doc,
precision, ns, axisOrder ) );
75 elemMultiPolygon.appendChild( elemPolygonMember );
79 return elemMultiPolygon;
84 QDomElement elemMultiSurface = doc.createElementNS( ns, QStringLiteral(
"MultiPolygon" ) );
87 return elemMultiSurface;
91 if ( qgsgeometry_cast<const QgsPolygon *>( geom ) )
93 QDomElement elemSurfaceMember = doc.createElementNS( ns, QStringLiteral(
"polygonMember" ) );
94 elemSurfaceMember.appendChild( geom->asGml3( doc,
precision, ns, axisOrder ) );
95 elemMultiSurface.appendChild( elemSurfaceMember );
99 return elemMultiSurface;
104 json polygons( json::array( ) );
107 if ( qgsgeometry_cast<const QgsPolygon *>( geom ) )
109 json coordinates( json::array( ) );
114 exteriorLineString->points( exteriorPts );
117 std::unique_ptr< QgsLineString > interiorLineString;
122 interiorLineString->points( interiorPts );
125 polygons.push_back( coordinates );
130 {
"type",
"MultiPolygon" },
131 {
"coordinates", polygons }
137 if ( !qgsgeometry_cast<QgsPolygon *>( g ) )
161 if ( !g || !qgsgeometry_cast< QgsPolygon * >( g ) )
191 if (
QgsLineString *lineStringBoundary = qgsgeometry_cast< QgsLineString * >( polygonBoundary ) )
193 multiLine->addGeometry( lineStringBoundary );
195 else if (
QgsMultiLineString *multiLineStringBoundary = qgsgeometry_cast< QgsMultiLineString * >( polygonBoundary ) )
197 for (
int j = 0; j < multiLineStringBoundary->numGeometries(); ++j )
199 multiLine->addGeometry( multiLineStringBoundary->geometryN( j )->clone() );
201 delete multiLineStringBoundary;
205 delete polygonBoundary;
209 if ( multiLine->numGeometries() == 0 )
213 return multiLine.release();
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
static json pointsToJson(const QgsPointSequence &points, int precision)
Returns coordinates as json object.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
QgsMultiPolygon * clone() const override
Clones the geometry by performing a deep copy.
void reserve(int size)
Attempts to allocate memory for at least size geometries.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
Multi line string geometry collection.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
QVector< QgsAbstractGeometry * > mGeometries
QgsWkbTypes::Type mWkbType
Multi surface geometry collection.
Line string geometry type, with support for z-dimension and m-values.
bool wktOmitChildType() const override
Returns whether child type names are omitted from Wkt representations of the collection.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
void clear() override
Clears the geometry, ie reset it to a null geometry.
AxisOrder
Axis order for GML generation.
bool isEmpty() const override
Returns true if the geometry is empty.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
bool fromCollectionWkt(const QString &wkt, const QVector< QgsAbstractGeometry * > &subtypes, const QString &defaultChildWkbType=QString())
Reads a collection from a WKT string.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
Multi polygon geometry collection.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QString geometryType() const override
Returns a unique string representing the geometry type.
QgsMultiPolygon * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
Abstract base class for all geometries.
json asJsonObject(int precision=17) const override
Returns a json object representation of the geometry.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
QVector< QgsPoint > QgsPointSequence
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
QgsMultiSurface * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsMultiSurface.
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.
bool isMeasure() const
Returns true if the geometry contains m values.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or 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.
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.