QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
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 }
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
bool isEmpty() const override SIP_HOLDGIL
Returns true if the geometry is empty.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
static json pointsToJson(const QgsPointSequence &points, int precision)
Returns coordinates as json object.
void clear() override
Clears the geometry, ie reset it to a null geometry.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
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.
Multi line string geometry collection.
QVector< QgsAbstractGeometry * > mGeometries
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
QString geometryType() const override SIP_HOLDGIL
Returns a unique string representing the geometry type.
QgsWkbTypes::Type mWkbType
Line string geometry type, with support for z-dimension and m-values.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
QgsMultiLineString * clone() const override
Clones the geometry by performing a deep copy.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
void clear() override
Clears the geometry, ie reset it to a null geometry.
AxisOrder
Axis order for GML generation.
Multi curve geometry 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.
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.
json asJsonObject(int precision=17) const override
Returns a json object representation of the geometry.
Abstract base class for all geometries.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
QVector< QgsPoint > QgsPointSequence
QgsLineString * lineStringN(int index)
Returns the line string with the specified index.
QgsMultiLineString() SIP_HOLDGIL
Constructor for an empty multilinestring geometry.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
void reserve(int size) SIP_HOLDGIL
Attempts to allocate memory for at least size geometries.
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.
bool wktOmitChildType() const override
Returns whether child type names are omitted from Wkt representations of the collection.