QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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(), typeName() );
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(), typeName() );
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(), typeName() );
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(), typeName() );
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(), typeName() );
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 
327  save( pCRS );
328 
330  save( pSRS );
331 
333  QVariant::String,
334  QVariant( "png" ) );
335  save( pFormat );
336 
337  const QgsWmsParameter pInfoFormat( QgsWmsParameter::INFO_FORMAT );
338  save( pInfoFormat );
339 
341  QVariant::Int,
342  QVariant( -1 ) );
343  save( pI );
344 
346  QVariant::Int,
347  QVariant( -1 ) );
348  save( pJ );
349 
351  QVariant::Int,
352  QVariant( -1 ) );
353  save( pX );
354 
356  QVariant::Int,
357  QVariant( -1 ) );
358  save( pY );
359 
360  const QgsWmsParameter pRule( QgsWmsParameter::RULE );
361  save( pRule );
362 
364  QVariant::Bool,
365  QVariant( true ) );
366  save( pRuleLabel );
367 
369  QVariant::Double,
370  QVariant( -1 ) );
371  save( pScale );
372 
374  QVariant::Int,
375  QVariant( 0 ) );
376  save( pHeight );
377 
379  QVariant::Int,
380  QVariant( 0 ) );
381  save( pWidth );
382 
384  QVariant::Int,
385  QVariant( 0 ) );
386  save( pSrcHeight );
387 
389  QVariant::Int,
390  QVariant( 0 ) );
391  save( pSrcWidth );
392 
393  const QgsWmsParameter pBbox( QgsWmsParameter::BBOX );
394  save( pBbox );
395 
397  save( pSld );
398 
399  const QgsWmsParameter pSldBody( QgsWmsParameter::SLD_BODY );
400  save( pSldBody );
401 
402  const QgsWmsParameter pLayer( QgsWmsParameter::LAYER );
403  save( pLayer );
404 
405  const QgsWmsParameter pLayers( QgsWmsParameter::LAYERS );
406  save( pLayers );
407 
408  const QgsWmsParameter pQueryLayers( QgsWmsParameter::QUERY_LAYERS );
409  save( pQueryLayers );
410 
411  const QgsWmsParameter pFeatureCount( QgsWmsParameter::FEATURE_COUNT,
412  QVariant::Int,
413  QVariant( 1 ) );
414  save( pFeatureCount );
415 
416  const QgsWmsParameter pLayerTitle( QgsWmsParameter::LAYERTITLE,
417  QVariant::Bool,
418  QVariant( true ) );
419  save( pLayerTitle );
420 
421  const QgsWmsParameter pLayerFtFamily( QgsWmsParameter::LAYERFONTFAMILY );
422  save( pLayerFtFamily );
423 
425  QVariant::Bool,
426  QVariant( false ) );
427  save( pLayerFtBold );
428 
430  QVariant::Bool,
431  QVariant( false ) );
432  save( pLayerFtItalic );
433 
435  QVariant::Double,
436  QVariant( -1 ) );
437  save( pLayerFtSize );
438 
440  QVariant::String,
441  QVariant( "black" ) );
442  save( pLayerFtColor );
443 
444  const QgsWmsParameter pStyle( QgsWmsParameter::STYLE );
445  save( pStyle );
446 
447  const QgsWmsParameter pStyles( QgsWmsParameter::STYLES );
448  save( pStyles );
449 
450  const QgsWmsParameter pOpacities( QgsWmsParameter::OPACITIES );
451  save( pOpacities );
452 
453  const QgsWmsParameter pFilter( QgsWmsParameter::FILTER );
454  save( pFilter );
455 
456  const QgsWmsParameter pFilterGeom( QgsWmsParameter::FILTER_GEOM );
457  save( pFilterGeom );
458 
460  QVariant::Double,
461  QVariant( 0.0 ) );
462  save( pPolygTol );
463 
465  QVariant::Double,
466  QVariant( 0.0 ) );
467  save( pLineTol );
468 
470  QVariant::Double,
471  QVariant( 0.0 ) );
472  save( pPointTol );
473 
474  const QgsWmsParameter pSelection( QgsWmsParameter::SELECTION );
475  save( pSelection );
476 
477  const QgsWmsParameter pWmsPrecision( QgsWmsParameter::WMS_PRECISION,
478  QVariant::Int,
479  QVariant( -1 ) );
480  save( pWmsPrecision );
481 
482  const QgsWmsParameter pTransparent( QgsWmsParameter::TRANSPARENT,
483  QVariant::Bool,
484  QVariant( false ) );
485  save( pTransparent );
486 
488  QVariant::String,
489  QVariant( "white" ) );
490  save( pBgColor );
491 
493  QVariant::Int,
494  QVariant( -1 ) );
495  save( pDpi );
496 
497  const QgsWmsParameter pTemplate( QgsWmsParameter::TEMPLATE );
498  save( pTemplate );
499 
500  const QgsWmsParameter pExtent( QgsWmsParameter::EXTENT );
501  save( pExtent );
502 
504  QVariant::Double,
505  QVariant( 0.0 ) );
506  save( pRotation );
507 
509  QVariant::Double,
510  QVariant( 0.0 ) );
511  save( pGridX );
512 
514  QVariant::Double,
515  QVariant( 0.0 ) );
516  save( pGridY );
517 
518  const QgsWmsParameter pWithGeometry( QgsWmsParameter::WITH_GEOMETRY,
519  QVariant::Bool,
520  QVariant( false ) );
521  save( pWithGeometry );
522 
524  QVariant::Bool,
525  QVariant( false ) );
526  save( pWithMapTip );
527 
528  const QgsWmsParameter pWmtver( QgsWmsParameter::WMTVER );
529  save( pWmtver );
530 
532  QVariant::StringList );
533  save( pAtlasPk );
534 
536  QVariant::String );
537  save( pFormatOpts );
538  }
539 
541  : QgsWmsParameters()
542  {
543  load( parameters.urlQuery() );
544 
545  const QString sld = mWmsParameters[ QgsWmsParameter::SLD ].toString();
546  if ( !sld.isEmpty() )
547  {
548  const QString sldBody = mWmsParameters[ QgsWmsParameter::SLD ].loadUrl();
549  if ( !sldBody.isEmpty() )
550  {
551  loadParameter( QgsWmsParameter::name( QgsWmsParameter::SLD_BODY ), sldBody );
552  }
553  }
554  }
555 
557  {
558  return mWmsParameters[name];
559  }
560 
561  void QgsWmsParameters::set( QgsWmsParameter::Name name, const QVariant &value )
562  {
563  mWmsParameters[name].mValue = value;
564  }
565 
566  bool QgsWmsParameters::loadParameter( const QString &key, const QString &value )
567  {
568  bool loaded = false;
569 
570  const QRegExp composerParamRegExp( QStringLiteral( "^MAP\\d+:" ), Qt::CaseInsensitive );
571  if ( key.contains( composerParamRegExp ) )
572  {
573  const int mapId = key.midRef( 3, key.indexOf( ':' ) - 3 ).toInt();
574  const QString theKey = key.mid( key.indexOf( ':' ) + 1 );
575  const QgsWmsParameter::Name name = QgsWmsParameter::name( theKey );
576 
577  if ( name >= 0 )
578  {
579  QgsWmsParameter param = mWmsParameters[name];
580  param.mValue = value;
581  param.mId = mapId;
582 
583  if ( ! param.isValid() )
584  {
585  param.raiseError();
586  }
587 
588  save( param, true ); // multi MAP parameters for composer
589  loaded = true;
590  }
591  }
592  else
593  {
594  const QgsWmsParameter::Name name = QgsWmsParameter::name( key );
595  if ( name >= 0 )
596  {
597  mWmsParameters[name].mValue = value;
598  if ( ! mWmsParameters[name].isValid() )
599  {
600  mWmsParameters[name].raiseError();
601  }
602 
603  loaded = true;
604  }
605  else //maybe an external wms parameter?
606  {
607  int separator = key.indexOf( QStringLiteral( ":" ) );
608  if ( separator >= 1 )
609  {
610  QString id = key.left( separator );
611  QString param = key.right( key.length() - separator - 1 );
612  mExternalWMSParameters[id].insert( param, value );
613 
614  loaded = true;
615  }
616  }
617  }
618 
619  return loaded;
620  }
621 
623  {
624  log( QStringLiteral( "WMS Request parameters:" ) );
625  for ( auto parameter : mWmsParameters.toStdMap() )
626  {
627  const QString value = parameter.second.toString();
628 
629  if ( ! value.isEmpty() )
630  {
631  QString name = QgsWmsParameter::name( parameter.first );
632 
633  if ( parameter.second.mId >= 0 )
634  {
635  name = QStringLiteral( "%1:%2" ).arg( QString::number( parameter.second.mId ), name );
636  }
637 
638  log( QStringLiteral( " - %1 : %2" ).arg( name, value ) );
639  }
640  }
641 
642  if ( !version().isEmpty() )
643  log( QStringLiteral( " - VERSION : %1" ).arg( version() ) );
644  }
645 
646  void QgsWmsParameters::save( const QgsWmsParameter &parameter, bool multi )
647  {
648  if ( multi )
649  {
650  mWmsParameters.insertMulti( parameter.mName, parameter );
651  }
652  else
653  {
654  mWmsParameters[ parameter.mName ] = parameter;
655  }
656  }
657 
659  {
660  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_GEOM ].toStringList( ';' );
661  }
662 
663  QList<QgsGeometry> QgsWmsParameters::highlightGeomAsGeom() const
664  {
665  return mWmsParameters[QgsWmsParameter::HIGHLIGHT_GEOM].toGeomList( ';' );
666  }
667 
669  {
670  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_SYMBOL ].toStringList( ';' );
671  }
672 
673  QString QgsWmsParameters::crs() const
674  {
675  QString rs;
676  const QString srs = mWmsParameters[ QgsWmsParameter::SRS ].toString();
677  const QString crs = mWmsParameters[ QgsWmsParameter::CRS ].toString();
678 
679  // both SRS/CRS are supported but there's a priority according to the
680  // specified version when both are defined in the request
681  if ( !srs.isEmpty() && crs.isEmpty() )
682  rs = srs;
683  else if ( srs.isEmpty() && !crs.isEmpty() )
684  rs = crs;
685  else if ( !srs.isEmpty() && !crs.isEmpty() )
686  {
687  if ( versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) )
688  rs = crs;
689  else
690  rs = srs;
691  }
692 
693  return rs;
694  }
695 
696  QString QgsWmsParameters::bbox() const
697  {
698  return mWmsParameters[ QgsWmsParameter::BBOX ].toString();
699  }
700 
702  {
703  return mWmsParameters[ QgsWmsParameter::BBOX ].toRectangle();
704  }
705 
706  QString QgsWmsParameters::height() const
707  {
708  return mWmsParameters[ QgsWmsParameter::HEIGHT ].toString();
709  }
710 
711  QString QgsWmsParameters::width() const
712  {
713  return mWmsParameters[ QgsWmsParameter::WIDTH ].toString();
714  }
715 
717  {
718  return mWmsParameters[ QgsWmsParameter::HEIGHT ].toInt();
719  }
720 
722  {
723  return mWmsParameters[ QgsWmsParameter::WIDTH ].toInt();
724  }
725 
727  {
728  return mWmsParameters[ QgsWmsParameter::SRCHEIGHT ].toString();
729  }
730 
732  {
733  return mWmsParameters[ QgsWmsParameter::SRCWIDTH ].toString();
734  }
735 
737  {
738  return mWmsParameters[ QgsWmsParameter::SRCHEIGHT ].toInt();
739  }
740 
742  {
743  return mWmsParameters[ QgsWmsParameter::SRCWIDTH ].toInt();
744  }
745 
746  QString QgsWmsParameters::dpi() const
747  {
748  return mWmsParameters[ QgsWmsParameter::DPI ].toString();
749  }
750 
752  {
753  return mWmsParameters[ QgsWmsParameter::DPI ].toDouble();
754  }
755 
757  {
758  const QString vStr = version();
759 
761 
762  if ( vStr.isEmpty() )
763  {
764  version = QgsProjectVersion( 1, 3, 0 ); // default value
765  }
766  else if ( mVersions.contains( QgsProjectVersion( vStr ) ) )
767  {
768  version = QgsProjectVersion( vStr );
769  }
770 
771  return version;
772  }
773 
774  bool QgsWmsParameters::versionIsValid( const QString version ) const
775  {
776  return mVersions.contains( QgsProjectVersion( version ) );
777  }
778 
780  {
781  return mWmsParameters[ QgsWmsParameter::FORMAT ].toString( true );
782  }
783 
785  {
786  const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::Format>() );
787  return metaEnum.valueToKey( format );
788  }
789 
791  {
792  const QString fStr = formatAsString();
793 
794  Format f = Format::NONE;
795  if ( fStr.compare( QLatin1String( "image/png" ), Qt::CaseInsensitive ) == 0 ||
796  fStr.compare( QLatin1String( "png" ), Qt::CaseInsensitive ) == 0 )
797  {
798  f = Format::PNG;
799  }
800  else if ( fStr.compare( QLatin1String( "jpg" ), Qt::CaseInsensitive ) == 0
801  || fStr.compare( QLatin1String( "jpeg" ), Qt::CaseInsensitive ) == 0
802  || fStr.compare( QLatin1String( "image/jpeg" ), Qt::CaseInsensitive ) == 0 )
803  {
804  f = Format::JPG;
805  }
806  else if ( fStr.compare( QLatin1String( "image/svg" ), Qt::CaseInsensitive ) == 0 ||
807  fStr.compare( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive ) == 0 ||
808  fStr.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 )
809  {
810  f = Format::SVG;
811  }
812  else if ( fStr.compare( QLatin1String( "application/pdf" ), Qt::CaseInsensitive ) == 0 ||
813  fStr.compare( QLatin1String( "pdf" ), Qt::CaseInsensitive ) == 0 )
814  {
815  f = Format::PDF;
816  }
817 
818  return f;
819  }
820 
822  {
823  return mWmsParameters[ QgsWmsParameter::INFO_FORMAT ].toString();
824  }
825 
827  {
828  return infoFormat() == Format::PNG || infoFormat() == Format::JPG;
829  }
830 
832  {
833  QString fStr = infoFormatAsString();
834 
835  Format f = Format::TEXT;
836  if ( fStr.isEmpty() )
837  return f;
838 
839  if ( fStr.startsWith( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) )
840  f = Format::XML;
841  else if ( fStr.startsWith( QLatin1String( "text/html" ), Qt::CaseInsensitive ) )
842  f = Format::HTML;
843  else if ( fStr.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
844  f = Format::TEXT;
845  else if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml" ), Qt::CaseInsensitive ) )
846  f = Format::GML;
847  else if ( fStr.startsWith( QLatin1String( "application/json" ), Qt::CaseInsensitive )
848  || fStr.startsWith( QLatin1String( "application/geo+json" ), Qt::CaseInsensitive ) )
849  f = Format::JSON;
850  else
851  f = Format::NONE;
852 
853  return f;
854  }
855 
857  {
858  if ( infoFormat() != Format::GML )
859  return -1;
860 
861  QString fStr = infoFormatAsString();
862  if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml/3" ), Qt::CaseInsensitive ) )
863  return 3;
864  else
865  return 2;
866  }
867 
868  QString QgsWmsParameters::i() const
869  {
870  return mWmsParameters[ QgsWmsParameter::I ].toString();
871  }
872 
873  QString QgsWmsParameters::j() const
874  {
875  return mWmsParameters[ QgsWmsParameter::J ].toString();
876  }
877 
879  {
880  return mWmsParameters[ QgsWmsParameter::I ].toInt();
881  }
882 
884  {
885  return mWmsParameters[ QgsWmsParameter::J ].toInt();
886  }
887 
888  QString QgsWmsParameters::x() const
889  {
890  return mWmsParameters[ QgsWmsParameter::X ].toString();
891  }
892 
893  QString QgsWmsParameters::y() const
894  {
895  return mWmsParameters[ QgsWmsParameter::Y ].toString();
896  }
897 
899  {
900  return mWmsParameters[ QgsWmsParameter::X ].toInt();
901  }
902 
904  {
905  return mWmsParameters[ QgsWmsParameter::Y ].toInt();
906  }
907 
908  QString QgsWmsParameters::rule() const
909  {
910  return mWmsParameters[ QgsWmsParameter::RULE ].toString();
911  }
912 
914  {
915  return mWmsParameters[ QgsWmsParameter::RULELABEL ].toString();
916  }
917 
919  {
920  return mWmsParameters[ QgsWmsParameter::RULELABEL ].toBool();
921  }
922 
924  {
925  return mWmsParameters[ QgsWmsParameter::TRANSPARENT ].toString();
926  }
927 
929  {
930  return mWmsParameters[ QgsWmsParameter::TRANSPARENT ].toBool();
931  }
932 
933  QString QgsWmsParameters::scale() const
934  {
935  return mWmsParameters[ QgsWmsParameter::SCALE ].toString();
936  }
937 
939  {
940  return mWmsParameters[ QgsWmsParameter::SCALE ].toDouble();
941  }
942 
944  {
945  return mWmsParameters[ QgsWmsParameter::IMAGE_QUALITY ].toString();
946  }
947 
949  {
950  return mWmsParameters[ QgsWmsParameter::IMAGE_QUALITY ].toInt();
951  }
952 
953  QString QgsWmsParameters::tiled() const
954  {
955  return mWmsParameters[ QgsWmsParameter::TILED ].toString();
956  }
957 
959  {
960  return mWmsParameters[ QgsWmsParameter::TILED ].toBool();
961  }
962 
964  {
965  return mWmsParameters[ QgsWmsParameter::SHOWFEATURECOUNT ].toString();
966  }
967 
969  {
970  return mWmsParameters[ QgsWmsParameter::SHOWFEATURECOUNT ].toBool();
971  }
972 
974  {
975  return mWmsParameters[ QgsWmsParameter::FEATURE_COUNT ].toString();
976  }
977 
979  {
980  return mWmsParameters[ QgsWmsParameter::FEATURE_COUNT ].toInt();
981  }
982 
984  {
985  return mWmsParameters[ QgsWmsParameter::BOXSPACE ].toString();
986  }
987 
989  {
990  return mWmsParameters[ QgsWmsParameter::BOXSPACE ].toDouble();
991  }
992 
994  {
995  return mWmsParameters[ QgsWmsParameter::LAYERSPACE ].toString();
996  }
997 
999  {
1000  return mWmsParameters[ QgsWmsParameter::LAYERSPACE ].toDouble();
1001  }
1002 
1004  {
1005  return mWmsParameters[ QgsWmsParameter::LAYERTITLESPACE ].toString();
1006  }
1007 
1009  {
1010  return mWmsParameters[ QgsWmsParameter::LAYERTITLESPACE ].toDouble();
1011  }
1012 
1014  {
1015  return mWmsParameters[ QgsWmsParameter::SYMBOLSPACE ].toString();
1016  }
1017 
1019  {
1020  return mWmsParameters[ QgsWmsParameter::SYMBOLSPACE ].toDouble();
1021  }
1022 
1024  {
1025  return mWmsParameters[ QgsWmsParameter::SYMBOLHEIGHT ].toString();
1026  }
1027 
1029  {
1030  return mWmsParameters[ QgsWmsParameter::SYMBOLHEIGHT ].toDouble();
1031  }
1032 
1034  {
1035  return mWmsParameters[ QgsWmsParameter::SYMBOLWIDTH ].toString();
1036  }
1037 
1039  {
1040  return mWmsParameters[ QgsWmsParameter::SYMBOLWIDTH ].toDouble();
1041  }
1042 
1044  {
1045  return mWmsParameters[ QgsWmsParameter::ICONLABELSPACE ].toString();
1046  }
1047 
1049  {
1050  return mWmsParameters[ QgsWmsParameter::ICONLABELSPACE ].toDouble();
1051  }
1052 
1054  {
1055  return mWmsParameters[ QgsWmsParameter::LAYERFONTFAMILY ].toString();
1056  }
1057 
1059  {
1060  return mWmsParameters[ QgsWmsParameter::ITEMFONTFAMILY ].toString();
1061  }
1062 
1064  {
1065  return mWmsParameters[ QgsWmsParameter::LAYERFONTBOLD ].toString();
1066  }
1067 
1069  {
1070  return mWmsParameters[ QgsWmsParameter::LAYERFONTBOLD ].toBool();
1071  }
1072 
1074  {
1075  return mWmsParameters[ QgsWmsParameter::ITEMFONTBOLD ].toString();
1076  }
1077 
1079  {
1080  return mWmsParameters[ QgsWmsParameter::FI_POLYGON_TOLERANCE ].toString();
1081  }
1082 
1084  {
1085  return mWmsParameters[ QgsWmsParameter::FI_LINE_TOLERANCE ].toString();
1086  }
1087 
1089  {
1090  return mWmsParameters[ QgsWmsParameter::FI_POINT_TOLERANCE ].toString();
1091  }
1092 
1094  {
1095  return mWmsParameters[ QgsWmsParameter::FI_POLYGON_TOLERANCE ].toInt();
1096  }
1097 
1099  {
1100  return mWmsParameters[ QgsWmsParameter::FI_LINE_TOLERANCE ].toInt();
1101  }
1102 
1104  {
1105  return mWmsParameters[ QgsWmsParameter::FI_POINT_TOLERANCE ].toInt();
1106  }
1107 
1109  {
1110  return mWmsParameters[ QgsWmsParameter::ITEMFONTBOLD ].toBool();
1111  }
1112 
1114  {
1115  return mWmsParameters[ QgsWmsParameter::LAYERFONTITALIC ].toString();
1116  }
1117 
1119  {
1120  return mWmsParameters[ QgsWmsParameter::LAYERFONTITALIC ].toBool();
1121  }
1122 
1124  {
1125  return mWmsParameters[ QgsWmsParameter::ITEMFONTITALIC ].toString();
1126  }
1127 
1129  {
1130  return mWmsParameters[ QgsWmsParameter::ITEMFONTITALIC ].toBool();
1131  }
1132 
1134  {
1135  return mWmsParameters[ QgsWmsParameter::LAYERFONTSIZE ].toString();
1136  }
1137 
1139  {
1140  return mWmsParameters[ QgsWmsParameter::LAYERFONTSIZE ].toDouble();
1141  }
1142 
1144  {
1145  return mWmsParameters[ QgsWmsParameter::LAYERFONTCOLOR ].toString();
1146  }
1147 
1149  {
1150  return mWmsParameters[ QgsWmsParameter::LAYERFONTCOLOR ].toColor();
1151  }
1152 
1154  {
1155  return mWmsParameters[ QgsWmsParameter::ITEMFONTSIZE ].toString();
1156  }
1157 
1159  {
1160  return mWmsParameters[ QgsWmsParameter::ITEMFONTSIZE ].toDouble();
1161  }
1162 
1164  {
1165  return mWmsParameters[ QgsWmsParameter::ITEMFONTCOLOR ].toString();
1166  }
1167 
1169  {
1170  return mWmsParameters[ QgsWmsParameter::ITEMFONTCOLOR ].toColor();
1171  }
1172 
1174  {
1175  QFont font;
1176  font.fromString( "" );
1177  font.setBold( layerFontBoldAsBool() );
1178  font.setItalic( layerFontItalicAsBool() );
1179 
1180  if ( ! layerFontSize().isEmpty() )
1181  font.setPointSizeF( layerFontSizeAsDouble() );
1182 
1183  if ( !layerFontFamily().isEmpty() )
1184  font.setFamily( layerFontFamily() );
1185 
1186  return font;
1187  }
1188 
1190  {
1191  QFont font;
1192  font.fromString( "" );
1193 
1194  font.setBold( itemFontBoldAsBool() );
1195  font.setItalic( itemFontItalicAsBool() );
1196 
1197  if ( ! itemFontSize().isEmpty() )
1198  font.setPointSizeF( itemFontSizeAsDouble() );
1199 
1200  if ( !itemFontFamily().isEmpty() )
1201  font.setFamily( itemFontFamily() );
1202 
1203  return font;
1204  }
1205 
1207  {
1208  return mWmsParameters[ QgsWmsParameter::LAYERTITLE ].toString();
1209  }
1210 
1212  {
1213  return mWmsParameters[ QgsWmsParameter::LAYERTITLE ].toBool();
1214  }
1215 
1217  {
1218  QgsLegendSettings settings;
1219  settings.setTitle( QString() );
1220  settings.setBoxSpace( boxSpaceAsDouble() );
1221  settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) );
1222 
1223  settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Top, layerSpaceAsDouble() );
1224  settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Bottom, layerTitleSpaceAsDouble() );
1225  settings.rstyle( QgsLegendStyle::Style::Subgroup ).setFont( layerFont() );
1226 
1227  if ( !itemFontColor().isEmpty() )
1228  {
1229  settings.setFontColor( itemFontColorAsColor() );
1230  }
1231 
1232  // Ok, this is tricky: because QgsLegendSettings's layerFontColor was added to the API after
1233  // fontColor, to fix regressions #21871 and #21870 and the previous behavior was to use fontColor
1234  // for the whole legend we need to preserve that behavior.
1235  // But, the 2.18 server parameters ITEMFONTCOLOR did not have effect on the layer titles too, so
1236  // we set explicitly layerFontColor to black if it's not overridden by LAYERFONTCOLOR argument.
1237  settings.setLayerFontColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1238 
1239  settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setFont( itemFont() );
1240  settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpaceAsDouble() );
1241  settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setMargin( QgsLegendStyle::Side::Left, iconLabelSpaceAsDouble() );
1242 
1243  return settings;
1244  }
1245 
1246  QString QgsWmsParameters::layoutParameter( const QString &id, bool &ok ) const
1247  {
1248  QString label;
1249  ok = false;
1250 
1251  if ( mUnmanagedParameters.contains( id.toUpper() ) )
1252  {
1253  label = mUnmanagedParameters[id.toUpper()];
1254  ok = true;
1255  }
1256 
1257  return label;
1258  }
1259 
1260  QStringList QgsWmsParameters::atlasPk() const
1261  {
1262  return mWmsParameters[ QgsWmsParameter::ATLAS_PK ].toStringList();
1263  }
1264 
1266  {
1267  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELSTRING ].toStringList( ';' );
1268  }
1269 
1271  {
1272  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELSIZE ].toStringList( ';' );
1273  }
1274 
1276  {
1277  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELSIZE ].toIntList( ';' );
1278  }
1279 
1281  {
1282  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELCOLOR ].toStringList( ';' );
1283  }
1284 
1286  {
1287  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELCOLOR ].toColorList( ';' );
1288  }
1289 
1291  {
1292  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ].toStringList( ';' );
1293  }
1294 
1296  {
1297  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ].toIntList( ';' );
1298  }
1299 
1301  {
1302  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELFONT ].toStringList( ';' );
1303  }
1304 
1306  {
1307  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ].toStringList( ';' );
1308  }
1309 
1311  {
1312  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ].toColorList( ';' );
1313  }
1314 
1316  {
1317  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ].toStringList( ';' );
1318  }
1319 
1321  {
1322  return mWmsParameters[ QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ].toDoubleList( ';' );
1323  }
1324 
1326  {
1327  return mWmsParameters[ QgsWmsParameter::WMS_PRECISION ].toString();
1328  }
1329 
1331  {
1332  return mWmsParameters[ QgsWmsParameter::WMS_PRECISION ].toInt();
1333  }
1334 
1336  {
1337  return mWmsParameters[ QgsWmsParameter::SLD_BODY ].toString();
1338  }
1339 
1340  QStringList QgsWmsParameters::filters() const
1341  {
1342  const QString filter = mWmsParameters[ QgsWmsParameter::FILTER ].toString();
1343  QStringList results;
1344  int pos = 0;
1345  while ( pos < filter.size() )
1346  {
1347  if ( pos + 1 < filter.size() && filter[pos] == '(' && filter[pos + 1] == '<' )
1348  {
1349  // OGC filter on multiple layers
1350  int posEnd = filter.indexOf( "Filter>)", pos );
1351  if ( posEnd < 0 )
1352  {
1353  posEnd = filter.size();
1354  }
1355  results.append( filter.mid( pos + 1, posEnd - pos + 6 ) );
1356  pos = posEnd + 8;
1357  }
1358  else if ( pos + 1 < filter.size() && filter[pos] == '(' && filter[pos + 1] == ')' )
1359  {
1360  // empty OGC filter
1361  results.append( "" );
1362  pos += 2;
1363  }
1364  else if ( filter[pos] == '<' )
1365  {
1366  // Single OGC filter
1367  results.append( filter.mid( pos ) );
1368  break;
1369  }
1370  else
1371  {
1372  // QGIS specific filter
1373  int posEnd = filter.indexOf( ';', pos + 1 );
1374  if ( posEnd < 0 )
1375  {
1376  posEnd = filter.size();
1377  }
1378  results.append( filter.mid( pos, posEnd - pos ) );
1379  pos = posEnd + 1;
1380  }
1381  }
1382  return results;
1383  }
1384 
1386  {
1387  return mWmsParameters[ QgsWmsParameter::FILTER_GEOM ].toString();
1388  }
1389 
1390  QStringList QgsWmsParameters::selections() const
1391  {
1392  return mWmsParameters[ QgsWmsParameter::SELECTION ].toStringList( ';' );
1393  }
1394 
1395  QStringList QgsWmsParameters::opacities() const
1396  {
1397  return mWmsParameters[ QgsWmsParameter::OPACITIES ].toStringList();
1398  }
1399 
1401  {
1402  return mWmsParameters[ QgsWmsParameter::OPACITIES ].toIntList();
1403  }
1404 
1406  {
1407  QStringList layer = mWmsParameters[ QgsWmsParameter::LAYER ].toStringList();
1408  const QStringList layers = mWmsParameters[ QgsWmsParameter::LAYERS ].toStringList();
1409  return layer << layers;
1410  }
1411 
1413  {
1414  return mWmsParameters[ QgsWmsParameter::QUERY_LAYERS ].toStringList();
1415  }
1416 
1417  QStringList QgsWmsParameters::allStyles() const
1418  {
1419  QStringList style = mWmsParameters[ QgsWmsParameter::STYLE ].toStyleList();
1420  const QStringList styles = mWmsParameters[ QgsWmsParameter::STYLES ].toStyleList();
1421  return style << styles;
1422  }
1423 
1424  QMultiMap<QString, QgsWmsParametersFilter> QgsWmsParameters::layerFilters( const QStringList &layers ) const
1425  {
1426  const QString nsWfs2 = QStringLiteral( "http://www.opengis.net/fes/2.0" );
1427  const QString prefixWfs2 = QStringLiteral( "<fes:" );
1428 
1429  const QStringList rawFilters = filters();
1430  QMultiMap<QString, QgsWmsParametersFilter> filters;
1431  for ( int i = 0; i < rawFilters.size(); i++ )
1432  {
1433  const QString f = rawFilters[i];
1434  if ( f.startsWith( QLatin1String( "<" ) ) \
1435  && f.endsWith( QLatin1String( "Filter>" ) ) \
1436  && i < layers.size() )
1437  {
1438  QgsWmsParametersFilter filter;
1439  filter.mFilter = f;
1442 
1443  if ( filter.mFilter.contains( nsWfs2 ) \
1444  || filter.mFilter.contains( prefixWfs2 ) )
1445  {
1447  }
1448 
1449  filters.insert( layers[i], filter );
1450  }
1451  else if ( !f.isEmpty() )
1452  {
1453  // filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
1454  // several filters can be defined for one layer
1455  const int colonIndex = f.indexOf( ':' );
1456  if ( colonIndex != -1 )
1457  {
1458  const QString layers = f.section( ':', 0, 0 );
1459  const QString filter = f.section( ':', 1 );
1460  const QStringList layersList = layers.split( ',' );
1461  for ( const QString &layer : layersList )
1462  {
1463  QgsWmsParametersFilter parametersFilter;
1464  parametersFilter.mFilter = filter;
1465  parametersFilter.mType = QgsWmsParametersFilter::SQL;
1466  filters.insert( layer, parametersFilter );
1467  }
1468  }
1469  else
1470  {
1471  QString filterStr = mWmsParameters[ QgsWmsParameter::FILTER ].toString();
1472  raiseError( QStringLiteral( "FILTER ('" ) + filterStr + QStringLiteral( "') is not properly formatted" ) );
1473  }
1474  }
1475  }
1476  return filters;
1477  }
1478 
1479  QList<QgsWmsParametersLayer> QgsWmsParameters::layersParameters() const
1480  {
1481  const QStringList layers = allLayersNickname();
1482  const QStringList styles = allStyles();
1483  const QStringList selection = selections();
1484  const QList<int> opacities = opacitiesAsInt();
1485  const QMultiMap<QString, QgsWmsParametersFilter> filters = layerFilters( layers );
1486 
1487  // selection format: "LayerName:id0,id1;LayerName2:id0,id1;..."
1488  // several filters can be defined for one layer
1489  QMultiMap<QString, QString> layerSelections;
1490  for ( const QString &s : selection )
1491  {
1492  const QStringList splits = s.split( ':' );
1493  if ( splits.size() == 2 )
1494  {
1495  layerSelections.insert( splits[0], splits[1] );
1496  }
1497  else
1498  {
1499  QString selStr = mWmsParameters[ QgsWmsParameter::SELECTION ].toString();
1500  raiseError( QStringLiteral( "SELECTION ('" ) + selStr + QStringLiteral( "') is not properly formatted" ) );
1501  }
1502  }
1503 
1504  QList<QgsWmsParametersLayer> parameters;
1505  for ( int i = 0; i < layers.size(); i++ )
1506  {
1507  QString layer = layers[i];
1508 
1509  if ( isExternalLayer( layer ) )
1510  continue;
1511 
1512  QgsWmsParametersLayer param;
1513  param.mNickname = layer;
1514 
1515  if ( i < styles.count() )
1516  param.mStyle = styles[i];
1517 
1518  if ( i < opacities.count() )
1519  param.mOpacity = opacities[i];
1520 
1521  if ( filters.contains( layer ) )
1522  {
1523  auto it = filters.find( layer );
1524  while ( it != filters.end() && it.key() == layer )
1525  {
1526  param.mFilter.append( it.value() );
1527  ++it;
1528  }
1529  }
1530 
1531  if ( layerSelections.contains( layer ) )
1532  {
1533  QMultiMap<QString, QString>::const_iterator it;
1534  it = layerSelections.constFind( layer );
1535  while ( it != layerSelections.constEnd() && it.key() == layer )
1536  {
1537  param.mSelection << it.value().split( ',' );
1538  ++it;
1539  }
1540  }
1541 
1542  parameters.append( param );
1543  }
1544 
1545  return parameters;
1546  }
1547 
1548  QList<QgsWmsParametersHighlightLayer> QgsWmsParameters::highlightLayersParameters() const
1549  {
1550  QList<QgsWmsParametersHighlightLayer> params;
1551  QList<QgsGeometry> geoms = highlightGeomAsGeom();
1552  QStringList slds = highlightSymbol();
1553  QStringList labels = highlightLabelString();
1554  QList<QColor> colors = highlightLabelColorAsColor();
1555  QList<int> sizes = highlightLabelSizeAsInt();
1556  QList<int> weights = highlightLabelWeightAsInt();
1557  QStringList fonts = highlightLabelFont();
1558  QList<QColor> bufferColors = highlightLabelBufferColorAsColor();
1559  QList<double> bufferSizes = highlightLabelBufferSizeAsFloat();
1560 
1561  int nLayers = std::min( geoms.size(), slds.size() );
1562  for ( int i = 0; i < nLayers; i++ )
1563  {
1565  param.mName = QStringLiteral( "highlight_" ) + QString::number( i );
1566  param.mGeom = geoms[i];
1567  param.mSld = slds[i];
1568 
1569  if ( i < labels.count() )
1570  param.mLabel = labels[i];
1571 
1572  if ( i < colors.count() )
1573  param.mColor = colors[i];
1574 
1575  if ( i < sizes.count() )
1576  param.mSize = sizes[i];
1577 
1578  if ( i < weights.count() )
1579  param.mWeight = weights[i];
1580 
1581  if ( i < fonts.count() )
1582  param.mFont = fonts[ i ];
1583 
1584  if ( i < bufferColors.count() )
1585  param.mBufferColor = bufferColors[i];
1586 
1587  if ( i < bufferSizes.count() )
1588  param.mBufferSize = bufferSizes[i];
1589 
1590  params.append( param );
1591  }
1592 
1593  return params;
1594  }
1595 
1596  QList<QgsWmsParametersExternalLayer> QgsWmsParameters::externalLayersParameters() const
1597  {
1598  auto notExternalLayer = []( const QString & name ) { return ! QgsWmsParameters::isExternalLayer( name ); };
1599 
1600  QList<QgsWmsParametersExternalLayer> externalLayers;
1601 
1602  QStringList layers = allLayersNickname();
1603  QStringList::iterator rit = std::remove_if( layers.begin(), layers.end(), notExternalLayer );
1604 
1605  for ( QStringList::iterator it = layers.begin(); it != rit; ++it )
1606  {
1607  externalLayers << externalLayerParameter( *it );
1608  }
1609 
1610  return externalLayers;
1611  }
1612 
1614  {
1615  return mWmsParameters[ QgsWmsParameter::BGCOLOR ].toString();
1616  }
1617 
1619  {
1620  return mWmsParameters[ QgsWmsParameter::BGCOLOR ].toColor();
1621  }
1622 
1624  {
1625  return mWmsParameters[ QgsWmsParameter::TEMPLATE ].toString();
1626  }
1627 
1629  {
1630  QgsWmsParameter wmsParam;
1632  param.mId = mapId;
1633 
1634  //map extent is mandatory
1635  QString extentStr;
1636  wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1637  if ( wmsParam.isValid() )
1638  {
1639  extentStr = wmsParam.toString();
1640  }
1641 
1642  if ( extentStr.isEmpty() )
1643  {
1644  return param;
1645  }
1646 
1647  QString pMapId = QStringLiteral( "MAP" ) + QString::number( mapId );
1648 
1649  wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1650  QgsRectangle extent;
1651  if ( wmsParam.isValid() )
1652  {
1653  extent = wmsParam.toRectangle();
1654  }
1655 
1656  if ( extent.isEmpty() )
1657  return param;
1658 
1659  param.mHasExtent = !extent.isEmpty();
1660  param.mExtent = extent;
1661 
1662  // scale
1663  wmsParam = idParameter( QgsWmsParameter::SCALE, mapId );
1664  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1665  {
1666  param.mScale = wmsParam.toDouble();
1667  }
1668 
1669  // rotation
1670  wmsParam = idParameter( QgsWmsParameter::ROTATION, mapId );
1671  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1672  {
1673  param.mRotation = wmsParam.toDouble();
1674  }
1675 
1676  //grid space x / y
1677  double gridx( -1 ), gridy( -1 );
1678 
1679  wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_X, mapId );
1680  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1681  {
1682  gridx = wmsParam.toDouble();
1683  }
1684 
1685  wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_Y, mapId );
1686  if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1687  {
1688  gridy = wmsParam.toDouble();
1689  }
1690 
1691  if ( gridx != -1 && gridy != -1 )
1692  {
1693  param.mGridX = gridx;
1694  param.mGridY = gridy;
1695  }
1696 
1697  //layers
1698  QStringList allLayers;
1699  wmsParam = idParameter( QgsWmsParameter::LAYERS, mapId );
1700  if ( wmsParam.isValid() )
1701  {
1702  allLayers = wmsParam.toStringList();
1703  }
1704 
1705  // external layers
1706  QStringList layers;
1707  QList<QgsWmsParametersExternalLayer> eParams;
1708 
1709  for ( const auto &layer : qgis::as_const( allLayers ) )
1710  {
1711  if ( isExternalLayer( layer ) )
1712  {
1713  eParams << externalLayerParameter( layer );
1714  }
1715  else
1716  {
1717  layers << layer;
1718  }
1719  }
1720  param.mExternalLayers = eParams;
1721 
1722  QStringList styles;
1723  wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
1724  if ( wmsParam.isValid() )
1725  {
1726  styles = wmsParam.toStyleList();
1727  }
1728 
1729  QList<QgsWmsParametersLayer> lParams;
1730  for ( int i = 0; i < layers.size(); i++ )
1731  {
1732  QString layer = layers[i];
1733  QgsWmsParametersLayer lParam;
1734  lParam.mNickname = layer;
1735 
1736  if ( i < styles.count() )
1737  lParam.mStyle = styles[i];
1738 
1739  lParams.append( lParam );
1740  }
1741  param.mLayers = lParams;
1742 
1743  //highlight layers
1744  QList<QgsWmsParametersHighlightLayer> hParams;
1745 
1746  QList<QgsGeometry> geoms;
1747  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_GEOM, mapId );
1748  if ( wmsParam.isValid() )
1749  {
1750  geoms = wmsParam.toGeomList( ';' );
1751  }
1752 
1753  QStringList slds;
1754  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_SYMBOL, mapId );
1755  if ( wmsParam.isValid() )
1756  {
1757  slds = wmsParam.toStringList( ';' );
1758  }
1759 
1760  QStringList labels;
1761  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSTRING, mapId );
1762  if ( wmsParam.isValid() )
1763  {
1764  labels = wmsParam.toStringList( ';' );
1765  }
1766 
1767  QStringList fonts;
1768  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELFONT, mapId );
1769  if ( wmsParam.isValid() )
1770  {
1771  fonts = wmsParam.toStringList( ';' );
1772  }
1773 
1774  QList<QColor> colors;
1775  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELCOLOR, mapId );
1776  if ( wmsParam.isValid() )
1777  {
1778  colors = wmsParam.toColorList( ';' );
1779  }
1780 
1781  QList<int> sizes;
1782  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSIZE, mapId );
1783  if ( wmsParam.isValid() )
1784  {
1785  sizes = wmsParam.toIntList( ';' );
1786  }
1787 
1788  QList<int> weights;
1789  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT, mapId );
1790  if ( wmsParam.isValid() )
1791  {
1792  weights = wmsParam.toIntList( ';' );
1793  }
1794 
1795  QList<QColor> bufferColors;
1796  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR, mapId );
1797  if ( wmsParam.isValid() )
1798  {
1799  bufferColors = wmsParam.toColorList( ';' );
1800  }
1801 
1802  QList<double> bufferSizes;
1803  wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE, mapId );
1804  if ( wmsParam.isValid() )
1805  {
1806  bufferSizes = wmsParam.toDoubleList( ';' );
1807  }
1808 
1809  int nHLayers = std::min( geoms.size(), slds.size() );
1810  for ( int i = 0; i < nHLayers; i++ )
1811  {
1813  hParam.mName = pMapId + QStringLiteral( "_highlight_" ) + QString::number( i );
1814  hParam.mGeom = geoms[i];
1815  hParam.mSld = slds[i];
1816 
1817  if ( i < labels.count() )
1818  hParam.mLabel = labels[i];
1819 
1820  if ( i < colors.count() )
1821  hParam.mColor = colors[i];
1822 
1823  if ( i < sizes.count() )
1824  hParam.mSize = sizes[i];
1825 
1826  if ( i < weights.count() )
1827  hParam.mWeight = weights[i];
1828 
1829  if ( i < fonts.count() )
1830  hParam.mFont = fonts[ i ];
1831 
1832  if ( i < bufferColors.count() )
1833  hParam.mBufferColor = bufferColors[i];
1834 
1835  if ( i < bufferSizes.count() )
1836  hParam.mBufferSize = bufferSizes[i];
1837 
1838  hParams.append( hParam );
1839  }
1840  param.mHighlightLayers = hParams;
1841 
1842  return param;
1843  }
1844 
1845  QString QgsWmsParameters::externalWMSUri( const QString &id ) const
1846  {
1847  if ( !mExternalWMSParameters.contains( id ) )
1848  {
1849  return QString();
1850  }
1851 
1852  QgsDataSourceUri wmsUri;
1853  const QMap<QString, QString> &paramMap = mExternalWMSParameters[ id ];
1854  QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin();
1855  for ( ; paramIt != paramMap.constEnd(); ++paramIt )
1856  {
1857  wmsUri.setParam( paramIt.key().toLower(), paramIt.value() );
1858  }
1859  return wmsUri.encodedUri();
1860  }
1861 
1863  {
1864  return mWmsParameters[ QgsWmsParameter::WITH_GEOMETRY ].toBool();
1865  }
1866 
1868  {
1869  return mWmsParameters[ QgsWmsParameter::WITH_MAPTIP ].toBool();
1870  }
1871 
1873  {
1874  return mWmsParameters[ QgsWmsParameter::WMTVER ].toString();
1875  }
1876 
1877  void QgsWmsParameters::log( const QString &msg ) const
1878  {
1879  QgsMessageLog::logMessage( msg, QStringLiteral( "Server" ), Qgis::Info );
1880  }
1881 
1882  void QgsWmsParameters::raiseError( const QString &msg ) const
1883  {
1885  }
1886 
1887  QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
1888  {
1889  QgsWmsParameter p;
1890 
1891  for ( const auto &param : mWmsParameters.values( name ) )
1892  {
1893  if ( param.mId == id )
1894  {
1895  p = param;
1896  }
1897  }
1898 
1899  return p;
1900  }
1901 
1902  QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
1903  {
1905 
1906  param.mName = name;
1907  param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
1908  param.mUri = externalWMSUri( param.mName );
1909 
1910  return param;
1911  }
1912 
1913  bool QgsWmsParameters::isExternalLayer( const QString &name )
1914  {
1915  return name.startsWith( EXTERNAL_LAYER_PREFIX );
1916  }
1917 
1919  {
1920  QStringList attributes;
1921  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1922 
1923  if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
1924  {
1925  attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
1926  }
1927 
1928  return attributes;
1929  }
1930 
1932  {
1933  bool use = false;
1934  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1935 
1936  if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
1937  {
1938  use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
1939  }
1940 
1941  return use;
1942  }
1943 
1945  {
1946  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1947 
1948  double scale = -1;
1949  if ( options.contains( DxfFormatOption::SCALE ) )
1950  {
1951  scale = options[ DxfFormatOption::SCALE ].toDouble();
1952  }
1953 
1954  return scale;
1955  }
1956 
1958  {
1959  const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1960 
1962 
1963  if ( ! options.contains( DxfFormatOption::MODE ) )
1964  {
1965  return symbol;
1966  }
1967 
1968  const QString mode = options[ DxfFormatOption::MODE ];
1969  if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
1970  {
1972  }
1973  else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
1974  {
1976  }
1977 
1978  return symbol;
1979  }
1980 
1982  {
1983  QString codec = QStringLiteral( "ISO-8859-1" );
1984 
1985  if ( dxfFormatOptions().contains( DxfFormatOption::CODEC ) )
1986  {
1987  codec = dxfFormatOptions()[ DxfFormatOption::CODEC ];
1988  }
1989 
1990  return codec;
1991  }
1992 
1993  QMap<QgsWmsParameters::DxfFormatOption, QString> QgsWmsParameters::dxfFormatOptions() const
1994  {
1995  QMap<QgsWmsParameters::DxfFormatOption, QString> options;
1996 
1997  const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::DxfFormatOption>() );
1998  const QStringList opts = mWmsParameters[ QgsWmsParameter::FORMAT_OPTIONS ].toStringList( ';' );
1999 
2000  for ( auto it = opts.constBegin(); it != opts.constEnd(); ++it )
2001  {
2002  const int equalIdx = it->indexOf( ':' );
2003  if ( equalIdx > 0 && equalIdx < ( it->length() - 1 ) )
2004  {
2005  const QString name = it->left( equalIdx ).toUpper();
2006  const QgsWmsParameters::DxfFormatOption option =
2007  ( QgsWmsParameters::DxfFormatOption ) metaEnum.keyToValue( name.toStdString().c_str() );
2008  const QString value = it->right( it->length() - equalIdx - 1 );
2009  options.insert( option, value );
2010  }
2011  }
2012 
2013  return options;
2014  }
2015 
2016  QMap<QString, QString> QgsWmsParameters::dimensionValues() const
2017  {
2018  QMap<QString, QString> dimValues;
2019  const QMetaEnum pnMetaEnum( QMetaEnum::fromType<QgsVectorLayerServerProperties::PredefinedWmsDimensionName>() );
2020  const QStringList unmanagedNames = mUnmanagedParameters.keys();
2021  for ( const QString &key : unmanagedNames )
2022  {
2023  if ( key.startsWith( QStringLiteral( "DIM_" ) ) )
2024  {
2025  dimValues[key.mid( 4 )] = mUnmanagedParameters[key];
2026  }
2027  else if ( pnMetaEnum.keyToValue( key.toUpper().toStdString().c_str() ) != -1 )
2028  {
2029  dimValues[key] = mUnmanagedParameters[key];
2030  }
2031  }
2032  return dimValues;
2033  }
2034 }
bool versionIsValid(const QString version) const
Returns true if version is valid, false otherwise.
Export only data.
Definition: qgsdxfexport.h:86
QList< QgsWmsParametersHighlightLayer > highlightLayersParameters() const
Returns parameters for each highlight layer.
int srcHeightAsInt() const
Returns SRCHEIGHT parameter as an int or its default value if not defined.
QFont layerFont() const
Returns the layer font (built thanks to the LAYERFONTFAMILY, LAYERFONTSIZE, LAYERFONTBOLD, ...
QString layerFontSize() const
Returns LAYERFONTSIZE parameter or an empty string if not defined.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
void dump() const
Dumps parameters.
int imageQualityAsInt() const
Returns IMAGE_QUALITY parameter as an integer.
QStringList highlightLabelWeight() const
Returns HIGHLIGHT_LABELWEIGHT as a list of string.
void setBoxSpace(double s)
QgsRectangle toRectangle() const
Converts the parameter into a rectangle.
QList< double > highlightLabelBufferSizeAsFloat() const
Returns HIGHLIGHT_LABELBUFFERSIZE as a list of float.
QString typeName() const
Returns the type of the parameter as a string.
double symbolHeightAsDouble() const
Returns SYMBOLHEIGHT as a double or its default value if not defined.
QUrl toUrl() const
Converts the parameter into an url.
QString transparent() const
Returns TRANSPARENT parameter or an empty string if not defined.
QString i() const
Returns I parameter or an empty string if not defined.
QList< QColor > highlightLabelColorAsColor() const
Returns HIGHLIGHT_LABELCOLOR as a list of color.
QMap< QString, QString > mUnmanagedParameters
const QString EXTERNAL_LAYER_PREFIX
int featureCountAsInt() const
Returns FEATURE_COUNT as an integer.
QStringList filters() const
Returns the list of filters found in FILTER parameter.
QString itemFontSize() const
Returns ITEMFONTSIZE parameter or an empty string if not defined.
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid.
QString j() const
Returns J parameter or an empty string if not defined.
QStringList highlightLabelBufferSize() const
Returns HIGHLIGHT_LABELBUFFERSIZE.
QString backgroundColor() const
Returns BGCOLOR parameter or an empty string if not defined.
QgsWmsParameter::Name mName
QList< QgsWmsParametersLayer > mLayers
QString srcWidth() const
Returns SRCWIDTH parameter or an empty string if not defined.
QString dxfCodec() const
Returns the DXF CODEC parameter.
int toInt() const
Converts the parameter into an integer.
QString scale() const
Returns SCALE parameter or an empty string if none is defined.
void setSymbolSize(QSizeF s)
QList< QColor > toColorList(const char delimiter=',') const
Converts the parameter into a list of colors.
QString layerFontBold() const
Returns LAYERFONTBOLD parameter or an empty string if not defined.
QString value(const QString &key) const
Returns the value of a parameter.
QgsLegendSettings legendSettings() const
Returns legend settings.
QList< QgsGeometry > toGeomList(const char delimiter=',') const
Converts the parameter into a list of geometries.
QString sldBody() const
Returns SLD_body if defined or an empty string.
QgsDxfExport::SymbologyExport dxfMode() const
Returns the DXF MODE parameter.
static void raiseError(const QString &msg)
Raises an exception in case of an invalid parameters.
int yAsInt() const
Returns Y parameter as an int or its default value if not defined.
double symbolSpaceAsDouble() const
Returns SYMBOLSPACE as a double or its default value if not defined.
double dpiAsDouble() const
Returns DPI parameter as an int or its default value if not defined.
double toDouble() const
Converts the parameter into a double.
QString loadUrl(bool &ok) const
Loads the data associated to the parameter converted into an url.
bool dxfUseLayerTitleAsName() const
Returns the DXF USE_TITLE_AS_LAYERNAME parameter.
bool isValid() const override
Returns true if the parameter is valid, false otherwise.
Format
Output format for the response.
QList< int > highlightLabelWeightAsInt() const
Returns HIGHLIGHT_LABELWEIGHT as a list of int.
int widthAsInt() const
Returns WIDTH parameter as an int or its default value if not defined.
void load(const QUrlQuery &query)
Loads new parameters.
double layerTitleSpaceAsDouble() const
Returns LAYERTITLESPACE as a double.
QString layerTitle() const
Returns LAYERTITLE parameter or an empty string if not defined.
QString symbolSpace() const
Returns SYMBOLSPACE parameter or an empty string if not defined.
QString layerFontColor() const
Returns LAYERFONTCOLOR parameter or an empty string if not defined.
Exception thrown in case of malformed request.
Format infoFormat() const
Returns infoFormat.
double layerSpaceAsDouble() const
Returns LAYERSPACE as a double or its default value if not defined.
QString featureCount() const
Returns FEATURE_COUNT parameter or an empty string if none is defined.
bool transparentAsBool() const
Returns TRANSPARENT parameter as a bool or its default value if not defined.
QString layerFontFamily() const
Returns LAYERFONTFAMILY parameter or an empty string if not defined.
DxfFormatOption
Options for DXF format.
QString symbolWidth() const
Returns SYMBOLWIDTH parameter or an empty string if not defined.
QStringList selections() const
Returns the list of feature selection found in SELECTION parameter.
bool withMapTip() const
withMapTip
QString bbox() const
Returns BBOX if defined or an empty string.
double iconLabelSpaceAsDouble() const
Returns ICONLABELSPACE as a double or its default value if not defined.
bool ruleLabelAsBool() const
Returns RULELABEL as a bool.
void raiseError() const
Raises an error in case of an invalid conversion.
bool showFeatureCountAsBool() const
Returns SHOWFEATURECOUNT as a bool.
QStringList highlightSymbol() const
Returns HIGHLIGHT_SYMBOL as a list of string.
QString tiled() const
Returns TILED parameter or an empty string if not defined.
QList< int > highlightLabelSizeAsInt() const
Returns HIGHLIGHT_LABELSIZE as a list of int An exception is raised if an invalid size is found...
double itemFontSizeAsDouble() const
Returns ITEMFONTSIZE as a double.
double toDouble(bool &ok) const
Converts the parameter into a double.
QStringList allLayersNickname() const
Returns nickname of layers found in LAYER and LAYERS parameters.
int lineToleranceAsInt() const
Returns FI_LINE_TOLERANCE parameter as an integer.
QUrl toUrl(bool &ok) const
Converts the parameter into an url.
void setFont(const QFont &font)
Sets the font used for rendering this legend component.
QStringList opacities() const
Returns the list of opacities found in OPACITIES parameter.
QString x() const
Returns X parameter or an empty string if not defined.
QString layoutParameter(const QString &id, bool &ok) const
Returns a layout parameter thanks to its id.
QList< double > toDoubleList(bool &ok, char delimiter=',') const
Converts the parameter into a list of doubles.
QString itemFontColor() const
Returns ITEMFONTCOLOR parameter or an empty string if not defined.
QString itemFontItalic() const
Returns ITEMFONTITALIC parameter or an empty string if not defined.
QStringList highlightLabelString() const
Returns HIGHLIGHT_LABELSTRING as a list of string.
QString crs() const
Returns CRS or an empty string if none is defined.
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:426
QList< int > toIntList(bool &ok, char delimiter=',') const
Converts the parameter into a list of integers.
QgsRectangle toRectangle(bool &ok) const
Converts the parameter into a rectangle.
QString filterGeom() const
Returns the filter geometry found in FILTER_GEOM parameter.
QString layerSpace() const
Returns LAYERSPACE parameter or an empty string if not defined.
A class to describe the version of a project.
QStringList highlightLabelSize() const
Returns HIGHLIGHT_LABELSIZE as a list of string.
Provides an interface to retrieve and manipulate WMS parameters received from the client...
int infoFormatVersion() const
Returns the infoFormat version for GML.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QStringList highlightLabelBufferColor() const
Returns HIGHLIGHT_LABELBUFFERCOLOR as a list of string.
QString version() const
Returns VERSION parameter as a string or an empty string if not defined.
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
QUrlQuery urlQuery() const
Returns a url query with underlying parameters.
QMap< QString, QString > dimensionValues() const
Returns the dimensions parameter.
bool tiledAsBool() const
Returns TILED parameter as a boolean.
QString imageQuality() const
Returns IMAGE_QUALITY parameter or an empty string if not defined.
QList< QgsWmsParametersHighlightLayer > mHighlightLayers
QString loadUrl() const
Loads the data associated to the parameter converted into an url.
void setTitle(const QString &t)
QString composerTemplate() const
Returns TEMPLATE parameter or an empty string if not defined.
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value.
QgsWmsParameters()
Constructor for WMS parameters with default values only.
void setMargin(Side side, double margin)
Sets the margin (in mm) for the specified side of the component.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
QColor toColor(bool &ok) const
Converts the parameter into a color.
QStringList toStringList(char delimiter=',', bool skipEmptyParts=true) const
Converts the parameter into a list of strings.
QStringList queryLayersNickname() const
Returns nickname of layers found in QUERY_LAYERS parameter.
void setFontColor(const QColor &c)
QgsWmsParametersFilter::Type mType
int pointToleranceAsInt() const
Returns FI_POINT_TOLERANCE parameter as an integer.
Format format() const
Returns format.
Keeps the number of features and export symbology per feature (using the first symbol level) ...
Definition: qgsdxfexport.h:87
QgsOgcUtils::FilterVersion mVersion
void set(QgsWmsParameter::Name name, const QVariant &value)
Sets a parameter value thanks to its name.
bool itemFontItalicAsBool() const
Returns ITEMFONTITALIC as a boolean or its default value if not defined.
int polygonToleranceAsInt() const
Returns FI_POLYGON_TOLERANCE parameter as an integer.
QList< double > toDoubleList(const char delimiter=',') const
Converts the parameter into a list of doubles.
bool layerTitleAsBool() const
Returns LAYERTITLE as a bool or its default value if not defined.
Median cut implementation.
bool withGeometry() const
Returns if the client wants the feature info response with geometry information.
double symbolWidthAsDouble() const
Returns SYMBOLWIDTH as a double or its default value if not defined.
void setLayerFontColor(const QColor &fontColor)
Sets layer font color to fontColor Overrides fontColor()
int heightAsInt() const
Returns HEIGHT parameter as an int or its default value if not defined.
QString layerTitleSpace() const
Returns LAYERTITLESPACE 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.
double boxSpaceAsDouble() const
Returns BOXSPACE as a double or its default value if not defined.
QgsLegendStyle & rstyle(QgsLegendStyle::Style s)
Returns reference to modifiable style.
int toInt(bool &ok) const
Converts the parameter into an integer.
QList< QgsWmsParametersExternalLayer > mExternalLayers
QStringList allStyles() const
Returns styles found in STYLE and STYLES parameters.
int jAsInt() const
Returns J parameter as an int or its default value if not defined.
double scaleAsDouble() const
Returns SCALE as a double.
QFont itemFont() const
Returns the item font (built thanks to the ITEMFONTFAMILY, ITEMFONTSIZE, ITEMFONTBOLD, ...
QColor layerFontColorAsColor() const
Returns LAYERFONTCOLOR as a color or its defined value if not defined.
QgsWmsParameter operator[](QgsWmsParameter::Name name) const
Returns the parameter corresponding to name.
QString name() const
Returns the name of the parameter.
QString pointTolerance() const
Returns FI_POINT_TOLERANCE parameter or an empty string if not defined.
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
QString toString(bool defaultValue=false) const
Converts the parameter into a string.
double dxfScale() const
Returns the DXF SCALE parameter.
QString boxSpace() const
Returns BOXSPACE parameter or an empty string if not defined.
QString width() const
Returns WIDTH parameter or an empty string if not defined.
virtual bool isValid() const
Returns true if the parameter is valid, false otherwise.
bool itemFontBoldAsBool() const
Returns ITEMFONTBOLD as a boolean or its default value if not defined.
QgsWmsParameter(const QgsWmsParameter::Name name=QgsWmsParameter::UNKNOWN, const QVariant::Type type=QVariant::String, const QVariant defaultValue=QVariant(""))
Constructor for QgsWmsParameter.
QString polygonTolerance() const
Returns FI_POLYGON_TOLERANCE parameter or an empty string if not defined.
QString symbolHeight() const
Returns SYMBOLHEIGHT parameter or an empty string if not defined.
QStringList atlasPk() const
Returns the ATLAS_PK parameter.
QList< int > opacitiesAsInt() const
Returns the list of opacities found in OPACITIES parameter as integers.
QList< int > toIntList(const char delimiter=',') const
Converts the parameter into a list of integers.
QColor itemFontColorAsColor() const
Returns ITEMFONTCOLOR as a color.
QString formatAsString() const
Returns FORMAT parameter as a string.
QStringList dxfLayerAttributes() const
Returns the DXF LAYERATTRIBUTES parameter.
bool layerFontBoldAsBool() const
Returns LAYERFONTBOLD as a boolean or its default value if not defined.
QString lineTolerance() const
Returns FI_LINE_TOLERANCE parameter or an empty string if not defined.
QString height() const
Returns HEIGHT parameter or an empty string if not defined.
QString rule() const
Returns RULE parameter or an empty string if none is defined.
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 y() const
Returns Y parameter or an empty string if not defined.
int srcWidthAsInt() const
Returns SRCWIDTH parameter as an int or its default value if not defined.
QColor backgroundColorAsColor() const
Returns BGCOLOR parameter as a QColor or its default value if not defined.
QList< QgsGeometry > toGeomList(bool &ok, char delimiter=',') const
Converts the parameter into a list of geometries.
QString layerFontItalic() const
Returns LAYERFONTITALIC parameter or an empty string if not defined.
QString wmtver() const
Returns WMTVER parameter or an empty string if not defined.
QMap< DxfFormatOption, QString > dxfFormatOptions() const
Returns a map of DXF options defined within FORMAT_OPTIONS parameter.
QString showFeatureCount() const
Returns SHOWFEATURECOUNT parameter or an empty string if none is defined.
QString srcHeight() const
Returns SRCHEIGHT parameter or an empty string if not defined.
Class for storing the component parts of a RDBMS data source URI (e.g.
QList< QgsWmsParametersExternalLayer > externalLayersParameters() const
Returns parameters for each external layer.
QString dpi() const
Returns DPI parameter or an empty string if not defined.
QString infoFormatAsString() const
Returns INFO_FORMAT parameter as a string.
int iAsInt() const
Returns I parameter as an int or its default value if not defined.
bool layerFontItalicAsBool() const
Returns LAYERFONTITALIC as a boolean or its default value if not defined.
QList< QgsWmsParametersLayer > layersParameters() const
Returns parameters for each layer found in LAYER/LAYERS.
bool infoFormatIsImage() const
Checks if INFO_FORMAT parameter is one of the image formats (PNG, JPG).
QString itemFontBold() const
Returns ITEMFONTBOLD parameter or an empty string if not defined.
QgsWmsParametersComposerMap composerMapParameters(int mapId) const
Returns the requested parameters for a composer map parameter.
QString iconLabelSpace() const
Returns ICONLABELSPACE parameter or an empty string if not defined.
QList< QColor > toColorList(bool &ok, char delimiter=',') const
Converts the parameter into a list of colors.
QList< QgsWmsParametersFilter > mFilter
QStringList highlightLabelColor() const
Returns HIGHLIGHT_LABELCOLOR as a list of string.
QColor toColor() const
Converts the parameter into a color.
WMS parameter received from the client.
double layerFontSizeAsDouble() const
Returns LAYERFONTSIZE as a double.
QStringList highlightGeom() const
Returns HIGHLIGHT_GEOM as a list of string in WKT.
QList< QgsGeometry > highlightGeomAsGeom() const
Returns HIGHLIGHT_GEOM as a list of geometries.
QList< QColor > highlightLabelBufferColorAsColor() const
Returns HIGHLIGHT_LABELBUFFERCOLOR as a list of colors.
QString ruleLabel() const
Returns RULELABEL parameter or an empty string if none is defined.
QString externalWMSUri(const QString &id) const
Returns the external WMS uri.
QString itemFontFamily() const
Returns ITEMFONTFAMILY parameter or an empty string if not defined.
QString wmsPrecision() const
Returns WMS_PRECISION parameter or an empty string if not defined.
int xAsInt() const
Returns X parameter as an int or its default value if not defined.
QStringList highlightLabelFont() const
Returns HIGHLIGHT_LABELFONT.
Name
Available parameters for WMS requests.
Exports one feature per symbol layer (considering symbol levels)
Definition: qgsdxfexport.h:88
Definition of a parameter with basic conversion methods.