33 return QStringLiteral(
"MultiSurface" );
44 auto result = qgis::make_unique< QgsMultiSurface >();
46 return result.release();
63 QStringLiteral(
"Polygon" ) );
69 QDomElement elemMultiPolygon = doc.createElementNS( ns, QStringLiteral(
"MultiPolygon" ) );
72 return elemMultiPolygon;
76 if ( qgsgeometry_cast<const QgsSurface *>( geom ) )
78 std::unique_ptr< QgsPolygon > polygon( static_cast<const QgsSurface *>( geom )->surfaceToPolygon() );
80 QDomElement elemPolygonMember = doc.createElementNS( ns, QStringLiteral(
"polygonMember" ) );
81 elemPolygonMember.appendChild( polygon->asGml2( doc, precision, ns, axisOrder ) );
82 elemMultiPolygon.appendChild( elemPolygonMember );
86 return elemMultiPolygon;
91 QDomElement elemMultiSurface = doc.createElementNS( ns, QStringLiteral(
"MultiSurface" ) );
94 return elemMultiSurface;
98 if ( qgsgeometry_cast<const QgsSurface *>( geom ) )
100 QDomElement elemSurfaceMember = doc.createElementNS( ns, QStringLiteral(
"surfaceMember" ) );
101 elemSurfaceMember.appendChild( geom->asGml3( doc, precision, ns, axisOrder ) );
102 elemMultiSurface.appendChild( elemSurfaceMember );
106 return elemMultiSurface;
112 QString json = QStringLiteral(
"{\"type\": \"MultiPolygon\", \"coordinates\": [" );
115 if ( qgsgeometry_cast<const QgsSurface *>( geom ) )
119 std::unique_ptr< QgsPolygon >polygon( static_cast<const QgsSurface *>( geom )->surfaceToPolygon() );
121 std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() );
123 exteriorLineString->points( exteriorPts );
126 std::unique_ptr< QgsLineString > interiorLineString;
127 for (
int i = 0, n = polygon->numInteriorRings(); i < n; ++i )
129 interiorLineString.reset( polygon->interiorRing( i )->curveToLine() );
131 interiorLineString->points( interiorPts );
134 if ( json.endsWith( QLatin1String(
", " ) ) )
139 json += QLatin1String(
"], " );
142 if ( json.endsWith( QLatin1String(
", " ) ) )
146 json += QLatin1String(
"] }" );
152 if ( !qgsgeometry_cast<QgsSurface *>( g ) )
176 if ( !g || !qgsgeometry_cast< QgsSurface * >( g ) )
187 std::unique_ptr< QgsMultiCurve > multiCurve(
new QgsMultiCurve() );
192 multiCurve->addGeometry( surface->boundary() );
195 if ( multiCurve->numGeometries() == 0 )
199 return multiCurve.release();
bool isMeasure() const
Returns true if the geometry contains m values.
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.
static QString pointsToJSON(const QgsPointSequence &points, int precision)
Returns a geoJSON coordinates string.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QString asJson(int precision=17) const override
Returns a GeoJSON representation of the geometry.
QgsMultiSurface * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership...
Curve polygon geometry type.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
void clear() override
Clears the geometry, ie reset it to a null geometry.
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.
Multi surface geometry collection.
QgsWkbTypes::Type mWkbType
virtual bool insertGeometry(QgsAbstractGeometry *g, int index)
Inserts a geometry before a specified index and takes ownership.
bool isEmpty() const override
Returns true if the geometry is empty.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
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.
Multi curve geometry collection.
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 fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
QVector< QgsPoint > QgsPointSequence
QVector< QgsAbstractGeometry *> mGeometries
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
QString geometryType() const override
Returns a unique string representing the geometry type.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
QgsMultiSurface * clone() const override
Clones the geometry by performing a deep copy.
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.
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...