Skip to content

Commit

Permalink
Use a DPI parameter in the WMS request. This allows printing with QGI…
Browse files Browse the repository at this point in the history
…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.
8 changes: 8 additions & 0 deletions python/core/qgsrasterdataprovider.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsrasterdataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
12 changes: 12 additions & 0 deletions src/core/qgsrasterdataprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

};

Expand Down
6 changes: 6 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
{
Expand Down

0 comments on commit bbc5fdc

Please sign in to comment.