Skip to content
Permalink
Browse files
Use a DPI parameter in the WMS request. This allows printing with QGI…
…S 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
  • Loading branch information
mhugent committed Jun 5, 2009
1 parent bfc3b6c commit bbc5fdc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
@@ -120,6 +120,14 @@ public:
*/
virtual QString lastError() = 0;

/**Returns the dpi of the output device.
@note: this method was added in version 1.2*/
int dpi();

/**Sets the output device resolution.
@note: this method was added in version 1.2*/
void setDpi(int dpi);


protected:

@@ -19,13 +19,13 @@
#include "qgsrasterdataprovider.h"
#include "qgslogger.h"

QgsRasterDataProvider::QgsRasterDataProvider()
QgsRasterDataProvider::QgsRasterDataProvider(): mDpi(-1)
{
}


QgsRasterDataProvider::QgsRasterDataProvider( QString const & uri )
: QgsDataProvider( uri )
: QgsDataProvider( uri ), mDpi(-1)
{
}

@@ -152,8 +152,20 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
*/
virtual QString lastError() = 0;

/**Returns the dpi of the output device.
@note: this method was added in version 1.2*/
int dpi() const {return mDpi;}

/**Sets the output device resolution.
@note: this method was added in version 1.2*/
void setDpi(int dpi){mDpi = dpi;}


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

};

@@ -454,6 +454,12 @@ QImage* QgsWmsProvider::draw( QgsRectangle const & viewExtent, int pixelWidth,
url += "&";
url += "FORMAT=" + imageMimeType;

//DPI parameter is accepted by QGIS mapserver (and ignored by the other WMS servers)
if(mDpi != -1)
{
url += "&DPI=" + QString::number(mDpi);
}

//MH: jpeg does not support transparency and some servers complain if jpg and transparent=true
if ( !imageMimeType.contains( "jpeg", Qt::CaseInsensitive ) && !imageMimeType.contains( "jpg", Qt::CaseInsensitive ) )
{

0 comments on commit bbc5fdc

Please sign in to comment.