25QString QgsSplitWithLinesAlgorithm::name()
 const 
   27  return QStringLiteral( 
"splitwithlines" );
 
   30QString QgsSplitWithLinesAlgorithm::displayName()
 const 
   32  return QObject::tr( 
"Split with lines" );
 
   35QStringList QgsSplitWithLinesAlgorithm::tags()
 const 
   37  return QObject::tr( 
"split,cut,lines" ).split( 
',' );
 
   40QString QgsSplitWithLinesAlgorithm::group()
 const 
   42  return QObject::tr( 
"Vector overlay" );
 
   45QString QgsSplitWithLinesAlgorithm::groupId()
 const 
   47  return QStringLiteral( 
"vectoroverlay" );
 
   50void QgsSplitWithLinesAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   59QString QgsSplitWithLinesAlgorithm::shortHelpString()
 const 
   61  return QObject::tr( 
"This algorithm splits the lines or polygons in one layer using the lines or polygon rings in another layer to define the breaking points. " 
   62                      "Intersection between geometries in both layers are considered as split points." );
 
   65QgsSplitWithLinesAlgorithm *QgsSplitWithLinesAlgorithm::createInstance()
 const 
   67  return new QgsSplitWithLinesAlgorithm();
 
   77bool QgsSplitWithLinesAlgorithm::supportInPlaceEdit( 
const QgsMapLayer *l )
 const 
   79  const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
 
   91  std::unique_ptr< QgsFeatureSource > source( parameterAsSource( parameters, QStringLiteral( 
"INPUT" ), context ) );
 
   95  std::unique_ptr< QgsFeatureSource > linesSource( parameterAsSource( parameters, QStringLiteral( 
"LINES" ), context ) );
 
   99  bool sameLayer = parameters.value( QStringLiteral( 
"INPUT" ) ) == parameters.value( QStringLiteral( 
"LINES" ) );
 
  102  std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( 
"OUTPUT" ), context, dest, source->fields(),
 
  119  double step = source->featureCount() > 0 ? 100.0 / source->featureCount() : 1;
 
  142    const QgsFeatureIds splitFeatureCandidates = qgis::listToSet( splitFeaturesIndex.intersects( originalGeometry.
boundingBox() ) );
 
  143    if ( !splitFeatureCandidates.empty() ) 
 
  145      QVector< QgsGeometry > splittingLines;
 
  148      std::unique_ptr< QgsGeometryEngine > originalGeometryEngine;
 
  150      for ( 
QgsFeatureId splitFeatureCandidateId : splitFeatureCandidates )
 
  153        if ( sameLayer && inFeatureA.
id() == splitFeatureCandidateId )
 
  156        const QgsGeometry splitFeatureCandidate = splitFeaturesIndex.geometry( splitFeatureCandidateId );
 
  157        if ( !originalGeometryEngine )
 
  160          originalGeometryEngine->prepareGeometry();
 
  163        if ( originalGeometryEngine->intersects( splitFeatureCandidate.
constGet() ) )
 
  167          splittingLines.append( splitGeomParts );
 
  171      if ( !splittingLines.empty() )
 
  173        for ( 
const QgsGeometry &splitGeom : std::as_const( splittingLines ) )
 
  176          QVector< QgsGeometry > outGeoms;
 
  180          splitGeomEngine->prepareGeometry();
 
  181          while ( !inGeoms.empty() )
 
  192            if ( splitGeomEngine->intersects( inGeom.
constGet() ) )
 
  195              if ( splitterPList.empty() )
 
  210              QVector< QgsGeometry > newGeometries;
 
  224                  outGeoms.append( inGeom );
 
  228                  outGeoms.append( inGeom );
 
  229                  outGeoms.append( newGeometries );
 
  234                outGeoms.append( inGeom );
 
  239              outGeoms.append( inGeom );
 
  248    QVector< QgsGeometry > parts;
 
  249    for ( 
const QgsGeometry &aGeom : std::as_const( inGeoms ) )
 
  259        int numPoints = aGeom.constGet()->nCoordinates();
 
  261        if ( numPoints <= 2 )
 
  263          if ( numPoints == 2 )
 
  264            passed = !
static_cast< const QgsCurve * 
>( aGeom.constGet() )->isClosed(); 
 
  271        parts.append( aGeom );
 
  285  outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
@ VectorPolygon
Vector polygon layers.
 
@ VectorLine
Vector line layers.
 
GeometryOperationResult
Success or failure of a geometry operation.
 
@ Success
Operation succeeded.
 
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
 
@ SupportsInPlaceEdits
Algorithm supports in-place editing.
 
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
 
Abstract base class for curved geometry type.
 
Wrapper for iterator of features from vector data provider or vector layer.
 
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
 
This class wraps a request for features to a vector layer (or directly its vector data provider).
 
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
 
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
 
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
 
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
 
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
 
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
 
bool hasGeometry() const
Returns true if the feature has an associated geometry.
 
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
 
bool isCanceled() const
Tells whether the operation has been canceled already.
 
void setProgress(double progress)
Sets the current progress for the feedback object.
 
A geometry is the spatial representation of a feature.
 
QgsGeometry convertToType(Qgis::GeometryType destType, bool destMultipart=false) const
Try to convert the geometry to the requested type.
 
QVector< QgsGeometry > asGeometryCollection() const
Returns contents of the geometry as a list of geometries.
 
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
 
double hausdorffDistance(const QgsGeometry &geom) const
Returns the Hausdorff distance between this geometry and geom.
 
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
 
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
 
Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitGeometry(const QVector< QgsPointXY > &splitLine, QVector< QgsGeometry > &newGeometries, bool topological, QVector< QgsPointXY > &topologyTestPoints, bool splitFeature=true)
Splits this geometry according to a given line.
 
Base class for all map layer types.
 
Point geometry type, with support for z-dimension and m-values.
 
virtual Qgis::ProcessingAlgorithmFlags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
 
Contains information about the context in which a processing algorithm is executed.
 
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
 
Custom exception class for processing related exceptions.
 
Base class for providing feedback from a processing algorithm.
 
A feature sink output for processing algorithms.
 
An input feature source (such as vector layers) parameter for processing algorithms.
 
A spatial index for QgsFeature objects.
 
@ FlagStoreFeatureGeometries
Indicates that the spatial index should also store feature geometries. This requires more memory,...
 
Represents a vector layer which manages a vector based data sets.
 
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
 
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
 
static Qgis::WkbType multiType(Qgis::WkbType type)
Returns the multi type for a WKB type.
 
QVector< QgsRingSequence > QgsCoordinateSequence
 
QVector< QgsPointSequence > QgsRingSequence
 
QVector< QgsPoint > QgsPointSequence
 
QSet< QgsFeatureId > QgsFeatureIds
 
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features