void QgsPointPatternFillSymbolLayer::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const { for ( int i = 0; i < mMarkerSymbol->symbolLayerCount(); i++ ) { QDomElement symbolizerElem = doc.createElement( "se:PolygonSymbolizer" ); if ( !props.value( "uom", "" ).isEmpty() ) symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) ); element.appendChild( symbolizerElem ); // <Geometry> QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) ); QDomElement fillElem = doc.createElement( "se:Fill" ); symbolizerElem.appendChild( fillElem ); QDomElement graphicFillElem = doc.createElement( "se:GraphicFill" ); fillElem.appendChild( graphicFillElem ); // store distanceX, distanceY, displacementX, displacementY in a <VendorOption> QString dist = QgsSymbolLayerV2Utils::encodePoint( QPointF( mDistanceX, mDistanceY ) ); QDomElement distanceElem = QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "distance", dist ); symbolizerElem.appendChild( distanceElem ); QgsSymbolLayerV2 *layer = mMarkerSymbol->symbolLayer( i ); QgsMarkerSymbolLayerV2 *markerLayer = static_cast<QgsMarkerSymbolLayerV2 *>( layer ); if ( !markerLayer ) { QString errorMsg = QString( "MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->layerType() ); graphicFillElem.appendChild( doc.createComment( errorMsg ) ); } else { markerLayer->writeSldMarker( doc, graphicFillElem, props ); } } }
void QgsMarkerLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const { for ( int i = 0; i < mMarker->symbolLayerCount(); i++ ) { QDomElement symbolizerElem = doc.createElement( "se:LineSymbolizer" ); if ( !props.value( "uom", "" ).isEmpty() ) symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) ); element.appendChild( symbolizerElem ); // <Geometry> QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) ); QString gap; switch ( mPlacement ) { case FirstVertex: symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "firstPoint" ) ); break; case LastVertex: symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "lastPoint" ) ); break; case CentralPoint: symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "centralPoint" ) ); break; case Vertex: // no way to get line/polygon's vertices, use a VendorOption symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "points" ) ); break; default: gap = QString::number( mInterval ); break; } if ( !mRotateMarker ) { // markers in LineSymbolizer must be drawn following the line orientation, // use a VendorOption when no marker rotation symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "rotateMarker", "0" ) ); } // <Stroke> QDomElement strokeElem = doc.createElement( "se:Stroke" ); symbolizerElem.appendChild( strokeElem ); // <GraphicStroke> QDomElement graphicStrokeElem = doc.createElement( "se:GraphicStroke" ); strokeElem.appendChild( graphicStrokeElem ); QgsSymbolLayerV2 *layer = mMarker->symbolLayer( i ); QgsMarkerSymbolLayerV2 *markerLayer = static_cast<QgsMarkerSymbolLayerV2 *>( layer ); if ( !markerLayer ) { graphicStrokeElem.appendChild( doc.createComment( QString( "MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( markerLayer->layerType() ) ) ); } else { markerLayer->writeSldMarker( doc, graphicStrokeElem, props ); } if ( !gap.isEmpty() ) { QDomElement gapElem = doc.createElement( "se:Gap" ); QgsSymbolLayerV2Utils::createFunctionElement( doc, gapElem, gap ); graphicStrokeElem.appendChild( gapElem ); } if ( !qgsDoubleNear( mOffset, 0.0 ) ) { QDomElement perpOffsetElem = doc.createElement( "se:PerpendicularOffset" ); perpOffsetElem.appendChild( doc.createTextNode( QString::number( mOffset ) ) ); symbolizerElem.appendChild( perpOffsetElem ); } } }