25 #include <QJsonObject> 
   27 #include <nlohmann/json.hpp> 
   36   return qgsgeometry_cast< QgsCurve * >( 
geometryN( index ) );
 
   41   return qgsgeometry_cast< const QgsCurve * >( 
geometryN( index ) );
 
   46   return QStringLiteral( 
"MultiCurve" );
 
   51   auto result = std::make_unique< QgsMultiCurve >();
 
   53   return result.release();
 
   76                             QStringLiteral( 
"LineString" ) );
 
   82   QDomElement elemMultiLineString = doc.createElementNS( ns, QStringLiteral( 
"MultiLineString" ) );
 
   85     return elemMultiLineString;
 
   89     if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
 
   91       std::unique_ptr< QgsLineString > lineString( 
static_cast<const QgsCurve *
>( geom )->curveToLine() );
 
   93       QDomElement elemLineStringMember = doc.createElementNS( ns, QStringLiteral( 
"lineStringMember" ) );
 
   94       elemLineStringMember.appendChild( lineString->asGml2( doc, 
precision, ns, axisOrder ) );
 
   95       elemMultiLineString.appendChild( elemLineStringMember );
 
   99   return elemMultiLineString;
 
  104   QDomElement elemMultiCurve = doc.createElementNS( ns, QStringLiteral( 
"MultiCurve" ) );
 
  107     return elemMultiCurve;
 
  111     if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
 
  115       QDomElement elemCurveMember = doc.createElementNS( ns, QStringLiteral( 
"curveMember" ) );
 
  116       elemCurveMember.appendChild( curve->
asGml3( doc, 
precision, ns, axisOrder ) );
 
  117       elemMultiCurve.appendChild( elemCurveMember );
 
  121   return elemMultiCurve;
 
  126   json coordinates( json::array( ) );
 
  129     if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
 
  131       std::unique_ptr< QgsLineString > lineString( 
static_cast<const QgsCurve *
>( geom )->curveToLine() );
 
  133       lineString->points( pts );
 
  139     {  
"type",  
"MultiLineString"  },
 
  140     {  
"coordinates", coordinates }
 
  146   if ( !qgsgeometry_cast<QgsCurve *>( g ) )
 
  170   if ( !g || !qgsgeometry_cast<QgsCurve *>( g ) )
 
  185     if ( qgsgeometry_cast<const QgsCurve *>( geom ) )
 
  190   return reversedMultiCurve;
 
  195   std::unique_ptr< QgsMultiPoint > multiPoint( 
new QgsMultiPoint() );
 
  201       if ( !curve->isClosed() )
 
  203         multiPoint->addGeometry( 
new QgsPoint( curve->startPoint() ) );
 
  204         multiPoint->addGeometry( 
new QgsPoint( curve->endPoint() ) );
 
  208   if ( multiPoint->numGeometries() == 0 )
 
  212   return multiPoint.release();
 
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.
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.
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.
Circular string geometry type.
Compound curve geometry type.
Abstract base class for curved geometry type.
bool isEmpty() const override SIP_HOLDGIL
Returns true if the geometry is empty.
QVector< QgsAbstractGeometry * > mGeometries
void clear() override
Clears the geometry, ie reset it to a null geometry.
virtual bool insertGeometry(QgsAbstractGeometry *g, int index)
Inserts a geometry before a specified index and takes ownership.
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.
Multi curve geometry collection.
QgsMultiCurve * reversed() const
Returns a copy of the multi curve, where each component curve has had its line direction reversed.
QString geometryType() const override SIP_HOLDGIL
Returns a unique string representing the geometry type.
json asJsonObject(int precision=17) const override
Returns a json object representation of the geometry.
QgsMultiCurve * toCurveType() const override
Returns the geometry converted to the more generic curve type.
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 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.
Multi point geometry collection.
Point geometry type, with support for z-dimension and m-values.
QVector< QgsPoint > QgsPointSequence