19#include <nlohmann/json.hpp>
32using namespace Qt::StringLiterals;
51 return u
"MultiCurve"_s;
56 auto result = std::make_unique< QgsMultiCurve >();
58 return result.release();
85 QDomElement elemMultiLineString = doc.createElementNS( ns, u
"MultiLineString"_s );
88 return elemMultiLineString;
94 std::unique_ptr< QgsLineString > lineString(
static_cast<const QgsCurve *
>( geom )->curveToLine() );
96 QDomElement elemLineStringMember = doc.createElementNS( ns, u
"lineStringMember"_s );
97 elemLineStringMember.appendChild( lineString->asGml2( doc, precision, ns, axisOrder ) );
98 elemMultiLineString.appendChild( elemLineStringMember );
102 return elemMultiLineString;
107 QDomElement elemMultiCurve = doc.createElementNS( ns, u
"MultiCurve"_s );
110 return elemMultiCurve;
118 QDomElement elemCurveMember = doc.createElementNS( ns, u
"curveMember"_s );
119 elemCurveMember.appendChild( curve->
asGml3( doc, precision, ns, axisOrder ) );
120 elemMultiCurve.appendChild( elemCurveMember );
124 return elemMultiCurve;
134 json coordinates( json::array() );
139 std::unique_ptr< QgsLineString > lineString( curveGeom->curveToLine() );
141 lineString->points( pts );
145 return { {
"type",
"MultiLineString" }, {
"coordinates", coordinates } };
150 json geometries( json::array() );
155 geometries.push_back( curveGeom->asJsonObject( precision, profile ) );
158 return { {
"type",
"MultiCurve" }, {
"geometries", geometries } };
194 qDeleteAll( geometries );
206 if (
is3D() && !g->is3D() )
208 else if ( !
is3D() && g->is3D() )
212 else if ( !
isMeasure() && g->isMeasure() )
234 auto res = std::make_unique< QgsMultiCurve >();
238 res->addGeometry(
mGeometries.at( i )->simplifyByDistance( tolerance ) );
240 return res.release();
254 return reversedMultiCurve;
259 auto multiPoint = std::make_unique<QgsMultiPoint>();
265 if ( !curve->isClosed() )
267 multiPoint->addGeometry(
new QgsPoint( curve->startPoint() ) );
268 multiPoint->addGeometry(
new QgsPoint( curve->endPoint() ) );
272 if ( multiPoint->numGeometries() == 0 )
276 return multiPoint.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....
@ CompoundCurve
CompoundCurve.
@ CircularString
CircularString.
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 QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML3 representation of the geometry.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
QgsAbstractGeometry()=default
Abstract base class for curved 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 reserve(int size)
Attempts to allocate memory for at least size geometries.
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.
QString geometryType() const override
Returns a unique string representing the geometry type.
QgsMultiCurve * reversed() const
Returns a copy of the multi curve, where each component curve has had its line direction reversed.
QgsMultiCurve * simplifyByDistance(double tolerance) const override
Simplifies the geometry by applying the Douglas Peucker simplification by distance algorithm.
QgsMultiCurve * toCurveType() const override
Returns the geometry converted to the more generic curve type.
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.
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.
QgsAbstractGeometry * boundary() const override
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.
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.
QgsMultiCurve * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
bool addGeometries(const QVector< QgsAbstractGeometry * > &geometries) override
Adds a list of geometries to the collection, transferring ownership to the collection.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
QgsMultiCurve * clone() const override
Clones the geometry by performing a deep copy.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QgsCurve * curveN(int index)
Returns the curve with the specified index.
Point geometry type, with support for z-dimension and m-values.
#define BUILTIN_UNREACHABLE
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsPoint > QgsPointSequence