QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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 QVariant::Bool,
543 QVariant( false ) );
544 save( pWithDisplayName );
545
547 save( pWmtver );
548
550 QVariant::StringList );
551 save( pAtlasPk );
552
554 QVariant::String );
555 save( pFormatOpts );
556
558 QVariant::Bool,
559 QVariant( false ) );
560 save( pAddLayerGroups );
561 }
562
565 {
566 load( parameters.urlQuery() );
567
568 auto it = mWmsParameters.constFind( QgsWmsParameter::SLD );
569 if ( it != mWmsParameters.constEnd() && !it->toString().isEmpty() )
570 {
571 const QString sldBody = it->loadUrl();
572 if ( !sldBody.isEmpty() )
573 {
575 }
576 }
577 }
578
580 {
581 return mWmsParameters.value( name );
582 }
583
584 void QgsWmsParameters::set( QgsWmsParameter::Name name, const QVariant &value )
585 {
586 auto it = mWmsParameters.find( name );
587 if ( it == mWmsParameters.end() )
588 {
589 it = mWmsParameters.insert( name, QgsWmsParameter() );
590 }
591
592 it->mValue = value;
593 }
594
595 bool QgsWmsParameters::loadParameter( const QString &key, const QString &value )
596 {
597 bool loaded = false;
598
599 const thread_local QRegularExpression composerParamRegExp( QStringLiteral( "^MAP\\d+:" ), QRegularExpression::CaseInsensitiveOption );
600 if ( key.contains( composerParamRegExp ) )
601 {
602#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
603 const int mapId = key.midRef( 3, key.indexOf( ':' ) - 3 ).toInt();
604#else
605 const int mapId = QStringView {key}.mid( 3, key.indexOf( ':' ) - 3 ).toInt();
606#endif
607 const QString theKey = key.mid( key.indexOf( ':' ) + 1 );
608 const QgsWmsParameter::Name name = QgsWmsParameter::name( theKey );
609
610 if ( name >= 0 )
611 {
612 QgsWmsParameter param = mWmsParameters.value( name );
613 param.mValue = value;
614 param.mMapId = mapId;
615
616 if ( ! param.isValid() )
617 {
618 param.raiseError();
619 }
620
621 save( param, true ); // multi MAP parameters for composer
622 loaded = true;
623 }
624 }
625 else
626 {
628 if ( name >= 0 )
629 {
630 auto it = mWmsParameters.find( name );
631 if ( it == mWmsParameters.end() )
632 it = mWmsParameters.insert( name, QgsWmsParameter() );
633
634 it->mValue = value;
635 if ( !it->isValid() )
636 {
637 it->raiseError();
638 }
639
640 loaded = true;
641 }
642 else //maybe an external wms parameter?
643 {
644 int separator = key.indexOf( QLatin1Char( ':' ) );
645 if ( separator >= 1 )
646 {
647 QString id = key.left( separator );
648 QString param = key.right( key.length() - separator - 1 );
649 mExternalWMSParameters[id].insert( param, value );
650
651 loaded = true;
652 }
653 }
654 }
655
656 return loaded;
657 }
658
660 {
661 log( QStringLiteral( "WMS Request parameters:" ) );
662 for ( auto it = mWmsParameters.constBegin(); it != mWmsParameters.constEnd(); ++it )
663 {
664 const QString value = it->toString();
665
666 if ( ! value.isEmpty() )
667 {
668 QString name = QgsWmsParameter::name( it.key() );
669
670 if ( it->mMapId >= 0 )
671 {
672 name = QStringLiteral( "%1:%2" ).arg( QString::number( it->mMapId ), name );
673 }
674
675 log( QStringLiteral( " - %1 : %2" ).arg( name, value ) );
676 }
677 }
678
679 if ( !version().isEmpty() )
680 log( QStringLiteral( " - VERSION : %1" ).arg( version() ) );
681 }
682
683 void QgsWmsParameters::save( const QgsWmsParameter &parameter, bool multi )
684 {
685 if ( multi )
686 {
687 mWmsParameters.insert( parameter.mName, parameter );
688 }
689 else
690 {
691 mWmsParameters.replace( parameter.mName, parameter );
692 }
693 }
694
696 {
697 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_GEOM ).toStringList( ';' );
698 }
699
700 QList<QgsGeometry> QgsWmsParameters::highlightGeomAsGeom() const
701 {
702 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_GEOM ).toGeomList( ';' );
703 }
704
706 {
707 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_SYMBOL ).toStringList( ';' );
708 }
709
710 QString QgsWmsParameters::crs() const
711 {
712 QString rs;
713 const QString srs = mWmsParameters.value( QgsWmsParameter::SRS ).toString();
714 const QString crs = mWmsParameters.value( QgsWmsParameter::CRS ).toString();
715
716 // both SRS/CRS are supported but there's a priority according to the
717 // specified version when both are defined in the request
718 if ( !srs.isEmpty() && crs.isEmpty() )
719 rs = srs;
720 else if ( srs.isEmpty() && !crs.isEmpty() )
721 rs = crs;
722 else if ( !srs.isEmpty() && !crs.isEmpty() )
723 {
724 if ( versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) )
725 rs = crs;
726 else
727 rs = srs;
728 }
729
730 return rs;
731 }
732
734 {
735 return mWmsParameters.value( QgsWmsParameter::BBOX ).toString();
736 }
737
739 {
740 return mWmsParameters.value( QgsWmsParameter::BBOX ).toRectangle();
741 }
742
744 {
745 return mWmsParameters.value( QgsWmsParameter::HEIGHT ).toString();
746 }
747
749 {
750 return mWmsParameters.value( QgsWmsParameter::WIDTH ).toString();
751 }
752
754 {
755 return mWmsParameters.value( QgsWmsParameter::HEIGHT ).toInt();
756 }
757
759 {
760 return mWmsParameters.value( QgsWmsParameter::WIDTH ).toInt();
761 }
762
764 {
765 return mWmsParameters.value( QgsWmsParameter::SRCHEIGHT ).toString();
766 }
767
769 {
770 return mWmsParameters.value( QgsWmsParameter::SRCWIDTH ).toString();
771 }
772
774 {
775 return mWmsParameters.value( QgsWmsParameter::SRCHEIGHT ).toInt();
776 }
777
779 {
780 return mWmsParameters.value( QgsWmsParameter::SRCWIDTH ).toInt();
781 }
782
783 QString QgsWmsParameters::dpi() const
784 {
785 return mWmsParameters.value( QgsWmsParameter::DPI ).toString();
786 }
787
789 {
790 return mWmsParameters.value( QgsWmsParameter::DPI ).toDouble();
791 }
792
794 {
796
797 if ( QgsServerParameters::request().compare( QLatin1String( "GetProjectSettings" ), Qt::CaseInsensitive ) == 0 )
798 {
799 version = QStringLiteral( "1.3.0" );
800 }
801 else if ( version.isEmpty() )
802 {
803 if ( ! wmtver().isEmpty() )
804 {
805 version = wmtver();
806 }
807 else
808 {
809 version = QStringLiteral( "1.3.0" );
810 }
811 }
812 else if ( !mVersions.contains( QgsProjectVersion( version ) ) )
813 {
814 // WMS 1.3.0 specification: If a version lower than any of those
815 // known to the server is requested, then the server shall send the
816 // lowest version it supports.
817 if ( QgsProjectVersion( 1, 1, 1 ) > QgsProjectVersion( version ) )
818 {
819 version = QStringLiteral( "1.1.1" );
820 }
821 else
822 {
823 version = QStringLiteral( "1.3.0" );
824 }
825 }
826
827 return version;
828 }
829
831 {
832 QString req = QgsServerParameters::request();
833
834 if ( version().compare( QLatin1String( "1.1.1" ) ) == 0
835 && req.compare( QLatin1String( "capabilities" ), Qt::CaseInsensitive ) == 0 )
836 {
837 req = QStringLiteral( "GetCapabilities" );
838 }
839
840 return req;
841 }
842
844 {
845 return QgsProjectVersion( version() );
846 }
847
848 bool QgsWmsParameters::versionIsValid( const QString version ) const
849 {
850 return mVersions.contains( QgsProjectVersion( version ) );
851 }
852
854 {
855 return mWmsParameters.value( QgsWmsParameter::FORMAT ).toString( true );
856 }
857
859 {
860 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::Format>() );
861 return metaEnum.valueToKey( format );
862 }
863
865 {
866 const QString fStr = formatAsString();
867
868 Format f = Format::NONE;
869 if ( fStr.compare( QLatin1String( "image/png" ), Qt::CaseInsensitive ) == 0 ||
870 fStr.compare( QLatin1String( "png" ), Qt::CaseInsensitive ) == 0 )
871 {
872 f = Format::PNG;
873 }
874 else if ( fStr.compare( QLatin1String( "jpg" ), Qt::CaseInsensitive ) == 0
875 || fStr.compare( QLatin1String( "jpeg" ), Qt::CaseInsensitive ) == 0
876 || fStr.compare( QLatin1String( "image/jpeg" ), Qt::CaseInsensitive ) == 0 )
877 {
878 f = Format::JPG;
879 }
880 else if ( fStr.compare( QLatin1String( "image/svg" ), Qt::CaseInsensitive ) == 0 ||
881 fStr.compare( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive ) == 0 ||
882 fStr.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 )
883 {
884 f = Format::SVG;
885 }
886 else if ( fStr.compare( QLatin1String( "application/pdf" ), Qt::CaseInsensitive ) == 0 ||
887 fStr.compare( QLatin1String( "pdf" ), Qt::CaseInsensitive ) == 0 )
888 {
889 f = Format::PDF;
890 }
891 else if ( fStr.compare( QLatin1String( "application/json" ), Qt::CaseInsensitive ) == 0 ||
892 fStr.compare( QLatin1String( "json" ), Qt::CaseInsensitive ) == 0 )
893 {
894 f = Format::JSON;
895 }
896 return f;
897 }
898
900 {
901 return mWmsParameters.value( QgsWmsParameter::INFO_FORMAT ).toString();
902 }
903
905 {
906 return infoFormat() == Format::PNG || infoFormat() == Format::JPG;
907 }
908
910 {
911 QString fStr = infoFormatAsString();
912
913 Format f = Format::TEXT;
914 if ( fStr.isEmpty() )
915 return f;
916
917 if ( fStr.startsWith( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) )
918 f = Format::XML;
919 else if ( fStr.startsWith( QLatin1String( "text/html" ), Qt::CaseInsensitive ) )
920 f = Format::HTML;
921 else if ( fStr.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
922 f = Format::TEXT;
923 else if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml" ), Qt::CaseInsensitive ) )
924 f = Format::GML;
925 else if ( fStr.startsWith( QLatin1String( "application/json" ), Qt::CaseInsensitive )
926 || fStr.startsWith( QLatin1String( "application/geo+json" ), Qt::CaseInsensitive ) )
927 f = Format::JSON;
928 else
929 f = Format::NONE;
930
931 return f;
932 }
933
935 {
936 if ( infoFormat() != Format::GML )
937 return -1;
938
939 QString fStr = infoFormatAsString();
940 if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml/3" ), Qt::CaseInsensitive ) )
941 return 3;
942 else
943 return 2;
944 }
945
946 QString QgsWmsParameters::i() const
947 {
948 return mWmsParameters.value( QgsWmsParameter::I ).toString();
949 }
950
951 QString QgsWmsParameters::j() const
952 {
953 return mWmsParameters.value( QgsWmsParameter::J ).toString();
954 }
955
957 {
958 return mWmsParameters.value( QgsWmsParameter::I ).toInt();
959 }
960
962 {
963 return mWmsParameters.value( QgsWmsParameter::J ).toInt();
964 }
965
966 QString QgsWmsParameters::x() const
967 {
968 return mWmsParameters.value( QgsWmsParameter::X ).toString();
969 }
970
971 QString QgsWmsParameters::y() const
972 {
973 return mWmsParameters.value( QgsWmsParameter::Y ).toString();
974 }
975
977 {
978 return mWmsParameters.value( QgsWmsParameter::X ).toInt();
979 }
980
982 {
983 return mWmsParameters.value( QgsWmsParameter::Y ).toInt();
984 }
985
987 {
988 return mWmsParameters.value( QgsWmsParameter::RULE ).toString();
989 }
990
992 {
993 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toString();
994 }
995
997 {
998 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toBool();
999 }
1000
1002 {
1003 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toString();
1004 }
1005
1007 {
1008 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toBool();
1009 }
1010
1012 {
1013 return mWmsParameters.value( QgsWmsParameter::SCALE ).toString();
1014 }
1015
1017 {
1018 return mWmsParameters.value( QgsWmsParameter::SCALE ).toDouble();
1019 }
1020
1022 {
1023 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toString();
1024 }
1025
1027 {
1028 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toInt();
1029 }
1030
1032 {
1033 return mWmsParameters.value( QgsWmsParameter::TILED ).toString();
1034 }
1035
1037 {
1038 return mWmsParameters.value( QgsWmsParameter::TILED ).toBool();
1039 }
1040
1042 {
1043 return mWmsParameters.value( QgsWmsParameter::ADDLAYERGROUPS ).toBool();
1044 }
1045
1047 {
1048 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toString();
1049 }
1050
1052 {
1053 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toBool();
1054 }
1055
1057 {
1058 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toString();
1059 }
1060
1062 {
1063 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toInt();
1064 }
1065
1067 {
1068 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toString();
1069 }
1070
1072 {
1073 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toDouble();
1074 }
1075
1077 {
1078 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toString();
1079 }
1080
1082 {
1083 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toDouble();
1084 }
1085
1087 {
1088 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toString();
1089 }
1090
1092 {
1093 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toDouble();
1094 }
1095
1097 {
1098 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toString();
1099 }
1100
1102 {
1103 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toDouble();
1104 }
1105
1107 {
1108 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toString();
1109 }
1110
1112 {
1113 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toDouble();
1114 }
1115
1117 {
1118 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toString();
1119 }
1120
1122 {
1123 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toDouble();
1124 }
1125
1127 {
1128 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toString();
1129 }
1130
1132 {
1133 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toDouble();
1134 }
1135
1137 {
1138 return mWmsParameters.value( QgsWmsParameter::LAYERFONTFAMILY ).toString();
1139 }
1140
1142 {
1143 return mWmsParameters.value( QgsWmsParameter::ITEMFONTFAMILY ).toString();
1144 }
1145
1147 {
1148 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toString();
1149 }
1150
1152 {
1153 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toBool();
1154 }
1155
1157 {
1158 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toString();
1159 }
1160
1162 {
1163 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toString();
1164 }
1165
1167 {
1168 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toString();
1169 }
1170
1172 {
1173 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toString();
1174 }
1175
1177 {
1178 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toInt();
1179 }
1180
1182 {
1183 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toInt();
1184 }
1185
1187 {
1188 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toInt();
1189 }
1190
1192 {
1193 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toBool();
1194 }
1195
1197 {
1198 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toString();
1199 }
1200
1202 {
1203 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toBool();
1204 }
1205
1207 {
1208 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toString();
1209 }
1210
1212 {
1213 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toBool();
1214 }
1215
1217 {
1218 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toString();
1219 }
1220
1222 {
1223 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toDouble();
1224 }
1225
1227 {
1228 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toString();
1229 }
1230
1232 {
1233 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toColor();
1234 }
1235
1237 {
1238 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toString();
1239 }
1240
1242 {
1243 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toDouble();
1244 }
1245
1247 {
1248 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toString();
1249 }
1250
1252 {
1253 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toColor();
1254 }
1255
1257 {
1258 QFont font;
1259 font.fromString( "" );
1260 font.setBold( layerFontBoldAsBool() );
1261 font.setItalic( layerFontItalicAsBool() );
1262
1263 if ( ! layerFontSize().isEmpty() )
1264 font.setPointSizeF( layerFontSizeAsDouble() );
1265
1266 if ( !layerFontFamily().isEmpty() )
1267 font.setFamily( layerFontFamily() );
1268
1269 return font;
1270 }
1271
1273 {
1274 QFont font;
1275 font.fromString( "" );
1276
1277 font.setBold( itemFontBoldAsBool() );
1278 font.setItalic( itemFontItalicAsBool() );
1279
1280 if ( ! itemFontSize().isEmpty() )
1281 font.setPointSizeF( itemFontSizeAsDouble() );
1282
1283 if ( !itemFontFamily().isEmpty() )
1284 font.setFamily( itemFontFamily() );
1285
1286 return font;
1287 }
1288
1290 {
1291 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toString();
1292 }
1293
1295 {
1296 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toBool();
1297 }
1298
1300 {
1301 QgsLegendSettings settings;
1302 settings.setTitle( QString() );
1303 settings.setBoxSpace( boxSpaceAsDouble() );
1304 settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) );
1305
1306 settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Top, layerSpaceAsDouble() );
1307 settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Bottom, layerTitleSpaceAsDouble() );
1308
1309 // text format must be set before setting the format's colors
1310 settings.rstyle( QgsLegendStyle::Style::Subgroup ).setTextFormat( QgsTextFormat::fromQFont( layerFont() ) );
1311 settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setTextFormat( QgsTextFormat::fromQFont( itemFont() ) );
1312
1313 if ( !itemFontColor().isEmpty() )
1314 {
1319 }
1320
1321 // Ok, this is tricky: because QgsLegendSettings's layerFontColor was added to the API after
1322 // fontColor, to fix regressions #21871 and #21870 and the previous behavior was to use fontColor
1323 // for the whole legend we need to preserve that behavior.
1324 // But, the 2.18 server parameters ITEMFONTCOLOR did not have effect on the layer titles too, so
1325 // we set explicitly layerFontColor to black if it's not overridden by LAYERFONTCOLOR argument.
1326 settings.rstyle( QgsLegendStyle::Group ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1327 settings.rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1328
1329 settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpaceAsDouble() );
1330 settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setMargin( QgsLegendStyle::Side::Left, iconLabelSpaceAsDouble() );
1331
1332 return settings;
1333 }
1334
1335 QString QgsWmsParameters::layoutParameter( const QString &id, bool &ok ) const
1336 {
1337 QString label;
1338 ok = false;
1339
1340 if ( mUnmanagedParameters.contains( id.toUpper() ) )
1341 {
1342 label = mUnmanagedParameters[id.toUpper()];
1343 ok = true;
1344 }
1345
1346 return label;
1347 }
1348
1349 QStringList QgsWmsParameters::atlasPk() const
1350 {
1351 return mWmsParameters.value( QgsWmsParameter::ATLAS_PK ).toStringList();
1352 }
1353
1355 {
1356 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSTRING ).toStringList( ';' );
1357 }
1358
1360 {
1361 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toStringList( ';' );
1362 }
1363
1365 {
1366 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toIntList( ';' );
1367 }
1368
1370 {
1371 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toStringList( ';' );
1372 }
1373
1375 {
1376 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toColorList( ';' );
1377 }
1378
1380 {
1381 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toStringList( ';' );
1382 }
1383
1385 {
1386 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toIntList( ';' );
1387 }
1388
1390 {
1391 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELFONT ).toStringList( ';' );
1392 }
1393
1395 {
1396 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toStringList( ';' );
1397 }
1398
1400 {
1401 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toColorList( ';' );
1402 }
1403
1405 {
1406 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toStringList( ';' );
1407 }
1408
1410 {
1411 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toDoubleList( ';' );
1412 }
1413
1415 {
1416 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION ).toDoubleList( ';' );
1417 }
1418
1420 {
1421 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE ).toDoubleList( ';' );
1422 }
1423
1425 {
1426 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT ).toStringList( ';' );
1427 }
1428
1430 {
1431 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT ).toStringList( ';' );
1432 }
1433
1435 {
1436 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toString();
1437 }
1438
1440 {
1441 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toInt();
1442 }
1443
1445 {
1446 return mWmsParameters.value( QgsWmsParameter::SLD_BODY ).toString();
1447 }
1448
1449 QStringList QgsWmsParameters::filters() const
1450 {
1451 QStringList filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toOgcFilterList();
1452 if ( filters.isEmpty() )
1453 filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toExpressionList();
1454 return filters;
1455 }
1456
1458 {
1459 return mWmsParameters.value( QgsWmsParameter::FILTER_GEOM ).toString();
1460 }
1461
1463 {
1464 return mWmsParameters.value( QgsWmsParameter::SELECTION ).toStringList( ';' );
1465 }
1466
1468 {
1469 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toStringList();
1470 }
1471
1473 {
1474 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toIntList();
1475 }
1476
1478 {
1479 // We don't want duplicates but order does matter, so no QSet
1480 QStringList result;
1481
1482 // LAYER
1483 QList<QgsWmsParameter> cLayer { mWmsParameters.values( QgsWmsParameter::LAYER ) };
1484 // Sort by map id
1485 std::sort( cLayer.begin(), cLayer.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1486 for ( const QgsWmsParameter &param : std::as_const( cLayer ) )
1487 {
1488 const QStringList layersList { param.toStringList() };
1489 for ( const QString &layerName : std::as_const( layersList ) )
1490 {
1491 if ( ! result.contains( layerName ) )
1492 result.append( layerName );
1493 }
1494 }
1495
1496 // LAYERS
1497 QList<QgsWmsParameter> cLayers { mWmsParameters.values( QgsWmsParameter::LAYERS ) };
1498 // Sort by map id
1499 std::sort( cLayers.begin(), cLayers.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1500 for ( const QgsWmsParameter &param : std::as_const( cLayers ) )
1501 {
1502 const QStringList layersList { param.toStringList() };
1503 for ( const QString &layerName : std::as_const( layersList ) )
1504 {
1505 if ( ! result.contains( layerName ) )
1506 result.append( layerName );
1507 }
1508 }
1509 return result;
1510 }
1511
1513 {
1514 return mWmsParameters.value( QgsWmsParameter::QUERY_LAYERS ).toStringList();
1515 }
1516
1518 {
1519 QStringList style = mWmsParameters.value( QgsWmsParameter::STYLE ).toStyleList();
1520 const QStringList styles = mWmsParameters.value( QgsWmsParameter::STYLES ).toStyleList();
1521 return style << styles;
1522 }
1523
1524 QMultiMap<QString, QgsWmsParametersFilter> QgsWmsParameters::layerFilters( const QStringList &layers ) const
1525 {
1526 const QString nsWfs2 = QStringLiteral( "http://www.opengis.net/fes/2.0" );
1527 const QString prefixWfs2 = QStringLiteral( "<fes:" );
1528
1529 const QStringList rawFilters = filters();
1530 QMultiMap<QString, QgsWmsParametersFilter> filters;
1531 for ( int i = 0; i < rawFilters.size(); i++ )
1532 {
1533 const QString f = rawFilters[i];
1534 if ( f.startsWith( QLatin1Char( '<' ) ) \
1535 && f.endsWith( QLatin1String( "Filter>" ) ) \
1536 && i < layers.size() )
1537 {
1539 filter.mFilter = f;
1542
1543 if ( filter.mFilter.contains( nsWfs2 ) \
1544 || filter.mFilter.contains( prefixWfs2 ) )
1545 {
1547 }
1548
1549 filters.insert( layers[i], filter );
1550 }
1551 else if ( !f.isEmpty() )
1552 {
1553 // filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
1554 // several filters can be defined for one layer
1555 const int colonIndex = f.indexOf( ':' );
1556 if ( colonIndex != -1 )
1557 {
1558 const QString layers = f.section( ':', 0, 0 );
1559 const QString filter = f.section( ':', 1 );
1560 const QStringList layersList = layers.split( ',' );
1561 for ( const QString &layer : layersList )
1562 {
1563 QgsWmsParametersFilter parametersFilter;
1564 parametersFilter.mFilter = filter;
1565 parametersFilter.mType = QgsWmsParametersFilter::SQL;
1566 filters.insert( layer, parametersFilter );
1567 }
1568 }
1569 else
1570 {
1571 QString filterStr = mWmsParameters.value( QgsWmsParameter::FILTER ).toString();
1572 raiseError( QStringLiteral( "FILTER ('" ) + filterStr + QStringLiteral( "') is not properly formatted" ) );
1573 }
1574 }
1575 }
1576 return filters;
1577 }
1578
1580 {
1581 bool force2D = false;
1582 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1583
1584 if ( options.contains( DxfFormatOption::FORCE_2D ) )
1585 {
1586 force2D = QVariant( options[ DxfFormatOption::FORCE_2D ] ).toBool();
1587 }
1588
1589 return force2D;
1590 }
1591
1593 {
1594 bool noMText = false;
1595 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1596
1597 if ( options.contains( DxfFormatOption::NO_MTEXT ) )
1598 {
1599 noMText = QVariant( options[ DxfFormatOption::NO_MTEXT ] ).toBool();
1600 }
1601
1602 return noMText;
1603 }
1604
1605
1606 QList<QgsWmsParametersLayer> QgsWmsParameters::layersParameters() const
1607 {
1608 const QStringList layers = allLayersNickname();
1609 const QStringList styles = allStyles();
1610 const QStringList selection = selections();
1611 const QList<int> opacities = opacitiesAsInt();
1612 const QMultiMap<QString, QgsWmsParametersFilter> filters = layerFilters( layers );
1613
1614 // selection format: "LayerName:id0,id1;LayerName2:id0,id1;..."
1615 // several filters can be defined for one layer
1616 QMultiMap<QString, QString> layerSelections;
1617 for ( const QString &s : selection )
1618 {
1619 const QStringList splits = s.split( ':' );
1620 if ( splits.size() == 2 )
1621 {
1622 layerSelections.insert( splits[0], splits[1] );
1623 }
1624 else
1625 {
1626 QString selStr = mWmsParameters.value( QgsWmsParameter::SELECTION ).toString();
1627 raiseError( QStringLiteral( "SELECTION ('" ) + selStr + QStringLiteral( "') is not properly formatted" ) );
1628 }
1629 }
1630
1631 QList<QgsWmsParametersLayer> parameters;
1632 for ( int i = 0; i < layers.size(); i++ )
1633 {
1634 QString layer = layers[i];
1635
1637 param.mNickname = layer;
1638
1639 if ( i < opacities.count() )
1640 param.mOpacity = opacities[i];
1641
1642 if ( isExternalLayer( layer ) )
1643 {
1644 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1645 param.mNickname = extParam.mName;
1646 param.mExternalUri = extParam.mUri;
1647 }
1648 else
1649 {
1650 if ( i < styles.count() )
1651 param.mStyle = styles[i];
1652
1653 if ( filters.contains( layer ) )
1654 {
1655 auto it = filters.find( layer );
1656 while ( it != filters.end() && it.key() == layer )
1657 {
1658 param.mFilter.append( it.value() );
1659 ++it;
1660 }
1661 }
1662
1663 if ( layerSelections.contains( layer ) )
1664 {
1665 QMultiMap<QString, QString>::const_iterator it;
1666 it = layerSelections.constFind( layer );
1667 while ( it != layerSelections.constEnd() && it.key() == layer )
1668 {
1669 param.mSelection << it.value().split( ',' );
1670 ++it;
1671 }
1672 }
1673 }
1674
1675 parameters.append( param );
1676 }
1677
1678 return parameters;
1679 }
1680
1681 QList<QgsWmsParametersHighlightLayer> QgsWmsParameters::highlightLayersParameters() const
1682 {
1683 QList<QgsWmsParametersHighlightLayer> params;
1684 const QList<QgsGeometry> geoms = highlightGeomAsGeom();
1685 const QStringList slds = highlightSymbol();
1686 const QStringList labels = highlightLabelString();
1687 const QList<QColor> colors = highlightLabelColorAsColor();
1688 const QList<int> sizes = highlightLabelSizeAsInt();
1689 const QList<int> weights = highlightLabelWeightAsInt();
1690 const QStringList fonts = highlightLabelFont();
1691 const QList<QColor> bufferColors = highlightLabelBufferColorAsColor();
1692 const QList<double> bufferSizes = highlightLabelBufferSizeAsFloat();
1693 const QList<double> rotation = highlightLabelRotation();
1694 const QList<double> distance = highlightLabelDistance();
1695 const QStringList hali = highlightLabelHorizontalAlignment();
1696 const QStringList vali = highlightLabelVerticalAlignment();
1697
1698 int nLayers = std::min( geoms.size(), slds.size() );
1699 for ( int i = 0; i < nLayers; i++ )
1700 {
1702 param.mName = QStringLiteral( "highlight_" ) + QString::number( i );
1703 param.mGeom = geoms[i];
1704 param.mSld = slds[i];
1705
1706 if ( i < labels.count() )
1707 param.mLabel = labels[i];
1708
1709 if ( i < colors.count() )
1710 param.mColor = colors[i];
1711
1712 if ( i < sizes.count() )
1713 param.mSize = sizes[i];
1714
1715 if ( i < weights.count() )
1716 param.mWeight = weights[i];
1717
1718 if ( i < fonts.count() )
1719 param.mFont = fonts[ i ];
1720
1721 if ( i < bufferColors.count() )
1722 param.mBufferColor = bufferColors[i];
1723
1724 if ( i < bufferSizes.count() )
1725 param.mBufferSize = bufferSizes[i];
1726
1727 if ( i < rotation.count() )
1728 param.mLabelRotation = rotation[i];
1729
1730 if ( i < distance.count() )
1731 param.mLabelDistance = distance[i];
1732
1733 if ( i < hali.count() )
1734 param.mHali = hali[i];
1735
1736 if ( i < vali.count() )
1737 param.mVali = vali[i];
1738
1739
1740
1741 params.append( param );
1742 }
1743
1744 return params;
1745 }
1746
1747 QList<QgsWmsParametersExternalLayer> QgsWmsParameters::externalLayersParameters() const
1748 {
1749 auto notExternalLayer = []( const QString & name ) { return ! QgsWmsParameters::isExternalLayer( name ); };
1750
1751 QList<QgsWmsParametersExternalLayer> externalLayers;
1752
1753 QStringList layers = allLayersNickname();
1754 QStringList::iterator rit = std::remove_if( layers.begin(), layers.end(), notExternalLayer );
1755
1756 for ( QStringList::iterator it = layers.begin(); it != rit; ++it )
1757 {
1758 externalLayers << externalLayerParameter( *it );
1759 }
1760
1761 return externalLayers;
1762 }
1763
1765 {
1766 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toString();
1767 }
1768
1770 {
1771 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toColor();
1772 }
1773
1775 {
1776 return mWmsParameters.value( QgsWmsParameter::TEMPLATE ).toString();
1777 }
1778
1780 {
1781 QgsWmsParameter wmsParam;
1783 param.mId = mapId;
1784
1785 QString pMapId = QStringLiteral( "MAP" ) + QString::number( mapId );
1786
1787 wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1788 QgsRectangle extent;
1789 if ( wmsParam.isValid() )
1790 {
1791 extent = wmsParam.toRectangle();
1792 }
1793
1794 param.mHasExtent = !extent.isEmpty();
1795 param.mExtent = extent;
1796
1797 // scale
1798 wmsParam = idParameter( QgsWmsParameter::SCALE, mapId );
1799 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1800 {
1801 param.mScale = wmsParam.toDouble();
1802 }
1803
1804 // rotation
1805 wmsParam = idParameter( QgsWmsParameter::ROTATION, mapId );
1806 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1807 {
1808 param.mRotation = wmsParam.toDouble();
1809 }
1810
1811 //grid space x / y
1812 double gridx( -1 ), gridy( -1 );
1813
1814 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_X, mapId );
1815 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1816 {
1817 gridx = wmsParam.toDouble();
1818 }
1819
1820 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_Y, mapId );
1821 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1822 {
1823 gridy = wmsParam.toDouble();
1824 }
1825
1826 if ( gridx != -1 && gridy != -1 )
1827 {
1828 param.mGridX = gridx;
1829 param.mGridY = gridy;
1830 }
1831
1832 //layers
1833 QStringList allLayers;
1834 wmsParam = idParameter( QgsWmsParameter::LAYERS, mapId );
1835 if ( wmsParam.isValid() )
1836 {
1837 allLayers = wmsParam.toStringList();
1838 }
1839
1840 // external layers
1841 QStringList layers;
1842
1843 for ( const auto &layer : std::as_const( allLayers ) )
1844 {
1845 if ( isExternalLayer( layer ) )
1846 {
1847 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1848 layers << extParam.mName;
1849 }
1850 else
1851 {
1852 layers << layer;
1853 }
1854 }
1855
1856 QStringList styles;
1857 wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
1858 if ( wmsParam.isValid() )
1859 {
1860 styles = wmsParam.toStyleList();
1861 }
1862
1863 QList<QgsWmsParametersLayer> lParams;
1864 for ( int i = 0; i < layers.size(); i++ )
1865 {
1866 QString layer = layers[i];
1867 QgsWmsParametersLayer lParam;
1868 lParam.mNickname = layer;
1869
1870 if ( i < styles.count() )
1871 lParam.mStyle = styles[i];
1872
1873 lParams.append( lParam );
1874 }
1875 param.mLayers = lParams;
1876
1877 //highlight layers
1878 QList<QgsWmsParametersHighlightLayer> hParams;
1879
1880 QList<QgsGeometry> geoms;
1881 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_GEOM, mapId );
1882 if ( wmsParam.isValid() )
1883 {
1884 geoms = wmsParam.toGeomList( ';' );
1885 }
1886
1887 QStringList slds;
1888 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_SYMBOL, mapId );
1889 if ( wmsParam.isValid() )
1890 {
1891 slds = wmsParam.toStringList( ';' );
1892 }
1893
1894 QStringList labels;
1895 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSTRING, mapId );
1896 if ( wmsParam.isValid() )
1897 {
1898 labels = wmsParam.toStringList( ';' );
1899 }
1900
1901 QStringList fonts;
1902 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELFONT, mapId );
1903 if ( wmsParam.isValid() )
1904 {
1905 fonts = wmsParam.toStringList( ';' );
1906 }
1907
1908 QList<QColor> colors;
1909 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELCOLOR, mapId );
1910 if ( wmsParam.isValid() )
1911 {
1912 colors = wmsParam.toColorList( ';' );
1913 }
1914
1915 QList<int> sizes;
1916 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSIZE, mapId );
1917 if ( wmsParam.isValid() )
1918 {
1919 sizes = wmsParam.toIntList( ';' );
1920 }
1921
1922 QList<int> weights;
1923 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT, mapId );
1924 if ( wmsParam.isValid() )
1925 {
1926 weights = wmsParam.toIntList( ';' );
1927 }
1928
1929 QList<QColor> bufferColors;
1930 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR, mapId );
1931 if ( wmsParam.isValid() )
1932 {
1933 bufferColors = wmsParam.toColorList( ';' );
1934 }
1935
1936 QList<double> bufferSizes;
1937 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE, mapId );
1938 if ( wmsParam.isValid() )
1939 {
1940 bufferSizes = wmsParam.toDoubleList( ';' );
1941 }
1942
1943 QList<double> rotations;
1944 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, mapId );
1945 if ( wmsParam.isValid() )
1946 {
1947 rotations = wmsParam.toDoubleList( ';' );
1948 }
1949
1950 QList<double> distances;
1951 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, mapId );
1952 if ( wmsParam.isValid() )
1953 {
1954 distances = wmsParam.toDoubleList( ';' );
1955 }
1956
1957 QStringList halis;
1958 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT, mapId );
1959 if ( wmsParam.isValid() )
1960 {
1961 halis = wmsParam.toStringList();
1962 }
1963
1964 QStringList valis;
1965 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT, mapId );
1966 if ( wmsParam.isValid() )
1967 {
1968 valis = wmsParam.toStringList();
1969 }
1970
1971 int nHLayers = std::min( geoms.size(), slds.size() );
1972 for ( int i = 0; i < nHLayers; i++ )
1973 {
1975 hParam.mName = pMapId + QStringLiteral( "_highlight_" ) + QString::number( i );
1976 hParam.mGeom = geoms[i];
1977 hParam.mSld = slds[i];
1978
1979 if ( i < labels.count() )
1980 hParam.mLabel = labels[i];
1981
1982 if ( i < colors.count() )
1983 hParam.mColor = colors[i];
1984
1985 if ( i < sizes.count() )
1986 hParam.mSize = sizes[i];
1987
1988 if ( i < weights.count() )
1989 hParam.mWeight = weights[i];
1990
1991 if ( i < fonts.count() )
1992 hParam.mFont = fonts[ i ];
1993
1994 if ( i < bufferColors.count() )
1995 hParam.mBufferColor = bufferColors[i];
1996
1997 if ( i < bufferSizes.count() )
1998 hParam.mBufferSize = bufferSizes[i];
1999
2000 if ( i < rotations.count() )
2001 hParam.mLabelRotation = rotations[i];
2002
2003 if ( i < distances.count() )
2004 hParam.mLabelDistance = distances[i];
2005
2006 if ( i < halis.count() )
2007 hParam.mHali = halis[i];
2008
2009 if ( i < valis.count() )
2010 hParam.mVali = valis[i];
2011
2012 hParams.append( hParam );
2013 }
2014 param.mHighlightLayers = hParams;
2015
2016 return param;
2017 }
2018
2019 QString QgsWmsParameters::externalWMSUri( const QString &layerId ) const
2020 {
2021
2022 // Param names may be uppercased.
2023 QString id { layerId };
2024
2025 for ( auto it = mExternalWMSParameters.cbegin(); it != mExternalWMSParameters.cend(); ++it )
2026 {
2027 if ( it.key().compare( id, Qt::CaseSensitivity::CaseInsensitive ) == 0 )
2028 {
2029 id = it.key();
2030 break;
2031 }
2032 }
2033
2034 if ( !mExternalWMSParameters.contains( id ) )
2035 {
2036 return QString();
2037 }
2038
2039 QgsDataSourceUri wmsUri;
2040 const QMap<QString, QString> &paramMap = mExternalWMSParameters[ id ];
2041 QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin();
2042 for ( ; paramIt != paramMap.constEnd(); ++paramIt )
2043 {
2044 QString paramName = paramIt.key().toLower();
2045 if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) || paramName == QLatin1String( "opacities" ) )
2046 {
2047 const QStringList values = paramIt.value().split( ',' );
2048 for ( const QString &value : values )
2049 wmsUri.setParam( paramName, value );
2050 }
2051 else if ( paramName == QLatin1String( "ignorereportedlayerextents" ) )
2052 {
2053 wmsUri.setParam( QStringLiteral( "IgnoreReportedLayerExtents" ), paramIt.value() );
2054 }
2055 else if ( paramName == QLatin1String( "smoothpixmaptransform" ) )
2056 {
2057 wmsUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), paramIt.value() );
2058 }
2059 else if ( paramName == QLatin1String( "ignoregetmapurl" ) )
2060 {
2061 wmsUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), paramIt.value() );
2062 }
2063 else if ( paramName == QLatin1String( "ignoregetfeatureinfourl" ) )
2064 {
2065 wmsUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), paramIt.value() );
2066 }
2067 else if ( paramName == QLatin1String( "ignoreaxisorientation" ) )
2068 {
2069 wmsUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), paramIt.value() );
2070 }
2071 else if ( paramName == QLatin1String( "invertaxisorientation" ) )
2072 {
2073 wmsUri.setParam( QStringLiteral( "InvertAxisOrientation" ), paramIt.value() );
2074 }
2075 else if ( paramName == QLatin1String( "dpimode" ) )
2076 {
2077 wmsUri.setParam( QStringLiteral( "dpiMode" ), paramIt.value() );
2078 }
2079 else if ( paramName == QLatin1String( "stepwidth" ) )
2080 {
2081 wmsUri.setParam( QStringLiteral( "stepWidth" ), paramIt.value() );
2082 }
2083 else if ( paramName == QLatin1String( "stepheight" ) )
2084 {
2085 wmsUri.setParam( QStringLiteral( "stepHeight" ), paramIt.value() );
2086 }
2087 else
2088 {
2089 wmsUri.setParam( paramName, paramIt.value() );
2090 }
2091 }
2092 return wmsUri.encodedUri();
2093 }
2094
2096 {
2097 return mWmsParameters.value( QgsWmsParameter::WITH_GEOMETRY ).toBool();
2098 }
2099
2101 {
2102 return mWmsParameters.value( QgsWmsParameter::WITH_MAPTIP ).toBool();
2103 }
2104
2106 {
2107 return mWmsParameters.value( QgsWmsParameter::WITH_DISPLAY_NAME ).toBool();
2108 }
2109
2111 {
2112 return mWmsParameters.value( QgsWmsParameter::WMTVER ).toString();
2113 }
2114
2115 void QgsWmsParameters::log( const QString &msg ) const
2116 {
2117 QgsMessageLog::logMessage( msg, QStringLiteral( "Server" ), Qgis::MessageLevel::Info );
2118 }
2119
2120 void QgsWmsParameters::raiseError( const QString &msg ) const
2121 {
2123 }
2124
2125 QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
2126 {
2127 QgsWmsParameter p;
2128
2129 for ( const auto &param : mWmsParameters.values( name ) )
2130 {
2131 if ( param.mMapId == id )
2132 {
2133 p = param;
2134 }
2135 }
2136
2137 return p;
2138 }
2139
2140 QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
2141 {
2142 QgsWmsParametersExternalLayer param;
2143
2144 param.mName = name;
2145 param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
2146 param.mUri = externalWMSUri( param.mName );
2147
2148 return param;
2149 }
2150
2151 bool QgsWmsParameters::isExternalLayer( const QString &name )
2152 {
2153 return name.startsWith( EXTERNAL_LAYER_PREFIX );
2154 }
2155
2157 {
2158 QStringList attributes;
2159 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2160
2161 if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
2162 {
2163 attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
2164 }
2165
2166 return attributes;
2167 }
2168
2170 {
2171 bool use = false;
2172 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2173
2174 if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
2175 {
2176 use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
2177 }
2178
2179 return use;
2180 }
2181
2183 {
2184 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2185
2186 double scale = -1;
2187 if ( options.contains( DxfFormatOption::SCALE ) )
2188 {
2189 scale = options[ DxfFormatOption::SCALE ].toDouble();
2190 }
2191
2192 return scale;
2193 }
2194
2196 {
2197 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2198
2200
2201 if ( ! options.contains( DxfFormatOption::MODE ) )
2202 {
2203 return symbol;
2204 }
2205
2206 const QString mode = options[ DxfFormatOption::MODE ];
2207 if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
2208 {
2209 symbol = Qgis::FeatureSymbologyExport::PerSymbolLayer;
2210 }
2211 else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
2212 {
2213 symbol = Qgis::FeatureSymbologyExport::PerFeature;
2214 }
2215
2216 return symbol;
2217 }
2218
2220 {
2221 QString codec = QStringLiteral( "ISO-8859-1" );
2222
2223 if ( formatOptions<QgsWmsParameters::DxfFormatOption>().contains( DxfFormatOption::CODEC ) )
2224 {
2225 codec = formatOptions<QgsWmsParameters::DxfFormatOption>()[ DxfFormatOption::CODEC ];
2226 }
2227
2228 return codec;
2229 }
2230
2232 {
2233 bool geoPdf = false;
2234 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2235 if ( options.contains( PdfFormatOption::WRITE_GEO_PDF ) )
2236 {
2237 geoPdf = QVariant( options[PdfFormatOption::WRITE_GEO_PDF] ).toBool();
2238 }
2239 return geoPdf;
2240 }
2241
2243 {
2244 bool forceVector = false;
2245 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2246 if ( options.contains( PdfFormatOption::FORCE_VECTOR_OUTPUT ) )
2247 {
2248 forceVector = QVariant( options[PdfFormatOption::FORCE_VECTOR_OUTPUT] ).toBool();
2249 }
2250 return forceVector;
2251 }
2252
2254 {
2255 bool appendGeoref = true;
2256 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2257 if ( options.contains( PdfFormatOption::APPEND_GEOREFERENCE ) )
2258 {
2259 appendGeoref = QVariant( options[PdfFormatOption::APPEND_GEOREFERENCE] ).toBool();
2260 }
2261 return appendGeoref;
2262 }
2263
2265 {
2266 bool simplify = true;
2267 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2268 if ( options.contains( PdfFormatOption::SIMPLIFY_GEOMETRY ) )
2269 {
2270 simplify = QVariant( options[PdfFormatOption::SIMPLIFY_GEOMETRY] ).toBool();
2271 }
2272 return simplify;
2273 }
2274
2276 {
2277 bool exportMetadata = false;
2278 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2279 if ( options.contains( PdfFormatOption::EXPORT_METADATA ) )
2280 {
2281 exportMetadata = QVariant( options[PdfFormatOption::EXPORT_METADATA] ).toBool();
2282 }
2283 return exportMetadata;
2284 }
2285
2287 {
2288 Qgis::TextRenderFormat format = Qgis::TextRenderFormat::AlwaysOutlines;
2289 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2290 if ( options.contains( PdfFormatOption::TEXT_RENDER_FORMAT ) )
2291 {
2292 if ( options[PdfFormatOption::TEXT_RENDER_FORMAT].compare( QStringLiteral( "AlwaysText" ), Qt::CaseInsensitive ) == 0 )
2293 {
2294 format = Qgis::TextRenderFormat::AlwaysText;
2295 }
2296 }
2297 return format;
2298 }
2299
2301 {
2302 bool losslessCompression = false;
2303 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2304 if ( options.contains( PdfFormatOption::LOSSLESS_IMAGE_COMPRESSION ) )
2305 {
2306 losslessCompression = QVariant( options[PdfFormatOption::LOSSLESS_IMAGE_COMPRESSION] ).toBool();
2307 }
2308 return losslessCompression;
2309 }
2310
2312 {
2313 bool disableTiledRaster = false;
2314 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2315 if ( options.contains( PdfFormatOption::DISABLE_TILED_RASTER_RENDERING ) )
2316 {
2317 disableTiledRaster = QVariant( options[PdfFormatOption::DISABLE_TILED_RASTER_RENDERING] ).toBool();
2318 }
2319 return disableTiledRaster;
2320 }
2321
2323 {
2324 bool useIso32000 = true;
2325 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2326 if ( options.contains( PdfFormatOption::USE_ISO_32000_EXTENSION_FORMAT_GEOREFERENCING ) )
2327 {
2328 useIso32000 = QVariant( options[PdfFormatOption::USE_ISO_32000_EXTENSION_FORMAT_GEOREFERENCING] ).toBool();
2329 }
2330 return useIso32000;
2331 }
2332
2334 {
2335 bool useOgcGeoreferencing = false;
2336 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2337 if ( options.contains( PdfFormatOption::USE_OGC_BEST_PRACTICE_FORMAT_GEOREFERENCING ) )
2338 {
2339 useOgcGeoreferencing = QVariant( options[PdfFormatOption::USE_OGC_BEST_PRACTICE_FORMAT_GEOREFERENCING] ).toBool();
2340 }
2341 return useOgcGeoreferencing;
2342 }
2343
2345 {
2346 QStringList themes;
2347 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2348 if ( options.contains( PdfFormatOption::EXPORT_THEMES ) )
2349 {
2350 themes = options[PdfFormatOption::EXPORT_THEMES].split( ',' );
2351 }
2352 return themes;
2353 }
2354
2356 {
2357 QVector<qreal> scales;
2358 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2359 if ( options.contains( PdfFormatOption::PREDEFINED_MAP_SCALES ) )
2360 {
2361 const QStringList scaleList = options[PdfFormatOption::PREDEFINED_MAP_SCALES].split( ',' );
2362 for ( const QString &it : std::as_const( scaleList ) )
2363 {
2364 bool ok = false;
2365 qreal scale = it.toDouble( &ok );
2366 if ( ok )
2367 {
2368 scales.append( scale );
2369 }
2370 }
2371 }
2372 return scales;
2373 }
2374
2375 QMap<QString, QString> QgsWmsParameters::dimensionValues() const
2376 {
2377 QMap<QString, QString> dimValues;
2378 const QMetaEnum pnMetaEnum( QMetaEnum::fromType<QgsMapLayerServerProperties::PredefinedWmsDimensionName>() );
2379 const QStringList unmanagedNames = mUnmanagedParameters.keys();
2380 for ( const QString &key : unmanagedNames )
2381 {
2382 if ( key.startsWith( QLatin1String( "DIM_" ) ) )
2383 {
2384 dimValues[key.mid( 4 )] = mUnmanagedParameters[key];
2385 }
2386 else if ( pnMetaEnum.keyToValue( key.toUpper().toStdString().c_str() ) != -1 )
2387 {
2388 dimValues[key] = mUnmanagedParameters[key];
2389 }
2390 }
2391 return dimValues;
2392 }
2393}
TextRenderFormat
Options for rendering text.
Definition: qgis.h:1885
FeatureSymbologyExport
Options for exporting features considering their symbology.
Definition: qgis.h:3635
@ NoSymbology
Export only data.
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.
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
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.
QgsTextFormat & textFormat()
Returns the text format used for rendering this legend component.
void setMargin(Side side, double margin)
Sets the margin (in mm) for the specified side of the component.
@ Group
Legend group title.
@ Subgroup
Legend subgroup title.
@ Title
Legend title.
@ SymbolLabel
Symbol label (excluding icon)
void setTextFormat(const QgsTextFormat &format)
Sets the text format 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.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
static QgsTextFormat fromQFont(const QFont &font)
Returns a text format matching the settings from an input font.
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.
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.
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.
bool pdfLosslessImageCompression() const
Returns true if images embedded in pdf must be compressed using a lossless algorithm.
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 pdfExportMapThemes() const
Returns map themes for GeoPDF export.
bool pdfUseOgcBestPracticeFormatGeoreferencing() const
Returns true if OGC best practice georeferencing shall be used.
QStringList highlightLabelColor() const
Returns HIGHLIGHT_LABELCOLOR as a list of string.
bool pdfExportMetadata() const
Returns true if metadata shall be added to the pdf.
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.
bool pdfAppendGeoreference() const
Returns true if georeference info shall be added to the pdf.
int polygonToleranceAsInt() const
Returns FI_POLYGON_TOLERANCE parameter as an integer.
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.
bool pdfDisableTiledRasterRendering() const
Returns true if rasters shall be untiled in the pdf.
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.
bool pdfForceVectorOutput() const
Returns if pdf should be exported as vector.
bool pdfUseIso32000ExtensionFormatGeoreferencing() const
Returns true, if Iso32000 georeferencing shall be used.
QMap< QString, QString > dimensionValues() const
Returns the dimensions parameter.
QList< QgsWmsParametersExternalLayer > externalLayersParameters() const
Returns parameters for each external layer.
bool withDisplayName() const
withDisplayName
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.
Qgis::TextRenderFormat pdfTextRenderFormat() const
Returns text render format for pdf export.
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.
bool writeGeoPdf() const
Returns if a GeoPDF shall be exported.
Qgis::FeatureSymbologyExport dxfMode() const
Returns the DXF MODE parameter.
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.
bool addLayerGroups() const
Returns true if layer groups shall be added to GetLegendGraphic results.
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.
QVector< qreal > pdfPredefinedMapScales() const
Returns list of map scales.
QString showFeatureCount() const
Returns SHOWFEATURECOUNT parameter or an empty string if none is defined.
bool pdfSimplifyGeometries() const
Returns if geometries shall to be simplified.
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