QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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::Double,
385 QVariant( -1 ) );
386 save( pScale );
387
389 QVariant::Int,
390 QVariant( 0 ) );
391 save( pHeight );
392
394 QVariant::Int,
395 QVariant( 0 ) );
396 save( pWidth );
397
399 QVariant::Int,
400 QVariant( 0 ) );
401 save( pSrcHeight );
402
404 QVariant::Int,
405 QVariant( 0 ) );
406 save( pSrcWidth );
407
409 save( pBbox );
410
412 save( pSld );
413
415 save( pSldBody );
416
418 save( pLayer );
419
421 save( pLayers );
422
424 save( pQueryLayers );
425
427 QVariant::Int,
428 QVariant( 1 ) );
429 save( pFeatureCount );
430
432 QVariant::Bool,
433 QVariant( true ) );
434 save( pLayerTitle );
435
437 save( pLayerFtFamily );
438
440 QVariant::Bool,
441 QVariant( false ) );
442 save( pLayerFtBold );
443
445 QVariant::Bool,
446 QVariant( false ) );
447 save( pLayerFtItalic );
448
450 QVariant::Double,
451 QVariant( -1 ) );
452 save( pLayerFtSize );
453
455 QVariant::String,
456 QVariant( "black" ) );
457 save( pLayerFtColor );
458
460 save( pStyle );
461
463 save( pStyles );
464
466 save( pOpacities );
467
469 save( pFilter );
470
472 save( pFilterGeom );
473
475 QVariant::Double,
476 QVariant( 0.0 ) );
477 save( pPolygTol );
478
480 QVariant::Double,
481 QVariant( 0.0 ) );
482 save( pLineTol );
483
485 QVariant::Double,
486 QVariant( 0.0 ) );
487 save( pPointTol );
488
490 save( pSelection );
491
493 QVariant::Int,
494 QVariant( -1 ) );
495 save( pWmsPrecision );
496
498 QVariant::Bool,
499 QVariant( false ) );
500 save( pTransparent );
501
503 QVariant::String,
504 QVariant( "white" ) );
505 save( pBgColor );
506
508 QVariant::Int,
509 QVariant( -1 ) );
510 save( pDpi );
511
513 save( pTemplate );
514
516 save( pExtent );
517
519 QVariant::Double,
520 QVariant( 0.0 ) );
521 save( pRotation );
522
524 QVariant::Double,
525 QVariant( 0.0 ) );
526 save( pGridX );
527
529 QVariant::Double,
530 QVariant( 0.0 ) );
531 save( pGridY );
532
534 QVariant::Bool,
535 QVariant( false ) );
536 save( pWithGeometry );
537
539 QVariant::Bool,
540 QVariant( false ) );
541 save( pWithMapTip );
542
544 QVariant::Bool,
545 QVariant( false ) );
546 save( pWithDisplayName );
547
549 save( pWmtver );
550
552 QVariant::StringList );
553 save( pAtlasPk );
554
556 QVariant::String );
557 save( pFormatOpts );
558
560 QVariant::Bool,
561 QVariant( false ) );
562 save( pAddLayerGroups );
563 }
564
567 {
568 load( parameters.urlQuery() );
569
570 auto it = mWmsParameters.constFind( QgsWmsParameter::SLD );
571 if ( it != mWmsParameters.constEnd() && !it->toString().isEmpty() )
572 {
573 const QString sldBody = it->loadUrl();
574 if ( !sldBody.isEmpty() )
575 {
577 }
578 }
579 }
580
582 {
583 return mWmsParameters.value( name );
584 }
585
586 void QgsWmsParameters::set( QgsWmsParameter::Name name, const QVariant &value )
587 {
588 auto it = mWmsParameters.find( name );
589 if ( it == mWmsParameters.end() )
590 {
591 it = mWmsParameters.insert( name, QgsWmsParameter() );
592 }
593
594 it->mValue = value;
595 }
596
597 bool QgsWmsParameters::loadParameter( const QString &key, const QString &value )
598 {
599 bool loaded = false;
600
601 const thread_local QRegularExpression composerParamRegExp( QStringLiteral( "^MAP\\d+:" ), QRegularExpression::CaseInsensitiveOption );
602 if ( key.contains( composerParamRegExp ) )
603 {
604#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
605 const int mapId = key.midRef( 3, key.indexOf( ':' ) - 3 ).toInt();
606#else
607 const int mapId = QStringView {key}.mid( 3, key.indexOf( ':' ) - 3 ).toInt();
608#endif
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::RULELABEL ).toString();
996 }
997
999 {
1000 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toBool();
1001 }
1002
1004 {
1005 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toString();
1006 }
1007
1009 {
1010 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toBool();
1011 }
1012
1014 {
1015 return mWmsParameters.value( QgsWmsParameter::SCALE ).toString();
1016 }
1017
1019 {
1020 return mWmsParameters.value( QgsWmsParameter::SCALE ).toDouble();
1021 }
1022
1024 {
1025 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toString();
1026 }
1027
1029 {
1030 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toInt();
1031 }
1032
1034 {
1035 return mWmsParameters.value( QgsWmsParameter::TILED ).toString();
1036 }
1037
1039 {
1040 return mWmsParameters.value( QgsWmsParameter::TILED ).toBool();
1041 }
1042
1044 {
1045 return mWmsParameters.value( QgsWmsParameter::ADDLAYERGROUPS ).toBool();
1046 }
1047
1049 {
1050 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toString();
1051 }
1052
1054 {
1055 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toBool();
1056 }
1057
1059 {
1060 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toString();
1061 }
1062
1064 {
1065 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toInt();
1066 }
1067
1069 {
1070 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toString();
1071 }
1072
1074 {
1075 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toDouble();
1076 }
1077
1079 {
1080 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toString();
1081 }
1082
1084 {
1085 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toDouble();
1086 }
1087
1089 {
1090 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toString();
1091 }
1092
1094 {
1095 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toDouble();
1096 }
1097
1099 {
1100 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toString();
1101 }
1102
1104 {
1105 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toDouble();
1106 }
1107
1109 {
1110 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toString();
1111 }
1112
1114 {
1115 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toDouble();
1116 }
1117
1119 {
1120 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toString();
1121 }
1122
1124 {
1125 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toDouble();
1126 }
1127
1129 {
1130 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toString();
1131 }
1132
1134 {
1135 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toDouble();
1136 }
1137
1139 {
1140 return mWmsParameters.value( QgsWmsParameter::LAYERFONTFAMILY ).toString();
1141 }
1142
1144 {
1145 return mWmsParameters.value( QgsWmsParameter::ITEMFONTFAMILY ).toString();
1146 }
1147
1149 {
1150 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toString();
1151 }
1152
1154 {
1155 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toBool();
1156 }
1157
1159 {
1160 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toString();
1161 }
1162
1164 {
1165 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toString();
1166 }
1167
1169 {
1170 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toString();
1171 }
1172
1174 {
1175 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toString();
1176 }
1177
1179 {
1180 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toInt();
1181 }
1182
1184 {
1185 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toInt();
1186 }
1187
1189 {
1190 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toInt();
1191 }
1192
1194 {
1195 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toBool();
1196 }
1197
1199 {
1200 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toString();
1201 }
1202
1204 {
1205 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toBool();
1206 }
1207
1209 {
1210 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toString();
1211 }
1212
1214 {
1215 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toBool();
1216 }
1217
1219 {
1220 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toString();
1221 }
1222
1224 {
1225 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toDouble();
1226 }
1227
1229 {
1230 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toString();
1231 }
1232
1234 {
1235 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toColor();
1236 }
1237
1239 {
1240 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toString();
1241 }
1242
1244 {
1245 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toDouble();
1246 }
1247
1249 {
1250 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toString();
1251 }
1252
1254 {
1255 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toColor();
1256 }
1257
1259 {
1260 QFont font;
1261 font.fromString( "" );
1262 font.setBold( layerFontBoldAsBool() );
1263 font.setItalic( layerFontItalicAsBool() );
1264
1265 if ( ! layerFontSize().isEmpty() )
1266 font.setPointSizeF( layerFontSizeAsDouble() );
1267
1268 if ( !layerFontFamily().isEmpty() )
1270
1271 return font;
1272 }
1273
1275 {
1276 QFont font;
1277 font.fromString( "" );
1278
1279 font.setBold( itemFontBoldAsBool() );
1280 font.setItalic( itemFontItalicAsBool() );
1281
1282 if ( ! itemFontSize().isEmpty() )
1283 font.setPointSizeF( itemFontSizeAsDouble() );
1284
1285 if ( !itemFontFamily().isEmpty() )
1287
1288 return font;
1289 }
1290
1292 {
1293 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toString();
1294 }
1295
1297 {
1298 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toBool();
1299 }
1300
1302 {
1303 QgsLegendSettings settings;
1304 settings.setTitle( QString() );
1305 settings.setBoxSpace( boxSpaceAsDouble() );
1306 settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) );
1307
1310
1311 // text format must be set before setting the format's colors
1314
1315 if ( !itemFontColor().isEmpty() )
1316 {
1321 }
1322
1323 // Ok, this is tricky: because QgsLegendSettings's layerFontColor was added to the API after
1324 // fontColor, to fix regressions #21871 and #21870 and the previous behavior was to use fontColor
1325 // for the whole legend we need to preserve that behavior.
1326 // But, the 2.18 server parameters ITEMFONTCOLOR did not have effect on the layer titles too, so
1327 // we set explicitly layerFontColor to black if it's not overridden by LAYERFONTCOLOR argument.
1328 settings.rstyle( QgsLegendStyle::Group ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1329 settings.rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1330
1333
1334 return settings;
1335 }
1336
1337 QString QgsWmsParameters::layoutParameter( const QString &id, bool &ok ) const
1338 {
1339 QString label;
1340 ok = false;
1341
1342 if ( mUnmanagedParameters.contains( id.toUpper() ) )
1343 {
1344 label = mUnmanagedParameters[id.toUpper()];
1345 ok = true;
1346 }
1347
1348 return label;
1349 }
1350
1351 QStringList QgsWmsParameters::atlasPk() const
1352 {
1353 return mWmsParameters.value( QgsWmsParameter::ATLAS_PK ).toStringList();
1354 }
1355
1357 {
1358 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSTRING ).toStringList( ';' );
1359 }
1360
1362 {
1363 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toStringList( ';' );
1364 }
1365
1367 {
1368 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toIntList( ';' );
1369 }
1370
1372 {
1373 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toStringList( ';' );
1374 }
1375
1377 {
1378 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toColorList( ';' );
1379 }
1380
1382 {
1383 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toStringList( ';' );
1384 }
1385
1387 {
1388 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toIntList( ';' );
1389 }
1390
1392 {
1393 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELFONT ).toStringList( ';' );
1394 }
1395
1397 {
1398 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toStringList( ';' );
1399 }
1400
1402 {
1403 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toColorList( ';' );
1404 }
1405
1407 {
1408 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toStringList( ';' );
1409 }
1410
1412 {
1413 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toDoubleList( ';' );
1414 }
1415
1417 {
1418 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION ).toDoubleList( ';' );
1419 }
1420
1422 {
1423 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE ).toDoubleList( ';' );
1424 }
1425
1427 {
1428 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT ).toStringList( ';' );
1429 }
1430
1432 {
1433 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT ).toStringList( ';' );
1434 }
1435
1437 {
1438 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toString();
1439 }
1440
1442 {
1443 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toInt();
1444 }
1445
1447 {
1448 return mWmsParameters.value( QgsWmsParameter::SLD_BODY ).toString();
1449 }
1450
1451 QStringList QgsWmsParameters::filters() const
1452 {
1453 QStringList filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toOgcFilterList();
1454 if ( filters.isEmpty() )
1455 filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toExpressionList();
1456 return filters;
1457 }
1458
1460 {
1461 return mWmsParameters.value( QgsWmsParameter::FILTER_GEOM ).toString();
1462 }
1463
1465 {
1466 return mWmsParameters.value( QgsWmsParameter::SELECTION ).toStringList( ';' );
1467 }
1468
1470 {
1471 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toStringList();
1472 }
1473
1475 {
1476 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toIntList();
1477 }
1478
1480 {
1481 // We don't want duplicates but order does matter, so no QSet
1482 QStringList result;
1483
1484 // LAYER
1485 QList<QgsWmsParameter> cLayer { mWmsParameters.values( QgsWmsParameter::LAYER ) };
1486 // Sort by map id
1487 std::sort( cLayer.begin(), cLayer.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1488 for ( const QgsWmsParameter &param : std::as_const( cLayer ) )
1489 {
1490 const QStringList layersList { param.toStringList() };
1491 for ( const QString &layerName : std::as_const( layersList ) )
1492 {
1493 if ( ! result.contains( layerName ) )
1494 result.append( layerName );
1495 }
1496 }
1497
1498 // LAYERS
1499 QList<QgsWmsParameter> cLayers { mWmsParameters.values( QgsWmsParameter::LAYERS ) };
1500 // Sort by map id
1501 std::sort( cLayers.begin(), cLayers.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1502 for ( const QgsWmsParameter &param : std::as_const( cLayers ) )
1503 {
1504 const QStringList layersList { param.toStringList() };
1505 for ( const QString &layerName : std::as_const( layersList ) )
1506 {
1507 if ( ! result.contains( layerName ) )
1508 result.append( layerName );
1509 }
1510 }
1511 return result;
1512 }
1513
1515 {
1516 return mWmsParameters.value( QgsWmsParameter::QUERY_LAYERS ).toStringList();
1517 }
1518
1520 {
1521 QStringList style = mWmsParameters.value( QgsWmsParameter::STYLE ).toStyleList();
1522 const QStringList styles = mWmsParameters.value( QgsWmsParameter::STYLES ).toStyleList();
1523 return style << styles;
1524 }
1525
1526 QMultiMap<QString, QgsWmsParametersFilter> QgsWmsParameters::layerFilters( const QStringList &layers ) const
1527 {
1528 const QString nsWfs2 = QStringLiteral( "http://www.opengis.net/fes/2.0" );
1529 const QString prefixWfs2 = QStringLiteral( "<fes:" );
1530
1531 const QStringList rawFilters = filters();
1532 QMultiMap<QString, QgsWmsParametersFilter> filters;
1533 for ( int i = 0; i < rawFilters.size(); i++ )
1534 {
1535 const QString f = rawFilters[i];
1536 if ( f.startsWith( QLatin1Char( '<' ) ) \
1537 && f.endsWith( QLatin1String( "Filter>" ) ) \
1538 && i < layers.size() )
1539 {
1541 filter.mFilter = f;
1544
1545 if ( filter.mFilter.contains( nsWfs2 ) \
1546 || filter.mFilter.contains( prefixWfs2 ) )
1547 {
1549 }
1550
1551 filters.insert( layers[i], filter );
1552 }
1553 else if ( !f.isEmpty() )
1554 {
1555 // filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
1556 // several filters can be defined for one layer
1557 const int colonIndex = f.indexOf( ':' );
1558 if ( colonIndex != -1 )
1559 {
1560 const QString layers = f.section( ':', 0, 0 );
1561 const QString filter = f.section( ':', 1 );
1562 const QStringList layersList = layers.split( ',' );
1563 for ( const QString &layer : layersList )
1564 {
1565 QgsWmsParametersFilter parametersFilter;
1566 parametersFilter.mFilter = filter;
1567 parametersFilter.mType = QgsWmsParametersFilter::SQL;
1568 filters.insert( layer, parametersFilter );
1569 }
1570 }
1571 else
1572 {
1573 QString filterStr = mWmsParameters.value( QgsWmsParameter::FILTER ).toString();
1574 raiseError( QStringLiteral( "FILTER ('" ) + filterStr + QStringLiteral( "') is not properly formatted" ) );
1575 }
1576 }
1577 }
1578 return filters;
1579 }
1580
1582 {
1583 bool force2D = false;
1584 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1585
1586 if ( options.contains( DxfFormatOption::FORCE_2D ) )
1587 {
1588 force2D = QVariant( options[ DxfFormatOption::FORCE_2D ] ).toBool();
1589 }
1590
1591 return force2D;
1592 }
1593
1595 {
1596 bool noMText = false;
1597 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1598
1599 if ( options.contains( DxfFormatOption::NO_MTEXT ) )
1600 {
1601 noMText = QVariant( options[ DxfFormatOption::NO_MTEXT ] ).toBool();
1602 }
1603
1604 return noMText;
1605 }
1606
1607
1608 QList<QgsWmsParametersLayer> QgsWmsParameters::layersParameters() const
1609 {
1610 const QStringList layers = allLayersNickname();
1611 const QStringList styles = allStyles();
1612 const QStringList selection = selections();
1613 const QList<int> opacities = opacitiesAsInt();
1614 const QMultiMap<QString, QgsWmsParametersFilter> filters = layerFilters( layers );
1615
1616 // selection format: "LayerName:id0,id1;LayerName2:id0,id1;..."
1617 // several filters can be defined for one layer
1618 QMultiMap<QString, QString> layerSelections;
1619 for ( const QString &s : selection )
1620 {
1621 const QStringList splits = s.split( ':' );
1622 if ( splits.size() == 2 )
1623 {
1624 layerSelections.insert( splits[0], splits[1] );
1625 }
1626 else
1627 {
1628 QString selStr = mWmsParameters.value( QgsWmsParameter::SELECTION ).toString();
1629 raiseError( QStringLiteral( "SELECTION ('" ) + selStr + QStringLiteral( "') is not properly formatted" ) );
1630 }
1631 }
1632
1633 QList<QgsWmsParametersLayer> parameters;
1634 for ( int i = 0; i < layers.size(); i++ )
1635 {
1636 QString layer = layers[i];
1637
1639 param.mNickname = layer;
1640
1641 if ( i < opacities.count() )
1642 param.mOpacity = opacities[i];
1643
1644 if ( isExternalLayer( layer ) )
1645 {
1646 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1647 param.mNickname = extParam.mName;
1648 param.mExternalUri = extParam.mUri;
1649 }
1650 else
1651 {
1652 if ( i < styles.count() )
1653 param.mStyle = styles[i];
1654
1655 if ( filters.contains( layer ) )
1656 {
1657 auto it = filters.find( layer );
1658 while ( it != filters.end() && it.key() == layer )
1659 {
1660 param.mFilter.append( it.value() );
1661 ++it;
1662 }
1663 }
1664
1665 if ( layerSelections.contains( layer ) )
1666 {
1667 QMultiMap<QString, QString>::const_iterator it;
1668 it = layerSelections.constFind( layer );
1669 while ( it != layerSelections.constEnd() && it.key() == layer )
1670 {
1671 param.mSelection << it.value().split( ',' );
1672 ++it;
1673 }
1674 }
1675 }
1676
1677 parameters.append( param );
1678 }
1679
1680 return parameters;
1681 }
1682
1683 QList<QgsWmsParametersHighlightLayer> QgsWmsParameters::highlightLayersParameters() const
1684 {
1685 QList<QgsWmsParametersHighlightLayer> params;
1686 const QList<QgsGeometry> geoms = highlightGeomAsGeom();
1687 const QStringList slds = highlightSymbol();
1688 const QStringList labels = highlightLabelString();
1689 const QList<QColor> colors = highlightLabelColorAsColor();
1690 const QList<int> sizes = highlightLabelSizeAsInt();
1691 const QList<int> weights = highlightLabelWeightAsInt();
1692 const QStringList fonts = highlightLabelFont();
1693 const QList<QColor> bufferColors = highlightLabelBufferColorAsColor();
1694 const QList<double> bufferSizes = highlightLabelBufferSizeAsFloat();
1695 const QList<double> rotation = highlightLabelRotation();
1696 const QList<double> distance = highlightLabelDistance();
1697 const QStringList hali = highlightLabelHorizontalAlignment();
1698 const QStringList vali = highlightLabelVerticalAlignment();
1699
1700 int nLayers = std::min( geoms.size(), slds.size() );
1701 for ( int i = 0; i < nLayers; i++ )
1702 {
1704 param.mName = QStringLiteral( "highlight_" ) + QString::number( i );
1705 param.mGeom = geoms[i];
1706 param.mSld = slds[i];
1707
1708 if ( i < labels.count() )
1709 param.mLabel = labels[i];
1710
1711 if ( i < colors.count() )
1712 param.mColor = colors[i];
1713
1714 if ( i < sizes.count() )
1715 param.mSize = sizes[i];
1716
1717 if ( i < weights.count() )
1718 param.mWeight = weights[i];
1719
1720 if ( i < fonts.count() )
1721 param.mFont = fonts[ i ];
1722
1723 if ( i < bufferColors.count() )
1724 param.mBufferColor = bufferColors[i];
1725
1726 if ( i < bufferSizes.count() )
1727 param.mBufferSize = bufferSizes[i];
1728
1729 if ( i < rotation.count() )
1730 param.mLabelRotation = rotation[i];
1731
1732 if ( i < distance.count() )
1733 param.mLabelDistance = distance[i];
1734
1735 if ( i < hali.count() )
1736 param.mHali = hali[i];
1737
1738 if ( i < vali.count() )
1739 param.mVali = vali[i];
1740
1741
1742
1743 params.append( param );
1744 }
1745
1746 return params;
1747 }
1748
1749 QList<QgsWmsParametersExternalLayer> QgsWmsParameters::externalLayersParameters() const
1750 {
1751 auto notExternalLayer = []( const QString & name ) { return ! QgsWmsParameters::isExternalLayer( name ); };
1752
1753 QList<QgsWmsParametersExternalLayer> externalLayers;
1754
1755 QStringList layers = allLayersNickname();
1756 QStringList::iterator rit = std::remove_if( layers.begin(), layers.end(), notExternalLayer );
1757
1758 for ( QStringList::iterator it = layers.begin(); it != rit; ++it )
1759 {
1760 externalLayers << externalLayerParameter( *it );
1761 }
1762
1763 return externalLayers;
1764 }
1765
1767 {
1768 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toString();
1769 }
1770
1772 {
1773 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toColor();
1774 }
1775
1777 {
1778 return mWmsParameters.value( QgsWmsParameter::TEMPLATE ).toString();
1779 }
1780
1782 {
1783 QgsWmsParameter wmsParam;
1785 param.mId = mapId;
1786
1787 QString pMapId = QStringLiteral( "MAP" ) + QString::number( mapId );
1788
1789 wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1790 QgsRectangle extent;
1791 if ( wmsParam.isValid() )
1792 {
1793 extent = wmsParam.toRectangle();
1794 }
1795
1796 param.mHasExtent = !extent.isEmpty();
1797 param.mExtent = extent;
1798
1799 // scale
1800 wmsParam = idParameter( QgsWmsParameter::SCALE, mapId );
1801 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1802 {
1803 param.mScale = wmsParam.toDouble();
1804 }
1805
1806 // rotation
1807 wmsParam = idParameter( QgsWmsParameter::ROTATION, mapId );
1808 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1809 {
1810 param.mRotation = wmsParam.toDouble();
1811 }
1812
1813 //grid space x / y
1814 double gridx( -1 ), gridy( -1 );
1815
1816 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_X, mapId );
1817 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1818 {
1819 gridx = wmsParam.toDouble();
1820 }
1821
1822 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_Y, mapId );
1823 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1824 {
1825 gridy = wmsParam.toDouble();
1826 }
1827
1828 if ( gridx != -1 && gridy != -1 )
1829 {
1830 param.mGridX = gridx;
1831 param.mGridY = gridy;
1832 }
1833
1834 //layers
1835 QStringList allLayers;
1836 wmsParam = idParameter( QgsWmsParameter::LAYERS, mapId );
1837 if ( wmsParam.isValid() )
1838 {
1839 allLayers = wmsParam.toStringList();
1840 }
1841
1842 // external layers
1843 QStringList layers;
1844
1845 for ( const auto &layer : std::as_const( allLayers ) )
1846 {
1847 if ( isExternalLayer( layer ) )
1848 {
1849 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1850 layers << extParam.mName;
1851 }
1852 else
1853 {
1854 layers << layer;
1855 }
1856 }
1857
1858 QStringList styles;
1859 wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
1860 if ( wmsParam.isValid() )
1861 {
1862 styles = wmsParam.toStyleList();
1863 }
1864
1865 QList<QgsWmsParametersLayer> lParams;
1866 for ( int i = 0; i < layers.size(); i++ )
1867 {
1868 QString layer = layers[i];
1869 QgsWmsParametersLayer lParam;
1870 lParam.mNickname = layer;
1871
1872 if ( i < styles.count() )
1873 lParam.mStyle = styles[i];
1874
1875 lParams.append( lParam );
1876 }
1877 param.mLayers = lParams;
1878
1879 //highlight layers
1880 QList<QgsWmsParametersHighlightLayer> hParams;
1881
1882 QList<QgsGeometry> geoms;
1883 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_GEOM, mapId );
1884 if ( wmsParam.isValid() )
1885 {
1886 geoms = wmsParam.toGeomList( ';' );
1887 }
1888
1889 QStringList slds;
1890 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_SYMBOL, mapId );
1891 if ( wmsParam.isValid() )
1892 {
1893 slds = wmsParam.toStringList( ';' );
1894 }
1895
1896 QStringList labels;
1897 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSTRING, mapId );
1898 if ( wmsParam.isValid() )
1899 {
1900 labels = wmsParam.toStringList( ';' );
1901 }
1902
1903 QStringList fonts;
1904 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELFONT, mapId );
1905 if ( wmsParam.isValid() )
1906 {
1907 fonts = wmsParam.toStringList( ';' );
1908 }
1909
1910 QList<QColor> colors;
1911 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELCOLOR, mapId );
1912 if ( wmsParam.isValid() )
1913 {
1914 colors = wmsParam.toColorList( ';' );
1915 }
1916
1917 QList<int> sizes;
1918 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSIZE, mapId );
1919 if ( wmsParam.isValid() )
1920 {
1921 sizes = wmsParam.toIntList( ';' );
1922 }
1923
1924 QList<int> weights;
1925 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT, mapId );
1926 if ( wmsParam.isValid() )
1927 {
1928 weights = wmsParam.toIntList( ';' );
1929 }
1930
1931 QList<QColor> bufferColors;
1932 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR, mapId );
1933 if ( wmsParam.isValid() )
1934 {
1935 bufferColors = wmsParam.toColorList( ';' );
1936 }
1937
1938 QList<double> bufferSizes;
1939 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE, mapId );
1940 if ( wmsParam.isValid() )
1941 {
1942 bufferSizes = wmsParam.toDoubleList( ';' );
1943 }
1944
1945 QList<double> rotations;
1946 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, mapId );
1947 if ( wmsParam.isValid() )
1948 {
1949 rotations = wmsParam.toDoubleList( ';' );
1950 }
1951
1952 QList<double> distances;
1953 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, mapId );
1954 if ( wmsParam.isValid() )
1955 {
1956 distances = wmsParam.toDoubleList( ';' );
1957 }
1958
1959 QStringList halis;
1960 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT, mapId );
1961 if ( wmsParam.isValid() )
1962 {
1963 halis = wmsParam.toStringList();
1964 }
1965
1966 QStringList valis;
1967 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT, mapId );
1968 if ( wmsParam.isValid() )
1969 {
1970 valis = wmsParam.toStringList();
1971 }
1972
1973 int nHLayers = std::min( geoms.size(), slds.size() );
1974 for ( int i = 0; i < nHLayers; i++ )
1975 {
1977 hParam.mName = pMapId + QStringLiteral( "_highlight_" ) + QString::number( i );
1978 hParam.mGeom = geoms[i];
1979 hParam.mSld = slds[i];
1980
1981 if ( i < labels.count() )
1982 hParam.mLabel = labels[i];
1983
1984 if ( i < colors.count() )
1985 hParam.mColor = colors[i];
1986
1987 if ( i < sizes.count() )
1988 hParam.mSize = sizes[i];
1989
1990 if ( i < weights.count() )
1991 hParam.mWeight = weights[i];
1992
1993 if ( i < fonts.count() )
1994 hParam.mFont = fonts[ i ];
1995
1996 if ( i < bufferColors.count() )
1997 hParam.mBufferColor = bufferColors[i];
1998
1999 if ( i < bufferSizes.count() )
2000 hParam.mBufferSize = bufferSizes[i];
2001
2002 if ( i < rotations.count() )
2003 hParam.mLabelRotation = rotations[i];
2004
2005 if ( i < distances.count() )
2006 hParam.mLabelDistance = distances[i];
2007
2008 if ( i < halis.count() )
2009 hParam.mHali = halis[i];
2010
2011 if ( i < valis.count() )
2012 hParam.mVali = valis[i];
2013
2014 hParams.append( hParam );
2015 }
2016 param.mHighlightLayers = hParams;
2017
2018 return param;
2019 }
2020
2021 QString QgsWmsParameters::externalWMSUri( const QString &layerId ) const
2022 {
2023
2024 // Param names may be uppercased.
2025 QString id { layerId };
2026
2027 for ( auto it = mExternalWMSParameters.cbegin(); it != mExternalWMSParameters.cend(); ++it )
2028 {
2029 if ( it.key().compare( id, Qt::CaseSensitivity::CaseInsensitive ) == 0 )
2030 {
2031 id = it.key();
2032 break;
2033 }
2034 }
2035
2036 if ( !mExternalWMSParameters.contains( id ) )
2037 {
2038 return QString();
2039 }
2040
2041 QgsDataSourceUri wmsUri;
2042 const QMap<QString, QString> &paramMap = mExternalWMSParameters[ id ];
2043 QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin();
2044 for ( ; paramIt != paramMap.constEnd(); ++paramIt )
2045 {
2046 QString paramName = paramIt.key().toLower();
2047 if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) || paramName == QLatin1String( "opacities" ) )
2048 {
2049 const QStringList values = paramIt.value().split( ',' );
2050 for ( const QString &value : values )
2051 wmsUri.setParam( paramName, value );
2052 }
2053 else if ( paramName == QLatin1String( "ignorereportedlayerextents" ) )
2054 {
2055 wmsUri.setParam( QStringLiteral( "IgnoreReportedLayerExtents" ), paramIt.value() );
2056 }
2057 else if ( paramName == QLatin1String( "smoothpixmaptransform" ) )
2058 {
2059 wmsUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), paramIt.value() );
2060 }
2061 else if ( paramName == QLatin1String( "ignoregetmapurl" ) )
2062 {
2063 wmsUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), paramIt.value() );
2064 }
2065 else if ( paramName == QLatin1String( "ignoregetfeatureinfourl" ) )
2066 {
2067 wmsUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), paramIt.value() );
2068 }
2069 else if ( paramName == QLatin1String( "ignoreaxisorientation" ) )
2070 {
2071 wmsUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), paramIt.value() );
2072 }
2073 else if ( paramName == QLatin1String( "invertaxisorientation" ) )
2074 {
2075 wmsUri.setParam( QStringLiteral( "InvertAxisOrientation" ), paramIt.value() );
2076 }
2077 else if ( paramName == QLatin1String( "dpimode" ) )
2078 {
2079 wmsUri.setParam( QStringLiteral( "dpiMode" ), paramIt.value() );
2080 }
2081 else if ( paramName == QLatin1String( "stepwidth" ) )
2082 {
2083 wmsUri.setParam( QStringLiteral( "stepWidth" ), paramIt.value() );
2084 }
2085 else if ( paramName == QLatin1String( "stepheight" ) )
2086 {
2087 wmsUri.setParam( QStringLiteral( "stepHeight" ), paramIt.value() );
2088 }
2089 else
2090 {
2091 wmsUri.setParam( paramName, paramIt.value() );
2092 }
2093 }
2094 return wmsUri.encodedUri();
2095 }
2096
2098 {
2099 return mWmsParameters.value( QgsWmsParameter::WITH_GEOMETRY ).toBool();
2100 }
2101
2103 {
2104 return mWmsParameters.value( QgsWmsParameter::WITH_MAPTIP ).toBool();
2105 }
2106
2108 {
2109 return mWmsParameters.value( QgsWmsParameter::WITH_DISPLAY_NAME ).toBool();
2110 }
2111
2113 {
2114 return mWmsParameters.value( QgsWmsParameter::WMTVER ).toString();
2115 }
2116
2117 void QgsWmsParameters::log( const QString &msg ) const
2118 {
2119 QgsMessageLog::logMessage( msg, QStringLiteral( "Server" ), Qgis::MessageLevel::Info );
2120 }
2121
2122 void QgsWmsParameters::raiseError( const QString &msg ) const
2123 {
2125 }
2126
2127 QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
2128 {
2129 QgsWmsParameter p;
2130
2131 for ( const auto &param : mWmsParameters.values( name ) )
2132 {
2133 if ( param.mMapId == id )
2134 {
2135 p = param;
2136 }
2137 }
2138
2139 return p;
2140 }
2141
2142 QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
2143 {
2144 QgsWmsParametersExternalLayer param;
2145
2146 param.mName = name;
2147 param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
2148 param.mUri = externalWMSUri( param.mName );
2149
2150 return param;
2151 }
2152
2153 bool QgsWmsParameters::isExternalLayer( const QString &name )
2154 {
2155 return name.startsWith( EXTERNAL_LAYER_PREFIX );
2156 }
2157
2159 {
2160 QStringList attributes;
2161 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2162
2163 if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
2164 {
2165 attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
2166 }
2167
2168 return attributes;
2169 }
2170
2172 {
2173 bool use = false;
2174 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2175
2176 if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
2177 {
2178 use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
2179 }
2180
2181 return use;
2182 }
2183
2185 {
2186 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2187
2188 double scale = -1;
2189 if ( options.contains( DxfFormatOption::SCALE ) )
2190 {
2191 scale = options[ DxfFormatOption::SCALE ].toDouble();
2192 }
2193
2194 return scale;
2195 }
2196
2198 {
2199 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2200
2202
2203 if ( ! options.contains( DxfFormatOption::MODE ) )
2204 {
2205 return symbol;
2206 }
2207
2208 const QString mode = options[ DxfFormatOption::MODE ];
2209 if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
2210 {
2212 }
2213 else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
2214 {
2216 }
2217
2218 return symbol;
2219 }
2220
2222 {
2223 QString codec = QStringLiteral( "ISO-8859-1" );
2224
2225 if ( formatOptions<QgsWmsParameters::DxfFormatOption>().contains( DxfFormatOption::CODEC ) )
2226 {
2227 codec = formatOptions<QgsWmsParameters::DxfFormatOption>()[ DxfFormatOption::CODEC ];
2228 }
2229
2230 return codec;
2231 }
2232
2234 {
2235 bool geoPdf = false;
2236 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2237 if ( options.contains( PdfFormatOption::WRITE_GEO_PDF ) )
2238 {
2239 geoPdf = QVariant( options[PdfFormatOption::WRITE_GEO_PDF] ).toBool();
2240 }
2241 return geoPdf;
2242 }
2243
2245 {
2246 bool forceVector = false;
2247 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2248 if ( options.contains( PdfFormatOption::FORCE_VECTOR_OUTPUT ) )
2249 {
2250 forceVector = QVariant( options[PdfFormatOption::FORCE_VECTOR_OUTPUT] ).toBool();
2251 }
2252 return forceVector;
2253 }
2254
2256 {
2257 bool appendGeoref = true;
2258 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2259 if ( options.contains( PdfFormatOption::APPEND_GEOREFERENCE ) )
2260 {
2261 appendGeoref = QVariant( options[PdfFormatOption::APPEND_GEOREFERENCE] ).toBool();
2262 }
2263 return appendGeoref;
2264 }
2265
2267 {
2268 bool simplify = true;
2269 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2270 if ( options.contains( PdfFormatOption::SIMPLIFY_GEOMETRY ) )
2271 {
2272 simplify = QVariant( options[PdfFormatOption::SIMPLIFY_GEOMETRY] ).toBool();
2273 }
2274 return simplify;
2275 }
2276
2278 {
2279 bool exportMetadata = false;
2280 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2281 if ( options.contains( PdfFormatOption::EXPORT_METADATA ) )
2282 {
2283 exportMetadata = QVariant( options[PdfFormatOption::EXPORT_METADATA] ).toBool();
2284 }
2285 return exportMetadata;
2286 }
2287
2289 {
2291 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2292 if ( options.contains( PdfFormatOption::TEXT_RENDER_FORMAT ) )
2293 {
2294 if ( options[PdfFormatOption::TEXT_RENDER_FORMAT].compare( QStringLiteral( "AlwaysText" ), Qt::CaseInsensitive ) == 0 )
2295 {
2297 }
2298 }
2299 return format;
2300 }
2301
2303 {
2304 bool losslessCompression = false;
2305 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2306 if ( options.contains( PdfFormatOption::LOSSLESS_IMAGE_COMPRESSION ) )
2307 {
2308 losslessCompression = QVariant( options[PdfFormatOption::LOSSLESS_IMAGE_COMPRESSION] ).toBool();
2309 }
2310 return losslessCompression;
2311 }
2312
2314 {
2315 bool disableTiledRaster = false;
2316 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2317 if ( options.contains( PdfFormatOption::DISABLE_TILED_RASTER_RENDERING ) )
2318 {
2319 disableTiledRaster = QVariant( options[PdfFormatOption::DISABLE_TILED_RASTER_RENDERING] ).toBool();
2320 }
2321 return disableTiledRaster;
2322 }
2323
2325 {
2326 bool useIso32000 = true;
2327 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2329 {
2330 useIso32000 = QVariant( options[PdfFormatOption::USE_ISO_32000_EXTENSION_FORMAT_GEOREFERENCING] ).toBool();
2331 }
2332 return useIso32000;
2333 }
2334
2336 {
2337 bool useOgcGeoreferencing = false;
2338 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2340 {
2341 useOgcGeoreferencing = QVariant( options[PdfFormatOption::USE_OGC_BEST_PRACTICE_FORMAT_GEOREFERENCING] ).toBool();
2342 }
2343 return useOgcGeoreferencing;
2344 }
2345
2347 {
2348 QStringList themes;
2349 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2350 if ( options.contains( PdfFormatOption::EXPORT_THEMES ) )
2351 {
2352 themes = options[PdfFormatOption::EXPORT_THEMES].split( ',' );
2353 }
2354 return themes;
2355 }
2356
2358 {
2359 QVector<qreal> scales;
2360 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2361 if ( options.contains( PdfFormatOption::PREDEFINED_MAP_SCALES ) )
2362 {
2363 const QStringList scaleList = options[PdfFormatOption::PREDEFINED_MAP_SCALES].split( ',' );
2364 for ( const QString &it : std::as_const( scaleList ) )
2365 {
2366 bool ok = false;
2367 qreal scale = it.toDouble( &ok );
2368 if ( ok )
2369 {
2370 scales.append( scale );
2371 }
2372 }
2373 }
2374 return scales;
2375 }
2376
2377 QMap<QString, QString> QgsWmsParameters::dimensionValues() const
2378 {
2379 QMap<QString, QString> dimValues;
2380 const QMetaEnum pnMetaEnum( QMetaEnum::fromType<QgsMapLayerServerProperties::PredefinedWmsDimensionName>() );
2381 const QStringList unmanagedNames = mUnmanagedParameters.keys();
2382 for ( const QString &key : unmanagedNames )
2383 {
2384 if ( key.startsWith( QLatin1String( "DIM_" ) ) )
2385 {
2386 dimValues[key.mid( 4 )] = mUnmanagedParameters[key];
2387 }
2388 else if ( pnMetaEnum.keyToValue( key.toUpper().toStdString().c_str() ) != -1 )
2389 {
2390 dimValues[key] = mUnmanagedParameters[key];
2391 }
2392 }
2393 return dimValues;
2394 }
2395}
@ Info
Information message.
Definition qgis.h:100
TextRenderFormat
Flags which control how map layer renderers behave.
Definition qgis.h:2055
@ 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:3849
@ 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.
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