23QString QgsFixGeometriesAlgorithm::name()
const
25 return QStringLiteral(
"fixgeometries" );
28QString QgsFixGeometriesAlgorithm::displayName()
const
30 return QObject::tr(
"Fix geometries" );
33QStringList QgsFixGeometriesAlgorithm::tags()
const
35 return QObject::tr(
"repair,invalid,geometry,make,valid,error" ).split(
',' );
38QString QgsFixGeometriesAlgorithm::group()
const
40 return QObject::tr(
"Vector geometry" );
43QString QgsFixGeometriesAlgorithm::groupId()
const
45 return QStringLiteral(
"vectorgeometry" );
53QString QgsFixGeometriesAlgorithm::outputName()
const
55 return QObject::tr(
"Fixed geometries" );
63QString QgsFixGeometriesAlgorithm::shortHelpString()
const
65 return QObject::tr(
"This algorithm attempts to create a valid representation of a given invalid geometry without "
66 "losing any of the input vertices. Already-valid geometries are returned without further intervention. "
67 "Always outputs multi-geometry layer.\n\n"
68 "NOTE: M values will be dropped from the output." );
71QgsFixGeometriesAlgorithm *QgsFixGeometriesAlgorithm::createInstance()
const
73 return new QgsFixGeometriesAlgorithm();
76bool QgsFixGeometriesAlgorithm::supportInPlaceEdit(
const QgsMapLayer *l )
const
78 const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
88void QgsFixGeometriesAlgorithm::initParameters(
const QVariantMap & )
90 std::unique_ptr< QgsProcessingParameterEnum> methodParameter = std::make_unique< QgsProcessingParameterEnum >(
91 QStringLiteral(
"METHOD" ),
92 QObject::tr(
"Repair method" ),
93 QStringList{ QObject::tr(
"Linework" ), QObject::tr(
"Structure" ) },
96#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<10
97 methodParameter->setDefaultValue( 0 );
99 methodParameter->setDefaultValue( 1 );
101 addParameter( methodParameter.release() );
106 mMethod =
static_cast< Qgis::MakeValidMethod>( parameterAsInt( parameters, QStringLiteral(
"METHOD" ), context ) );
107#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<10
110 throw QgsProcessingException(
"The structured method to make geometries valid requires a QGIS build based on GEOS 3.10 or later" );
124 if ( outputGeometry.
isNull() )
126 feedback->
pushInfo( QObject::tr(
"makeValid failed for feature %1 " ).arg( feature.
id() ) );
136 QVector< QgsGeometry > matchingParts;
142 if ( !matchingParts.empty() )
148 if ( outputGeometry.
type() != QgsWkbTypes::GeometryType::PointGeometry )
MakeValidMethod
Algorithms to use when repairing invalid geometries.
@ Structure
Structured method, first makes all rings valid and then merges shells and subtracts holes from shells...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void clearGeometry()
Removes any geometry associated with the feature.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
A geometry is the spatial representation of a feature.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
QVector< QgsGeometry > asGeometryCollection() const
Returns contents of the geometry as a list of geometries.
QgsWkbTypes::GeometryType type
QgsGeometry makeValid(Qgis::MakeValidMethod method=Qgis::MakeValidMethod::Linework, bool keepCollapsed=false) const SIP_THROW(QgsNotSupportedException)
Attempts to make an invalid geometry valid without losing vertices.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
Base class for all map layer types.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
bool supportInPlaceEdit(const QgsMapLayer *layer) const override
Checks whether this algorithm supports in-place editing on the given layer Default implementation for...
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
@ FlagSkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static Type promoteNonPointTypesToMulti(Type type) SIP_HOLDGIL
Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types...
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
Type
The WKB type describes the number of dimensions a geometry has.
static QString displayString(Type type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
QList< QgsFeature > QgsFeatureList