1 /*************************************************************************** 2 qgswmsparameters.h 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 #ifndef QGSWMSPARAMETERS_H 19 #define QGSWMSPARAMETERS_H 20 21 #include <QMap> 22 #include <QMetaEnum> 23 #include <QColor> 24 25 #include "qgsrectangle.h" 26 #include "qgslegendsettings.h" 27 #include "qgsprojectversion.h" 28 #include "qgsogcutils.h" 29 #include "qgsserverparameters.h" 30 #include "qgsdxfexport.h" 31 32 namespace QgsWms 33 { 34 struct QgsWmsParametersFilter 35 { 36 //! Filter type 37 enum Type 38 { 39 UNKNOWN, 40 SQL, 41 OGC_FE 42 }; 43 44 QString mFilter; 45 QgsWmsParametersFilter::Type mType = QgsWmsParametersFilter::UNKNOWN; 46 QgsOgcUtils::FilterVersion mVersion = QgsOgcUtils::FILTER_OGC_1_0; // only if FE 47 }; 48 49 struct QgsWmsParametersLayer 50 { 51 QString mNickname; // name, id or short name 52 int mOpacity = -1; 53 QList<QgsWmsParametersFilter> mFilter; // list of filter 54 QStringList mSelection; // list of string fid 55 QString mStyle; 56 QString mExternalUri; 57 }; 58 59 struct QgsWmsParametersExternalLayer 60 { 61 QString mName; 62 QString mUri; 63 }; 64 65 struct QgsWmsParametersHighlightLayer 66 { 67 QString mName; 68 QgsGeometry mGeom; 69 QString mSld; 70 QString mLabel; 71 QColor mColor; 72 int mSize = 0; 73 int mWeight = 0; 74 QString mFont; 75 float mBufferSize = 0; 76 QColor mBufferColor; 77 }; 78 79 struct QgsWmsParametersComposerMap 80 { 81 int mId = 0; // composer map id 82 bool mHasExtent = false; // does the request contains extent for this composer map 83 QgsRectangle mExtent; // the request extent for this composer map 84 float mScale = -1; 85 float mRotation = 0; 86 float mGridX = 0; 87 float mGridY = 0; 88 QList<QgsWmsParametersLayer> mLayers; // list of layers for this composer map 89 QList<QgsWmsParametersHighlightLayer> mHighlightLayers; // list of highlight layers for this composer map 90 }; 91 92 /** 93 * \ingroup server 94 * \class QgsWmsParameter 95 * \brief WMS parameter received from the client. 96 * \since QGIS 3.4 97 */ 98 class QgsWmsParameter : public QgsServerParameterDefinition 99 { 100 Q_GADGET 101 102 public: 103 //! Available parameters for WMS requests 104 enum Name 105 { 106 UNKNOWN, 107 BOXSPACE, 108 CRS, 109 SRS, 110 WIDTH, 111 HEIGHT, 112 BBOX, 113 ICONLABELSPACE, 114 IMAGE_QUALITY, 115 ITEMFONTFAMILY, 116 ITEMFONTBOLD, 117 ITEMFONTITALIC, 118 ITEMFONTSIZE, 119 ITEMFONTCOLOR, 120 LAYER, 121 LAYERFONTFAMILY, 122 LAYERFONTBOLD, 123 LAYERFONTITALIC, 124 LAYERFONTSIZE, 125 LAYERFONTCOLOR, 126 LAYERTITLE, 127 LAYERS, 128 LAYERSPACE, 129 LAYERTITLESPACE, 130 QUERY_LAYERS, 131 FEATURE_COUNT, 132 SHOWFEATURECOUNT, 133 STYLE, 134 STYLES, 135 SYMBOLSPACE, 136 SYMBOLHEIGHT, 137 SYMBOLWIDTH, 138 OPACITIES, 139 SLD, 140 SLD_BODY, 141 FI_POLYGON_TOLERANCE, 142 FI_LINE_TOLERANCE, 143 FI_POINT_TOLERANCE, 144 FILTER, 145 FILTER_GEOM, 146 FORMAT, 147 INFO_FORMAT, 148 I, 149 J, 150 X, 151 Y, 152 RULE, 153 RULELABEL, 154 SCALE, 155 SELECTION, 156 HIGHLIGHT_GEOM, 157 HIGHLIGHT_SYMBOL, 158 HIGHLIGHT_LABELSTRING, 159 HIGHLIGHT_LABELFONT, 160 HIGHLIGHT_LABELSIZE, 161 HIGHLIGHT_LABELWEIGHT, 162 HIGHLIGHT_LABELCOLOR, 163 HIGHLIGHT_LABELBUFFERCOLOR, 164 HIGHLIGHT_LABELBUFFERSIZE, 165 WMS_PRECISION, 166 TRANSPARENT, 167 BGCOLOR, 168 DPI, 169 TEMPLATE, 170 EXTENT, 171 ROTATION, 172 GRID_INTERVAL_X, 173 GRID_INTERVAL_Y, 174 WITH_GEOMETRY, 175 WITH_MAPTIP, 176 WMTVER, 177 ATLAS_PK, 178 FORMAT_OPTIONS, 179 SRCWIDTH, 180 SRCHEIGHT, 181 TILED 182 }; 183 Q_ENUM( Name ) 184 185 /** 186 * Constructor for QgsWmsParameter. 187 * \param name Name of the WMS parameter 188 * \param type Type of the parameter 189 * \param defaultValue Default value of the parameter 190 */ 191 QgsWmsParameter( const QgsWmsParameter::Name name = QgsWmsParameter::UNKNOWN, 192 const QVariant::Type type = QVariant::String, 193 const QVariant defaultValue = QVariant( "" ) ); 194 195 /** 196 * Default destructor for QgsWmsParameter. 197 */ 198 virtual ~QgsWmsParameter() override = default; 199 200 /** 201 * Returns TRUE if the parameter is valid, FALSE otherwise. 202 */ 203 bool isValid() const override; 204 205 /** 206 * Converts the parameter into a list of strings and keeps empty parts 207 * Default style value is an empty string 208 * \param delimiter The character used for delimiting 209 * \returns A list of strings 210 * \since QGIS 3.8 211 */ 212 QStringList toStyleList( const char delimiter = ',' ) const; 213 214 /** 215 * Converts the parameter into a list of geometries. 216 * \param delimiter The character delimiting string geometries 217 * \returns A list of geometries 218 * \throws QgsBadRequestException Invalid parameter exception 219 */ 220 QList<QgsGeometry> toGeomList( const char delimiter = ',' ) const; 221 222 /** 223 * Converts the parameter into a list of integers. 224 * \param delimiter The character delimiting string integers 225 * \returns A list of integers 226 * \throws QgsBadRequestException Invalid parameter exception 227 */ 228 QList<int> toIntList( const char delimiter = ',' ) const; 229 230 /** 231 * Converts the parameter into a list of doubles. 232 * \param delimiter The character delimiting string doubles 233 * \returns A list of doubles 234 * \throws QgsBadRequestException Invalid parameter exception 235 */ 236 QList<double> toDoubleList( const char delimiter = ',' ) const; 237 238 /** 239 * Converts the parameter into a list of colors. 240 * \param delimiter The character delimiting string colors 241 * \returns A list of colors 242 * \throws QgsBadRequestException Invalid parameter exception 243 */ 244 QList<QColor> toColorList( const char delimiter = ',' ) const; 245 246 /** 247 * Converts the parameter into a rectangle. 248 * \returns A rectangle 249 * \throws QgsBadRequestException Invalid parameter exception 250 */ 251 QgsRectangle toRectangle() const; 252 253 /** 254 * Converts the parameter into an integer. 255 * \returns An integer 256 * \throws QgsBadRequestException Invalid parameter exception 257 */ 258 int toInt() const; 259 260 /** 261 * Converts the parameter into a double. 262 * \returns A double 263 * \throws QgsBadRequestException Invalid parameter exception 264 */ 265 double toDouble() const; 266 267 /** 268 * Converts the parameter into a color. 269 * \returns A color 270 * \throws QgsBadRequestException Invalid parameter exception 271 */ 272 QColor toColor() const; 273 274 /** 275 * Converts the parameter into an url. 276 * \returns An url 277 * \throws QgsBadRequestException Invalid parameter exception 278 * \since QGIS 3.4 279 */ 280 QUrl toUrl() const; 281 282 /** 283 * Loads the data associated to the parameter converted into an url. 284 * \returns The content loaded 285 * \throws QgsBadRequestException Invalid parameter exception 286 * \since QGIS 3.4 287 */ 288 QString loadUrl() const; 289 290 /** 291 * Raises an error in case of an invalid conversion. 292 * \throws QgsBadRequestException Invalid parameter exception 293 */ 294 void raiseError() const; 295 296 /** 297 * Returns the name of the parameter. 298 * \since QGIS 3.8 299 */ 300 QString name() const; 301 302 /** 303 * Converts a parameter's name into its string representation. 304 */ 305 static QString name( const QgsWmsParameter::Name ); 306 307 /** 308 * Converts a string into a parameter's name (UNKNOWN in case of an 309 * invalid string). 310 */ 311 static QgsWmsParameter::Name name( const QString &name ); 312 313 QgsWmsParameter::Name mName; 314 int mId = -1; 315 }; 316 317 /** 318 * \ingroup server 319 * \class QgsWms::QgsWmsParameters 320 * \brief Provides an interface to retrieve and manipulate WMS parameters received from the client. 321 * \since QGIS 3.0 322 */ 323 class QgsWmsParameters : public QgsServerParameters 324 { 325 Q_GADGET 326 327 public: 328 329 //! Output format for the response 330 enum Format 331 { 332 NONE, 333 JPG, 334 PNG, 335 SVG, 336 PDF, 337 TEXT, 338 XML, 339 HTML, 340 GML, 341 JSON 342 }; 343 Q_ENUM( Format ) 344 345 //! Options for DXF format 346 enum DxfFormatOption 347 { 348 SCALE, 349 MODE, 350 LAYERATTRIBUTES, 351 USE_TITLE_AS_LAYERNAME, 352 CODEC, 353 NO_MTEXT, 354 FORCE_2D 355 }; 356 Q_ENUM( DxfFormatOption ) 357 358 /** 359 * Constructor for WMS parameters with specific values. 360 * \param parameters Map of parameters where keys are parameters' names. 361 */ 362 QgsWmsParameters( const QgsServerParameters ¶meters ); 363 364 /** 365 * Constructor for WMS parameters with default values only. 366 */ 367 QgsWmsParameters(); 368 369 virtual ~QgsWmsParameters() override = default; 370 371 /** 372 * Returns the parameter corresponding to \a name. 373 * \since QGIS 3.8 374 */ 375 QgsWmsParameter operator[]( QgsWmsParameter::Name name ) const; 376 377 /** 378 * Sets a parameter \a value thanks to its \a name. 379 * \since QGIS 3.8 380 */ 381 void set( QgsWmsParameter::Name name, const QVariant &value ); 382 383 /** 384 * Dumps parameters. 385 */ 386 void dump() const; 387 388 /** 389 * Returns CRS or an empty string if none is defined. 390 * \returns crs parameter as string 391 */ 392 QString crs() const; 393 394 /** 395 * Returns WIDTH parameter or an empty string if not defined. 396 * \returns width parameter 397 */ 398 QString width() const; 399 400 /** 401 * Returns WIDTH parameter as an int or its default value if not 402 * defined. An exception is raised if WIDTH is defined and cannot be 403 * converted. 404 * \returns width parameter 405 * \throws QgsBadRequestException 406 */ 407 int widthAsInt() const; 408 409 /** 410 * Returns HEIGHT parameter or an empty string if not defined. 411 * \returns height parameter 412 */ 413 QString height() const; 414 415 /** 416 * Returns HEIGHT parameter as an int or its default value if not 417 * defined. An exception is raised if HEIGHT is defined and cannot be 418 * converted. 419 * \returns height parameter 420 * \throws QgsBadRequestException 421 */ 422 int heightAsInt() const; 423 424 /** 425 * Returns SRCWIDTH parameter or an empty string if not defined. 426 * \returns srcWidth parameter 427 * \since QGIS 3.8 428 */ 429 QString srcWidth() const; 430 431 /** 432 * Returns SRCWIDTH parameter as an int or its default value if not 433 * defined. An exception is raised if SRCWIDTH is defined and cannot be 434 * converted. 435 * \returns srcWidth parameter 436 * \throws QgsBadRequestException 437 * \since QGIS 3.8 438 */ 439 int srcWidthAsInt() const; 440 441 /** 442 * Returns SRCHEIGHT parameter or an empty string if not defined. 443 * \returns srcHeight parameter 444 * \since QGIS 3.8 445 */ 446 QString srcHeight() const; 447 448 /** 449 * Returns SRCHEIGHT parameter as an int or its default value if not 450 * defined. An exception is raised if SRCHEIGHT is defined and cannot be 451 * converted. 452 * \returns srcHeight parameter 453 * \throws QgsBadRequestException 454 * \since QGIS 3.8 455 */ 456 int srcHeightAsInt() const; 457 458 /** 459 * Returns VERSION parameter if defined or its default value. 460 * \returns version 461 */ 462 QgsProjectVersion versionAsNumber() const; 463 464 /** 465 * Returns TRUE if \a version is valid, FALSE otherwise. 466 * \since QGIS 3.4 467 */ 468 bool versionIsValid( const QString version ) const; 469 470 /** 471 * Returns BBOX if defined or an empty string. 472 * \returns bbox parameter 473 */ 474 QString bbox() const; 475 476 /** 477 * Returns BBOX as a rectangle if defined and valid. An exception is 478 * raised if the BBOX string cannot be converted into a rectangle. 479 * \returns bbox as rectangle 480 * \throws QgsBadRequestException 481 */ 482 QgsRectangle bboxAsRectangle() const; 483 484 /** 485 * Returns SLD_body if defined or an empty string. 486 * \returns sld body 487 */ 488 QString sldBody() const; 489 490 /** 491 * Returns the list of feature selection found in SELECTION parameter. 492 * \returns the list of selection 493 */ 494 QStringList selections() const; 495 496 /** 497 * Returns the list of filters found in FILTER parameter. 498 * \returns the list of filter 499 */ 500 QStringList filters() const; 501 502 /** 503 * Returns the filter geometry found in FILTER_GEOM parameter. 504 * \returns the filter geometry as Well Known Text. 505 */ 506 QString filterGeom() const; 507 508 /** 509 * Returns the list of opacities found in OPACITIES parameter. 510 * \returns the list of opacities in string 511 */ 512 QStringList opacities() const; 513 514 /** 515 * Returns the list of opacities found in OPACITIES parameter as 516 * integers. If an opacity cannot be converted into an integer, then an 517 * exception is raised 518 * \returns a list of opacities as integers 519 * \throws QgsBadRequestException 520 */ 521 QList<int> opacitiesAsInt() const; 522 523 /** 524 * Returns nickname of layers found in LAYER and LAYERS parameters. 525 * \returns nickname of layers 526 */ 527 QStringList allLayersNickname() const; 528 529 /** 530 * Returns nickname of layers found in QUERY_LAYERS parameter. 531 * \returns nickname of layers 532 */ 533 QStringList queryLayersNickname() const; 534 535 /** 536 * Returns styles found in STYLE and STYLES parameters. 537 * \returns name of styles 538 */ 539 QStringList allStyles() const; 540 541 /** 542 * Returns parameters for each layer found in LAYER/LAYERS. 543 * \returns layer parameters 544 */ 545 QList<QgsWmsParametersLayer> layersParameters() const; 546 547 /** 548 * Returns FI_POLYGON_TOLERANCE parameter or an empty string if not 549 * defined. 550 * \since QGIS 3.4 551 */ 552 QString polygonTolerance() const; 553 554 /** 555 * Returns FI_LINE_TOLERANCE parameter or an empty string if not 556 * defined. 557 * \since QGIS 3.4 558 */ 559 QString lineTolerance() const; 560 561 /** 562 * Returns FI_POINT_TOLERANCE parameter or an empty string if not 563 * defined. 564 * \since QGIS 3.4 565 */ 566 QString pointTolerance() const; 567 568 /** 569 * Returns FI_POLYGON_TOLERANCE parameter as an integer. 570 * \throws QgsBadRequestException 571 * \since QGIS 3.4 572 */ 573 int polygonToleranceAsInt() const; 574 575 /** 576 * Returns FI_LINE_TOLERANCE parameter as an integer. 577 * \throws QgsBadRequestException 578 * \since QGIS 3.4 579 */ 580 int lineToleranceAsInt() const; 581 582 /** 583 * Returns FI_POINT_TOLERANCE parameter as an integer. 584 * \throws QgsBadRequestException 585 * \since QGIS 3.4 586 */ 587 int pointToleranceAsInt() const; 588 589 /** 590 * Returns FORMAT parameter as a string. 591 * \returns FORMAT parameter as string 592 */ 593 QString formatAsString() const; 594 595 /** 596 * Returns format parameter as a string. 597 * \since QGIS 3.8 598 */ 599 static QString formatAsString( Format format ); 600 601 /** 602 * Returns format. If the FORMAT parameter is not used, then the 603 * default value is PNG. 604 * \returns format 605 */ 606 Format format() const; 607 608 /** 609 * Returns INFO_FORMAT parameter as a string. 610 * \returns INFO_FORMAT parameter as string 611 */ 612 QString infoFormatAsString() const; 613 614 /** 615 * Checks if INFO_FORMAT parameter is one of the image formats (PNG, JPG). 616 * \returns TRUE if the INFO_FORMAT is an image format 617 */ 618 bool infoFormatIsImage() const; 619 620 /** 621 * Returns IMAGE_QUALITY parameter or an empty string if not 622 * defined. 623 * \since QGIS 3.4 624 */ 625 QString imageQuality() const; 626 627 /** 628 * Returns IMAGE_QUALITY parameter as an integer. 629 * \throws QgsBadRequestException 630 * \since QGIS 3.4 631 */ 632 int imageQualityAsInt() const; 633 634 /** 635 * Returns TILED parameter or an empty string if not 636 * defined. 637 * \since QGIS 3.10 638 */ 639 QString tiled() const; 640 641 /** 642 * Returns TILED parameter as a boolean. 643 * \throws QgsBadRequestException 644 * \since QGIS 3.10 645 */ 646 bool tiledAsBool() const; 647 648 /** 649 * Returns infoFormat. If the INFO_FORMAT parameter is not used, then the 650 * default value is text/plain. 651 * \returns infoFormat 652 */ 653 Format infoFormat() const; 654 655 /** 656 * Returns the infoFormat version for GML. If the INFO_FORMAT is not GML, 657 * then the default value is -1. 658 * \returns infoFormat version 659 */ 660 int infoFormatVersion() const; 661 662 /** 663 * Returns I parameter or an empty string if not defined. 664 * \returns i parameter 665 */ 666 QString i() const; 667 668 /** 669 * Returns I parameter as an int or its default value if not 670 * defined. An exception is raised if I is defined and cannot be 671 * converted. 672 * \returns i parameter 673 * \throws QgsBadRequestException 674 */ 675 int iAsInt() const; 676 677 /** 678 * Returns J parameter or an empty string if not defined. 679 * \returns j parameter 680 */ 681 QString j() const; 682 683 /** 684 * Returns J parameter as an int or its default value if not 685 * defined. An exception is raised if J is defined and cannot be 686 * converted. 687 * \returns j parameter 688 * \throws QgsBadRequestException 689 */ 690 int jAsInt() const; 691 692 /** 693 * Returns X parameter or an empty string if not defined. 694 * \returns x parameter 695 */ 696 QString x() const; 697 698 /** 699 * Returns X parameter as an int or its default value if not 700 * defined. An exception is raised if X is defined and cannot be 701 * converted. 702 * \returns x parameter 703 * \throws QgsBadRequestException 704 */ 705 int xAsInt() const; 706 707 /** 708 * Returns Y parameter or an empty string if not defined. 709 * \returns y parameter 710 */ 711 QString y() const; 712 713 /** 714 * Returns Y parameter as an int or its default value if not 715 * defined. An exception is raised if Y is defined and cannot be 716 * converted. 717 * \returns j parameter 718 * \throws QgsBadRequestException 719 */ 720 int yAsInt() const; 721 722 /** 723 * Returns RULE parameter or an empty string if none is defined 724 * \returns RULE parameter or an empty string if none is defined 725 */ 726 QString rule() const; 727 728 /** 729 * Returns RULELABEL parameter or an empty string if none is defined 730 * \returns RULELABEL parameter or an empty string if none is defined 731 */ 732 QString ruleLabel() const; 733 734 /** 735 * Returns RULELABEL as a bool. An exception is raised if an invalid 736 * parameter is found. 737 * \returns ruleLabel 738 * \throws QgsBadRequestException 739 */ 740 bool ruleLabelAsBool() const; 741 742 /** 743 * Returns SHOWFEATURECOUNT parameter or an empty string if none is defined 744 * \returns SHOWFEATURECOUNT parameter or an empty string if none is defined 745 */ 746 QString showFeatureCount() const; 747 748 /** 749 * Returns SHOWFEATURECOUNT as a bool. An exception is raised if an invalid 750 * parameter is found. 751 * \returns showFeatureCount 752 * \throws QgsBadRequestException 753 */ 754 bool showFeatureCountAsBool() const; 755 756 /** 757 * Returns FEATURE_COUNT parameter or an empty string if none is defined 758 * \returns FEATURE_COUNT parameter or an empty string if none is defined 759 */ 760 QString featureCount() const; 761 762 /** 763 * Returns FEATURE_COUNT as an integer. An exception is raised if an invalid 764 * parameter is found. 765 * \returns FeatureCount 766 * \throws QgsBadRequestException 767 */ 768 int featureCountAsInt() const; 769 770 /** 771 * Returns SCALE parameter or an empty string if none is defined 772 * \returns SCALE parameter or an empty string if none is defined 773 */ 774 QString scale() const; 775 776 /** 777 * Returns SCALE as a double. An exception is raised if an invalid 778 * parameter is found. 779 * \returns scale 780 * \throws QgsBadRequestException 781 */ 782 double scaleAsDouble() const; 783 784 /** 785 * Returns BOXSPACE parameter or an empty string if not defined. 786 * \returns BOXSPACE parameter or an empty string if not defined. 787 */ 788 QString boxSpace() const; 789 790 /** 791 * Returns BOXSPACE as a double or its default value if not defined. 792 * An exception is raised if an invalid parameter is found. 793 * \returns boxSpace 794 * \throws QgsBadRequestException 795 */ 796 double boxSpaceAsDouble() const; 797 798 /** 799 * Returns LAYERSPACE parameter or an empty string if not defined. 800 * \returns LAYERSPACE parameter or an empty string if not defined. 801 */ 802 QString layerSpace() const; 803 804 /** 805 * Returns LAYERSPACE as a double or its default value if not defined. 806 * An exception is raised if an invalid parameter is found. 807 * \returns layerSpace 808 * \throws QgsBadRequestException 809 */ 810 double layerSpaceAsDouble() const; 811 812 /** 813 * Returns LAYERTITLESPACE parameter or an empty string if not defined. 814 * \returns LAYERTITLESPACE parameter or an empty string if not defined. 815 */ 816 QString layerTitleSpace() const; 817 818 /** 819 * Returns LAYERTITLESPACE as a double. An exception is raised if an invalid 820 * parameter is found. 821 * \returns layerTitleSpace 822 * \throws QgsBadRequestException 823 */ 824 double layerTitleSpaceAsDouble() const; 825 826 /** 827 * Returns SYMBOLSPACE parameter or an empty string if not defined. 828 * \returns SYMBOLSPACE parameter or an empty string if not defined. 829 */ 830 QString symbolSpace() const; 831 832 /** 833 * Returns SYMBOLSPACE as a double or its default value if not defined. 834 * An exception is raised if an invalid parameter is found. 835 * \returns symbolSpace 836 * \throws QgsBadRequestException 837 */ 838 double symbolSpaceAsDouble() const; 839 840 /** 841 * Returns ICONLABELSPACE parameter or an empty string if not defined. 842 * \returns ICONLABELSPACE parameter or an empty string if not defined. 843 */ 844 QString iconLabelSpace() const; 845 846 /** 847 * Returns ICONLABELSPACE as a double or its default value if not 848 * defined. An exception is raised if an invalid parameter is found. 849 * \returns iconLabelSpace 850 * \throws QgsBadRequestException 851 */ 852 double iconLabelSpaceAsDouble() const; 853 854 /** 855 * Returns SYMBOLWIDTH parameter or an empty string if not defined. 856 * \returns SYMBOLWIDTH parameter or an empty string if not defined. 857 */ 858 QString symbolWidth() const; 859 860 /** 861 * Returns SYMBOLWIDTH as a double or its default value if not defined. 862 * An exception is raised if an invalid parameter is found. 863 * \returns symbolWidth 864 * \throws QgsBadRequestException 865 */ 866 double symbolWidthAsDouble() const; 867 868 /** 869 * Returns SYMBOLHEIGHT parameter or an empty string if not defined. 870 * \returns SYMBOLHEIGHT parameter or an empty string if not defined. 871 */ 872 QString symbolHeight() const; 873 874 /** 875 * Returns SYMBOLHEIGHT as a double or its default value if not defined. 876 * An exception is raised if an invalid parameter is found. 877 * \returns symbolHeight 878 * \throws QgsBadRequestException 879 */ 880 double symbolHeightAsDouble() const; 881 882 /** 883 * Returns the layer font (built thanks to the LAYERFONTFAMILY, 884 * LAYERFONTSIZE, LAYERFONTBOLD, ... parameters). 885 * \returns layerFont 886 */ 887 QFont layerFont() const; 888 889 /** 890 * Returns LAYERFONTFAMILY parameter or an empty string if not defined. 891 * \returns LAYERFONTFAMILY parameter or an empty string if not defined. 892 */ 893 QString layerFontFamily() const; 894 895 /** 896 * Returns LAYERFONTBOLD parameter or an empty string if not defined. 897 * \returns LAYERFONTBOLD parameter or an empty string if not defined. 898 */ 899 QString layerFontBold() const; 900 901 /** 902 * Returns LAYERFONTBOLD as a boolean or its default value if not 903 * defined. An exception is raised if an invalid parameter is found. 904 * \returns layerFontBold 905 * \throws QgsBadRequestException 906 */ 907 bool layerFontBoldAsBool() const; 908 909 /** 910 * Returns LAYERFONTITALIC parameter or an empty string if not defined. 911 * \returns LAYERFONTITALIC parameter or an empty string if not defined. 912 */ 913 QString layerFontItalic() const; 914 915 /** 916 * Returns LAYERFONTITALIC as a boolean or its default value if not 917 * defined. An exception is raised if an invalid parameter is found. 918 * \returns layerFontItalic 919 * \throws QgsBadRequestException 920 */ 921 bool layerFontItalicAsBool() const; 922 923 /** 924 * Returns LAYERFONTSIZE parameter or an empty string if not defined. 925 * \returns LAYERFONTSIZE parameter or an empty string if not defined. 926 */ 927 QString layerFontSize() const; 928 929 /** 930 * Returns LAYERFONTSIZE as a double. An exception is raised if an invalid 931 * parameter is found. 932 * \returns layerFontSize 933 * \throws QgsBadRequestException 934 */ 935 double layerFontSizeAsDouble() const; 936 937 /** 938 * Returns LAYERFONTCOLOR parameter or an empty string if not defined. 939 * \returns LAYERFONTCOLOR parameter or an empty string if not defined. 940 */ 941 QString layerFontColor() const; 942 943 /** 944 * Returns LAYERFONTCOLOR as a color or its defined value if not 945 * defined. An exception is raised if an invalid parameter is found. 946 * \returns layerFontColor 947 * \throws QgsBadRequestException 948 */ 949 QColor layerFontColorAsColor() const; 950 951 /** 952 * Returns the item font (built thanks to the ITEMFONTFAMILY, 953 * ITEMFONTSIZE, ITEMFONTBOLD, ... parameters). 954 * \returns itemFont 955 */ 956 QFont itemFont() const; 957 958 /** 959 * Returns ITEMFONTFAMILY parameter or an empty string if not defined. 960 * \returns ITEMFONTFAMILY parameter or an empty string if not defined. 961 */ 962 QString itemFontFamily() const; 963 964 /** 965 * Returns ITEMFONTBOLD parameter or an empty string if not defined. 966 * \returns ITEMFONTBOLD parameter or an empty string if not defined. 967 */ 968 QString itemFontBold() const; 969 970 /** 971 * Returns ITEMFONTBOLD as a boolean or its default value if not 972 * defined. An exception is raised if an invalid parameter is found. 973 * \returns itemFontBold 974 * \throws QgsBadRequestException 975 */ 976 bool itemFontBoldAsBool() const; 977 978 /** 979 * Returns ITEMFONTITALIC parameter or an empty string if not defined. 980 * \returns ITEMFONTITALIC parameter or an empty string if not defined. 981 */ 982 QString itemFontItalic() const; 983 984 /** 985 * Returns ITEMFONTITALIC as a boolean or its default value if not 986 * defined. An exception is raised if an invalid parameter is found. 987 * \returns itemFontItalic 988 * \throws QgsBadRequestException 989 */ 990 bool itemFontItalicAsBool() const; 991 992 /** 993 * Returns ITEMFONTSIZE parameter or an empty string if not defined. 994 * \returns ITEMFONTSIZE parameter or an empty string if not defined. 995 */ 996 QString itemFontSize() const; 997 998 /** 999 * Returns ITEMFONTSIZE as a double. An exception is raised if an 1000 * invalid parameter is found. 1001 * \returns itemFontSize 1002 * \throws QgsBadRequestException 1003 */ 1004 double itemFontSizeAsDouble() const; 1005 1006 /** 1007 * Returns ITEMFONTCOLOR parameter or an empty string if not defined. 1008 * \returns ITEMFONTCOLOR parameter or an empty string if not defined. 1009 */ 1010 QString itemFontColor() const; 1011 1012 /** 1013 * Returns ITEMFONTCOLOR as a color. An exception is raised if an 1014 * invalid parameter is found. 1015 * \returns itemFontColor 1016 * \throws QgsBadRequestException 1017 */ 1018 QColor itemFontColorAsColor() const; 1019 1020 /** 1021 * Returns LAYERTITLE parameter or an empty string if not defined. 1022 * \returns LAYERTITLE parameter or an empty string if not defined. 1023 */ 1024 QString layerTitle() const; 1025 1026 /** 1027 * Returns LAYERTITLE as a bool or its default value if not defined. An 1028 * exception is raised if an invalid parameter is found. 1029 * \returns layerTitle 1030 * \throws QgsBadRequestException 1031 */ 1032 bool layerTitleAsBool() const; 1033 1034 /** 1035 * Returns legend settings 1036 * \returns legend settings 1037 */ 1038 QgsLegendSettings legendSettings() const; 1039 1040 /** 1041 * Returns parameters for each highlight layer. 1042 * \returns parameters for each highlight layer 1043 */ 1044 QList<QgsWmsParametersHighlightLayer> highlightLayersParameters() const; 1045 1046 /** 1047 * Returns parameters for each external layer. 1048 * \since QGIS 3.8 1049 */ 1050 QList<QgsWmsParametersExternalLayer> externalLayersParameters() const; 1051 1052 /** 1053 * Returns HIGHLIGHT_GEOM as a list of string in WKT. 1054 * \returns highlight geometries 1055 */ 1056 QStringList highlightGeom() const; 1057 1058 /** 1059 * Returns HIGHLIGHT_GEOM as a list of geometries. An exception is 1060 * raised if an invalid geometry is found. 1061 * \returns highlight geometries 1062 * \throws QgsBadRequestException 1063 */ 1064 QList<QgsGeometry> highlightGeomAsGeom() const; 1065 1066 /** 1067 * Returns HIGHLIGHT_SYMBOL as a list of string. 1068 * \returns highlight sld symbols 1069 */ 1070 QStringList highlightSymbol() const; 1071 1072 /** 1073 * Returns HIGHLIGHT_LABELSTRING as a list of string. 1074 * \returns highlight label string 1075 */ 1076 QStringList highlightLabelString() const; 1077 1078 /** 1079 * Returns HIGHLIGHT_LABELCOLOR as a list of string. 1080 * \returns highlight label color 1081 */ 1082 QStringList highlightLabelColor() const; 1083 1084 /** 1085 * Returns HIGHLIGHT_LABELCOLOR as a list of color. An exception is 1086 * raised if an invalid color is found. 1087 * \returns highlight label color 1088 * \throws QgsBadRequestException 1089 */ 1090 QList<QColor> highlightLabelColorAsColor() const; 1091 1092 /** 1093 * Returns HIGHLIGHT_LABELSIZE as a list of string. 1094 * \returns highlight label size 1095 */ 1096 QStringList highlightLabelSize() const; 1097 1098 /** 1099 * Returns HIGHLIGHT_LABELSIZE as a list of int An exception is raised 1100 * if an invalid size is found. 1101 * \returns highlight label size 1102 * \throws QgsBadRequestException 1103 */ 1104 QList<int> highlightLabelSizeAsInt() const; 1105 1106 /** 1107 * Returns HIGHLIGHT_LABELWEIGHT as a list of string. 1108 * \returns highlight label weight 1109 */ 1110 QStringList highlightLabelWeight() const; 1111 1112 /** 1113 * Returns HIGHLIGHT_LABELWEIGHT as a list of int. An exception is 1114 * raised if an invalid weight is found. 1115 * \returns highlight label weight 1116 * \throws QgsBadRequestException 1117 */ 1118 QList<int> highlightLabelWeightAsInt() const; 1119 1120 /** 1121 * Returns HIGHLIGHT_LABELFONT 1122 * \returns highlight label font 1123 */ 1124 QStringList highlightLabelFont() const; 1125 1126 /** 1127 * Returns HIGHLIGHT_LABELBUFFERSIZE 1128 * \returns highlight label buffer size 1129 */ 1130 QStringList highlightLabelBufferSize() const; 1131 1132 /** 1133 * Returns HIGHLIGHT_LABELBUFFERSIZE as a list of float. An exception is 1134 * raised if an invalid size is found. 1135 * \returns highlight label buffer size 1136 * \throws QgsBadRequestException 1137 */ 1138 QList<double> highlightLabelBufferSizeAsFloat() const; 1139 1140 /** 1141 * Returns HIGHLIGHT_LABELBUFFERCOLOR as a list of string. 1142 * \returns highlight label buffer color 1143 */ 1144 QStringList highlightLabelBufferColor() const; 1145 1146 /** 1147 * Returns HIGHLIGHT_LABELBUFFERCOLOR as a list of colors. An axception 1148 * is raised if an invalid color is found. 1149 * \returns highlight label buffer color 1150 * \throws QgsBadRequestException 1151 */ 1152 QList<QColor> highlightLabelBufferColorAsColor() const; 1153 1154 /** 1155 * Returns WMS_PRECISION parameter or an empty string if not defined. 1156 * \returns wms precision parameter 1157 */ 1158 QString wmsPrecision() const; 1159 1160 /** 1161 * Returns WMS_PRECISION parameter as an int or its default value if not 1162 * defined. An exception is raised if WMS_PRECISION is defined and cannot be 1163 * converted. 1164 * \returns wms precision parameter 1165 * \throws QgsBadRequestException 1166 */ 1167 int wmsPrecisionAsInt() const; 1168 1169 /** 1170 * Returns TRANSPARENT parameter or an empty string if not defined. 1171 * \returns TRANSPARENT parameter 1172 */ 1173 QString transparent() const; 1174 1175 /** 1176 * Returns TRANSPARENT parameter as a bool or its default value if not 1177 * defined. An exception is raised if TRANSPARENT is defined and cannot 1178 * be converted. 1179 * \returns transparent parameter 1180 * \throws QgsBadRequestException 1181 */ 1182 bool transparentAsBool() const; 1183 1184 /** 1185 * Returns BGCOLOR parameter or an empty string if not defined. 1186 * \returns BGCOLOR parameter 1187 */ 1188 QString backgroundColor() const; 1189 1190 /** 1191 * Returns BGCOLOR parameter as a QColor or its default value if not 1192 * defined. An exception is raised if BGCOLOR is defined and cannot 1193 * be converted. 1194 * \returns background color parameter 1195 * \throws QgsBadRequestException 1196 */ 1197 QColor backgroundColorAsColor() const; 1198 1199 /** 1200 * Returns DPI parameter or an empty string if not defined. 1201 * \returns DPI parameter 1202 */ 1203 QString dpi() const; 1204 1205 /** 1206 * Returns DPI parameter as an int or its default value if not 1207 * defined. An exception is raised if DPI is defined and cannot 1208 * be converted. 1209 * \returns dpi parameter 1210 * \throws QgsBadRequestException 1211 */ 1212 double dpiAsDouble() const; 1213 1214 /** 1215 * Returns TEMPLATE parameter or an empty string if not defined. 1216 * \returns TEMPLATE parameter 1217 */ 1218 QString composerTemplate() const; 1219 1220 /** 1221 * Returns the requested parameters for a composer map parameter. 1222 * An exception is raised if parameters are defined and cannot be 1223 * converted like EXTENT, SCALE, ROTATION, GRID_INTERVAL_X and 1224 * GRID_INTERVAL_Y. 1225 * \param mapId the composer map id. 1226 * \returns parameters for the composer map. 1227 * \throws QgsBadRequestException 1228 */ 1229 QgsWmsParametersComposerMap composerMapParameters( int mapId ) const; 1230 1231 /** 1232 * Returns the external WMS uri 1233 * \param id the id of the external wms 1234 * \return uri string or an empty string if the external wms id does not exist 1235 */ 1236 QString externalWMSUri( const QString &id ) const; 1237 1238 /** 1239 * Returns if the client wants the feature info response with geometry information 1240 * \returns TRUE if geometry information is requested for feature info response 1241 */ 1242 bool withGeometry() const; 1243 1244 /** 1245 * \brief withMapTip 1246 * \returns TRUE if maptip information is requested for feature info response 1247 */ 1248 bool withMapTip() const; 1249 1250 /** 1251 * Returns WMTVER parameter or an empty string if not defined. 1252 * \since QGIS 3.4 1253 */ 1254 QString wmtver() const; 1255 1256 /** 1257 * Returns a layout parameter thanks to its \a id. 1258 * \param id Parameter id 1259 * \param ok TRUE if the parameter is valid, FALSE otherwise 1260 * \returns The layout parameter 1261 * \since QGIS 3.4 1262 */ 1263 QString layoutParameter( const QString &id, bool &ok ) const; 1264 1265 /** 1266 * Returns the ATLAS_PK parameter 1267 * \returns The ATLAS_PK parameter 1268 * \since QGIS 3.6 1269 */ 1270 QStringList atlasPk() const; 1271 1272 /** 1273 * Returns a map of DXF options defined within FORMAT_OPTIONS parameter. 1274 * \since QGIS 3.8 1275 */ 1276 QMap<DxfFormatOption, QString> dxfFormatOptions() const; 1277 1278 /** 1279 * Returns the DXF LAYERATTRIBUTES parameter. 1280 * \since QGIS 3.8 1281 */ 1282 QStringList dxfLayerAttributes() const; 1283 1284 /** 1285 * Returns the DXF USE_TITLE_AS_LAYERNAME parameter. 1286 * \since QGIS 3.8 1287 */ 1288 bool dxfUseLayerTitleAsName() const; 1289 1290 /** 1291 * Returns the DXF SCALE parameter. 1292 * \since QGIS 3.8 1293 */ 1294 double dxfScale() const; 1295 1296 /** 1297 * Returns the DXF MODE parameter. 1298 * \since QGIS 3.8 1299 */ 1300 QgsDxfExport::SymbologyExport dxfMode() const; 1301 1302 /** 1303 * Returns the DXF CODEC parameter. 1304 * \since QGIS 3.8 1305 */ 1306 QString dxfCodec() const; 1307 1308 /** 1309 * Returns the dimensions parameter. 1310 * \since QGIS 3.10 1311 */ 1312 QMap<QString, QString> dimensionValues() const; 1313 1314 /** 1315 * \returns true if the FORCE_MTEXT parameter is set and the DXF should 1316 * be produced with MTEXT instead of TEXT. 1317 * 1318 * \since QGIS 3.12 1319 */ 1320 bool noMText() const; 1321 1322 /** 1323 * \returns true if the FORCE_2D parameter is set and the DXF should 1324 * be produced in 2D. 1325 * 1326 * \since QGIS 3.12 1327 */ 1328 bool isForce2D() const; 1329 1330 private: 1331 static bool isExternalLayer( const QString &name ); 1332 1333 bool loadParameter( const QString &name, const QString &value ) override; 1334 1335 void save( const QgsWmsParameter ¶meter, bool multi = false ); 1336 1337 QgsWmsParameter idParameter( QgsWmsParameter::Name name, int id ) const; 1338 1339 void raiseError( const QString &msg ) const; 1340 void log( const QString &msg ) const; 1341 1342 QgsWmsParametersExternalLayer externalLayerParameter( const QString &name ) const; 1343 1344 QMultiMap<QString, QgsWmsParametersFilter> layerFilters( const QStringList &layers ) const; 1345 1346 1347 QMap<QgsWmsParameter::Name, QgsWmsParameter> mWmsParameters; 1348 QMap<QString, QMap<QString, QString> > mExternalWMSParameters; 1349 QList<QgsProjectVersion> mVersions; 1350 }; 1351 } 1352 1353 #endif 1354