@@ -564,7 +564,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
564
564
QSettings s;
565
565
bool bkLayerCaching = s.value ( " /qgis/enable_render_caching" , false ).toBool ();
566
566
567
- if ( !mTiled )
567
+ if ( !mTiled && ! mMaxWidth && ! mMaxHeight )
568
568
{
569
569
// Calculate active layers that are also visible.
570
570
@@ -655,33 +655,53 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
655
655
{
656
656
mTileReqNo ++;
657
657
658
- Q_ASSERT ( mTileLayer );
659
- Q_ASSERT ( mTileMatrixSet );
660
- Q_ASSERT ( mTileMatrixSet ->tileMatrices .size () > 0 );
661
-
662
658
double vres = viewExtent.width () / pixelWidth;
663
659
double tres = vres;
664
660
665
- QMap<double , QgsWmtsTileMatrix> &m = mTileMatrixSet ->tileMatrices ;
661
+ const QgsWmtsTileMatrix *tm = 0 ;
662
+ enum QgsTileMode tileMode;
666
663
667
- // find nearest resolution
668
- QMap<double , QgsWmtsTileMatrix>::const_iterator prev, it = m.constBegin ();
669
- while ( it != m.constEnd () && it.key () < vres )
664
+ if ( mTiled )
670
665
{
671
- QgsDebugMsg ( QString ( " res:%1 >= %2" ).arg ( it.key () ).arg ( vres ) );
672
- prev = it;
673
- it++;
674
- }
666
+ Q_ASSERT ( mTileLayer );
667
+ Q_ASSERT ( mTileMatrixSet );
668
+ Q_ASSERT ( mTileMatrixSet ->tileMatrices .size () > 0 );
675
669
676
- if ( it == m.constEnd () ||
677
- ( it != m.constBegin () && vres - prev.key () < it.key () - vres ) )
678
- {
679
- QgsDebugMsg ( " back to previous res" );
680
- it = prev;
670
+ QMap<double , QgsWmtsTileMatrix> &m = mTileMatrixSet ->tileMatrices ;
671
+
672
+ // find nearest resolution
673
+ QMap<double , QgsWmtsTileMatrix>::const_iterator prev, it = m.constBegin ();
674
+ while ( it != m.constEnd () && it.key () < vres )
675
+ {
676
+ QgsDebugMsg ( QString ( " res:%1 >= %2" ).arg ( it.key () ).arg ( vres ) );
677
+ prev = it;
678
+ it++;
679
+ }
680
+
681
+ if ( it == m.constEnd () ||
682
+ ( it != m.constBegin () && vres - prev.key () < it.key () - vres ) )
683
+ {
684
+ QgsDebugMsg ( " back to previous res" );
685
+ it = prev;
686
+ }
687
+
688
+ tres = it.key ();
689
+ tm = &it.value ();
690
+
691
+ tileMode = mTileLayer ->tileMode ;
681
692
}
693
+ else
694
+ {
695
+ static QgsWmtsTileMatrix tempTm;
696
+ tempTm.topLeft = QgsPoint ( mLayerExtent .xMinimum (), mLayerExtent .yMaximum () );
697
+ tempTm.tileWidth = mMaxWidth ;
698
+ tempTm.tileHeight = mMaxHeight ;
699
+ tempTm.matrixWidth = ceil ( mLayerExtent .width () / mMaxWidth / vres );
700
+ tempTm.matrixHeight = ceil ( mLayerExtent .height () / mMaxHeight / vres );
701
+ tm = &tempTm;
682
702
683
- tres = it. key () ;
684
- const QgsWmtsTileMatrix *tm = &it. value ();
703
+ tileMode = WMSC ;
704
+ }
685
705
686
706
QgsDebugMsg ( QString ( " layer extent: %1,%2 %3x%4" )
687
707
.arg ( mLayerExtent .xMinimum (), 0 , ' f' )
@@ -715,7 +735,9 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
715
735
int minTileRow = 0 ;
716
736
int maxTileRow = tm->matrixHeight - 1 ;
717
737
718
- if ( mTileLayer ->setLinks .contains ( mTileMatrixSet ->identifier ) &&
738
+
739
+ if ( mTileLayer &&
740
+ mTileLayer ->setLinks .contains ( mTileMatrixSet ->identifier ) &&
719
741
mTileLayer ->setLinks [ mTileMatrixSet ->identifier ].limits .contains ( tm->identifier ) )
720
742
{
721
743
const QgsWmtsTileMatrixLimits &tml = mTileLayer ->setLinks [ mTileMatrixSet ->identifier ].limits [ tm->identifier ];
@@ -745,7 +767,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
745
767
}
746
768
#endif
747
769
748
- switch ( mTileLayer -> tileMode )
770
+ switch ( tileMode )
749
771
{
750
772
case WMSC:
751
773
{
@@ -760,7 +782,8 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
760
782
setQueryItem ( url, " STYLES" , mActiveSubStyles .join ( " ," ) );
761
783
setQueryItem ( url, " FORMAT" , mImageMimeType );
762
784
setQueryItem ( url, crsKey, mImageCrs );
763
- setQueryItem ( url, " TILED" , " true" );
785
+ if ( mTiled )
786
+ setQueryItem ( url, " TILED" , " true" );
764
787
765
788
int i = 0 ;
766
789
for ( int row = row0; row <= row1; row++ )
@@ -982,7 +1005,7 @@ void QgsWmsProvider::tileReplyFinished()
982
1005
cmd.setRawHeaders ( hl );
983
1006
984
1007
QgsDebugMsg ( QString ( " expirationDate:%1" ).arg ( cmd.expirationDate ().toString () ) );
985
- if ( cmd.expirationDate ().isNull () )
1008
+ if ( cmd.expirationDate ().isNull () )
986
1009
{
987
1010
QSettings s;
988
1011
cmd.setExpirationDate ( QDateTime::currentDateTime ().addSecs ( s.value ( " /qgis/defaultTileExpiry" , " 24" ).toInt () * 60 * 60 ) );
0 commit comments