Skip to content
Permalink
Browse files

apply #3768: tile WMS getmap requests by limiting the size

  • Loading branch information
jef-n committed May 4, 2011
1 parent 5794256 commit d508f56aa1640ccf9ac6e7373090ceacefbfcaf9
Showing with 72 additions and 34 deletions.
  1. +14 −4 src/app/qgswmssourceselect.cpp
  2. +17 −11 src/providers/wms/qgswmsprovider.cpp
  3. +41 −19 src/ui/qgswmssourceselectbase.ui
@@ -511,11 +511,18 @@ void QgsWMSSourceSelect::addClicked()
QString crs;
QString connInfo = connectionInfo();

QString connArgs;

if ( lstTilesets->selectedItems().isEmpty() )
{
collectSelectedLayers( layers, styles );
crs = mCRS;
format = mFormats[ mImageFormatGroup->checkedId()];

if ( mTileWidth->text().toInt() > 0 && mTileHeight->text().toInt() > 0 )
{
connArgs = QString( "tiled=%1;%2" ).arg( mTileWidth->text().toInt() ).arg( mTileHeight->text().toInt() );
}
}
else
{
@@ -525,11 +532,14 @@ void QgsWMSSourceSelect::addClicked()
format = item->data( Qt::UserRole + 2 ).toString();
crs = item->data( Qt::UserRole + 3 ).toString();

QString connArgs = QString( "tiled=%1;%2;%3" )
.arg( item->data( Qt::UserRole + 4 ).toInt() )
.arg( item->data( Qt::UserRole + 5 ).toInt() )
.arg( item->data( Qt::UserRole + 6 ).toStringList().join( ";" ) );
connArgs = QString( "tiled=%1;%2;%3" )
.arg( item->data( Qt::UserRole + 4 ).toInt() )
.arg( item->data( Qt::UserRole + 5 ).toInt() )
.arg( item->data( Qt::UserRole + 6 ).toStringList().join( ";" ) );
}

if ( !connArgs.isEmpty() )
{
if ( connInfo.startsWith( "username=" ) || connInfo.startsWith( "ignoreUrl=" ) )
{
connInfo.prepend( connArgs + "," );
@@ -545,21 +545,27 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
else
{
mTileReqNo++;

double vres = viewExtent.width() / pixelWidth;

// find nearest resolution
double tres = vres;
int i;
for ( i = 0; i < mResolutions.size() && mResolutions[i] < vres; i++ )
QgsDebugMsg( QString( "skipped res: %1:%2" ).arg( i ).arg( mResolutions[i] ) );

if ( i == mResolutions.size() ||
( i > 0 && vres - mResolutions[i-1] < mResolutions[i] - vres ) )
if ( mResolutions.size() > 0 )
{
QgsDebugMsg( "back to previous res" );
i--;
}

double tres = mResolutions[i];
// find nearest resolution
for ( i = 0; i < mResolutions.size() && mResolutions[i] < vres; i++ )
QgsDebugMsg( QString( "skipped res: %1:%2" ).arg( i ).arg( mResolutions[i] ) );

if ( i == mResolutions.size() ||
( i > 0 && vres - mResolutions[i-1] < mResolutions[i] - vres ) )
{
QgsDebugMsg( "back to previous res" );
i--;
}

tres = mResolutions[i];
}

// clip view extent to layer extent
double xmin = qMax( viewExtent.xMinimum(), layerExtent.xMinimum() );
@@ -2136,7 +2142,7 @@ bool QgsWmsProvider::calculateExtent()
return false;
}

if ( mTiled )
if ( mTiled && mResolutions.size() > 0 )
{
QString layers = activeSubLayers.join( "," );
QString styles = activeSubStyles.join( "," );
@@ -182,6 +182,24 @@
<property name="title">
<string>Image encoding</string>
</property>
<zorder>gbCRS</zorder>
</widget>
</item>
<item row="1" column="9">
<widget class="QPushButton" name="btnSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QPushButton" name="btnLoad">
<property name="toolTip">
<string>Load connections from file</string>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="12">
@@ -203,7 +221,7 @@
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="leLayerName"/>
</item>
<item row="1" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="labelCoordRefSys">
<property name="text">
<string>Coordinate Reference System</string>
@@ -213,7 +231,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="2" column="2">
<widget class="QPushButton" name="btnChangeSpatialRefSys">
<property name="enabled">
<bool>false</bool>
@@ -223,26 +241,30 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mTileWidth">
<property name="inputMask">
<string>9999; </string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tile size</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="mTileHeight">
<property name="inputMask">
<string>9999; </string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="9">
<widget class="QPushButton" name="btnSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QPushButton" name="btnLoad">
<property name="toolTip">
<string>Load connections from file</string>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabLayerOrder">

0 comments on commit d508f56

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