25 #include <nlohmann/json.hpp> 26 #include <QJsonObject> 35 return QStringLiteral(
"MultiLineString" );
40 auto result = qgis::make_unique< QgsMultiLineString >();
42 return result.release();
63 QDomElement elemMultiLineString = doc.createElementNS( ns, QStringLiteral(
"MultiLineString" ) );
66 return elemMultiLineString;
70 if (
const QgsLineString *lineString = qgsgeometry_cast<const QgsLineString *>( geom ) )
72 QDomElement elemLineStringMember = doc.createElementNS( ns, QStringLiteral(
"lineStringMember" ) );
73 elemLineStringMember.appendChild( lineString->asGml2( doc, precision, ns, axisOrder ) );
74 elemMultiLineString.appendChild( elemLineStringMember );
78 return elemMultiLineString;
83 QDomElement elemMultiCurve = doc.createElementNS( ns, QStringLiteral(
"MultiCurve" ) );
86 return elemMultiCurve;
90 if (
const QgsLineString *lineString = qgsgeometry_cast<const QgsLineString *>( geom ) )
92 QDomElement elemCurveMember = doc.createElementNS( ns, QStringLiteral(
"curveMember" ) );
93 elemCurveMember.appendChild( lineString->asGml3( doc, precision, ns, axisOrder ) );
94 elemMultiCurve.appendChild( elemCurveMember );
98 return elemMultiCurve;
103 json coordinates( json::array( ) );
106 if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
110 lineString->
points( pts );
116 {
"type",
"MultiLineString" },
117 {
"coordinates", coordinates }
123 if ( !dynamic_cast<QgsLineString *>( g ) )
bool isMeasure() const
Returns true if the geometry contains m values.
QgsMultiLineString * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers 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.
void points(QgsPointSequence &pt) const override
Returns a list of points within the curve.
QgsMultiCurve * toCurveType() const override
Returns the geometry converted to the more generic curve type QgsMultiCurve.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
QgsMultiLineString * clone() const override
Clones the geometry by performing a deep copy.
Multi line string geometry collection.
void clear() override
Clears the geometry, ie reset it to a null geometry.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
QgsWkbTypes::Type mWkbType
bool isEmpty() const override
Returns true if the geometry is empty.
json asJsonObject(int precision=17) const override
Returns a json object representation of the geometry.
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.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
Abstract base class for all geometries.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
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 addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
static json pointsToJson(const QgsPointSequence &points, int precision)
Returns coordinates as json object.
QVector< QgsPoint > QgsPointSequence
QVector< QgsAbstractGeometry *> mGeometries
void reserve(int size)
Attempts to allocate memory for at least size geometries.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
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.
Line string geometry type, with support for z-dimension and m-values.
bool wktOmitChildType() const override
Returns whether child type names are omitted from Wkt representations of the collection.
void clear() override
Clears the geometry, ie reset it to a null geometry.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
static Type flatType(Type type)
Returns the flat type for a WKB type.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
QString geometryType() const override
Returns a unique string representing the geometry type.
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.