Skip to content

Commit bbc5fdc

Browse files
author
mhugent
committed
Use a DPI parameter in the WMS request. This allows printing with QGIS from QGIS mapserver (and is ignored by the other WMS servers)
git-svn-id: http://svn.osgeo.org/qgis/trunk@10885 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent bfc3b6c commit bbc5fdc

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

python/core/qgsrasterdataprovider.sip

+8
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ public:
120120
*/
121121
virtual QString lastError() = 0;
122122

123+
/**Returns the dpi of the output device.
124+
@note: this method was added in version 1.2*/
125+
int dpi();
126+
127+
/**Sets the output device resolution.
128+
@note: this method was added in version 1.2*/
129+
void setDpi(int dpi);
130+
123131

124132
protected:
125133

src/core/qgsrasterdataprovider.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
#include "qgsrasterdataprovider.h"
2020
#include "qgslogger.h"
2121

22-
QgsRasterDataProvider::QgsRasterDataProvider()
22+
QgsRasterDataProvider::QgsRasterDataProvider(): mDpi(-1)
2323
{
2424
}
2525

2626

2727
QgsRasterDataProvider::QgsRasterDataProvider( QString const & uri )
28-
: QgsDataProvider( uri )
28+
: QgsDataProvider( uri ), mDpi(-1)
2929
{
3030
}
3131

src/core/qgsrasterdataprovider.h

+12
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,20 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
152152
*/
153153
virtual QString lastError() = 0;
154154

155+
/**Returns the dpi of the output device.
156+
@note: this method was added in version 1.2*/
157+
int dpi() const {return mDpi;}
158+
159+
/**Sets the output device resolution.
160+
@note: this method was added in version 1.2*/
161+
void setDpi(int dpi){mDpi = dpi;}
162+
155163

156164
protected:
165+
/**Dots per intch. Extended WMS (e.g. QGIS mapserver) support DPI dependent output and therefore
166+
are suited for printing. A value of -1 means it has not been set
167+
@note: this member has been added in version 1.2*/
168+
int mDpi;
157169

158170
};
159171

src/providers/wms/qgswmsprovider.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,12 @@ QImage* QgsWmsProvider::draw( QgsRectangle const & viewExtent, int pixelWidth,
454454
url += "&";
455455
url += "FORMAT=" + imageMimeType;
456456

457+
//DPI parameter is accepted by QGIS mapserver (and ignored by the other WMS servers)
458+
if(mDpi != -1)
459+
{
460+
url += "&DPI=" + QString::number(mDpi);
461+
}
462+
457463
//MH: jpeg does not support transparency and some servers complain if jpg and transparent=true
458464
if ( !imageMimeType.contains( "jpeg", Qt::CaseInsensitive ) && !imageMimeType.contains( "jpg", Qt::CaseInsensitive ) )
459465
{

0 commit comments

Comments
 (0)