27using namespace Qt::StringLiterals;
31QString QgsRepairShapefileAlgorithm::name()
const
33 return u
"repairshapefile"_s;
36QString QgsRepairShapefileAlgorithm::displayName()
const
38 return QObject::tr(
"Repair Shapefile" );
41QStringList QgsRepairShapefileAlgorithm::tags()
const
43 return QObject::tr(
"fix,shp,shx,broken,missing" ).split(
',' );
46QString QgsRepairShapefileAlgorithm::group()
const
48 return QObject::tr(
"Vector general" );
51QString QgsRepairShapefileAlgorithm::groupId()
const
53 return u
"vectorgeneral"_s;
56QString QgsRepairShapefileAlgorithm::shortHelpString()
const
58 return QObject::tr(
"Repairs a broken Shapefile by recreating missing or broken SHX files." );
61QString QgsRepairShapefileAlgorithm::shortDescription()
const
63 return QObject::tr(
"Repairs broken Shapefiles by recreating SHX files." );
66QgsRepairShapefileAlgorithm *QgsRepairShapefileAlgorithm::createInstance()
const
68 return new QgsRepairShapefileAlgorithm();
71void QgsRepairShapefileAlgorithm::initAlgorithm(
const QVariantMap & )
80 const QString path = parameterAsFile( parameters, u
"INPUT"_s, context );
82 if ( !QFile::exists( path ) )
85 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
"YES" );
87 auto layer = std::make_unique<QgsVectorLayer>( path );
88 if ( !layer->isValid() )
90 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
nullptr );
94 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
nullptr );
96 feedback->
pushInfo( QObject::tr(
"Successfully repaired, found %n feature(s)",
nullptr, layer->featureCount() ) );
99 outputs.insert( u
"OUTPUT"_s, 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.