QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
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 "qgsfontutils.h"
24
25#include <QRegularExpression>
26
27const QString EXTERNAL_LAYER_PREFIX = QStringLiteral( "EXTERNAL_WMS:" );
28
29namespace QgsWms
30{
31 //
32 // QgsWmsParameter
33 //
35 const QVariant::Type type,
36 const QVariant defaultValue )
37 : QgsServerParameterDefinition( type, defaultValue )
38 , mName( name )
39 {
40 }
41
46
48 {
49 const QString msg = QString( "%1 ('%2') cannot be converted into %3" ).arg( name( mName ), toString(), typeName() );
51 }
52
53 QStringList QgsWmsParameter::toStyleList( const char delimiter ) const
54 {
55 return QgsServerParameterDefinition::toStringList( delimiter, false );
56 }
57
58 QList<QgsGeometry> QgsWmsParameter::toGeomList( const char delimiter ) const
59 {
60 bool ok = true;
61 const QList<QgsGeometry> geoms = QgsServerParameterDefinition::toGeomList( ok, delimiter );
62
63 if ( !ok )
64 {
65 const QString msg = QString( "%1 ('%2') cannot be converted into a list of geometries" ).arg( name( mName ), toString() );
67 }
68
69 return geoms;
70 }
71
73 {
74 bool ok = true;
76
77 if ( !ok )
78 {
79 const QString msg = QString( "%1 ('%2') cannot be converted into a rectangle" ).arg( name( mName ), toString() );
81 }
82
83 return rect;
84 }
85
87 {
88 bool ok = false;
89 const int val = QgsServerParameterDefinition::toInt( ok );
90
91 if ( !ok )
92 {
93 raiseError();
94 }
95
96 return val;
97 }
98
100 {
101 // Check URL -- it will be used in error messages
102 const QUrl url = toUrl();
103
104 bool ok = false;
105 const QString content = QgsServerParameterDefinition::loadUrl( ok );
106
107 if ( !ok )
108 {
109 const QString msg = QString( "%1 request error for %2" ).arg( name( mName ), url.toString() );
111 }
112
113 return content;
114 }
115
117 {
118 bool ok = false;
119 const QUrl url = QgsServerParameterDefinition::toUrl( ok );
120
121 if ( !ok )
122 {
123 raiseError();
124 }
125
126 return url;
127 }
128
130 {
131 bool ok = false;
132 const QColor col = QgsServerParameterDefinition::toColor( ok );
133
134 if ( !ok )
135 {
136 raiseError();
137 }
138
139 return col;
140 }
141
142 QList<QColor> QgsWmsParameter::toColorList( const char delimiter ) const
143 {
144 bool ok = false;
145 const QList<QColor> vals = QgsServerParameterDefinition::toColorList( ok, delimiter );
146
147 if ( !ok )
148 {
149 const QString msg = QString( "%1 ('%2') cannot be converted into a list of colors" ).arg( name( mName ), toString() );
151 }
152
153 return vals;
154 }
155
156 QList<int> QgsWmsParameter::toIntList( const char delimiter ) const
157 {
158 bool ok = false;
159 const QList<int> vals = QgsServerParameterDefinition::toIntList( ok, delimiter );
160
161 if ( !ok )
162 {
163 const QString msg = QString( "%1 ('%2') cannot be converted into a list of int" ).arg( name( mName ), toString() );
165 }
166
167 return vals;
168 }
169
170 QList<double> QgsWmsParameter::toDoubleList( const char delimiter ) const
171 {
172 bool ok = false;
173 const QList<double> vals = QgsServerParameterDefinition::toDoubleList( ok, delimiter );
174
175 if ( !ok )
176 {
177 const QString msg = QString( "%1 ('%2') cannot be converted into a list of float" ).arg( name( mName ), toString() );
179 }
180
181 return vals;
182 }
183
185 {
186 bool ok = false;
187 const double val = QgsServerParameterDefinition::toDouble( ok );
188
189 if ( !ok )
190 {
191 raiseError();
192 }
193
194 return val;
195 }
196
197 QString QgsWmsParameter::name() const
198 {
200 }
201
203 {
204 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
205 return metaEnum.valueToKey( name );
206 }
207
209 {
210 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
211 return ( QgsWmsParameter::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
212 }
213
214 //
215 // QgsWmsParameters
216 //
219 {
220 // Available version number
221 mVersions.append( QgsProjectVersion( 1, 1, 1 ) );
222 mVersions.append( QgsProjectVersion( 1, 3, 0 ) );
223
224 // WMS parameters definition
226 QVariant::Int,
227 QVariant( 0 ) );
228 save( pQuality );
229
231 QVariant::Bool,
232 QVariant( false ) );
233 save( pTiled );
234
236 QVariant::Double,
237 QVariant( 2.0 ) );
238 save( pBoxSpace );
239
241 QVariant::Double,
242 QVariant( 2.0 ) );
243 save( pSymbSpace );
244
246 QVariant::Double,
247 QVariant( 3.0 ) );
248 save( pLayerSpace );
249
251 QVariant::Double,
252 QVariant( 3.0 ) );
253 save( pTitleSpace );
254
256 QVariant::Double,
257 QVariant( 4.0 ) );
258 save( pSymbHeight );
259
261 QVariant::Double,
262 QVariant( 7.0 ) );
263 save( pSymbWidth );
264
266 QVariant::Double,
267 QVariant( 2.0 ) );
268 save( pIcLabelSpace );
269
271 save( pItFontFamily );
272
274 QVariant::Bool,
275 QVariant( false ) );
276 save( pItFontBold );
277
279 QVariant::Bool,
280 QVariant( false ) );
281 save( pItFontItalic );
282
284 QVariant::Double,
285 QVariant( -1 ) );
286 save( pItFontSize );
287
289 QVariant::String,
290 QVariant( "black" ) );
291 save( pItFontColor );
292
293 const QgsWmsParameter pHighlightGeom( QgsWmsParameter::HIGHLIGHT_GEOM );
294 save( pHighlightGeom );
295
296 const QgsWmsParameter pShowFeatureCount( QgsWmsParameter::SHOWFEATURECOUNT,
297 QVariant::Bool,
298 QVariant( false ) );
299 save( pShowFeatureCount );
300
301 const QgsWmsParameter pHighlightSymbol( QgsWmsParameter::HIGHLIGHT_SYMBOL );
302 save( pHighlightSymbol );
303
305 save( pHighlightLabel );
306
308 QVariant::String,
309 QVariant( "black" ) );
310 save( pHighlightColor );
311
312 const QgsWmsParameter pHighlightFontSize( QgsWmsParameter::HIGHLIGHT_LABELSIZE );
313 save( pHighlightFontSize );
314
315 const QgsWmsParameter pHighlightFontWeight( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT );
316 save( pHighlightFontWeight );
317
319 save( pHighlightFont );
320
322 QVariant::String,
323 QVariant( "black" ) );
324 save( pHighlightBufferColor );
325
327 save( pHighlightBufferSize );
328
329 const QgsWmsParameter pLabelRotation( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, QVariant::Double );
330 save( pLabelRotation );
331
332 const QgsWmsParameter pLabelDistance( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, QVariant::Double );
333 save( pLabelDistance );
334
336 save( pLabelHali );
337
339 save( pLabelVali );
340
342 save( pCRS );
343
345 save( pSRS );
346
348 QVariant::String,
349 QVariant( "png" ) );
350 save( pFormat );
351
353 save( pInfoFormat );
354
356 QVariant::Int,
357 QVariant( -1 ) );
358 save( pI );
359
361 QVariant::Int,
362 QVariant( -1 ) );
363 save( pJ );
364
366 QVariant::Int,
367 QVariant( -1 ) );
368 save( pX );
369
371 QVariant::Int,
372 QVariant( -1 ) );
373 save( pY );
374
376 save( pRule );
377
379 QVariant::Bool,
380 QVariant( true ) );
381 save( pRuleLabel );
382
384 QVariant::Bool,
385 QVariant( false ) );
386 save( pShowRuleDetails );
387
389 QVariant::Double,
390 QVariant( -1 ) );
391 save( pScale );
392
394 QVariant::Int,
395 QVariant( 0 ) );
396 save( pHeight );
397
399 QVariant::Int,
400 QVariant( 0 ) );
401 save( pWidth );
402
404 QVariant::Int,
405 QVariant( 0 ) );
406 save( pSrcHeight );
407
409 QVariant::Int,
410 QVariant( 0 ) );
411 save( pSrcWidth );
412
414 save( pBbox );
415
417 save( pSld );
418
420 save( pSldBody );
421
423 save( pLayer );
424
426 save( pLayers );
427
429 save( pQueryLayers );
430
432 QVariant::Int,
433 QVariant( 1 ) );
434 save( pFeatureCount );
435
437 QVariant::Bool,
438 QVariant( true ) );
439 save( pLayerTitle );
440
442 save( pLayerFtFamily );
443
445 QVariant::Bool,
446 QVariant( false ) );
447 save( pLayerFtBold );
448
450 QVariant::Bool,
451 QVariant( false ) );
452 save( pLayerFtItalic );
453
455 QVariant::Double,
456 QVariant( -1 ) );
457 save( pLayerFtSize );
458
460 QVariant::String,
461 QVariant( "black" ) );
462 save( pLayerFtColor );
463
465 save( pStyle );
466
468 save( pStyles );
469
471 save( pOpacities );
472
474 save( pFilter );
475
477 save( pFilterGeom );
478
480 QVariant::Double,
481 QVariant( 0.0 ) );
482 save( pPolygTol );
483
485 QVariant::Double,
486 QVariant( 0.0 ) );
487 save( pLineTol );
488
490 QVariant::Double,
491 QVariant( 0.0 ) );
492 save( pPointTol );
493
495 save( pSelection );
496
498 QVariant::Int,
499 QVariant( -1 ) );
500 save( pWmsPrecision );
501
503 QVariant::Bool,
504 QVariant( false ) );
505 save( pTransparent );
506
508 QVariant::String,
509 QVariant( "white" ) );
510 save( pBgColor );
511
513 QVariant::Int,
514 QVariant( -1 ) );
515 save( pDpi );
516
518 save( pTemplate );
519
521 save( pExtent );
522
524 QVariant::Double,
525 QVariant( 0.0 ) );
526 save( pRotation );
527
529 QVariant::Double,
530 QVariant( 0.0 ) );
531 save( pGridX );
532
534 QVariant::Double,
535 QVariant( 0.0 ) );
536 save( pGridY );
537
539 QVariant::Bool,
540 QVariant( false ) );
541 save( pWithGeometry );
542
544 QVariant::String );
545 save( pWithMapTip );
546
548 QVariant::Bool,
549 QVariant( false ) );
550 save( pWithDisplayName );
551
553 save( pWmtver );
554
556 QVariant::StringList );
557 save( pAtlasPk );
558
560 QVariant::String );
561 save( pFormatOpts );
562
564 QVariant::Bool,
565 QVariant( false ) );
566 save( pAddLayerGroups );
567 }
568
571 {
572 load( parameters.urlQuery() );
573
574 auto it = mWmsParameters.constFind( QgsWmsParameter::SLD );
575 if ( it != mWmsParameters.constEnd() && !it->toString().isEmpty() )
576 {
577 const QString sldBody = it->loadUrl();
578 if ( !sldBody.isEmpty() )
579 {
581 }
582 }
583 }
584
586 {
587 return mWmsParameters.value( name );
588 }
589
590 void QgsWmsParameters::set( QgsWmsParameter::Name name, const QVariant &value )
591 {
592 auto it = mWmsParameters.find( name );
593 if ( it == mWmsParameters.end() )
594 {
595 it = mWmsParameters.insert( name, QgsWmsParameter() );
596 }
597
598 it->mValue = value;
599 }
600
601 bool QgsWmsParameters::loadParameter( const QString &key, const QString &value )
602 {
603 bool loaded = false;
604
605 const thread_local QRegularExpression composerParamRegExp( QStringLiteral( "^MAP\\d+:" ), QRegularExpression::CaseInsensitiveOption );
606 if ( key.contains( composerParamRegExp ) )
607 {
608 const int mapId = QStringView {key} .mid( 3, key.indexOf( ':' ) - 3 ).toInt();
609 const QString theKey = key.mid( key.indexOf( ':' ) + 1 );
610 const QgsWmsParameter::Name name = QgsWmsParameter::name( theKey );
611
612 if ( name >= 0 )
613 {
614 QgsWmsParameter param = mWmsParameters.value( name );
615 param.mValue = value;
616 param.mMapId = mapId;
617
618 if ( ! param.isValid() )
619 {
620 param.raiseError();
621 }
622
623 save( param, true ); // multi MAP parameters for composer
624 loaded = true;
625 }
626 }
627 else
628 {
630 if ( name >= 0 )
631 {
632 auto it = mWmsParameters.find( name );
633 if ( it == mWmsParameters.end() )
634 it = mWmsParameters.insert( name, QgsWmsParameter() );
635
636 it->mValue = value;
637 if ( !it->isValid() )
638 {
639 it->raiseError();
640 }
641
642 loaded = true;
643 }
644 else //maybe an external wms parameter?
645 {
646 int separator = key.indexOf( QLatin1Char( ':' ) );
647 if ( separator >= 1 )
648 {
649 QString id = key.left( separator );
650 QString param = key.right( key.length() - separator - 1 );
651 mExternalWMSParameters[id].insert( param, value );
652
653 loaded = true;
654 }
655 }
656 }
657
658 return loaded;
659 }
660
662 {
663 log( QStringLiteral( "WMS Request parameters:" ) );
664 for ( auto it = mWmsParameters.constBegin(); it != mWmsParameters.constEnd(); ++it )
665 {
666 const QString value = it->toString();
667
668 if ( ! value.isEmpty() )
669 {
670 QString name = QgsWmsParameter::name( it.key() );
671
672 if ( it->mMapId >= 0 )
673 {
674 name = QStringLiteral( "%1:%2" ).arg( QString::number( it->mMapId ), name );
675 }
676
677 log( QStringLiteral( " - %1 : %2" ).arg( name, value ) );
678 }
679 }
680
681 if ( !version().isEmpty() )
682 log( QStringLiteral( " - VERSION : %1" ).arg( version() ) );
683 }
684
685 void QgsWmsParameters::save( const QgsWmsParameter &parameter, bool multi )
686 {
687 if ( multi )
688 {
689 mWmsParameters.insert( parameter.mName, parameter );
690 }
691 else
692 {
693 mWmsParameters.replace( parameter.mName, parameter );
694 }
695 }
696
698 {
699 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_GEOM ).toStringList( ';' );
700 }
701
702 QList<QgsGeometry> QgsWmsParameters::highlightGeomAsGeom() const
703 {
704 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_GEOM ).toGeomList( ';' );
705 }
706
708 {
709 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_SYMBOL ).toStringList( ';' );
710 }
711
712 QString QgsWmsParameters::crs() const
713 {
714 QString rs;
715 const QString srs = mWmsParameters.value( QgsWmsParameter::SRS ).toString();
716 const QString crs = mWmsParameters.value( QgsWmsParameter::CRS ).toString();
717
718 // both SRS/CRS are supported but there's a priority according to the
719 // specified version when both are defined in the request
720 if ( !srs.isEmpty() && crs.isEmpty() )
721 rs = srs;
722 else if ( srs.isEmpty() && !crs.isEmpty() )
723 rs = crs;
724 else if ( !srs.isEmpty() && !crs.isEmpty() )
725 {
726 if ( versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) )
727 rs = crs;
728 else
729 rs = srs;
730 }
731
732 return rs;
733 }
734
736 {
737 return mWmsParameters.value( QgsWmsParameter::BBOX ).toString();
738 }
739
741 {
742 return mWmsParameters.value( QgsWmsParameter::BBOX ).toRectangle();
743 }
744
746 {
747 return mWmsParameters.value( QgsWmsParameter::HEIGHT ).toString();
748 }
749
751 {
752 return mWmsParameters.value( QgsWmsParameter::WIDTH ).toString();
753 }
754
756 {
757 return mWmsParameters.value( QgsWmsParameter::HEIGHT ).toInt();
758 }
759
761 {
762 return mWmsParameters.value( QgsWmsParameter::WIDTH ).toInt();
763 }
764
766 {
767 return mWmsParameters.value( QgsWmsParameter::SRCHEIGHT ).toString();
768 }
769
771 {
772 return mWmsParameters.value( QgsWmsParameter::SRCWIDTH ).toString();
773 }
774
776 {
777 return mWmsParameters.value( QgsWmsParameter::SRCHEIGHT ).toInt();
778 }
779
781 {
782 return mWmsParameters.value( QgsWmsParameter::SRCWIDTH ).toInt();
783 }
784
785 QString QgsWmsParameters::dpi() const
786 {
787 return mWmsParameters.value( QgsWmsParameter::DPI ).toString();
788 }
789
791 {
792 return mWmsParameters.value( QgsWmsParameter::DPI ).toDouble();
793 }
794
796 {
798
799 if ( QgsServerParameters::request().compare( QLatin1String( "GetProjectSettings" ), Qt::CaseInsensitive ) == 0 )
800 {
801 version = QStringLiteral( "1.3.0" );
802 }
803 else if ( version.isEmpty() )
804 {
805 if ( ! wmtver().isEmpty() )
806 {
807 version = wmtver();
808 }
809 else
810 {
811 version = QStringLiteral( "1.3.0" );
812 }
813 }
814 else if ( !mVersions.contains( QgsProjectVersion( version ) ) )
815 {
816 // WMS 1.3.0 specification: If a version lower than any of those
817 // known to the server is requested, then the server shall send the
818 // lowest version it supports.
819 if ( QgsProjectVersion( 1, 1, 1 ) > QgsProjectVersion( version ) )
820 {
821 version = QStringLiteral( "1.1.1" );
822 }
823 else
824 {
825 version = QStringLiteral( "1.3.0" );
826 }
827 }
828
829 return version;
830 }
831
833 {
834 QString req = QgsServerParameters::request();
835
836 if ( version().compare( QLatin1String( "1.1.1" ) ) == 0
837 && req.compare( QLatin1String( "capabilities" ), Qt::CaseInsensitive ) == 0 )
838 {
839 req = QStringLiteral( "GetCapabilities" );
840 }
841
842 return req;
843 }
844
849
850 bool QgsWmsParameters::versionIsValid( const QString version ) const
851 {
852 return mVersions.contains( QgsProjectVersion( version ) );
853 }
854
856 {
857 return mWmsParameters.value( QgsWmsParameter::FORMAT ).toString( true );
858 }
859
861 {
862 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::Format>() );
863 return metaEnum.valueToKey( format );
864 }
865
867 {
868 const QString fStr = formatAsString();
869
871 if ( fStr.compare( QLatin1String( "image/png" ), Qt::CaseInsensitive ) == 0 ||
872 fStr.compare( QLatin1String( "png" ), Qt::CaseInsensitive ) == 0 )
873 {
874 f = Format::PNG;
875 }
876 else if ( fStr.compare( QLatin1String( "jpg" ), Qt::CaseInsensitive ) == 0
877 || fStr.compare( QLatin1String( "jpeg" ), Qt::CaseInsensitive ) == 0
878 || fStr.compare( QLatin1String( "image/jpeg" ), Qt::CaseInsensitive ) == 0 )
879 {
880 f = Format::JPG;
881 }
882 else if ( fStr.compare( QLatin1String( "image/svg" ), Qt::CaseInsensitive ) == 0 ||
883 fStr.compare( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive ) == 0 ||
884 fStr.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 )
885 {
886 f = Format::SVG;
887 }
888 else if ( fStr.compare( QLatin1String( "application/pdf" ), Qt::CaseInsensitive ) == 0 ||
889 fStr.compare( QLatin1String( "pdf" ), Qt::CaseInsensitive ) == 0 )
890 {
891 f = Format::PDF;
892 }
893 else if ( fStr.compare( QLatin1String( "application/json" ), Qt::CaseInsensitive ) == 0 ||
894 fStr.compare( QLatin1String( "json" ), Qt::CaseInsensitive ) == 0 )
895 {
896 f = Format::JSON;
897 }
898 return f;
899 }
900
902 {
903 return mWmsParameters.value( QgsWmsParameter::INFO_FORMAT ).toString();
904 }
905
907 {
908 return infoFormat() == Format::PNG || infoFormat() == Format::JPG;
909 }
910
912 {
913 QString fStr = infoFormatAsString();
914
916 if ( fStr.isEmpty() )
917 return f;
918
919 if ( fStr.startsWith( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) )
920 f = Format::XML;
921 else if ( fStr.startsWith( QLatin1String( "text/html" ), Qt::CaseInsensitive ) )
922 f = Format::HTML;
923 else if ( fStr.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
924 f = Format::TEXT;
925 else if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml" ), Qt::CaseInsensitive ) )
926 f = Format::GML;
927 else if ( fStr.startsWith( QLatin1String( "application/json" ), Qt::CaseInsensitive )
928 || fStr.startsWith( QLatin1String( "application/geo+json" ), Qt::CaseInsensitive ) )
929 f = Format::JSON;
930 else
931 f = Format::NONE;
932
933 return f;
934 }
935
937 {
938 if ( infoFormat() != Format::GML )
939 return -1;
940
941 QString fStr = infoFormatAsString();
942 if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml/3" ), Qt::CaseInsensitive ) )
943 return 3;
944 else
945 return 2;
946 }
947
948 QString QgsWmsParameters::i() const
949 {
950 return mWmsParameters.value( QgsWmsParameter::I ).toString();
951 }
952
953 QString QgsWmsParameters::j() const
954 {
955 return mWmsParameters.value( QgsWmsParameter::J ).toString();
956 }
957
959 {
960 return mWmsParameters.value( QgsWmsParameter::I ).toInt();
961 }
962
964 {
965 return mWmsParameters.value( QgsWmsParameter::J ).toInt();
966 }
967
968 QString QgsWmsParameters::x() const
969 {
970 return mWmsParameters.value( QgsWmsParameter::X ).toString();
971 }
972
973 QString QgsWmsParameters::y() const
974 {
975 return mWmsParameters.value( QgsWmsParameter::Y ).toString();
976 }
977
979 {
980 return mWmsParameters.value( QgsWmsParameter::X ).toInt();
981 }
982
984 {
985 return mWmsParameters.value( QgsWmsParameter::Y ).toInt();
986 }
987
989 {
990 return mWmsParameters.value( QgsWmsParameter::RULE ).toString();
991 }
992
994 {
995 return mWmsParameters.value( QgsWmsParameter::SHOWRULEDETAILS ).toBool();
996 }
997
999 {
1000 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toString();
1001 }
1002
1004 {
1005 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toBool();
1006 }
1007
1009 {
1010 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toString();
1011 }
1012
1014 {
1015 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toBool();
1016 }
1017
1019 {
1020 return mWmsParameters.value( QgsWmsParameter::SCALE ).toString();
1021 }
1022
1024 {
1025 return mWmsParameters.value( QgsWmsParameter::SCALE ).toDouble();
1026 }
1027
1029 {
1030 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toString();
1031 }
1032
1034 {
1035 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toInt();
1036 }
1037
1039 {
1040 return mWmsParameters.value( QgsWmsParameter::TILED ).toString();
1041 }
1042
1044 {
1045 return mWmsParameters.value( QgsWmsParameter::TILED ).toBool();
1046 }
1047
1049 {
1050 return mWmsParameters.value( QgsWmsParameter::ADDLAYERGROUPS ).toBool();
1051 }
1052
1054 {
1055 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toString();
1056 }
1057
1059 {
1060 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toBool();
1061 }
1062
1064 {
1065 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toString();
1066 }
1067
1069 {
1070 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toInt();
1071 }
1072
1074 {
1075 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toString();
1076 }
1077
1079 {
1080 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toDouble();
1081 }
1082
1084 {
1085 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toString();
1086 }
1087
1089 {
1090 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toDouble();
1091 }
1092
1094 {
1095 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toString();
1096 }
1097
1099 {
1100 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toDouble();
1101 }
1102
1104 {
1105 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toString();
1106 }
1107
1109 {
1110 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toDouble();
1111 }
1112
1114 {
1115 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toString();
1116 }
1117
1119 {
1120 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toDouble();
1121 }
1122
1124 {
1125 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toString();
1126 }
1127
1129 {
1130 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toDouble();
1131 }
1132
1134 {
1135 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toString();
1136 }
1137
1139 {
1140 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toDouble();
1141 }
1142
1144 {
1145 return mWmsParameters.value( QgsWmsParameter::LAYERFONTFAMILY ).toString();
1146 }
1147
1149 {
1150 return mWmsParameters.value( QgsWmsParameter::ITEMFONTFAMILY ).toString();
1151 }
1152
1154 {
1155 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toString();
1156 }
1157
1159 {
1160 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toBool();
1161 }
1162
1164 {
1165 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toString();
1166 }
1167
1169 {
1170 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toString();
1171 }
1172
1174 {
1175 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toString();
1176 }
1177
1179 {
1180 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toString();
1181 }
1182
1184 {
1185 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toInt();
1186 }
1187
1189 {
1190 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toInt();
1191 }
1192
1194 {
1195 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toInt();
1196 }
1197
1199 {
1200 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toBool();
1201 }
1202
1204 {
1205 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toString();
1206 }
1207
1209 {
1210 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toBool();
1211 }
1212
1214 {
1215 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toString();
1216 }
1217
1219 {
1220 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toBool();
1221 }
1222
1224 {
1225 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toString();
1226 }
1227
1229 {
1230 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toDouble();
1231 }
1232
1234 {
1235 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toString();
1236 }
1237
1239 {
1240 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toColor();
1241 }
1242
1244 {
1245 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toString();
1246 }
1247
1249 {
1250 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toDouble();
1251 }
1252
1254 {
1255 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toString();
1256 }
1257
1259 {
1260 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toColor();
1261 }
1262
1264 {
1265 QFont font;
1266 font.fromString( "" );
1267 font.setBold( layerFontBoldAsBool() );
1268 font.setItalic( layerFontItalicAsBool() );
1269
1270 if ( ! layerFontSize().isEmpty() )
1271 font.setPointSizeF( layerFontSizeAsDouble() );
1272
1273 if ( !layerFontFamily().isEmpty() )
1275
1276 return font;
1277 }
1278
1280 {
1281 QFont font;
1282 font.fromString( "" );
1283
1284 font.setBold( itemFontBoldAsBool() );
1285 font.setItalic( itemFontItalicAsBool() );
1286
1287 if ( ! itemFontSize().isEmpty() )
1288 font.setPointSizeF( itemFontSizeAsDouble() );
1289
1290 if ( !itemFontFamily().isEmpty() )
1292
1293 return font;
1294 }
1295
1297 {
1298 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toString();
1299 }
1300
1302 {
1303 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toBool();
1304 }
1305
1307 {
1308 QgsLegendSettings settings;
1309 settings.setTitle( QString() );
1310 settings.setBoxSpace( boxSpaceAsDouble() );
1311 settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) );
1312
1315
1316 // text format must be set before setting the format's colors
1319
1320 if ( !itemFontColor().isEmpty() )
1321 {
1326 }
1327
1328 // Ok, this is tricky: because QgsLegendSettings's layerFontColor was added to the API after
1329 // fontColor, to fix regressions #21871 and #21870 and the previous behavior was to use fontColor
1330 // for the whole legend we need to preserve that behavior.
1331 // But, the 2.18 server parameters ITEMFONTCOLOR did not have effect on the layer titles too, so
1332 // we set explicitly layerFontColor to black if it's not overridden by LAYERFONTCOLOR argument.
1333 settings.rstyle( QgsLegendStyle::Group ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1334 settings.rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1335
1338
1339 return settings;
1340 }
1341
1342 QString QgsWmsParameters::layoutParameter( const QString &id, bool &ok ) const
1343 {
1344 QString label;
1345 ok = false;
1346
1347 if ( mUnmanagedParameters.contains( id.toUpper() ) )
1348 {
1349 label = mUnmanagedParameters[id.toUpper()];
1350 ok = true;
1351 }
1352
1353 return label;
1354 }
1355
1356 QStringList QgsWmsParameters::atlasPk() const
1357 {
1358 return mWmsParameters.value( QgsWmsParameter::ATLAS_PK ).toStringList();
1359 }
1360
1362 {
1363 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSTRING ).toStringList( ';' );
1364 }
1365
1367 {
1368 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toStringList( ';' );
1369 }
1370
1372 {
1373 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toIntList( ';' );
1374 }
1375
1377 {
1378 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toStringList( ';' );
1379 }
1380
1382 {
1383 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toColorList( ';' );
1384 }
1385
1387 {
1388 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toStringList( ';' );
1389 }
1390
1392 {
1393 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toIntList( ';' );
1394 }
1395
1397 {
1398 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELFONT ).toStringList( ';' );
1399 }
1400
1402 {
1403 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toStringList( ';' );
1404 }
1405
1407 {
1408 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toColorList( ';' );
1409 }
1410
1412 {
1413 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toStringList( ';' );
1414 }
1415
1417 {
1418 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toDoubleList( ';' );
1419 }
1420
1422 {
1423 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION ).toDoubleList( ';' );
1424 }
1425
1427 {
1428 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE ).toDoubleList( ';' );
1429 }
1430
1432 {
1433 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT ).toStringList( ';' );
1434 }
1435
1437 {
1438 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT ).toStringList( ';' );
1439 }
1440
1442 {
1443 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toString();
1444 }
1445
1447 {
1448 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toInt();
1449 }
1450
1452 {
1453 return mWmsParameters.value( QgsWmsParameter::SLD_BODY ).toString();
1454 }
1455
1456 QStringList QgsWmsParameters::filters() const
1457 {
1458 QStringList filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toOgcFilterList();
1459 if ( filters.isEmpty() )
1460 filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toExpressionList();
1461 return filters;
1462 }
1463
1465 {
1466 return mWmsParameters.value( QgsWmsParameter::FILTER_GEOM ).toString();
1467 }
1468
1470 {
1471 return mWmsParameters.value( QgsWmsParameter::SELECTION ).toStringList( ';' );
1472 }
1473
1475 {
1476 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toStringList();
1477 }
1478
1480 {
1481 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toIntList();
1482 }
1483
1485 {
1486 // We don't want duplicates but order does matter, so no QSet
1487 QStringList result;
1488
1489 // LAYER
1490 QList<QgsWmsParameter> cLayer { mWmsParameters.values( QgsWmsParameter::LAYER ) };
1491 // Sort by map id
1492 std::sort( cLayer.begin(), cLayer.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1493 for ( const QgsWmsParameter &param : std::as_const( cLayer ) )
1494 {
1495 const QStringList layersList { param.toStringList() };
1496 for ( const QString &layerName : std::as_const( layersList ) )
1497 {
1498 if ( ! result.contains( layerName ) )
1499 result.append( layerName );
1500 }
1501 }
1502
1503 // LAYERS
1504 QList<QgsWmsParameter> cLayers { mWmsParameters.values( QgsWmsParameter::LAYERS ) };
1505 // Sort by map id
1506 std::sort( cLayers.begin(), cLayers.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1507 for ( const QgsWmsParameter &param : std::as_const( cLayers ) )
1508 {
1509 const QStringList layersList { param.toStringList() };
1510 for ( const QString &layerName : std::as_const( layersList ) )
1511 {
1512 if ( ! result.contains( layerName ) )
1513 result.append( layerName );
1514 }
1515 }
1516 return result;
1517 }
1518
1520 {
1521 return mWmsParameters.value( QgsWmsParameter::QUERY_LAYERS ).toStringList();
1522 }
1523
1525 {
1526 QStringList style = mWmsParameters.value( QgsWmsParameter::STYLE ).toStyleList();
1527 const QStringList styles = mWmsParameters.value( QgsWmsParameter::STYLES ).toStyleList();
1528 return style << styles;
1529 }
1530
1531 QMultiMap<QString, QgsWmsParametersFilter> QgsWmsParameters::layerFilters( const QStringList &layers ) const
1532 {
1533 const QString nsWfs2 = QStringLiteral( "http://www.opengis.net/fes/2.0" );
1534 const QString prefixWfs2 = QStringLiteral( "<fes:" );
1535
1536 const QStringList rawFilters = filters();
1537 QMultiMap<QString, QgsWmsParametersFilter> filters;
1538 for ( int i = 0; i < rawFilters.size(); i++ )
1539 {
1540 const QString f = rawFilters[i];
1541 if ( f.startsWith( QLatin1Char( '<' ) ) \
1542 && f.endsWith( QLatin1String( "Filter>" ) ) \
1543 && i < layers.size() )
1544 {
1546 filter.mFilter = f;
1549
1550 if ( filter.mFilter.contains( nsWfs2 ) \
1551 || filter.mFilter.contains( prefixWfs2 ) )
1552 {
1554 }
1555
1556 filters.insert( layers[i], filter );
1557 }
1558 else if ( !f.isEmpty() )
1559 {
1560 // filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
1561 // several filters can be defined for one layer
1562 const int colonIndex = f.indexOf( ':' );
1563 if ( colonIndex != -1 )
1564 {
1565 const QString layers = f.section( ':', 0, 0 );
1566 const QString filter = f.section( ':', 1 );
1567 const QStringList layersList = layers.split( ',' );
1568 for ( const QString &layer : layersList )
1569 {
1570 QgsWmsParametersFilter parametersFilter;
1571 parametersFilter.mFilter = filter;
1572 parametersFilter.mType = QgsWmsParametersFilter::SQL;
1573 filters.insert( layer, parametersFilter );
1574 }
1575 }
1576 else
1577 {
1578 QString filterStr = mWmsParameters.value( QgsWmsParameter::FILTER ).toString();
1579 raiseError( QStringLiteral( "FILTER ('" ) + filterStr + QStringLiteral( "') is not properly formatted" ) );
1580 }
1581 }
1582 }
1583 return filters;
1584 }
1585
1587 {
1588 bool force2D = false;
1589 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1590
1591 if ( options.contains( DxfFormatOption::FORCE_2D ) )
1592 {
1593 force2D = QVariant( options[ DxfFormatOption::FORCE_2D ] ).toBool();
1594 }
1595
1596 return force2D;
1597 }
1598
1600 {
1601 bool noMText = false;
1602 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1603
1604 if ( options.contains( DxfFormatOption::NO_MTEXT ) )
1605 {
1606 noMText = QVariant( options[ DxfFormatOption::NO_MTEXT ] ).toBool();
1607 }
1608
1609 return noMText;
1610 }
1611
1612
1613 QList<QgsWmsParametersLayer> QgsWmsParameters::layersParameters() const
1614 {
1615 const QStringList layers = allLayersNickname();
1616 const QStringList styles = allStyles();
1617 const QStringList selection = selections();
1618 const QList<int> opacities = opacitiesAsInt();
1619 const QMultiMap<QString, QgsWmsParametersFilter> filters = layerFilters( layers );
1620
1621 // selection format: "LayerName:id0,id1;LayerName2:id0,id1;..."
1622 // several filters can be defined for one layer
1623 QMultiMap<QString, QString> layerSelections;
1624 for ( const QString &s : selection )
1625 {
1626 const QStringList splits = s.split( ':' );
1627 if ( splits.size() == 2 )
1628 {
1629 layerSelections.insert( splits[0], splits[1] );
1630 }
1631 else
1632 {
1633 QString selStr = mWmsParameters.value( QgsWmsParameter::SELECTION ).toString();
1634 raiseError( QStringLiteral( "SELECTION ('" ) + selStr + QStringLiteral( "') is not properly formatted" ) );
1635 }
1636 }
1637
1638 QList<QgsWmsParametersLayer> parameters;
1639 for ( int i = 0; i < layers.size(); i++ )
1640 {
1641 QString layer = layers[i];
1642
1644 param.mNickname = layer;
1645
1646 if ( i < opacities.count() )
1647 param.mOpacity = opacities[i];
1648
1649 if ( isExternalLayer( layer ) )
1650 {
1651 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1652 param.mNickname = extParam.mName;
1653 param.mExternalUri = extParam.mUri;
1654 }
1655 else
1656 {
1657 if ( i < styles.count() )
1658 param.mStyle = styles[i];
1659
1660 if ( filters.contains( layer ) )
1661 {
1662 auto it = filters.find( layer );
1663 while ( it != filters.end() && it.key() == layer )
1664 {
1665 param.mFilter.append( it.value() );
1666 ++it;
1667 }
1668 }
1669
1670 if ( layerSelections.contains( layer ) )
1671 {
1672 QMultiMap<QString, QString>::const_iterator it;
1673 it = layerSelections.constFind( layer );
1674 while ( it != layerSelections.constEnd() && it.key() == layer )
1675 {
1676 param.mSelection << it.value().split( ',' );
1677 ++it;
1678 }
1679 }
1680 }
1681
1682 parameters.append( param );
1683 }
1684
1685 return parameters;
1686 }
1687
1688 QList<QgsWmsParametersHighlightLayer> QgsWmsParameters::highlightLayersParameters() const
1689 {
1690 QList<QgsWmsParametersHighlightLayer> params;
1691 const QList<QgsGeometry> geoms = highlightGeomAsGeom();
1692 const QStringList slds = highlightSymbol();
1693 const QStringList labels = highlightLabelString();
1694 const QList<QColor> colors = highlightLabelColorAsColor();
1695 const QList<int> sizes = highlightLabelSizeAsInt();
1696 const QList<int> weights = highlightLabelWeightAsInt();
1697 const QStringList fonts = highlightLabelFont();
1698 const QList<QColor> bufferColors = highlightLabelBufferColorAsColor();
1699 const QList<double> bufferSizes = highlightLabelBufferSizeAsFloat();
1700 const QList<double> rotation = highlightLabelRotation();
1701 const QList<double> distance = highlightLabelDistance();
1702 const QStringList hali = highlightLabelHorizontalAlignment();
1703 const QStringList vali = highlightLabelVerticalAlignment();
1704
1705 int nLayers = std::min( geoms.size(), slds.size() );
1706 for ( int i = 0; i < nLayers; i++ )
1707 {
1709 param.mName = QStringLiteral( "highlight_" ) + QString::number( i );
1710 param.mGeom = geoms[i];
1711 param.mSld = slds[i];
1712
1713 if ( i < labels.count() )
1714 param.mLabel = labels[i];
1715
1716 if ( i < colors.count() )
1717 param.mColor = colors[i];
1718
1719 if ( i < sizes.count() )
1720 param.mSize = sizes[i];
1721
1722 if ( i < weights.count() )
1723 param.mWeight = weights[i];
1724
1725 if ( i < fonts.count() )
1726 param.mFont = fonts[ i ];
1727
1728 if ( i < bufferColors.count() )
1729 param.mBufferColor = bufferColors[i];
1730
1731 if ( i < bufferSizes.count() )
1732 param.mBufferSize = bufferSizes[i];
1733
1734 if ( i < rotation.count() )
1735 param.mLabelRotation = rotation[i];
1736
1737 if ( i < distance.count() )
1738 param.mLabelDistance = distance[i];
1739
1740 if ( i < hali.count() )
1741 param.mHali = hali[i];
1742
1743 if ( i < vali.count() )
1744 param.mVali = vali[i];
1745
1746
1747
1748 params.append( param );
1749 }
1750
1751 return params;
1752 }
1753
1754 QList<QgsWmsParametersExternalLayer> QgsWmsParameters::externalLayersParameters() const
1755 {
1756 auto notExternalLayer = []( const QString & name ) { return ! QgsWmsParameters::isExternalLayer( name ); };
1757
1758 QList<QgsWmsParametersExternalLayer> externalLayers;
1759
1760 QStringList layers = allLayersNickname();
1761 QStringList::iterator rit = std::remove_if( layers.begin(), layers.end(), notExternalLayer );
1762
1763 for ( QStringList::iterator it = layers.begin(); it != rit; ++it )
1764 {
1765 externalLayers << externalLayerParameter( *it );
1766 }
1767
1768 return externalLayers;
1769 }
1770
1772 {
1773 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toString();
1774 }
1775
1777 {
1778 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toColor();
1779 }
1780
1782 {
1783 return mWmsParameters.value( QgsWmsParameter::TEMPLATE ).toString();
1784 }
1785
1787 {
1788 QgsWmsParameter wmsParam;
1790 param.mId = mapId;
1791
1792 QString pMapId = QStringLiteral( "MAP" ) + QString::number( mapId );
1793
1794 wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1795 QgsRectangle extent;
1796 if ( wmsParam.isValid() )
1797 {
1798 extent = wmsParam.toRectangle();
1799 }
1800
1801 param.mHasExtent = !extent.isEmpty();
1802 param.mExtent = extent;
1803
1804 // scale
1805 wmsParam = idParameter( QgsWmsParameter::SCALE, mapId );
1806 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1807 {
1808 param.mScale = wmsParam.toDouble();
1809 }
1810
1811 // rotation
1812 wmsParam = idParameter( QgsWmsParameter::ROTATION, mapId );
1813 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1814 {
1815 param.mRotation = wmsParam.toDouble();
1816 }
1817
1818 //grid space x / y
1819 double gridx( -1 ), gridy( -1 );
1820
1821 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_X, mapId );
1822 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1823 {
1824 gridx = wmsParam.toDouble();
1825 }
1826
1827 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_Y, mapId );
1828 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1829 {
1830 gridy = wmsParam.toDouble();
1831 }
1832
1833 if ( gridx != -1 && gridy != -1 )
1834 {
1835 param.mGridX = gridx;
1836 param.mGridY = gridy;
1837 }
1838
1839 //layers
1840 QStringList allLayers;
1841 wmsParam = idParameter( QgsWmsParameter::LAYERS, mapId );
1842 if ( wmsParam.isValid() )
1843 {
1844 allLayers = wmsParam.toStringList();
1845 }
1846
1847 // external layers
1848 QStringList layers;
1849
1850 for ( const auto &layer : std::as_const( allLayers ) )
1851 {
1852 if ( isExternalLayer( layer ) )
1853 {
1854 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1855 layers << extParam.mName;
1856 }
1857 else
1858 {
1859 layers << layer;
1860 }
1861 }
1862
1863 QStringList styles;
1864 wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
1865 if ( wmsParam.isValid() )
1866 {
1867 styles = wmsParam.toStyleList();
1868 }
1869
1870 QList<QgsWmsParametersLayer> lParams;
1871 for ( int i = 0; i < layers.size(); i++ )
1872 {
1873 QString layer = layers[i];
1874 QgsWmsParametersLayer lParam;
1875 lParam.mNickname = layer;
1876
1877 if ( i < styles.count() )
1878 lParam.mStyle = styles[i];
1879
1880 lParams.append( lParam );
1881 }
1882 param.mLayers = lParams;
1883
1884 //highlight layers
1885 QList<QgsWmsParametersHighlightLayer> hParams;
1886
1887 QList<QgsGeometry> geoms;
1888 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_GEOM, mapId );
1889 if ( wmsParam.isValid() )
1890 {
1891 geoms = wmsParam.toGeomList( ';' );
1892 }
1893
1894 QStringList slds;
1895 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_SYMBOL, mapId );
1896 if ( wmsParam.isValid() )
1897 {
1898 slds = wmsParam.toStringList( ';' );
1899 }
1900
1901 QStringList labels;
1902 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSTRING, mapId );
1903 if ( wmsParam.isValid() )
1904 {
1905 labels = wmsParam.toStringList( ';' );
1906 }
1907
1908 QStringList fonts;
1909 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELFONT, mapId );
1910 if ( wmsParam.isValid() )
1911 {
1912 fonts = wmsParam.toStringList( ';' );
1913 }
1914
1915 QList<QColor> colors;
1916 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELCOLOR, mapId );
1917 if ( wmsParam.isValid() )
1918 {
1919 colors = wmsParam.toColorList( ';' );
1920 }
1921
1922 QList<int> sizes;
1923 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSIZE, mapId );
1924 if ( wmsParam.isValid() )
1925 {
1926 sizes = wmsParam.toIntList( ';' );
1927 }
1928
1929 QList<int> weights;
1930 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT, mapId );
1931 if ( wmsParam.isValid() )
1932 {
1933 weights = wmsParam.toIntList( ';' );
1934 }
1935
1936 QList<QColor> bufferColors;
1937 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR, mapId );
1938 if ( wmsParam.isValid() )
1939 {
1940 bufferColors = wmsParam.toColorList( ';' );
1941 }
1942
1943 QList<double> bufferSizes;
1944 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE, mapId );
1945 if ( wmsParam.isValid() )
1946 {
1947 bufferSizes = wmsParam.toDoubleList( ';' );
1948 }
1949
1950 QList<double> rotations;
1951 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, mapId );
1952 if ( wmsParam.isValid() )
1953 {
1954 rotations = wmsParam.toDoubleList( ';' );
1955 }
1956
1957 QList<double> distances;
1958 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, mapId );
1959 if ( wmsParam.isValid() )
1960 {
1961 distances = wmsParam.toDoubleList( ';' );
1962 }
1963
1964 QStringList halis;
1965 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT, mapId );
1966 if ( wmsParam.isValid() )
1967 {
1968 halis = wmsParam.toStringList();
1969 }
1970
1971 QStringList valis;
1972 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT, mapId );
1973 if ( wmsParam.isValid() )
1974 {
1975 valis = wmsParam.toStringList();
1976 }
1977
1978 int nHLayers = std::min( geoms.size(), slds.size() );
1979 for ( int i = 0; i < nHLayers; i++ )
1980 {
1982 hParam.mName = pMapId + QStringLiteral( "_highlight_" ) + QString::number( i );
1983 hParam.mGeom = geoms[i];
1984 hParam.mSld = slds[i];
1985
1986 if ( i < labels.count() )
1987 hParam.mLabel = labels[i];
1988
1989 if ( i < colors.count() )
1990 hParam.mColor = colors[i];
1991
1992 if ( i < sizes.count() )
1993 hParam.mSize = sizes[i];
1994
1995 if ( i < weights.count() )
1996 hParam.mWeight = weights[i];
1997
1998 if ( i < fonts.count() )
1999 hParam.mFont = fonts[ i ];
2000
2001 if ( i < bufferColors.count() )
2002 hParam.mBufferColor = bufferColors[i];
2003
2004 if ( i < bufferSizes.count() )
2005 hParam.mBufferSize = bufferSizes[i];
2006
2007 if ( i < rotations.count() )
2008 hParam.mLabelRotation = rotations[i];
2009
2010 if ( i < distances.count() )
2011 hParam.mLabelDistance = distances[i];
2012
2013 if ( i < halis.count() )
2014 hParam.mHali = halis[i];
2015
2016 if ( i < valis.count() )
2017 hParam.mVali = valis[i];
2018
2019 hParams.append( hParam );
2020 }
2021 param.mHighlightLayers = hParams;
2022
2023 return param;
2024 }
2025
2026 QString QgsWmsParameters::externalWMSUri( const QString &layerId ) const
2027 {
2028
2029 // Param names may be uppercased.
2030 QString id { layerId };
2031
2032 for ( auto it = mExternalWMSParameters.cbegin(); it != mExternalWMSParameters.cend(); ++it )
2033 {
2034 if ( it.key().compare( id, Qt::CaseSensitivity::CaseInsensitive ) == 0 )
2035 {
2036 id = it.key();
2037 break;
2038 }
2039 }
2040
2041 if ( !mExternalWMSParameters.contains( id ) )
2042 {
2043 return QString();
2044 }
2045
2046 QgsDataSourceUri wmsUri;
2047 const QMap<QString, QString> &paramMap = mExternalWMSParameters[ id ];
2048 QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin();
2049 for ( ; paramIt != paramMap.constEnd(); ++paramIt )
2050 {
2051 QString paramName = paramIt.key().toLower();
2052 if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) || paramName == QLatin1String( "opacities" ) )
2053 {
2054 const QStringList values = paramIt.value().split( ',' );
2055 for ( const QString &value : values )
2056 wmsUri.setParam( paramName, value );
2057 }
2058 else if ( paramName == QLatin1String( "ignorereportedlayerextents" ) )
2059 {
2060 wmsUri.setParam( QStringLiteral( "IgnoreReportedLayerExtents" ), paramIt.value() );
2061 }
2062 else if ( paramName == QLatin1String( "smoothpixmaptransform" ) )
2063 {
2064 wmsUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), paramIt.value() );
2065 }
2066 else if ( paramName == QLatin1String( "ignoregetmapurl" ) )
2067 {
2068 wmsUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), paramIt.value() );
2069 }
2070 else if ( paramName == QLatin1String( "ignoregetfeatureinfourl" ) )
2071 {
2072 wmsUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), paramIt.value() );
2073 }
2074 else if ( paramName == QLatin1String( "ignoreaxisorientation" ) )
2075 {
2076 wmsUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), paramIt.value() );
2077 }
2078 else if ( paramName == QLatin1String( "invertaxisorientation" ) )
2079 {
2080 wmsUri.setParam( QStringLiteral( "InvertAxisOrientation" ), paramIt.value() );
2081 }
2082 else if ( paramName == QLatin1String( "dpimode" ) )
2083 {
2084 wmsUri.setParam( QStringLiteral( "dpiMode" ), paramIt.value() );
2085 }
2086 else if ( paramName == QLatin1String( "stepwidth" ) )
2087 {
2088 wmsUri.setParam( QStringLiteral( "stepWidth" ), paramIt.value() );
2089 }
2090 else if ( paramName == QLatin1String( "stepheight" ) )
2091 {
2092 wmsUri.setParam( QStringLiteral( "stepHeight" ), paramIt.value() );
2093 }
2094 else
2095 {
2096 wmsUri.setParam( paramName, paramIt.value() );
2097 }
2098 }
2099 return wmsUri.encodedUri();
2100 }
2101
2103 {
2104 return mWmsParameters.value( QgsWmsParameter::WITH_GEOMETRY ).toBool();
2105 }
2106
2108 {
2109 return mWmsParameters.value( QgsWmsParameter::WITH_MAPTIP ).toString();
2110 }
2111
2113 {
2114 const QString mStr = withMapTipAsString();
2115
2116 if ( mStr.startsWith( QLatin1String( "true" ), Qt::CaseInsensitive ) ||
2117 mStr.startsWith( QLatin1String( "on" ), Qt::CaseInsensitive ) ||
2118 mStr.startsWith( QLatin1String( "yes" ), Qt::CaseInsensitive ) ||
2119 mStr.startsWith( QLatin1String( "1" ) ) )
2120 return true;
2121 else
2122 return false;
2123 }
2124
2126 {
2127 const QString mStr = withMapTipAsString();
2128
2129 if ( mStr.startsWith( QLatin1String( "html_fi_only_maptip" ), Qt::CaseInsensitive ) )
2130 return true;
2131 else
2132 return false;
2133 }
2134
2136 {
2137 return mWmsParameters.value( QgsWmsParameter::WITH_DISPLAY_NAME ).toBool();
2138 }
2139
2141 {
2142 return mWmsParameters.value( QgsWmsParameter::WMTVER ).toString();
2143 }
2144
2145 void QgsWmsParameters::log( const QString &msg ) const
2146 {
2147 QgsMessageLog::logMessage( msg, QStringLiteral( "Server" ), Qgis::MessageLevel::Info );
2148 }
2149
2150 void QgsWmsParameters::raiseError( const QString &msg ) const
2151 {
2153 }
2154
2155 QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
2156 {
2157 QgsWmsParameter p;
2158
2159 for ( const auto &param : mWmsParameters.values( name ) )
2160 {
2161 if ( param.mMapId == id )
2162 {
2163 p = param;
2164 }
2165 }
2166
2167 return p;
2168 }
2169
2170 QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
2171 {
2172 QgsWmsParametersExternalLayer param;
2173
2174 param.mName = name;
2175 param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
2176 param.mUri = externalWMSUri( param.mName );
2177
2178 return param;
2179 }
2180
2181 bool QgsWmsParameters::isExternalLayer( const QString &name )
2182 {
2183 return name.startsWith( EXTERNAL_LAYER_PREFIX );
2184 }
2185
2187 {
2188 QStringList attributes;
2189 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2190
2191 if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
2192 {
2193 attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
2194 }
2195
2196 return attributes;
2197 }
2198
2200 {
2201 bool use = false;
2202 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2203
2204 if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
2205 {
2206 use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
2207 }
2208
2209 return use;
2210 }
2211
2213 {
2214 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2215
2216 double scale = -1;
2217 if ( options.contains( DxfFormatOption::SCALE ) )
2218 {
2219 scale = options[ DxfFormatOption::SCALE ].toDouble();
2220 }
2221
2222 return scale;
2223 }
2224
2226 {
2227 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2228
2230
2231 if ( ! options.contains( DxfFormatOption::MODE ) )
2232 {
2233 return symbol;
2234 }
2235
2236 const QString mode = options[ DxfFormatOption::MODE ];
2237 if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
2238 {
2240 }
2241 else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
2242 {
2244 }
2245
2246 return symbol;
2247 }
2248
2250 {
2251 QString codec = QStringLiteral( "ISO-8859-1" );
2252
2253 if ( formatOptions<QgsWmsParameters::DxfFormatOption>().contains( DxfFormatOption::CODEC ) )
2254 {
2255 codec = formatOptions<QgsWmsParameters::DxfFormatOption>()[ DxfFormatOption::CODEC ];
2256 }
2257
2258 return codec;
2259 }
2260
2262 {
2263 bool geoPdf = false;
2264 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2265 if ( options.contains( PdfFormatOption::WRITE_GEO_PDF ) )
2266 {
2267 geoPdf = QVariant( options[PdfFormatOption::WRITE_GEO_PDF] ).toBool();
2268 }
2269 return geoPdf;
2270 }
2271
2273 {
2274 bool forceVector = false;
2275 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2276 if ( options.contains( PdfFormatOption::FORCE_VECTOR_OUTPUT ) )
2277 {
2278 forceVector = QVariant( options[PdfFormatOption::FORCE_VECTOR_OUTPUT] ).toBool();
2279 }
2280 return forceVector;
2281 }
2282
2284 {
2285 bool appendGeoref = true;
2286 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2287 if ( options.contains( PdfFormatOption::APPEND_GEOREFERENCE ) )
2288 {
2289 appendGeoref = QVariant( options[PdfFormatOption::APPEND_GEOREFERENCE] ).toBool();
2290 }
2291 return appendGeoref;
2292 }
2293
2295 {
2296 bool simplify = true;
2297 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2298 if ( options.contains( PdfFormatOption::SIMPLIFY_GEOMETRY ) )
2299 {
2300 simplify = QVariant( options[PdfFormatOption::SIMPLIFY_GEOMETRY] ).toBool();
2301 }
2302 return simplify;
2303 }
2304
2306 {
2307 bool exportMetadata = false;
2308 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2309 if ( options.contains( PdfFormatOption::EXPORT_METADATA ) )
2310 {
2311 exportMetadata = QVariant( options[PdfFormatOption::EXPORT_METADATA] ).toBool();
2312 }
2313 return exportMetadata;
2314 }
2315
2317 {
2319 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2320 if ( options.contains( PdfFormatOption::TEXT_RENDER_FORMAT ) )
2321 {
2322 if ( options[PdfFormatOption::TEXT_RENDER_FORMAT].compare( QStringLiteral( "AlwaysText" ), Qt::CaseInsensitive ) == 0 )
2323 {
2325 }
2326 }
2327 return format;
2328 }
2329
2331 {
2332 bool losslessCompression = false;
2333 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2334 if ( options.contains( PdfFormatOption::LOSSLESS_IMAGE_COMPRESSION ) )
2335 {
2336 losslessCompression = QVariant( options[PdfFormatOption::LOSSLESS_IMAGE_COMPRESSION] ).toBool();
2337 }
2338 return losslessCompression;
2339 }
2340
2342 {
2343 bool disableTiledRaster = false;
2344 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2345 if ( options.contains( PdfFormatOption::DISABLE_TILED_RASTER_RENDERING ) )
2346 {
2347 disableTiledRaster = QVariant( options[PdfFormatOption::DISABLE_TILED_RASTER_RENDERING] ).toBool();
2348 }
2349 return disableTiledRaster;
2350 }
2351
2353 {
2354 bool useIso32000 = true;
2355 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2357 {
2358 useIso32000 = QVariant( options[PdfFormatOption::USE_ISO_32000_EXTENSION_FORMAT_GEOREFERENCING] ).toBool();
2359 }
2360 return useIso32000;
2361 }
2362
2364 {
2365 bool useOgcGeoreferencing = false;
2366 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2368 {
2369 useOgcGeoreferencing = QVariant( options[PdfFormatOption::USE_OGC_BEST_PRACTICE_FORMAT_GEOREFERENCING] ).toBool();
2370 }
2371 return useOgcGeoreferencing;
2372 }
2373
2375 {
2376 QStringList themes;
2377 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2378 if ( options.contains( PdfFormatOption::EXPORT_THEMES ) )
2379 {
2380 themes = options[PdfFormatOption::EXPORT_THEMES].split( ',' );
2381 }
2382 return themes;
2383 }
2384
2386 {
2387 QVector<qreal> scales;
2388 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2389 if ( options.contains( PdfFormatOption::PREDEFINED_MAP_SCALES ) )
2390 {
2391 const QStringList scaleList = options[PdfFormatOption::PREDEFINED_MAP_SCALES].split( ',' );
2392 for ( const QString &it : std::as_const( scaleList ) )
2393 {
2394 bool ok = false;
2395 qreal scale = it.toDouble( &ok );
2396 if ( ok )
2397 {
2398 scales.append( scale );
2399 }
2400 }
2401 }
2402 return scales;
2403 }
2404
2405 QMap<QString, QString> QgsWmsParameters::dimensionValues() const
2406 {
2407 QMap<QString, QString> dimValues;
2408 const QMetaEnum pnMetaEnum( QMetaEnum::fromType<QgsMapLayerServerProperties::PredefinedWmsDimensionName>() );
2409 const QStringList unmanagedNames = mUnmanagedParameters.keys();
2410 for ( const QString &key : unmanagedNames )
2411 {
2412 if ( key.startsWith( QLatin1String( "DIM_" ) ) )
2413 {
2414 dimValues[key.mid( 4 )] = mUnmanagedParameters[key];
2415 }
2416 else if ( pnMetaEnum.keyToValue( key.toUpper().toStdString().c_str() ) != -1 )
2417 {
2418 dimValues[key] = mUnmanagedParameters[key];
2419 }
2420 }
2421 return dimValues;
2422 }
2423}
@ Info
Information message.
Definition qgis.h:100
TextRenderFormat
Flags which control how map layer renderers behave.
Definition qgis.h:2287
@ AlwaysOutlines
Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality...
@ AlwaysText
Always render text as text objects. While this mode preserves text objects as text for post-processin...
FeatureSymbologyExport
Options for exporting features considering their symbology.
Definition qgis.h:4415
@ PerFeature
Keeps the number of features and export symbology per feature.
@ PerSymbolLayer
Exports one feature per symbol layer (considering symbol levels)
@ 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.
static void setFontFamily(QFont &font, const QString &family)
Sets the family for a font object.
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.
@ Left
Left side.
@ Bottom
Bottom side.
@ Group
Legend group title.
@ Symbol
Symbol icon (excluding label)
@ 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.
bool isEmpty() const
Returns true if the rectangle has no area.
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.
bool htmlInfoOnlyMapTip() const
Returns true if only maptip information is requested for HTML feature info response.
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.
QString withMapTipAsString() const
withMapTipAsString
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.
bool showRuleDetailsAsBool() const
Returns SHOWRULEDETAILS as a bool.
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