Skip to content
Permalink
Browse files
Merge pull request #893 from sbrunner/scalehint
Fix Scales in qgis server
  • Loading branch information
mhugent committed Sep 15, 2013
2 parents 64c947b + 617fa68 commit 017f8f27d83576549c58dc78281ce3c6e487bde8
Showing with 13 additions and 8 deletions.
  1. +8 −5 src/mapserver/qgsprojectparser.cpp
  2. +5 −3 src/mapserver/qgswmsserver.cpp
@@ -772,22 +772,25 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
//min/max scale denominatormScaleBasedVisibility
if ( currentLayer->hasScaleBasedVisibility() )
{
QString minScaleString = QString::number( currentLayer->minimumScale() );
QString maxScaleString = QString::number( currentLayer->maximumScale() );

if ( version == "1.1.1" )
{
double OGC_PX_M = 0.00028; // OGC referance pixel size in meter, also used by qgis
double SCALE_TO_SCALEHINT = OGC_PX_M * sqrt( 2 );

QDomElement scaleHintElem = doc.createElement( "ScaleHint" );
scaleHintElem.setAttribute( "min", minScaleString );
scaleHintElem.setAttribute( "max", maxScaleString );
scaleHintElem.setAttribute( "min", QString::number( currentLayer->minimumScale() * SCALE_TO_SCALEHINT ) );
scaleHintElem.setAttribute( "max", QString::number( currentLayer->maximumScale() * SCALE_TO_SCALEHINT ) );
layerElem.appendChild( scaleHintElem );
}
else
{
QString minScaleString = QString::number( currentLayer->minimumScale() );
QDomElement minScaleElem = doc.createElement( "MinScaleDenominator" );
QDomText minScaleText = doc.createTextNode( minScaleString );
minScaleElem.appendChild( minScaleText );
layerElem.appendChild( minScaleElem );

QString maxScaleString = QString::number( currentLayer->maximumScale() );
QDomElement maxScaleElem = doc.createElement( "MaxScaleDenominator" );
QDomText maxScaleText = doc.createTextNode( maxScaleString );
maxScaleElem.appendChild( maxScaleText );
@@ -1109,16 +1109,18 @@ QImage* QgsWMSServer::createImage( int width, int height ) const

//apply DPI parameter if present. This is an extension of QGIS mapserver compared to WMS 1.3.
//Because of backwards compatibility, this parameter is optional
double OGC_PX_M = 0.00028; // OGC referance pixel size in meter, also used by qgis
int dpm = 1 / OGC_PX_M;
if ( mParameterMap.contains( "DPI" ) )
{
int dpi = mParameterMap[ "DPI" ].toInt( &conversionSuccess );
if ( conversionSuccess )
{
int dpm = dpi / 0.0254;
theImage->setDotsPerMeterX( dpm );
theImage->setDotsPerMeterY( dpm );
dpm = dpi / 0.0254;
}
}
theImage->setDotsPerMeterX( dpm );
theImage->setDotsPerMeterY( dpm );
return theImage;
}

0 comments on commit 017f8f2

Please sign in to comment.