QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 "qgslegendsettings.h"
27 #include "qgsprojectversion.h"
28 #include "qgsogcutils.h"
29 #include "qgsserverparameters.h"
30 #include "qgsdxfexport.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;
61  QString mUri;
62  };
63 
65  {
66  QString mName;
68  QString mSld;
69  QString mLabel;
70  QColor mColor;
71  int mSize = 0;
72  int mWeight = 0;
73  QString mFont;
74  float mBufferSize = 0;
75  QColor mBufferColor;
76  };
77 
79  {
80  int mId = 0; // composer map id
81  bool mHasExtent = false; // does the request contains extent for this composer map
82  QgsRectangle mExtent; // the request extent for this composer map
83  float mScale = -1;
84  float mRotation = 0;
85  float mGridX = 0;
86  float mGridY = 0;
87  QList<QgsWmsParametersLayer> mLayers; // list of layers for this composer map
88  QList<QgsWmsParametersExternalLayer> mExternalLayers; // list of external layers for this composer map
89  QList<QgsWmsParametersHighlightLayer> mHighlightLayers; // list of highlight layers for this composer map
90  };
91 
99  {
100  Q_GADGET
101 
102  public:
104  enum Name
105  {
148  I,
149  J,
150  X,
151  Y,
180  SRCHEIGHT
181  };
182  Q_ENUM( Name )
183 
184 
191  const QVariant::Type type = QVariant::String,
192  const QVariant defaultValue = QVariant( "" ) );
193 
197  virtual ~QgsWmsParameter() override = default;
198 
202  bool isValid() const override;
203 
211  QStringList toStyleList( const char delimiter = ',' ) const;
212 
219  QList<QgsGeometry> toGeomList( const char delimiter = ',' ) const;
220 
227  QList<int> toIntList( const char delimiter = ',' ) const;
228 
235  QList<double> toDoubleList( const char delimiter = ',' ) const;
236 
243  QList<QColor> toColorList( const char delimiter = ',' ) const;
244 
250  QgsRectangle toRectangle() const;
251 
257  int toInt() const;
258 
264  double toDouble() const;
265 
271  QColor toColor() const;
272 
279  QUrl toUrl() const;
280 
287  QString loadUrl() const;
288 
293  void raiseError() const;
294 
299  QString name() const;
300 
304  static QString name( const QgsWmsParameter::Name );
305 
310  static QgsWmsParameter::Name name( const QString &name );
311 
313  int mId = -1;
314  };
315 
323  {
324  Q_GADGET
325 
326  public:
327 
329  enum Format
330  {
340  JSON
341  };
342  Q_ENUM( Format )
343 
344 
346  {
351  CODEC
352  };
353  Q_ENUM( DxfFormatOption )
354 
355 
359  QgsWmsParameters( const QgsServerParameters &parameters );
360 
365 
366  virtual ~QgsWmsParameters() override = default;
367 
372  QgsWmsParameter operator[]( QgsWmsParameter::Name name ) const;
373 
378  void set( QgsWmsParameter::Name name, const QVariant &value );
379 
383  void dump() const;
384 
389  QString crs() const;
390 
395  QString width() const;
396 
404  int widthAsInt() const;
405 
410  QString height() const;
411 
419  int heightAsInt() const;
420 
426  QString srcWidth() const;
427 
436  int srcWidthAsInt() const;
437 
443  QString srcHeight() const;
444 
453  int srcHeightAsInt() const;
454 
459  QgsProjectVersion versionAsNumber() const;
460 
465  bool versionIsValid( const QString version ) const;
466 
471  QString bbox() const;
472 
479  QgsRectangle bboxAsRectangle() const;
480 
485  QString sldBody() const;
486 
491  QStringList selections() const;
492 
497  QStringList filters() const;
498 
503  QString filterGeom() const;
504 
509  QStringList opacities() const;
510 
518  QList<int> opacitiesAsInt() const;
519 
524  QStringList allLayersNickname() const;
525 
530  QStringList queryLayersNickname() const;
531 
536  QStringList allStyles() const;
537 
542  QList<QgsWmsParametersLayer> layersParameters() const;
543 
549  QString polygonTolerance() const;
550 
556  QString lineTolerance() const;
557 
563  QString pointTolerance() const;
564 
570  int polygonToleranceAsInt() const;
571 
577  int lineToleranceAsInt() const;
578 
584  int pointToleranceAsInt() const;
585 
590  QString formatAsString() const;
591 
596  static QString formatAsString( Format format );
597 
603  Format format() const;
604 
609  QString infoFormatAsString() const;
610 
615  bool infoFormatIsImage() const;
616 
622  QString imageQuality() const;
623 
629  int imageQualityAsInt() const;
630 
636  Format infoFormat() const;
637 
643  int infoFormatVersion() const;
644 
649  QString i() const;
650 
658  int iAsInt() const;
659 
664  QString j() const;
665 
673  int jAsInt() const;
674 
679  QString x() const;
680 
688  int xAsInt() const;
689 
694  QString y() const;
695 
703  int yAsInt() const;
704 
709  QString rule() const;
710 
715  QString ruleLabel() const;
716 
723  bool ruleLabelAsBool() const;
724 
729  QString showFeatureCount() const;
730 
737  bool showFeatureCountAsBool() const;
738 
743  QString featureCount() const;
744 
751  int featureCountAsInt() const;
752 
757  QString scale() const;
758 
765  double scaleAsDouble() const;
766 
771  QString boxSpace() const;
772 
779  double boxSpaceAsDouble() const;
780 
785  QString layerSpace() const;
786 
793  double layerSpaceAsDouble() const;
794 
799  QString layerTitleSpace() const;
800 
807  double layerTitleSpaceAsDouble() const;
808 
813  QString symbolSpace() const;
814 
821  double symbolSpaceAsDouble() const;
822 
827  QString iconLabelSpace() const;
828 
835  double iconLabelSpaceAsDouble() const;
836 
841  QString symbolWidth() const;
842 
849  double symbolWidthAsDouble() const;
850 
855  QString symbolHeight() const;
856 
863  double symbolHeightAsDouble() const;
864 
870  QFont layerFont() const;
871 
876  QString layerFontFamily() const;
877 
882  QString layerFontBold() const;
883 
890  bool layerFontBoldAsBool() const;
891 
896  QString layerFontItalic() const;
897 
904  bool layerFontItalicAsBool() const;
905 
910  QString layerFontSize() const;
911 
918  double layerFontSizeAsDouble() const;
919 
924  QString layerFontColor() const;
925 
932  QColor layerFontColorAsColor() const;
933 
939  QFont itemFont() const;
940 
945  QString itemFontFamily() const;
946 
951  QString itemFontBold() const;
952 
959  bool itemFontBoldAsBool() const;
960 
965  QString itemFontItalic() const;
966 
973  bool itemFontItalicAsBool() const;
974 
979  QString itemFontSize() const;
980 
987  double itemFontSizeAsDouble() const;
988 
993  QString itemFontColor() const;
994 
1001  QColor itemFontColorAsColor() const;
1002 
1007  QString layerTitle() const;
1008 
1015  bool layerTitleAsBool() const;
1016 
1021  QgsLegendSettings legendSettings() const;
1022 
1027  QList<QgsWmsParametersHighlightLayer> highlightLayersParameters() const;
1028 
1033  QList<QgsWmsParametersExternalLayer> externalLayersParameters() const;
1034 
1039  QStringList highlightGeom() const;
1040 
1047  QList<QgsGeometry> highlightGeomAsGeom() const;
1048 
1053  QStringList highlightSymbol() const;
1054 
1059  QStringList highlightLabelString() const;
1060 
1065  QStringList highlightLabelColor() const;
1066 
1073  QList<QColor> highlightLabelColorAsColor() const;
1074 
1079  QStringList highlightLabelSize() const;
1080 
1087  QList<int> highlightLabelSizeAsInt() const;
1088 
1093  QStringList highlightLabelWeight() const;
1094 
1101  QList<int> highlightLabelWeightAsInt() const;
1102 
1107  QStringList highlightLabelFont() const;
1108 
1113  QStringList highlightLabelBufferSize() const;
1114 
1121  QList<double> highlightLabelBufferSizeAsFloat() const;
1122 
1127  QStringList highlightLabelBufferColor() const;
1128 
1135  QList<QColor> highlightLabelBufferColorAsColor() const;
1136 
1141  QString wmsPrecision() const;
1142 
1150  int wmsPrecisionAsInt() const;
1151 
1156  QString transparent() const;
1157 
1165  bool transparentAsBool() const;
1166 
1171  QString backgroundColor() const;
1172 
1180  QColor backgroundColorAsColor() const;
1181 
1186  QString dpi() const;
1187 
1195  double dpiAsDouble() const;
1196 
1201  QString composerTemplate() const;
1202 
1212  QgsWmsParametersComposerMap composerMapParameters( int mapId ) const;
1213 
1219  QString externalWMSUri( const QString &id ) const;
1220 
1225  bool withGeometry() const;
1226 
1231  bool withMapTip() const;
1232 
1237  QString wmtver() const;
1238 
1246  QString layoutParameter( const QString &id, bool &ok ) const;
1247 
1253  QStringList atlasPk() const;
1254 
1259  QMap<DxfFormatOption, QString> dxfFormatOptions() const;
1260 
1265  QStringList dxfLayerAttributes() const;
1266 
1271  bool dxfUseLayerTitleAsName() const;
1272 
1277  double dxfScale() const;
1278 
1283  QgsDxfExport::SymbologyExport dxfMode() const;
1284 
1289  QString dxfCodec() const;
1290 
1291  private:
1292  static bool isExternalLayer( const QString &name );
1293 
1294  bool loadParameter( const QString &name, const QString &value ) override;
1295 
1296  void save( const QgsWmsParameter &parameter, bool multi = false );
1297 
1298  QgsWmsParameter idParameter( QgsWmsParameter::Name name, int id ) const;
1299 
1300  void raiseError( const QString &msg ) const;
1301  void log( const QString &msg ) const;
1302 
1303  QgsWmsParametersExternalLayer externalLayerParameter( const QString &name ) const;
1304 
1305  QMultiMap<QString, QgsWmsParametersFilter> layerFilters( const QStringList &layers ) const;
1306 
1307  QMap<QgsWmsParameter::Name, QgsWmsParameter> mWmsParameters;
1308  QMap<QString, QMap<QString, QString> > mExternalWMSParameters;
1309  QList<QgsProjectVersion> mVersions;
1310  };
1311 }
1312 
1313 #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:111
Format
Output format for the response.
const QgsCoordinateReferenceSystem & crs
DxfFormatOption
Options for DXF format.
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.
QList< QgsWmsParametersExternalLayer > mExternalLayers
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.