25 #include <nlohmann/json.hpp>
26 #include <QJsonObject>
35 return qgsgeometry_cast< QgsLineString * >(
geometryN( index ) );
40 return qgsgeometry_cast< const QgsLineString * >(
geometryN( index ) );
45 return QStringLiteral(
"MultiLineString" );
50 auto result = qgis::make_unique< QgsMultiLineString >();
52 return result.release();
73 QDomElement elemMultiLineString = doc.createElementNS( ns, QStringLiteral(
"MultiLineString" ) );
76 return elemMultiLineString;
80 if (
const QgsLineString *lineString = qgsgeometry_cast<const QgsLineString *>( geom ) )
82 QDomElement elemLineStringMember = doc.createElementNS( ns, QStringLiteral(
"lineStringMember" ) );
83 elemLineStringMember.appendChild( lineString->asGml2( doc,
precision, ns, axisOrder ) );
84 elemMultiLineString.appendChild( elemLineStringMember );
88 return elemMultiLineString;
93 QDomElement elemMultiCurve = doc.createElementNS( ns, QStringLiteral(
"MultiCurve" ) );
96 return elemMultiCurve;
100 if (
const QgsLineString *lineString = qgsgeometry_cast<const QgsLineString *>( geom ) )
102 QDomElement elemCurveMember = doc.createElementNS( ns, QStringLiteral(
"curveMember" ) );
103 elemCurveMember.appendChild( lineString->asGml3( doc,
precision, ns, axisOrder ) );
104 elemMultiCurve.appendChild( elemCurveMember );
108 return elemMultiCurve;
113 json coordinates( json::array( ) );
116 if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
120 lineString->
points( pts );
126 {
"type",
"MultiLineString" },
127 {
"coordinates", coordinates }
Abstract base class for all geometries.
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 is3D() const SIP_HOLDGIL
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.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
QgsWkbTypes::Type mWkbType
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
bool isEmpty() const override SIP_HOLDGIL
Returns true if the geometry is empty.
QVector< QgsAbstractGeometry * > mGeometries
void reserve(int size) SIP_HOLDGIL
Attempts to allocate memory for at least size geometries.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the 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.
static json pointsToJson(const QgsPointSequence &points, int precision)
Returns coordinates as json object.
Line string geometry type, with support for z-dimension and m-values.
void points(QgsPointSequence &pt) const override
Returns a list of points within the curve.
Multi curve geometry collection.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
void clear() override
Clears the geometry, ie reset it to a null geometry.
Multi line string geometry collection.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QString geometryType() const override SIP_HOLDGIL
Returns a unique string representing the geometry type.
QgsMultiCurve * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsMultiCurve.
bool wktOmitChildType() const override
Returns whether child type names are omitted from Wkt representations of the collection.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
json asJsonObject(int precision=17) const override
Returns a json object representation of the 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.
QgsMultiLineString() SIP_HOLDGIL
Constructor for an empty multilinestring geometry.
QgsMultiLineString * clone() const override
Clones the geometry by performing a deep copy.
QgsMultiLineString * 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.
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.
QgsLineString * lineStringN(int index)
Returns the line string with the specified index.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
QVector< QgsPoint > QgsPointSequence