25 QString QgsIntersectionAlgorithm::name()
const 27 return QStringLiteral(
"intersection" );
30 QString QgsIntersectionAlgorithm::displayName()
const 32 return QObject::tr(
"Intersection" );
35 QString QgsIntersectionAlgorithm::group()
const 37 return QObject::tr(
"Vector overlay" );
40 QString QgsIntersectionAlgorithm::groupId()
const 42 return QStringLiteral(
"vectoroverlay" );
45 QString QgsIntersectionAlgorithm::shortHelpString()
const 47 return QObject::tr(
"This algorithm extracts the overlapping portions of features in the Input and Overlay layers. " 48 "Features in the output Intersection layer are assigned the attributes of the overlapping features " 49 "from both the Input and Overlay layers." );
54 return new QgsIntersectionAlgorithm();
57 void QgsIntersectionAlgorithm::initAlgorithm(
const QVariantMap & )
63 QStringLiteral(
"INPUT_FIELDS" ),
64 QObject::tr(
"Input fields to keep (leave empty to keep all fields)" ), QVariant(),
67 QStringLiteral(
"OVERLAY_FIELDS" ),
68 QObject::tr(
"Overlay fields to keep (leave empty to keep all fields)" ), QVariant(),
78 std::unique_ptr< QgsFeatureSource > sourceA( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
82 std::unique_ptr< QgsFeatureSource > sourceB( parameterAsSource( parameters, QStringLiteral(
"OVERLAY" ), context ) );
88 const QStringList fieldsA = parameterAsFields( parameters, QStringLiteral(
"INPUT_FIELDS" ), context );
89 const QStringList fieldsB = parameterAsFields( parameters, QStringLiteral(
"OVERLAY_FIELDS" ), context );
99 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, outputFields, geomType, sourceA->sourceCrs(),
QgsFeatureSink::RegeneratePrimaryKey ) );
104 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
107 int total = sourceA->featureCount();
109 QgsOverlayUtils::intersection( *sourceA, *sourceB, *sink, context, feedback, count, total, fieldIndicesA, fieldIndicesB );
static Type multiType(Type type)
Returns the multi type for a WKB type.
Base class for providing feedback from a processing algorithm.
A vector layer or feature source field parameter for processing algorithms.
Container of fields for a vector layer.
Abstract base class for processing algorithms.
A feature sink output for processing algorithms.
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
static QList< int > fieldNamesToIndices(const QStringList &fieldNames, const QgsFields &fields)
Returns a list of field indices parsed from the given list of field names.
Type
The WKB type describes the number of dimensions a geometry has.
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB)
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
Custom exception class for processing related exceptions.
static QgsFields indicesToFields(const QList< int > &indices, const QgsFields &fields)
Returns a subset of fields based on the indices of desired fields.
An input feature source (such as vector layers) parameter for processing algorithms.
Contains information about the context in which a processing algorithm is executed.