@@ -863,14 +863,82 @@ void QgsLinePatternFillSymbolLayer::toSld( QDomDocument &doc, QDomElement &eleme
863
863
QgsSymbolLayerV2Utils::createRotationElement ( doc, graphicElem, angleFunc );
864
864
865
865
// <se:Displacement>
866
- QPointF lineOffset ( qSin ( mLineAngle ) * mOffset , qCos ( mLineAngle ) * mOffset );
866
+ QPointF lineOffset ( sin ( mLineAngle ) * mOffset , cos ( mLineAngle ) * mOffset );
867
867
QgsSymbolLayerV2Utils::createDisplacementElement ( doc, graphicElem, lineOffset );
868
+
869
+ if ( mOutline )
870
+ {
871
+ // the outline sub symbol should be stored within the Stroke element,
872
+ // but it will be stored in a separated LineSymbolizer because it could
873
+ // have more than one layer
874
+ mOutline ->toSld ( doc, element, props );
875
+ }
868
876
}
869
877
870
878
QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::createFromSld ( QDomElement &element )
871
879
{
872
- Q_UNUSED ( element );
873
- return NULL ;
880
+ QgsDebugMsg ( " Entered." );
881
+
882
+ QString name;
883
+ QColor fillColor, lineColor;
884
+ double size, lineWidth;
885
+
886
+ QDomElement fillElem = element.firstChildElement ( " Fill" );
887
+ if ( fillElem.isNull () )
888
+ return NULL ;
889
+
890
+ QDomElement graphicFillElem = fillElem.firstChildElement ( " GraphicFill" );
891
+ if ( graphicFillElem.isNull () )
892
+ return NULL ;
893
+
894
+ QDomElement graphicElem = graphicFillElem.firstChildElement ( " Graphic" );
895
+ if ( graphicElem.isNull () )
896
+ return NULL ;
897
+
898
+ if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld ( graphicElem, name, fillColor, lineColor, lineWidth, size ) )
899
+ return NULL ;
900
+
901
+ if ( name != " horline" )
902
+ return NULL ;
903
+
904
+ double angle = 0.0 ;
905
+ QString angleFunc;
906
+ if ( QgsSymbolLayerV2Utils::rotationFromSldElement ( graphicElem, angleFunc ) )
907
+ {
908
+ bool ok;
909
+ double d = angleFunc.toDouble ( &ok );
910
+ if ( ok )
911
+ angle = d;
912
+ }
913
+
914
+ double offset = 0.0 ;
915
+ QPointF vectOffset;
916
+ if ( QgsSymbolLayerV2Utils::displacementFromSldElement ( graphicElem, vectOffset ) )
917
+ {
918
+ offset = sqrt ( pow ( vectOffset.x (), 2 ) + pow ( vectOffset.y (), 2 ) );
919
+ }
920
+
921
+ QgsLinePatternFillSymbolLayer* sl = new QgsLinePatternFillSymbolLayer ();
922
+ sl->setColor ( lineColor );
923
+ sl->setLineWidth ( lineWidth );
924
+ sl->setLineAngle ( angle );
925
+ sl->setOffset ( offset );
926
+ sl->setDistance ( size );
927
+
928
+ // try to get the outline
929
+ QDomElement strokeElem = element.firstChildElement ( " Stroke" );
930
+ if ( !strokeElem.isNull () )
931
+ {
932
+ QgsSymbolLayerV2 *l = QgsSymbolLayerV2Utils::createLineLayerFromSld ( strokeElem );
933
+ if ( l )
934
+ {
935
+ QgsSymbolLayerV2List layers;
936
+ layers.append ( l );
937
+ sl->setSubSymbol ( new QgsLineSymbolV2 ( layers ) );
938
+ }
939
+ }
940
+
941
+ return sl;
874
942
}
875
943
876
944
// //////////////////////
0 commit comments