QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
26 #include <QJsonObject>
27 #include <nlohmann/json.hpp>
36 return qgsgeometry_cast< QgsSurface * >(
geometryN( index ) );
41 return qgsgeometry_cast< const QgsSurface * >(
geometryN( index ) );
46 return QStringLiteral(
"MultiSurface" );
57 auto result = qgis::make_unique< QgsMultiSurface >();
59 return result.release();
76 QStringLiteral(
"Polygon" ) );
82 QDomElement elemMultiPolygon = doc.createElementNS( ns, QStringLiteral(
"MultiPolygon" ) );
85 return elemMultiPolygon;
89 if ( qgsgeometry_cast<const QgsSurface *>( geom ) )
91 std::unique_ptr< QgsPolygon > polygon(
static_cast<const QgsSurface *
>( geom )->surfaceToPolygon() );
93 QDomElement elemPolygonMember = doc.createElementNS( ns, QStringLiteral(
"polygonMember" ) );
94 elemPolygonMember.appendChild( polygon->asGml2( doc,
precision, ns, axisOrder ) );
95 elemMultiPolygon.appendChild( elemPolygonMember );
99 return elemMultiPolygon;
104 QDomElement elemMultiSurface = doc.createElementNS( ns, QStringLiteral(
"MultiSurface" ) );
107 return elemMultiSurface;
111 if ( qgsgeometry_cast<const QgsSurface *>( geom ) )
113 QDomElement elemSurfaceMember = doc.createElementNS( ns, QStringLiteral(
"surfaceMember" ) );
114 elemSurfaceMember.appendChild( geom->asGml3( doc,
precision, ns, axisOrder ) );
115 elemMultiSurface.appendChild( elemSurfaceMember );
119 return elemMultiSurface;
125 json polygons( json::array( ) );
128 if ( qgsgeometry_cast<const QgsSurface *>( geom ) )
130 json coordinates( json::array( ) );
131 std::unique_ptr< QgsPolygon >polygon(
static_cast<const QgsSurface *
>( geom )->surfaceToPolygon() );
132 std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() );
134 exteriorLineString->points( exteriorPts );
137 std::unique_ptr< QgsLineString > interiorLineString;
138 for (
int i = 0, n = polygon->numInteriorRings(); i < n; ++i )
140 interiorLineString.reset( polygon->interiorRing( i )->curveToLine() );
142 interiorLineString->points( interiorPts );
145 polygons.push_back( coordinates );
150 {
"type",
"MultiPolygon" },
151 {
"coordinates", polygons }
157 if ( !qgsgeometry_cast<QgsSurface *>( g ) )
181 if ( !g || !qgsgeometry_cast< QgsSurface * >( g ) )
192 std::unique_ptr< QgsMultiCurve > multiCurve(
new QgsMultiCurve() );
198 multiCurve->addGeometry( surface->boundary() );
201 if ( multiCurve->numGeometries() == 0 )
205 return multiCurve.release();
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual bool insertGeometry(QgsAbstractGeometry *g, int index)
Inserts a geometry before a specified index and takes ownership.
bool isEmpty() const override SIP_HOLDGIL
Returns true if the geometry is empty.
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.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
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.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
Curve polygon geometry type.
QVector< QgsAbstractGeometry * > mGeometries
QgsWkbTypes::Type mWkbType
Multi surface geometry collection.
QgsMultiSurface * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
QgsMultiSurface * clone() const override
Clones the geometry by performing a deep copy.
QgsSurface * surfaceN(int index)
Returns the surface with the specified index.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
AxisOrder
Axis order for GML generation.
Multi curve geometry collection.
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.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QgsMultiSurface * toCurveType() const override
Returns the geometry converted to the more generic curve type.
Abstract base class for all geometries.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
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.
QVector< QgsPoint > QgsPointSequence
QgsAbstractGeometry * boundary() const override
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.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
QgsMultiSurface() SIP_HOLDGIL
Constructor for an empty multisurface geometry.
QString geometryType() const override SIP_HOLDGIL
Returns a unique string representing the geometry type.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
json asJsonObject(int precision=17) const override
Returns a json object representation of the geometry.