QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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"
23#include <QRegularExpression>
24
25const QString EXTERNAL_LAYER_PREFIX = QStringLiteral( "EXTERNAL_WMS:" );
26
27namespace QgsWms
28{
29 //
30 // QgsWmsParameter
31 //
33 const QVariant::Type type,
34 const QVariant defaultValue )
35 : QgsServerParameterDefinition( type, defaultValue )
36 , mName( name )
37 {
38 }
39
41 {
43 }
44
46 {
47 const QString msg = QString( "%1 ('%2') cannot be converted into %3" ).arg( name( mName ), toString(), typeName() );
49 }
50
51 QStringList QgsWmsParameter::toStyleList( const char delimiter ) const
52 {
53 return QgsServerParameterDefinition::toStringList( delimiter, false );
54 }
55
56 QList<QgsGeometry> QgsWmsParameter::toGeomList( const char delimiter ) const
57 {
58 bool ok = true;
59 const QList<QgsGeometry> geoms = QgsServerParameterDefinition::toGeomList( ok, delimiter );
60
61 if ( !ok )
62 {
63 const QString msg = QString( "%1 ('%2') cannot be converted into a list of geometries" ).arg( name( mName ), toString() );
65 }
66
67 return geoms;
68 }
69
71 {
72 bool ok = true;
74
75 if ( !ok )
76 {
77 const QString msg = QString( "%1 ('%2') cannot be converted into a rectangle" ).arg( name( mName ), toString() );
79 }
80
81 return rect;
82 }
83
85 {
86 bool ok = false;
87 const int val = QgsServerParameterDefinition::toInt( ok );
88
89 if ( !ok )
90 {
91 raiseError();
92 }
93
94 return val;
95 }
96
98 {
99 // Check URL -- it will be used in error messages
100 const QUrl url = toUrl();
101
102 bool ok = false;
103 const QString content = QgsServerParameterDefinition::loadUrl( ok );
104
105 if ( !ok )
106 {
107 const QString msg = QString( "%1 request error for %2" ).arg( name( mName ), url.toString() );
109 }
110
111 return content;
112 }
113
115 {
116 bool ok = false;
117 const QUrl url = QgsServerParameterDefinition::toUrl( ok );
118
119 if ( !ok )
120 {
121 raiseError();
122 }
123
124 return url;
125 }
126
128 {
129 bool ok = false;
130 const QColor col = QgsServerParameterDefinition::toColor( ok );
131
132 if ( !ok )
133 {
134 raiseError();
135 }
136
137 return col;
138 }
139
140 QList<QColor> QgsWmsParameter::toColorList( const char delimiter ) const
141 {
142 bool ok = false;
143 const QList<QColor> vals = QgsServerParameterDefinition::toColorList( ok, delimiter );
144
145 if ( !ok )
146 {
147 const QString msg = QString( "%1 ('%2') cannot be converted into a list of colors" ).arg( name( mName ), toString() );
149 }
150
151 return vals;
152 }
153
154 QList<int> QgsWmsParameter::toIntList( const char delimiter ) const
155 {
156 bool ok = false;
157 const QList<int> vals = QgsServerParameterDefinition::toIntList( ok, delimiter );
158
159 if ( !ok )
160 {
161 const QString msg = QString( "%1 ('%2') cannot be converted into a list of int" ).arg( name( mName ), toString() );
163 }
164
165 return vals;
166 }
167
168 QList<double> QgsWmsParameter::toDoubleList( const char delimiter ) const
169 {
170 bool ok = false;
171 const QList<double> vals = QgsServerParameterDefinition::toDoubleList( ok, delimiter );
172
173 if ( !ok )
174 {
175 const QString msg = QString( "%1 ('%2') cannot be converted into a list of float" ).arg( name( mName ), toString() );
177 }
178
179 return vals;
180 }
181
183 {
184 bool ok = false;
185 const double val = QgsServerParameterDefinition::toDouble( ok );
186
187 if ( !ok )
188 {
189 raiseError();
190 }
191
192 return val;
193 }
194
195 QString QgsWmsParameter::name() const
196 {
198 }
199
201 {
202 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
203 return metaEnum.valueToKey( name );
204 }
205
207 {
208 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
209 return ( QgsWmsParameter::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
210 }
211
212 //
213 // QgsWmsParameters
214 //
217 {
218 // Available version number
219 mVersions.append( QgsProjectVersion( 1, 1, 1 ) );
220 mVersions.append( QgsProjectVersion( 1, 3, 0 ) );
221
222 // WMS parameters definition
224 QVariant::Int,
225 QVariant( 0 ) );
226 save( pQuality );
227
229 QVariant::Bool,
230 QVariant( false ) );
231 save( pTiled );
232
234 QVariant::Double,
235 QVariant( 2.0 ) );
236 save( pBoxSpace );
237
239 QVariant::Double,
240 QVariant( 2.0 ) );
241 save( pSymbSpace );
242
244 QVariant::Double,
245 QVariant( 3.0 ) );
246 save( pLayerSpace );
247
249 QVariant::Double,
250 QVariant( 3.0 ) );
251 save( pTitleSpace );
252
254 QVariant::Double,
255 QVariant( 4.0 ) );
256 save( pSymbHeight );
257
259 QVariant::Double,
260 QVariant( 7.0 ) );
261 save( pSymbWidth );
262
264 QVariant::Double,
265 QVariant( 2.0 ) );
266 save( pIcLabelSpace );
267
269 save( pItFontFamily );
270
272 QVariant::Bool,
273 QVariant( false ) );
274 save( pItFontBold );
275
277 QVariant::Bool,
278 QVariant( false ) );
279 save( pItFontItalic );
280
282 QVariant::Double,
283 QVariant( -1 ) );
284 save( pItFontSize );
285
287 QVariant::String,
288 QVariant( "black" ) );
289 save( pItFontColor );
290
291 const QgsWmsParameter pHighlightGeom( QgsWmsParameter::HIGHLIGHT_GEOM );
292 save( pHighlightGeom );
293
294 const QgsWmsParameter pShowFeatureCount( QgsWmsParameter::SHOWFEATURECOUNT,
295 QVariant::Bool,
296 QVariant( false ) );
297 save( pShowFeatureCount );
298
299 const QgsWmsParameter pHighlightSymbol( QgsWmsParameter::HIGHLIGHT_SYMBOL );
300 save( pHighlightSymbol );
301
303 save( pHighlightLabel );
304
306 QVariant::String,
307 QVariant( "black" ) );
308 save( pHighlightColor );
309
310 const QgsWmsParameter pHighlightFontSize( QgsWmsParameter::HIGHLIGHT_LABELSIZE );
311 save( pHighlightFontSize );
312
313 const QgsWmsParameter pHighlightFontWeight( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT );
314 save( pHighlightFontWeight );
315
317 save( pHighlightFont );
318
320 QVariant::String,
321 QVariant( "black" ) );
322 save( pHighlightBufferColor );
323
325 save( pHighlightBufferSize );
326
327 const QgsWmsParameter pLabelRotation( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, QVariant::Double );
328 save( pLabelRotation );
329
330 const QgsWmsParameter pLabelDistance( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, QVariant::Double );
331 save( pLabelDistance );
332
334 save( pLabelHali );
335
337 save( pLabelVali );
338
340 save( pCRS );
341
343 save( pSRS );
344
346 QVariant::String,
347 QVariant( "png" ) );
348 save( pFormat );
349
351 save( pInfoFormat );
352
354 QVariant::Int,
355 QVariant( -1 ) );
356 save( pI );
357
359 QVariant::Int,
360 QVariant( -1 ) );
361 save( pJ );
362
364 QVariant::Int,
365 QVariant( -1 ) );
366 save( pX );
367
369 QVariant::Int,
370 QVariant( -1 ) );
371 save( pY );
372
374 save( pRule );
375
377 QVariant::Bool,
378 QVariant( true ) );
379 save( pRuleLabel );
380
382 QVariant::Double,
383 QVariant( -1 ) );
384 save( pScale );
385
387 QVariant::Int,
388 QVariant( 0 ) );
389 save( pHeight );
390
392 QVariant::Int,
393 QVariant( 0 ) );
394 save( pWidth );
395
397 QVariant::Int,
398 QVariant( 0 ) );
399 save( pSrcHeight );
400
402 QVariant::Int,
403 QVariant( 0 ) );
404 save( pSrcWidth );
405
407 save( pBbox );
408
410 save( pSld );
411
413 save( pSldBody );
414
416 save( pLayer );
417
419 save( pLayers );
420
422 save( pQueryLayers );
423
425 QVariant::Int,
426 QVariant( 1 ) );
427 save( pFeatureCount );
428
430 QVariant::Bool,
431 QVariant( true ) );
432 save( pLayerTitle );
433
435 save( pLayerFtFamily );
436
438 QVariant::Bool,
439 QVariant( false ) );
440 save( pLayerFtBold );
441
443 QVariant::Bool,
444 QVariant( false ) );
445 save( pLayerFtItalic );
446
448 QVariant::Double,
449 QVariant( -1 ) );
450 save( pLayerFtSize );
451
453 QVariant::String,
454 QVariant( "black" ) );
455 save( pLayerFtColor );
456
458 save( pStyle );
459
461 save( pStyles );
462
464 save( pOpacities );
465
467 save( pFilter );
468
470 save( pFilterGeom );
471
473 QVariant::Double,
474 QVariant( 0.0 ) );
475 save( pPolygTol );
476
478 QVariant::Double,
479 QVariant( 0.0 ) );
480 save( pLineTol );
481
483 QVariant::Double,
484 QVariant( 0.0 ) );
485 save( pPointTol );
486
488 save( pSelection );
489
491 QVariant::Int,
492 QVariant( -1 ) );
493 save( pWmsPrecision );
494
496 QVariant::Bool,
497 QVariant( false ) );
498 save( pTransparent );
499
501 QVariant::String,
502 QVariant( "white" ) );
503 save( pBgColor );
504
506 QVariant::Int,
507 QVariant( -1 ) );
508 save( pDpi );
509
511 save( pTemplate );
512
514 save( pExtent );
515
517 QVariant::Double,
518 QVariant( 0.0 ) );
519 save( pRotation );
520
522 QVariant::Double,
523 QVariant( 0.0 ) );
524 save( pGridX );
525
527 QVariant::Double,
528 QVariant( 0.0 ) );
529 save( pGridY );
530
532 QVariant::Bool,
533 QVariant( false ) );
534 save( pWithGeometry );
535
537 QVariant::Bool,
538 QVariant( false ) );
539 save( pWithMapTip );
540
542 save( pWmtver );
543
545 QVariant::StringList );
546 save( pAtlasPk );
547
549 QVariant::String );
550 save( pFormatOpts );
551 }
552
555 {
556 load( parameters.urlQuery() );
557
558 auto it = mWmsParameters.constFind( QgsWmsParameter::SLD );
559 if ( it != mWmsParameters.constEnd() && !it->toString().isEmpty() )
560 {
561 const QString sldBody = it->loadUrl();
562 if ( !sldBody.isEmpty() )
563 {
565 }
566 }
567 }
568
570 {
571 return mWmsParameters.value( name );
572 }
573
574 void QgsWmsParameters::set( QgsWmsParameter::Name name, const QVariant &value )
575 {
576 auto it = mWmsParameters.find( name );
577 if ( it == mWmsParameters.end() )
578 {
579 it = mWmsParameters.insert( name, QgsWmsParameter() );
580 }
581
582 it->mValue = value;
583 }
584
585 bool QgsWmsParameters::loadParameter( const QString &key, const QString &value )
586 {
587 bool loaded = false;
588
589 const thread_local QRegularExpression composerParamRegExp( QStringLiteral( "^MAP\\d+:" ), QRegularExpression::CaseInsensitiveOption );
590 if ( key.contains( composerParamRegExp ) )
591 {
592#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
593 const int mapId = key.midRef( 3, key.indexOf( ':' ) - 3 ).toInt();
594#else
595 const int mapId = QStringView {key}.mid( 3, key.indexOf( ':' ) - 3 ).toInt();
596#endif
597 const QString theKey = key.mid( key.indexOf( ':' ) + 1 );
598 const QgsWmsParameter::Name name = QgsWmsParameter::name( theKey );
599
600 if ( name >= 0 )
601 {
602 QgsWmsParameter param = mWmsParameters.value( name );
603 param.mValue = value;
604 param.mMapId = mapId;
605
606 if ( ! param.isValid() )
607 {
608 param.raiseError();
609 }
610
611 save( param, true ); // multi MAP parameters for composer
612 loaded = true;
613 }
614 }
615 else
616 {
618 if ( name >= 0 )
619 {
620 auto it = mWmsParameters.find( name );
621 if ( it == mWmsParameters.end() )
622 it = mWmsParameters.insert( name, QgsWmsParameter() );
623
624 it->mValue = value;
625 if ( !it->isValid() )
626 {
627 it->raiseError();
628 }
629
630 loaded = true;
631 }
632 else //maybe an external wms parameter?
633 {
634 int separator = key.indexOf( QLatin1Char( ':' ) );
635 if ( separator >= 1 )
636 {
637 QString id = key.left( separator );
638 QString param = key.right( key.length() - separator - 1 );
639 mExternalWMSParameters[id].insert( param, value );
640
641 loaded = true;
642 }
643 }
644 }
645
646 return loaded;
647 }
648
650 {
651 log( QStringLiteral( "WMS Request parameters:" ) );
652 for ( auto it = mWmsParameters.constBegin(); it != mWmsParameters.constEnd(); ++it )
653 {
654 const QString value = it->toString();
655
656 if ( ! value.isEmpty() )
657 {
658 QString name = QgsWmsParameter::name( it.key() );
659
660 if ( it->mMapId >= 0 )
661 {
662 name = QStringLiteral( "%1:%2" ).arg( QString::number( it->mMapId ), name );
663 }
664
665 log( QStringLiteral( " - %1 : %2" ).arg( name, value ) );
666 }
667 }
668
669 if ( !version().isEmpty() )
670 log( QStringLiteral( " - VERSION : %1" ).arg( version() ) );
671 }
672
673 void QgsWmsParameters::save( const QgsWmsParameter &parameter, bool multi )
674 {
675 if ( multi )
676 {
677 mWmsParameters.insert( parameter.mName, parameter );
678 }
679 else
680 {
681 mWmsParameters.replace( parameter.mName, parameter );
682 }
683 }
684
686 {
687 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_GEOM ).toStringList( ';' );
688 }
689
690 QList<QgsGeometry> QgsWmsParameters::highlightGeomAsGeom() const
691 {
692 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_GEOM ).toGeomList( ';' );
693 }
694
696 {
697 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_SYMBOL ).toStringList( ';' );
698 }
699
700 QString QgsWmsParameters::crs() const
701 {
702 QString rs;
703 const QString srs = mWmsParameters.value( QgsWmsParameter::SRS ).toString();
704 const QString crs = mWmsParameters.value( QgsWmsParameter::CRS ).toString();
705
706 // both SRS/CRS are supported but there's a priority according to the
707 // specified version when both are defined in the request
708 if ( !srs.isEmpty() && crs.isEmpty() )
709 rs = srs;
710 else if ( srs.isEmpty() && !crs.isEmpty() )
711 rs = crs;
712 else if ( !srs.isEmpty() && !crs.isEmpty() )
713 {
714 if ( versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) )
715 rs = crs;
716 else
717 rs = srs;
718 }
719
720 return rs;
721 }
722
724 {
725 return mWmsParameters.value( QgsWmsParameter::BBOX ).toString();
726 }
727
729 {
730 return mWmsParameters.value( QgsWmsParameter::BBOX ).toRectangle();
731 }
732
734 {
735 return mWmsParameters.value( QgsWmsParameter::HEIGHT ).toString();
736 }
737
739 {
740 return mWmsParameters.value( QgsWmsParameter::WIDTH ).toString();
741 }
742
744 {
745 return mWmsParameters.value( QgsWmsParameter::HEIGHT ).toInt();
746 }
747
749 {
750 return mWmsParameters.value( QgsWmsParameter::WIDTH ).toInt();
751 }
752
754 {
755 return mWmsParameters.value( QgsWmsParameter::SRCHEIGHT ).toString();
756 }
757
759 {
760 return mWmsParameters.value( QgsWmsParameter::SRCWIDTH ).toString();
761 }
762
764 {
765 return mWmsParameters.value( QgsWmsParameter::SRCHEIGHT ).toInt();
766 }
767
769 {
770 return mWmsParameters.value( QgsWmsParameter::SRCWIDTH ).toInt();
771 }
772
773 QString QgsWmsParameters::dpi() const
774 {
775 return mWmsParameters.value( QgsWmsParameter::DPI ).toString();
776 }
777
779 {
780 return mWmsParameters.value( QgsWmsParameter::DPI ).toDouble();
781 }
782
784 {
786
787 if ( QgsServerParameters::request().compare( QLatin1String( "GetProjectSettings" ), Qt::CaseInsensitive ) == 0 )
788 {
789 version = QStringLiteral( "1.3.0" );
790 }
791 else if ( version.isEmpty() )
792 {
793 if ( ! wmtver().isEmpty() )
794 {
795 version = wmtver();
796 }
797 else
798 {
799 version = QStringLiteral( "1.3.0" );
800 }
801 }
802 else if ( !mVersions.contains( QgsProjectVersion( version ) ) )
803 {
804 // WMS 1.3.0 specification: If a version lower than any of those
805 // known to the server is requested, then the server shall send the
806 // lowest version it supports.
807 if ( QgsProjectVersion( 1, 1, 1 ) > QgsProjectVersion( version ) )
808 {
809 version = QStringLiteral( "1.1.1" );
810 }
811 else
812 {
813 version = QStringLiteral( "1.3.0" );
814 }
815 }
816
817 return version;
818 }
819
821 {
822 QString req = QgsServerParameters::request();
823
824 if ( version().compare( QLatin1String( "1.1.1" ) ) == 0
825 && req.compare( QLatin1String( "capabilities" ), Qt::CaseInsensitive ) == 0 )
826 {
827 req = QStringLiteral( "GetCapabilities" );
828 }
829
830 return req;
831 }
832
834 {
835 return QgsProjectVersion( version() );
836 }
837
838 bool QgsWmsParameters::versionIsValid( const QString version ) const
839 {
840 return mVersions.contains( QgsProjectVersion( version ) );
841 }
842
844 {
845 return mWmsParameters.value( QgsWmsParameter::FORMAT ).toString( true );
846 }
847
849 {
850 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::Format>() );
851 return metaEnum.valueToKey( format );
852 }
853
855 {
856 const QString fStr = formatAsString();
857
858 Format f = Format::NONE;
859 if ( fStr.compare( QLatin1String( "image/png" ), Qt::CaseInsensitive ) == 0 ||
860 fStr.compare( QLatin1String( "png" ), Qt::CaseInsensitive ) == 0 )
861 {
862 f = Format::PNG;
863 }
864 else if ( fStr.compare( QLatin1String( "jpg" ), Qt::CaseInsensitive ) == 0
865 || fStr.compare( QLatin1String( "jpeg" ), Qt::CaseInsensitive ) == 0
866 || fStr.compare( QLatin1String( "image/jpeg" ), Qt::CaseInsensitive ) == 0 )
867 {
868 f = Format::JPG;
869 }
870 else if ( fStr.compare( QLatin1String( "image/svg" ), Qt::CaseInsensitive ) == 0 ||
871 fStr.compare( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive ) == 0 ||
872 fStr.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 )
873 {
874 f = Format::SVG;
875 }
876 else if ( fStr.compare( QLatin1String( "application/pdf" ), Qt::CaseInsensitive ) == 0 ||
877 fStr.compare( QLatin1String( "pdf" ), Qt::CaseInsensitive ) == 0 )
878 {
879 f = Format::PDF;
880 }
881 else if ( fStr.compare( QLatin1String( "application/json" ), Qt::CaseInsensitive ) == 0 ||
882 fStr.compare( QLatin1String( "json" ), Qt::CaseInsensitive ) == 0 )
883 {
884 f = Format::JSON;
885 }
886 return f;
887 }
888
890 {
891 return mWmsParameters.value( QgsWmsParameter::INFO_FORMAT ).toString();
892 }
893
895 {
896 return infoFormat() == Format::PNG || infoFormat() == Format::JPG;
897 }
898
900 {
901 QString fStr = infoFormatAsString();
902
903 Format f = Format::TEXT;
904 if ( fStr.isEmpty() )
905 return f;
906
907 if ( fStr.startsWith( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) )
908 f = Format::XML;
909 else if ( fStr.startsWith( QLatin1String( "text/html" ), Qt::CaseInsensitive ) )
910 f = Format::HTML;
911 else if ( fStr.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
912 f = Format::TEXT;
913 else if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml" ), Qt::CaseInsensitive ) )
914 f = Format::GML;
915 else if ( fStr.startsWith( QLatin1String( "application/json" ), Qt::CaseInsensitive )
916 || fStr.startsWith( QLatin1String( "application/geo+json" ), Qt::CaseInsensitive ) )
917 f = Format::JSON;
918 else
919 f = Format::NONE;
920
921 return f;
922 }
923
925 {
926 if ( infoFormat() != Format::GML )
927 return -1;
928
929 QString fStr = infoFormatAsString();
930 if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml/3" ), Qt::CaseInsensitive ) )
931 return 3;
932 else
933 return 2;
934 }
935
936 QString QgsWmsParameters::i() const
937 {
938 return mWmsParameters.value( QgsWmsParameter::I ).toString();
939 }
940
941 QString QgsWmsParameters::j() const
942 {
943 return mWmsParameters.value( QgsWmsParameter::J ).toString();
944 }
945
947 {
948 return mWmsParameters.value( QgsWmsParameter::I ).toInt();
949 }
950
952 {
953 return mWmsParameters.value( QgsWmsParameter::J ).toInt();
954 }
955
956 QString QgsWmsParameters::x() const
957 {
958 return mWmsParameters.value( QgsWmsParameter::X ).toString();
959 }
960
961 QString QgsWmsParameters::y() const
962 {
963 return mWmsParameters.value( QgsWmsParameter::Y ).toString();
964 }
965
967 {
968 return mWmsParameters.value( QgsWmsParameter::X ).toInt();
969 }
970
972 {
973 return mWmsParameters.value( QgsWmsParameter::Y ).toInt();
974 }
975
977 {
978 return mWmsParameters.value( QgsWmsParameter::RULE ).toString();
979 }
980
982 {
983 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toString();
984 }
985
987 {
988 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toBool();
989 }
990
992 {
993 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toString();
994 }
995
997 {
998 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toBool();
999 }
1000
1002 {
1003 return mWmsParameters.value( QgsWmsParameter::SCALE ).toString();
1004 }
1005
1007 {
1008 return mWmsParameters.value( QgsWmsParameter::SCALE ).toDouble();
1009 }
1010
1012 {
1013 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toString();
1014 }
1015
1017 {
1018 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toInt();
1019 }
1020
1022 {
1023 return mWmsParameters.value( QgsWmsParameter::TILED ).toString();
1024 }
1025
1027 {
1028 return mWmsParameters.value( QgsWmsParameter::TILED ).toBool();
1029 }
1030
1032 {
1033 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toString();
1034 }
1035
1037 {
1038 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toBool();
1039 }
1040
1042 {
1043 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toString();
1044 }
1045
1047 {
1048 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toInt();
1049 }
1050
1052 {
1053 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toString();
1054 }
1055
1057 {
1058 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toDouble();
1059 }
1060
1062 {
1063 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toString();
1064 }
1065
1067 {
1068 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toDouble();
1069 }
1070
1072 {
1073 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toString();
1074 }
1075
1077 {
1078 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toDouble();
1079 }
1080
1082 {
1083 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toString();
1084 }
1085
1087 {
1088 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toDouble();
1089 }
1090
1092 {
1093 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toString();
1094 }
1095
1097 {
1098 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toDouble();
1099 }
1100
1102 {
1103 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toString();
1104 }
1105
1107 {
1108 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toDouble();
1109 }
1110
1112 {
1113 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toString();
1114 }
1115
1117 {
1118 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toDouble();
1119 }
1120
1122 {
1123 return mWmsParameters.value( QgsWmsParameter::LAYERFONTFAMILY ).toString();
1124 }
1125
1127 {
1128 return mWmsParameters.value( QgsWmsParameter::ITEMFONTFAMILY ).toString();
1129 }
1130
1132 {
1133 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toString();
1134 }
1135
1137 {
1138 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toBool();
1139 }
1140
1142 {
1143 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toString();
1144 }
1145
1147 {
1148 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toString();
1149 }
1150
1152 {
1153 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toString();
1154 }
1155
1157 {
1158 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toString();
1159 }
1160
1162 {
1163 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toInt();
1164 }
1165
1167 {
1168 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toInt();
1169 }
1170
1172 {
1173 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toInt();
1174 }
1175
1177 {
1178 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toBool();
1179 }
1180
1182 {
1183 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toString();
1184 }
1185
1187 {
1188 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toBool();
1189 }
1190
1192 {
1193 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toString();
1194 }
1195
1197 {
1198 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toBool();
1199 }
1200
1202 {
1203 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toString();
1204 }
1205
1207 {
1208 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toDouble();
1209 }
1210
1212 {
1213 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toString();
1214 }
1215
1217 {
1218 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toColor();
1219 }
1220
1222 {
1223 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toString();
1224 }
1225
1227 {
1228 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toDouble();
1229 }
1230
1232 {
1233 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toString();
1234 }
1235
1237 {
1238 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toColor();
1239 }
1240
1242 {
1243 QFont font;
1244 font.fromString( "" );
1245 font.setBold( layerFontBoldAsBool() );
1246 font.setItalic( layerFontItalicAsBool() );
1247
1248 if ( ! layerFontSize().isEmpty() )
1249 font.setPointSizeF( layerFontSizeAsDouble() );
1250
1251 if ( !layerFontFamily().isEmpty() )
1252 font.setFamily( layerFontFamily() );
1253
1254 return font;
1255 }
1256
1258 {
1259 QFont font;
1260 font.fromString( "" );
1261
1262 font.setBold( itemFontBoldAsBool() );
1263 font.setItalic( itemFontItalicAsBool() );
1264
1265 if ( ! itemFontSize().isEmpty() )
1266 font.setPointSizeF( itemFontSizeAsDouble() );
1267
1268 if ( !itemFontFamily().isEmpty() )
1269 font.setFamily( itemFontFamily() );
1270
1271 return font;
1272 }
1273
1275 {
1276 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toString();
1277 }
1278
1280 {
1281 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toBool();
1282 }
1283
1285 {
1286 QgsLegendSettings settings;
1287 settings.setTitle( QString() );
1288 settings.setBoxSpace( boxSpaceAsDouble() );
1289 settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) );
1290
1291 settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Top, layerSpaceAsDouble() );
1292 settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Bottom, layerTitleSpaceAsDouble() );
1293 settings.rstyle( QgsLegendStyle::Style::Subgroup ).setFont( layerFont() );
1294
1295 if ( !itemFontColor().isEmpty() )
1296 {
1297 settings.setFontColor( itemFontColorAsColor() );
1298 }
1299
1300 // Ok, this is tricky: because QgsLegendSettings's layerFontColor was added to the API after
1301 // fontColor, to fix regressions #21871 and #21870 and the previous behavior was to use fontColor
1302 // for the whole legend we need to preserve that behavior.
1303 // But, the 2.18 server parameters ITEMFONTCOLOR did not have effect on the layer titles too, so
1304 // we set explicitly layerFontColor to black if it's not overridden by LAYERFONTCOLOR argument.
1305 settings.setLayerFontColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1306
1307 settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setFont( itemFont() );
1308 settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpaceAsDouble() );
1309 settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setMargin( QgsLegendStyle::Side::Left, iconLabelSpaceAsDouble() );
1310
1311 return settings;
1312 }
1313
1314 QString QgsWmsParameters::layoutParameter( const QString &id, bool &ok ) const
1315 {
1316 QString label;
1317 ok = false;
1318
1319 if ( mUnmanagedParameters.contains( id.toUpper() ) )
1320 {
1321 label = mUnmanagedParameters[id.toUpper()];
1322 ok = true;
1323 }
1324
1325 return label;
1326 }
1327
1328 QStringList QgsWmsParameters::atlasPk() const
1329 {
1330 return mWmsParameters.value( QgsWmsParameter::ATLAS_PK ).toStringList();
1331 }
1332
1334 {
1335 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSTRING ).toStringList( ';' );
1336 }
1337
1339 {
1340 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toStringList( ';' );
1341 }
1342
1344 {
1345 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toIntList( ';' );
1346 }
1347
1349 {
1350 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toStringList( ';' );
1351 }
1352
1354 {
1355 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toColorList( ';' );
1356 }
1357
1359 {
1360 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toStringList( ';' );
1361 }
1362
1364 {
1365 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toIntList( ';' );
1366 }
1367
1369 {
1370 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELFONT ).toStringList( ';' );
1371 }
1372
1374 {
1375 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toStringList( ';' );
1376 }
1377
1379 {
1380 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toColorList( ';' );
1381 }
1382
1384 {
1385 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toStringList( ';' );
1386 }
1387
1389 {
1390 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toDoubleList( ';' );
1391 }
1392
1394 {
1395 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION ).toDoubleList( ';' );
1396 }
1397
1399 {
1400 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE ).toDoubleList( ';' );
1401 }
1402
1404 {
1405 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT ).toStringList( ';' );
1406 }
1407
1409 {
1410 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT ).toStringList( ';' );
1411 }
1412
1414 {
1415 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toString();
1416 }
1417
1419 {
1420 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toInt();
1421 }
1422
1424 {
1425 return mWmsParameters.value( QgsWmsParameter::SLD_BODY ).toString();
1426 }
1427
1428 QStringList QgsWmsParameters::filters() const
1429 {
1430 QStringList filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toOgcFilterList();
1431 if ( filters.isEmpty() )
1432 filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toExpressionList();
1433 return filters;
1434 }
1435
1437 {
1438 return mWmsParameters.value( QgsWmsParameter::FILTER_GEOM ).toString();
1439 }
1440
1442 {
1443 return mWmsParameters.value( QgsWmsParameter::SELECTION ).toStringList( ';' );
1444 }
1445
1447 {
1448 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toStringList();
1449 }
1450
1452 {
1453 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toIntList();
1454 }
1455
1457 {
1458 // We don't want duplicates but order does matter, so no QSet
1459 QStringList result;
1460
1461 // LAYER
1462 QList<QgsWmsParameter> cLayer { mWmsParameters.values( QgsWmsParameter::LAYER ) };
1463 // Sort by map id
1464 std::sort( cLayer.begin(), cLayer.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1465 for ( const QgsWmsParameter &param : std::as_const( cLayer ) )
1466 {
1467 const QStringList layersList { param.toStringList() };
1468 for ( const QString &layerName : std::as_const( layersList ) )
1469 {
1470 if ( ! result.contains( layerName ) )
1471 result.append( layerName );
1472 }
1473 }
1474
1475 // LAYERS
1476 QList<QgsWmsParameter> cLayers { mWmsParameters.values( QgsWmsParameter::LAYERS ) };
1477 // Sort by map id
1478 std::sort( cLayers.begin(), cLayers.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1479 for ( const QgsWmsParameter &param : std::as_const( cLayers ) )
1480 {
1481 const QStringList layersList { param.toStringList() };
1482 for ( const QString &layerName : std::as_const( layersList ) )
1483 {
1484 if ( ! result.contains( layerName ) )
1485 result.append( layerName );
1486 }
1487 }
1488 return result;
1489 }
1490
1492 {
1493 return mWmsParameters.value( QgsWmsParameter::QUERY_LAYERS ).toStringList();
1494 }
1495
1497 {
1498 QStringList style = mWmsParameters.value( QgsWmsParameter::STYLE ).toStyleList();
1499 const QStringList styles = mWmsParameters.value( QgsWmsParameter::STYLES ).toStyleList();
1500 return style << styles;
1501 }
1502
1503 QMultiMap<QString, QgsWmsParametersFilter> QgsWmsParameters::layerFilters( const QStringList &layers ) const
1504 {
1505 const QString nsWfs2 = QStringLiteral( "http://www.opengis.net/fes/2.0" );
1506 const QString prefixWfs2 = QStringLiteral( "<fes:" );
1507
1508 const QStringList rawFilters = filters();
1509 QMultiMap<QString, QgsWmsParametersFilter> filters;
1510 for ( int i = 0; i < rawFilters.size(); i++ )
1511 {
1512 const QString f = rawFilters[i];
1513 if ( f.startsWith( QLatin1Char( '<' ) ) \
1514 && f.endsWith( QLatin1String( "Filter>" ) ) \
1515 && i < layers.size() )
1516 {
1518 filter.mFilter = f;
1521
1522 if ( filter.mFilter.contains( nsWfs2 ) \
1523 || filter.mFilter.contains( prefixWfs2 ) )
1524 {
1526 }
1527
1528 filters.insert( layers[i], filter );
1529 }
1530 else if ( !f.isEmpty() )
1531 {
1532 // filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
1533 // several filters can be defined for one layer
1534 const int colonIndex = f.indexOf( ':' );
1535 if ( colonIndex != -1 )
1536 {
1537 const QString layers = f.section( ':', 0, 0 );
1538 const QString filter = f.section( ':', 1 );
1539 const QStringList layersList = layers.split( ',' );
1540 for ( const QString &layer : layersList )
1541 {
1542 QgsWmsParametersFilter parametersFilter;
1543 parametersFilter.mFilter = filter;
1544 parametersFilter.mType = QgsWmsParametersFilter::SQL;
1545 filters.insert( layer, parametersFilter );
1546 }
1547 }
1548 else
1549 {
1550 QString filterStr = mWmsParameters.value( QgsWmsParameter::FILTER ).toString();
1551 raiseError( QStringLiteral( "FILTER ('" ) + filterStr + QStringLiteral( "') is not properly formatted" ) );
1552 }
1553 }
1554 }
1555 return filters;
1556 }
1557
1559 {
1560 bool force2D = false;
1561 const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1562
1563 if ( options.contains( DxfFormatOption::FORCE_2D ) )
1564 {
1565 force2D = QVariant( options[ DxfFormatOption::FORCE_2D ] ).toBool();
1566 }
1567
1568 return force2D;
1569 }
1570
1572 {
1573 bool noMText = false;
1574 const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
1575
1576 if ( options.contains( DxfFormatOption::NO_MTEXT ) )
1577 {
1578 noMText = QVariant( options[ DxfFormatOption::NO_MTEXT ] ).toBool();
1579 }
1580
1581 return noMText;
1582 }
1583
1584
1585 QList<QgsWmsParametersLayer> QgsWmsParameters::layersParameters() const
1586 {
1587 const QStringList layers = allLayersNickname();
1588 const QStringList styles = allStyles();
1589 const QStringList selection = selections();
1590 const QList<int> opacities = opacitiesAsInt();
1591 const QMultiMap<QString, QgsWmsParametersFilter> filters = layerFilters( layers );
1592
1593 // selection format: "LayerName:id0,id1;LayerName2:id0,id1;..."
1594 // several filters can be defined for one layer
1595 QMultiMap<QString, QString> layerSelections;
1596 for ( const QString &s : selection )
1597 {
1598 const QStringList splits = s.split( ':' );
1599 if ( splits.size() == 2 )
1600 {
1601 layerSelections.insert( splits[0], splits[1] );
1602 }
1603 else
1604 {
1605 QString selStr = mWmsParameters.value( QgsWmsParameter::SELECTION ).toString();
1606 raiseError( QStringLiteral( "SELECTION ('" ) + selStr + QStringLiteral( "') is not properly formatted" ) );
1607 }
1608 }
1609
1610 QList<QgsWmsParametersLayer> parameters;
1611 for ( int i = 0; i < layers.size(); i++ )
1612 {
1613 QString layer = layers[i];
1614
1616 param.mNickname = layer;
1617
1618 if ( i < opacities.count() )
1619 param.mOpacity = opacities[i];
1620
1621 if ( isExternalLayer( layer ) )
1622 {
1623 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1624 param.mNickname = extParam.mName;
1625 param.mExternalUri = extParam.mUri;
1626 }
1627 else
1628 {
1629 if ( i < styles.count() )
1630 param.mStyle = styles[i];
1631
1632 if ( filters.contains( layer ) )
1633 {
1634 auto it = filters.find( layer );
1635 while ( it != filters.end() && it.key() == layer )
1636 {
1637 param.mFilter.append( it.value() );
1638 ++it;
1639 }
1640 }
1641
1642 if ( layerSelections.contains( layer ) )
1643 {
1644 QMultiMap<QString, QString>::const_iterator it;
1645 it = layerSelections.constFind( layer );
1646 while ( it != layerSelections.constEnd() && it.key() == layer )
1647 {
1648 param.mSelection << it.value().split( ',' );
1649 ++it;
1650 }
1651 }
1652 }
1653
1654 parameters.append( param );
1655 }
1656
1657 return parameters;
1658 }
1659
1660 QList<QgsWmsParametersHighlightLayer> QgsWmsParameters::highlightLayersParameters() const
1661 {
1662 QList<QgsWmsParametersHighlightLayer> params;
1663 const QList<QgsGeometry> geoms = highlightGeomAsGeom();
1664 const QStringList slds = highlightSymbol();
1665 const QStringList labels = highlightLabelString();
1666 const QList<QColor> colors = highlightLabelColorAsColor();
1667 const QList<int> sizes = highlightLabelSizeAsInt();
1668 const QList<int> weights = highlightLabelWeightAsInt();
1669 const QStringList fonts = highlightLabelFont();
1670 const QList<QColor> bufferColors = highlightLabelBufferColorAsColor();
1671 const QList<double> bufferSizes = highlightLabelBufferSizeAsFloat();
1672 const QList<double> rotation = highlightLabelRotation();
1673 const QList<double> distance = highlightLabelDistance();
1674 const QStringList hali = highlightLabelHorizontalAlignment();
1675 const QStringList vali = highlightLabelVerticalAlignment();
1676
1677 int nLayers = std::min( geoms.size(), slds.size() );
1678 for ( int i = 0; i < nLayers; i++ )
1679 {
1681 param.mName = QStringLiteral( "highlight_" ) + QString::number( i );
1682 param.mGeom = geoms[i];
1683 param.mSld = slds[i];
1684
1685 if ( i < labels.count() )
1686 param.mLabel = labels[i];
1687
1688 if ( i < colors.count() )
1689 param.mColor = colors[i];
1690
1691 if ( i < sizes.count() )
1692 param.mSize = sizes[i];
1693
1694 if ( i < weights.count() )
1695 param.mWeight = weights[i];
1696
1697 if ( i < fonts.count() )
1698 param.mFont = fonts[ i ];
1699
1700 if ( i < bufferColors.count() )
1701 param.mBufferColor = bufferColors[i];
1702
1703 if ( i < bufferSizes.count() )
1704 param.mBufferSize = bufferSizes[i];
1705
1706 if ( i < rotation.count() )
1707 param.mLabelRotation = rotation[i];
1708
1709 if ( i < distance.count() )
1710 param.mLabelDistance = distance[i];
1711
1712 if ( i < hali.count() )
1713 param.mHali = hali[i];
1714
1715 if ( i < vali.count() )
1716 param.mVali = vali[i];
1717
1718
1719
1720 params.append( param );
1721 }
1722
1723 return params;
1724 }
1725
1726 QList<QgsWmsParametersExternalLayer> QgsWmsParameters::externalLayersParameters() const
1727 {
1728 auto notExternalLayer = []( const QString & name ) { return ! QgsWmsParameters::isExternalLayer( name ); };
1729
1730 QList<QgsWmsParametersExternalLayer> externalLayers;
1731
1732 QStringList layers = allLayersNickname();
1733 QStringList::iterator rit = std::remove_if( layers.begin(), layers.end(), notExternalLayer );
1734
1735 for ( QStringList::iterator it = layers.begin(); it != rit; ++it )
1736 {
1737 externalLayers << externalLayerParameter( *it );
1738 }
1739
1740 return externalLayers;
1741 }
1742
1744 {
1745 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toString();
1746 }
1747
1749 {
1750 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toColor();
1751 }
1752
1754 {
1755 return mWmsParameters.value( QgsWmsParameter::TEMPLATE ).toString();
1756 }
1757
1759 {
1760 QgsWmsParameter wmsParam;
1762 param.mId = mapId;
1763
1764 QString pMapId = QStringLiteral( "MAP" ) + QString::number( mapId );
1765
1766 wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1767 QgsRectangle extent;
1768 if ( wmsParam.isValid() )
1769 {
1770 extent = wmsParam.toRectangle();
1771 }
1772
1773 param.mHasExtent = !extent.isEmpty();
1774 param.mExtent = extent;
1775
1776 // scale
1777 wmsParam = idParameter( QgsWmsParameter::SCALE, mapId );
1778 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1779 {
1780 param.mScale = wmsParam.toDouble();
1781 }
1782
1783 // rotation
1784 wmsParam = idParameter( QgsWmsParameter::ROTATION, mapId );
1785 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1786 {
1787 param.mRotation = wmsParam.toDouble();
1788 }
1789
1790 //grid space x / y
1791 double gridx( -1 ), gridy( -1 );
1792
1793 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_X, mapId );
1794 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1795 {
1796 gridx = wmsParam.toDouble();
1797 }
1798
1799 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_Y, mapId );
1800 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1801 {
1802 gridy = wmsParam.toDouble();
1803 }
1804
1805 if ( gridx != -1 && gridy != -1 )
1806 {
1807 param.mGridX = gridx;
1808 param.mGridY = gridy;
1809 }
1810
1811 //layers
1812 QStringList allLayers;
1813 wmsParam = idParameter( QgsWmsParameter::LAYERS, mapId );
1814 if ( wmsParam.isValid() )
1815 {
1816 allLayers = wmsParam.toStringList();
1817 }
1818
1819 // external layers
1820 QStringList layers;
1821
1822 for ( const auto &layer : std::as_const( allLayers ) )
1823 {
1824 if ( isExternalLayer( layer ) )
1825 {
1826 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1827 layers << extParam.mName;
1828 }
1829 else
1830 {
1831 layers << layer;
1832 }
1833 }
1834
1835 QStringList styles;
1836 wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
1837 if ( wmsParam.isValid() )
1838 {
1839 styles = wmsParam.toStyleList();
1840 }
1841
1842 QList<QgsWmsParametersLayer> lParams;
1843 for ( int i = 0; i < layers.size(); i++ )
1844 {
1845 QString layer = layers[i];
1846 QgsWmsParametersLayer lParam;
1847 lParam.mNickname = layer;
1848
1849 if ( i < styles.count() )
1850 lParam.mStyle = styles[i];
1851
1852 lParams.append( lParam );
1853 }
1854 param.mLayers = lParams;
1855
1856 //highlight layers
1857 QList<QgsWmsParametersHighlightLayer> hParams;
1858
1859 QList<QgsGeometry> geoms;
1860 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_GEOM, mapId );
1861 if ( wmsParam.isValid() )
1862 {
1863 geoms = wmsParam.toGeomList( ';' );
1864 }
1865
1866 QStringList slds;
1867 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_SYMBOL, mapId );
1868 if ( wmsParam.isValid() )
1869 {
1870 slds = wmsParam.toStringList( ';' );
1871 }
1872
1873 QStringList labels;
1874 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSTRING, mapId );
1875 if ( wmsParam.isValid() )
1876 {
1877 labels = wmsParam.toStringList( ';' );
1878 }
1879
1880 QStringList fonts;
1881 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELFONT, mapId );
1882 if ( wmsParam.isValid() )
1883 {
1884 fonts = wmsParam.toStringList( ';' );
1885 }
1886
1887 QList<QColor> colors;
1888 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELCOLOR, mapId );
1889 if ( wmsParam.isValid() )
1890 {
1891 colors = wmsParam.toColorList( ';' );
1892 }
1893
1894 QList<int> sizes;
1895 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSIZE, mapId );
1896 if ( wmsParam.isValid() )
1897 {
1898 sizes = wmsParam.toIntList( ';' );
1899 }
1900
1901 QList<int> weights;
1902 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT, mapId );
1903 if ( wmsParam.isValid() )
1904 {
1905 weights = wmsParam.toIntList( ';' );
1906 }
1907
1908 QList<QColor> bufferColors;
1909 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR, mapId );
1910 if ( wmsParam.isValid() )
1911 {
1912 bufferColors = wmsParam.toColorList( ';' );
1913 }
1914
1915 QList<double> bufferSizes;
1916 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE, mapId );
1917 if ( wmsParam.isValid() )
1918 {
1919 bufferSizes = wmsParam.toDoubleList( ';' );
1920 }
1921
1922 QList<double> rotations;
1923 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, mapId );
1924 if ( wmsParam.isValid() )
1925 {
1926 rotations = wmsParam.toDoubleList( ';' );
1927 }
1928
1929 QList<double> distances;
1930 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, mapId );
1931 if ( wmsParam.isValid() )
1932 {
1933 distances = wmsParam.toDoubleList( ';' );
1934 }
1935
1936 QStringList halis;
1937 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT, mapId );
1938 if ( wmsParam.isValid() )
1939 {
1940 halis = wmsParam.toStringList();
1941 }
1942
1943 QStringList valis;
1944 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT, mapId );
1945 if ( wmsParam.isValid() )
1946 {
1947 valis = wmsParam.toStringList();
1948 }
1949
1950 int nHLayers = std::min( geoms.size(), slds.size() );
1951 for ( int i = 0; i < nHLayers; i++ )
1952 {
1954 hParam.mName = pMapId + QStringLiteral( "_highlight_" ) + QString::number( i );
1955 hParam.mGeom = geoms[i];
1956 hParam.mSld = slds[i];
1957
1958 if ( i < labels.count() )
1959 hParam.mLabel = labels[i];
1960
1961 if ( i < colors.count() )
1962 hParam.mColor = colors[i];
1963
1964 if ( i < sizes.count() )
1965 hParam.mSize = sizes[i];
1966
1967 if ( i < weights.count() )
1968 hParam.mWeight = weights[i];
1969
1970 if ( i < fonts.count() )
1971 hParam.mFont = fonts[ i ];
1972
1973 if ( i < bufferColors.count() )
1974 hParam.mBufferColor = bufferColors[i];
1975
1976 if ( i < bufferSizes.count() )
1977 hParam.mBufferSize = bufferSizes[i];
1978
1979 if ( i < rotations.count() )
1980 hParam.mLabelRotation = rotations[i];
1981
1982 if ( i < distances.count() )
1983 hParam.mLabelDistance = distances[i];
1984
1985 if ( i < halis.count() )
1986 hParam.mHali = halis[i];
1987
1988 if ( i < valis.count() )
1989 hParam.mVali = valis[i];
1990
1991 hParams.append( hParam );
1992 }
1993 param.mHighlightLayers = hParams;
1994
1995 return param;
1996 }
1997
1998 QString QgsWmsParameters::externalWMSUri( const QString &layerId ) const
1999 {
2000
2001 // Param names may be uppercased.
2002 QString id { layerId };
2003
2004 for ( auto it = mExternalWMSParameters.cbegin(); it != mExternalWMSParameters.cend(); ++it )
2005 {
2006 if ( it.key().compare( id, Qt::CaseSensitivity::CaseInsensitive ) == 0 )
2007 {
2008 id = it.key();
2009 break;
2010 }
2011 }
2012
2013 if ( !mExternalWMSParameters.contains( id ) )
2014 {
2015 return QString();
2016 }
2017
2018 QgsDataSourceUri wmsUri;
2019 const QMap<QString, QString> &paramMap = mExternalWMSParameters[ id ];
2020 QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin();
2021 for ( ; paramIt != paramMap.constEnd(); ++paramIt )
2022 {
2023 QString paramName = paramIt.key().toLower();
2024 if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) || paramName == QLatin1String( "opacities" ) )
2025 {
2026 const QStringList values = paramIt.value().split( ',' );
2027 for ( const QString &value : values )
2028 wmsUri.setParam( paramName, value );
2029 }
2030 else if ( paramName == QLatin1String( "ignorereportedlayerextents" ) )
2031 {
2032 wmsUri.setParam( QStringLiteral( "IgnoreReportedLayerExtents" ), paramIt.value() );
2033 }
2034 else if ( paramName == QLatin1String( "smoothpixmaptransform" ) )
2035 {
2036 wmsUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), paramIt.value() );
2037 }
2038 else if ( paramName == QLatin1String( "ignoregetmapurl" ) )
2039 {
2040 wmsUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), paramIt.value() );
2041 }
2042 else if ( paramName == QLatin1String( "ignoregetfeatureinfourl" ) )
2043 {
2044 wmsUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), paramIt.value() );
2045 }
2046 else if ( paramName == QLatin1String( "ignoreaxisorientation" ) )
2047 {
2048 wmsUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), paramIt.value() );
2049 }
2050 else if ( paramName == QLatin1String( "invertaxisorientation" ) )
2051 {
2052 wmsUri.setParam( QStringLiteral( "InvertAxisOrientation" ), paramIt.value() );
2053 }
2054 else if ( paramName == QLatin1String( "dpimode" ) )
2055 {
2056 wmsUri.setParam( QStringLiteral( "dpiMode" ), paramIt.value() );
2057 }
2058 else if ( paramName == QLatin1String( "stepwidth" ) )
2059 {
2060 wmsUri.setParam( QStringLiteral( "stepWidth" ), paramIt.value() );
2061 }
2062 else if ( paramName == QLatin1String( "stepheight" ) )
2063 {
2064 wmsUri.setParam( QStringLiteral( "stepHeight" ), paramIt.value() );
2065 }
2066 else
2067 {
2068 wmsUri.setParam( paramName, paramIt.value() );
2069 }
2070 }
2071 return wmsUri.encodedUri();
2072 }
2073
2075 {
2076 return mWmsParameters.value( QgsWmsParameter::WITH_GEOMETRY ).toBool();
2077 }
2078
2080 {
2081 return mWmsParameters.value( QgsWmsParameter::WITH_MAPTIP ).toBool();
2082 }
2083
2085 {
2086 return mWmsParameters.value( QgsWmsParameter::WMTVER ).toString();
2087 }
2088
2089 void QgsWmsParameters::log( const QString &msg ) const
2090 {
2091 QgsMessageLog::logMessage( msg, QStringLiteral( "Server" ), Qgis::MessageLevel::Info );
2092 }
2093
2094 void QgsWmsParameters::raiseError( const QString &msg ) const
2095 {
2097 }
2098
2099 QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
2100 {
2101 QgsWmsParameter p;
2102
2103 for ( const auto &param : mWmsParameters.values( name ) )
2104 {
2105 if ( param.mMapId == id )
2106 {
2107 p = param;
2108 }
2109 }
2110
2111 return p;
2112 }
2113
2114 QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
2115 {
2116 QgsWmsParametersExternalLayer param;
2117
2118 param.mName = name;
2119 param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
2120 param.mUri = externalWMSUri( param.mName );
2121
2122 return param;
2123 }
2124
2125 bool QgsWmsParameters::isExternalLayer( const QString &name )
2126 {
2127 return name.startsWith( EXTERNAL_LAYER_PREFIX );
2128 }
2129
2131 {
2132 QStringList attributes;
2133 const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2134
2135 if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
2136 {
2137 attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
2138 }
2139
2140 return attributes;
2141 }
2142
2144 {
2145 bool use = false;
2146 const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2147
2148 if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
2149 {
2150 use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
2151 }
2152
2153 return use;
2154 }
2155
2157 {
2158 const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2159
2160 double scale = -1;
2161 if ( options.contains( DxfFormatOption::SCALE ) )
2162 {
2163 scale = options[ DxfFormatOption::SCALE ].toDouble();
2164 }
2165
2166 return scale;
2167 }
2168
2170 {
2171 const QMap<DxfFormatOption, QString> options = dxfFormatOptions();
2172
2174
2175 if ( ! options.contains( DxfFormatOption::MODE ) )
2176 {
2177 return symbol;
2178 }
2179
2180 const QString mode = options[ DxfFormatOption::MODE ];
2181 if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
2182 {
2184 }
2185 else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
2186 {
2188 }
2189
2190 return symbol;
2191 }
2192
2194 {
2195 QString codec = QStringLiteral( "ISO-8859-1" );
2196
2197 if ( dxfFormatOptions().contains( DxfFormatOption::CODEC ) )
2198 {
2199 codec = dxfFormatOptions()[ DxfFormatOption::CODEC ];
2200 }
2201
2202 return codec;
2203 }
2204
2205 QMap<QgsWmsParameters::DxfFormatOption, QString> QgsWmsParameters::dxfFormatOptions() const
2206 {
2207 QMap<QgsWmsParameters::DxfFormatOption, QString> options;
2208
2209 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::DxfFormatOption>() );
2210 const QStringList opts = mWmsParameters.value( QgsWmsParameter::FORMAT_OPTIONS ).toStringList( ';' );
2211
2212 for ( auto it = opts.constBegin(); it != opts.constEnd(); ++it )
2213 {
2214 const int equalIdx = it->indexOf( ':' );
2215 if ( equalIdx > 0 && equalIdx < ( it->length() - 1 ) )
2216 {
2217 const QString name = it->left( equalIdx ).toUpper();
2219 ( QgsWmsParameters::DxfFormatOption ) metaEnum.keyToValue( name.toStdString().c_str() );
2220 const QString value = it->right( it->length() - equalIdx - 1 );
2221 options.insert( option, value );
2222 }
2223 }
2224
2225 return options;
2226 }
2227
2228 QMap<QString, QString> QgsWmsParameters::dimensionValues() const
2229 {
2230 QMap<QString, QString> dimValues;
2231 const QMetaEnum pnMetaEnum( QMetaEnum::fromType<QgsMapLayerServerProperties::PredefinedWmsDimensionName>() );
2232 const QStringList unmanagedNames = mUnmanagedParameters.keys();
2233 for ( const QString &key : unmanagedNames )
2234 {
2235 if ( key.startsWith( QLatin1String( "DIM_" ) ) )
2236 {
2237 dimValues[key.mid( 4 )] = mUnmanagedParameters[key];
2238 }
2239 else if ( pnMetaEnum.keyToValue( key.toUpper().toStdString().c_str() ) != -1 )
2240 {
2241 dimValues[key] = mUnmanagedParameters[key];
2242 }
2243 }
2244 return dimValues;
2245 }
2246}
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