27QString QgsRepairShapefileAlgorithm::name()
const
29 return QStringLiteral(
"repairshapefile" );
32QString QgsRepairShapefileAlgorithm::displayName()
const
34 return QObject::tr(
"Repair Shapefile" );
37QStringList QgsRepairShapefileAlgorithm::tags()
const
39 return QObject::tr(
"fix,shp,shx,broken,missing" ).split(
',' );
42QString QgsRepairShapefileAlgorithm::group()
const
44 return QObject::tr(
"Vector general" );
47QString QgsRepairShapefileAlgorithm::groupId()
const
49 return QStringLiteral(
"vectorgeneral" );
52QString QgsRepairShapefileAlgorithm::shortHelpString()
const
54 return QObject::tr(
"Repairs a broken Shapefile by recreating missing or broken SHX files." );
57QString QgsRepairShapefileAlgorithm::shortDescription()
const
59 return QObject::tr(
"Repairs broken Shapefiles by recreating SHX files." );
62QgsRepairShapefileAlgorithm *QgsRepairShapefileAlgorithm::createInstance()
const
64 return new QgsRepairShapefileAlgorithm();
67void QgsRepairShapefileAlgorithm::initAlgorithm(
const QVariantMap & )
76 const QString path = parameterAsFile( parameters, QStringLiteral(
"INPUT" ), context );
78 if ( !QFile::exists( path ) )
79 throw QgsProcessingException( QObject::tr(
"Could not load source layer for %1." ).arg( QLatin1String(
"INPUT" ) ) );
81 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
"YES" );
83 auto layer = std::make_unique<QgsVectorLayer>( path );
84 if ( !layer->isValid() )
86 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
nullptr );
90 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
nullptr );
92 feedback->
pushInfo( QObject::tr(
"Successfully repaired, found %n feature(s)",
nullptr, layer->featureCount() ) );
95 outputs.insert( QStringLiteral(
"OUTPUT" ), path );
@ File
Parameter is a single file.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A vector layer output for processing algorithms.
An input file or folder parameter for processing algorithms.