19#include <nlohmann/json.hpp>
31using namespace Qt::StringLiterals;
50 return u
"MultiSurface"_s;
61 auto result = std::make_unique< QgsMultiSurface >();
63 return result.release();
84 QDomElement elemMultiPolygon = doc.createElementNS( ns, u
"MultiPolygon"_s );
87 return elemMultiPolygon;
93 std::unique_ptr< QgsPolygon > polygon(
static_cast<const QgsCurvePolygon *
>( geom )->surfaceToPolygon() );
95 QDomElement elemPolygonMember = doc.createElementNS( ns, u
"polygonMember"_s );
96 elemPolygonMember.appendChild( polygon->asGml2( doc, precision, ns, axisOrder ) );
97 elemMultiPolygon.appendChild( elemPolygonMember );
101 return elemMultiPolygon;
106 QDomElement elemMultiSurface = doc.createElementNS( ns, u
"MultiSurface"_s );
109 return elemMultiSurface;
115 QDomElement elemSurfaceMember = doc.createElementNS( ns, u
"surfaceMember"_s );
116 elemSurfaceMember.appendChild( geom->asGml3( doc, precision, ns, axisOrder ) );
117 elemMultiSurface.appendChild( elemSurfaceMember );
121 return elemMultiSurface;
132 json polygons( json::array() );
137 json coordinates( json::array() );
138 std::unique_ptr< QgsPolygon > polygon( curveGeom->surfaceToPolygon() );
139 std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() );
141 exteriorLineString->points( exteriorPts );
144 std::unique_ptr< QgsLineString > interiorLineString;
145 for (
int i = 0, n = polygon->numInteriorRings(); i < n; ++i )
147 interiorLineString.reset( polygon->interiorRing( i )->curveToLine() );
149 interiorLineString->points( interiorPts );
152 polygons.push_back( coordinates );
155 return { {
"type",
"MultiPolygon" }, {
"coordinates", polygons } };
160 json geometries( json::array() );
163 geometries.push_back( geom->asJsonObject( precision, profile ) );
165 return { {
"type",
"MultiSurface" }, {
"geometries", geometries } };
201 qDeleteAll( geometries );
213 if (
is3D() && !g->is3D() )
215 else if ( !
is3D() && g->is3D() )
219 else if ( !
isMeasure() && g->isMeasure() )
241 auto multiCurve = std::make_unique<QgsMultiCurve>();
247 multiCurve->addGeometry( surface->boundary() );
250 if ( multiCurve->numGeometries() == 0 )
254 return multiCurve.release();
259 auto res = std::make_unique< QgsMultiSurface >();
263 res->addGeometry(
mGeometries.at( i )->simplifyByDistance( tolerance ) );
265 return res.release();
GeoJsonProfile
GeoJson export Profile according to OGC Features and Geometries JSON - Part 1: Core https://docs....
@ Legacy
Legacy GeoJson profile used in QGIS prior to 4.2, which included some non-standard extensions and dev...
@ Rfc7946
GeoJson profile compliant with RFC7946 standard "http://www.opengis.net/def/profile/OGC/0/rfc7946".
@ JsonFg
GeoJson profile from OGC Features and Geometries JSON Part 1: core "http://www.opengis....
@ JsonFgPlus
GeoJson profile from OGC Features and Geometries JSON Part 1: core "http://www.opengis....
@ CurvePolygon
CurvePolygon.
@ MultiSurface
MultiSurface.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
bool isMeasure() const
Returns true if the geometry contains m values.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
AxisOrder
Axis order for GML generation.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, Qgis::WkbType baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
QgsAbstractGeometry()=default
Curve polygon geometry type.
QVector< QgsAbstractGeometry * > mGeometries
bool fromCollectionWkt(const QString &wkt, const QVector< Qgis::WkbType > &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.
void clearCache() const override
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
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.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
static json pointsToJson(const QgsPointSequence &points, int precision, Qgis::GeoJsonProfile profile)
Returns coordinates as json object.
QgsMultiSurface()
Constructor for an empty multisurface geometry.
QgsMultiSurface * simplifyByDistance(double tolerance) const override
Simplifies the geometry by applying the Douglas Peucker simplification by distance algorithm.
json asJsonObject(int precision=17, Qgis::GeoJsonProfile profile=Qgis::GeoJsonProfile::Legacy) const override
Returns a json object representation of the geometry with the given precision and profile.
QgsSurface * surfaceN(int index)
Returns the surface with the specified index.
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.
QString geometryType() const override
Returns a unique string representing the geometry type.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
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 fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
QgsMultiSurface * clone() const override
Clones the geometry by performing a deep copy.
bool addGeometries(const QVector< QgsAbstractGeometry * > &geometries) override
Adds a list of geometries to the collection, transferring ownership to the collection.
QgsMultiSurface * 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...
QgsMultiSurface * toCurveType() const override
Returns the geometry converted to the more generic curve type.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
void clear() override
Clears the geometry, ie reset it to a null geometry.
#define BUILTIN_UNREACHABLE
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsPoint > QgsPointSequence