QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
25 #include <QJsonObject>
27 #include <nlohmann/json.hpp>
36 return QStringLiteral(
"MultiCurve" );
41 auto result = qgis::make_unique< QgsMultiCurve >();
43 return result.release();
66 QStringLiteral(
"LineString" ) );
72 QDomElement elemMultiLineString = doc.createElementNS( ns, QStringLiteral(
"MultiLineString" ) );
75 return elemMultiLineString;
79 if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
81 std::unique_ptr< QgsLineString > lineString(
static_cast<const QgsCurve *
>( geom )->curveToLine() );
83 QDomElement elemLineStringMember = doc.createElementNS( ns, QStringLiteral(
"lineStringMember" ) );
84 elemLineStringMember.appendChild( lineString->asGml2( doc,
precision, ns, axisOrder ) );
85 elemMultiLineString.appendChild( elemLineStringMember );
89 return elemMultiLineString;
94 QDomElement elemMultiCurve = doc.createElementNS( ns, QStringLiteral(
"MultiCurve" ) );
97 return elemMultiCurve;
101 if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
105 QDomElement elemCurveMember = doc.createElementNS( ns, QStringLiteral(
"curveMember" ) );
106 elemCurveMember.appendChild( curve->
asGml3( doc,
precision, ns, axisOrder ) );
107 elemMultiCurve.appendChild( elemCurveMember );
111 return elemMultiCurve;
116 json coordinates( json::array( ) );
119 if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
121 std::unique_ptr< QgsLineString > lineString(
static_cast<const QgsCurve *
>( geom )->curveToLine() );
123 lineString->points( pts );
129 {
"type",
"MultiLineString" },
130 {
"coordinates", coordinates }
136 if ( !qgsgeometry_cast<QgsCurve *>( g ) )
160 if ( !g || !qgsgeometry_cast<QgsCurve *>( g ) )
175 if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
180 return reversedMultiCurve;
185 std::unique_ptr< QgsMultiPoint > multiPoint(
new QgsMultiPoint() );
191 if ( !curve->isClosed() )
193 multiPoint->addGeometry(
new QgsPoint( curve->startPoint() ) );
194 multiPoint->addGeometry(
new QgsPoint( curve->endPoint() ) );
198 if ( multiPoint->numGeometries() == 0 )
202 return multiPoint.release();
Abstract base class for curved geometry type.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual bool insertGeometry(QgsAbstractGeometry *g, int index)
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.
QgsMultiCurve * reversed() const
Returns a copy of the multi curve, where each component curve has had its line direction reversed.
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.
bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string.
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.
Point geometry type, with support for z-dimension and m-values.
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.
void reserve(int size)
Attempts to allocate memory for at least size geometries.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
QgsMultiCurve * clone() const override
Clones the geometry by performing a deep copy.
QVector< QgsAbstractGeometry * > mGeometries
QgsWkbTypes::Type mWkbType
Line string geometry type, with support for z-dimension and m-values.
json asJsonObject(int precision=17) const override
Returns a json object representation of the geometry.
Circular string geometry type.
AxisOrder
Axis order for GML generation.
bool isEmpty() const override
Returns true if the geometry is empty.
Multi curve geometry collection.
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
QString geometryType() const override
Returns a unique string representing the geometry type.
QgsMultiCurve * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
QgsMultiCurve * toCurveType() const override
Returns the geometry converted to the more generic curve type.
bool fromCollectionWkt(const QString &wkt, const QVector< QgsAbstractGeometry * > &subtypes, const QString &defaultChildWkbType=QString())
Reads a collection from a WKT string.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
Multi point geometry collection.
Abstract base class for all geometries.
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.
QVector< QgsPoint > QgsPointSequence
bool isMeasure() const
Returns true if the geometry contains m values.
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 clear() override
Clears the geometry, ie reset it to a null geometry.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
bool insertGeometry(QgsAbstractGeometry *g, int index) override
Inserts a geometry before a specified index and takes ownership.
Compound curve geometry type.