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