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 & )
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() )
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 );
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.