Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'release-2_16-aaime_sld' into release-2_16
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Sep 22, 2016
2 parents 8190e4c + cac25d3 commit 282dfbc
Show file tree
Hide file tree
Showing 51 changed files with 3,730 additions and 135 deletions.
7 changes: 7 additions & 0 deletions python/core/qgsogcutils.sip
Expand Up @@ -59,5 +59,12 @@ class QgsOgcUtils
*/
static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage /Out/ );

/** Creates an OGC expression XML element.
* @return valid OGC expression QDomElement on success,
* otherwise null QDomElement
* @note added in 2.14
*/
static QDomElement expressionToOgcExpression( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage = nullptr );

};

19 changes: 17 additions & 2 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -564,7 +564,23 @@ class QgsVectorLayer : QgsMapLayer
*/
bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;

bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
/**
* Writes the symbology of the layer into the document provided in SLD 1.1 format
* @param node the node that will have the style element added to it.
* @param doc the document that will have the QDomNode added.
* @param errorMessage reference to string that will be updated with any error messages
* @param props a open ended set of properties that can drive/inform the SLD encoding
* @return true in case of success
*/
bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage, const QgsStringMap& props = QgsStringMap() ) const;

/**
* Read the symbology of the layer according to the information contained in
* the UserStyle element of a SLD style document
* @param node the node that have the style element in it.
* @param errorMessage reference to string that will be updated with any error messages
* @return true in case of success
*/
bool readSld( const QDomNode& node, QString& errorMessage );

/**
Expand Down Expand Up @@ -1713,4 +1729,3 @@ class QgsVectorLayer : QgsMapLayer


};

10 changes: 9 additions & 1 deletion python/core/symbology-ng/qgscategorizedsymbolrendererv2.sip
Expand Up @@ -28,7 +28,12 @@ class QgsRendererCategoryV2
// debugging
QString dump() const;

void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const;
/** Creates a DOM element representing the category in SLD format.
* @param doc DOM document
* @param element destination DOM element
* @param props graduated renderer properties
*/
void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;

protected:

Expand Down Expand Up @@ -65,7 +70,10 @@ class QgsCategorizedSymbolRendererV2 : QgsFeatureRendererV2

virtual QgsCategorizedSymbolRendererV2* clone() const /Factory/;

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

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities();
Expand Down
1 change: 1 addition & 0 deletions python/core/symbology-ng/qgsellipsesymbollayerv2.sip
Expand Up @@ -18,6 +18,7 @@ class QgsEllipseSymbolLayerV2 : QgsMarkerSymbolLayerV2
virtual QgsEllipseSymbolLayerV2* clone() const /Factory/;
QgsStringMap properties() const;

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

Expand Down
5 changes: 5 additions & 0 deletions python/core/symbology-ng/qgsfillsymbollayerv2.sip
Expand Up @@ -32,6 +32,7 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2

virtual QgsSimpleFillSymbolLayerV2* clone() const /Factory/;

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

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

virtual QgsSVGFillSymbolLayer* clone() const /Factory/;

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

//getters and setters
Expand Down Expand Up @@ -720,6 +722,7 @@ class QgsLinePatternFillSymbolLayer: QgsImageFillSymbolLayer

virtual QgsLinePatternFillSymbolLayer* clone() const /Factory/;

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

double estimateMaxBleed() const;
Expand Down Expand Up @@ -791,6 +794,7 @@ class QgsPointPatternFillSymbolLayer : QgsImageFillSymbolLayer

virtual QgsPointPatternFillSymbolLayer* clone() const /Factory/;

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

double estimateMaxBleed() const;
Expand Down Expand Up @@ -879,6 +883,7 @@ class QgsCentroidFillSymbolLayerV2 : QgsFillSymbolLayerV2

virtual QgsCentroidFillSymbolLayerV2* clone() const /Factory/;

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

void setColor( const QColor& color );
Expand Down
3 changes: 3 additions & 0 deletions python/core/symbology-ng/qgsgraduatedsymbolrendererv2.sip
Expand Up @@ -108,7 +108,10 @@ class QgsGraduatedSymbolRendererV2 : QgsFeatureRendererV2

virtual QgsGraduatedSymbolRendererV2* clone() const /Factory/;

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

//! returns bitwise OR-ed capabilities of the renderer
virtual int capabilities();
Expand Down
2 changes: 2 additions & 0 deletions python/core/symbology-ng/qgslinesymbollayerv2.sip
Expand Up @@ -31,6 +31,7 @@ class QgsSimpleLineSymbolLayerV2 : QgsLineSymbolLayerV2

virtual QgsSimpleLineSymbolLayerV2* clone() const /Factory/;

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

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

virtual QgsMarkerLineSymbolLayerV2* clone() const;

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

void setColor( const QColor& color );
Expand Down
3 changes: 3 additions & 0 deletions python/core/symbology-ng/qgspointdisplacementrenderer.sip
Expand Up @@ -18,7 +18,10 @@ class QgsPointDisplacementRenderer : QgsFeatureRendererV2

virtual QgsPointDisplacementRenderer* clone() const /Factory/;

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

/** Reimplemented from QgsFeatureRendererV2*/
bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
Expand Down
5 changes: 5 additions & 0 deletions python/core/symbology-ng/qgsrendererv2.sip
Expand Up @@ -212,6 +212,9 @@ class QgsFeatureRendererV2
//! create the SLD UserStyle element following the SLD v1.1 specs with the given name
//! @note added in 2.8
virtual QDomElement writeSld( QDomDocument& doc, const QString& styleName ) const;
//! create the SLD UserStyle element following the SLD v1.1 specs with the given name
//! @note added in 2.14
virtual QDomElement writeSld( QDomDocument& doc, const QString& styleName, const QgsStringMap& props ) const;

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

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

//! return a list of symbology items for the legend
virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );
Expand Down
12 changes: 10 additions & 2 deletions python/core/symbology-ng/qgsrulebasedrendererv2.sip
Expand Up @@ -87,7 +87,7 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
*/
bool needsGeometry() const;

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

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

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

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

virtual QgsRuleBasedRendererV2* clone() const /Factory/;

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

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

Expand Down
3 changes: 3 additions & 0 deletions python/core/symbology-ng/qgssinglesymbolrendererv2.sip
Expand Up @@ -37,7 +37,10 @@ class QgsSingleSymbolRendererV2 : QgsFeatureRendererV2

virtual QgsSingleSymbolRendererV2* clone() const /Factory/;

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

//! returns bitwise OR-ed capabilities of the renderer
Expand Down
54 changes: 28 additions & 26 deletions python/core/symbology-ng/qgssymbollayerv2.sip
Expand Up @@ -10,56 +10,56 @@ class QgsSymbolLayerV2
{
case QgsSymbolV2::Marker:
if (dynamic_cast<QgsEllipseSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsEllipseSymbolLayerV2;
sipType = sipType_QgsEllipseSymbolLayerV2;
else if (dynamic_cast<QgsFontMarkerSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsFontMarkerSymbolLayerV2;
sipType = sipType_QgsFontMarkerSymbolLayerV2;
else if (dynamic_cast<QgsSimpleMarkerSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsSimpleMarkerSymbolLayerV2;
sipType = sipType_QgsSimpleMarkerSymbolLayerV2;
else if (dynamic_cast<QgsFilledMarkerSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsFilledMarkerSymbolLayer;
sipType = sipType_QgsFilledMarkerSymbolLayer;
else if (dynamic_cast<QgsSvgMarkerSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsSvgMarkerSymbolLayerV2;
sipType = sipType_QgsSvgMarkerSymbolLayerV2;
else if (dynamic_cast<QgsVectorFieldSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsVectorFieldSymbolLayer;
sipType = sipType_QgsVectorFieldSymbolLayer;
else
sipType = sipType_QgsMarkerSymbolLayerV2;
sipType = sipType_QgsMarkerSymbolLayerV2;
break;

case QgsSymbolV2::Line:
if (dynamic_cast<QgsMarkerLineSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsMarkerLineSymbolLayerV2;
sipType = sipType_QgsMarkerLineSymbolLayerV2;
else if (dynamic_cast<QgsSimpleLineSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsSimpleLineSymbolLayerV2;
sipType = sipType_QgsSimpleLineSymbolLayerV2;
else if (dynamic_cast<QgsArrowSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsArrowSymbolLayer;
sipType = sipType_QgsArrowSymbolLayer;
else
sipType = sipType_QgsLineSymbolLayerV2;
sipType = sipType_QgsLineSymbolLayerV2;
break;

case QgsSymbolV2::Fill:
if (dynamic_cast<QgsSimpleFillSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsSimpleFillSymbolLayerV2;
sipType = sipType_QgsSimpleFillSymbolLayerV2;
else if (dynamic_cast<QgsImageFillSymbolLayer*>(sipCpp) != NULL)
{
if (dynamic_cast<QgsLinePatternFillSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsLinePatternFillSymbolLayer;
else if (dynamic_cast<QgsPointPatternFillSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsPointPatternFillSymbolLayer;
else if (dynamic_cast<QgsSVGFillSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsSVGFillSymbolLayer;
else if (dynamic_cast<QgsRasterFillSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsRasterFillSymbolLayer;
else
sipType = sipType_QgsImageFillSymbolLayer;
if (dynamic_cast<QgsLinePatternFillSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsLinePatternFillSymbolLayer;
else if (dynamic_cast<QgsPointPatternFillSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsPointPatternFillSymbolLayer;
else if (dynamic_cast<QgsSVGFillSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsSVGFillSymbolLayer;
else if (dynamic_cast<QgsRasterFillSymbolLayer*>(sipCpp) != NULL)
sipType = sipType_QgsRasterFillSymbolLayer;
else
sipType = sipType_QgsImageFillSymbolLayer;
}
else if (dynamic_cast<QgsCentroidFillSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsCentroidFillSymbolLayerV2;
sipType = sipType_QgsCentroidFillSymbolLayerV2;
else if (dynamic_cast<QgsGradientFillSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsGradientFillSymbolLayerV2;
sipType = sipType_QgsGradientFillSymbolLayerV2;
else if (dynamic_cast<QgsShapeburstFillSymbolLayerV2*>(sipCpp) != NULL)
sipType = sipType_QgsShapeburstFillSymbolLayerV2;
sipType = sipType_QgsShapeburstFillSymbolLayerV2;
else
sipType = sipType_QgsFillSymbolLayerV2;
sipType = sipType_QgsFillSymbolLayerV2;
break;

case QgsSymbolV2::Hybrid:
Expand Down Expand Up @@ -111,6 +111,7 @@ class QgsSymbolLayerV2
*/
virtual QgsSymbolLayerV2* clone() const = 0 /Factory/;

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

virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const;
Expand Down Expand Up @@ -527,6 +528,7 @@ class QgsMarkerSymbolLayerV2 : QgsSymbolLayerV2
*/
VerticalAnchorPoint verticalAnchorPoint() const;

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

/** Writes the symbol layer definition as a SLD XML element.
Expand Down
31 changes: 31 additions & 0 deletions python/core/symbology-ng/qgssymbollayerv2utils.sip
Expand Up @@ -204,6 +204,7 @@ class QgsSymbolLayerV2Utils
static void createGeometryElement( QDomDocument &doc, QDomElement &element, const QString& geomFunc );
static bool geometryFromSldElement( QDomElement &element, QString &geomFunc );

static bool createExpressionElement( QDomDocument &doc, QDomElement &element, const QString& function );
static bool createFunctionElement( QDomDocument &doc, QDomElement &element, const QString& function );
static bool functionFromSldElement( QDomElement &element, QString &function );

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

/** Rescales the given size based on the uomScale found in the props, if any is found, otherwise
* returns the value un-modified
* @note added in 2.14
*/
static double rescaleUom( double size, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props );

/** Rescales the given point based on the uomScale found in the props, if any is found, otherwise
* returns a copy of the original point
* @note added in 2.14
*/
static QPointF rescaleUom( const QPointF& point, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props ) /PyName=rescalePointUom/;

/** Rescales the given array based on the uomScale found in the props, if any is found, otherwise
* returns a copy of the original point
* @note added in 2.14
*/
static QVector<qreal> rescaleUom( const QVector<qreal>& array, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props ) /PyName=rescaleArrayUom/;

/**
* Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into the SE Rule element
* @note added in 2.14
*/
static void applyScaleDependency( QDomDocument& doc, QDomElement& ruleElem, QgsStringMap& props );

/**
* Merges the local scale limits, if any, with the ones already in the map, if any
* @note added in 2.14
*/
static void mergeScaleDependencies( int mScaleMinDenom, int mScaleMaxDenom, QgsStringMap& props );

};
3 changes: 2 additions & 1 deletion python/core/symbology-ng/qgssymbolv2.sip
Expand Up @@ -152,7 +152,8 @@ class QgsSymbolV2

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

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

OutputUnit outputUnit() const;
void setOutputUnit( OutputUnit u );
Expand Down
1 change: 1 addition & 0 deletions python/core/symbology-ng/qgsvectorfieldsymbollayer.sip
Expand Up @@ -44,6 +44,7 @@ class QgsVectorFieldSymbolLayer : QgsMarkerSymbolLayerV2
virtual QgsVectorFieldSymbolLayer* clone() const /Factory/;
QgsStringMap properties() const;

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

void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
Expand Down

0 comments on commit 282dfbc

Please sign in to comment.