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 = qgis::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 : qgis::as_const( fieldIndicesA ) )
156 outAttributes.append( inFeatureA.
attribute( a ) );
158 for (
int b : qgis::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 : qgis::as_const( points ) )
206 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );