QGIS API Documentation  3.27.0-Master (0e23467727)
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.mMapId = 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.mMapId >= 0 )
650  {
651  name = QStringLiteral( "%1:%2" ).arg( QString::number( parameter.second.mMapId ), 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  // We don't want duplicates but order does matter, so no QSet
1448  QStringList result;
1449 
1450  // LAYER
1451  QList<QgsWmsParameter> cLayer { mWmsParameters.values( QgsWmsParameter::LAYER ) };
1452  // Sort by map id
1453  std::sort( cLayer.begin(), cLayer.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1454  for ( const QgsWmsParameter &param : std::as_const( cLayer ) )
1455  {
1456  const QStringList layersList { param.toStringList() };
1457  for ( const QString &layerName : std::as_const( layersList ) )
1458  {
1459  if ( ! result.contains( layerName ) )
1460  result.append( layerName );
1461  }
1462  }
1463 
1464  // LAYERS
1465  QList<QgsWmsParameter> cLayers { mWmsParameters.values( QgsWmsParameter::LAYERS ) };
1466  // Sort by map id
1467  std::sort( cLayers.begin(), cLayers.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1468  for ( const QgsWmsParameter &param : std::as_const( cLayers ) )
1469  {
1470  const QStringList layersList { param.toStringList() };
1471  for ( const QString &layerName : std::as_const( layersList ) )
1472  {
1473  if ( ! result.contains( layerName ) )
1474  result.append( layerName );
1475  }
1476  }
1477  return result;
1478  }
1479 
1481  {
1482  return mWmsParameters[ QgsWmsParameter::QUERY_LAYERS ].toStringList();
1483  }
1484 
1485  QStringList QgsWmsParameters::allStyles() const
1486  {
1487  QStringList style = mWmsParameters[ QgsWmsParameter::STYLE ].toStyleList();
1488  const QStringList styles = mWmsParameters[ QgsWmsParameter::STYLES ].toStyleList();
1489  return style << styles;
1490  }
1491 
1492  QMultiMap<QString, QgsWmsParametersFilter> QgsWmsParameters::layerFilters( const QStringList &layers ) const
1493  {
1494  const QString nsWfs2 = QStringLiteral( "http://www.opengis.net/fes/2.0" );
1495  const QString prefixWfs2 = QStringLiteral( "<fes:" );
1496 
1497  const QStringList rawFilters = filters();
1498  QMultiMap<QString, QgsWmsParametersFilter> filters;
1499  for ( int i = 0; i < rawFilters.size(); i++ )
1500  {
1501  const QString f = rawFilters[i];
1502  if ( f.startsWith( QLatin1Char( '<' ) ) \
1503  && f.endsWith( QLatin1String( "Filter>" ) ) \
1504  && i < layers.size() )
1505  {
1506  QgsWmsParametersFilter filter;
1507  filter.mFilter = f;
1510 
1511  if ( filter.mFilter.contains( nsWfs2 ) \
1512  || filter.mFilter.contains( prefixWfs2 ) )
1513  {
1515  }
1516 
1517  filters.insert( layers[i], filter );
1518  }
1519  else if ( !f.isEmpty() )
1520  {
1521  // filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
1522  // several filters can be defined for one layer
1523  const int colonIndex = f.indexOf( ':' );
1524  if ( colonIndex != -1 )
1525  {
1526  const QString layers = f.section( ':', 0, 0 );
1527  const QString filter = f.section( ':', 1 );
1528  const QStringList layersList = layers.split( ',' );
1529  for ( const QString &layer : layersList )
1530  {
1531  QgsWmsParametersFilter parametersFilter;
1532  parametersFilter.mFilter = filter;
1533  parametersFilter.mType = QgsWmsParametersFilter::SQL;
1534  filters.insert( layer, parametersFilter );
1535  }
1536  }
1537  else
1538  {
1539  QString filterStr = mWmsParameters[ QgsWmsParameter::FILTER ].toString();
1540  raiseError( QStringLiteral( "FILTER ('" ) + filterStr + QStringLiteral( "') is not properly formatted" ) );
1541  }
1542  }
1543  }
1544  return filters;
1545  }
1546 
1548  {
1549  bool force2D = false;
1550  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1551 
1552  if ( options.contains( DxfFormatOption::FORCE_2D ) )
1553  {
1554  force2D = QVariant( options[ DxfFormatOption::FORCE_2D ] ).toBool();
1555  }
1556 
1557  return force2D;
1558  }
1559 
1561  {
1562  bool noMText = false;
1563  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1564 
1565  if ( options.contains( DxfFormatOption::NO_MTEXT ) )
1566  {
1567  noMText = QVariant( options[ DxfFormatOption::NO_MTEXT ] ).toBool();
1568  }
1569 
1570  return noMText;
1571  }
1572 
1573 
1574  QList<QgsWmsParametersLayer> QgsWmsParameters::layersParameters() const
1575  {
1576  const QStringList layers = allLayersNickname();
1577  const QStringList styles = allStyles();
1578  const QStringList selection = selections();
1579  const QList<int> opacities = opacitiesAsInt();
1580  const QMultiMap<QString, QgsWmsParametersFilter> filters = layerFilters( layers );
1581 
1582  // selection format: "LayerName:id0,id1;LayerName2:id0,id1;..."
1583  // several filters can be defined for one layer
1584  QMultiMap<QString, QString> layerSelections;
1585  for ( const QString &s : selection )
1586  {
1587  const QStringList splits = s.split( ':' );
1588  if ( splits.size() == 2 )
1589  {
1590  layerSelections.insert( splits[0], splits[1] );
1591  }
1592  else
1593  {
1594  QString selStr = mWmsParameters[ QgsWmsParameter::SELECTION ].toString();
1595  raiseError( QStringLiteral( "SELECTION ('" ) + selStr + QStringLiteral( "') is not properly formatted" ) );
1596  }
1597  }
1598 
1599  QList<QgsWmsParametersLayer> parameters;
1600  for ( int i = 0; i < layers.size(); i++ )
1601  {
1602  QString layer = layers[i];
1603 
1604  QgsWmsParametersLayer param;
1605  param.mNickname = layer;
1606 
1607  if ( i < opacities.count() )
1608  param.mOpacity = opacities[i];
1609 
1610  if ( isExternalLayer( layer ) )
1611  {
1612  const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1613  param.mNickname = extParam.mName;
1614  param.mExternalUri = extParam.mUri;
1615  }
1616  else
1617  {
1618  if ( i < styles.count() )
1619  param.mStyle = styles[i];
1620 
1621  if ( filters.contains( layer ) )
1622  {
1623  auto it = filters.find( layer );
1624  while ( it != filters.end() && it.key() == layer )
1625  {
1626  param.mFilter.append( it.value() );
1627  ++it;
1628  }
1629  }
1630 
1631  if ( layerSelections.contains( layer ) )
1632  {
1633  QMultiMap<QString, QString>::const_iterator it;
1634  it = layerSelections.constFind( layer );
1635  while ( it != layerSelections.constEnd() && it.key() == layer )
1636  {
1637  param.mSelection << it.value().split( ',' );
1638  ++it;
1639  }
1640  }
1641  }
1642 
1643  parameters.append( param );
1644  }
1645 
1646  return parameters;
1647  }
1648 
1649  QList<QgsWmsParametersHighlightLayer> QgsWmsParameters::highlightLayersParameters() const
1650  {
1651  QList<QgsWmsParametersHighlightLayer> params;
1652  const QList<QgsGeometry> geoms = highlightGeomAsGeom();
1653  const QStringList slds = highlightSymbol();
1654  const QStringList labels = highlightLabelString();
1655  const QList<QColor> colors = highlightLabelColorAsColor();
1656  const QList<int> sizes = highlightLabelSizeAsInt();
1657  const QList<int> weights = highlightLabelWeightAsInt();
1658  const QStringList fonts = highlightLabelFont();
1659  const QList<QColor> bufferColors = highlightLabelBufferColorAsColor();
1660  const QList<double> bufferSizes = highlightLabelBufferSizeAsFloat();
1661  const QList<double> rotation = highlightLabelRotation();
1662  const QList<double> distance = highlightLabelDistance();
1663  const QStringList hali = highlightLabelHorizontalAlignment();
1664  const QStringList vali = highlightLabelVerticalAlignment();
1665 
1666  int nLayers = std::min( geoms.size(), slds.size() );
1667  for ( int i = 0; i < nLayers; i++ )
1668  {
1670  param.mName = QStringLiteral( "highlight_" ) + QString::number( i );
1671  param.mGeom = geoms[i];
1672  param.mSld = slds[i];
1673 
1674  if ( i < labels.count() )
1675  param.mLabel = labels[i];
1676 
1677  if ( i < colors.count() )
1678  param.mColor = colors[i];
1679 
1680  if ( i < sizes.count() )
1681  param.mSize = sizes[i];
1682 
1683  if ( i < weights.count() )
1684  param.mWeight = weights[i];
1685 
1686  if ( i < fonts.count() )
1687  param.mFont = fonts[ i ];
1688 
1689  if ( i < bufferColors.count() )
1690  param.mBufferColor = bufferColors[i];
1691 
1692  if ( i < bufferSizes.count() )
1693  param.mBufferSize = bufferSizes[i];
1694 
1695  if ( i < rotation.count() )
1696  param.mLabelRotation = rotation[i];
1697 
1698  if ( i < distance.count() )
1699  param.mLabelDistance = distance[i];
1700 
1701  if ( i < hali.count() )
1702  param.mHali = hali[i];
1703 
1704  if ( i < vali.count() )
1705  param.mVali = vali[i];
1706 
1707 
1708 
1709  params.append( param );
1710  }
1711 
1712  return params;
1713  }
1714 
1715  QList<QgsWmsParametersExternalLayer> QgsWmsParameters::externalLayersParameters() const
1716  {
1717  auto notExternalLayer = []( const QString & name ) { return ! QgsWmsParameters::isExternalLayer( name ); };
1718 
1719  QList<QgsWmsParametersExternalLayer> externalLayers;
1720 
1721  QStringList layers = allLayersNickname();
1722  QStringList::iterator rit = std::remove_if( layers.begin(), layers.end(), notExternalLayer );
1723 
1724  for ( QStringList::iterator it = layers.begin(); it != rit; ++it )
1725  {
1726  externalLayers << externalLayerParameter( *it );
1727  }
1728 
1729  return externalLayers;
1730  }
1731 
1733  {
1734  return mWmsParameters[ QgsWmsParameter::BGCOLOR ].toString();
1735  }
1736 
1738  {
1739  return mWmsParameters[ QgsWmsParameter::BGCOLOR ].toColor();
1740  }
1741 
1743  {
1744  return mWmsParameters[ QgsWmsParameter::TEMPLATE ].toString();
1745  }
1746 
1748  {
1749  QgsWmsParameter wmsParam;
1751  param.mId = mapId;
1752 
1753  QString pMapId = QStringLiteral( "MAP" ) + QString::number( mapId );
1754 
1755  wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1756  QgsRectangle extent;
1757  if ( wmsParam.isValid() )
1758  {
1759  extent = wmsParam.toRectangle();
1760  }
1761 
1762  param.mHasExtent = !extent.isEmpty();
1763  param.mExtent = extent;
1764 
1765  // scale
1766  wmsParam = idParameter( QgsWmsParameter::SCALE, mapId );
1767  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1768  {
1769  param.mScale = wmsParam.toDouble();
1770  }
1771 
1772  // rotation
1773  wmsParam = idParameter( QgsWmsParameter::ROTATION, mapId );
1774  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1775  {
1776  param.mRotation = wmsParam.toDouble();
1777  }
1778 
1779  //grid space x / y
1780  double gridx( -1 ), gridy( -1 );
1781 
1782  wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_X, mapId );
1783  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1784  {
1785  gridx = wmsParam.toDouble();
1786  }
1787 
1788  wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_Y, mapId );
1789  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1790  {
1791  gridy = wmsParam.toDouble();
1792  }
1793 
1794  if ( gridx != -1 && gridy != -1 )
1795  {
1796  param.mGridX = gridx;
1797  param.mGridY = gridy;
1798  }
1799 
1800  //layers
1801  QStringList allLayers;
1802  wmsParam = idParameter( QgsWmsParameter::LAYERS, mapId );
1803  if ( wmsParam.isValid() )
1804  {
1805  allLayers = wmsParam.toStringList();
1806  }
1807 
1808  // external layers
1809  QStringList layers;
1810 
1811  for ( const auto &layer : std::as_const( allLayers ) )
1812  {
1813  if ( isExternalLayer( layer ) )
1814  {
1815  const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1816  layers << extParam.mName;
1817  }
1818  else
1819  {
1820  layers << layer;
1821  }
1822  }
1823 
1824  QStringList styles;
1825  wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
1826  if ( wmsParam.isValid() )
1827  {
1828  styles = wmsParam.toStyleList();
1829  }
1830 
1831  QList<QgsWmsParametersLayer> lParams;
1832  for ( int i = 0; i < layers.size(); i++ )
1833  {
1834  QString layer = layers[i];
1835  QgsWmsParametersLayer lParam;
1836  lParam.mNickname = layer;
1837 
1838  if ( i < styles.count() )
1839  lParam.mStyle = styles[i];
1840 
1841  lParams.append( lParam );
1842  }
1843  param.mLayers = lParams;
1844 
1845  //highlight layers
1846  QList<QgsWmsParametersHighlightLayer> hParams;
1847 
1848  QList<QgsGeometry> geoms;
1849  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_GEOM, mapId );
1850  if ( wmsParam.isValid() )
1851  {
1852  geoms = wmsParam.toGeomList( ';' );
1853  }
1854 
1855  QStringList slds;
1856  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_SYMBOL, mapId );
1857  if ( wmsParam.isValid() )
1858  {
1859  slds = wmsParam.toStringList( ';' );
1860  }
1861 
1862  QStringList labels;
1863  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSTRING, mapId );
1864  if ( wmsParam.isValid() )
1865  {
1866  labels = wmsParam.toStringList( ';' );
1867  }
1868 
1869  QStringList fonts;
1870  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELFONT, mapId );
1871  if ( wmsParam.isValid() )
1872  {
1873  fonts = wmsParam.toStringList( ';' );
1874  }
1875 
1876  QList<QColor> colors;
1877  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELCOLOR, mapId );
1878  if ( wmsParam.isValid() )
1879  {
1880  colors = wmsParam.toColorList( ';' );
1881  }
1882 
1883  QList<int> sizes;
1884  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSIZE, mapId );
1885  if ( wmsParam.isValid() )
1886  {
1887  sizes = wmsParam.toIntList( ';' );
1888  }
1889 
1890  QList<int> weights;
1891  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT, mapId );
1892  if ( wmsParam.isValid() )
1893  {
1894  weights = wmsParam.toIntList( ';' );
1895  }
1896 
1897  QList<QColor> bufferColors;
1898  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR, mapId );
1899  if ( wmsParam.isValid() )
1900  {
1901  bufferColors = wmsParam.toColorList( ';' );
1902  }
1903 
1904  QList<double> bufferSizes;
1905  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE, mapId );
1906  if ( wmsParam.isValid() )
1907  {
1908  bufferSizes = wmsParam.toDoubleList( ';' );
1909  }
1910 
1911  QList<double> rotations;
1912  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, mapId );
1913  if ( wmsParam.isValid() )
1914  {
1915  rotations = wmsParam.toDoubleList( ';' );
1916  }
1917 
1918  QList<double> distances;
1919  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, mapId );
1920  if ( wmsParam.isValid() )
1921  {
1922  distances = wmsParam.toDoubleList( ';' );
1923  }
1924 
1925  QStringList halis;
1926  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT, mapId );
1927  if ( wmsParam.isValid() )
1928  {
1929  halis = wmsParam.toStringList();
1930  }
1931 
1932  QStringList valis;
1933  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT, mapId );
1934  if ( wmsParam.isValid() )
1935  {
1936  valis = wmsParam.toStringList();
1937  }
1938 
1939  int nHLayers = std::min( geoms.size(), slds.size() );
1940  for ( int i = 0; i < nHLayers; i++ )
1941  {
1943  hParam.mName = pMapId + QStringLiteral( "_highlight_" ) + QString::number( i );
1944  hParam.mGeom = geoms[i];
1945  hParam.mSld = slds[i];
1946 
1947  if ( i < labels.count() )
1948  hParam.mLabel = labels[i];
1949 
1950  if ( i < colors.count() )
1951  hParam.mColor = colors[i];
1952 
1953  if ( i < sizes.count() )
1954  hParam.mSize = sizes[i];
1955 
1956  if ( i < weights.count() )
1957  hParam.mWeight = weights[i];
1958 
1959  if ( i < fonts.count() )
1960  hParam.mFont = fonts[ i ];
1961 
1962  if ( i < bufferColors.count() )
1963  hParam.mBufferColor = bufferColors[i];
1964 
1965  if ( i < bufferSizes.count() )
1966  hParam.mBufferSize = bufferSizes[i];
1967 
1968  if ( i < rotations.count() )
1969  hParam.mLabelRotation = rotations[i];
1970 
1971  if ( i < distances.count() )
1972  hParam.mLabelDistance = distances[i];
1973 
1974  if ( i < halis.count() )
1975  hParam.mHali = halis[i];
1976 
1977  if ( i < valis.count() )
1978  hParam.mVali = valis[i];
1979 
1980  hParams.append( hParam );
1981  }
1982  param.mHighlightLayers = hParams;
1983 
1984  return param;
1985  }
1986 
1987  QString QgsWmsParameters::externalWMSUri( const QString &layerId ) const
1988  {
1989 
1990  // Param names may be uppercased.
1991  QString id { layerId };
1992 
1993  for ( auto it = mExternalWMSParameters.cbegin(); it != mExternalWMSParameters.cend(); ++it )
1994  {
1995  if ( it.key().compare( id, Qt::CaseSensitivity::CaseInsensitive ) == 0 )
1996  {
1997  id = it.key();
1998  break;
1999  }
2000  }
2001 
2002  if ( !mExternalWMSParameters.contains( id ) )
2003  {
2004  return QString();
2005  }
2006 
2007  QgsDataSourceUri wmsUri;
2008  const QMap<QString, QString> &paramMap = mExternalWMSParameters[ id ];
2009  QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin();
2010  for ( ; paramIt != paramMap.constEnd(); ++paramIt )
2011  {
2012  QString paramName = paramIt.key().toLower();
2013  if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) || paramName == QLatin1String( "opacities" ) )
2014  {
2015  const QStringList values = paramIt.value().split( ',' );
2016  for ( const QString &value : values )
2017  wmsUri.setParam( paramName, value );
2018  }
2019  else if ( paramName == QLatin1String( "ignorereportedlayerextents" ) )
2020  {
2021  wmsUri.setParam( QStringLiteral( "IgnoreReportedLayerExtents" ), paramIt.value() );
2022  }
2023  else if ( paramName == QLatin1String( "smoothpixmaptransform" ) )
2024  {
2025  wmsUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), paramIt.value() );
2026  }
2027  else if ( paramName == QLatin1String( "ignoregetmapurl" ) )
2028  {
2029  wmsUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), paramIt.value() );
2030  }
2031  else if ( paramName == QLatin1String( "ignoregetfeatureinfourl" ) )
2032  {
2033  wmsUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), paramIt.value() );
2034  }
2035  else if ( paramName == QLatin1String( "ignoreaxisorientation" ) )
2036  {
2037  wmsUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), paramIt.value() );
2038  }
2039  else if ( paramName == QLatin1String( "invertaxisorientation" ) )
2040  {
2041  wmsUri.setParam( QStringLiteral( "InvertAxisOrientation" ), paramIt.value() );
2042  }
2043  else if ( paramName == QLatin1String( "dpimode" ) )
2044  {
2045  wmsUri.setParam( QStringLiteral( "dpiMode" ), paramIt.value() );
2046  }
2047  else
2048  {
2049  wmsUri.setParam( paramName, paramIt.value() );
2050  }
2051  }
2052  return wmsUri.encodedUri();
2053  }
2054 
2056  {
2057  return mWmsParameters[ QgsWmsParameter::WITH_GEOMETRY ].toBool();
2058  }
2059 
2061  {
2062  return mWmsParameters[ QgsWmsParameter::WITH_MAPTIP ].toBool();
2063  }
2064 
2066  {
2067  return mWmsParameters[ QgsWmsParameter::WMTVER ].toString();
2068  }
2069 
2070  void QgsWmsParameters::log( const QString &msg ) const
2071  {
2072  QgsMessageLog::logMessage( msg, QStringLiteral( "Server" ), Qgis::MessageLevel::Info );
2073  }
2074 
2075  void QgsWmsParameters::raiseError( const QString &msg ) const
2076  {
2078  }
2079 
2080  QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
2081  {
2082  QgsWmsParameter p;
2083 
2084  for ( const auto &param : mWmsParameters.values( name ) )
2085  {
2086  if ( param.mMapId == id )
2087  {
2088  p = param;
2089  }
2090  }
2091 
2092  return p;
2093  }
2094 
2095  QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
2096  {
2097  QgsWmsParametersExternalLayer param;
2098 
2099  param.mName = name;
2100  param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
2101  param.mUri = externalWMSUri( param.mName );
2102 
2103  return param;
2104  }
2105 
2106  bool QgsWmsParameters::isExternalLayer( const QString &name )
2107  {
2108  return name.startsWith( EXTERNAL_LAYER_PREFIX );
2109  }
2110 
2112  {
2113  QStringList attributes;
2114  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2115 
2116  if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
2117  {
2118  attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
2119  }
2120 
2121  return attributes;
2122  }
2123 
2125  {
2126  bool use = false;
2127  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2128 
2129  if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
2130  {
2131  use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
2132  }
2133 
2134  return use;
2135  }
2136 
2138  {
2139  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2140 
2141  double scale = -1;
2142  if ( options.contains( DxfFormatOption::SCALE ) )
2143  {
2144  scale = options[ DxfFormatOption::SCALE ].toDouble();
2145  }
2146 
2147  return scale;
2148  }
2149 
2151  {
2152  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2153 
2155 
2156  if ( ! options.contains( DxfFormatOption::MODE ) )
2157  {
2158  return symbol;
2159  }
2160 
2161  const QString mode = options[ DxfFormatOption::MODE ];
2162  if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
2163  {
2165  }
2166  else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
2167  {
2169  }
2170 
2171  return symbol;
2172  }
2173 
2175  {
2176  QString codec = QStringLiteral( "ISO-8859-1" );
2177 
2178  if ( dxfFormatOptions().contains( DxfFormatOption::CODEC ) )
2179  {
2180  codec = dxfFormatOptions()[ DxfFormatOption::CODEC ];
2181  }
2182 
2183  return codec;
2184  }
2185 
2186  QMap<QgsWmsParameters::DxfFormatOption, QString> QgsWmsParameters::dxfFormatOptions() const
2187  {
2188  QMap<QgsWmsParameters::DxfFormatOption, QString> options;
2189 
2190  const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::DxfFormatOption>() );
2191  const QStringList opts = mWmsParameters[ QgsWmsParameter::FORMAT_OPTIONS ].toStringList( ';' );
2192 
2193  for ( auto it = opts.constBegin(); it != opts.constEnd(); ++it )
2194  {
2195  const int equalIdx = it->indexOf( ':' );
2196  if ( equalIdx > 0 && equalIdx < ( it->length() - 1 ) )
2197  {
2198  const QString name = it->left( equalIdx ).toUpper();
2199  const QgsWmsParameters::DxfFormatOption option =
2200  ( QgsWmsParameters::DxfFormatOption ) metaEnum.keyToValue( name.toStdString().c_str() );
2201  const QString value = it->right( it->length() - equalIdx - 1 );
2202  options.insert( option, value );
2203  }
2204  }
2205 
2206  return options;
2207  }
2208 
2209  QMap<QString, QString> QgsWmsParameters::dimensionValues() const
2210  {
2211  QMap<QString, QString> dimValues;
2212  const QMetaEnum pnMetaEnum( QMetaEnum::fromType<QgsMapLayerServerProperties::PredefinedWmsDimensionName>() );
2213  const QStringList unmanagedNames = mUnmanagedParameters.keys();
2214  for ( const QString &key : unmanagedNames )
2215  {
2216  if ( key.startsWith( QLatin1String( "DIM_" ) ) )
2217  {
2218  dimValues[key.mid( 4 )] = mUnmanagedParameters[key];
2219  }
2220  else if ( pnMetaEnum.keyToValue( key.toUpper().toStdString().c_str() ) != -1 )
2221  {
2222  dimValues[key] = mUnmanagedParameters[key];
2223  }
2224  }
2225  return dimValues;
2226  }
2227 }
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