File tree Expand file tree Collapse file tree 3 files changed +38
-18
lines changed Expand file tree Collapse file tree 3 files changed +38
-18
lines changed Original file line number Diff line number Diff line change 16
16
***************************************************************************/
17
17
18
18
#include " qgswmsparameters.h"
19
+ #include " qgsdatasourceuri.h"
19
20
#include " qgsmessagelog.h"
20
21
#include < iostream>
21
22
@@ -512,6 +513,16 @@ namespace QgsWms
512
513
raiseError ( name );
513
514
}
514
515
}
516
+ else // maybe an external wms parameter?
517
+ {
518
+ int separator = key.indexOf ( " :" );
519
+ if ( separator >= 1 )
520
+ {
521
+ QString id = key.left ( separator );
522
+ QString param = key.right ( key.length () - separator - 1 );
523
+ mExternalWMSParameters [id].insert ( param, parameters[key] );
524
+ }
525
+ }
515
526
}
516
527
}
517
528
}
@@ -1874,6 +1885,23 @@ namespace QgsWms
1874
1885
return param;
1875
1886
}
1876
1887
1888
+ QString QgsWmsParameters::externalWMSUri ( const QString &id ) const
1889
+ {
1890
+ if ( !mExternalWMSParameters .contains ( id ) )
1891
+ {
1892
+ return QString ();
1893
+ }
1894
+
1895
+ QgsDataSourceUri wmsUri;
1896
+ const QMap<QString, QString> ¶mMap = mExternalWMSParameters [ id ];
1897
+ QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin ();
1898
+ for ( ; paramIt != paramMap.constEnd (); ++paramIt )
1899
+ {
1900
+ wmsUri.setParam ( paramIt.key ().toLower (), paramIt.value () );
1901
+ }
1902
+ return wmsUri.encodedUri ();
1903
+ }
1904
+
1877
1905
QString QgsWmsParameters::name ( ParameterName name ) const
1878
1906
{
1879
1907
const QMetaEnum metaEnum ( QMetaEnum::fromType<ParameterName>() );
Original file line number Diff line number Diff line change @@ -909,6 +909,13 @@ namespace QgsWms
909
909
*/
910
910
QgsWmsParametersComposerMap composerMapParameters ( int mapId ) const ;
911
911
912
+ /* *
913
+ * @brief externalWMSUri
914
+ * @param id the id of the external wms
915
+ * @return uri string or an empty string if the external wms id does not exist
916
+ */
917
+ QString externalWMSUri ( const QString &id ) const ;
918
+
912
919
private:
913
920
QString name ( ParameterName name ) const ;
914
921
void raiseError ( ParameterName name ) const ;
@@ -955,6 +962,7 @@ namespace QgsWms
955
962
QgsServerRequest::Parameters mRequestParameters ;
956
963
QMap<ParameterName, Parameter> mParameters ;
957
964
QMap<int , QMap<ParameterName, Parameter>> mComposerParameters ;
965
+ QMap<QString, QMap<QString, QString> > mExternalWMSParameters ;
958
966
QList<QgsProjectVersion> mVersions ;
959
967
};
960
968
}
Original file line number Diff line number Diff line change @@ -2653,24 +2653,8 @@ namespace QgsWms
2653
2653
2654
2654
QgsMapLayer *QgsRenderer::createExternalWMSLayer ( const QString &externalLayerId ) const
2655
2655
{
2656
- QgsMapLayer *wmsLayer = 0 ;
2657
- QgsDataSourceUri wmsUri;
2658
-
2659
- QgsServerRequest::Parameters::const_iterator it = mParameters .lowerBound ( externalLayerId.toUpper () + " :" );
2660
- while ( it != mParameters .constEnd () )
2661
- {
2662
- if ( !it.key ().startsWith ( externalLayerId.toUpper () + " :" ) )
2663
- {
2664
- break ;
2665
- }
2666
-
2667
- QString paramKey = it.key ();
2668
- paramKey.remove ( 0 , externalLayerId.size () + 1 );
2669
- wmsUri.setParam ( paramKey.toLower (), it.value () );
2670
- ++it;
2671
- }
2672
-
2673
- wmsLayer = new QgsRasterLayer ( wmsUri.encodedUri (), externalLayerId, QStringLiteral ( " wms" ) );
2656
+ QString wmsUri = mWmsParameters .externalWMSUri ( externalLayerId.toUpper () );
2657
+ QgsMapLayer *wmsLayer = new QgsRasterLayer ( wmsUri, externalLayerId, QStringLiteral ( " wms" ) );
2674
2658
if ( !wmsLayer->isValid () )
2675
2659
{
2676
2660
delete wmsLayer;
You can’t perform that action at this time.
0 commit comments