Skip to content

Commit 282dfbc

Browse files
committed
Merge branch 'release-2_16-aaime_sld' into release-2_16
2 parents 8190e4c + cac25d3 commit 282dfbc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3730
-135
lines changed

python/core/qgsogcutils.sip

+7
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,12 @@ class QgsOgcUtils
5959
*/
6060
static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage /Out/ );
6161

62+
/** Creates an OGC expression XML element.
63+
* @return valid OGC expression QDomElement on success,
64+
* otherwise null QDomElement
65+
* @note added in 2.14
66+
*/
67+
static QDomElement expressionToOgcExpression( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage = nullptr );
68+
6269
};
6370

python/core/qgsvectorlayer.sip

+17-2
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,23 @@ class QgsVectorLayer : QgsMapLayer
564564
*/
565565
bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
566566

567-
bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
567+
/**
568+
* Writes the symbology of the layer into the document provided in SLD 1.1 format
569+
* @param node the node that will have the style element added to it.
570+
* @param doc the document that will have the QDomNode added.
571+
* @param errorMessage reference to string that will be updated with any error messages
572+
* @param props a open ended set of properties that can drive/inform the SLD encoding
573+
* @return true in case of success
574+
*/
575+
bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage, const QgsStringMap& props = QgsStringMap() ) const;
576+
577+
/**
578+
* Read the symbology of the layer according to the information contained in
579+
* the UserStyle element of a SLD style document
580+
* @param node the node that have the style element in it.
581+
* @param errorMessage reference to string that will be updated with any error messages
582+
* @return true in case of success
583+
*/
568584
bool readSld( const QDomNode& node, QString& errorMessage );
569585

570586
/**
@@ -1713,4 +1729,3 @@ class QgsVectorLayer : QgsMapLayer
17131729

17141730

17151731
};
1716-

python/core/symbology-ng/qgscategorizedsymbolrendererv2.sip

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ class QgsRendererCategoryV2
2828
// debugging
2929
QString dump() const;
3030

31-
void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const;
31+
/** Creates a DOM element representing the category in SLD format.
32+
* @param doc DOM document
33+
* @param element destination DOM element
34+
* @param props graduated renderer properties
35+
*/
36+
void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
3237

3338
protected:
3439

@@ -65,7 +70,10 @@ class QgsCategorizedSymbolRendererV2 : QgsFeatureRendererV2
6570

6671
virtual QgsCategorizedSymbolRendererV2* clone() const /Factory/;
6772

73+
//! Writes the SLD element following the SLD v1.1 specs
6874
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
75+
//! Writes the SLD element following the SLD v1.1 specs
76+
virtual void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
6977

7078
//! returns bitwise OR-ed capabilities of the renderer
7179
virtual int capabilities();

python/core/symbology-ng/qgsellipsesymbollayerv2.sip

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class QgsEllipseSymbolLayerV2 : QgsMarkerSymbolLayerV2
1818
virtual QgsEllipseSymbolLayerV2* clone() const /Factory/;
1919
QgsStringMap properties() const;
2020

21+
//! Writes the SLD element following the SLD v1.1 specs
2122
void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
2223
void writeSldMarker( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
2324

python/core/symbology-ng/qgsfillsymbollayerv2.sip

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2
3232

3333
virtual QgsSimpleFillSymbolLayerV2* clone() const /Factory/;
3434

35+
//! Writes the SLD element following the SLD v1.1 specs
3536
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
3637

3738
QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const;
@@ -661,6 +662,7 @@ class QgsSVGFillSymbolLayer: QgsImageFillSymbolLayer
661662

662663
virtual QgsSVGFillSymbolLayer* clone() const /Factory/;
663664

665+
//! Writes the SLD element following the SLD v1.1 specs
664666
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
665667

666668
//getters and setters
@@ -720,6 +722,7 @@ class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer
720722

721723
virtual QgsLinePatternFillSymbolLayer* clone() const /Factory/;
722724

725+
//! Writes the SLD element following the SLD v1.1 specs
723726
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
724727

725728
double estimateMaxBleed() const;
@@ -791,6 +794,7 @@ class QgsPointPatternFillSymbolLayer : QgsImageFillSymbolLayer
791794

792795
virtual QgsPointPatternFillSymbolLayer* clone() const /Factory/;
793796

797+
//! Writes the SLD element following the SLD v1.1 specs
794798
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
795799

796800
double estimateMaxBleed() const;
@@ -879,6 +883,7 @@ class QgsCentroidFillSymbolLayerV2 : QgsFillSymbolLayerV2
879883

880884
virtual QgsCentroidFillSymbolLayerV2* clone() const /Factory/;
881885

886+
//! Writes the SLD element following the SLD v1.1 specs
882887
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
883888

884889
void setColor( const QColor& color );

python/core/symbology-ng/qgsgraduatedsymbolrendererv2.sip

+3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ class QgsGraduatedSymbolRendererV2 : QgsFeatureRendererV2
108108

109109
virtual QgsGraduatedSymbolRendererV2* clone() const /Factory/;
110110

111+
//! Writes the SLD element following the SLD v1.1 specs
111112
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
113+
//! Writes the SLD element following the SLD v1.1 specs
114+
virtual void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
112115

113116
//! returns bitwise OR-ed capabilities of the renderer
114117
virtual int capabilities();

python/core/symbology-ng/qgslinesymbollayerv2.sip

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class QgsSimpleLineSymbolLayerV2 : QgsLineSymbolLayerV2
3131

3232
virtual QgsSimpleLineSymbolLayerV2* clone() const /Factory/;
3333

34+
//! Writes the SLD element following the SLD v1.1 specs
3435
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
3536

3637
QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const;
@@ -142,6 +143,7 @@ class QgsMarkerLineSymbolLayerV2 : QgsLineSymbolLayerV2
142143

143144
virtual QgsMarkerLineSymbolLayerV2* clone() const;
144145

146+
//! Writes the SLD element following the SLD v1.1 specs
145147
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
146148

147149
void setColor( const QColor& color );

python/core/symbology-ng/qgspointdisplacementrenderer.sip

+3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class QgsPointDisplacementRenderer : QgsFeatureRendererV2
1818

1919
virtual QgsPointDisplacementRenderer* clone() const /Factory/;
2020

21+
//! Writes the SLD element following the SLD v1.1 specs
2122
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
23+
//! Writes the SLD element following the SLD v1.1 specs
24+
virtual void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
2225

2326
/** Reimplemented from QgsFeatureRendererV2*/
2427
bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );

python/core/symbology-ng/qgsrendererv2.sip

+5
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ class QgsFeatureRendererV2
212212
//! create the SLD UserStyle element following the SLD v1.1 specs with the given name
213213
//! @note added in 2.8
214214
virtual QDomElement writeSld( QDomDocument& doc, const QString& styleName ) const;
215+
//! create the SLD UserStyle element following the SLD v1.1 specs with the given name
216+
//! @note added in 2.14
217+
virtual QDomElement writeSld( QDomDocument& doc, const QString& styleName, const QgsStringMap& props ) const;
215218

216219
/** Create a new renderer according to the information contained in
217220
* the UserStyle element of a SLD style document
@@ -227,6 +230,8 @@ class QgsFeatureRendererV2
227230

228231
//! used from subclasses to create SLD Rule elements following SLD v1.1 specs
229232
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
233+
//! used from subclasses to create SLD Rule elements following SLD v1.1 specs
234+
virtual void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
230235

231236
//! return a list of symbology items for the legend
232237
virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );

python/core/symbology-ng/qgsrulebasedrendererv2.sip

+10-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
8787
*/
8888
bool needsGeometry() const;
8989

90-
//! @note available in python bindings as symbol2
90+
//! @note available in python bindings as symbol2
9191
QgsSymbolV2List symbols( const QgsRenderContext& context = QgsRenderContext() ) /PyName=symbols2/;
9292

9393
//! @note not available in python bindings
@@ -203,7 +203,12 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
203203
//! clone this rule, return new instance
204204
QgsRuleBasedRendererV2::Rule* clone() const /Factory/;
205205

206-
void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props );
206+
/** Creates a DOM element representing the rule in SLD format.
207+
* @param doc DOM document
208+
* @param element destination DOM element
209+
* @param props graduated renderer properties
210+
*/
211+
void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props = QgsStringMap() );
207212
static QgsRuleBasedRendererV2::Rule* createFromSld( QDomElement& element, QGis::GeometryType geomType ) /Factory/;
208213

209214
QDomElement save( QDomDocument& doc, QgsSymbolV2Map& symbolMap );
@@ -366,7 +371,10 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
366371

367372
virtual QgsRuleBasedRendererV2* clone() const /Factory/;
368373

374+
//! Writes the SLD element following the SLD v1.1 specs
369375
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
376+
//! Writes the SLD element following the SLD v1.1 specs
377+
virtual void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
370378

371379
static QgsFeatureRendererV2* createFromSld( QDomElement& element, QGis::GeometryType geomType ) /Factory/;
372380

python/core/symbology-ng/qgssinglesymbolrendererv2.sip

+3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ class QgsSingleSymbolRendererV2 : QgsFeatureRendererV2
3737

3838
virtual QgsSingleSymbolRendererV2* clone() const /Factory/;
3939

40+
//! Writes the SLD element following the SLD v1.1 specs
4041
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
42+
//! Writes the SLD element following the SLD v1.1 specs
43+
virtual void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
4144
static QgsFeatureRendererV2* createFromSld( QDomElement& element, QGis::GeometryType geomType );
4245

4346
//! returns bitwise OR-ed capabilities of the renderer

python/core/symbology-ng/qgssymbollayerv2.sip

+28-26
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,56 @@ class QgsSymbolLayerV2
1010
{
1111
case QgsSymbolV2::Marker:
1212
if (dynamic_cast<QgsEllipseSymbolLayerV2*>(sipCpp) != NULL)
13-
sipType = sipType_QgsEllipseSymbolLayerV2;
13+
sipType = sipType_QgsEllipseSymbolLayerV2;
1414
else if (dynamic_cast<QgsFontMarkerSymbolLayerV2*>(sipCpp) != NULL)
15-
sipType = sipType_QgsFontMarkerSymbolLayerV2;
15+
sipType = sipType_QgsFontMarkerSymbolLayerV2;
1616
else if (dynamic_cast<QgsSimpleMarkerSymbolLayerV2*>(sipCpp) != NULL)
17-
sipType = sipType_QgsSimpleMarkerSymbolLayerV2;
17+
sipType = sipType_QgsSimpleMarkerSymbolLayerV2;
1818
else if (dynamic_cast<QgsFilledMarkerSymbolLayer*>(sipCpp) != NULL)
19-
sipType = sipType_QgsFilledMarkerSymbolLayer;
19+
sipType = sipType_QgsFilledMarkerSymbolLayer;
2020
else if (dynamic_cast<QgsSvgMarkerSymbolLayerV2*>(sipCpp) != NULL)
21-
sipType = sipType_QgsSvgMarkerSymbolLayerV2;
21+
sipType = sipType_QgsSvgMarkerSymbolLayerV2;
2222
else if (dynamic_cast<QgsVectorFieldSymbolLayer*>(sipCpp) != NULL)
23-
sipType = sipType_QgsVectorFieldSymbolLayer;
23+
sipType = sipType_QgsVectorFieldSymbolLayer;
2424
else
25-
sipType = sipType_QgsMarkerSymbolLayerV2;
25+
sipType = sipType_QgsMarkerSymbolLayerV2;
2626
break;
2727

2828
case QgsSymbolV2::Line:
2929
if (dynamic_cast<QgsMarkerLineSymbolLayerV2*>(sipCpp) != NULL)
30-
sipType = sipType_QgsMarkerLineSymbolLayerV2;
30+
sipType = sipType_QgsMarkerLineSymbolLayerV2;
3131
else if (dynamic_cast<QgsSimpleLineSymbolLayerV2*>(sipCpp) != NULL)
32-
sipType = sipType_QgsSimpleLineSymbolLayerV2;
32+
sipType = sipType_QgsSimpleLineSymbolLayerV2;
3333
else if (dynamic_cast<QgsArrowSymbolLayer*>(sipCpp) != NULL)
34-
sipType = sipType_QgsArrowSymbolLayer;
34+
sipType = sipType_QgsArrowSymbolLayer;
3535
else
36-
sipType = sipType_QgsLineSymbolLayerV2;
36+
sipType = sipType_QgsLineSymbolLayerV2;
3737
break;
3838

3939
case QgsSymbolV2::Fill:
4040
if (dynamic_cast<QgsSimpleFillSymbolLayerV2*>(sipCpp) != NULL)
41-
sipType = sipType_QgsSimpleFillSymbolLayerV2;
41+
sipType = sipType_QgsSimpleFillSymbolLayerV2;
4242
else if (dynamic_cast<QgsImageFillSymbolLayer*>(sipCpp) != NULL)
4343
{
44-
if (dynamic_cast<QgsLinePatternFillSymbolLayer*>(sipCpp) != NULL)
45-
sipType = sipType_QgsLinePatternFillSymbolLayer;
46-
else if (dynamic_cast<QgsPointPatternFillSymbolLayer*>(sipCpp) != NULL)
47-
sipType = sipType_QgsPointPatternFillSymbolLayer;
48-
else if (dynamic_cast<QgsSVGFillSymbolLayer*>(sipCpp) != NULL)
49-
sipType = sipType_QgsSVGFillSymbolLayer;
50-
else if (dynamic_cast<QgsRasterFillSymbolLayer*>(sipCpp) != NULL)
51-
sipType = sipType_QgsRasterFillSymbolLayer;
52-
else
53-
sipType = sipType_QgsImageFillSymbolLayer;
44+
if (dynamic_cast<QgsLinePatternFillSymbolLayer*>(sipCpp) != NULL)
45+
sipType = sipType_QgsLinePatternFillSymbolLayer;
46+
else if (dynamic_cast<QgsPointPatternFillSymbolLayer*>(sipCpp) != NULL)
47+
sipType = sipType_QgsPointPatternFillSymbolLayer;
48+
else if (dynamic_cast<QgsSVGFillSymbolLayer*>(sipCpp) != NULL)
49+
sipType = sipType_QgsSVGFillSymbolLayer;
50+
else if (dynamic_cast<QgsRasterFillSymbolLayer*>(sipCpp) != NULL)
51+
sipType = sipType_QgsRasterFillSymbolLayer;
52+
else
53+
sipType = sipType_QgsImageFillSymbolLayer;
5454
}
5555
else if (dynamic_cast<QgsCentroidFillSymbolLayerV2*>(sipCpp) != NULL)
56-
sipType = sipType_QgsCentroidFillSymbolLayerV2;
56+
sipType = sipType_QgsCentroidFillSymbolLayerV2;
5757
else if (dynamic_cast<QgsGradientFillSymbolLayerV2*>(sipCpp) != NULL)
58-
sipType = sipType_QgsGradientFillSymbolLayerV2;
58+
sipType = sipType_QgsGradientFillSymbolLayerV2;
5959
else if (dynamic_cast<QgsShapeburstFillSymbolLayerV2*>(sipCpp) != NULL)
60-
sipType = sipType_QgsShapeburstFillSymbolLayerV2;
60+
sipType = sipType_QgsShapeburstFillSymbolLayerV2;
6161
else
62-
sipType = sipType_QgsFillSymbolLayerV2;
62+
sipType = sipType_QgsFillSymbolLayerV2;
6363
break;
6464

6565
case QgsSymbolV2::Hybrid:
@@ -111,6 +111,7 @@ class QgsSymbolLayerV2
111111
*/
112112
virtual QgsSymbolLayerV2* clone() const = 0 /Factory/;
113113

114+
//! Writes the SLD element following the SLD v1.1 specs
114115
virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
115116

116117
virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const;
@@ -527,6 +528,7 @@ class QgsMarkerSymbolLayerV2 : QgsSymbolLayerV2
527528
*/
528529
VerticalAnchorPoint verticalAnchorPoint() const;
529530

531+
//! Writes the SLD element following the SLD v1.1 specs
530532
virtual void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
531533

532534
/** Writes the symbol layer definition as a SLD XML element.

python/core/symbology-ng/qgssymbollayerv2utils.sip

+31
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class QgsSymbolLayerV2Utils
204204
static void createGeometryElement( QDomDocument &doc, QDomElement &element, const QString& geomFunc );
205205
static bool geometryFromSldElement( QDomElement &element, QString &geomFunc );
206206

207+
static bool createExpressionElement( QDomDocument &doc, QDomElement &element, const QString& function );
207208
static bool createFunctionElement( QDomDocument &doc, QDomElement &element, const QString& function );
208209
static bool functionFromSldElement( QDomElement &element, QString &function );
209210

@@ -424,4 +425,34 @@ class QgsSymbolLayerV2Utils
424425
*/
425426
static QList<double> prettyBreaks( double minimum, double maximum, int classes );
426427

428+
/** Rescales the given size based on the uomScale found in the props, if any is found, otherwise
429+
* returns the value un-modified
430+
* @note added in 2.14
431+
*/
432+
static double rescaleUom( double size, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props );
433+
434+
/** Rescales the given point based on the uomScale found in the props, if any is found, otherwise
435+
* returns a copy of the original point
436+
* @note added in 2.14
437+
*/
438+
static QPointF rescaleUom( const QPointF& point, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props ) /PyName=rescalePointUom/;
439+
440+
/** Rescales the given array based on the uomScale found in the props, if any is found, otherwise
441+
* returns a copy of the original point
442+
* @note added in 2.14
443+
*/
444+
static QVector<qreal> rescaleUom( const QVector<qreal>& array, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props ) /PyName=rescaleArrayUom/;
445+
446+
/**
447+
* Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into the SE Rule element
448+
* @note added in 2.14
449+
*/
450+
static void applyScaleDependency( QDomDocument& doc, QDomElement& ruleElem, QgsStringMap& props );
451+
452+
/**
453+
* Merges the local scale limits, if any, with the ones already in the map, if any
454+
* @note added in 2.14
455+
*/
456+
static void mergeScaleDependencies( int mScaleMinDenom, int mScaleMaxDenom, QgsStringMap& props );
457+
427458
};

python/core/symbology-ng/qgssymbolv2.sip

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ class QgsSymbolV2
152152

153153
virtual QgsSymbolV2* clone() const = 0 /Factory/;
154154

155-
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
155+
//! Writes the SLD element following the SLD v1.1 specs
156+
void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const;
156157

157158
OutputUnit outputUnit() const;
158159
void setOutputUnit( OutputUnit u );

python/core/symbology-ng/qgsvectorfieldsymbollayer.sip

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class QgsVectorFieldSymbolLayer : QgsMarkerSymbolLayerV2
4444
virtual QgsVectorFieldSymbolLayer* clone() const /Factory/;
4545
QgsStringMap properties() const;
4646

47+
//! Writes the SLD element following the SLD v1.1 specs
4748
void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
4849

4950
void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );

0 commit comments

Comments
 (0)