Subversion Repositories public

Rev

Go to most recent revision | Details | 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
 
109
class wmsSelectorWidget : public QDialog,
110
			  public QXmlDefaultHandler,
111
			  private Ui::wmsSelectorWidgetBase
112
{
113
	Q_OBJECT
114
 
115
	public:
116
	   enum ELEMENT
117
	   {
118
	      el_none,
119
	      el_WMT_MS_Capabilities,
120
	      el_Service,
121
	      el_Name,
122
	      el_Title,
123
	      el_Abstract,
124
	      el_KeywordList,
125
	      el_Keyword,
126
	      el_OnlineResource,
127
	      el_ContactInformation,
128
	      el_ContactPersonPrimary,
129
	      el_ContactPerson,
130
	      el_ContactOrganisation,
131
	      el_ContactPosition,
132
	      el_ContactAddress,
133
	      el_AddressType,
134
	      el_Address,
135
	      el_City,
136
	      el_StateOrProvince,
137
	      el_PostCode,
138
	      el_Country,
139
	      el_ContactVoiceTelephone,
140
	      el_ContactFacsimileTelephone,
141
	      el_ElectronicMailAddress,
142
	      el_Fees,
143
	      el_AccessConstraints,
144
	      el_Capability,
145
	      el_Request,
146
	      el_GetCapabilities,
147
	      el_Format,
148
	      el_DCPType,
149
	      el_HTTP,
150
	      el_Get,
151
	      el_Post,
152
	      el_GetMap,
153
	      el_GetFeatureInfo,
154
	      el_DescribeLayer,
155
	      el_GetLegendGraphic,
156
	      el_GetStyles,
157
	      el_Exception,
158
	      el_VendorSpecificCapabilities,
159
	      el_UserDefinedSymbolization,
160
	      el_Layer,
161
	      el_SRS,
162
	      el_LatLonBoundingBox,
163
	      el_BoundingBox,
164
	      el_ScaleHint,
165
	      el_Style,
166
	      el_LegendURL,
167
	      el_MetadataURL
168
	   };
169
 
170
	   enum ATTRIBUTE
171
	   {
172
	      at_none,
173
	      at_Name,
174
	      at_Title,
175
	      at_Abstract,
176
	      at_ContactPerson,
177
	      at_ContactOrganisation,
178
	      at_ContactPosition,
179
	      at_AddressType,
180
	      at_Address,
181
	      at_City,
182
	      at_StateOrProvince,
183
	      at_PostCode,
184
	      at_Country,
185
	      at_ContactVoiceTelephone,
186
	      at_ContactFacsimileTelephone,
187
	      at_ContactElectronicMailAddress,
188
	      at_Fees,
189
	      at_AccessConstraints,
190
	      at_Format,
191
	      at_SRS,
192
	      at_CRS
193
	   };
194
 
195
	public:
196
	   wmsSelectorWidget (QWidget* parent = 0, Qt::WFlags fl = 0);
197
	   ~wmsSelectorWidget();
198
	   /*$PUBLIC_FUNCTIONS$*/
199
 
200
	   // Functions to parse the XML file
201
	   bool startDocument ();
202
	   bool startElement (const QString&, const QString&, const QString& , const QXmlAttributes&);
203
	   bool endElement (const QString&, const QString&, const QString&);
204
	   bool characters (const QString&);
205
 
206
 
207
	public slots:
208
	   /*$PUBLIC_SLOTS$*/
209
	   virtual void slotGetCapabilities();
210
	   virtual void slotDetails();
211
	   virtual void slotAdded(QListWidgetItem *);
212
	   virtual void slotRemoved(QListWidgetItem *);
213
	   virtual void slotUp(QListWidgetItem *);
214
	   virtual void slotDown(QListWidgetItem *);
215
	   virtual void slotCities(QString);
216
	   virtual void slotStyles(bool);
217
 
218
	protected:
219
	   /*$PROTECTED_FUNCTIONS$*/
220
	   void getCapabilities();
221
	   bool parseWMS();
222
	   bool grabPicture(double, double, double, double);
223
 
224
	private slots:
225
	   // Functions called during downloading the capabilities of a WMS-server
226
	   void WMSrequestFinished(int, bool);
227
	   void updateDataReadProgress(int, int);
228
	   void readResponseHeader(const QHttpResponseHeader &);
229
	   void slotAuthenticationRequired(const QString &, quint16, QAuthenticator *);
230
#ifndef QT_NO_OPENSSL
231
	   void sslErrors(const QList<QSslError> &);
232
#endif
233
	   void cancelDownload();	// The cancel button in progress dialog
234
 
235
	private:
236
	   void initializeParser();
237
	   LAYER *allocateLayer();
238
	   STYLE *allocateStyle();
239
	   STYLE *findLastStyle(LAYER *);
240
	   bool writeWMSTag(double, double, double, double, int, int);
241
	   void setDimension(double &, double &, double &, double &, QListWidgetItem *);
242
 
243
	private:
244
	   int id;			// ID used during download
245
	   QString Data, MAP;
246
	   QHttp *http;
247
	   bool httpRequestAborted;
248
	   bool StyleCommas;
249
	   QFile file;
250
	   KProgressDialog *progressDialog;
251
	   ELEMENT element, el2;
252
	   ATTRIBUTE attribute;
253
	   QStringList Exception;	// List of exceptions of WMS server
254
	   QString WMSVersion;		// Version, WMS server supports
255
	   SERVICE Service;
256
	   REQUEST Request;
257
	   LAYER *Layer, *firstLayer;
258
	   int line;			// actual line number during parsing
259
	   int lcount;			// counts the deepnes of layers
260
};
261
 
262
#endif
263