25 QString QgsRepairShapefileAlgorithm::name()
const
27 return QStringLiteral(
"repairshapefile" );
30 QString QgsRepairShapefileAlgorithm::displayName()
const
32 return QObject::tr(
"Repair Shapefile" );
35 QStringList QgsRepairShapefileAlgorithm::tags()
const
37 return QObject::tr(
"fix,shp,shx,broken,missing" ).split(
',' );
40 QString QgsRepairShapefileAlgorithm::group()
const
42 return QObject::tr(
"Vector general" );
45 QString QgsRepairShapefileAlgorithm::groupId()
const
47 return QStringLiteral(
"vectorgeneral" );
50 QString QgsRepairShapefileAlgorithm::shortHelpString()
const
52 return QObject::tr(
"Repairs a broken Shapefile by recreating missing or broken SHX files." );
55 QString QgsRepairShapefileAlgorithm::shortDescription()
const
57 return QObject::tr(
"Repairs broken Shapefiles by recreating SHX files." );
60 QgsRepairShapefileAlgorithm *QgsRepairShapefileAlgorithm::createInstance()
const
62 return new QgsRepairShapefileAlgorithm();
65 void QgsRepairShapefileAlgorithm::initAlgorithm(
const QVariantMap & )
68 QStringLiteral(
"shp" ), QVariant(),
false, QObject::tr(
"ESRI Shapefile" ) +
69 QStringLiteral(
" (*.shp *.SHP)" ) ) );
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 std::unique_ptr< QgsVectorLayer > layer = std::make_unique< QgsVectorLayer >( path );
84 if ( !layer->isValid() )
87 CPLSetConfigOption(
"SHAPE_RESTORE_SHX",
nullptr );
89 feedback->
pushInfo( QObject::tr(
"Successfully repaired, found %n feature(s)",
nullptr, layer->featureCount() ) );
92 outputs.insert( QStringLiteral(
"OUTPUT" ), path );
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.
@ File
Parameter is a single file.