25QString QgsRepairShapefileAlgorithm::name()
const
27 return QStringLiteral(
"repairshapefile" );
30QString QgsRepairShapefileAlgorithm::displayName()
const
32 return QObject::tr(
"Repair Shapefile" );
35QStringList QgsRepairShapefileAlgorithm::tags()
const
37 return QObject::tr(
"fix,shp,shx,broken,missing" ).split(
',' );
40QString QgsRepairShapefileAlgorithm::group()
const
42 return QObject::tr(
"Vector general" );
45QString QgsRepairShapefileAlgorithm::groupId()
const
47 return QStringLiteral(
"vectorgeneral" );
50QString QgsRepairShapefileAlgorithm::shortHelpString()
const
52 return QObject::tr(
"Repairs a broken Shapefile by recreating missing or broken SHX files." );
55QString QgsRepairShapefileAlgorithm::shortDescription()
const
57 return QObject::tr(
"Repairs broken Shapefiles by recreating SHX files." );
60QgsRepairShapefileAlgorithm *QgsRepairShapefileAlgorithm::createInstance()
const
62 return new QgsRepairShapefileAlgorithm();
65void QgsRepairShapefileAlgorithm::initAlgorithm(
const QVariantMap & )
74 const QString path = parameterAsFile( parameters, QStringLiteral(
"INPUT" ), context );
76 if ( !QFile::exists( path ) )
77 throw QgsProcessingException( QObject::tr(
"Could not load source layer for %1." ).arg( QLatin1String(
"INPUT" ) ) );
79 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
"YES" );
81 std::unique_ptr<QgsVectorLayer> layer = std::make_unique<QgsVectorLayer>( path );
82 if ( !layer->isValid() )
84 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
nullptr );
88 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
nullptr );
90 feedback->
pushInfo( QObject::tr(
"Successfully repaired, found %n feature(s)",
nullptr, layer->featureCount() ) );
93 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.