Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
apply #3768: tile WMS getmap requests by limiting the size
  • Loading branch information
jef-n committed May 4, 2011
1 parent 5794256 commit d508f56
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 34 deletions.
18 changes: 14 additions & 4 deletions src/app/qgswmssourceselect.cpp
Expand Up @@ -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
{
Expand All @@ -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 + "," );
Expand Down
28 changes: 17 additions & 11 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -2136,7 +2142,7 @@ bool QgsWmsProvider::calculateExtent()
return false;
}

if ( mTiled )
if ( mTiled && mResolutions.size() > 0 )
{
QString layers = activeSubLayers.join( "," );
QString styles = activeSubStyles.join( "," );
Expand Down
60 changes: 41 additions & 19 deletions src/ui/qgswmssourceselectbase.ui
Expand Up @@ -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">
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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">
Expand Down

0 comments on commit d508f56

Please sign in to comment.