Skip to content
Permalink
Browse files

Always use full precision when exporting to SLD (fix #15176)

  • Loading branch information
nyalldawson committed Jun 29, 2016
1 parent e95a8a9 commit b49ada283d7e1074b6809877cc089e43c4fa79d5
@@ -2268,7 +2268,7 @@ QDomElement QgsOgcUtilsExprToFilter::expressionLiteralToOgcFilter( const QgsExpr
value = QString::number( node->value().toInt() );
break;
case QVariant::Double:
value = QString::number( node->value().toDouble() );
value = qgsDoubleToString( node->value().toDouble() );
break;
case QVariant::String:
value = node->value().toString();
@@ -2713,7 +2713,7 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
value = QString::number( node->value().toLongLong() );
break;
case QVariant::Double:
value = QString::number( node->value().toDouble() );
value = qgsDoubleToString( node->value().toDouble() );
break;
case QVariant::String:
value = node->value().toString();
@@ -3128,7 +3128,7 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
distance = QString::number( lit->value().toLongLong() );
break;
case QVariant::Double:
distance = QString::number( lit->value().toDouble() );
distance = qgsDoubleToString( lit->value().toDouble() );
break;
case QVariant::String:
{
@@ -3306,7 +3306,7 @@ void QgsPointPatternFillSymbolLayer::toSld( QDomDocument &doc, QDomElement &elem
fillElem.appendChild( graphicFillElem );

// store distanceX, distanceY, displacementX, displacementY in a <VendorOption>
QString dist = QgsSymbolLayerV2Utils::encodePoint( QPointF( mDistanceX, mDistanceY ) );
QString dist = QgsSymbolLayerV2Utils::encodePoint( QPointF( mDistanceX, mDistanceY ) );
QDomElement distanceElem = QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "distance", dist );
symbolizerElem.appendChild( distanceElem );

@@ -157,15 +157,16 @@ void QgsRendererRangeV2::toSld( QDomDocument &doc, QDomElement &element, QgsStri

QDomElement descrElem = doc.createElement( "se:Description" );
QDomElement titleElem = doc.createElement( "se:Title" );
QString descrStr = QString( "range: %1 - %2" ).arg( mLowerValue ).arg( mUpperValue );
QString descrStr = QString( "range: %1 - %2" ).arg( qgsDoubleToString( mLowerValue ), qgsDoubleToString( mUpperValue ) );
titleElem.appendChild( doc.createTextNode( !mLabel.isEmpty() ? mLabel : descrStr ) );
descrElem.appendChild( titleElem );
ruleElem.appendChild( descrElem );

// create the ogc:Filter for the range
QString filterFunc = QString( "%1 > %2 AND %1 <= %3" )
.arg( attrName.replace( '\"', "\"\"" ) )
.arg( mLowerValue ).arg( mUpperValue );
.arg( attrName.replace( '\"', "\"\"" ),
qgsDoubleToString( mLowerValue ),
qgsDoubleToString( mUpperValue ) );
QgsSymbolLayerV2Utils::createFunctionElement( doc, ruleElem, filterFunc );

mSymbol->toSld( doc, ruleElem, props );
@@ -417,7 +417,7 @@ void QgsSimpleLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
if ( !qgsDoubleNear( mOffset, 0.0 ) )
{
QDomElement perpOffsetElem = doc.createElement( "se:PerpendicularOffset" );
perpOffsetElem.appendChild( doc.createTextNode( QString::number( mOffset ) ) );
perpOffsetElem.appendChild( doc.createTextNode( qgsDoubleToString( mOffset ) ) );
symbolizerElem.appendChild( perpOffsetElem );
}
}
@@ -1413,7 +1413,7 @@ void QgsMarkerLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "points" ) );
break;
default:
gap = QString::number( mInterval );
gap = qgsDoubleToString( mInterval );
break;
}

@@ -1453,7 +1453,7 @@ void QgsMarkerLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
if ( !qgsDoubleNear( mOffset, 0.0 ) )
{
QDomElement perpOffsetElem = doc.createElement( "se:PerpendicularOffset" );
perpOffsetElem.appendChild( doc.createTextNode( QString::number( mOffset ) ) );
perpOffsetElem.appendChild( doc.createTextNode( qgsDoubleToString( mOffset ) ) );
symbolizerElem.appendChild( perpOffsetElem );
}
}
@@ -366,7 +366,7 @@ Qt::BrushStyle QgsSymbolLayerV2Utils::decodeSldBrushStyle( const QString& str )

QString QgsSymbolLayerV2Utils::encodePoint( QPointF point )
{
return QString( "%1,%2" ).arg( point.x() ).arg( point.y() );
return QString( "%1,%2" ).arg( qgsDoubleToString( point.x() ), qgsDoubleToString( point.y() ) );
}

QPointF QgsSymbolLayerV2Utils::decodePoint( const QString& str )
@@ -379,7 +379,8 @@ QPointF QgsSymbolLayerV2Utils::decodePoint( const QString& str )

QString QgsSymbolLayerV2Utils::encodeMapUnitScale( const QgsMapUnitScale& mapUnitScale )
{
return QString( "%1,%2,%3,%4,%5,%6" ).arg( mapUnitScale.minScale ).arg( mapUnitScale.maxScale )
return QString( "%1,%2,%3,%4,%5,%6" ).arg( qgsDoubleToString( mapUnitScale.minScale ),
qgsDoubleToString( mapUnitScale.maxScale ) )
.arg( mapUnitScale.minSizeMMEnabled ? 1 : 0 )
.arg( mapUnitScale.minSizeMM )
.arg( mapUnitScale.maxSizeMMEnabled ? 1 : 0 )
@@ -1939,7 +1940,7 @@ void QgsSymbolLayerV2Utils::lineToSld( QDomDocument &doc, QDomElement &element,
element.appendChild( createSvgParameterElement( doc, "stroke-opacity", encodeSldAlpha( color.alpha() ) ) );
}
if ( width > 0 )
element.appendChild( createSvgParameterElement( doc, "stroke-width", QString::number( width ) ) );
element.appendChild( createSvgParameterElement( doc, "stroke-width", qgsDoubleToString( width ) ) );
if ( penJoinStyle )
element.appendChild( createSvgParameterElement( doc, "stroke-linejoin", encodeSldLineJoinStyle( *penJoinStyle ) ) );
if ( penCapStyle )
@@ -1949,7 +1950,7 @@ void QgsSymbolLayerV2Utils::lineToSld( QDomDocument &doc, QDomElement &element,
{
element.appendChild( createSvgParameterElement( doc, "stroke-dasharray", encodeSldRealVector( *pattern ) ) );
if ( !qgsDoubleNear( dashOffset, 0.0 ) )
element.appendChild( createSvgParameterElement( doc, "stroke-dashoffset", QString::number( dashOffset ) ) );
element.appendChild( createSvgParameterElement( doc, "stroke-dashoffset", qgsDoubleToString( dashOffset ) ) );
}
}

@@ -2100,7 +2101,7 @@ void QgsSymbolLayerV2Utils::externalGraphicToSld( QDomDocument &doc, QDomElement
if ( size >= 0 )
{
QDomElement sizeElem = doc.createElement( "se:Size" );
sizeElem.appendChild( doc.createTextNode( QString::number( size ) ) );
sizeElem.appendChild( doc.createTextNode( qgsDoubleToString( size ) ) );
element.appendChild( sizeElem );
}
}
@@ -2155,7 +2156,7 @@ void QgsSymbolLayerV2Utils::externalMarkerToSld( QDomDocument &doc, QDomElement
if ( !qgsDoubleNear( size, 0.0 ) && size > 0 )
{
QDomElement sizeElem = doc.createElement( "se:Size" );
sizeElem.appendChild( doc.createTextNode( QString::number( size ) ) );
sizeElem.appendChild( doc.createTextNode( qgsDoubleToString( size ) ) );
element.appendChild( sizeElem );
}
}
@@ -2242,7 +2243,7 @@ void QgsSymbolLayerV2Utils::wellKnownMarkerToSld( QDomDocument &doc, QDomElement
if ( !qgsDoubleNear( size, 0.0 ) && size > 0 )
{
QDomElement sizeElem = doc.createElement( "se:Size" );
sizeElem.appendChild( doc.createTextNode( QString::number( size ) ) );
sizeElem.appendChild( doc.createTextNode( qgsDoubleToString( size ) ) );
element.appendChild( sizeElem );
}
}
@@ -2352,10 +2353,10 @@ void QgsSymbolLayerV2Utils::createDisplacementElement( QDomDocument &doc, QDomEl
element.appendChild( displacementElem );

QDomElement dispXElem = doc.createElement( "se:DisplacementX" );
dispXElem.appendChild( doc.createTextNode( QString::number( offset.x() ) ) );
dispXElem.appendChild( doc.createTextNode( qgsDoubleToString( offset.x() ) ) );

QDomElement dispYElem = doc.createElement( "se:DisplacementY" );
dispYElem.appendChild( doc.createTextNode( QString::number( offset.y() ) ) );
dispYElem.appendChild( doc.createTextNode( qgsDoubleToString( offset.y() ) ) );

displacementElem.appendChild( dispXElem );
displacementElem.appendChild( dispYElem );
@@ -629,7 +629,7 @@ void QgsSymbolV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap p
props[ "alpha" ] = QString::number( alpha() );
double scaleFactor = 1.0;
props[ "uom" ] = QgsSymbolLayerV2Utils::encodeSldUom( outputUnit(), &scaleFactor );
props[ "uomScale" ] = ( !qgsDoubleNear( scaleFactor, 1.0 ) ? QString::number( scaleFactor ) : "" );
props[ "uomScale" ] = ( !qgsDoubleNear( scaleFactor, 1.0 ) ? qgsDoubleToString( scaleFactor ) : "" );

for ( QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it )
{

0 comments on commit b49ada2

Please sign in to comment.
You can’t perform that action at this time.