QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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 "moc_qgswmsparameters.cpp"
20#include "qgsdatasourceuri.h"
22#include "qgsmessagelog.h"
24#include "qgsfontutils.h"
25
26#include <QRegularExpression>
27
28const QString EXTERNAL_LAYER_PREFIX = QStringLiteral( "EXTERNAL_WMS:" );
29
30namespace QgsWms
31{
32 //
33 // QgsWmsParameter
34 //
36 const QMetaType::Type type,
37 const QVariant defaultValue )
38 : QgsServerParameterDefinition( type, defaultValue )
39 , mName( name )
40 {
41 }
42
47
49 {
50 const QString msg = QString( "%1 ('%2') cannot be converted into %3" ).arg( name( mName ), toString(), typeName() );
52 }
53
54 QStringList QgsWmsParameter::toStyleList( const char delimiter ) const
55 {
56 return QgsServerParameterDefinition::toStringList( delimiter, false );
57 }
58
59 QList<QgsGeometry> QgsWmsParameter::toGeomList( const char delimiter ) const
60 {
61 bool ok = true;
62 const QList<QgsGeometry> geoms = QgsServerParameterDefinition::toGeomList( ok, delimiter );
63
64 if ( !ok )
65 {
66 const QString msg = QString( "%1 ('%2') cannot be converted into a list of geometries" ).arg( name( mName ), toString() );
68 }
69
70 return geoms;
71 }
72
74 {
75 bool ok = true;
77
78 if ( !ok )
79 {
80 const QString msg = QString( "%1 ('%2') cannot be converted into a rectangle" ).arg( name( mName ), toString() );
82 }
83
84 return rect;
85 }
86
88 {
89 bool ok = false;
90 const int val = QgsServerParameterDefinition::toInt( ok );
91
92 if ( !ok )
93 {
94 raiseError();
95 }
96
97 return val;
98 }
99
101 {
102 // Check URL -- it will be used in error messages
103 const QUrl url = toUrl();
104
105 bool ok = false;
106 const QString content = QgsServerParameterDefinition::loadUrl( ok );
107
108 if ( !ok )
109 {
110 const QString msg = QString( "%1 request error for %2" ).arg( name( mName ), url.toString() );
112 }
113
114 return content;
115 }
116
118 {
119 bool ok = false;
120 const QUrl url = QgsServerParameterDefinition::toUrl( ok );
121
122 if ( !ok )
123 {
124 raiseError();
125 }
126
127 return url;
128 }
129
131 {
132 bool ok = false;
133 const QColor col = QgsServerParameterDefinition::toColor( ok );
134
135 if ( !ok )
136 {
137 raiseError();
138 }
139
140 return col;
141 }
142
143 QList<QColor> QgsWmsParameter::toColorList( const char delimiter ) const
144 {
145 bool ok = false;
146 const QList<QColor> vals = QgsServerParameterDefinition::toColorList( ok, delimiter );
147
148 if ( !ok )
149 {
150 const QString msg = QString( "%1 ('%2') cannot be converted into a list of colors" ).arg( name( mName ), toString() );
152 }
153
154 return vals;
155 }
156
157 QList<int> QgsWmsParameter::toIntList( const char delimiter ) const
158 {
159 bool ok = false;
160 const QList<int> vals = QgsServerParameterDefinition::toIntList( ok, delimiter );
161
162 if ( !ok )
163 {
164 const QString msg = QString( "%1 ('%2') cannot be converted into a list of int" ).arg( name( mName ), toString() );
166 }
167
168 return vals;
169 }
170
171 QList<double> QgsWmsParameter::toDoubleList( const char delimiter ) const
172 {
173 bool ok = false;
174 const QList<double> vals = QgsServerParameterDefinition::toDoubleList( ok, delimiter );
175
176 if ( !ok )
177 {
178 const QString msg = QString( "%1 ('%2') cannot be converted into a list of float" ).arg( name( mName ), toString() );
180 }
181
182 return vals;
183 }
184
186 {
187 bool ok = false;
188 const double val = QgsServerParameterDefinition::toDouble( ok );
189
190 if ( !ok )
191 {
192 raiseError();
193 }
194
195 return val;
196 }
197
198 QString QgsWmsParameter::name() const
199 {
201 }
202
204 {
205 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
206 return metaEnum.valueToKey( name );
207 }
208
210 {
211 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameter::Name>() );
212 return ( QgsWmsParameter::Name ) metaEnum.keyToValue( name.toUpper().toStdString().c_str() );
213 }
214
215 //
216 // QgsWmsParameters
217 //
220 {
221 // Available version number
222 mVersions.append( QgsProjectVersion( 1, 1, 1 ) );
223 mVersions.append( QgsProjectVersion( 1, 3, 0 ) );
224
225 // WMS parameters definition
227 QMetaType::Type::Int,
228 QVariant( 0 ) );
229 save( pQuality );
230
232 QMetaType::Type::Bool,
233 QVariant( false ) );
234 save( pTiled );
235
237 QMetaType::Type::Double,
238 QVariant( 2.0 ) );
239 save( pBoxSpace );
240
242 QMetaType::Type::Double,
243 QVariant( 2.0 ) );
244 save( pSymbSpace );
245
247 QMetaType::Type::Double,
248 QVariant( 3.0 ) );
249 save( pLayerSpace );
250
252 QMetaType::Type::Double,
253 QVariant( 3.0 ) );
254 save( pTitleSpace );
255
257 QMetaType::Type::Double,
258 QVariant( 4.0 ) );
259 save( pSymbHeight );
260
262 QMetaType::Type::Double,
263 QVariant( 7.0 ) );
264 save( pSymbWidth );
265
267 QMetaType::Type::Double,
268 QVariant( 2.0 ) );
269 save( pIcLabelSpace );
270
272 save( pItFontFamily );
273
275 QMetaType::Type::Bool,
276 QVariant( false ) );
277 save( pItFontBold );
278
280 QMetaType::Type::Bool,
281 QVariant( false ) );
282 save( pItFontItalic );
283
285 QMetaType::Type::Double,
286 QVariant( -1 ) );
287 save( pItFontSize );
288
290 QMetaType::Type::QString,
291 QVariant( "black" ) );
292 save( pItFontColor );
293
294 const QgsWmsParameter pHighlightGeom( QgsWmsParameter::HIGHLIGHT_GEOM );
295 save( pHighlightGeom );
296
297 const QgsWmsParameter pShowFeatureCount( QgsWmsParameter::SHOWFEATURECOUNT,
298 QMetaType::Type::Bool,
299 QVariant( false ) );
300 save( pShowFeatureCount );
301
302 const QgsWmsParameter pHighlightSymbol( QgsWmsParameter::HIGHLIGHT_SYMBOL );
303 save( pHighlightSymbol );
304
306 save( pHighlightLabel );
307
309 QMetaType::Type::QString,
310 QVariant( "black" ) );
311 save( pHighlightColor );
312
313 const QgsWmsParameter pHighlightFontSize( QgsWmsParameter::HIGHLIGHT_LABELSIZE );
314 save( pHighlightFontSize );
315
316 const QgsWmsParameter pHighlightFontWeight( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT );
317 save( pHighlightFontWeight );
318
320 save( pHighlightFont );
321
323 QMetaType::Type::QString,
324 QVariant( "black" ) );
325 save( pHighlightBufferColor );
326
328 save( pHighlightBufferSize );
329
330 const QgsWmsParameter pLabelRotation( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, QMetaType::Type::Double );
331 save( pLabelRotation );
332
333 const QgsWmsParameter pLabelDistance( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, QMetaType::Type::Double );
334 save( pLabelDistance );
335
337 save( pLabelHali );
338
340 save( pLabelVali );
341
343 save( pCRS );
344
346 save( pSRS );
347
349 QMetaType::Type::QString,
350 QVariant( "png" ) );
351 save( pFormat );
352
354 save( pInfoFormat );
355
357 QMetaType::Type::Int,
358 QVariant( -1 ) );
359 save( pI );
360
362 QMetaType::Type::Int,
363 QVariant( -1 ) );
364 save( pJ );
365
367 QMetaType::Type::Int,
368 QVariant( -1 ) );
369 save( pX );
370
372 QMetaType::Type::Int,
373 QVariant( -1 ) );
374 save( pY );
375
377 save( pRule );
378
380 QMetaType::Type::Bool,
381 QVariant( true ) );
382 save( pRuleLabel );
383
385 QMetaType::Type::Bool,
386 QVariant( false ) );
387 save( pShowRuleDetails );
388
390 QMetaType::Type::Double,
391 QVariant( -1 ) );
392 save( pScale );
393
395 QMetaType::Type::Int,
396 QVariant( 0 ) );
397 save( pHeight );
398
400 QMetaType::Type::Int,
401 QVariant( 0 ) );
402 save( pWidth );
403
405 QMetaType::Type::Int,
406 QVariant( 0 ) );
407 save( pSrcHeight );
408
410 QMetaType::Type::Int,
411 QVariant( 0 ) );
412 save( pSrcWidth );
413
415 save( pBbox );
416
418 save( pSld );
419
421 save( pSldBody );
422
424 save( pLayer );
425
427 save( pLayers );
428
430 save( pQueryLayers );
431
433 QMetaType::Type::Int,
434 QVariant( 1 ) );
435 save( pFeatureCount );
436
438 QMetaType::Type::Bool,
439 QVariant( true ) );
440 save( pLayerTitle );
441
443 save( pLayerFtFamily );
444
446 QMetaType::Type::Bool,
447 QVariant( false ) );
448 save( pLayerFtBold );
449
451 QMetaType::Type::Bool,
452 QVariant( false ) );
453 save( pLayerFtItalic );
454
456 QMetaType::Type::Double,
457 QVariant( -1 ) );
458 save( pLayerFtSize );
459
461 QMetaType::Type::QString,
462 QVariant( "black" ) );
463 save( pLayerFtColor );
464
466 save( pStyle );
467
469 save( pStyles );
470
472 save( pOpacities );
473
475 save( pFilter );
476
478 save( pFilterGeom );
479
481 QMetaType::Type::Double,
482 QVariant( 0.0 ) );
483 save( pPolygTol );
484
486 QMetaType::Type::Double,
487 QVariant( 0.0 ) );
488 save( pLineTol );
489
491 QMetaType::Type::Double,
492 QVariant( 0.0 ) );
493 save( pPointTol );
494
496 save( pSelection );
497
499 QMetaType::Type::Int,
500 QVariant( -1 ) );
501 save( pWmsPrecision );
502
504 QMetaType::Type::Bool,
505 QVariant( false ) );
506 save( pTransparent );
507
509 QMetaType::Type::QString,
510 QVariant( "white" ) );
511 save( pBgColor );
512
514 QMetaType::Type::Int,
515 QVariant( -1 ) );
516 save( pDpi );
517
519 save( pTemplate );
520
522 save( pExtent );
523
525 QMetaType::Type::Double,
526 QVariant( 0.0 ) );
527 save( pRotation );
528
530 QMetaType::Type::Double,
531 QVariant( 0.0 ) );
532 save( pGridX );
533
535 QMetaType::Type::Double,
536 QVariant( 0.0 ) );
537 save( pGridY );
538
540 QMetaType::Type::Bool,
541 QVariant( false ) );
542 save( pWithGeometry );
543
545 QMetaType::Type::QString );
546 save( pWithMapTip );
547
549 QMetaType::Type::Bool,
550 QVariant( false ) );
551 save( pWithDisplayName );
552
554 save( pWmtver );
555
557 QMetaType::Type::QStringList );
558 save( pAtlasPk );
559
561 QMetaType::Type::QString );
562 save( pFormatOpts );
563
565 QMetaType::Type::Bool,
566 QVariant( false ) );
567 save( pAddLayerGroups );
568 }
569
572 {
573 load( parameters.urlQuery() );
574
575 auto it = mWmsParameters.constFind( QgsWmsParameter::SLD );
576 if ( it != mWmsParameters.constEnd() && !it->toString().isEmpty() )
577 {
578 const QString sldBody = it->loadUrl();
579 if ( !sldBody.isEmpty() )
580 {
582 }
583 }
584 }
585
587 {
588 return mWmsParameters.value( name );
589 }
590
591 void QgsWmsParameters::set( QgsWmsParameter::Name name, const QVariant &value )
592 {
593 auto it = mWmsParameters.find( name );
594 if ( it == mWmsParameters.end() )
595 {
596 it = mWmsParameters.insert( name, QgsWmsParameter() );
597 }
598
599 it->mValue = value;
600 }
601
602 bool QgsWmsParameters::loadParameter( const QString &key, const QString &value )
603 {
604 bool loaded = false;
605
606 const thread_local QRegularExpression composerParamRegExp( QStringLiteral( "^MAP\\d+:" ), QRegularExpression::CaseInsensitiveOption );
607 if ( key.contains( composerParamRegExp ) )
608 {
609 const int mapId = QStringView {key} .mid( 3, key.indexOf( ':' ) - 3 ).toInt();
610 const QString theKey = key.mid( key.indexOf( ':' ) + 1 );
611 const QgsWmsParameter::Name name = QgsWmsParameter::name( theKey );
612
613 if ( name >= 0 )
614 {
615 QgsWmsParameter param = mWmsParameters.value( name );
616 param.mValue = value;
617 param.mMapId = mapId;
618
619 if ( ! param.isValid() )
620 {
621 param.raiseError();
622 }
623
624 save( param, true ); // multi MAP parameters for composer
625 loaded = true;
626 }
627 }
628 else
629 {
631 if ( name >= 0 )
632 {
633 auto it = mWmsParameters.find( name );
634 if ( it == mWmsParameters.end() )
635 it = mWmsParameters.insert( name, QgsWmsParameter() );
636
637 it->mValue = value;
638 if ( !it->isValid() )
639 {
640 it->raiseError();
641 }
642
643 loaded = true;
644 }
645 else //maybe an external wms parameter?
646 {
647 int separator = key.indexOf( QLatin1Char( ':' ) );
648 if ( separator >= 1 )
649 {
650 QString id = key.left( separator );
651 QString param = key.right( key.length() - separator - 1 );
652 mExternalWMSParameters[id].insert( param, value );
653
654 loaded = true;
655 }
656 }
657 }
658
659 return loaded;
660 }
661
663 {
664 log( QStringLiteral( "WMS Request parameters:" ) );
665 for ( auto it = mWmsParameters.constBegin(); it != mWmsParameters.constEnd(); ++it )
666 {
667 const QString value = it->toString();
668
669 if ( ! value.isEmpty() )
670 {
671 QString name = QgsWmsParameter::name( it.key() );
672
673 if ( it->mMapId >= 0 )
674 {
675 name = QStringLiteral( "%1:%2" ).arg( QString::number( it->mMapId ), name );
676 }
677
678 log( QStringLiteral( " - %1 : %2" ).arg( name, value ) );
679 }
680 }
681
682 if ( !version().isEmpty() )
683 log( QStringLiteral( " - VERSION : %1" ).arg( version() ) );
684 }
685
686 void QgsWmsParameters::save( const QgsWmsParameter &parameter, bool multi )
687 {
688 if ( multi )
689 {
690 mWmsParameters.insert( parameter.mName, parameter );
691 }
692 else
693 {
694 mWmsParameters.replace( parameter.mName, parameter );
695 }
696 }
697
699 {
700 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_GEOM ).toStringList( ';' );
701 }
702
703 QList<QgsGeometry> QgsWmsParameters::highlightGeomAsGeom() const
704 {
705 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_GEOM ).toGeomList( ';' );
706 }
707
709 {
710 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_SYMBOL ).toStringList( ';' );
711 }
712
713 QString QgsWmsParameters::crs() const
714 {
715 QString rs;
716 const QString srs = mWmsParameters.value( QgsWmsParameter::SRS ).toString();
717 const QString crs = mWmsParameters.value( QgsWmsParameter::CRS ).toString();
718
719 // both SRS/CRS are supported but there's a priority according to the
720 // specified version when both are defined in the request
721 if ( !srs.isEmpty() && crs.isEmpty() )
722 rs = srs;
723 else if ( srs.isEmpty() && !crs.isEmpty() )
724 rs = crs;
725 else if ( !srs.isEmpty() && !crs.isEmpty() )
726 {
727 if ( versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) )
728 rs = crs;
729 else
730 rs = srs;
731 }
732
733 return rs;
734 }
735
737 {
738 return mWmsParameters.value( QgsWmsParameter::BBOX ).toString();
739 }
740
742 {
743 return mWmsParameters.value( QgsWmsParameter::BBOX ).toRectangle();
744 }
745
747 {
748 return mWmsParameters.value( QgsWmsParameter::HEIGHT ).toString();
749 }
750
752 {
753 return mWmsParameters.value( QgsWmsParameter::WIDTH ).toString();
754 }
755
757 {
758 return mWmsParameters.value( QgsWmsParameter::HEIGHT ).toInt();
759 }
760
762 {
763 return mWmsParameters.value( QgsWmsParameter::WIDTH ).toInt();
764 }
765
767 {
768 return mWmsParameters.value( QgsWmsParameter::SRCHEIGHT ).toString();
769 }
770
772 {
773 return mWmsParameters.value( QgsWmsParameter::SRCWIDTH ).toString();
774 }
775
777 {
778 return mWmsParameters.value( QgsWmsParameter::SRCHEIGHT ).toInt();
779 }
780
782 {
783 return mWmsParameters.value( QgsWmsParameter::SRCWIDTH ).toInt();
784 }
785
786 QString QgsWmsParameters::dpi() const
787 {
788 return mWmsParameters.value( QgsWmsParameter::DPI ).toString();
789 }
790
792 {
793 return mWmsParameters.value( QgsWmsParameter::DPI ).toDouble();
794 }
795
797 {
799
800 if ( QgsServerParameters::request().compare( QLatin1String( "GetProjectSettings" ), Qt::CaseInsensitive ) == 0 )
801 {
802 version = QStringLiteral( "1.3.0" );
803 }
804 else if ( version.isEmpty() )
805 {
806 if ( ! wmtver().isEmpty() )
807 {
808 version = wmtver();
809 }
810 else
811 {
812 version = QStringLiteral( "1.3.0" );
813 }
814 }
815 else if ( !mVersions.contains( QgsProjectVersion( version ) ) )
816 {
817 // WMS 1.3.0 specification: If a version lower than any of those
818 // known to the server is requested, then the server shall send the
819 // lowest version it supports.
820 if ( QgsProjectVersion( 1, 1, 1 ) > QgsProjectVersion( version ) )
821 {
822 version = QStringLiteral( "1.1.1" );
823 }
824 else
825 {
826 version = QStringLiteral( "1.3.0" );
827 }
828 }
829
830 return version;
831 }
832
834 {
835 QString req = QgsServerParameters::request();
836
837 if ( version().compare( QLatin1String( "1.1.1" ) ) == 0
838 && req.compare( QLatin1String( "capabilities" ), Qt::CaseInsensitive ) == 0 )
839 {
840 req = QStringLiteral( "GetCapabilities" );
841 }
842
843 return req;
844 }
845
850
851 bool QgsWmsParameters::versionIsValid( const QString version ) const
852 {
853 return mVersions.contains( QgsProjectVersion( version ) );
854 }
855
857 {
858 return mWmsParameters.value( QgsWmsParameter::FORMAT ).toString( true );
859 }
860
862 {
863 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsWmsParameters::Format>() );
864 return metaEnum.valueToKey( format );
865 }
866
868 {
869 const QString fStr = formatAsString();
870
872 if ( fStr.compare( QLatin1String( "image/png" ), Qt::CaseInsensitive ) == 0 ||
873 fStr.compare( QLatin1String( "png" ), Qt::CaseInsensitive ) == 0 )
874 {
875 f = Format::PNG;
876 }
877 else if ( fStr.compare( QLatin1String( "jpg" ), Qt::CaseInsensitive ) == 0
878 || fStr.compare( QLatin1String( "jpeg" ), Qt::CaseInsensitive ) == 0
879 || fStr.compare( QLatin1String( "image/jpeg" ), Qt::CaseInsensitive ) == 0 )
880 {
881 f = Format::JPG;
882 }
883 else if ( fStr.compare( QLatin1String( "image/svg" ), Qt::CaseInsensitive ) == 0 ||
884 fStr.compare( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive ) == 0 ||
885 fStr.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 )
886 {
887 f = Format::SVG;
888 }
889 else if ( fStr.compare( QLatin1String( "application/pdf" ), Qt::CaseInsensitive ) == 0 ||
890 fStr.compare( QLatin1String( "pdf" ), Qt::CaseInsensitive ) == 0 )
891 {
892 f = Format::PDF;
893 }
894 else if ( fStr.compare( QLatin1String( "application/json" ), Qt::CaseInsensitive ) == 0 ||
895 fStr.compare( QLatin1String( "json" ), Qt::CaseInsensitive ) == 0 )
896 {
897 f = Format::JSON;
898 }
899 return f;
900 }
901
903 {
904 return mWmsParameters.value( QgsWmsParameter::INFO_FORMAT ).toString();
905 }
906
908 {
909 return infoFormat() == Format::PNG || infoFormat() == Format::JPG;
910 }
911
913 {
914 QString fStr = infoFormatAsString();
915
917 if ( fStr.isEmpty() )
918 return f;
919
920 if ( fStr.startsWith( QLatin1String( "text/xml" ), Qt::CaseInsensitive ) )
921 f = Format::XML;
922 else if ( fStr.startsWith( QLatin1String( "text/html" ), Qt::CaseInsensitive ) )
923 f = Format::HTML;
924 else if ( fStr.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
925 f = Format::TEXT;
926 else if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml" ), Qt::CaseInsensitive ) )
927 f = Format::GML;
928 else if ( fStr.startsWith( QLatin1String( "application/json" ), Qt::CaseInsensitive )
929 || fStr.startsWith( QLatin1String( "application/geo+json" ), Qt::CaseInsensitive ) )
930 f = Format::JSON;
931 else
932 f = Format::NONE;
933
934 return f;
935 }
936
938 {
939 if ( infoFormat() != Format::GML )
940 return -1;
941
942 QString fStr = infoFormatAsString();
943 if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml/3" ), Qt::CaseInsensitive ) )
944 return 3;
945 else
946 return 2;
947 }
948
949 QString QgsWmsParameters::i() const
950 {
951 return mWmsParameters.value( QgsWmsParameter::I ).toString();
952 }
953
954 QString QgsWmsParameters::j() const
955 {
956 return mWmsParameters.value( QgsWmsParameter::J ).toString();
957 }
958
960 {
961 return mWmsParameters.value( QgsWmsParameter::I ).toInt();
962 }
963
965 {
966 return mWmsParameters.value( QgsWmsParameter::J ).toInt();
967 }
968
969 QString QgsWmsParameters::x() const
970 {
971 return mWmsParameters.value( QgsWmsParameter::X ).toString();
972 }
973
974 QString QgsWmsParameters::y() const
975 {
976 return mWmsParameters.value( QgsWmsParameter::Y ).toString();
977 }
978
980 {
981 return mWmsParameters.value( QgsWmsParameter::X ).toInt();
982 }
983
985 {
986 return mWmsParameters.value( QgsWmsParameter::Y ).toInt();
987 }
988
990 {
991 return mWmsParameters.value( QgsWmsParameter::RULE ).toString();
992 }
993
995 {
996 return mWmsParameters.value( QgsWmsParameter::SHOWRULEDETAILS ).toBool();
997 }
998
1000 {
1001 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toString();
1002 }
1003
1005 {
1006 return mWmsParameters.value( QgsWmsParameter::RULELABEL ).toBool();
1007 }
1008
1010 {
1011 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toString();
1012 }
1013
1015 {
1016 return mWmsParameters.value( QgsWmsParameter::TRANSPARENT ).toBool();
1017 }
1018
1020 {
1021 return mWmsParameters.value( QgsWmsParameter::SCALE ).toString();
1022 }
1023
1025 {
1026 return mWmsParameters.value( QgsWmsParameter::SCALE ).toDouble();
1027 }
1028
1030 {
1031 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toString();
1032 }
1033
1035 {
1036 return mWmsParameters.value( QgsWmsParameter::IMAGE_QUALITY ).toInt();
1037 }
1038
1040 {
1041 return mWmsParameters.value( QgsWmsParameter::TILED ).toString();
1042 }
1043
1045 {
1046 return mWmsParameters.value( QgsWmsParameter::TILED ).toBool();
1047 }
1048
1050 {
1051 return mWmsParameters.value( QgsWmsParameter::ADDLAYERGROUPS ).toBool();
1052 }
1053
1055 {
1056 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toString();
1057 }
1058
1060 {
1061 return mWmsParameters.value( QgsWmsParameter::SHOWFEATURECOUNT ).toBool();
1062 }
1063
1065 {
1066 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toString();
1067 }
1068
1070 {
1071 return mWmsParameters.value( QgsWmsParameter::FEATURE_COUNT ).toInt();
1072 }
1073
1075 {
1076 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toString();
1077 }
1078
1080 {
1081 return mWmsParameters.value( QgsWmsParameter::BOXSPACE ).toDouble();
1082 }
1083
1085 {
1086 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toString();
1087 }
1088
1090 {
1091 return mWmsParameters.value( QgsWmsParameter::LAYERSPACE ).toDouble();
1092 }
1093
1095 {
1096 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toString();
1097 }
1098
1100 {
1101 return mWmsParameters.value( QgsWmsParameter::LAYERTITLESPACE ).toDouble();
1102 }
1103
1105 {
1106 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toString();
1107 }
1108
1110 {
1111 return mWmsParameters.value( QgsWmsParameter::SYMBOLSPACE ).toDouble();
1112 }
1113
1115 {
1116 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toString();
1117 }
1118
1120 {
1121 return mWmsParameters.value( QgsWmsParameter::SYMBOLHEIGHT ).toDouble();
1122 }
1123
1125 {
1126 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toString();
1127 }
1128
1130 {
1131 return mWmsParameters.value( QgsWmsParameter::SYMBOLWIDTH ).toDouble();
1132 }
1133
1135 {
1136 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toString();
1137 }
1138
1140 {
1141 return mWmsParameters.value( QgsWmsParameter::ICONLABELSPACE ).toDouble();
1142 }
1143
1145 {
1146 return mWmsParameters.value( QgsWmsParameter::LAYERFONTFAMILY ).toString();
1147 }
1148
1150 {
1151 return mWmsParameters.value( QgsWmsParameter::ITEMFONTFAMILY ).toString();
1152 }
1153
1155 {
1156 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toString();
1157 }
1158
1160 {
1161 return mWmsParameters.value( QgsWmsParameter::LAYERFONTBOLD ).toBool();
1162 }
1163
1165 {
1166 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toString();
1167 }
1168
1170 {
1171 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toString();
1172 }
1173
1175 {
1176 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toString();
1177 }
1178
1180 {
1181 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toString();
1182 }
1183
1185 {
1186 return mWmsParameters.value( QgsWmsParameter::FI_POLYGON_TOLERANCE ).toInt();
1187 }
1188
1190 {
1191 return mWmsParameters.value( QgsWmsParameter::FI_LINE_TOLERANCE ).toInt();
1192 }
1193
1195 {
1196 return mWmsParameters.value( QgsWmsParameter::FI_POINT_TOLERANCE ).toInt();
1197 }
1198
1200 {
1201 return mWmsParameters.value( QgsWmsParameter::ITEMFONTBOLD ).toBool();
1202 }
1203
1205 {
1206 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toString();
1207 }
1208
1210 {
1211 return mWmsParameters.value( QgsWmsParameter::LAYERFONTITALIC ).toBool();
1212 }
1213
1215 {
1216 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toString();
1217 }
1218
1220 {
1221 return mWmsParameters.value( QgsWmsParameter::ITEMFONTITALIC ).toBool();
1222 }
1223
1225 {
1226 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toString();
1227 }
1228
1230 {
1231 return mWmsParameters.value( QgsWmsParameter::LAYERFONTSIZE ).toDouble();
1232 }
1233
1235 {
1236 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toString();
1237 }
1238
1240 {
1241 return mWmsParameters.value( QgsWmsParameter::LAYERFONTCOLOR ).toColor();
1242 }
1243
1245 {
1246 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toString();
1247 }
1248
1250 {
1251 return mWmsParameters.value( QgsWmsParameter::ITEMFONTSIZE ).toDouble();
1252 }
1253
1255 {
1256 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toString();
1257 }
1258
1260 {
1261 return mWmsParameters.value( QgsWmsParameter::ITEMFONTCOLOR ).toColor();
1262 }
1263
1265 {
1266 QFont font;
1267 font.fromString( "" );
1268 font.setBold( layerFontBoldAsBool() );
1269 font.setItalic( layerFontItalicAsBool() );
1270
1271 if ( ! layerFontSize().isEmpty() )
1272 font.setPointSizeF( layerFontSizeAsDouble() );
1273
1274 if ( !layerFontFamily().isEmpty() )
1276
1277 return font;
1278 }
1279
1281 {
1282 QFont font;
1283 font.fromString( "" );
1284
1285 font.setBold( itemFontBoldAsBool() );
1286 font.setItalic( itemFontItalicAsBool() );
1287
1288 if ( ! itemFontSize().isEmpty() )
1289 font.setPointSizeF( itemFontSizeAsDouble() );
1290
1291 if ( !itemFontFamily().isEmpty() )
1293
1294 return font;
1295 }
1296
1298 {
1299 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toString();
1300 }
1301
1303 {
1304 return mWmsParameters.value( QgsWmsParameter::LAYERTITLE ).toBool();
1305 }
1306
1308 {
1309 QgsLegendSettings settings;
1310 settings.setTitle( QString() );
1311 settings.setBoxSpace( boxSpaceAsDouble() );
1312 settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) );
1313
1316
1317 // text format must be set before setting the format's colors
1320
1321 if ( !itemFontColor().isEmpty() )
1322 {
1327 }
1328
1329 // Ok, this is tricky: because QgsLegendSettings's layerFontColor was added to the API after
1330 // fontColor, to fix regressions #21871 and #21870 and the previous behavior was to use fontColor
1331 // for the whole legend we need to preserve that behavior.
1332 // But, the 2.18 server parameters ITEMFONTCOLOR did not have effect on the layer titles too, so
1333 // we set explicitly layerFontColor to black if it's not overridden by LAYERFONTCOLOR argument.
1334 settings.rstyle( QgsLegendStyle::Group ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1335 settings.rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() );
1336
1339
1340 // When processing a request involving an upstream WMS server, any responses from such a remote
1341 // server must be awaited. This was not the case for GetLegendGraphic requests (#42063). If not,
1342 // the response to the current request will never contain any data from upstream.
1343 // A quick way to fix this is to force upstream `GetLegendRequest' requests to be synchronous.
1344 // The problem with this approach is that if the GetLegendGraphic contains multiple layers, the
1345 // remote calls are made one at a time. This increases the response time. Making concurrent
1346 // asynchronous requests and waiting for them all would be a better approach.
1347 settings.setSynchronousLegendRequests( true );
1348
1349 return settings;
1350 }
1351
1352 QString QgsWmsParameters::layoutParameter( const QString &id, bool &ok ) const
1353 {
1354 QString label;
1355 ok = false;
1356
1357 if ( mUnmanagedParameters.contains( id.toUpper() ) )
1358 {
1359 label = mUnmanagedParameters[id.toUpper()];
1360 ok = true;
1361 }
1362
1363 return label;
1364 }
1365
1366 QStringList QgsWmsParameters::atlasPk() const
1367 {
1368 return mWmsParameters.value( QgsWmsParameter::ATLAS_PK ).toStringList();
1369 }
1370
1372 {
1373 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSTRING ).toStringList( ';', false );
1374 }
1375
1377 {
1378 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toStringList( ';' );
1379 }
1380
1382 {
1383 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELSIZE ).toIntList( ';' );
1384 }
1385
1387 {
1388 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toStringList( ';' );
1389 }
1390
1392 {
1393 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELCOLOR ).toColorList( ';' );
1394 }
1395
1397 {
1398 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toStringList( ';' );
1399 }
1400
1402 {
1403 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT ).toIntList( ';' );
1404 }
1405
1407 {
1408 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELFONT ).toStringList( ';' );
1409 }
1410
1412 {
1413 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toStringList( ';' );
1414 }
1415
1417 {
1418 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR ).toColorList( ';' );
1419 }
1420
1422 {
1423 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toStringList( ';' );
1424 }
1425
1427 {
1428 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE ).toDoubleList( ';' );
1429 }
1430
1432 {
1433 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION ).toDoubleList( ';' );
1434 }
1435
1437 {
1438 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE ).toDoubleList( ';' );
1439 }
1440
1442 {
1443 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT ).toStringList( ';' );
1444 }
1445
1447 {
1448 return mWmsParameters.value( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT ).toStringList( ';' );
1449 }
1450
1452 {
1453 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toString();
1454 }
1455
1457 {
1458 return mWmsParameters.value( QgsWmsParameter::WMS_PRECISION ).toInt();
1459 }
1460
1462 {
1463 return mWmsParameters.value( QgsWmsParameter::SLD_BODY ).toString();
1464 }
1465
1466 QStringList QgsWmsParameters::filters() const
1467 {
1468 QStringList filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toOgcFilterList();
1469 if ( filters.isEmpty() )
1470 filters = mWmsParameters.value( QgsWmsParameter::FILTER ).toExpressionList();
1471 return filters;
1472 }
1473
1475 {
1476 return mWmsParameters.value( QgsWmsParameter::FILTER_GEOM ).toString();
1477 }
1478
1480 {
1481 return mWmsParameters.value( QgsWmsParameter::SELECTION ).toStringList( ';' );
1482 }
1483
1485 {
1486 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toStringList();
1487 }
1488
1490 {
1491 return mWmsParameters.value( QgsWmsParameter::OPACITIES ).toIntList();
1492 }
1493
1495 {
1496 // We don't want duplicates but order does matter, so no QSet
1497 QStringList result;
1498
1499 // LAYER
1500 QList<QgsWmsParameter> cLayer { mWmsParameters.values( QgsWmsParameter::LAYER ) };
1501 // Sort by map id
1502 std::sort( cLayer.begin(), cLayer.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1503 for ( const QgsWmsParameter &param : std::as_const( cLayer ) )
1504 {
1505 const QStringList layersList { param.toStringList() };
1506 for ( const QString &layerName : std::as_const( layersList ) )
1507 {
1508 if ( ! result.contains( layerName ) )
1509 result.append( layerName );
1510 }
1511 }
1512
1513 // LAYERS
1514 QList<QgsWmsParameter> cLayers { mWmsParameters.values( QgsWmsParameter::LAYERS ) };
1515 // Sort by map id
1516 std::sort( cLayers.begin(), cLayers.end(), []( const QgsWmsParameter & a, const QgsWmsParameter & b ) -> bool { return a.mMapId < b.mMapId; } );
1517 for ( const QgsWmsParameter &param : std::as_const( cLayers ) )
1518 {
1519 const QStringList layersList { param.toStringList() };
1520 for ( const QString &layerName : std::as_const( layersList ) )
1521 {
1522 if ( ! result.contains( layerName ) )
1523 result.append( layerName );
1524 }
1525 }
1526 return result;
1527 }
1528
1530 {
1531 return mWmsParameters.value( QgsWmsParameter::QUERY_LAYERS ).toStringList();
1532 }
1533
1535 {
1536 QStringList style = mWmsParameters.value( QgsWmsParameter::STYLE ).toStyleList();
1537 const QStringList styles = mWmsParameters.value( QgsWmsParameter::STYLES ).toStyleList();
1538 return style << styles;
1539 }
1540
1541 QMultiMap<QString, QgsWmsParametersFilter> QgsWmsParameters::layerFilters( const QStringList &layers ) const
1542 {
1543 const QString nsWfs2 = QStringLiteral( "http://www.opengis.net/fes/2.0" );
1544 const QString prefixWfs2 = QStringLiteral( "<fes:" );
1545
1546 const QStringList rawFilters = filters();
1547 QMultiMap<QString, QgsWmsParametersFilter> filters;
1548 for ( int i = 0; i < rawFilters.size(); i++ )
1549 {
1550 const QString f = rawFilters[i];
1551 if ( f.startsWith( QLatin1Char( '<' ) ) \
1552 && f.endsWith( QLatin1String( "Filter>" ) ) \
1553 && i < layers.size() )
1554 {
1556 filter.mFilter = f;
1559
1560 if ( filter.mFilter.contains( nsWfs2 ) \
1561 || filter.mFilter.contains( prefixWfs2 ) )
1562 {
1564 }
1565
1566 filters.insert( layers[i], filter );
1567 }
1568 else if ( !f.isEmpty() )
1569 {
1570 // filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
1571 // several filters can be defined for one layer
1572 const int colonIndex = f.indexOf( ':' );
1573 if ( colonIndex != -1 )
1574 {
1575 const QString layers = f.section( ':', 0, 0 );
1576 const QString filter = f.section( ':', 1 );
1577 const QStringList layersList = layers.split( ',' );
1578 for ( const QString &layer : layersList )
1579 {
1580 QgsWmsParametersFilter parametersFilter;
1581 parametersFilter.mFilter = filter;
1582 parametersFilter.mType = QgsWmsParametersFilter::SQL;
1583 filters.insert( layer, parametersFilter );
1584 }
1585 }
1586 else
1587 {
1588 QString filterStr = mWmsParameters.value( QgsWmsParameter::FILTER ).toString();
1589 raiseError( QStringLiteral( "FILTER ('" ) + filterStr + QStringLiteral( "') is not properly formatted" ) );
1590 }
1591 }
1592 }
1593 return filters;
1594 }
1595
1597 {
1598 bool force2D = false;
1599 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1600
1601 if ( options.contains( DxfFormatOption::FORCE_2D ) )
1602 {
1603 force2D = QVariant( options[ DxfFormatOption::FORCE_2D ] ).toBool();
1604 }
1605
1606 return force2D;
1607 }
1608
1610 {
1611 bool zeroWidth = false;
1612 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1613
1614 if ( options.contains( DxfFormatOption::EXPORT_LINES_WITH_ZERO_WIDTH ) )
1615 {
1616 zeroWidth = QVariant( options[ DxfFormatOption::EXPORT_LINES_WITH_ZERO_WIDTH ] ).toBool();
1617 }
1618
1619 return zeroWidth;
1620 }
1621
1623 {
1624 bool noMText = false;
1625 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
1626
1627 if ( options.contains( DxfFormatOption::NO_MTEXT ) )
1628 {
1629 noMText = QVariant( options[ DxfFormatOption::NO_MTEXT ] ).toBool();
1630 }
1631
1632 return noMText;
1633 }
1634
1635
1636 QList<QgsWmsParametersLayer> QgsWmsParameters::layersParameters() const
1637 {
1638 const QStringList layers = allLayersNickname();
1639 const QStringList styles = allStyles();
1640 const QStringList selection = selections();
1641 const QList<int> opacities = opacitiesAsInt();
1642 const QMultiMap<QString, QgsWmsParametersFilter> filters = layerFilters( layers );
1643
1644 // selection format: "LayerName:id0,id1;LayerName2:id0,id1;..."
1645 // several filters can be defined for one layer
1646 QMultiMap<QString, QString> layerSelections;
1647 for ( const QString &s : selection )
1648 {
1649 const QStringList splits = s.split( ':' );
1650 if ( splits.size() == 2 )
1651 {
1652 layerSelections.insert( splits[0], splits[1] );
1653 }
1654 else
1655 {
1656 QString selStr = mWmsParameters.value( QgsWmsParameter::SELECTION ).toString();
1657 raiseError( QStringLiteral( "SELECTION ('" ) + selStr + QStringLiteral( "') is not properly formatted" ) );
1658 }
1659 }
1660
1661 QList<QgsWmsParametersLayer> parameters;
1662 for ( int i = 0; i < layers.size(); i++ )
1663 {
1664 QString layer = layers[i];
1665
1667 param.mNickname = layer;
1668
1669 if ( i < opacities.count() )
1670 param.mOpacity = opacities[i];
1671
1672 if ( isExternalLayer( layer ) )
1673 {
1674 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1675 param.mNickname = extParam.mName;
1676 param.mExternalUri = extParam.mUri;
1677 }
1678 else
1679 {
1680 if ( i < styles.count() )
1681 param.mStyle = styles[i];
1682
1683 if ( filters.contains( layer ) )
1684 {
1685 auto it = filters.find( layer );
1686 while ( it != filters.end() && it.key() == layer )
1687 {
1688 param.mFilter.append( it.value() );
1689 ++it;
1690 }
1691 }
1692
1693 if ( layerSelections.contains( layer ) )
1694 {
1695 QMultiMap<QString, QString>::const_iterator it;
1696 it = layerSelections.constFind( layer );
1697 while ( it != layerSelections.constEnd() && it.key() == layer )
1698 {
1699 param.mSelection << it.value().split( ',' );
1700 ++it;
1701 }
1702 }
1703 }
1704
1705 parameters.append( param );
1706 }
1707
1708 return parameters;
1709 }
1710
1711 QList<QgsWmsParametersHighlightLayer> QgsWmsParameters::highlightLayersParameters() const
1712 {
1713 QList<QgsWmsParametersHighlightLayer> params;
1714 const QList<QgsGeometry> geoms = highlightGeomAsGeom();
1715 const QStringList slds = highlightSymbol();
1716 const QStringList labels = highlightLabelString();
1717 const QList<QColor> colors = highlightLabelColorAsColor();
1718 const QList<int> sizes = highlightLabelSizeAsInt();
1719 const QList<int> weights = highlightLabelWeightAsInt();
1720 const QStringList fonts = highlightLabelFont();
1721 const QList<QColor> bufferColors = highlightLabelBufferColorAsColor();
1722 const QList<double> bufferSizes = highlightLabelBufferSizeAsFloat();
1723 const QList<double> rotation = highlightLabelRotation();
1724 const QList<double> distance = highlightLabelDistance();
1725 const QStringList hali = highlightLabelHorizontalAlignment();
1726 const QStringList vali = highlightLabelVerticalAlignment();
1727
1728 int nLayers = std::min( geoms.size(), slds.size() );
1729 for ( int i = 0; i < nLayers; i++ )
1730 {
1732 param.mName = QStringLiteral( "highlight_" ) + QString::number( i );
1733 param.mGeom = geoms[i];
1734 param.mSld = slds[i];
1735
1736 if ( i < labels.count() )
1737 param.mLabel = labels[i];
1738
1739 if ( i < colors.count() )
1740 param.mColor = colors[i];
1741
1742 if ( i < sizes.count() )
1743 param.mSize = sizes[i];
1744
1745 if ( i < weights.count() )
1746 param.mWeight = weights[i];
1747
1748 if ( i < fonts.count() )
1749 param.mFont = fonts[ i ];
1750
1751 if ( i < bufferColors.count() )
1752 param.mBufferColor = bufferColors[i];
1753
1754 if ( i < bufferSizes.count() )
1755 param.mBufferSize = bufferSizes[i];
1756
1757 if ( i < rotation.count() )
1758 param.mLabelRotation = rotation[i];
1759
1760 if ( i < distance.count() )
1761 param.mLabelDistance = distance[i];
1762
1763 if ( i < hali.count() )
1764 param.mHali = hali[i];
1765
1766 if ( i < vali.count() )
1767 param.mVali = vali[i];
1768
1769
1770
1771 params.append( param );
1772 }
1773
1774 return params;
1775 }
1776
1777 QList<QgsWmsParametersExternalLayer> QgsWmsParameters::externalLayersParameters() const
1778 {
1779 auto notExternalLayer = []( const QString & name ) { return ! QgsWmsParameters::isExternalLayer( name ); };
1780
1781 QList<QgsWmsParametersExternalLayer> externalLayers;
1782
1783 QStringList layers = allLayersNickname();
1784 QStringList::iterator rit = std::remove_if( layers.begin(), layers.end(), notExternalLayer );
1785
1786 for ( QStringList::iterator it = layers.begin(); it != rit; ++it )
1787 {
1788 externalLayers << externalLayerParameter( *it );
1789 }
1790
1791 return externalLayers;
1792 }
1793
1795 {
1796 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toString();
1797 }
1798
1800 {
1801 return mWmsParameters.value( QgsWmsParameter::BGCOLOR ).toColor();
1802 }
1803
1805 {
1806 return mWmsParameters.value( QgsWmsParameter::TEMPLATE ).toString();
1807 }
1808
1810 {
1811 QgsWmsParameter wmsParam;
1813 param.mId = mapId;
1814
1815 QString pMapId = QStringLiteral( "MAP" ) + QString::number( mapId );
1816
1817 wmsParam = idParameter( QgsWmsParameter::EXTENT, mapId );
1818 QgsRectangle extent;
1819 if ( wmsParam.isValid() )
1820 {
1821 extent = wmsParam.toRectangle();
1822 }
1823
1824 param.mHasExtent = !extent.isEmpty();
1825 param.mExtent = extent;
1826
1827 // scale
1828 wmsParam = idParameter( QgsWmsParameter::SCALE, mapId );
1829 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1830 {
1831 param.mScale = wmsParam.toDouble();
1832 }
1833
1834 // rotation
1835 wmsParam = idParameter( QgsWmsParameter::ROTATION, mapId );
1836 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1837 {
1838 param.mRotation = wmsParam.toDouble();
1839 }
1840
1841 //grid space x / y
1842 double gridx( -1 ), gridy( -1 );
1843
1844 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_X, mapId );
1845 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1846 {
1847 gridx = wmsParam.toDouble();
1848 }
1849
1850 wmsParam = idParameter( QgsWmsParameter::GRID_INTERVAL_Y, mapId );
1851 if ( wmsParam.isValid() && !wmsParam.toString().isEmpty() )
1852 {
1853 gridy = wmsParam.toDouble();
1854 }
1855
1856 if ( gridx != -1 && gridy != -1 )
1857 {
1858 param.mGridX = gridx;
1859 param.mGridY = gridy;
1860 }
1861
1862 //layers
1863 QStringList allLayers;
1864 wmsParam = idParameter( QgsWmsParameter::LAYERS, mapId );
1865 if ( wmsParam.isValid() )
1866 {
1867 allLayers = wmsParam.toStringList();
1868 }
1869
1870 // external layers
1871 QStringList layers;
1872
1873 for ( const auto &layer : std::as_const( allLayers ) )
1874 {
1875 if ( isExternalLayer( layer ) )
1876 {
1877 const QgsWmsParametersExternalLayer extParam = externalLayerParameter( layer );
1878 layers << extParam.mName;
1879 }
1880 else
1881 {
1882 layers << layer;
1883 }
1884 }
1885
1886 QStringList styles;
1887 wmsParam = idParameter( QgsWmsParameter::STYLES, mapId );
1888 if ( wmsParam.isValid() )
1889 {
1890 styles = wmsParam.toStyleList();
1891 }
1892
1893 QList<QgsWmsParametersLayer> lParams;
1894 for ( int i = 0; i < layers.size(); i++ )
1895 {
1896 QString layer = layers[i];
1897 QgsWmsParametersLayer lParam;
1898 lParam.mNickname = layer;
1899
1900 if ( i < styles.count() )
1901 lParam.mStyle = styles[i];
1902
1903 lParams.append( lParam );
1904 }
1905 param.mLayers = lParams;
1906
1907 //highlight layers
1908 QList<QgsWmsParametersHighlightLayer> hParams;
1909
1910 QList<QgsGeometry> geoms;
1911 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_GEOM, mapId );
1912 if ( wmsParam.isValid() )
1913 {
1914 geoms = wmsParam.toGeomList( ';' );
1915 }
1916
1917 QStringList slds;
1918 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_SYMBOL, mapId );
1919 if ( wmsParam.isValid() )
1920 {
1921 slds = wmsParam.toStringList( ';' );
1922 }
1923
1924 QStringList labels;
1925 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSTRING, mapId );
1926 if ( wmsParam.isValid() )
1927 {
1928 labels = wmsParam.toStringList( ';' );
1929 }
1930
1931 QStringList fonts;
1932 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELFONT, mapId );
1933 if ( wmsParam.isValid() )
1934 {
1935 fonts = wmsParam.toStringList( ';' );
1936 }
1937
1938 QList<QColor> colors;
1939 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELCOLOR, mapId );
1940 if ( wmsParam.isValid() )
1941 {
1942 colors = wmsParam.toColorList( ';' );
1943 }
1944
1945 QList<int> sizes;
1946 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELSIZE, mapId );
1947 if ( wmsParam.isValid() )
1948 {
1949 sizes = wmsParam.toIntList( ';' );
1950 }
1951
1952 QList<int> weights;
1953 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELWEIGHT, mapId );
1954 if ( wmsParam.isValid() )
1955 {
1956 weights = wmsParam.toIntList( ';' );
1957 }
1958
1959 QList<QColor> bufferColors;
1960 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERCOLOR, mapId );
1961 if ( wmsParam.isValid() )
1962 {
1963 bufferColors = wmsParam.toColorList( ';' );
1964 }
1965
1966 QList<double> bufferSizes;
1967 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABELBUFFERSIZE, mapId );
1968 if ( wmsParam.isValid() )
1969 {
1970 bufferSizes = wmsParam.toDoubleList( ';' );
1971 }
1972
1973 QList<double> rotations;
1974 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_ROTATION, mapId );
1975 if ( wmsParam.isValid() )
1976 {
1977 rotations = wmsParam.toDoubleList( ';' );
1978 }
1979
1980 QList<double> distances;
1981 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_DISTANCE, mapId );
1982 if ( wmsParam.isValid() )
1983 {
1984 distances = wmsParam.toDoubleList( ';' );
1985 }
1986
1987 QStringList halis;
1988 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT, mapId );
1989 if ( wmsParam.isValid() )
1990 {
1991 halis = wmsParam.toStringList();
1992 }
1993
1994 QStringList valis;
1995 wmsParam = idParameter( QgsWmsParameter::HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT, mapId );
1996 if ( wmsParam.isValid() )
1997 {
1998 valis = wmsParam.toStringList();
1999 }
2000
2001 int nHLayers = std::min( geoms.size(), slds.size() );
2002 for ( int i = 0; i < nHLayers; i++ )
2003 {
2005 hParam.mName = pMapId + QStringLiteral( "_highlight_" ) + QString::number( i );
2006 hParam.mGeom = geoms[i];
2007 hParam.mSld = slds[i];
2008
2009 if ( i < labels.count() )
2010 hParam.mLabel = labels[i];
2011
2012 if ( i < colors.count() )
2013 hParam.mColor = colors[i];
2014
2015 if ( i < sizes.count() )
2016 hParam.mSize = sizes[i];
2017
2018 if ( i < weights.count() )
2019 hParam.mWeight = weights[i];
2020
2021 if ( i < fonts.count() )
2022 hParam.mFont = fonts[ i ];
2023
2024 if ( i < bufferColors.count() )
2025 hParam.mBufferColor = bufferColors[i];
2026
2027 if ( i < bufferSizes.count() )
2028 hParam.mBufferSize = bufferSizes[i];
2029
2030 if ( i < rotations.count() )
2031 hParam.mLabelRotation = rotations[i];
2032
2033 if ( i < distances.count() )
2034 hParam.mLabelDistance = distances[i];
2035
2036 if ( i < halis.count() )
2037 hParam.mHali = halis[i];
2038
2039 if ( i < valis.count() )
2040 hParam.mVali = valis[i];
2041
2042 hParams.append( hParam );
2043 }
2044 param.mHighlightLayers = hParams;
2045
2046 return param;
2047 }
2048
2049 QString QgsWmsParameters::externalWMSUri( const QString &layerId ) const
2050 {
2051
2052 // Param names may be uppercased.
2053 QString id { layerId };
2054
2055 for ( auto it = mExternalWMSParameters.cbegin(); it != mExternalWMSParameters.cend(); ++it )
2056 {
2057 if ( it.key().compare( id, Qt::CaseSensitivity::CaseInsensitive ) == 0 )
2058 {
2059 id = it.key();
2060 break;
2061 }
2062 }
2063
2064 if ( !mExternalWMSParameters.contains( id ) )
2065 {
2066 return QString();
2067 }
2068
2069 QgsDataSourceUri wmsUri;
2070 const QMap<QString, QString> &paramMap = mExternalWMSParameters[ id ];
2071 QMap<QString, QString>::const_iterator paramIt = paramMap.constBegin();
2072 for ( ; paramIt != paramMap.constEnd(); ++paramIt )
2073 {
2074 QString paramName = paramIt.key().toLower();
2075 if ( paramName == QLatin1String( "layers" ) || paramName == QLatin1String( "styles" ) || paramName == QLatin1String( "opacities" ) )
2076 {
2077 const QStringList values = paramIt.value().split( ',' );
2078 for ( const QString &value : values )
2079 wmsUri.setParam( paramName, value );
2080 }
2081 else if ( paramName == QLatin1String( "ignorereportedlayerextents" ) )
2082 {
2083 wmsUri.setParam( QStringLiteral( "IgnoreReportedLayerExtents" ), paramIt.value() );
2084 }
2085 else if ( paramName == QLatin1String( "smoothpixmaptransform" ) )
2086 {
2087 wmsUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), paramIt.value() );
2088 }
2089 else if ( paramName == QLatin1String( "ignoregetmapurl" ) )
2090 {
2091 wmsUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), paramIt.value() );
2092 }
2093 else if ( paramName == QLatin1String( "ignoregetfeatureinfourl" ) )
2094 {
2095 wmsUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), paramIt.value() );
2096 }
2097 else if ( paramName == QLatin1String( "ignoreaxisorientation" ) )
2098 {
2099 wmsUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), paramIt.value() );
2100 }
2101 else if ( paramName == QLatin1String( "invertaxisorientation" ) )
2102 {
2103 wmsUri.setParam( QStringLiteral( "InvertAxisOrientation" ), paramIt.value() );
2104 }
2105 else if ( paramName == QLatin1String( "dpimode" ) )
2106 {
2107 wmsUri.setParam( QStringLiteral( "dpiMode" ), paramIt.value() );
2108 }
2109 else if ( paramName == QLatin1String( "stepwidth" ) )
2110 {
2111 wmsUri.setParam( QStringLiteral( "stepWidth" ), paramIt.value() );
2112 }
2113 else if ( paramName == QLatin1String( "stepheight" ) )
2114 {
2115 wmsUri.setParam( QStringLiteral( "stepHeight" ), paramIt.value() );
2116 }
2117 else
2118 {
2119 wmsUri.setParam( paramName, paramIt.value() );
2120 }
2121 }
2122 return wmsUri.encodedUri();
2123 }
2124
2126 {
2127 return mWmsParameters.value( QgsWmsParameter::WITH_GEOMETRY ).toBool();
2128 }
2129
2131 {
2132 return mWmsParameters.value( QgsWmsParameter::WITH_MAPTIP ).toString();
2133 }
2134
2136 {
2137 const QString mStr = withMapTipAsString();
2138
2139 if ( mStr.startsWith( QLatin1String( "true" ), Qt::CaseInsensitive ) ||
2140 mStr.startsWith( QLatin1String( "on" ), Qt::CaseInsensitive ) ||
2141 mStr.startsWith( QLatin1String( "yes" ), Qt::CaseInsensitive ) ||
2142 mStr.startsWith( QLatin1Char( '1' ) ) )
2143 return true;
2144 else
2145 return false;
2146 }
2147
2149 {
2150 const QString mStr = withMapTipAsString();
2151
2152 if ( mStr.startsWith( QLatin1String( "html_fi_only_maptip" ), Qt::CaseInsensitive ) )
2153 return true;
2154 else
2155 return false;
2156 }
2157
2159 {
2160 return mWmsParameters.value( QgsWmsParameter::WITH_DISPLAY_NAME ).toBool();
2161 }
2162
2164 {
2165 return mWmsParameters.value( QgsWmsParameter::WMTVER ).toString();
2166 }
2167
2168 void QgsWmsParameters::log( const QString &msg ) const
2169 {
2170 QgsMessageLog::logMessage( msg, QStringLiteral( "Server" ), Qgis::MessageLevel::Info );
2171 }
2172
2173 void QgsWmsParameters::raiseError( const QString &msg ) const
2174 {
2176 }
2177
2178 QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
2179 {
2180 QgsWmsParameter p;
2181
2182 for ( const auto &param : mWmsParameters.values( name ) )
2183 {
2184 if ( param.mMapId == id )
2185 {
2186 p = param;
2187 }
2188 }
2189
2190 return p;
2191 }
2192
2193 QgsWmsParametersExternalLayer QgsWmsParameters::externalLayerParameter( const QString &name ) const
2194 {
2195 QgsWmsParametersExternalLayer param;
2196
2197 param.mName = name;
2198 param.mName.remove( 0, EXTERNAL_LAYER_PREFIX.size() );
2199 param.mUri = externalWMSUri( param.mName );
2200
2201 return param;
2202 }
2203
2204 bool QgsWmsParameters::isExternalLayer( const QString &name )
2205 {
2206 return name.startsWith( EXTERNAL_LAYER_PREFIX );
2207 }
2208
2210 {
2211 QStringList attributes;
2212 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2213
2214 if ( options.contains( DxfFormatOption::LAYERATTRIBUTES ) )
2215 {
2216 attributes = options[ DxfFormatOption::LAYERATTRIBUTES ].split( ',' );
2217 }
2218
2219 return attributes;
2220 }
2221
2223 {
2224 bool use = false;
2225 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2226
2227 if ( options.contains( DxfFormatOption::USE_TITLE_AS_LAYERNAME ) )
2228 {
2229 use = QVariant( options[ DxfFormatOption::USE_TITLE_AS_LAYERNAME ] ).toBool();
2230 }
2231
2232 return use;
2233 }
2234
2236 {
2237 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2238
2239 double scale = -1;
2240 if ( options.contains( DxfFormatOption::SCALE ) )
2241 {
2242 scale = options[ DxfFormatOption::SCALE ].toDouble();
2243 }
2244
2245 return scale;
2246 }
2247
2249 {
2250 const QMap<DxfFormatOption, QString> options = formatOptions<QgsWmsParameters::DxfFormatOption>();
2251
2253
2254 if ( ! options.contains( DxfFormatOption::MODE ) )
2255 {
2256 return symbol;
2257 }
2258
2259 const QString mode = options[ DxfFormatOption::MODE ];
2260 if ( mode.compare( QLatin1String( "SymbolLayerSymbology" ), Qt::CaseInsensitive ) == 0 )
2261 {
2263 }
2264 else if ( mode.compare( QLatin1String( "FeatureSymbology" ), Qt::CaseInsensitive ) == 0 )
2265 {
2267 }
2268
2269 return symbol;
2270 }
2271
2273 {
2274 QString codec = QStringLiteral( "ISO-8859-1" );
2275
2276 if ( formatOptions<QgsWmsParameters::DxfFormatOption>().contains( DxfFormatOption::CODEC ) )
2277 {
2278 codec = formatOptions<QgsWmsParameters::DxfFormatOption>()[ DxfFormatOption::CODEC ];
2279 }
2280
2281 return codec;
2282 }
2283
2285 {
2286 bool geospatialPdf = false;
2287 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2288 if ( options.contains( PdfFormatOption::WRITE_GEO_PDF ) )
2289 {
2290 geospatialPdf = QVariant( options[PdfFormatOption::WRITE_GEO_PDF] ).toBool();
2291 }
2292 return geospatialPdf;
2293 }
2294
2296 {
2297 bool forceVector = false;
2298 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2299 if ( options.contains( PdfFormatOption::FORCE_VECTOR_OUTPUT ) )
2300 {
2301 forceVector = QVariant( options[PdfFormatOption::FORCE_VECTOR_OUTPUT] ).toBool();
2302 }
2303 return forceVector;
2304 }
2305
2307 {
2308 bool appendGeoref = true;
2309 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2310 if ( options.contains( PdfFormatOption::APPEND_GEOREFERENCE ) )
2311 {
2312 appendGeoref = QVariant( options[PdfFormatOption::APPEND_GEOREFERENCE] ).toBool();
2313 }
2314 return appendGeoref;
2315 }
2316
2318 {
2319 bool simplify = true;
2320 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2321 if ( options.contains( PdfFormatOption::SIMPLIFY_GEOMETRY ) )
2322 {
2323 simplify = QVariant( options[PdfFormatOption::SIMPLIFY_GEOMETRY] ).toBool();
2324 }
2325 return simplify;
2326 }
2327
2329 {
2330 bool exportMetadata = false;
2331 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2332 if ( options.contains( PdfFormatOption::EXPORT_METADATA ) )
2333 {
2334 exportMetadata = QVariant( options[PdfFormatOption::EXPORT_METADATA] ).toBool();
2335 }
2336 return exportMetadata;
2337 }
2338
2340 {
2342 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2343 if ( options.contains( PdfFormatOption::TEXT_RENDER_FORMAT ) )
2344 {
2345 if ( options[PdfFormatOption::TEXT_RENDER_FORMAT].compare( QStringLiteral( "AlwaysText" ), Qt::CaseInsensitive ) == 0 )
2346 {
2348 }
2349 else if ( options[PdfFormatOption::TEXT_RENDER_FORMAT].compare( QStringLiteral( "PreferText" ), Qt::CaseInsensitive ) == 0 )
2350 {
2352 }
2353 }
2354 return format;
2355 }
2356
2358 {
2359 bool losslessCompression = false;
2360 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2361 if ( options.contains( PdfFormatOption::LOSSLESS_IMAGE_COMPRESSION ) )
2362 {
2363 losslessCompression = QVariant( options[PdfFormatOption::LOSSLESS_IMAGE_COMPRESSION] ).toBool();
2364 }
2365 return losslessCompression;
2366 }
2367
2369 {
2370 bool disableTiledRaster = false;
2371 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2372 if ( options.contains( PdfFormatOption::DISABLE_TILED_RASTER_RENDERING ) )
2373 {
2374 disableTiledRaster = QVariant( options[PdfFormatOption::DISABLE_TILED_RASTER_RENDERING] ).toBool();
2375 }
2376 return disableTiledRaster;
2377 }
2378
2380 {
2381 bool useIso32000 = true;
2382 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2384 {
2385 useIso32000 = QVariant( options[PdfFormatOption::USE_ISO_32000_EXTENSION_FORMAT_GEOREFERENCING] ).toBool();
2386 }
2387 return useIso32000;
2388 }
2389
2391 {
2392 bool useOgcGeoreferencing = false;
2393 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2395 {
2396 useOgcGeoreferencing = QVariant( options[PdfFormatOption::USE_OGC_BEST_PRACTICE_FORMAT_GEOREFERENCING] ).toBool();
2397 }
2398 return useOgcGeoreferencing;
2399 }
2400
2402 {
2403 QStringList themes;
2404 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2405 if ( options.contains( PdfFormatOption::EXPORT_THEMES ) )
2406 {
2407 themes = options[PdfFormatOption::EXPORT_THEMES].split( ',' );
2408 }
2409 return themes;
2410 }
2411
2413 {
2414 QVector<qreal> scales;
2415 const QMap<QgsWmsParameters::PdfFormatOption, QString> options = formatOptions<QgsWmsParameters::PdfFormatOption>();
2416 if ( options.contains( PdfFormatOption::PREDEFINED_MAP_SCALES ) )
2417 {
2418 const QStringList scaleList = options[PdfFormatOption::PREDEFINED_MAP_SCALES].split( ',' );
2419 for ( const QString &it : std::as_const( scaleList ) )
2420 {
2421 bool ok = false;
2422 qreal scale = it.toDouble( &ok );
2423 if ( ok )
2424 {
2425 scales.append( scale );
2426 }
2427 }
2428 }
2429 return scales;
2430 }
2431
2432 QMap<QString, QString> QgsWmsParameters::dimensionValues() const
2433 {
2434 QMap<QString, QString> dimValues;
2435 const QMetaEnum pnMetaEnum( QMetaEnum::fromType<QgsMapLayerServerProperties::PredefinedWmsDimensionName>() );
2436 const QStringList unmanagedNames = mUnmanagedParameters.keys();
2437 for ( const QString &key : unmanagedNames )
2438 {
2439 if ( key.startsWith( QLatin1String( "DIM_" ) ) )
2440 {
2441 dimValues[key.mid( 4 )] = mUnmanagedParameters[key];
2442 }
2443 else if ( pnMetaEnum.keyToValue( key.toUpper().toStdString().c_str() ) != -1 )
2444 {
2445 dimValues[key] = mUnmanagedParameters[key];
2446 }
2447 }
2448 return dimValues;
2449 }
2450}
@ Info
Information message.
Definition qgis.h:155
TextRenderFormat
Options for rendering text.
Definition qgis.h:2624
@ PreferText
Render text as text objects, unless doing so results in rendering artifacts or poor quality rendering...
@ 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:5147
@ 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 setSynchronousLegendRequests(bool b)
Sets whether to request legend graphics synchronously.
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.
QgsWmsParameter(const QgsWmsParameter::Name name=QgsWmsParameter::UNKNOWN, const QMetaType::Type type=QMetaType::Type::QString, const QVariant defaultValue=QVariant(""))
Constructor for QgsWmsParameter.
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.
QColor toColor() const
Converts the parameter into a color.
QgsWmsParameter::Name mName
QList< int > toIntList(const char delimiter=',') const
Converts the parameter into a list of integers.
QStringList toStyleList(const char delimiter=',') const
Converts the parameter into a list of strings and keeps empty parts Default style value is an empty s...
QString loadUrl() const
Loads the data associated to the parameter converted into an url.
Provides an interface to retrieve and manipulate WMS parameters received from the client.
bool htmlInfoOnlyMapTip() const
Returns true if only maptip information is requested for HTML feature info response.
QString rule() const
Returns RULE parameter or an empty string if none is defined.
QString layerTitle() const
Returns LAYERTITLE parameter or an empty string if not defined.
double layerSpaceAsDouble() const
Returns LAYERSPACE as a double or its default value if not defined.
QString boxSpace() const
Returns BOXSPACE parameter or an empty string if not defined.
QString wmsPrecision() const
Returns WMS_PRECISION parameter or an empty string if not defined.
double dxfScale() const
Returns the DXF SCALE parameter.
QString featureCount() const
Returns FEATURE_COUNT parameter or an empty string if none is defined.
QFont layerFont() const
Returns the layer font (built thanks to the LAYERFONTFAMILY, LAYERFONTSIZE, LAYERFONTBOLD,...
QList< int > opacitiesAsInt() const
Returns the list of opacities found in OPACITIES parameter as integers.
bool transparentAsBool() const
Returns TRANSPARENT parameter as a bool or its default value if not defined.
QString transparent() const
Returns TRANSPARENT parameter or an empty string if not defined.
QList< int > highlightLabelWeightAsInt() const
Returns HIGHLIGHT_LABELWEIGHT as a list of int.
QString iconLabelSpace() const
Returns ICONLABELSPACE parameter or an empty string if not defined.
QString layerTitleSpace() const
Returns LAYERTITLESPACE parameter or an empty string if not defined.
QString x() const
Returns X parameter or an empty string if not defined.
QString layerSpace() const
Returns LAYERSPACE parameter or an empty string if not defined.
int wmsPrecisionAsInt() const
Returns WMS_PRECISION parameter as an int or its default value if not defined.
QStringList highlightLabelBufferSize() const
Returns HIGHLIGHT_LABELBUFFERSIZE.
QStringList allLayersNickname() const
Returns nickname of layers found in LAYER and LAYERS parameters.
QString formatAsString() const
Returns FORMAT parameter as a string.
double layerFontSizeAsDouble() const
Returns LAYERFONTSIZE as a double.
QString externalWMSUri(const QString &id) const
Returns the external WMS uri.
QgsProjectVersion versionAsNumber() const
Returns VERSION parameter if defined or its default value.
QString scale() const
Returns SCALE parameter or an empty string if none is defined.
QString ruleLabel() const
Returns RULELABEL parameter or an empty string if none is defined.
double scaleAsDouble() const
Returns SCALE as a double.
bool layerFontItalicAsBool() const
Returns LAYERFONTITALIC as a boolean or its default value if not defined.
QgsWmsParametersComposerMap composerMapParameters(int mapId) const
Returns the requested parameters for a composer map parameter.
QgsRectangle bboxAsRectangle() const
Returns BBOX as a rectangle if defined and valid.
bool withGeometry() const
Returns if the client wants the feature info response with geometry information.
QStringList highlightLabelString() const
Returns HIGHLIGHT_LABELSTRING as a list of string.
QString tiled() const
Returns TILED parameter or an empty string if not defined.
QString layerFontSize() const
Returns LAYERFONTSIZE parameter or an empty string if not defined.
QList< QColor > highlightLabelColorAsColor() const
Returns HIGHLIGHT_LABELCOLOR as a list of color.
bool itemFontBoldAsBool() const
Returns ITEMFONTBOLD as a boolean or its default value if not defined.
QStringList highlightLabelHorizontalAlignment() const
Returns HIGHLIGHT_LABEL_HORIZONTAL_ALIGNMENT as a list of string.
void set(QgsWmsParameter::Name name, const QVariant &value)
Sets a parameter value thanks to its name.
QString pointTolerance() const
Returns FI_POINT_TOLERANCE parameter or an empty string if not defined.
QString filterGeom() const
Returns the filter geometry found in FILTER_GEOM parameter.
QString composerTemplate() const
Returns TEMPLATE parameter or an empty string if not defined.
Format infoFormat() const
Returns infoFormat.
QString dxfCodec() const
Returns the DXF CODEC parameter.
QString y() const
Returns Y parameter or an empty string if not defined.
QString srcHeight() const
Returns SRCHEIGHT parameter or an empty string if not defined.
double dpiAsDouble() const
Returns DPI parameter as an int or its default value if not defined.
QStringList highlightLabelVerticalAlignment() const
Returns HIGHLIGHT_LABEL_VERTICAL_ALIGNMENT as a list of string.
void dump() const
Dumps parameters.
int pointToleranceAsInt() const
Returns FI_POINT_TOLERANCE parameter as an integer.
bool withMapTip() const
withMapTip
QString polygonTolerance() const
Returns FI_POLYGON_TOLERANCE parameter or an empty string if not defined.
QStringList highlightGeom() const
Returns HIGHLIGHT_GEOM as a list of string in WKT.
QString i() const
Returns I parameter or an empty string if not defined.
bool pdfLosslessImageCompression() const
Returns true if images embedded in pdf must be compressed using a lossless algorithm.
QList< QColor > highlightLabelBufferColorAsColor() const
Returns HIGHLIGHT_LABELBUFFERCOLOR as a list of colors.
QString request() const override
Returns REQUEST parameter as a string or an empty string if not defined.
double layerTitleSpaceAsDouble() const
Returns LAYERTITLESPACE as a double.
QList< QgsWmsParametersLayer > layersParameters() const
Returns parameters for each layer found in LAYER/LAYERS.
int lineToleranceAsInt() const
Returns FI_LINE_TOLERANCE parameter as an integer.
QList< double > highlightLabelBufferSizeAsFloat() const
Returns HIGHLIGHT_LABELBUFFERSIZE as a list of float.
QString lineTolerance() const
Returns FI_LINE_TOLERANCE parameter or an empty string if not defined.
bool showFeatureCountAsBool() const
Returns SHOWFEATURECOUNT as a bool.
QStringList pdfExportMapThemes() const
Returns map themes for geospatial PDF export.
bool pdfUseOgcBestPracticeFormatGeoreferencing() const
Returns true if OGC best practice georeferencing shall be used.
QStringList highlightLabelColor() const
Returns HIGHLIGHT_LABELCOLOR as a list of string.
bool pdfExportMetadata() const
Returns true if metadata shall be added to the pdf.
bool versionIsValid(const QString version) const
Returns true if version is valid, false otherwise.
QString j() const
Returns J parameter or an empty string if not defined.
int xAsInt() const
Returns X parameter as an int or its default value if not defined.
QColor layerFontColorAsColor() const
Returns LAYERFONTCOLOR as a color or its defined value if not defined.
QString bbox() const
Returns BBOX if defined or an empty string.
QgsWmsParameters()
Constructor for WMS parameters with default values only.
int heightAsInt() const
Returns HEIGHT parameter as an int or its default value if not defined.
QStringList highlightLabelWeight() const
Returns HIGHLIGHT_LABELWEIGHT as a list of string.
QString backgroundColor() const
Returns BGCOLOR parameter or an empty string if not defined.
QStringList allStyles() const
Returns styles found in STYLE and STYLES parameters.
double symbolWidthAsDouble() const
Returns SYMBOLWIDTH as a double or its default value if not defined.
QColor backgroundColorAsColor() const
Returns BGCOLOR parameter as a QColor or its default value if not defined.
Format format() const
Returns format.
QgsWmsParameter operator[](QgsWmsParameter::Name name) const
Returns the parameter corresponding to name.
QString itemFontSize() const
Returns ITEMFONTSIZE parameter or an empty string if not defined.
QStringList atlasPk() const
Returns the ATLAS_PK parameter.
QList< QgsGeometry > highlightGeomAsGeom() const
Returns HIGHLIGHT_GEOM as a list of geometries.
QString layerFontFamily() const
Returns LAYERFONTFAMILY parameter or an empty string if not defined.
QString withMapTipAsString() const
withMapTipAsString
QList< QgsWmsParametersHighlightLayer > highlightLayersParameters() const
Returns parameters for each highlight layer.
int iAsInt() const
Returns I parameter as an int or its default value if not defined.
QStringList highlightLabelBufferColor() const
Returns HIGHLIGHT_LABELBUFFERCOLOR as a list of string.
bool pdfAppendGeoreference() const
Returns true if georeference info shall be added to the pdf.
int polygonToleranceAsInt() const
Returns FI_POLYGON_TOLERANCE parameter as an integer.
bool ruleLabelAsBool() const
Returns RULELABEL as a bool.
QList< double > highlightLabelDistance() const
Returns HIGHLIGHT_LABEL_DISTANCE as a list of double.
QList< int > highlightLabelSizeAsInt() const
Returns HIGHLIGHT_LABELSIZE as a list of int An exception is raised if an invalid size is found.
int widthAsInt() const
Returns WIDTH parameter as an int or its default value if not defined.
QString sldBody() const
Returns SLD_body if defined or an empty string.
bool itemFontItalicAsBool() const
Returns ITEMFONTITALIC as a boolean or its default value if not defined.
bool pdfDisableTiledRasterRendering() const
Returns true if rasters shall be untiled in the pdf.
QColor itemFontColorAsColor() const
Returns ITEMFONTCOLOR as a color.
double itemFontSizeAsDouble() const
Returns ITEMFONTSIZE as a double.
QString layerFontColor() const
Returns LAYERFONTCOLOR parameter or an empty string if not defined.
QString layoutParameter(const QString &id, bool &ok) const
Returns a layout parameter thanks to its id.
bool dxfUseLayerTitleAsName() const
Returns the DXF USE_TITLE_AS_LAYERNAME parameter.
QString symbolHeight() const
Returns SYMBOLHEIGHT parameter or an empty string if not defined.
int imageQualityAsInt() const
Returns IMAGE_QUALITY parameter as an integer.
bool pdfForceVectorOutput() const
Returns if pdf should be exported as vector.
bool writeGeospatialPdf() const
Returns if a geospatial PDF shall be exported.
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.
Qgis::FeatureSymbologyExport dxfMode() const
Returns the DXF MODE parameter.
QStringList highlightLabelSize() const
Returns HIGHLIGHT_LABELSIZE as a list of string.
QString imageQuality() const
Returns IMAGE_QUALITY parameter or an empty string if not defined.
QList< double > highlightLabelRotation() const
Returns HIGHLIGHT_LABEL_ROTATION as a list of double.
QString height() const
Returns HEIGHT parameter or an empty string if not defined.
QString crs() const
Returns CRS or an empty string if none is defined.
bool showRuleDetailsAsBool() const
Returns SHOWRULEDETAILS as a bool.
QStringList selections() const
Returns the list of feature selection found in SELECTION parameter.
int featureCountAsInt() const
Returns FEATURE_COUNT as an integer.
int yAsInt() const
Returns Y parameter as an int or its default value if not defined.
bool layerTitleAsBool() const
Returns LAYERTITLE as a bool or its default value if not defined.
QString itemFontColor() const
Returns ITEMFONTCOLOR parameter or an empty string if not defined.
double boxSpaceAsDouble() const
Returns BOXSPACE as a double or its default value if not defined.
bool addLayerGroups() const
Returns true if layer groups shall be added to GetLegendGraphic results.
QString symbolWidth() const
Returns SYMBOLWIDTH parameter or an empty string if not defined.
bool tiledAsBool() const
Returns TILED parameter as a boolean.
Format
Output format for the response.
QString width() const
Returns WIDTH parameter or an empty string if not defined.
QFont itemFont() const
Returns the item font (built thanks to the ITEMFONTFAMILY, ITEMFONTSIZE, ITEMFONTBOLD,...
QStringList opacities() const
Returns the list of opacities found in OPACITIES parameter.
QString version() const override
Returns VERSION parameter as a string or an empty string if not defined.
QString layerFontItalic() const
Returns LAYERFONTITALIC parameter or an empty string if not defined.
QString itemFontItalic() const
Returns ITEMFONTITALIC parameter or an empty string if not defined.
QStringList filters() const
Returns the list of filters found in FILTER parameter.
QString dpi() const
Returns DPI parameter or an empty string if not defined.
QString itemFontFamily() const
Returns ITEMFONTFAMILY parameter or an empty string if not defined.
int jAsInt() const
Returns J parameter as an int or its default value if not defined.
QVector< qreal > pdfPredefinedMapScales() const
Returns list of map scales.
QString showFeatureCount() const
Returns SHOWFEATURECOUNT parameter or an empty string if none is defined.
bool pdfSimplifyGeometries() const
Returns if geometries shall to be simplified.
bool layerFontBoldAsBool() const
Returns LAYERFONTBOLD as a boolean or its default value if not defined.
double iconLabelSpaceAsDouble() const
Returns ICONLABELSPACE as a double or its default value if not defined.
QStringList highlightSymbol() const
Returns HIGHLIGHT_SYMBOL as a list of string.
QStringList queryLayersNickname() const
Returns nickname of layers found in QUERY_LAYERS parameter.
double symbolHeightAsDouble() const
Returns SYMBOLHEIGHT as a double or its default value if not defined.
bool infoFormatIsImage() const
Checks if INFO_FORMAT parameter is one of the image formats (PNG, JPG).
int srcWidthAsInt() const
Returns SRCWIDTH parameter as an int or its default value if not defined.
Median cut implementation.
const QString EXTERNAL_LAYER_PREFIX
QList< QgsWmsParametersLayer > mLayers
QList< QgsWmsParametersHighlightLayer > mHighlightLayers
QgsWmsParametersFilter::Type mType
QgsOgcUtils::FilterVersion mVersion
QList< QgsWmsParametersFilter > mFilter