24using namespace Qt::StringLiterals;
28QString QgsProjectPointCartesianAlgorithm::name()
const
30 return u
"projectpointcartesian"_s;
33QString QgsProjectPointCartesianAlgorithm::displayName()
const
35 return QObject::tr(
"Project points (Cartesian)" );
38QStringList QgsProjectPointCartesianAlgorithm::tags()
const
40 return QObject::tr(
"bearing,azimuth,distance,angle" ).split(
',' );
43QString QgsProjectPointCartesianAlgorithm::group()
const
45 return QObject::tr(
"Vector geometry" );
48QString QgsProjectPointCartesianAlgorithm::groupId()
const
50 return u
"vectorgeometry"_s;
53QString QgsProjectPointCartesianAlgorithm::outputName()
const
55 return QObject::tr(
"Projected" );
58QString QgsProjectPointCartesianAlgorithm::shortHelpString()
const
60 return QObject::tr(
"This algorithm projects point geometries by a specified distance and bearing (azimuth), creating a new point layer with the projected points.\n\n"
61 "The distance is specified in layer units, and the bearing in degrees clockwise from North." );
64QString QgsProjectPointCartesianAlgorithm::shortDescription()
const
66 return QObject::tr(
"Creates a point layer with geometries projected by a specified distance and bearing (azimuth)." );
69QList<int> QgsProjectPointCartesianAlgorithm::inputLayerTypes()
const
79QgsProjectPointCartesianAlgorithm *QgsProjectPointCartesianAlgorithm::createInstance()
const
81 return new QgsProjectPointCartesianAlgorithm();
84void QgsProjectPointCartesianAlgorithm::initParameters(
const QVariantMap & )
87 bearing->setIsDynamic(
true );
89 bearing->setDynamicLayerParameterName( u
"INPUT"_s );
90 addParameter( bearing.release() );
92 auto distance = std::make_unique<QgsProcessingParameterDistance>( u
"DISTANCE"_s, QObject::tr(
"Distance" ), 1, u
"INPUT"_s,
false );
93 distance->setIsDynamic(
true );
95 distance->setDynamicLayerParameterName( u
"INPUT"_s );
96 addParameter( distance.release() );
106 mBearing = parameterAsDouble( parameters, u
"BEARING"_s, context );
108 if ( mDynamicBearing )
109 mBearingProperty = parameters.value( u
"BEARING"_s ).value<
QgsProperty>();
111 mDistance = parameterAsDouble( parameters, u
"DISTANCE"_s, context );
113 if ( mDynamicDistance )
114 mDistanceProperty = parameters.value( u
"DISTANCE"_s ).value<
QgsProperty>();
124 double distance = mDistance;
125 if ( mDynamicDistance )
127 double bearing = mBearing;
128 if ( mDynamicBearing )
129 bearing = mBearingProperty.valueAsDouble( context.
expressionContext(), bearing );
135 auto result = std::make_unique<QgsMultiPoint>();
140 result->addGeometry( p->
project( distance, bearing ).
clone() );
ProcessingSourceType
Processing data source types.
@ VectorPoint
Vector point layers.
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
@ Double
Double/float values.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
int numGeometries() const
Returns the number of geometries within the collection.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Qgis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.).
Multi point geometry collection.
QgsPoint * pointN(int index)
Returns the point with the specified index.
Point geometry type, with support for z-dimension and m-values.
QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
QgsPoint project(double distance, double azimuth, double inclination=90.0) const
Returns a new point which corresponds to this point projected by a specified distance with specified ...
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
Base class for providing feedback from a processing algorithm.
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
Definition for a property.
@ Double
Double value (including negative values).
A store for object properties.
double valueAsDouble(const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a double.
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 Q_INVOKABLE bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
QList< QgsFeature > QgsFeatureList