Skip to content

Commit

Permalink
Fix cherry-pickings
Browse files Browse the repository at this point in the history
Do not generate a ogc:Filter where a ogc:Expression is expected. #3366
Emit valid SLD when mm are used as symbol unit #3414
Export map level scale based dependencies in most vector symbology #3436
  • Loading branch information
rldhont committed Oct 1, 2016
1 parent 5297df7 commit 4aef2db
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 69 deletions.
8 changes: 0 additions & 8 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,6 @@ class QgsVectorLayer : QgsMapLayer
*/
bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;

/** Write just the style information for the layer into the document
* @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
* @return true in case of success.
*/
bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;

bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage, QgsStringMap& props ) const;
bool readSld( const QDomNode& node, QString& errorMessage );

Expand Down
6 changes: 3 additions & 3 deletions python/core/symbology-ng/qgssymbollayerv2utils.sip
Original file line number Diff line number Diff line change
Expand Up @@ -417,19 +417,19 @@ class QgsSymbolLayerV2Utils
* returns the value un-modified
* @note added in 3.0
*/
static double rescaleUom( double size, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props );
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 3.0
*/
static QPointF rescaleUom( const QPointF& point, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props ) /PyName=rescalePointUom/;
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 3.0
*/
static QVector<qreal> rescaleUom( const QVector<qreal>& array, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props ) /PyName=rescaleArrayUom/;
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
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@ bool QgsVectorLayer::writeSld( QDomNode& node, QDomDocument& doc, QString& error
QgsStringMap localProps = QgsStringMap( props );
if ( hasScaleBasedVisibility() )
{
QgsSymbolLayerUtils::mergeScaleDependencies( minimumScale(), maximumScale(), localProps );
QgsSymbolLayerV2Utils::mergeScaleDependencies( minimumScale(), maximumScale(), localProps );
}

if ( hasGeometryType() )
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void QgsRendererCategoryV2::toSld( QDomDocument &doc, QDomElement &element, QgsS
QgsSymbolLayerV2Utils::createFunctionElement( doc, ruleElem, filterFunc );

// add the mix/max scale denoms if we got any from the callers
QgsSymbolLayerUtils::applyScaleDependency( doc, ruleElem, props );
QgsSymbolLayerV2Utils::applyScaleDependency( doc, ruleElem, props );

mSymbol->toSld( doc, ruleElem, props );
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ void QgsSimpleMarkerSymbolLayerV2::writeSldMarker( QDomDocument &doc, QDomElemen

double outlineWidth = QgsSymbolLayerV2Utils::rescaleUom( mOutlineWidth, mOutlineWidthUnit, props );
double size = QgsSymbolLayerV2Utils::rescaleUom( mSize, mSizeUnit, props );
QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, encodeShape( mShape ), mColor, mBorderColor, mOutlineStyle, outlineWidth, size );
QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, mName, mColor, mBorderColor, mOutlineStyle, outlineWidth, size );

// <Rotation>
QString angleFunc;
Expand Down Expand Up @@ -2144,7 +2144,6 @@ void QgsFontMarkerSymbolLayerV2::writeSldMarker( QDomDocument &doc, QDomElement

QString fontPath = QString( "ttf://%1" ).arg( mFontFamily );
int markIndex = mChr.unicode();
QgsSymbolLayerV2Utils::externalMarkerToSld( doc, graphicElem, fontPath, "ttf", &markIndex, mColor, mSize );
double size = QgsSymbolLayerV2Utils::rescaleUom( mSize, mSizeUnit, props );
QgsSymbolLayerV2Utils::externalMarkerToSld( doc, graphicElem, fontPath, "ttf", &markIndex, mColor, size );

Expand Down
10 changes: 3 additions & 7 deletions src/core/symbology-ng/qgsrulebasedrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void QgsRuleBasedRendererV2::Rule::toSld( QDomDocument& doc, QDomElement &elemen
props[ "filter" ] += mFilterExp;
}

QgsSymbolLayerUtils::mergeScaleDependencies( mScaleMinDenom, mScaleMaxDenom, props );
QgsSymbolLayerV2Utils::mergeScaleDependencies( mScaleMinDenom, mScaleMaxDenom, props );

if ( mSymbol )
{
Expand Down Expand Up @@ -370,7 +370,7 @@ void QgsRuleBasedRendererV2::Rule::toSld( QDomDocument& doc, QDomElement &elemen
QgsSymbolLayerV2Utils::createFunctionElement( doc, ruleElem, props.value( "filter", "" ) );
}

QgsSymbolLayerUtils::applyScaleDependency( doc, ruleElem, props );
QgsSymbolLayerV2Utils::applyScaleDependency( doc, ruleElem, props );

mSymbol->toSld( doc, ruleElem, props );
}
Expand Down Expand Up @@ -927,11 +927,7 @@ QgsRuleBasedRendererV2* QgsRuleBasedRendererV2::clone() const
return r;
}

<<<<<<< HEAD:src/core/symbology-ng/qgsrulebasedrendererv2.cpp
void QgsRuleBasedRendererV2::toSld( QDomDocument& doc, QDomElement &element ) const
=======
void QgsRuleBasedRenderer::toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const
>>>>>>> a25b025... Export map level scale based dependencies in most vector symbology:src/core/symbology-ng/qgsrulebasedrenderer.cpp
void QgsRuleBasedRendererV2::toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const
{
mRootRule->toSld( doc, element, props );
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgssinglesymbolrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void QgsSingleSymbolRendererV2::toSld( QDomDocument& doc, QDomElement &element,
nameElem.appendChild( doc.createTextNode( "Single symbol" ) );
ruleElem.appendChild( nameElem );

QgsSymbolLayerUtils::applyScaleDependency( doc, ruleElem, props );
QgsSymbolLayerV2Utils::applyScaleDependency( doc, ruleElem, props );

if ( mSymbol.data() ) mSymbol->toSld( doc, ruleElem, props );
}
Expand Down
18 changes: 9 additions & 9 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4044,11 +4044,11 @@ QList<double> QgsSymbolLayerV2Utils::prettyBreaks( double minimum, double maximu
return breaks;
}

double QgsSymbolLayerV2Utils::rescaleUom( double size, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props )
double QgsSymbolLayerV2Utils::rescaleUom( double size, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props )
{
double scale = 1;
bool roundToUnit = false;
if ( unit == QgsUnitTypes::RenderUnknownUnit )
if ( unit == QgsSymbolV2::Mixed )
{
if ( props.contains( "uomScale" ) )
{
Expand All @@ -4066,10 +4066,10 @@ double QgsSymbolLayerV2Utils::rescaleUom( double size, QgsUnitTypes::RenderUnit
{
switch ( unit )
{
case QgsUnitTypes::RenderMillimeters:
case QgsSymbolV2::MM:
scale = 0.001;
break;
case QgsUnitTypes::RenderPixels:
case QgsSymbolV2::Pixel:
scale = 0.00028;
roundToUnit = true;
break;
Expand All @@ -4082,7 +4082,7 @@ double QgsSymbolLayerV2Utils::rescaleUom( double size, QgsUnitTypes::RenderUnit
// target is pixels
switch ( unit )
{
case QgsUnitTypes::RenderMillimeters:
case QgsSymbolV2::MM:
scale = 1 / 0.28;
roundToUnit = true;
break;
Expand All @@ -4103,14 +4103,14 @@ double QgsSymbolLayerV2Utils::rescaleUom( double size, QgsUnitTypes::RenderUnit
return rescaled;
}

QPointF QgsSymbolLayerV2Utils::rescaleUom( const QPointF& point, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props )
QPointF QgsSymbolLayerV2Utils::rescaleUom( const QPointF& point, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props )
{
double x = rescaleUom( point.x(), unit, props );
double y = rescaleUom( point.y(), unit, props );
return QPointF( x, y );
}

QVector<qreal> QgsSymbolLayerV2Utils::rescaleUom( const QVector<qreal>& array, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props )
QVector<qreal> QgsSymbolLayerV2Utils::rescaleUom( const QVector<qreal>& array, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props )
{
QVector<qreal> result;
QVector<qreal>::const_iterator it = array.constBegin();
Expand All @@ -4121,7 +4121,7 @@ QVector<qreal> QgsSymbolLayerV2Utils::rescaleUom( const QVector<qreal>& array, Q
return result;
}

void QgsSymbolLayerUtils::applyScaleDependency( QDomDocument& doc, QDomElement& ruleElem, QgsStringMap& props )
void QgsSymbolLayerV2Utils::applyScaleDependency( QDomDocument& doc, QDomElement& ruleElem, QgsStringMap& props )
{
if ( !props.value( "scaleMinDenom", "" ).isEmpty() )
{
Expand All @@ -4138,7 +4138,7 @@ void QgsSymbolLayerUtils::applyScaleDependency( QDomDocument& doc, QDomElement&
}
}

void QgsSymbolLayerUtils::mergeScaleDependencies( int mScaleMinDenom, int mScaleMaxDenom, QgsStringMap& props )
void QgsSymbolLayerV2Utils::mergeScaleDependencies( int mScaleMinDenom, int mScaleMaxDenom, QgsStringMap& props )
{
if ( mScaleMinDenom != 0 )
{
Expand Down
6 changes: 3 additions & 3 deletions src/core/symbology-ng/qgssymbollayerv2utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,19 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
* returns the value un-modified
* @note added in 3.0
*/
static double rescaleUom( double size, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props );
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 3.0
*/
static QPointF rescaleUom( const QPointF& point, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props );
static QPointF rescaleUom( const QPointF& point, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props );

/** 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 3.0
*/
static QVector<qreal> rescaleUom( const QVector<qreal>& array, QgsUnitTypes::RenderUnit unit, const QgsStringMap& props );
static QVector<qreal> rescaleUom( const QVector<qreal>& array, QgsSymbolV2::OutputUnit unit, const QgsStringMap& props );

/**
* Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into the SE Rule element
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ADD_PYTHON_TEST(PyQgsOGRProvider test_provider_ogr.py)
ADD_PYTHON_TEST(PyQgsSpatialIndex test_qgsspatialindex.py)
ADD_PYTHON_TEST(PyQgsSpatialiteProvider test_provider_spatialite.py)
ADD_PYTHON_TEST(PyQgsSymbolLayerV2 test_qgssymbollayerv2.py)
ADD_PYTHON_TEST(PyQgsSymbolLayerCreateSld test_qgssymbollayer_createsld.py)
ADD_PYTHON_TEST(PyQgsSymbolLayerV2CreateSld test_qgssymbollayerv2_createsld.py)
ADD_PYTHON_TEST(PyQgsSymbolExpressionVariables test_qgssymbolexpressionvariables.py)
ADD_PYTHON_TEST(PyQgsSyntacticSugar test_syntactic_sugar.py)
ADD_PYTHON_TEST(PyQgsSymbolV2 test_qgssymbolv2.py)
Expand Down
Loading

0 comments on commit 4aef2db

Please sign in to comment.