24using namespace Qt::StringLiterals;
28QString QgsShapefileEncodingInfoAlgorithm::name()
const
30 return u
"shpencodinginfo"_s;
33QString QgsShapefileEncodingInfoAlgorithm::displayName()
const
35 return QObject::tr(
"Extract Shapefile encoding" );
38QStringList QgsShapefileEncodingInfoAlgorithm::tags()
const
40 return QObject::tr(
"shp,codepage,cpg,ldid,information,list,show" ).split(
',' );
43QString QgsShapefileEncodingInfoAlgorithm::group()
const
45 return QObject::tr(
"Vector general" );
48QString QgsShapefileEncodingInfoAlgorithm::groupId()
const
50 return u
"vectorgeneral"_s;
53QString QgsShapefileEncodingInfoAlgorithm::shortHelpString()
const
55 return QObject::tr(
"This algorithm extracts the attribute encoding information embedded in a Shapefile.\n\n"
56 "Both the encoding specified by an optional .cpg file and any encoding details present in the "
57 ".dbf LDID header block are considered." );
60QString QgsShapefileEncodingInfoAlgorithm::shortDescription()
const
62 return QObject::tr(
"Extracts the attribute encoding information embedded in a Shapefile." );
65QgsShapefileEncodingInfoAlgorithm *QgsShapefileEncodingInfoAlgorithm::createInstance()
const
67 return new QgsShapefileEncodingInfoAlgorithm();
70void QgsShapefileEncodingInfoAlgorithm::initAlgorithm(
const QVariantMap & )
81 const QString path = parameterAsFile( parameters, u
"INPUT"_s, context );
84 if ( mCpgEncoding.isEmpty() )
85 feedback->
pushInfo( QObject::tr(
"No encoding information present in CPG file" ) );
87 feedback->
pushInfo( QObject::tr(
"Detected encoding from CPG file: %1" ).arg( mCpgEncoding ) );
90 if ( mLdidEncoding.isEmpty() )
91 feedback->
pushInfo( QObject::tr(
"No encoding information present in DBF LDID header" ) );
93 feedback->
pushInfo( QObject::tr(
"Detected encoding from DBF LDID header: %1" ).arg( mLdidEncoding ) );
102 outputs.insert( u
"ENCODING"_s, mCpgEncoding.isEmpty() ? mLdidEncoding : mCpgEncoding );
103 outputs.insert( u
"CPG_ENCODING"_s, mCpgEncoding );
104 outputs.insert( u
"LDID_ENCODING"_s, mLdidEncoding );
@ File
Parameter is a single file.
static QString readShapefileEncodingFromCpg(const QString &path)
Reads the encoding of the shapefile at the specified path (where path is the location of the "....
static QString readShapefileEncodingFromLdid(const QString &path)
Reads the encoding of the shapefile at the specified path (where path is the location of the "....
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A string output for processing algorithms.
An input file or folder parameter for processing algorithms.