Skip to content

Commit

Permalink
Implement ogr style in simple line symbol layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Dec 7, 2012
1 parent b0b9098 commit ac2e77c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/qgsvectorfilewriter.cpp
Expand Up @@ -69,6 +69,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
, mLayer( NULL )
, mGeom( NULL )
, mError( NoError )
, mExportFeatureStyle( true )
{
QString vectorFileName = theVectorFileName;
QString fileEncoding = theFileEncoding;
Expand Down Expand Up @@ -588,6 +589,8 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature, QgsFeatureRendererV2*
}
styleString.append( currentStyle );
}

OGR_F_SetStyleString( poFeature, styleString.toLocal8Bit().data() );
}

// put the created feature to layer
Expand Down Expand Up @@ -747,7 +750,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
{
fet.clearAttributeMap();
}
if ( !writer->addFeature( fet ) )
if ( !writer->addFeature( fet, layer->rendererV2() ) )
{
WriterError err = writer->hasError();
if ( err != NoError && errorMessage )
Expand Down
16 changes: 16 additions & 0 deletions src/core/symbology-ng/qgslinesymbollayerv2.cpp
Expand Up @@ -195,6 +195,22 @@ void QgsSimpleLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
}
}

QString QgsSimpleLineSymbolLayerV2::ogrFeatureStyle() const
{
QString symbolStyle;

//pen
symbolStyle.append( "PEN(" );
symbolStyle.append( "c:" );
symbolStyle.append( mPen.color().name() );
symbolStyle.append( ",w:" );
symbolStyle.append( QString::number( mPen.width() ) );
symbolStyle.append( "mm" );
symbolStyle.append( ")" );

return symbolStyle;
}

QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::createFromSld( QDomElement &element )
{
QgsDebugMsg( "Entered." );
Expand Down
2 changes: 2 additions & 0 deletions src/core/symbology-ng/qgslinesymbollayerv2.h
Expand Up @@ -56,6 +56,8 @@ class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2

void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;

QString ogrFeatureStyle() const;

// new stuff

Qt::PenStyle penStyle() const { return mPenStyle; }
Expand Down
1 change: 1 addition & 0 deletions src/core/symbology-ng/qgssymbolv2.cpp
Expand Up @@ -332,6 +332,7 @@ QString QgsSymbolV2::ogrFeatureStyle() const
}
styleString.append( currentStyleString );
}
return styleString;
}

QgsSymbolLayerV2List QgsSymbolV2::cloneLayers() const
Expand Down

0 comments on commit ac2e77c

Please sign in to comment.