Subversion Repositories public

Rev

Rev 283 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
283 andreas 1
//
2
// C++ Interface:
3
//
4
// Description:
5
//
6
//
7
// Author: Andreas Theofilu <andreas@theosys.at>, (C) 2009
8
//
9
// Copyright: See COPYING file that comes with this distribution
10
//
11
//
12
 
13
#ifndef WMSSELECTORWIDGET_H
14
#define WMSSELECTORWIDGET_H
15
 
16
#include <QDialog>
17
#include <QString>
18
#include <QLabel>
19
#include <QHttp>
20
#include <QFile>
21
#include <QXmlReader>
22
#include <KUrlRequester>
23
#include <KActionSelector>
24
#include <KProgressDialog>
25
#include <KDoubleNumInput>
26
#include "ui_wmsselectorwidgetbase.h"
27
 
28
typedef struct
29
{
30
	QString Name;
31
	QString Title;
32
	QString Abstract;
33
	QString OnlineResource;
34
	QString Type;
35
	QString ContactPerson;
36
	QString ContactOrganisation;
37
	QString ContactPosition;
38
	QString AddressType;
39
	QString Address;
40
	QString City;
41
	QString StateOrProvince;
42
	QString PostCode;
43
	QString Country;
44
	QString ContactVoiceTelephone;
45
	QString ContactFacsimileTelephone;
46
	QString ContactElectronicMailAddress;
47
	QString Fees;
48
	QString AccessConstraints;
49
}SERVICE;
50
 
51
typedef struct
52
{
53
	QStringList Format;
54
	QString Get;
55
	QString Post;
56
}GET;
57
 
58
typedef struct
59
{
60
	GET GetCapabilities;
61
	GET GetMap;
62
	GET GetFeatureInfo;
63
}REQUEST;
64
 
65
typedef struct
66
{
67
	double maxx;
68
	double minx;
69
	double maxy;
70
	double miny;
71
	QString SRS;
72
}BOX;
73
 
74
typedef struct STYLE
75
{
76
	QString Name;
77
	QString Title;
78
	QString Format;
79
	QString LegendURL;
80
	STYLE *next;
81
}STYLE;
82
 
83
typedef struct LAYER
84
{
85
	bool opaque;
86
	bool noSubsets;
87
	bool queryable;
88
	bool cascaded;
89
	QString Name;
90
	QString Title;
91
	QString Abstract;
92
	QStringList SRS;
93
	QStringList CRS;
94
	BOX LatLon;
95
	BOX Bounding;
96
	double scaleMin;
97
	double scaleMax;
98
	STYLE *style;
99
	LAYER *next;
100
}LAYER;
101
 
102
typedef struct
103
{
104
	QString city;
105
	double  lon;
106
	double  lat;
107
}CITIES;
108
 
284 andreas 109
typedef struct
110
{
111
	double x;
112
	double y;
113
}ZOOM;
114
 
283 andreas 115
class wmsSelectorWidget : public QDialog,
116
			  public QXmlDefaultHandler,
117
			  private Ui::wmsSelectorWidgetBase
118
{
119
	Q_OBJECT
120
 
121
	public:
122
	   enum ELEMENT
123
	   {
124
	      el_none,
125
	      el_WMT_MS_Capabilities,
126
	      el_Service,
127
	      el_Name,
128
	      el_Title,
129
	      el_Abstract,
130
	      el_KeywordList,
131
	      el_Keyword,
132
	      el_OnlineResource,
133
	      el_ContactInformation,
134
	      el_ContactPersonPrimary,
135
	      el_ContactPerson,
136
	      el_ContactOrganisation,
137
	      el_ContactPosition,
138
	      el_ContactAddress,
139
	      el_AddressType,
140
	      el_Address,
141
	      el_City,
142
	      el_StateOrProvince,
143
	      el_PostCode,
144
	      el_Country,
145
	      el_ContactVoiceTelephone,
146
	      el_ContactFacsimileTelephone,
147
	      el_ElectronicMailAddress,
148
	      el_Fees,
149
	      el_AccessConstraints,
150
	      el_Capability,
151
	      el_Request,
152
	      el_GetCapabilities,
153
	      el_Format,
154
	      el_DCPType,
155
	      el_HTTP,
156
	      el_Get,
157
	      el_Post,
158
	      el_GetMap,
159
	      el_GetFeatureInfo,
160
	      el_DescribeLayer,
161
	      el_GetLegendGraphic,
162
	      el_GetStyles,
163
	      el_Exception,
164
	      el_VendorSpecificCapabilities,
165
	      el_UserDefinedSymbolization,
166
	      el_Layer,
167
	      el_SRS,
168
	      el_LatLonBoundingBox,
169
	      el_BoundingBox,
170
	      el_ScaleHint,
171
	      el_Style,
172
	      el_LegendURL,
173
	      el_MetadataURL
174
	   };
175
 
176
	   enum ATTRIBUTE
177
	   {
178
	      at_none,
179
	      at_Name,
180
	      at_Title,
181
	      at_Abstract,
182
	      at_ContactPerson,
183
	      at_ContactOrganisation,
184
	      at_ContactPosition,
185
	      at_AddressType,
186
	      at_Address,
187
	      at_City,
188
	      at_StateOrProvince,
189
	      at_PostCode,
190
	      at_Country,
191
	      at_ContactVoiceTelephone,
192
	      at_ContactFacsimileTelephone,
193
	      at_ContactElectronicMailAddress,
194
	      at_Fees,
195
	      at_AccessConstraints,
196
	      at_Format,
197
	      at_SRS,
198
	      at_CRS
199
	   };
200
 
201
	public:
202
	   wmsSelectorWidget (QWidget* parent = 0, Qt::WFlags fl = 0);
203
	   ~wmsSelectorWidget();
204
	   /*$PUBLIC_FUNCTIONS$*/
205
 
206
	   // Functions to parse the XML file
207
	   bool startDocument ();
208
	   bool startElement (const QString&, const QString&, const QString& , const QXmlAttributes&);
209
	   bool endElement (const QString&, const QString&, const QString&);
210
	   bool characters (const QString&);
284 andreas 211
	   QString getServer() { return urlWMS->url().url(); };
212
	   QString getLayers();
213
	   int getBands() { return edBands->value(); };
214
	   QString getStyles();
283 andreas 215
 
216
 
217
	public slots:
218
	   /*$PUBLIC_SLOTS$*/
284 andreas 219
	   virtual void slotValueChanged(int);
220
	   virtual void slotSliderPressed();
221
	   virtual void slotSliderReleased();
283 andreas 222
	   virtual void slotGetCapabilities();
223
	   virtual void slotDetails();
224
	   virtual void slotAdded(QListWidgetItem *);
225
	   virtual void slotRemoved(QListWidgetItem *);
226
	   virtual void slotUp(QListWidgetItem *);
227
	   virtual void slotDown(QListWidgetItem *);
228
	   virtual void slotCities(QString);
229
	   virtual void slotStyles(bool);
230
 
231
	protected:
232
	   /*$PROTECTED_FUNCTIONS$*/
233
	   void getCapabilities();
234
	   bool parseWMS();
235
	   bool grabPicture(double, double, double, double);
236
 
237
	private slots:
238
	   // Functions called during downloading the capabilities of a WMS-server
239
	   void WMSrequestFinished(int, bool);
240
	   void updateDataReadProgress(int, int);
241
	   void readResponseHeader(const QHttpResponseHeader &);
242
	   void slotAuthenticationRequired(const QString &, quint16, QAuthenticator *);
243
#ifndef QT_NO_OPENSSL
244
	   void sslErrors(const QList<QSslError> &);
245
#endif
246
	   void cancelDownload();	// The cancel button in progress dialog
247
 
248
	private:
249
	   void initializeParser();
250
	   LAYER *allocateLayer();
251
	   STYLE *allocateStyle();
252
	   STYLE *findLastStyle(LAYER *);
253
	   bool writeWMSTag(double, double, double, double, int, int);
254
	   void setDimension(double &, double &, double &, double &, QListWidgetItem *);
255
 
256
	private:
257
	   int id;			// ID used during download
284 andreas 258
	   QString Data, MAP, Layers;
283 andreas 259
	   QHttp *http;
260
	   bool httpRequestAborted;
284 andreas 261
	   bool StyleCommas, Init;
283 andreas 262
	   QFile file;
263
	   KProgressDialog *progressDialog;
264
	   ELEMENT element, el2;
265
	   ATTRIBUTE attribute;
266
	   QStringList Exception;	// List of exceptions of WMS server
267
	   QString WMSVersion;		// Version, WMS server supports
268
	   SERVICE Service;
269
	   REQUEST Request;
270
	   LAYER *Layer, *firstLayer;
284 andreas 271
	   int zLevel;			// zoom level
283 andreas 272
	   int line;			// actual line number during parsing
273
	   int lcount;			// counts the deepnes of layers
284 andreas 274
	   bool sliderPressed;
283 andreas 275
};
276
 
277
#endif
278