QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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,
181  TILED
182  };
183  Q_ENUM( Name )
184 
185 
192  const QVariant::Type type = QVariant::String,
193  const QVariant defaultValue = QVariant( "" ) );
194 
198  virtual ~QgsWmsParameter() override = default;
199 
203  bool isValid() const override;
204 
212  QStringList toStyleList( const char delimiter = ',' ) const;
213 
220  QList<QgsGeometry> toGeomList( const char delimiter = ',' ) const;
221 
228  QList<int> toIntList( const char delimiter = ',' ) const;
229 
236  QList<double> toDoubleList( const char delimiter = ',' ) const;
237 
244  QList<QColor> toColorList( const char delimiter = ',' ) const;
245 
251  QgsRectangle toRectangle() const;
252 
258  int toInt() const;
259 
265  double toDouble() const;
266 
272  QColor toColor() const;
273 
280  QUrl toUrl() const;
281 
288  QString loadUrl() const;
289 
294  void raiseError() const;
295 
300  QString name() const;
301 
305  static QString name( const QgsWmsParameter::Name );
306 
311  static QgsWmsParameter::Name name( const QString &name );
312 
314  int mId = -1;
315  };
316 
324  {
325  Q_GADGET
326 
327  public:
328 
330  enum Format
331  {
341  JSON
342  };
343  Q_ENUM( Format )
344 
345 
347  {
352  CODEC
353  };
354  Q_ENUM( DxfFormatOption )
355 
356 
360  QgsWmsParameters( const QgsServerParameters &parameters );
361 
366 
367  virtual ~QgsWmsParameters() override = default;
368 
373  QgsWmsParameter operator[]( QgsWmsParameter::Name name ) const;
374 
379  void set( QgsWmsParameter::Name name, const QVariant &value );
380 
384  void dump() const;
385 
390  QString crs() const;
391 
396  QString width() const;
397 
405  int widthAsInt() const;
406 
411  QString height() const;
412 
420  int heightAsInt() const;
421 
427  QString srcWidth() const;
428 
437  int srcWidthAsInt() const;
438 
444  QString srcHeight() const;
445 
454  int srcHeightAsInt() const;
455 
460  QgsProjectVersion versionAsNumber() const;
461 
466  bool versionIsValid( const QString version ) const;
467 
472  QString bbox() const;
473 
480  QgsRectangle bboxAsRectangle() const;
481 
486  QString sldBody() const;
487 
492  QStringList selections() const;
493 
498  QStringList filters() const;
499 
504  QString filterGeom() const;
505 
510  QStringList opacities() const;
511 
519  QList<int> opacitiesAsInt() const;
520 
525  QStringList allLayersNickname() const;
526 
531  QStringList queryLayersNickname() const;
532 
537  QStringList allStyles() const;
538 
543  QList<QgsWmsParametersLayer> layersParameters() const;
544 
550  QString polygonTolerance() const;
551 
557  QString lineTolerance() const;
558 
564  QString pointTolerance() const;
565 
571  int polygonToleranceAsInt() const;
572 
578  int lineToleranceAsInt() const;
579 
585  int pointToleranceAsInt() const;
586 
591  QString formatAsString() const;
592 
597  static QString formatAsString( Format format );
598 
604  Format format() const;
605 
610  QString infoFormatAsString() const;
611 
616  bool infoFormatIsImage() const;
617 
623  QString imageQuality() const;
624 
630  int imageQualityAsInt() const;
631 
637  QString tiled() const;
638 
644  bool tiledAsBool() const;
645 
651  Format infoFormat() const;
652 
658  int infoFormatVersion() const;
659 
664  QString i() const;
665 
673  int iAsInt() const;
674 
679  QString j() const;
680 
688  int jAsInt() const;
689 
694  QString x() const;
695 
703  int xAsInt() const;
704 
709  QString y() const;
710 
718  int yAsInt() const;
719 
724  QString rule() const;
725 
730  QString ruleLabel() const;
731 
738  bool ruleLabelAsBool() const;
739 
744  QString showFeatureCount() const;
745 
752  bool showFeatureCountAsBool() const;
753 
758  QString featureCount() const;
759 
766  int featureCountAsInt() const;
767 
772  QString scale() const;
773 
780  double scaleAsDouble() const;
781 
786  QString boxSpace() const;
787 
794  double boxSpaceAsDouble() const;
795 
800  QString layerSpace() const;
801 
808  double layerSpaceAsDouble() const;
809 
814  QString layerTitleSpace() const;
815 
822  double layerTitleSpaceAsDouble() const;
823 
828  QString symbolSpace() const;
829 
836  double symbolSpaceAsDouble() const;
837 
842  QString iconLabelSpace() const;
843 
850  double iconLabelSpaceAsDouble() const;
851 
856  QString symbolWidth() const;
857 
864  double symbolWidthAsDouble() const;
865 
870  QString symbolHeight() const;
871 
878  double symbolHeightAsDouble() const;
879 
885  QFont layerFont() const;
886 
891  QString layerFontFamily() const;
892 
897  QString layerFontBold() const;
898 
905  bool layerFontBoldAsBool() const;
906 
911  QString layerFontItalic() const;
912 
919  bool layerFontItalicAsBool() const;
920 
925  QString layerFontSize() const;
926 
933  double layerFontSizeAsDouble() const;
934 
939  QString layerFontColor() const;
940 
947  QColor layerFontColorAsColor() const;
948 
954  QFont itemFont() const;
955 
960  QString itemFontFamily() const;
961 
966  QString itemFontBold() const;
967 
974  bool itemFontBoldAsBool() const;
975 
980  QString itemFontItalic() const;
981 
988  bool itemFontItalicAsBool() const;
989 
994  QString itemFontSize() const;
995 
1002  double itemFontSizeAsDouble() const;
1003 
1008  QString itemFontColor() const;
1009 
1016  QColor itemFontColorAsColor() const;
1017 
1022  QString layerTitle() const;
1023 
1030  bool layerTitleAsBool() const;
1031 
1036  QgsLegendSettings legendSettings() const;
1037 
1042  QList<QgsWmsParametersHighlightLayer> highlightLayersParameters() const;
1043 
1048  QList<QgsWmsParametersExternalLayer> externalLayersParameters() const;
1049 
1054  QStringList highlightGeom() const;
1055 
1062  QList<QgsGeometry> highlightGeomAsGeom() const;
1063 
1068  QStringList highlightSymbol() const;
1069 
1074  QStringList highlightLabelString() const;
1075 
1080  QStringList highlightLabelColor() const;
1081 
1088  QList<QColor> highlightLabelColorAsColor() const;
1089 
1094  QStringList highlightLabelSize() const;
1095 
1102  QList<int> highlightLabelSizeAsInt() const;
1103 
1108  QStringList highlightLabelWeight() const;
1109 
1116  QList<int> highlightLabelWeightAsInt() const;
1117 
1122  QStringList highlightLabelFont() const;
1123 
1128  QStringList highlightLabelBufferSize() const;
1129 
1136  QList<double> highlightLabelBufferSizeAsFloat() const;
1137 
1142  QStringList highlightLabelBufferColor() const;
1143 
1150  QList<QColor> highlightLabelBufferColorAsColor() const;
1151 
1156  QString wmsPrecision() const;
1157 
1165  int wmsPrecisionAsInt() const;
1166 
1171  QString transparent() const;
1172 
1180  bool transparentAsBool() const;
1181 
1186  QString backgroundColor() const;
1187 
1195  QColor backgroundColorAsColor() const;
1196 
1201  QString dpi() const;
1202 
1210  double dpiAsDouble() const;
1211 
1216  QString composerTemplate() const;
1217 
1227  QgsWmsParametersComposerMap composerMapParameters( int mapId ) const;
1228 
1234  QString externalWMSUri( const QString &id ) const;
1235 
1240  bool withGeometry() const;
1241 
1246  bool withMapTip() const;
1247 
1252  QString wmtver() const;
1253 
1261  QString layoutParameter( const QString &id, bool &ok ) const;
1262 
1268  QStringList atlasPk() const;
1269 
1274  QMap<DxfFormatOption, QString> dxfFormatOptions() const;
1275 
1280  QStringList dxfLayerAttributes() const;
1281 
1286  bool dxfUseLayerTitleAsName() const;
1287 
1292  double dxfScale() const;
1293 
1298  QgsDxfExport::SymbologyExport dxfMode() const;
1299 
1304  QString dxfCodec() const;
1305 
1310  QMap<QString, QString> dimensionValues() const;
1311 
1312  private:
1313  static bool isExternalLayer( const QString &name );
1314 
1315  bool loadParameter( const QString &name, const QString &value ) override;
1316 
1317  void save( const QgsWmsParameter &parameter, bool multi = false );
1318 
1319  QgsWmsParameter idParameter( QgsWmsParameter::Name name, int id ) const;
1320 
1321  void raiseError( const QString &msg ) const;
1322  void log( const QString &msg ) const;
1323 
1324  QgsWmsParametersExternalLayer externalLayerParameter( const QString &name ) const;
1325 
1326  QMultiMap<QString, QgsWmsParametersFilter> layerFilters( const QStringList &layers ) const;
1327 
1328  QMap<QgsWmsParameter::Name, QgsWmsParameter> mWmsParameters;
1329  QMap<QString, QMap<QString, QString> > mExternalWMSParameters;
1330  QList<QgsProjectVersion> mVersions;
1331  };
1332 }
1333 
1334 #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:122
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.