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