Rev 283 | Blame | Compare with Previous | Last modification | View Log | RSS feed
//
// C++ Interface:
//
// Description:
//
//
// Author: Andreas Theofilu <andreas@theosys.at>, (C) 2009
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef WMSSELECTORWIDGET_H
#define WMSSELECTORWIDGET_H
#include <QDialog>
#include <QString>
#include <QLabel>
#include <QHttp>
#include <QFile>
#include <QXmlReader>
#include <KUrlRequester>
#include <KActionSelector>
#include <KProgressDialog>
#include <KDoubleNumInput>
#include "ui_wmsselectorwidgetbase.h"
typedef struct
{
QString Name;
QString Title;
QString Abstract;
QString OnlineResource;
QString Type;
QString ContactPerson;
QString ContactOrganisation;
QString ContactPosition;
QString AddressType;
QString Address;
QString City;
QString StateOrProvince;
QString PostCode;
QString Country;
QString ContactVoiceTelephone;
QString ContactFacsimileTelephone;
QString ContactElectronicMailAddress;
QString Fees;
QString AccessConstraints;
}SERVICE;
typedef struct
{
QStringList Format;
QString Get;
QString Post;
}GET;
typedef struct
{
GET GetCapabilities;
GET GetMap;
GET GetFeatureInfo;
}REQUEST;
typedef struct
{
double maxx;
double minx;
double maxy;
double miny;
QString SRS;
}BOX;
typedef struct STYLE
{
QString Name;
QString Title;
QString Format;
QString LegendURL;
STYLE *next;
}STYLE;
typedef struct LAYER
{
bool opaque;
bool noSubsets;
bool queryable;
bool cascaded;
QString Name;
QString Title;
QString Abstract;
QStringList SRS;
QStringList CRS;
BOX LatLon;
BOX Bounding;
double scaleMin;
double scaleMax;
STYLE *style;
LAYER *next;
}LAYER;
typedef struct
{
QString city;
double lon;
double lat;
}CITIES;
typedef struct
{
double x;
double y;
}ZOOM;
class wmsSelectorWidget : public QDialog,
public QXmlDefaultHandler,
private Ui::wmsSelectorWidgetBase
{
Q_OBJECT
public:
enum ELEMENT
{
el_none,
el_WMT_MS_Capabilities,
el_Service,
el_Name,
el_Title,
el_Abstract,
el_KeywordList,
el_Keyword,
el_OnlineResource,
el_ContactInformation,
el_ContactPersonPrimary,
el_ContactPerson,
el_ContactOrganisation,
el_ContactPosition,
el_ContactAddress,
el_AddressType,
el_Address,
el_City,
el_StateOrProvince,
el_PostCode,
el_Country,
el_ContactVoiceTelephone,
el_ContactFacsimileTelephone,
el_ElectronicMailAddress,
el_Fees,
el_AccessConstraints,
el_Capability,
el_Request,
el_GetCapabilities,
el_Format,
el_DCPType,
el_HTTP,
el_Get,
el_Post,
el_GetMap,
el_GetFeatureInfo,
el_DescribeLayer,
el_GetLegendGraphic,
el_GetStyles,
el_Exception,
el_VendorSpecificCapabilities,
el_UserDefinedSymbolization,
el_Layer,
el_SRS,
el_LatLonBoundingBox,
el_BoundingBox,
el_ScaleHint,
el_Style,
el_LegendURL,
el_MetadataURL
};
enum ATTRIBUTE
{
at_none,
at_Name,
at_Title,
at_Abstract,
at_ContactPerson,
at_ContactOrganisation,
at_ContactPosition,
at_AddressType,
at_Address,
at_City,
at_StateOrProvince,
at_PostCode,
at_Country,
at_ContactVoiceTelephone,
at_ContactFacsimileTelephone,
at_ContactElectronicMailAddress,
at_Fees,
at_AccessConstraints,
at_Format,
at_SRS,
at_CRS
};
public:
wmsSelectorWidget (QWidget* parent = 0, Qt::WFlags fl = 0);
~wmsSelectorWidget();
/*$PUBLIC_FUNCTIONS$*/
// Functions to parse the XML file
bool startDocument ();
bool startElement (const QString&, const QString&, const QString& , const QXmlAttributes&);
bool endElement (const QString&, const QString&, const QString&);
bool characters (const QString&);
QString getServer() { return urlWMS->url().url(); };
QString getLayers();
int getBands() { return edBands->value(); };
QString getStyles();
public slots:
/*$PUBLIC_SLOTS$*/
virtual void slotValueChanged(int);
virtual void slotSliderPressed();
virtual void slotSliderReleased();
virtual void slotGetCapabilities();
virtual void slotDetails();
virtual void slotAdded(QListWidgetItem *);
virtual void slotRemoved(QListWidgetItem *);
virtual void slotUp(QListWidgetItem *);
virtual void slotDown(QListWidgetItem *);
virtual void slotCities(QString);
virtual void slotStyles(bool);
protected:
/*$PROTECTED_FUNCTIONS$*/
void getCapabilities();
bool parseWMS();
bool grabPicture(double, double, double, double);
private slots:
// Functions called during downloading the capabilities of a WMS-server
void WMSrequestFinished(int, bool);
void updateDataReadProgress(int, int);
void readResponseHeader(const QHttpResponseHeader &);
void slotAuthenticationRequired(const QString &, quint16, QAuthenticator *);
#ifndef QT_NO_OPENSSL
void sslErrors(const QList<QSslError> &);
#endif
void cancelDownload(); // The cancel button in progress dialog
private:
void initializeParser();
LAYER *allocateLayer();
STYLE *allocateStyle();
STYLE *findLastStyle(LAYER *);
bool writeWMSTag(double, double, double, double, int, int);
void setDimension(double &, double &, double &, double &, QListWidgetItem *);
private:
int id; // ID used during download
QString Data, MAP, Layers;
QHttp *http;
bool httpRequestAborted;
bool StyleCommas, Init;
QFile file;
KProgressDialog *progressDialog;
ELEMENT element, el2;
ATTRIBUTE attribute;
QStringList Exception; // List of exceptions of WMS server
QString WMSVersion; // Version, WMS server supports
SERVICE Service;
REQUEST Request;
LAYER *Layer, *firstLayer;
int zLevel; // zoom level
int line; // actual line number during parsing
int lcount; // counts the deepnes of layers
bool sliderPressed;
};
#endif