23 QString QgsLineIntersectionAlgorithm::name()
 const 
   25   return QStringLiteral( 
"lineintersections" );
 
   28 QString QgsLineIntersectionAlgorithm::displayName()
 const 
   30   return QObject::tr( 
"Line intersections" );
 
   33 QStringList QgsLineIntersectionAlgorithm::tags()
 const 
   35   return QObject::tr( 
"line,intersection" ).split( 
',' );
 
   38 QString QgsLineIntersectionAlgorithm::group()
 const 
   40   return QObject::tr( 
"Vector overlay" );
 
   43 QString QgsLineIntersectionAlgorithm::groupId()
 const 
   45   return QStringLiteral( 
"vectoroverlay" );
 
   48 void QgsLineIntersectionAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   56                   QStringLiteral( 
"INPUT_FIELDS" ),
 
   57                   QObject::tr( 
"Input fields to keep (leave empty to keep all fields)" ), QVariant(),
 
   61                   QStringLiteral( 
"INTERSECT_FIELDS" ),
 
   62                   QObject::tr( 
"Intersect fields to keep (leave empty to keep all fields)" ), QVariant(),
 
   66   std::unique_ptr< QgsProcessingParameterString > prefix = std::make_unique< QgsProcessingParameterString >( QStringLiteral( 
"INTERSECT_FIELDS_PREFIX" ), QObject::tr( 
"Intersect fields prefix" ), QString(), 
false, 
true );
 
   68   addParameter( prefix.release() );
 
   73 QString QgsLineIntersectionAlgorithm::shortHelpString()
 const 
   75   return QObject::tr( 
"This algorithm creates point features where the lines in the Intersect layer intersect the lines in the Input layer." );
 
   78 QgsLineIntersectionAlgorithm *QgsLineIntersectionAlgorithm::createInstance()
 const 
   80   return new QgsLineIntersectionAlgorithm();
 
   85   std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral( 
"INPUT" ), context ) );
 
   89   std::unique_ptr< QgsFeatureSource > sourceB( parameterAsSource( parameters, QStringLiteral( 
"INTERSECT" ), context ) );
 
   93   const QStringList fieldsA = parameterAsFields( parameters, QStringLiteral( 
"INPUT_FIELDS" ), context );
 
   94   const QStringList fieldsB = parameterAsFields( parameters, QStringLiteral( 
"INTERSECT_FIELDS" ), context );
 
   99   QString intersectFieldsPrefix = parameterAsString( parameters, QStringLiteral( 
"INTERSECT_FIELDS_PREFIX" ), context );
 
  103                           intersectFieldsPrefix );
 
  113   double step = sourceA->featureCount() > 0 ? 100.0 / sourceA->featureCount() : 1;
 
  129     if ( !lines.empty() )
 
  133       engine->prepareGeometry();
 
  149         if ( engine->intersects( tmpGeom.
constGet() ) )
 
  154           for ( 
int a : std::as_const( fieldIndicesA ) )
 
  156             outAttributes.append( inFeatureA.
attribute( a ) );
 
  158           for ( 
int b : std::as_const( fieldIndicesB ) )
 
  160             outAttributes.append( inFeatureB.
attribute( b ) );
 
  169                 if ( part.isMultipart() )
 
  171                   points = part.asMultiPoint();
 
  175                   points.append( part.asPoint() );
 
  188               points.append( intersectGeom.
asPoint() );
 
  191           for ( 
const QgsPointXY &j : std::as_const( points ) )
 
  206   outputs.insert( QStringLiteral( 
"OUTPUT" ), dest );
 
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
@ 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.
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsMultiPointXY asMultiPoint() const
Returns the contents of the geometry as a multi-point.
QVector< QgsGeometry > asGeometryCollection() const
Returns contents of the geometry as a list of geometries.
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
static QgsGeometry fromPointXY(const QgsPointXY &point) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
QgsWkbTypes::GeometryType type
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified geometry.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
A class to represent a 2D point.
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.
@ FlagAdvanced
Parameter is an advanced parameter which should be hidden from users by default.
A feature sink output for processing algorithms.
An input feature source (such as vector layers) parameter for processing algorithms.
A vector layer or feature source field parameter for processing algorithms.
static QgsFields indicesToFields(const QList< int > &indices, const QgsFields &fields)
Returns a subset of fields based on the indices of desired fields.
static QList< int > fieldNamesToIndices(const QStringList &fieldNames, const QgsFields &fields)
Returns a list of field indices parsed from the given list of field names.
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB, const QString &fieldsBPrefix=QString())
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
@ TypeVectorLine
Vector line layers.
@ TypeVectorPoint
Vector point layers.
A spatial index for QgsFeature objects.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
QSet< QgsFeatureId > QgsFeatureIds
QList< int > QgsAttributeList
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.