QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgswmsparameters.h
Go to the documentation of this file.
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 <QObject>
23 #include <QMetaEnum>
24 #include <QColor>
25 
26 #include "qgsrectangle.h"
27 #include "qgswmsserviceexception.h"
28 #include "qgsserverrequest.h"
29 #include "qgslegendsettings.h"
30 #include "qgsprojectversion.h"
31 #include "qgsogcutils.h"
32 #include "qgsserverparameters.h"
33 
34 namespace QgsWms
35 {
37  {
39  enum Type
40  {
42  SQL,
44  };
45 
46  QString mFilter;
49  };
50 
52  {
53  QString mNickname; // name, id or short name
54  int mOpacity = -1;
55  QList<QgsWmsParametersFilter> mFilter; // list of filter
56  QStringList mSelection; // list of string fid
57  QString mStyle;
58  };
59 
61  {
62  QString mName;
64  QString mSld;
65  QString mLabel;
66  QColor mColor;
67  int mSize = 0;
68  int mWeight = 0;
69  QString mFont;
70  float mBufferSize = 0;
71  QColor mBufferColor;
72  };
73 
75  {
76  int mId = 0; // composer map id
77  bool mHasExtent = false; // does the request contains extent for this composer map
78  QgsRectangle mExtent; // the request extent for this composer map
79  float mScale = -1;
80  float mRotation = 0;
81  float mGridX = 0;
82  float mGridY = 0;
83  QList<QgsWmsParametersLayer> mLayers; // list of layers for this composer map
84  QList<QgsWmsParametersHighlightLayer> mHighlightLayers; // list of highlight layers for this composer map
85  };
86 
94  {
95  Q_GADGET
96 
97  public:
99  enum Name
100  {
143  I,
144  J,
145  X,
146  Y,
173  SRCHEIGHT
174  };
175  Q_ENUM( Name )
176 
177 
184  const QVariant::Type type = QVariant::String,
185  const QVariant defaultValue = QVariant( "" ) );
186 
190  virtual ~QgsWmsParameter() override = default;
191 
195  bool isValid() const override;
196 
204  QStringList toStyleList( const char delimiter = ',' ) const;
205 
212  QList<QgsGeometry> toGeomList( const char delimiter = ',' ) const;
213 
220  QList<int> toIntList( const char delimiter = ',' ) const;
221 
228  QList<double> toDoubleList( const char delimiter = ',' ) const;
229 
236  QList<QColor> toColorList( const char delimiter = ',' ) const;
237 
243  QgsRectangle toRectangle() const;
244 
250  int toInt() const;
251 
257  double toDouble() const;
258 
264  QColor toColor() const;
265 
272  QUrl toUrl() const;
273 
280  QString loadUrl() const;
281 
286  void raiseError() const;
287 
291  static QString name( const QgsWmsParameter::Name );
292 
297  static QgsWmsParameter::Name name( const QString &name );
298 
299  QgsWmsParameter::Name mName;
300  int mId = -1;
301  };
302 
310  {
311  Q_GADGET
312 
313  public:
314 
316  enum Format
317  {
324  GML
325  };
326 
331  QgsWmsParameters( const QgsServerParameters &parameters );
332 
337 
338  virtual ~QgsWmsParameters() override = default;
339 
343  void dump() const;
344 
349  QString crs() const;
350 
355  QString width() const;
356 
364  int widthAsInt() const;
365 
370  QString height() const;
371 
379  int heightAsInt() const;
380 
386  QString srcWidth() const;
387 
396  int srcWidthAsInt() const;
397 
403  QString srcHeight() const;
404 
413  int srcHeightAsInt() const;
414 
419  QgsProjectVersion versionAsNumber() const;
420 
425  bool versionIsValid( const QString version ) const;
426 
431  QString bbox() const;
432 
439  QgsRectangle bboxAsRectangle() const;
440 
445  QString sldBody() const;
446 
451  QStringList selections() const;
452 
457  QStringList filters() const;
458 
463  QString filterGeom() const;
464 
469  QStringList opacities() const;
470 
478  QList<int> opacitiesAsInt() const;
479 
484  QStringList allLayersNickname() const;
485 
490  QStringList queryLayersNickname() const;
491 
496  QStringList allStyles() const;
497 
502  QList<QgsWmsParametersLayer> layersParameters() const;
503 
509  QString polygonTolerance() const;
510 
516  QString lineTolerance() const;
517 
523  QString pointTolerance() const;
524 
530  int polygonToleranceAsInt() const;
531 
537  int lineToleranceAsInt() const;
538 
544  int pointToleranceAsInt() const;
545 
550  QString formatAsString() const;
551 
557  Format format() const;
558 
563  QString infoFormatAsString() const;
564 
569  bool infoFormatIsImage() const;
570 
576  QString imageQuality() const;
577 
583  int imageQualityAsInt() const;
584 
590  Format infoFormat() const;
591 
597  int infoFormatVersion() const;
598 
603  QString i() const;
604 
612  int iAsInt() const;
613 
618  QString j() const;
619 
627  int jAsInt() const;
628 
633  QString x() const;
634 
642  int xAsInt() const;
643 
648  QString y() const;
649 
657  int yAsInt() const;
658 
663  QString rule() const;
664 
669  QString ruleLabel() const;
670 
677  bool ruleLabelAsBool() const;
678 
683  QString showFeatureCount() const;
684 
691  bool showFeatureCountAsBool() const;
692 
697  QString featureCount() const;
698 
705  int featureCountAsInt() const;
706 
711  QString scale() const;
712 
719  double scaleAsDouble() const;
720 
725  QString boxSpace() const;
726 
733  double boxSpaceAsDouble() const;
734 
739  QString layerSpace() const;
740 
747  double layerSpaceAsDouble() const;
748 
753  QString layerTitleSpace() const;
754 
761  double layerTitleSpaceAsDouble() const;
762 
767  QString symbolSpace() const;
768 
775  double symbolSpaceAsDouble() const;
776 
781  QString iconLabelSpace() const;
782 
789  double iconLabelSpaceAsDouble() const;
790 
795  QString symbolWidth() const;
796 
803  double symbolWidthAsDouble() const;
804 
809  QString symbolHeight() const;
810 
817  double symbolHeightAsDouble() const;
818 
824  QFont layerFont() const;
825 
830  QString layerFontFamily() const;
831 
836  QString layerFontBold() const;
837 
844  bool layerFontBoldAsBool() const;
845 
850  QString layerFontItalic() const;
851 
858  bool layerFontItalicAsBool() const;
859 
864  QString layerFontSize() const;
865 
872  double layerFontSizeAsDouble() const;
873 
878  QString layerFontColor() const;
879 
886  QColor layerFontColorAsColor() const;
887 
893  QFont itemFont() const;
894 
899  QString itemFontFamily() const;
900 
905  QString itemFontBold() const;
906 
913  bool itemFontBoldAsBool() const;
914 
919  QString itemFontItalic() const;
920 
927  bool itemFontItalicAsBool() const;
928 
933  QString itemFontSize() const;
934 
941  double itemFontSizeAsDouble() const;
942 
947  QString itemFontColor() const;
948 
955  QColor itemFontColorAsColor() const;
956 
961  QString layerTitle() const;
962 
969  bool layerTitleAsBool() const;
970 
975  QgsLegendSettings legendSettings() const;
976 
981  QList<QgsWmsParametersHighlightLayer> highlightLayersParameters() const;
982 
987  QStringList highlightGeom() const;
988 
995  QList<QgsGeometry> highlightGeomAsGeom() const;
996 
1001  QStringList highlightSymbol() const;
1002 
1007  QStringList highlightLabelString() const;
1008 
1013  QStringList highlightLabelColor() const;
1014 
1021  QList<QColor> highlightLabelColorAsColor() const;
1022 
1027  QStringList highlightLabelSize() const;
1028 
1035  QList<int> highlightLabelSizeAsInt() const;
1036 
1041  QStringList highlightLabelWeight() const;
1042 
1049  QList<int> highlightLabelWeightAsInt() const;
1050 
1055  QStringList highlightLabelFont() const;
1056 
1061  QStringList highlightLabelBufferSize() const;
1062 
1069  QList<double> highlightLabelBufferSizeAsFloat() const;
1070 
1075  QStringList highlightLabelBufferColor() const;
1076 
1083  QList<QColor> highlightLabelBufferColorAsColor() const;
1084 
1089  QString wmsPrecision() const;
1090 
1098  int wmsPrecisionAsInt() const;
1099 
1104  QString transparent() const;
1105 
1113  bool transparentAsBool() const;
1114 
1119  QString backgroundColor() const;
1120 
1128  QColor backgroundColorAsColor() const;
1129 
1134  QString dpi() const;
1135 
1143  double dpiAsDouble() const;
1144 
1149  QString composerTemplate() const;
1150 
1160  QgsWmsParametersComposerMap composerMapParameters( int mapId ) const;
1161 
1167  QString externalWMSUri( const QString &id ) const;
1168 
1173  bool withGeometry() const;
1174 
1179  bool withMapTip() const;
1180 
1185  QString wmtver() const;
1186 
1194  QString layoutParameter( const QString &id, bool &ok ) const;
1195 
1196  private:
1197  bool loadParameter( const QString &name, const QString &value ) override;
1198 
1199  void save( const QgsWmsParameter &parameter, bool multi = false );
1200 
1201  QgsWmsParameter idParameter( QgsWmsParameter::Name name, int id ) const;
1202 
1203  void raiseError( const QString &msg ) const;
1204  void log( const QString &msg ) const;
1205 
1206  QMultiMap<QString, QgsWmsParametersFilter> layerFilters( const QStringList &layers ) const;
1207 
1208  QMap<QgsWmsParameter::Name, QgsWmsParameter> mWmsParameters;
1209  QMap<QString, QMap<QString, QString> > mExternalWMSParameters;
1210  QList<QgsProjectVersion> mVersions;
1211 
1212  // Temporary workaround to be able to set defaults for SRCHEIGHT and SRCWIDTH in case of
1213  // contextual (BBOX) GetLegendGraphics, not necessary from 3.8
1214  friend class QgsRenderer;
1215  };
1216 }
1217 
1218 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:40
QList< QgsWmsParametersLayer > mLayers
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:106
Format
Output format for the response.
const QgsCoordinateReferenceSystem & crs
A class to describe the version of a project.
Provides an interface to retrieve and manipulate WMS parameters received from the client...
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
QList< QgsWmsParametersHighlightLayer > mHighlightLayers
QgsWmsParametersFilter::Type mType
QgsOgcUtils::FilterVersion mVersion
FilterVersion
OGC filter version.
Definition: qgsogcutils.h:157
Median cut implementation.
Map renderer for WMS requests.
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
QList< QgsWmsParametersFilter > mFilter
WMS parameter received from the client.
Name
Available parameters for WMS requests.
Definition of a parameter with basic conversion methods.