mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Dxf export: modify layer name to be a valid dxf layer name
This commit is contained in:
parent
b1b7904e14
commit
8405ddb876
@ -467,7 +467,7 @@ void QgsDxfExport::writeTables()
|
||||
{
|
||||
writeGroup( 0, "LAYER" );
|
||||
QString layerName = *layerIt ? ( *layerIt )->name() : "";
|
||||
writeGroup( 2, layerName );
|
||||
writeGroup( 2, dxfLayerName( layerName ) );
|
||||
writeGroup( 70, 64 );
|
||||
writeGroup( 62, 1 );
|
||||
writeGroup( 6, "CONTINUOUS" );
|
||||
@ -577,7 +577,7 @@ void QgsDxfExport::writeEntities()
|
||||
{
|
||||
if ( mSymbologyExport == NoSymbology )
|
||||
{
|
||||
addFeature( fet, vl->name(), 0, 0 ); //no symbology at all
|
||||
addFeature( fet, dxfLayerName( vl->name() ), 0, 0 ); //no symbology at all
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -597,7 +597,7 @@ void QgsDxfExport::writeEntities()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
addFeature( fet, vl->name(), s->symbolLayer( 0 ), s );
|
||||
addFeature( fet, dxfLayerName( vl->name() ), s->symbolLayer( 0 ), s );
|
||||
}
|
||||
}
|
||||
renderer->stopRender( ctx );
|
||||
@ -1331,6 +1331,38 @@ QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
|
||||
}
|
||||
}
|
||||
|
||||
QString QgsDxfExport::dxfLayerName( const QString& name )
|
||||
{
|
||||
//dxf layers can be max 31 characters long
|
||||
QString layerName = name.left( 31 );
|
||||
|
||||
//allowed characters are 0-9, A-Z, $, -, _
|
||||
for ( int i = 0; i < layerName.size(); ++i )
|
||||
{
|
||||
QChar c = layerName.at( i );
|
||||
if ( c > 122 )
|
||||
{
|
||||
layerName[i] = '_';
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( c.isNumber() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( c == '$' || c == '-' || c == '_' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !c.isLetter() )
|
||||
{
|
||||
layerName[i] = '_';
|
||||
}
|
||||
}
|
||||
return layerName;
|
||||
}
|
||||
|
||||
/******************************************************Test with AC_1018 methods***************************************************************/
|
||||
|
||||
void QgsDxfExport::writeHeaderAC1018( QTextStream& stream )
|
||||
|
@ -160,6 +160,7 @@ class CORE_EXPORT QgsDxfExport
|
||||
double dashSeparatorSize() const;
|
||||
double sizeToMapUnits( double s ) const;
|
||||
static QString lineNameFromPenStyle( Qt::PenStyle style );
|
||||
static QString dxfLayerName( const QString& name );
|
||||
};
|
||||
|
||||
#endif // QGSDXFEXPORT_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user