QGIS API Documentation  3.6.0-Noosa (5873452)
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 <QMetaEnum>
23 #include <QColor>
24 
25 #include "qgsrectangle.h"
26 #include "qgswmsserviceexception.h"
27 #include "qgslegendsettings.h"
28 #include "qgsprojectversion.h"
29 #include "qgsogcutils.h"
30 #include "qgsserverparameters.h"
31 
32 namespace QgsWms
33 {
35  {
37  enum Type
38  {
40  SQL,
42  };
43 
44  QString mFilter;
47  };
48 
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  };
57 
59  {
60  QString mName;
62  QString mSld;
63  QString mLabel;
64  QColor mColor;
65  int mSize = 0;
66  int mWeight = 0;
67  QString mFont;
68  float mBufferSize = 0;
69  QColor mBufferColor;
70  };
71 
73  {
74  int mId = 0; // composer map id
75  bool mHasExtent = false; // does the request contains extent for this composer map
76  QgsRectangle mExtent; // the request extent for this composer map
77  float mScale = -1;
78  float mRotation = 0;
79  float mGridX = 0;
80  float mGridY = 0;
81  QList<QgsWmsParametersLayer> mLayers; // list of layers for this composer map
82  QList<QgsWmsParametersHighlightLayer> mHighlightLayers; // list of highlight layers for this composer map
83  };
84 
92  {
93  Q_GADGET
94 
95  public:
97  enum Name
98  {
141  I,
142  J,
143  X,
144  Y,
170  ATLAS_PK
171  };
172  Q_ENUM( Name )
173 
174 
181  const QVariant::Type type = QVariant::String,
182  const QVariant defaultValue = QVariant( "" ) );
183 
187  virtual ~QgsWmsParameter() = default;
188 
192  bool isValid() const override;
193 
200  QList<QgsGeometry> toGeomList( const char delimiter = ',' ) const;
201 
208  QList<int> toIntList( const char delimiter = ',' ) const;
209 
216  QList<double> toDoubleList( const char delimiter = ',' ) const;
217 
224  QList<QColor> toColorList( const char delimiter = ',' ) const;
225 
231  QgsRectangle toRectangle() const;
232 
238  int toInt() const;
239 
245  double toDouble() const;
246 
252  QColor toColor() const;
253 
260  QUrl toUrl() const;
261 
268  QString loadUrl() const;
269 
274  void raiseError() const;
275 
279  static QString name( const QgsWmsParameter::Name );
280 
285  static QgsWmsParameter::Name name( const QString &name );
286 
288  int mId = -1;
289  };
290 
298  {
299  Q_GADGET
300 
301  public:
302 
304  enum Format
305  {
313  JSON
314  };
315 
320  QgsWmsParameters( const QgsServerParameters &parameters );
321 
326 
327  virtual ~QgsWmsParameters() = default;
328 
332  void dump() const;
333 
338  QString crs() const;
339 
344  QString width() const;
345 
353  int widthAsInt() const;
354 
359  QString height() const;
360 
368  int heightAsInt() const;
369 
374  QgsProjectVersion versionAsNumber() const;
375 
380  bool versionIsValid( const QString version ) const;
381 
386  QString bbox() const;
387 
394  QgsRectangle bboxAsRectangle() const;
395 
400  QString sldBody() const;
401 
406  QStringList selections() const;
407 
412  QStringList filters() const;
413 
418  QString filterGeom() const;
419 
424  QStringList opacities() const;
425 
433  QList<int> opacitiesAsInt() const;
434 
439  QStringList allLayersNickname() const;
440 
445  QStringList queryLayersNickname() const;
446 
451  QStringList allStyles() const;
452 
457  QList<QgsWmsParametersLayer> layersParameters() const;
458 
464  QString polygonTolerance() const;
465 
471  QString lineTolerance() const;
472 
478  QString pointTolerance() const;
479 
485  int polygonToleranceAsInt() const;
486 
492  int lineToleranceAsInt() const;
493 
499  int pointToleranceAsInt() const;
500 
505  QString formatAsString() const;
506 
512  Format format() const;
513 
518  QString infoFormatAsString() const;
519 
524  bool infoFormatIsImage() const;
525 
531  QString imageQuality() const;
532 
538  int imageQualityAsInt() const;
539 
545  Format infoFormat() const;
546 
552  int infoFormatVersion() const;
553 
558  QString i() const;
559 
567  int iAsInt() const;
568 
573  QString j() const;
574 
582  int jAsInt() const;
583 
588  QString x() const;
589 
597  int xAsInt() const;
598 
603  QString y() const;
604 
612  int yAsInt() const;
613 
618  QString rule() const;
619 
624  QString ruleLabel() const;
625 
632  bool ruleLabelAsBool() const;
633 
638  QString showFeatureCount() const;
639 
646  bool showFeatureCountAsBool() const;
647 
652  QString featureCount() const;
653 
660  int featureCountAsInt() const;
661 
666  QString scale() const;
667 
674  double scaleAsDouble() const;
675 
680  QString boxSpace() const;
681 
688  double boxSpaceAsDouble() const;
689 
694  QString layerSpace() const;
695 
702  double layerSpaceAsDouble() const;
703 
708  QString layerTitleSpace() const;
709 
716  double layerTitleSpaceAsDouble() const;
717 
722  QString symbolSpace() const;
723 
730  double symbolSpaceAsDouble() const;
731 
736  QString iconLabelSpace() const;
737 
744  double iconLabelSpaceAsDouble() const;
745 
750  QString symbolWidth() const;
751 
758  double symbolWidthAsDouble() const;
759 
764  QString symbolHeight() const;
765 
772  double symbolHeightAsDouble() const;
773 
779  QFont layerFont() const;
780 
785  QString layerFontFamily() const;
786 
791  QString layerFontBold() const;
792 
799  bool layerFontBoldAsBool() const;
800 
805  QString layerFontItalic() const;
806 
813  bool layerFontItalicAsBool() const;
814 
819  QString layerFontSize() const;
820 
827  double layerFontSizeAsDouble() const;
828 
833  QString layerFontColor() const;
834 
841  QColor layerFontColorAsColor() const;
842 
848  QFont itemFont() const;
849 
854  QString itemFontFamily() const;
855 
860  QString itemFontBold() const;
861 
868  bool itemFontBoldAsBool() const;
869 
874  QString itemFontItalic() const;
875 
882  bool itemFontItalicAsBool() const;
883 
888  QString itemFontSize() const;
889 
896  double itemFontSizeAsDouble() const;
897 
902  QString itemFontColor() const;
903 
910  QColor itemFontColorAsColor() const;
911 
916  QString layerTitle() const;
917 
924  bool layerTitleAsBool() const;
925 
930  QgsLegendSettings legendSettings() const;
931 
936  QList<QgsWmsParametersHighlightLayer> highlightLayersParameters() const;
937 
942  QStringList highlightGeom() const;
943 
950  QList<QgsGeometry> highlightGeomAsGeom() const;
951 
956  QStringList highlightSymbol() const;
957 
962  QStringList highlightLabelString() const;
963 
968  QStringList highlightLabelColor() const;
969 
976  QList<QColor> highlightLabelColorAsColor() const;
977 
982  QStringList highlightLabelSize() const;
983 
990  QList<int> highlightLabelSizeAsInt() const;
991 
996  QStringList highlightLabelWeight() const;
997 
1004  QList<int> highlightLabelWeightAsInt() const;
1005 
1010  QStringList highlightLabelFont() const;
1011 
1016  QStringList highlightLabelBufferSize() const;
1017 
1024  QList<double> highlightLabelBufferSizeAsFloat() const;
1025 
1030  QStringList highlightLabelBufferColor() const;
1031 
1038  QList<QColor> highlightLabelBufferColorAsColor() const;
1039 
1044  QString wmsPrecision() const;
1045 
1053  int wmsPrecisionAsInt() const;
1054 
1059  QString transparent() const;
1060 
1068  bool transparentAsBool() const;
1069 
1074  QString backgroundColor() const;
1075 
1083  QColor backgroundColorAsColor() const;
1084 
1089  QString dpi() const;
1090 
1098  double dpiAsDouble() const;
1099 
1104  QString composerTemplate() const;
1105 
1115  QgsWmsParametersComposerMap composerMapParameters( int mapId ) const;
1116 
1122  QString externalWMSUri( const QString &id ) const;
1123 
1128  bool withGeometry() const;
1129 
1134  bool withMapTip() const;
1135 
1140  QString wmtver() const;
1141 
1149  QString layoutParameter( const QString &id, bool &ok ) const;
1150 
1156  QStringList atlasPk() const;
1157 
1158  private:
1159  bool loadParameter( const QString &name, const QString &value ) override;
1160 
1161  void save( const QgsWmsParameter &parameter, bool multi = false );
1162 
1163  QgsWmsParameter idParameter( QgsWmsParameter::Name name, int id ) const;
1164 
1165  void raiseError( const QString &msg ) const;
1166  void log( const QString &msg ) const;
1167 
1168  QMultiMap<QString, QgsWmsParametersFilter> layerFilters( const QStringList &layers ) const;
1169 
1170  QMap<QgsWmsParameter::Name, QgsWmsParameter> mWmsParameters;
1171  QMap<QString, QMap<QString, QString> > mExternalWMSParameters;
1172  QList<QgsProjectVersion> mVersions;
1173  };
1174 }
1175 
1176 #endif
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsWmsParameter::Name mName
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:156
Median cut implementation.
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.