QGIS API Documentation  3.25.0-Master (10b47c2603)
qgswmsparameters.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgswmsparameters.cpp
3  --------------------
4  begin : March 17, 2017
5  copyright : (C) 2017 by Paul Blottiere
6  email : paul dot blottiere at oslandia dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgswmsparameters.h"
19 #include "qgsdatasourceuri.h"
21 #include "qgsmessagelog.h"
22 #include "qgswmsserviceexception.h"
23 
24 const QString EXTERNAL_LAYER_PREFIX = QStringLiteral( "EXTERNAL_WMS:" );
25 
26 namespace QgsWms
27 {
28  //
29  // QgsWmsParameter
30  //
32  const QVariant::Type type,
33  const QVariant defaultValue )
34  : QgsServerParameterDefinition( type, defaultValue )
35  , mName( name )
36  {
37  }
38 
40  {
42  }
43 
45  {
46  const QString msg = QString( "%1 ('%2') cannot be converted into %3" ).arg( name( mName ), toString(), typeName() );
48  }
49 
50  QStringList QgsWmsParameter::toStyleList( const char delimiter ) const
51  {
52  return QgsServerParameterDefinition::toStringList( delimiter, false );
53  }
54 
55  QList<QgsGeometry> QgsWmsParameter::toGeomList( const char delimiter ) const
56  {
57  bool ok = true;
58  const QList<QgsGeometry> geoms = QgsServerParameterDefinition::toGeomList( ok, delimiter );
59 
60  if ( !ok )
61  {
62  const QString msg = QString( "%1 ('%2') cannot be converted into a list of geometries" ).arg( name( mName ), toString() );
64  }
65 
66  return geoms;
67  }
68 
70  {
71  bool ok = true;
73 
74  if ( !ok )
75  {
76  const QString msg = QString( "%1 ('%2') cannot be converted into a rectangle" ).arg( name( mName ), toString() );
78  }
79 
80  return rect;
81  }
82 
84  {
85  bool ok = false;
86  const int val = QgsServerParameterDefinition::toInt( ok );
87 
88  if ( !ok )
89  {
90  raiseError();
91  }
92 
93  return val;
94  }
95 
96  QString QgsWmsParameter::loadUrl() const
97  {
98  // Check URL -- it will be used in error messages
99  const QUrl url = toUrl();
100 
101  bool ok = false;
102  const QString content = QgsServerParameterDefinition::loadUrl( ok );
103 
104  if ( !ok )
105  {
106  const QString msg = QString( "%1 request error for %2" ).arg( name( mName ), url.toString() );
108  }
109 
110  return content;
111  }
112 
114  {
115  bool ok = false;
116  const QUrl url = QgsServerParameterDefinition::toUrl( ok );
117 
118  if ( !ok )
119  {
120  raiseError();
121  }
122 
123  return url;
124  }
125 
127  {
128  bool ok = false;
129  const QColor col = QgsServerParameterDefinition::toColor( ok );
130 
131  if ( !ok )
132  {
133  raiseError();
134  }
135 
136  return col;
137  }
138 
139  QList<QColor> QgsWmsParameter::toColorList( const char delimiter ) const
140  {
141  bool ok = false;
142  const QList<QColor> vals = QgsServerParameterDefinition::toColorList( ok, delimiter );
143 
144  if ( !ok )
145  {
146  const QString msg = QString( "%1 ('%2') cannot be converted into a list of colors" ).arg( name( mName ), toString() );
148  }
149 
150  return vals;
151  }
152 
153  QList<int> QgsWmsParameter::toIntList( const char delimiter ) const
154  {
155  bool ok = false;
156  const QList<int> vals = QgsServerParameterDefinition::toIntList( ok, delimiter );
157 
158  if ( !ok )
159  {
160  const QString msg = QString( "%1 ('%2') cannot be converted into a list of int" ).arg( name( mName ), toString() );
162  }
163 
164  return vals;
165  }
166 
167  QList<double> QgsWmsParameter::toDoubleList( const char delimiter ) const
168  {
169  bool ok = false;
170  const QList<double> vals = QgsServerParameterDefinition::toDoubleList( ok, delimiter );
171 
172  if ( !ok )
173  {
174  const QString msg = QString( "%1 ('%2') cannot be converted into a list of float" ).arg( name( mName ), toString() );
176  }
177 
178  return vals;
179  }
180 
182  {
183  bool ok = false;
184  const double val = QgsServerParameterDefinition::toDouble( ok );
185 
186  if ( !ok )
187  {
188  raiseError();
189  }
190 
191  return val;
192  }
193 
194  QString QgsWmsParameter::name() const
195  {
196  return QgsWmsParameter::name( mName );
197  }
198 
200  {
201  const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
202  return metaEnum.valueToKey( name );
203  }
204 
206  {
207  const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
208  return ( QgsWmsParameter::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
209  }
210 
211  //
212  // QgsWmsParameters
213  //
216  {
217  // Available version number
218  mVersions.append( QgsProjectVersion( 1, 1, 1 ) );
219  mVersions.append( QgsProjectVersion( 1, 3, 0 ) );
220 
221  // WMS parameters definition
223  QVariant::Int,
224  QVariant( 0 ) );
225  save( pQuality );
226 
228  QVariant::Bool,
229  QVariant( false ) );
230  save( pTiled );
231 
233  QVariant::Double,
234  QVariant( 2.0 ) );
235  save( pBoxSpace );
236 
238  QVariant::Double,
239  QVariant( 2.0 ) );
240  save( pSymbSpace );
241 
242  const QgsWmsParameter pLayerSpace( QgsWmsParameter::LAYERSPACE,
243  QVariant::Double,
244  QVariant( 3.0 ) );
245  save( pLayerSpace );
246 
248  QVariant::Double,
249  QVariant( 3.0 ) );
250  save( pTitleSpace );
251 
253  QVariant::Double,
254  QVariant( 4.0 ) );
255  save( pSymbHeight );
256 
258  QVariant::Double,
259  QVariant( 7.0 ) );
260  save( pSymbWidth );
261 
263  QVariant::Double,
264  QVariant( 2.0 ) );
265  save( pIcLabelSpace );
266 
267  const QgsWmsParameter pItFontFamily( QgsWmsParameter::ITEMFONTFAMILY );
268  save( pItFontFamily );
269 
271  QVariant::Bool,
272  QVariant( false ) );
273  save( pItFontBold );
274 
276  QVariant::Bool,
277  QVariant( false ) );
278  save( pItFontItalic );
279 
281  QVariant::Double,
282  QVariant( -1 ) );
283  save( pItFontSize );
284 
286  QVariant::String,
287  QVariant( "black" ) );
288  save( pItFontColor );
289 
290  const QgsWmsParameter pHighlightGeom( QgsWmsParameter::HIGHLIGHT_GEOM );
291  save( pHighlightGeom );
292 
293  const QgsWmsParameter pShowFeatureCount( QgsWmsParameter::SHOWFEATURECOUNT,
294  QVariant::Bool,
295  QVariant( false ) );
296  save( pShowFeatureCount );
297 
298  const QgsWmsParameter pHighlightSymbol( QgsWmsParameter::HIGHLIGHT_SYMBOL );
299  save( pHighlightSymbol );
300 
302  save( pHighlightLabel );
303 
305  QVariant::String,
306  QVariant( "black" ) );
307  save( pHighlightColor );
308 
309  const QgsWmsParameter pHighlightFontSize( QgsWmsParameter::HIGHLIGHT_LABELSIZE );
310  save( pHighlightFontSize );
311 
312  const QgsWmsParameter pHighlightFontWeight( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT );
313  save( pHighlightFontWeight );
314 
316  save( pHighlightFont );
317 
319  QVariant::String,
320  QVariant( "black" ) );
321  save( pHighlightBufferColor );
322 
323  const QgsWmsParameter pHighlightBufferSize( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE );
324  save( pHighlightBufferSize );
325 
326  const QgsWmsParameter pLabelRotation( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, QVariant::Double );
327  save( pLabelRotation );
328 
329  const QgsWmsParameter pLabelDistance( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, QVariant::Double );
330  save( pLabelDistance );
331 
333  save( pLabelHali );
334 
336  save( pLabelVali );
337 
339  save( pCRS );
340 
342  save( pSRS );
343 
345  QVariant::String,
346  QVariant( "png" ) );
347  save( pFormat );
348 
349  const QgsWmsParameter pInfoFormat( QgsWmsParameter::INFO_FORMAT );
350  save( pInfoFormat );
351 
353  QVariant::Int,
354  QVariant( -1 ) );
355  save( pI );
356 
358  QVariant::Int,
359  QVariant( -1 ) );
360  save( pJ );
361 
363  QVariant::Int,
364  QVariant( -1 ) );
365  save( pX );
366 
368  QVariant::Int,
369  QVariant( -1 ) );
370  save( pY );
371 
372  const QgsWmsParameter pRule( QgsWmsParameter::RULE );
373  save( pRule );
374 
376  QVariant::Bool,
377  QVariant( true ) );
378  save( pRuleLabel );
379 
381  QVariant::Double,
382  QVariant( -1 ) );
383  save( pScale );
384 
386  QVariant::Int,
387  QVariant( 0 ) );
388  save( pHeight );
389 
391  QVariant::Int,
392  QVariant( 0 ) );
393  save( pWidth );
394 
396  QVariant::Int,
397  QVariant( 0 ) );
398  save( pSrcHeight );
399 
401  QVariant::Int,
402  QVariant( 0 ) );
403  save( pSrcWidth );
404 
405  const QgsWmsParameter pBbox( QgsWmsParameter::BBOX );
406  save( pBbox );
407 
409  save( pSld );
410 
411  const QgsWmsParameter pSldBody( QgsWmsParameter::SLD_BODY );
412  save( pSldBody );
413 
414  const QgsWmsParameter pLayer( QgsWmsParameter::LAYER );
415  save( pLayer );
416 
417  const QgsWmsParameter pLayers( QgsWmsParameter::LAYERS );
418  save( pLayers );
419 
420  const QgsWmsParameter pQueryLayers( QgsWmsParameter::QUERY_LAYERS );
421  save( pQueryLayers );
422 
423  const QgsWmsParameter pFeatureCount( QgsWmsParameter::FEATURE_COUNT,
424  QVariant::Int,
425  QVariant( 1 ) );
426  save( pFeatureCount );
427 
428  const QgsWmsParameter pLayerTitle( QgsWmsParameter::LAYERTITLE,
429  QVariant::Bool,
430  QVariant( true ) );
431  save( pLayerTitle );
432 
433  const QgsWmsParameter pLayerFtFamily( QgsWmsParameter::LAYERFONTFAMILY );
434  save( pLayerFtFamily );
435 
437  QVariant::Bool,
438  QVariant( false ) );
439  save( pLayerFtBold );
440 
442  QVariant::Bool,
443  QVariant( false ) );
444  save( pLayerFtItalic );
445 
447  QVariant::Double,
448  QVariant( -1 ) );
449  save( pLayerFtSize );
450 
452  QVariant::String,
453  QVariant( "black" ) );
454  save( pLayerFtColor );
455 
456  const QgsWmsParameter pStyle( QgsWmsParameter::STYLE );
457  save( pStyle );
458 
459  const QgsWmsParameter pStyles( QgsWmsParameter::STYLES );
460  save( pStyles );
461 
462  const QgsWmsParameter pOpacities( QgsWmsParameter::OPACITIES );
463  save( pOpacities );
464 
465  const QgsWmsParameter pFilter( QgsWmsParameter::FILTER );
466  save( pFilter );
467 
468  const QgsWmsParameter pFilterGeom( QgsWmsParameter::FILTER_GEOM );
469  save( pFilterGeom );
470 
472  QVariant::Double,
473  QVariant( 0.0 ) );
474  save( pPolygTol );
475 
477  QVariant::Double,
478  QVariant( 0.0 ) );
479  save( pLineTol );
480 
482  QVariant::Double,
483  QVariant( 0.0 ) );
484  save( pPointTol );
485 
486  const QgsWmsParameter pSelection( QgsWmsParameter::SELECTION );
487  save( pSelection );
488 
489  const QgsWmsParameter pWmsPrecision( QgsWmsParameter::WMS_PRECISION,
490  QVariant::Int,
491  QVariant( -1 ) );
492  save( pWmsPrecision );
493 
494  const QgsWmsParameter pTransparent( QgsWmsParameter::TRANSPARENT,
495  QVariant::Bool,
496  QVariant( false ) );
497  save( pTransparent );
498 
500  QVariant::String,
501  QVariant( "white" ) );
502  save( pBgColor );
503 
505  QVariant::Int,
506  QVariant( -1 ) );
507  save( pDpi );
508 
509  const QgsWmsParameter pTemplate( QgsWmsParameter::TEMPLATE );
510  save( pTemplate );
511 
512  const QgsWmsParameter pExtent( QgsWmsParameter::EXTENT );
513  save( pExtent );
514 
516  QVariant::Double,
517  QVariant( 0.0 ) );
518  save( pRotation );
519 
521  QVariant::Double,
522  QVariant( 0.0 ) );
523  save( pGridX );
524 
526  QVariant::Double,
527  QVariant( 0.0 ) );
528  save( pGridY );
529 
530  const QgsWmsParameter pWithGeometry( QgsWmsParameter::WITH_GEOMETRY,
531  QVariant::Bool,
532  QVariant( false ) );
533  save( pWithGeometry );
534 
536  QVariant::Bool,
537  QVariant( false ) );
538  save( pWithMapTip );
539 
540  const QgsWmsParameter pWmtver( QgsWmsParameter::WMTVER );
541  save( pWmtver );
542 
544  QVariant::StringList );
545  save( pAtlasPk );
546 
548  QVariant::String );
549  save( pFormatOpts );
550  }
551 
553  : QgsWmsParameters()
554  {
555  load( parameters.urlQuery() );
556 
557  const QString sld = mWmsParameters[ QgsWmsParameter::SLD ].toString();
558  if ( !sld.isEmpty() )
559  {
560  const QString sldBody = mWmsParameters[ QgsWmsParameter::SLD ].loadUrl();
561  if ( !sldBody.isEmpty() )
562  {
564  }
565  }
566  }
567 
569  {
570  return mWmsParameters[name];
571  }
572 
573  void QgsWmsParameters::set( QgsWmsParameter::Name name, const QVariant &value )
574  {
575  mWmsParameters[name].mValue = value;
576  }
577 
578  bool QgsWmsParameters::loadParameter( const QString &key, const QString &value )
579  {
580  bool loaded = false;
581 
582  const QRegExp composerParamRegExp( QStringLiteral( "^MAP\\d+:" ), Qt::CaseInsensitive );
583  if ( key.contains( composerParamRegExp ) )
584  {
585 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
586  const int mapId = key.midRef( 3, key.indexOf( ':' ) - 3 ).toInt();
587 #else
588  const int mapId = QStringView {key}.mid( 3, key.indexOf( ':' ) - 3 ).toInt();
589 #endif
590  const QString theKey = key.mid( key.indexOf( ':' ) + 1 );
591  const QgsWmsParameter::Name name = QgsWmsParameter::name( theKey );
592 
593  if ( name >= 0 )
594  {
595  QgsWmsParameter param = mWmsParameters[name];
596  param.mValue = value;
597  param.mId = mapId;
598 
599  if ( ! param.isValid() )
600  {
601  param.raiseError();
602  }
603 
604  save( param, true ); // multi MAP parameters for composer
605  loaded = true;
606  }
607  }
608  else
609  {
610  const QgsWmsParameter::Name name = QgsWmsParameter::name( key );
611  if ( name >= 0 )
612  {
613  mWmsParameters[name].mValue = value;
614  if ( ! mWmsParameters[name].isValid() )
615  {
616  mWmsParameters[name].raiseError();
617  }
618 
619  loaded = true;
620  }
621  else //maybe an external wms parameter?
622  {
623  int separator = key.indexOf( QLatin1Char( ':' ) );
624  if ( separator >= 1 )
625  {
626  QString id = key.left( separator );
627  QString param = key.right( key.length() - separator - 1 );
628  mExternalWMSParameters[id].insert( param, value );
629 
630  loaded = true;
631  }
632  }
633  }
634 
635  return loaded;
636  }
637 
639  {
640  log( QStringLiteral( "WMS Request parameters:" ) );
641  for ( auto parameter : mWmsParameters.toStdMap() )
642  {
643  const QString value = parameter.second.toString();
644 
645  if ( ! value.isEmpty() )
646  {
647  QString name = QgsWmsParameter::name( parameter.first );
648 
649  if ( parameter.second.mId >= 0 )
650  {
651  name = QStringLiteral( "%1:%2" ).arg( QString::number( parameter.second.mId ), name );
652  }
653 
654  log( QStringLiteral( " - %1 : %2" ).arg( name, value ) );
655  }
656  }
657 
658  if ( !version().isEmpty() )
659  log( QStringLiteral( " - VERSION : %1" ).arg( version() ) );
660  }
661 
662  void QgsWmsParameters::save( const QgsWmsParameter &parameter, bool multi )
663  {
664  if ( multi )
665  {
666  mWmsParameters.insertMulti( parameter.mName, parameter );
667  }
668  else
669  {
670  mWmsParameters[ parameter.mName ] = parameter;
671  }
672  }
673 
675  {
676  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_GEOM ].toStringList( ';' );
677  }
678 
679  QList<QgsGeometry> QgsWmsParameters::highlightGeomAsGeom() const
680  {
681  return mWmsParameters[QgsWmsParameter::HIGHLIGHT_GEOM].toGeomList( ';' );
682  }
683 
685  {
686  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_SYMBOL ].toStringList( ';' );
687  }
688 
689  QString QgsWmsParameters::crs() const
690  {
691  QString rs;
692  const QString srs = mWmsParameters[ QgsWmsParameter::SRS ].toString();
693  const QString crs = mWmsParameters[ QgsWmsParameter::CRS ].toString();
694 
695  // both SRS/CRS are supported but there's a priority according to the
696  // specified version when both are defined in the request
697  if ( !srs.isEmpty() && crs.isEmpty() )
698  rs = srs;
699  else if ( srs.isEmpty() && !crs.isEmpty() )
700  rs = crs;
701  else if ( !srs.isEmpty() && !crs.isEmpty() )
702  {
703  if ( versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) )
704  rs = crs;
705  else
706  rs = srs;
707  }
708 
709  return rs;
710  }
711 
712  QString QgsWmsParameters::bbox() const
713  {
714  return mWmsParameters[ QgsWmsParameter::BBOX ].toString();
715  }
716 
718  {
719  return mWmsParameters[ QgsWmsParameter::BBOX ].toRectangle();
720  }
721 
722  QString QgsWmsParameters::height() const
723  {
724  return mWmsParameters[ QgsWmsParameter::HEIGHT ].toString();
725  }
726 
727  QString QgsWmsParameters::width() const
728  {
729  return mWmsParameters[ QgsWmsParameter::WIDTH ].toString();
730  }
731 
733  {
734  return mWmsParameters[ QgsWmsParameter::HEIGHT ].toInt();
735  }
736 
738  {
739  return mWmsParameters[ QgsWmsParameter::WIDTH ].toInt();
740  }
741 
743  {
744  return mWmsParameters[ QgsWmsParameter::SRCHEIGHT ].toString();
745  }
746 
748  {
749  return mWmsParameters[ QgsWmsParameter::SRCWIDTH ].toString();
750  }
751 
753  {
754  return mWmsParameters[ QgsWmsParameter::SRCHEIGHT ].toInt();
755  }
756 
758  {
759  return mWmsParameters[ QgsWmsParameter::SRCWIDTH ].toInt();
760  }
761 
762  QString QgsWmsParameters::dpi() const
763  {
764  return mWmsParameters[ QgsWmsParameter::DPI ].toString();
765  }
766 
768  {
769  return mWmsParameters[ QgsWmsParameter::DPI ].toDouble();
770  }
771 
773  {
775 
776  if ( QgsServerParameters::request().compare( QLatin1String( "GetProjectSettings" ), Qt::CaseInsensitive ) == 0 )
777  {
778  version = QStringLiteral( "1.3.0" );
779  }
780  else if ( version.isEmpty() )
781  {
782  if ( ! wmtver().isEmpty() )
783  {
784  version = wmtver();
785  }
786  else
787  {
788  version = QStringLiteral( "1.3.0" );
789  }
790  }
791  else if ( !mVersions.contains( QgsProjectVersion( version ) ) )
792  {
793  // WMS 1.3.0 specification: If a version lower than any of those
794  // known to the server is requested, then the server shall send the
795  // lowest version it supports.
796  if ( QgsProjectVersion( 1, 1, 1 ) > QgsProjectVersion( version ) )
797  {
798  version = QStringLiteral( "1.1.1" );
799  }
800  else
801  {
802  version = QStringLiteral( "1.3.0" );
803  }
804  }
805 
806  return version;
807  }
808 
810  {
811  QString req = QgsServerParameters::request();
812 
813  if ( version().compare( QLatin1String( "1.1.1" ) ) == 0
814  && req.compare( QLatin1String( "capabilities" ), Qt::CaseInsensitive ) == 0 )
815  {
816  req = QStringLiteral( "GetCapabilities" );
817  }
818 
819  return req;
820  }
821 
823  {
824  return QgsProjectVersion( version() );
825  }
826 
827  bool QgsWmsParameters::versionIsValid( const QString version ) const
828  {
829  return mVersions.contains( QgsProjectVersion( version ) );
830  }
831 
833  {
834  return mWmsParameters[ QgsWmsParameter::FORMAT ].toString( true );
835  }
836 
838  {
839  const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::Format>() );
840  return metaEnum.valueToKey( format );
841  }
842 
844  {
845  const QString fStr = formatAsString();
846 
847  Format f = Format::NONE;
848  if ( fStr.compare( QLatin1String( "image/png" ), Qt::CaseInsensitive ) == 0 ||
849  fStr.compare( QLatin1String( "png" ), Qt::CaseInsensitive ) == 0 )
850  {
851  f = Format::PNG;
852  }
853  else if ( fStr.compare( QLatin1String( "jpg" ), Qt::CaseInsensitive ) == 0
854  || fStr.compare( QLatin1String( "jpeg" ), Qt::CaseInsensitive ) == 0
855  || fStr.compare( QLatin1String( "image/jpeg" ), Qt::CaseInsensitive ) == 0 )
856  {
857  f = Format::JPG;
858  }
859  else if ( fStr.compare( QLatin1String( "image/svg" ), Qt::CaseInsensitive ) == 0 ||
860  fStr.compare( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive ) == 0 ||
861  fStr.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 )
862  {
863  f = Format::SVG;
864  }
865  else if ( fStr.compare( QLatin1String( "application/pdf" ), Qt::CaseInsensitive ) == 0 ||
866  fStr.compare( QLatin1String( "pdf" ), Qt::CaseInsensitive ) == 0 )
867  {
868  f = Format::PDF;
869  }
870  else if ( fStr.compare( QLatin1String( "application/json" ), Qt::CaseInsensitive ) == 0 ||
871  fStr.compare( QLatin1String( "json" ), Qt::CaseInsensitive ) == 0 )
872  {
873  f = Format::JSON;
874  }
875  return f;
876  }
877 
879  {
880  return mWmsParameters[ QgsWmsParameter::INFO_FORMAT ].toString();
881  }
882 
884  {
885  return infoFormat() == Format::PNG || infoFormat() == Format::JPG;
886  }
887 
889  {
890  QString fStr = infoFormatAsString();
891 
892  Format f = Format::TEXT;
893  if ( fStr.isEmpty() )
894  return f;
895 
896  if ( fStr.startsWith( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) )
897  f = Format::XML;
898  else if ( fStr.startsWith( QLatin1String( "text/html" ), Qt::CaseInsensitive ) )
899  f = Format::HTML;
900  else if ( fStr.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
901  f = Format::TEXT;
902  else if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml" ), Qt::CaseInsensitive ) )
903  f = Format::GML;
904  else if ( fStr.startsWith( QLatin1String( "application/json" ), Qt::CaseInsensitive )
905  || fStr.startsWith( QLatin1String( "application/geo+json" ), Qt::CaseInsensitive ) )
906  f = Format::JSON;
907  else
908  f = Format::NONE;
909 
910  return f;
911  }
912 
914  {
915  if ( infoFormat() != Format::GML )
916  return -1;
917 
918  QString fStr = infoFormatAsString();
919  if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml/3" ), Qt::CaseInsensitive ) )
920  return 3;
921  else
922  return 2;
923  }
924 
925  QString QgsWmsParameters::i() const
926  {
927  return mWmsParameters[ QgsWmsParameter::I ].toString();
928  }
929 
930  QString QgsWmsParameters::j() const
931  {
932  return mWmsParameters[ QgsWmsParameter::J ].toString();
933  }
934 
936  {
937  return mWmsParameters[ QgsWmsParameter::I ].toInt();
938  }
939 
941  {
942  return mWmsParameters[ QgsWmsParameter::J ].toInt();
943  }
944 
945  QString QgsWmsParameters::x() const
946  {
947  return mWmsParameters[ QgsWmsParameter::X ].toString();
948  }
949 
950  QString QgsWmsParameters::y() const
951  {
952  return mWmsParameters[ QgsWmsParameter::Y ].toString();
953  }
954 
956  {
957  return mWmsParameters[ QgsWmsParameter::X ].toInt();
958  }
959 
961  {
962  return mWmsParameters[ QgsWmsParameter::Y ].toInt();
963  }
964 
965  QString QgsWmsParameters::rule() const
966  {
967  return mWmsParameters[ QgsWmsParameter::RULE ].toString();
968  }
969 
971  {
972  return mWmsParameters[ QgsWmsParameter::RULELABEL ].toString();
973  }
974 
976  {
977  return mWmsParameters[ QgsWmsParameter::RULELABEL ].toBool();
978  }
979 
981  {
982  return mWmsParameters[ QgsWmsParameter::TRANSPARENT ].toString();
983  }
984 
986  {
987  return mWmsParameters[ QgsWmsParameter::TRANSPARENT ].toBool();
988  }
989 
990  QString QgsWmsParameters::scale() const
991  {
992  return mWmsParameters[ QgsWmsParameter::SCALE ].toString();
993  }
994 
996  {
997  return mWmsParameters[ QgsWmsParameter::SCALE ].toDouble();
998  }
999 
1001  {
1002  return mWmsParameters[ QgsWmsParameter::IMAGE_QUALITY ].toString();
1003  }
1004 
1006  {
1007  return mWmsParameters[ QgsWmsParameter::IMAGE_QUALITY ].toInt();
1008  }
1009 
1010  QString QgsWmsParameters::tiled() const
1011  {
1012  return mWmsParameters[ QgsWmsParameter::TILED ].toString();
1013  }
1014 
1016  {
1017  return mWmsParameters[ QgsWmsParameter::TILED ].toBool();
1018  }
1019 
1021  {
1022  return mWmsParameters[ QgsWmsParameter::SHOWFEATURECOUNT ].toString();
1023  }
1024 
1026  {
1027  return mWmsParameters[ QgsWmsParameter::SHOWFEATURECOUNT ].toBool();
1028  }
1029 
1031  {
1032  return mWmsParameters[ QgsWmsParameter::FEATURE_COUNT ].toString();
1033  }
1034 
1036  {
1037  return mWmsParameters[ QgsWmsParameter::FEATURE_COUNT ].toInt();
1038  }
1039 
1041  {
1042  return mWmsParameters[ QgsWmsParameter::BOXSPACE ].toString();
1043  }
1044 
1046  {
1047  return mWmsParameters[ QgsWmsParameter::BOXSPACE ].toDouble();
1048  }
1049 
1051  {
1052  return mWmsParameters[ QgsWmsParameter::LAYERSPACE ].toString();
1053  }
1054 
1056  {
1057  return mWmsParameters[ QgsWmsParameter::LAYERSPACE ].toDouble();
1058  }
1059 
1061  {
1062  return mWmsParameters[ QgsWmsParameter::LAYERTITLESPACE ].toString();
1063  }
1064 
1066  {
1067  return mWmsParameters[ QgsWmsParameter::LAYERTITLESPACE ].toDouble();
1068  }
1069 
1071  {
1072  return mWmsParameters[ QgsWmsParameter::SYMBOLSPACE ].toString();
1073  }
1074 
1076  {
1077  return mWmsParameters[ QgsWmsParameter::SYMBOLSPACE ].toDouble();
1078  }
1079 
1081  {
1082  return mWmsParameters[ QgsWmsParameter::SYMBOLHEIGHT ].toString();
1083  }
1084 
1086  {
1087  return mWmsParameters[ QgsWmsParameter::SYMBOLHEIGHT ].toDouble();
1088  }
1089 
1091  {
1092  return mWmsParameters[ QgsWmsParameter::SYMBOLWIDTH ].toString();
1093  }
1094 
1096  {
1097  return mWmsParameters[ QgsWmsParameter::SYMBOLWIDTH ].toDouble();
1098  }
1099 
1101  {
1102  return mWmsParameters[ QgsWmsParameter::ICONLABELSPACE ].toString();
1103  }
1104 
1106  {
1107  return mWmsParameters[ QgsWmsParameter::ICONLABELSPACE ].toDouble();
1108  }
1109 
1111  {
1112  return mWmsParameters[ QgsWmsParameter::LAYERFONTFAMILY ].toString();
1113  }
1114 
1116  {
1117  return mWmsParameters[ QgsWmsParameter::ITEMFONTFAMILY ].toString();
1118  }
1119 
1121  {
1122  return mWmsParameters[ QgsWmsParameter::LAYERFONTBOLD ].toString();
1123  }
1124 
1126  {
1127  return mWmsParameters[ QgsWmsParameter::LAYERFONTBOLD ].toBool();
1128  }
1129 
1131  {
1132  return mWmsParameters[ QgsWmsParameter::ITEMFONTBOLD ].toString();
1133  }
1134 
1136  {
1137  return mWmsParameters[ QgsWmsParameter::FI_POLYGON_TOLERANCE ].toString();
1138  }
1139 
1141  {
1142  return mWmsParameters[ QgsWmsParameter::FI_LINE_TOLERANCE ].toString();
1143  }
1144 
1146  {
1147  return mWmsParameters[ QgsWmsParameter::FI_POINT_TOLERANCE ].toString();
1148  }
1149 
1151  {
1152  return mWmsParameters[ QgsWmsParameter::FI_POLYGON_TOLERANCE ].toInt();
1153  }
1154 
1156  {
1157  return mWmsParameters[ QgsWmsParameter::FI_LINE_TOLERANCE ].toInt();
1158  }
1159 
1161  {
1162  return mWmsParameters[ QgsWmsParameter::FI_POINT_TOLERANCE ].toInt();
1163  }
1164 
1166  {
1167  return mWmsParameters[ QgsWmsParameter::ITEMFONTBOLD ].toBool();
1168  }
1169 
1171  {
1172  return mWmsParameters[ QgsWmsParameter::LAYERFONTITALIC ].toString();
1173  }
1174 
1176  {
1177  return mWmsParameters[ QgsWmsParameter::LAYERFONTITALIC ].toBool();
1178  }
1179 
1181  {
1182  return mWmsParameters[ QgsWmsParameter::ITEMFONTITALIC ].toString();
1183  }
1184 
1186  {
1187  return mWmsParameters[ QgsWmsParameter::ITEMFONTITALIC ].toBool();
1188  }
1189 
1191  {
1192  return mWmsParameters[ QgsWmsParameter::LAYERFONTSIZE ].toString();
1193  }
1194 
1196  {
1197  return mWmsParameters[ QgsWmsParameter::LAYERFONTSIZE ].toDouble();
1198  }
1199 
1201  {
1202  return mWmsParameters[ QgsWmsParameter::LAYERFONTCOLOR ].toString();
1203  }
1204 
1206  {
1207  return mWmsParameters[ QgsWmsParameter::LAYERFONTCOLOR ].toColor();
1208  }
1209 
1211  {
1212  return mWmsParameters[ QgsWmsParameter::ITEMFONTSIZE ].toString();
1213  }
1214 
1216  {
1217  return mWmsParameters[ QgsWmsParameter::ITEMFONTSIZE ].toDouble();
1218  }
1219 
1221  {
1222  return mWmsParameters[ QgsWmsParameter::ITEMFONTCOLOR ].toString();
1223  }
1224 
1226  {
1227  return mWmsParameters[ QgsWmsParameter::ITEMFONTCOLOR ].toColor();
1228  }
1229 
1231  {
1232  QFont font;
1233  font.fromString( "" );
1234  font.setBold( layerFontBoldAsBool() );
1235  font.setItalic( layerFontItalicAsBool() );
1236 
1237  if ( ! layerFontSize().isEmpty() )
1238  font.setPointSizeF( layerFontSizeAsDouble() );
1239 
1240  if ( !layerFontFamily().isEmpty() )
1241  font.setFamily( layerFontFamily() );
1242 
1243  return font;
1244  }
1245 
1247  {
1248  QFont font;
1249  font.fromString( "" );
1250 
1251  font.setBold( itemFontBoldAsBool() );
1252  font.setItalic( itemFontItalicAsBool() );
1253 
1254  if ( ! itemFontSize().isEmpty() )
1255  font.setPointSizeF( itemFontSizeAsDouble() );
1256 
1257  if ( !itemFontFamily().isEmpty() )
1258  font.setFamily( itemFontFamily() );
1259 
1260  return font;
1261  }
1262 
1264  {
1265  return mWmsParameters[ QgsWmsParameter::LAYERTITLE ].toString();
1266  }
1267 
1269  {
1270  return mWmsParameters[ QgsWmsParameter::LAYERTITLE ].toBool();
1271  }
1272 
1274  {
1275  QgsLegendSettings settings;
1276  settings.setTitle( QString() );
1277  settings.setBoxSpace( boxSpaceAsDouble() );
1278  settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) );
1279 
1280  settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Top, layerSpaceAsDouble() );
1281  settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Bottom, layerTitleSpaceAsDouble() );
1282  settings.rstyle( QgsLegendStyle::Style::Subgroup ).setFont( layerFont() );
1283 
1284  if ( !itemFontColor().isEmpty() )
1285  {
1286  settings.setFontColor( itemFontColorAsColor() );
1287  }
1288 
1289  // Ok, this is tricky: because QgsLegendSettings's layerFontColor was added to the API after
1290  // fontColor, to fix regressions #21871 and #21870 and the previous behavior was to use fontColor
1291  // for the whole legend we need to preserve that behavior.
1292  // But, the 2.18 server parameters ITEMFONTCOLOR did not have effect on the layer titles too, so
1293  // we set explicitly layerFontColor to black if it's not overridden by LAYERFONTCOLOR argument.
1294  settings.setLayerFontColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1295 
1296  settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setFont( itemFont() );
1297  settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpaceAsDouble() );
1298  settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setMargin( QgsLegendStyle::Side::Left, iconLabelSpaceAsDouble() );
1299 
1300  return settings;
1301  }
1302 
1303  QString QgsWmsParameters::layoutParameter( const QString &id, bool &ok ) const
1304  {
1305  QString label;
1306  ok = false;
1307 
1308  if ( mUnmanagedParameters.contains( id.toUpper() ) )
1309  {
1310  label = mUnmanagedParameters[id.toUpper()];
1311  ok = true;
1312  }
1313 
1314  return label;
1315  }
1316 
1317  QStringList QgsWmsParameters::atlasPk() const
1318  {
1319  return mWmsParameters[ QgsWmsParameter::ATLAS_PK ].toStringList();
1320  }
1321 
1323  {
1324  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELSTRING ].toStringList( ';' );
1325  }
1326 
1328  {
1329  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELSIZE ].toStringList( ';' );
1330  }
1331 
1333  {
1334  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELSIZE ].toIntList( ';' );
1335  }
1336 
1338  {
1339  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELCOLOR ].toStringList( ';' );
1340  }
1341 
1343  {
1344  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELCOLOR ].toColorList( ';' );
1345  }
1346 
1348  {
1349  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ].toStringList( ';' );
1350  }
1351 
1353  {
1354  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ].toIntList( ';' );
1355  }
1356 
1358  {
1359  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELFONT ].toStringList( ';' );
1360  }
1361 
1363  {
1364  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ].toStringList( ';' );
1365  }
1366 
1368  {
1369  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ].toColorList( ';' );
1370  }
1371 
1373  {
1374  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ].toStringList( ';' );
1375  }
1376 
1378  {
1379  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ].toDoubleList( ';' );
1380  }
1381 
1383  {
1384  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION ].toDoubleList( ';' );
1385  }
1386 
1388  {
1389  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE ].toDoubleList( ';' );
1390  }
1391 
1393  {
1394  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT ].toStringList( ';' );
1395  }
1396 
1398  {
1399  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT ].toStringList( ';' );
1400  }
1401 
1403  {
1404  return mWmsParameters[ QgsWmsParameter::WMS_PRECISION ].toString();
1405  }
1406 
1408  {
1409  return mWmsParameters[ QgsWmsParameter::WMS_PRECISION ].toInt();
1410  }
1411 
1413  {
1414  return mWmsParameters[ QgsWmsParameter::SLD_BODY ].toString();
1415  }
1416 
1417  QStringList QgsWmsParameters::filters() const
1418  {
1419  QStringList filters = mWmsParameters[ QgsWmsParameter::FILTER ].toOgcFilterList();
1420  if ( filters.isEmpty() )
1421  filters = mWmsParameters[ QgsWmsParameter::FILTER ].toExpressionList();
1422  return filters;
1423  }
1424 
1426  {
1427  return mWmsParameters[ QgsWmsParameter::FILTER_GEOM ].toString();
1428  }
1429 
1430  QStringList QgsWmsParameters::selections() const
1431  {
1432  return mWmsParameters[ QgsWmsParameter::SELECTION ].toStringList( ';' );
1433  }
1434 
1435  QStringList QgsWmsParameters::opacities() const
1436  {
1437  return mWmsParameters[ QgsWmsParameter::OPACITIES ].toStringList();
1438  }
1439 
1441  {
1442  return mWmsParameters[ QgsWmsParameter::OPACITIES ].toIntList();
1443  }
1444 
1446  {
1447  QStringList layer = mWmsParameters[ QgsWmsParameter::LAYER ].toStringList();
1448  const QStringList layers = mWmsParameters[ QgsWmsParameter::LAYERS ].toStringList();
1449  return layer << layers;
1450  }
1451 
1453  {
1454  return mWmsParameters[ QgsWmsParameter::QUERY_LAYERS ].toStringList();
1455  }
1456 
1457  QStringList QgsWmsParameters::allStyles() const
1458  {
1459  QStringList style = mWmsParameters[ QgsWmsParameter::STYLE ].toStyleList();
1460  const QStringList styles = mWmsParameters[ QgsWmsParameter::STYLES ].toStyleList();
1461  return style << styles;
1462  }
1463 
1464  QMultiMap<QString, QgsWmsParametersFilter> QgsWmsParameters::layerFilters( const QStringList &layers ) const
1465  {
1466  const QString nsWfs2 = QStringLiteral( "http://www.opengis.net/fes/2.0" );
1467  const QString prefixWfs2 = QStringLiteral( "<fes:" );
1468 
1469  const QStringList rawFilters = filters();
1470  QMultiMap<QString, QgsWmsParametersFilter> filters;
1471  for ( int i = 0; i < rawFilters.size(); i++ )
1472  {
1473  const QString f = rawFilters[i];
1474  if ( f.startsWith( QLatin1Char( '<' ) ) \
1475  && f.endsWith( QLatin1String( "Filter>" ) ) \
1476  && i < layers.size() )
1477  {
1478  QgsWmsParametersFilter filter;
1479  filter.mFilter = f;
1482 
1483  if ( filter.mFilter.contains( nsWfs2 ) \
1484  || filter.mFilter.contains( prefixWfs2 ) )
1485  {
1487  }
1488 
1489  filters.insert( layers[i], filter );
1490  }
1491  else if ( !f.isEmpty() )
1492  {
1493  // filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
1494  // several filters can be defined for one layer
1495  const int colonIndex = f.indexOf( ':' );
1496  if ( colonIndex != -1 )
1497  {
1498  const QString layers = f.section( ':', 0, 0 );
1499  const QString filter = f.section( ':', 1 );
1500  const QStringList layersList = layers.split( ',' );
1501  for ( const QString &layer : layersList )
1502  {
1503  QgsWmsParametersFilter parametersFilter;
1504  parametersFilter.mFilter = filter;
1505  parametersFilter.mType = QgsWmsParametersFilter::SQL;
1506  filters.insert( layer, parametersFilter );
1507  }
1508  }
1509  else
1510  {
1511  QString filterStr = mWmsParameters[ QgsWmsParameter::FILTER ].toString();
1512  raiseError( QStringLiteral( "FILTER ('" ) + filterStr + QStringLiteral( "') is not properly formatted" ) );
1513  }
1514  }
1515  }
1516  return filters;
1517  }
1518 
1520  {
1521  bool force2D = false;
1522  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1523 
1524  if ( options.contains( DxfFormatOption::FORCE_2D ) )
1525  {
1526  force2D = QVariant( options[ DxfFormatOption::FORCE_2D ] ).toBool();
1527  }
1528 
1529  return force2D;
1530  }
1531 
1533  {
1534  bool noMText = false;
1535  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1536 
1537  if ( options.contains( DxfFormatOption::NO_MTEXT ) )
1538  {
1539  noMText = QVariant( options[ DxfFormatOption::NO_MTEXT ] ).toBool();
1540  }
1541 
1542  return noMText;
1543  }
1544 
1545  QList<QgsWmsParametersLayer> QgsWmsParameters::layersParameters() const
1546  {
1547  const QStringList layers = allLayersNickname();
1548  const QStringList styles = allStyles();
1549  const QStringList selection = selections();
1550  const QList<int> opacities = opacitiesAsInt();
1551  const QMultiMap<QString, QgsWmsParametersFilter> filters = layerFilters( layers );
1552 
1553  // selection format: "LayerName:id0,id1;LayerName2:id0,id1;..."
1554  // several filters can be defined for one layer
1555  QMultiMap<QString, QString> layerSelections;
1556  for ( const QString &s : selection )
1557  {
1558  const QStringList splits = s.split( ':' );
1559  if ( splits.size() == 2 )
1560  {
1561  layerSelections.insert( splits[0], splits[1] );
1562  }
1563  else
1564  {
1565  QString selStr = mWmsParameters[ QgsWmsParameter::SELECTION ].toString();
1566  raiseError( QStringLiteral( "SELECTION ('" ) + selStr + QStringLiteral( "') is not properly formatted" ) );
1567  }
1568  }
1569 
1570  QList<QgsWmsParametersLayer> parameters;
1571  for ( int i = 0; i < layers.size(); i++ )
1572  {
1573  QString layer = layers[i];
1574 
1575  QgsWmsParametersLayer param;
1576  param.mNickname = layer;
1577 
1578  if ( i < opacities.count() )
1579  param.mOpacity = opacities[i];
1580 
1581  if ( isExternalLayer( layer ) )
1582  {
1583  const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1584  param.mNickname = extParam.mName;
1585  param.mExternalUri = extParam.mUri;
1586  }
1587  else
1588  {
1589  if ( i < styles.count() )
1590  param.mStyle = styles[i];
1591 
1592  if ( filters.contains( layer ) )
1593  {
1594  auto it = filters.find( layer );
1595  while ( it != filters.end() && it.key() == layer )
1596  {
1597  param.mFilter.append( it.value() );
1598  ++it;
1599  }
1600  }
1601 
1602  if ( layerSelections.contains( layer ) )
1603  {
1604  QMultiMap<QString, QString>::const_iterator it;
1605  it = layerSelections.constFind( layer );
1606  while ( it != layerSelections.constEnd() && it.key() == layer )
1607  {
1608  param.mSelection << it.value().split( ',' );
1609  ++it;
1610  }
1611  }
1612  }
1613 
1614  parameters.append( param );
1615  }
1616 
1617  return parameters;
1618  }
1619 
1620  QList<QgsWmsParametersHighlightLayer> QgsWmsParameters::highlightLayersParameters() const
1621  {
1622  QList<QgsWmsParametersHighlightLayer> params;
1623  const QList<QgsGeometry> geoms = highlightGeomAsGeom();
1624  const QStringList slds = highlightSymbol();
1625  const QStringList labels = highlightLabelString();
1626  const QList<QColor> colors = highlightLabelColorAsColor();
1627  const QList<int> sizes = highlightLabelSizeAsInt();
1628  const QList<int> weights = highlightLabelWeightAsInt();
1629  const QStringList fonts = highlightLabelFont();
1630  const QList<QColor> bufferColors = highlightLabelBufferColorAsColor();
1631  const QList<double> bufferSizes = highlightLabelBufferSizeAsFloat();
1632  const QList<double> rotation = highlightLabelRotation();
1633  const QList<double> distance = highlightLabelDistance();
1634  const QStringList hali = highlightLabelHorizontalAlignment();
1635  const QStringList vali = highlightLabelVerticalAlignment();
1636 
1637  int nLayers = std::min( geoms.size(), slds.size() );
1638  for ( int i = 0; i < nLayers; i++ )
1639  {
1641  param.mName = QStringLiteral( "highlight_" ) + QString::number( i );
1642  param.mGeom = geoms[i];
1643  param.mSld = slds[i];
1644 
1645  if ( i < labels.count() )
1646  param.mLabel = labels[i];
1647 
1648  if ( i < colors.count() )
1649  param.mColor = colors[i];
1650 
1651  if ( i < sizes.count() )
1652  param.mSize = sizes[i];
1653 
1654  if ( i < weights.count() )
1655  param.mWeight = weights[i];
1656 
1657  if ( i < fonts.count() )
1658  param.mFont = fonts[ i ];
1659 
1660  if ( i < bufferColors.count() )
1661  param.mBufferColor = bufferColors[i];
1662 
1663  if ( i < bufferSizes.count() )
1664  param.mBufferSize = bufferSizes[i];
1665 
1666  if ( i < rotation.count() )
1667  param.mLabelRotation = rotation[i];
1668 
1669  if ( i < distance.count() )
1670  param.mLabelDistance = distance[i];
1671 
1672  if ( i < hali.count() )
1673  param.mHali = hali[i];
1674 
1675  if ( i < vali.count() )
1676  param.mVali = vali[i];
1677 
1678 
1679 
1680  params.append( param );
1681  }
1682 
1683  return params;
1684  }
1685 
1686  QList<QgsWmsParametersExternalLayer> QgsWmsParameters::externalLayersParameters() const
1687  {
1688  auto notExternalLayer = []( const QString & name ) { return ! QgsWmsParameters::isExternalLayer( name ); };
1689 
1690  QList<QgsWmsParametersExternalLayer> externalLayers;
1691 
1692  QStringList layers = allLayersNickname();
1693  QStringList::iterator rit = std::remove_if( layers.begin(), layers.end(), notExternalLayer );
1694 
1695  for ( QStringList::iterator it = layers.begin(); it != rit; ++it )
1696  {
1697  externalLayers << externalLayerParameter( *it );
1698  }
1699 
1700  return externalLayers;
1701  }
1702 
1704  {
1705  return mWmsParameters[ QgsWmsParameter::BGCOLOR ].toString();
1706  }
1707 
1709  {
1710  return mWmsParameters[ QgsWmsParameter::BGCOLOR ].toColor();
1711  }
1712 
1714  {
1715  return mWmsParameters[ QgsWmsParameter::TEMPLATE ].toString();
1716  }
1717 
1719  {
1720  QgsWmsParameter wmsParam;
1722  param.mId = mapId;
1723 
1724  //map extent is mandatory
1725  QString extentStr;
1726  wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1727  if ( wmsParam.isValid() )
1728  {
1729  extentStr = wmsParam.toString();
1730  }
1731 
1732  if ( extentStr.isEmpty() )
1733  {
1734  return param;
1735  }
1736 
1737  QString pMapId = QStringLiteral( "MAP" ) + QString::number( mapId );
1738 
1739  wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1740  QgsRectangle extent;
1741  if ( wmsParam.isValid() )
1742  {
1743  extent = wmsParam.toRectangle();
1744  }
1745 
1746  if ( extent.isEmpty() )
1747  return param;
1748 
1749  param.mHasExtent = !extent.isEmpty();
1750  param.mExtent = extent;
1751 
1752  // scale
1753  wmsParam = idParameter( QgsWmsParameter::SCALE, mapId );
1754  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1755  {
1756  param.mScale = wmsParam.toDouble();
1757  }
1758 
1759  // rotation
1760  wmsParam = idParameter( QgsWmsParameter::ROTATION, mapId );
1761  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1762  {
1763  param.mRotation = wmsParam.toDouble();
1764  }
1765 
1766  //grid space x / y
1767  double gridx( -1 ), gridy( -1 );
1768 
1769  wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_X, mapId );
1770  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1771  {
1772  gridx = wmsParam.toDouble();
1773  }
1774 
1775  wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_Y, mapId );
1776  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1777  {
1778  gridy = wmsParam.toDouble();
1779  }
1780 
1781  if ( gridx != -1 && gridy != -1 )
1782  {
1783  param.mGridX = gridx;
1784  param.mGridY = gridy;
1785  }
1786 
1787  //layers
1788  QStringList allLayers;
1789  wmsParam = idParameter( QgsWmsParameter::LAYERS, mapId );
1790  if ( wmsParam.isValid() )
1791  {
1792  allLayers = wmsParam.toStringList();
1793  }
1794 
1795  // external layers
1796  QStringList layers;
1797 
1798  for ( const auto &layer : std::as_const( allLayers ) )
1799  {
1800  if ( isExternalLayer( layer ) )
1801  {
1802  const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1803  layers << extParam.mName;
1804  }
1805  else
1806  {
1807  layers << layer;
1808  }
1809  }
1810 
1811  QStringList styles;
1812  wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
1813  if ( wmsParam.isValid() )
1814  {
1815  styles = wmsParam.toStyleList();
1816  }
1817 
1818  QList<QgsWmsParametersLayer> lParams;
1819  for ( int i = 0; i < layers.size(); i++ )
1820  {
1821  QString layer = layers[i];
1822  QgsWmsParametersLayer lParam;
1823  lParam.mNickname = layer;
1824 
1825  if ( i < styles.count() )
1826  lParam.mStyle = styles[i];
1827 
1828  lParams.append( lParam );
1829  }
1830  param.mLayers = lParams;
1831 
1832  //highlight layers
1833  QList<QgsWmsParametersHighlightLayer> hParams;
1834 
1835  QList<QgsGeometry> geoms;
1836  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_GEOM, mapId );
1837  if ( wmsParam.isValid() )
1838  {
1839  geoms = wmsParam.toGeomList( ';' );
1840  }
1841 
1842  QStringList slds;
1843  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_SYMBOL, mapId );
1844  if ( wmsParam.isValid() )
1845  {
1846  slds = wmsParam.toStringList( ';' );
1847  }
1848 
1849  QStringList labels;
1850  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSTRING, mapId );
1851  if ( wmsParam.isValid() )
1852  {
1853  labels = wmsParam.toStringList( ';' );
1854  }
1855 
1856  QStringList fonts;
1857  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELFONT, mapId );
1858  if ( wmsParam.isValid() )
1859  {
1860  fonts = wmsParam.toStringList( ';' );
1861  }
1862 
1863  QList<QColor> colors;
1864  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELCOLOR, mapId );
1865  if ( wmsParam.isValid() )
1866  {
1867  colors = wmsParam.toColorList( ';' );
1868  }
1869 
1870  QList<int> sizes;
1871  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSIZE, mapId );
1872  if ( wmsParam.isValid() )
1873  {
1874  sizes = wmsParam.toIntList( ';' );
1875  }
1876 
1877  QList<int> weights;
1878  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT, mapId );
1879  if ( wmsParam.isValid() )
1880  {
1881  weights = wmsParam.toIntList( ';' );
1882  }
1883 
1884  QList<QColor> bufferColors;
1885  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR, mapId );
1886  if ( wmsParam.isValid() )
1887  {
1888  bufferColors = wmsParam.toColorList( ';' );
1889  }
1890 
1891  QList<double> bufferSizes;
1892  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE, mapId );
1893  if ( wmsParam.isValid() )
1894  {
1895  bufferSizes = wmsParam.toDoubleList( ';' );
1896  }
1897 
1898  QList<double> rotations;
1899  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, mapId );
1900  if ( wmsParam.isValid() )
1901  {
1902  rotations = wmsParam.toDoubleList( ';' );
1903  }
1904 
1905  QList<double> distances;
1906  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, mapId );
1907  if ( wmsParam.isValid() )
1908  {
1909  distances = wmsParam.toDoubleList( ';' );
1910  }
1911 
1912  QStringList halis;
1913  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT, mapId );
1914  if ( wmsParam.isValid() )
1915  {
1916  halis = wmsParam.toStringList();
1917  }
1918 
1919  QStringList valis;
1920  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT, mapId );
1921  if ( wmsParam.isValid() )
1922  {
1923  valis = wmsParam.toStringList();
1924  }
1925 
1926  int nHLayers = std::min( geoms.size(), slds.size() );
1927  for ( int i = 0; i < nHLayers; i++ )
1928  {
1930  hParam.mName = pMapId + QStringLiteral( "_highlight_" ) + QString::number( i );
1931  hParam.mGeom = geoms[i];
1932  hParam.mSld = slds[i];
1933 
1934  if ( i < labels.count() )
1935  hParam.mLabel = labels[i];
1936 
1937  if ( i < colors.count() )
1938  hParam.mColor = colors[i];
1939 
1940  if ( i < sizes.count() )
1941  hParam.mSize = sizes[i];
1942 
1943  if ( i < weights.count() )
1944  hParam.mWeight = weights[i];
1945 
1946  if ( i < fonts.count() )
1947  hParam.mFont = fonts[ i ];
1948 
1949  if ( i < bufferColors.count() )
1950  hParam.mBufferColor = bufferColors[i];
1951 
1952  if ( i < bufferSizes.count() )
1953  hParam.mBufferSize = bufferSizes[i];
1954 
1955  if ( i < rotations.count() )
1956  hParam.mLabelRotation = rotations[i];
1957 
1958  if ( i < distances.count() )
1959  hParam.mLabelDistance = distances[i];
1960 
1961  if ( i < halis.count() )
1962  hParam.mHali = halis[i];
1963 
1964  if ( i < valis.count() )
1965  hParam.mVali = valis[i];
1966 
1967  hParams.append( hParam );
1968  }
1969  param.mHighlightLayers = hParams;
1970 
1971  return param;
1972  }
1973 
1974  QString QgsWmsParameters::externalWMSUri( const QString &layerId ) const
1975  {
1976 
1977  // Param names may be uppercased.
1978  QString id { layerId };
1979 
1980  for ( auto it = mExternalWMSParameters.cbegin(); it != mExternalWMSParameters.cend(); ++it )
1981  {
1982  if ( it.key().compare( id, Qt::CaseSensitivity::CaseInsensitive ) == 0 )
1983  {
1984  id = it.key();
1985  break;
1986  }
1987  }
1988 
1989  if ( !mExternalWMSParameters.contains( id ) )
1990  {
1991  return QString();
1992  }
1993 
1994  QgsDataSourceUri wmsUri;
1995  const QMap<QString, QString> &paramMap = mExternalWMSParameters[ id ];
1996  QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin();
1997  for ( ; paramIt != paramMap.constEnd(); ++paramIt )
1998  {
1999  QString paramName = paramIt.key().toLower();
2000  if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) || paramName == QLatin1String( "opacities" ) )
2001  {
2002  const QStringList values = paramIt.value().split( ',' );
2003  for ( const QString &value : values )
2004  wmsUri.setParam( paramName, value );
2005  }
2006  else if ( paramName == QLatin1String( "ignorereportedlayerextents" ) )
2007  {
2008  wmsUri.setParam( QStringLiteral( "IgnoreReportedLayerExtents" ), paramIt.value() );
2009  }
2010  else if ( paramName == QLatin1String( "smoothpixmaptransform" ) )
2011  {
2012  wmsUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), paramIt.value() );
2013  }
2014  else if ( paramName == QLatin1String( "ignoregetmapurl" ) )
2015  {
2016  wmsUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), paramIt.value() );
2017  }
2018  else if ( paramName == QLatin1String( "ignoregetfeatureinfourl" ) )
2019  {
2020  wmsUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), paramIt.value() );
2021  }
2022  else if ( paramName == QLatin1String( "ignoreaxisorientation" ) )
2023  {
2024  wmsUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), paramIt.value() );
2025  }
2026  else if ( paramName == QLatin1String( "invertaxisorientation" ) )
2027  {
2028  wmsUri.setParam( QStringLiteral( "InvertAxisOrientation" ), paramIt.value() );
2029  }
2030  else if ( paramName == QLatin1String( "dpimode" ) )
2031  {
2032  wmsUri.setParam( QStringLiteral( "dpiMode" ), paramIt.value() );
2033  }
2034  else
2035  {
2036  wmsUri.setParam( paramName, paramIt.value() );
2037  }
2038  }
2039  return wmsUri.encodedUri();
2040  }
2041 
2043  {
2044  return mWmsParameters[ QgsWmsParameter::WITH_GEOMETRY ].toBool();
2045  }
2046 
2048  {
2049  return mWmsParameters[ QgsWmsParameter::WITH_MAPTIP ].toBool();
2050  }
2051 
2053  {
2054  return mWmsParameters[ QgsWmsParameter::WMTVER ].toString();
2055  }
2056 
2057  void QgsWmsParameters::log( const QString &msg ) const
2058  {
2059  QgsMessageLog::logMessage( msg, QStringLiteral( "Server" ), Qgis::MessageLevel::Info );
2060  }
2061 
2062  void QgsWmsParameters::raiseError( const QString &msg ) const
2063  {
2065  }
2066 
2067  QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
2068  {
2069  QgsWmsParameter p;
2070 
2071  for ( const auto &param : mWmsParameters.values( name ) )
2072  {
2073  if ( param.mId == id )
2074  {
2075  p = param;
2076  }
2077  }
2078 
2079  return p;
2080  }
2081 
2082  QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
2083  {
2084  QgsWmsParametersExternalLayer param;
2085 
2086  param.mName = name;
2087  param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
2088  param.mUri = externalWMSUri( param.mName );
2089 
2090  return param;
2091  }
2092 
2093  bool QgsWmsParameters::isExternalLayer( const QString &name )
2094  {
2095  return name.startsWith( EXTERNAL_LAYER_PREFIX );
2096  }
2097 
2099  {
2100  QStringList attributes;
2101  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2102 
2103  if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
2104  {
2105  attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
2106  }
2107 
2108  return attributes;
2109  }
2110 
2112  {
2113  bool use = false;
2114  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2115 
2116  if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
2117  {
2118  use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
2119  }
2120 
2121  return use;
2122  }
2123 
2125  {
2126  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2127 
2128  double scale = -1;
2129  if ( options.contains( DxfFormatOption::SCALE ) )
2130  {
2131  scale = options[ DxfFormatOption::SCALE ].toDouble();
2132  }
2133 
2134  return scale;
2135  }
2136 
2138  {
2139  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2140 
2142 
2143  if ( ! options.contains( DxfFormatOption::MODE ) )
2144  {
2145  return symbol;
2146  }
2147 
2148  const QString mode = options[ DxfFormatOption::MODE ];
2149  if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
2150  {
2152  }
2153  else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
2154  {
2156  }
2157 
2158  return symbol;
2159  }
2160 
2162  {
2163  QString codec = QStringLiteral( "ISO-8859-1" );
2164 
2165  if ( dxfFormatOptions().contains( DxfFormatOption::CODEC ) )
2166  {
2167  codec = dxfFormatOptions()[ DxfFormatOption::CODEC ];
2168  }
2169 
2170  return codec;
2171  }
2172 
2173  QMap<QgsWmsParameters::DxfFormatOption, QString> QgsWmsParameters::dxfFormatOptions() const
2174  {
2175  QMap<QgsWmsParameters::DxfFormatOption, QString> options;
2176 
2177  const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::DxfFormatOption>() );
2178  const QStringList opts = mWmsParameters[ QgsWmsParameter::FORMAT_OPTIONS ].toStringList( ';' );
2179 
2180  for ( auto it = opts.constBegin(); it != opts.constEnd(); ++it )
2181  {
2182  const int equalIdx = it->indexOf( ':' );
2183  if ( equalIdx > 0 && equalIdx < ( it->length() - 1 ) )
2184  {
2185  const QString name = it->left( equalIdx ).toUpper();
2186  const QgsWmsParameters::DxfFormatOption option =
2187  ( QgsWmsParameters::DxfFormatOption ) metaEnum.keyToValue( name.toStdString().c_str() );
2188  const QString value = it->right( it->length() - equalIdx - 1 );
2189  options.insert( option, value );
2190  }
2191  }
2192 
2193  return options;
2194  }
2195 
2196  QMap<QString, QString> QgsWmsParameters::dimensionValues() const
2197  {
2198  QMap<QString, QString> dimValues;
2199  const QMetaEnum pnMetaEnum( QMetaEnum::fromType<QgsMapLayerServerProperties::PredefinedWmsDimensionName>() );
2200  const QStringList unmanagedNames = mUnmanagedParameters.keys();
2201  for ( const QString &key : unmanagedNames )
2202  {
2203  if ( key.startsWith( QLatin1String( "DIM_" ) ) )
2204  {
2205  dimValues[key.mid( 4 )] = mUnmanagedParameters[key];
2206  }
2207  else if ( pnMetaEnum.keyToValue( key.toUpper().toStdString().c_str() ) != -1 )
2208  {
2209  dimValues[key] = mUnmanagedParameters[key];
2210  }
2211  }
2212  return dimValues;
2213  }
2214 }
Exception thrown in case of malformed request.
Class for storing the component parts of a RDBMS data source URI (e.g.
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
@ FeatureSymbology
Keeps the number of features and export symbology per feature (using the first symbol level)
Definition: qgsdxfexport.h:106
@ SymbolLayerSymbology
Exports one feature per symbol layer (considering symbol levels)
Definition: qgsdxfexport.h:107
@ NoSymbology
Export only data.
Definition: qgsdxfexport.h:105
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
void setFontColor(const QColor &c)
Sets the font color used for legend items.
void setLayerFontColor(const QColor &fontColor)
Sets layer font color to fontColor Overrides fontColor()
void setTitle(const QString &t)
Sets the title for the legend, which will be rendered above all legend items.
QgsLegendStyle & rstyle(QgsLegendStyle::Style s)
Returns modifiable reference to the style for a legend component.
void setBoxSpace(double s)
Sets the legend box space (in millimeters), which is the empty margin around the inside of the legend...
void setSymbolSize(QSizeF s)
Sets the default symbol size (in millimeters) used for legend items.
void setMargin(Side side, double margin)
Sets the margin (in mm) for the specified side of the component.
void setFont(const QFont &font)
Sets the font used for rendering this legend component.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
A class to describe the version of a project.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:469
Definition of a parameter with basic conversion methods.
QList< QgsGeometry > toGeomList(bool &ok, char delimiter=',') const
Converts the parameter into a list of geometries.
QString loadUrl(bool &ok) const
Loads the data associated to the parameter converted into an url.
QUrl toUrl(bool &ok) const
Converts the parameter into an url.
QString toString(bool defaultValue=false) const
Converts the parameter into a string.
QList< double > toDoubleList(bool &ok, char delimiter=',') const
Converts the parameter into a list of doubles.
QStringList toStringList(char delimiter=',', bool skipEmptyParts=true) const
Converts the parameter into a list of strings.
virtual bool isValid() const
Returns true if the parameter is valid, false otherwise.
QString typeName() const
Returns the type of the parameter as a string.
static void raiseError(const QString &msg)
Raises an exception in case of an invalid parameters.
int toInt(bool &ok) const
Converts the parameter into an integer.
QList< int > toIntList(bool &ok, char delimiter=',') const
Converts the parameter into a list of integers.
QColor toColor(bool &ok) const
Converts the parameter into a color.
double toDouble(bool &ok) const
Converts the parameter into a double.
QgsRectangle toRectangle(bool &ok) const
Converts the parameter into a rectangle.
QList< QColor > toColorList(bool &ok, char delimiter=',') const
Converts the parameter into a list of colors.
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
virtual QString request() const
Returns REQUEST parameter as a string or an empty string if not defined.
QUrlQuery urlQuery() const
Returns a url query with underlying parameters.
QMap< QString, QString > mUnmanagedParameters
void load(const QUrlQuery &query)
Loads new parameters.
virtual QString version() const
Returns VERSION parameter as a string or an empty string if not defined.
QString value(const QString &key) const
Returns the value of a parameter.
WMS parameter received from the client.
int toInt() const
Converts the parameter into an integer.
QList< double > toDoubleList(const char delimiter=',') const
Converts the parameter into a list of doubles.
QList< QColor > toColorList(const char delimiter=',') const
Converts the parameter into a list of colors.
double toDouble() const
Converts the parameter into a double.
void raiseError() const
Raises an error in case of an invalid conversion.
Name
Available parameters for WMS requests.
QUrl toUrl() const
Converts the parameter into an url.
QList< QgsGeometry > toGeomList(const char delimiter=',') const
Converts the parameter into a list of geometries.
bool isValid() const override
Returns true if the parameter is valid, false otherwise.
QString name() const
Returns the name of the parameter.
QgsRectangle toRectangle() const
Converts the parameter into a rectangle.
QgsWmsParameter(const QgsWmsParameter::Name name=QgsWmsParameter::UNKNOWN, const QVariant::Type type=QVariant::String, const QVariant defaultValue=QVariant(""))
Constructor for QgsWmsParameter.
QColor toColor() const
Converts the parameter into a color.
QgsWmsParameter::Name mName
QList< int > toIntList(const char delimiter=',') const
Converts the parameter into a list of integers.
QStringList toStyleList(const char delimiter=',') const
Converts the parameter into a list of strings and keeps empty parts Default style value is an empty s...
QString loadUrl() const
Loads the data associated to the parameter converted into an url.
Provides an interface to retrieve and manipulate WMS parameters received from the client.
QString rule() const
Returns RULE parameter or an empty string if none is defined.
QString layerTitle() const
Returns LAYERTITLE parameter or an empty string if not defined.
double layerSpaceAsDouble() const
Returns LAYERSPACE as a double or its default value if not defined.
QString boxSpace() const
Returns BOXSPACE parameter or an empty string if not defined.
QString wmsPrecision() const
Returns WMS_PRECISION parameter or an empty string if not defined.
double dxfScale() const
Returns the DXF SCALE parameter.
QString featureCount() const
Returns FEATURE_COUNT parameter or an empty string if none is defined.
QFont layerFont() const
Returns the layer font (built thanks to the LAYERFONTFAMILY, LAYERFONTSIZE, LAYERFONTBOLD,...
QList< int > opacitiesAsInt() const
Returns the list of opacities found in OPACITIES parameter as integers.
bool transparentAsBool() const
Returns TRANSPARENT parameter as a bool or its default value if not defined.
QString transparent() const
Returns TRANSPARENT parameter or an empty string if not defined.
QList< int > highlightLabelWeightAsInt() const
Returns HIGHLIGHT_LABELWEIGHT as a list of int.
QString iconLabelSpace() const
Returns ICONLABELSPACE parameter or an empty string if not defined.
QString layerTitleSpace() const
Returns LAYERTITLESPACE parameter or an empty string if not defined.
QString x() const
Returns X parameter or an empty string if not defined.
QString layerSpace() const
Returns LAYERSPACE parameter or an empty string if not defined.
int wmsPrecisionAsInt() const
Returns WMS_PRECISION parameter as an int or its default value if not defined.
QMap< DxfFormatOption, QString > dxfFormatOptions() const
Returns a map of DXF options defined within FORMAT_OPTIONS parameter.
QStringList highlightLabelBufferSize() const
Returns HIGHLIGHT_LABELBUFFERSIZE.
QStringList allLayersNickname() const
Returns nickname of layers found in LAYER and LAYERS parameters.
QString formatAsString() const
Returns FORMAT parameter as a string.
double layerFontSizeAsDouble() const
Returns LAYERFONTSIZE as a double.
QString externalWMSUri(const QString &id) const
Returns the external WMS uri.
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value.
QString scale() const
Returns SCALE parameter or an empty string if none is defined.
QString ruleLabel() const
Returns RULELABEL parameter or an empty string if none is defined.
double scaleAsDouble() const
Returns SCALE as a double.
bool layerFontItalicAsBool() const
Returns LAYERFONTITALIC as a boolean or its default value if not defined.
QgsWmsParametersComposerMap composerMapParameters(int mapId) const
Returns the requested parameters for a composer map parameter.
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid.
bool withGeometry() const
Returns if the client wants the feature info response with geometry information.
QStringList highlightLabelString() const
Returns HIGHLIGHT_LABELSTRING as a list of string.
QString tiled() const
Returns TILED parameter or an empty string if not defined.
QString layerFontSize() const
Returns LAYERFONTSIZE parameter or an empty string if not defined.
DxfFormatOption
Options for DXF format.
QList< QColor > highlightLabelColorAsColor() const
Returns HIGHLIGHT_LABELCOLOR as a list of color.
bool itemFontBoldAsBool() const
Returns ITEMFONTBOLD as a boolean or its default value if not defined.
QStringList highlightLabelHorizontalAlignment() const
Returns HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT as a list of string.
void set(QgsWmsParameter::Name name, const QVariant &value)
Sets a parameter value thanks to its name.
QString pointTolerance() const
Returns FI_POINT_TOLERANCE parameter or an empty string if not defined.
QString filterGeom() const
Returns the filter geometry found in FILTER_GEOM parameter.
QString composerTemplate() const
Returns TEMPLATE parameter or an empty string if not defined.
Format infoFormat() const
Returns infoFormat.
QString dxfCodec() const
Returns the DXF CODEC parameter.
QString y() const
Returns Y parameter or an empty string if not defined.
QString srcHeight() const
Returns SRCHEIGHT parameter or an empty string if not defined.
double dpiAsDouble() const
Returns DPI parameter as an int or its default value if not defined.
QStringList highlightLabelVerticalAlignment() const
Returns HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT as a list of string.
void dump() const
Dumps parameters.
int pointToleranceAsInt() const
Returns FI_POINT_TOLERANCE parameter as an integer.
bool withMapTip() const
withMapTip
QString polygonTolerance() const
Returns FI_POLYGON_TOLERANCE parameter or an empty string if not defined.
QStringList highlightGeom() const
Returns HIGHLIGHT_GEOM as a list of string in WKT.
QString i() const
Returns I parameter or an empty string if not defined.
QList< QColor > highlightLabelBufferColorAsColor() const
Returns HIGHLIGHT_LABELBUFFERCOLOR as a list of colors.
QString request() const override
Returns REQUEST parameter as a string or an empty string if not defined.
double layerTitleSpaceAsDouble() const
Returns LAYERTITLESPACE as a double.
QList< QgsWmsParametersLayer > layersParameters() const
Returns parameters for each layer found in LAYER/LAYERS.
int lineToleranceAsInt() const
Returns FI_LINE_TOLERANCE parameter as an integer.
QList< double > highlightLabelBufferSizeAsFloat() const
Returns HIGHLIGHT_LABELBUFFERSIZE as a list of float.
QString lineTolerance() const
Returns FI_LINE_TOLERANCE parameter or an empty string if not defined.
bool showFeatureCountAsBool() const
Returns SHOWFEATURECOUNT as a bool.
QStringList highlightLabelColor() const
Returns HIGHLIGHT_LABELCOLOR as a list of string.
bool versionIsValid(const QString version) const
Returns true if version is valid, false otherwise.
QString j() const
Returns J parameter or an empty string if not defined.
int xAsInt() const
Returns X parameter as an int or its default value if not defined.
QColor layerFontColorAsColor() const
Returns LAYERFONTCOLOR as a color or its defined value if not defined.
QString bbox() const
Returns BBOX if defined or an empty string.
QgsWmsParameters()
Constructor for WMS parameters with default values only.
int heightAsInt() const
Returns HEIGHT parameter as an int or its default value if not defined.
QStringList highlightLabelWeight() const
Returns HIGHLIGHT_LABELWEIGHT as a list of string.
QString backgroundColor() const
Returns BGCOLOR parameter or an empty string if not defined.
QStringList allStyles() const
Returns styles found in STYLE and STYLES parameters.
double symbolWidthAsDouble() const
Returns SYMBOLWIDTH as a double or its default value if not defined.
QColor backgroundColorAsColor() const
Returns BGCOLOR parameter as a QColor or its default value if not defined.
Format format() const
Returns format.
QgsWmsParameter operator[](QgsWmsParameter::Name name) const
Returns the parameter corresponding to name.
QString itemFontSize() const
Returns ITEMFONTSIZE parameter or an empty string if not defined.
QStringList atlasPk() const
Returns the ATLAS_PK parameter.
QList< QgsGeometry > highlightGeomAsGeom() const
Returns HIGHLIGHT_GEOM as a list of geometries.
QString layerFontFamily() const
Returns LAYERFONTFAMILY parameter or an empty string if not defined.
QList< QgsWmsParametersHighlightLayer > highlightLayersParameters() const
Returns parameters for each highlight layer.
int iAsInt() const
Returns I parameter as an int or its default value if not defined.
QStringList highlightLabelBufferColor() const
Returns HIGHLIGHT_LABELBUFFERCOLOR as a list of string.
int polygonToleranceAsInt() const
Returns FI_POLYGON_TOLERANCE parameter as an integer.
QgsDxfExport::SymbologyExport dxfMode() const
Returns the DXF MODE parameter.
bool ruleLabelAsBool() const
Returns RULELABEL as a bool.
QList< double > highlightLabelDistance() const
Returns HIGHLIGHT_LABEL_DISTANCE as a list of double.
QList< int > highlightLabelSizeAsInt() const
Returns HIGHLIGHT_LABELSIZE as a list of int An exception is raised if an invalid size is found.
int widthAsInt() const
Returns WIDTH parameter as an int or its default value if not defined.
QString sldBody() const
Returns SLD_body if defined or an empty string.
bool itemFontItalicAsBool() const
Returns ITEMFONTITALIC as a boolean or its default value if not defined.
QColor itemFontColorAsColor() const
Returns ITEMFONTCOLOR as a color.
double itemFontSizeAsDouble() const
Returns ITEMFONTSIZE as a double.
QString layerFontColor() const
Returns LAYERFONTCOLOR parameter or an empty string if not defined.
QString layoutParameter(const QString &id, bool &ok) const
Returns a layout parameter thanks to its id.
bool dxfUseLayerTitleAsName() const
Returns the DXF USE_TITLE_AS_LAYERNAME parameter.
QString symbolHeight() const
Returns SYMBOLHEIGHT parameter or an empty string if not defined.
int imageQualityAsInt() const
Returns IMAGE_QUALITY parameter as an integer.
QMap< QString, QString > dimensionValues() const
Returns the dimensions parameter.
QList< QgsWmsParametersExternalLayer > externalLayersParameters() const
Returns parameters for each external layer.
int infoFormatVersion() const
Returns the infoFormat version for GML.
QString layerFontBold() const
Returns LAYERFONTBOLD parameter or an empty string if not defined.
QgsLegendSettings legendSettings() const
Returns legend settings.
int srcHeightAsInt() const
Returns SRCHEIGHT parameter as an int or its default value if not defined.
QString symbolSpace() const
Returns SYMBOLSPACE parameter or an empty string if not defined.
QString itemFontBold() const
Returns ITEMFONTBOLD parameter or an empty string if not defined.
double symbolSpaceAsDouble() const
Returns SYMBOLSPACE as a double or its default value if not defined.
QString infoFormatAsString() const
Returns INFO_FORMAT parameter as a string.
QStringList highlightLabelFont() const
Returns HIGHLIGHT_LABELFONT.
QString wmtver() const
Returns WMTVER parameter or an empty string if not defined.
QStringList dxfLayerAttributes() const
Returns the DXF LAYERATTRIBUTES parameter.
QString srcWidth() const
Returns SRCWIDTH parameter or an empty string if not defined.
QStringList highlightLabelSize() const
Returns HIGHLIGHT_LABELSIZE as a list of string.
QString imageQuality() const
Returns IMAGE_QUALITY parameter or an empty string if not defined.
QList< double > highlightLabelRotation() const
Returns HIGHLIGHT_LABEL_ROTATION as a list of double.
QString height() const
Returns HEIGHT parameter or an empty string if not defined.
QString crs() const
Returns CRS or an empty string if none is defined.
QStringList selections() const
Returns the list of feature selection found in SELECTION parameter.
int featureCountAsInt() const
Returns FEATURE_COUNT as an integer.
int yAsInt() const
Returns Y parameter as an int or its default value if not defined.
bool layerTitleAsBool() const
Returns LAYERTITLE as a bool or its default value if not defined.
QString itemFontColor() const
Returns ITEMFONTCOLOR parameter or an empty string if not defined.
double boxSpaceAsDouble() const
Returns BOXSPACE as a double or its default value if not defined.
QString symbolWidth() const
Returns SYMBOLWIDTH parameter or an empty string if not defined.
bool tiledAsBool() const
Returns TILED parameter as a boolean.
Format
Output format for the response.
QString width() const
Returns WIDTH parameter or an empty string if not defined.
QFont itemFont() const
Returns the item font (built thanks to the ITEMFONTFAMILY, ITEMFONTSIZE, ITEMFONTBOLD,...
QStringList opacities() const
Returns the list of opacities found in OPACITIES parameter.
QString version() const override
Returns VERSION parameter as a string or an empty string if not defined.
QString layerFontItalic() const
Returns LAYERFONTITALIC parameter or an empty string if not defined.
QString itemFontItalic() const
Returns ITEMFONTITALIC parameter or an empty string if not defined.
QStringList filters() const
Returns the list of filters found in FILTER parameter.
QString dpi() const
Returns DPI parameter or an empty string if not defined.
QString itemFontFamily() const
Returns ITEMFONTFAMILY parameter or an empty string if not defined.
int jAsInt() const
Returns J parameter as an int or its default value if not defined.
QString showFeatureCount() const
Returns SHOWFEATURECOUNT parameter or an empty string if none is defined.
bool layerFontBoldAsBool() const
Returns LAYERFONTBOLD as a boolean or its default value if not defined.
double iconLabelSpaceAsDouble() const
Returns ICONLABELSPACE as a double or its default value if not defined.
QStringList highlightSymbol() const
Returns HIGHLIGHT_SYMBOL as a list of string.
QStringList queryLayersNickname() const
Returns nickname of layers found in QUERY_LAYERS parameter.
double symbolHeightAsDouble() const
Returns SYMBOLHEIGHT as a double or its default value if not defined.
bool infoFormatIsImage() const
Checks if INFO_FORMAT parameter is one of the image formats (PNG, JPG).
int srcWidthAsInt() const
Returns SRCWIDTH parameter as an int or its default value if not defined.
Median cut implementation.
const QString EXTERNAL_LAYER_PREFIX
QList< QgsWmsParametersLayer > mLayers
QList< QgsWmsParametersHighlightLayer > mHighlightLayers
QgsWmsParametersFilter::Type mType
QgsOgcUtils::FilterVersion mVersion
QList< QgsWmsParametersFilter > mFilter