Skip to content

Commit 829e1e1

Browse files
author
mhugent
committedSep 1, 2006
Added a very early version of a wfs plugin
git-svn-id: http://svn.osgeo.org/qgis/trunk@5744 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e86f0da commit 829e1e1

File tree

6 files changed

+956
-0
lines changed

6 files changed

+956
-0
lines changed
 

‎src/plugins/wfs/mIconAddWfsLayer.xpm

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
/* XPM */
2+
static char *mIconAddWfsLayer[]={
3+
"22 22 274 2",
4+
"Qt c None",
5+
".Q c None",
6+
"#L c #000000",
7+
"#K c #000000",
8+
"#r c #000001",
9+
"cf c #010102",
10+
".i c #000001",
11+
".# c #000002",
12+
"cc c #030305",
13+
"cd c #030305",
14+
"ce c #030306",
15+
"bp c #000000",
16+
".P c #000107",
17+
".u c #01040c",
18+
"b6 c #000101",
19+
"bF c #000001",
20+
".G c #000410",
21+
"cb c #0b0b0e",
22+
"aT c #000002",
23+
".7 c #00030a",
24+
".j c #010613",
25+
".F c #010611",
26+
".Z c #030917",
27+
".v c #020817",
28+
".h c #050c1d",
29+
".a c #050e23",
30+
"b5 c #0a0c13",
31+
"ak c #151c30",
32+
"aB c #010715",
33+
"ca c #242428",
34+
"#e c #071025",
35+
"bT c #0a0e19",
36+
".8 c #101b3d",
37+
"b. c #020919",
38+
"ck c #06121f",
39+
".Y c #101b3d",
40+
"b4 c #1b1f2f",
41+
"aj c #05112e",
42+
"#4 c #1e2b4f",
43+
".g c #253358",
44+
".t c #313d5c",
45+
"#q c #131e40",
46+
".R c #162652",
47+
"bU c #121b26",
48+
"bV c #1a232d",
49+
".b c #23345d",
50+
"#f c #182855",
51+
".k c #2e3d63",
52+
"bE c #0b1531",
53+
"bo c #05112f",
54+
"#3 c #07173f",
55+
"#J c #132149",
56+
"aC c #61676e",
57+
"#M c #2b3a67",
58+
"#s c #2c3c6c",
59+
".O c #394872",
60+
".E c #4f5d81",
61+
"bS c #29365a",
62+
".H c #3a4c7f",
63+
".f c #4c5e89",
64+
"aS c #1c2d5c",
65+
".w c #4c5c88",
66+
".c c #4b5d89",
67+
"cg c #031f51",
68+
".6 c #384a81",
69+
"c# c #8e8e92",
70+
".e c #63739c",
71+
".d c #63739c",
72+
".0 c #384d8c",
73+
"cl c #051d40",
74+
"aD c #737b91",
75+
".l c #8e9aba",
76+
"bR c #526192",
77+
"bD c #2b417e",
78+
"a9 c #0e2970",
79+
"aA c #495b96",
80+
"c. c #d0d0d2",
81+
"al c #6a79b0",
82+
"bn c #16327b",
83+
"#d c #5d6da9",
84+
".X c #8a96c3",
85+
"bQ c #717eb1",
86+
".D c #cdd3e6",
87+
".x c #cad1e6",
88+
".m c #cfd5e6",
89+
"b7 c #032562",
90+
"cm c #052351",
91+
"bP c #0a293e",
92+
"aa c #0a2979",
93+
"bi c #0b3a54",
94+
"bz c #0b3b54",
95+
"as c #0d2c7b",
96+
"aO c #0e2c79",
97+
"bZ c #0e96be",
98+
"ax c #0f2a6f",
99+
"ch c #0f5a7d",
100+
"bh c #0f8eb6",
101+
"b8 c #106e93",
102+
"ci c #107ea6",
103+
"#U c #12307d",
104+
"a3 c #133348",
105+
"a2 c #13688c",
106+
"by c #138fb7",
107+
"bg c #1397be",
108+
"b0 c #157296",
109+
"cn c #173156",
110+
"bY c #1799bf",
111+
"bW c #192b47",
112+
"a1 c #197397",
113+
"a6 c #1c3a85",
114+
"#0 c #1d3575",
115+
"af c #1e3779",
116+
"a8 c #1e3b86",
117+
"bX c #1e7699",
118+
"a7 c #213e87",
119+
"bO c #217294",
120+
"a5 c #233f88",
121+
"at c #244087",
122+
"aP c #264187",
123+
"bx c #27a0c3",
124+
"co c #2b3e58",
125+
"a4 c #2b468d",
126+
"ag c #2c4079",
127+
"aQ c #2c4589",
128+
"#2 c #2c4790",
129+
"bL c #2ca2c4",
130+
"ai c #2d478f",
131+
"#x c #2f4989",
132+
"#y c #304b8f",
133+
"bm c #304b91",
134+
"ay c #334579",
135+
"bN c #3685a3",
136+
"aJ c #374552",
137+
"aN c #375194",
138+
"bG c #3b5160",
139+
"#O c #3b659f",
140+
"bM c #3b88a5",
141+
"bl c #3e5697",
142+
"aL c #3f5f7c",
143+
"b1 c #40515d",
144+
"bf c #41abca",
145+
"#1 c #425896",
146+
"aw c #425997",
147+
"b3 c #42617b",
148+
"bk c #445b9a",
149+
"#I c #455c9f",
150+
"bI c #4588a5",
151+
"#H c #465993",
152+
"aM c #485e9c",
153+
"bj c #495f9d",
154+
"a0 c #4a8fab",
155+
"bC c #4b62a0",
156+
"#h c #4b639d",
157+
"aR c #4c62a2",
158+
"#z c #4c639c",
159+
"#g c #4c649c",
160+
"bK c #4dafcc",
161+
"aI c #4e8ea8",
162+
"#6 c #4f6e9c",
163+
"aK c #506d80",
164+
"ab c #51669d",
165+
"#w c #526393",
166+
"bw c #56b4d0",
167+
"bH c #578da6",
168+
"ah c #5a6ca7",
169+
"am c #5a77a4",
170+
"b2 c #5c7c90",
171+
"bJ c #5e9ab2",
172+
"bv c #5eb7d2",
173+
"#A c #5f72a2",
174+
"bB c #5f72aa",
175+
"aq c #629ab2",
176+
"#G c #6574a5",
177+
"#Z c #6677a9",
178+
"#p c #6878b4",
179+
"ar c #687e8c",
180+
"bA c #6a7baf",
181+
"be c #6cbdd4",
182+
"cj c #6e757f",
183+
"#S c #707d88",
184+
"bd c #73bed4",
185+
"#V c #7485af",
186+
"a# c #748997",
187+
"bu c #76c0d6",
188+
"b9 c #777d84",
189+
"#o c #7783b4",
190+
"#T c #7992a0",
191+
"aZ c #79c2d6",
192+
"#5 c #7d89c0",
193+
"cp c #7e889a",
194+
"#N c #828dc3",
195+
"#t c #828ec4",
196+
"aE c #8291a9",
197+
"aY c #82c5d7",
198+
"bq c #83949c",
199+
"aH c #84c6d8",
200+
"a. c #86a6b7",
201+
"bs c #87c8da",
202+
".S c #8894c3",
203+
"#Q c #8b9ca5",
204+
"az c #8c96c7",
205+
"bt c #8eccdd",
206+
"aU c #8f98a1",
207+
"bc c #8fcadb",
208+
"ae c #919ec7",
209+
"#P c #92a0a9",
210+
"#v c #949dc7",
211+
"#u c #949dcc",
212+
"#R c #95a1a8",
213+
"#n c #99a2c5",
214+
"#c c #99a2ce",
215+
"b# c #9ca6ae",
216+
"ap c #9ed0e0",
217+
".T c #9fabc9",
218+
".5 c #a2aad3",
219+
"aG c #a2d3e1",
220+
"aX c #a7c9d5",
221+
"#7 c #a8bfc9",
222+
"av c #aab3d4",
223+
"br c #aad3e1",
224+
"au c #acb4d4",
225+
"#F c #afb6d7",
226+
"an c #b0cad4",
227+
"bb c #b1d8e4",
228+
"aF c #b2ced8",
229+
"#B c #b5bdd4",
230+
"#8 c #b5d3db",
231+
"#m c #b7bdd8",
232+
"#9 c #b8d5e0",
233+
"ao c #badde6",
234+
".K c #bbc2d4",
235+
"#b c #bec4e0",
236+
".J c #bfc4d4",
237+
"aW c #c1d5de",
238+
".I c #c2cae2",
239+
"#Y c #c3c9e2",
240+
"#a c #c4cae1",
241+
".N c #c4cce3",
242+
"aV c #c4d4db",
243+
".4 c #c8cde4",
244+
".1 c #cacfe0",
245+
"#E c #cbd0e6",
246+
"ad c #ccd0e6",
247+
".3 c #cfd3e7",
248+
"#l c #cfd3e8",
249+
".L c #cfd4e2",
250+
"ba c #cfe4ec",
251+
"## c #d1d5e8",
252+
".W c #d2d6e9",
253+
".U c #d3d7e7",
254+
".2 c #d3d7e9",
255+
"#X c #d4d8ea",
256+
".V c #d5d9ea",
257+
"ac c #d7daeb",
258+
"#D c #d9dcec",
259+
"#k c #dadded",
260+
"#. c #dbdeed",
261+
".M c #e0e3f0",
262+
".9 c #e1e4f0",
263+
".A c #e3e6f0",
264+
"#j c #e4e7f2",
265+
"#W c #e5e7f2",
266+
".B c #e6e8f1",
267+
".n c #e7ebf3",
268+
"#i c #e9ebf3",
269+
"#C c #e9ebf5",
270+
".z c #eaecf4",
271+
".q c #ebeef5",
272+
".C c #edeef6",
273+
".y c #eeeff7",
274+
".o c #eff1f7",
275+
".p c #f1f3f8",
276+
".s c #ff0000",
277+
".r c #ffc0c0",
278+
"QtQtQtQtQtQt.#.a.b.c.d.e.f.g.h.iQtQtQtQtQtQt",
279+
"QtQtQtQtQt.j.k.l.m.n.o.p.q.r.s.t.uQtQtQtQtQt",
280+
"QtQtQtQt.v.w.x.y.z.A.B.C.r.s.s.D.E.FQtQtQtQt",
281+
"QtQtQt.G.H.I.r.r.J.K.L.r.s.s.r.M.N.O.PQtQtQt",
282+
"QtQt.Q.R.S.r.s.s.r.T.r.s.s.r.U.V.W.X.YQtQtQt",
283+
"QtQt.Z.0.r.s.s.s.s.r.s.s.r.1.2.3.4.5.6.7QtQt",
284+
"QtQt.8.r.s.s.r.r.s.s.s.r.9#.###a#b#c#d#eQtQt",
285+
"QtQt#f.s.s.r#g#h.r.r.r#i#j#k#l#m#n#o#p#qQtQt",
286+
"Qt#r#s#t#u#v#w#x#y#z#A#B#C#D#E#F#G#H#I#J#KQt",
287+
"Qt#L#M#N#O#P#Q#R#S#T#U#V#W#X#Y#Z#0#1#2#3#KQt",
288+
"QtQt#4#5#6#7#8#9a.a#aaabacadaeafagahaiajQtQt",
289+
"QtQtakalamanaoapaqarasatauavawaxayazaAaBQtQt",
290+
"QtQtaCaDaEaFaGaHaIaJaKaLaMaNaOaPaQaRaSaTQtQt",
291+
"QtQtaUaVaWaXaYaZa0a1a2a3a4a5a6a7a8a9b.QtQtQt",
292+
"QtQtb#babbbcbdbebfbgbhbibjbkblbmbnbobpQtQtQt",
293+
"QtQtbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFQtQtQtQt",
294+
"QtQtbGbHbIbJbKbLbMbNbObPbQbRbSbTbpQtQtQtQtQt",
295+
"QtQtbUbVbWbXbYbZb0b1b2b3b4b5b6#LQtQtQtQtQtQt",
296+
"QtQtQtQtb7b8bZbZb8b9c.c#cacbcccdcecfQtQtQtQt",
297+
"QtQtQtQtcgchcicichcjQtQtQtQtQtQtQtQtQtQtQtQt",
298+
"QtQtQtQtckclcmcncocpQtQtQtQtQtQtQtQtQtQtQtQt",
299+
"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt"};

‎src/plugins/wfs/qgswfsplugin.cpp

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/***************************************************************************
2+
qgswfsplugin.h
3+
-------------------
4+
begin : July 25, 2006
5+
copyright : (C) 2006 by Marco Hugentobler
6+
email : marco dot hugentobler at karto dot baug dot ethz dot ch
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+
#include "qgsproviderregistry.h"
19+
#include "qgswfssourceselect.h"
20+
#include "qgssinglesymbolrenderer.h"
21+
#include "qgsvectorlayer.h"
22+
#include "qgswfsplugin.h"
23+
#include "qgswfsprovider.h"
24+
25+
#include "mIconAddWfsLayer.xpm"
26+
27+
#ifdef WIN32
28+
#define QGISEXTERN extern "C" __declspec( dllexport )
29+
#else
30+
#define QGISEXTERN extern "C"
31+
#endif
32+
33+
QgsWFSPlugin::QgsWFSPlugin(QgisApp* app, QgisIface* iface): QgisPlugin("WFS plugin", "A plugin to add WFS layers to the QGIS canvas", "Version 0.0001", QgisPlugin::MAPLAYER), mApp(app), mIface(iface), mWfsDialogAction(0)
34+
{
35+
36+
}
37+
38+
QgsWFSPlugin::~QgsWFSPlugin()
39+
{
40+
delete mWfsDialogAction;
41+
}
42+
43+
void QgsWFSPlugin::initGui()
44+
{
45+
if(mIface)
46+
{
47+
//mIface->addVectorLayer("http://karlinapp.ethz.ch/cgi-bin/mapserv?map=/home/marco/mapfiles/mapfile1.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=states", "states", "WFS");
48+
//mIface->addVectorLayer("http://karlinapp.ethz.ch/cgi-bin/mapserv?map=/home/marco/mapfiles/mapfile1.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=usroads", "usroads", "WFS");
49+
//mIface->addVectorLayer("http://localhost/cgi-bin/mapserv?map=/var/www/mapfile_europe.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=mjrivers", "mjrivers", "WFS");
50+
//mIface->addVectorLayer("http://localhost/cgi-bin/mapserv?map=/var/www/mapfile_europe.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=cities", "cities", "WFS");
51+
//mIface->addVectorLayer("http://map.ns.ec.gc.ca/MapServer/mapserv.exe?map=/mapserver/services/envdat/config.map&service=WFS&version=1.0.0&request=GetFeature&TYPENAME=envirodat", "envirodat", "WFS");
52+
53+
mWfsDialogAction = new QAction(QIcon(mIconAddWfsLayer), tr("&Add WFS layer"), 0);
54+
QObject::connect(mWfsDialogAction, SIGNAL(activated()), this, SLOT(showSourceDialog()));
55+
mIface->addToolBarIcon(mWfsDialogAction);
56+
mIface->addPluginMenu(tr("&Add WFS layer"), mWfsDialogAction);
57+
}
58+
}
59+
60+
void QgsWFSPlugin::unload()
61+
{
62+
mIface->removeToolBarIcon(mWfsDialogAction);
63+
mIface->removePluginMenu(tr("&Add WFS layer"), mWfsDialogAction);
64+
delete mWfsDialogAction;
65+
mWfsDialogAction = 0;
66+
}
67+
68+
void QgsWFSPlugin::showSourceDialog()
69+
{
70+
QgsWFSSourceSelect serverDialog(0, mIface);
71+
serverDialog.exec();
72+
}
73+
74+
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
75+
{
76+
return new QgsWFSPlugin(theQGisAppPointer, theQgisInterfacePointer);
77+
}
78+
79+
QGISEXTERN QString name()
80+
{
81+
return QString("WFS plugin");
82+
}
83+
84+
QGISEXTERN QString description()
85+
{
86+
return QString("A plugin to add WFS layers to the QGIS canvas");
87+
}
88+
89+
QGISEXTERN QString version()
90+
{
91+
return QString("Version 0.0001");
92+
}
93+
94+
QGISEXTERN int type()
95+
{
96+
return QgisPlugin::UI;
97+
}
98+
99+
QGISEXTERN void unload(QgisPlugin* theQgsWFSPluginPointer)
100+
{
101+
delete theQgsWFSPluginPointer;
102+
}

‎src/plugins/wfs/qgswfsplugin.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
qgswfsplugin.h
3+
-------------------
4+
begin : July 25, 2006
5+
copyright : (C) 2006 by Marco Hugentobler
6+
email : marco dot hugentobler at karto dot baug dot ethz dot ch
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 QGSWFSPLUGIN_H
19+
#define QGSWFSPLUGIN_H
20+
21+
#include "qgisplugin.h"
22+
#include <QObject>
23+
24+
class QGisApp;
25+
class QgisIface;
26+
27+
/**A plugin for adding vector layers with the WFS provider*/
28+
class QgsWFSPlugin: public QObject, public QgisPlugin
29+
{
30+
Q_OBJECT
31+
public:
32+
QgsWFSPlugin(QgisApp* app, QgisIface* iface);
33+
~QgsWFSPlugin();
34+
/**initialize connection to GUI*/
35+
void initGui();
36+
/**Unload the plugin and cleanup the GUI*/
37+
void unload();
38+
39+
private:
40+
QgisApp* mApp;
41+
QgisIface* mIface;
42+
QAction* mWfsDialogAction;
43+
44+
private slots:
45+
void showSourceDialog();
46+
};
47+
48+
#endif
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/***************************************************************************
2+
qgswfssourceselect.cpp
3+
-------------------
4+
begin : August 25, 2006
5+
copyright : (C) 2006 by Marco Hugentobler
6+
email : marco dot hugentobler at karto dot baug dot ethz dot ch
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+
#include "qgisiface.h"
19+
#include "qgswfssourceselect.h"
20+
#include "../../providers/wfs/qgswfsprovider.h"
21+
#include "qgsnewhttpconnection.h"
22+
#include "qgslayerprojectionselector.h"
23+
#include <QListWidgetItem>
24+
#include <QMessageBox>
25+
#include <QSettings>
26+
27+
QgsWFSSourceSelect::QgsWFSSourceSelect(QWidget* parent, QgisIface* iface): QDialog(parent), mIface(iface)
28+
{
29+
setupUi(this);
30+
31+
connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
32+
connect(btnAdd, SIGNAL(clicked()), this, SLOT(addLayer()));
33+
connect(btnNew, SIGNAL(clicked()), this, SLOT(addEntryToServerList()));
34+
connect(btnEdit, SIGNAL(clicked()), this, SLOT(modifyEntryOfServerList()));
35+
connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteEntryOfServerList()));
36+
connect(btnConnect,SIGNAL(clicked()), this, SLOT(connectToServer()));
37+
connect(btnChangeSpatialRefSys, SIGNAL(clicked()), this, SLOT(changeCRS()));
38+
connect(lstWidget, SIGNAL(currentRowChanged(int)), this, SLOT(changeCRSFilter()));
39+
populateConnectionList();
40+
41+
mProjectionSelector = new QgsLayerProjectionSelector(this);
42+
}
43+
44+
QgsWFSSourceSelect::~QgsWFSSourceSelect()
45+
{
46+
delete mProjectionSelector;
47+
}
48+
49+
void QgsWFSSourceSelect::populateConnectionList()
50+
{
51+
QSettings settings;
52+
QStringList keys = settings.subkeyList("/Qgis/connections-wfs");
53+
QStringList::Iterator it = keys.begin();
54+
cmbConnections->clear();
55+
while (it != keys.end())
56+
{
57+
cmbConnections->insertItem(*it);
58+
++it;
59+
}
60+
61+
if (keys.begin() != keys.end())
62+
{
63+
// Connections available - enable various buttons
64+
btnConnect->setEnabled(TRUE);
65+
btnEdit->setEnabled(TRUE);
66+
btnDelete->setEnabled(TRUE);
67+
}
68+
69+
else
70+
{
71+
// No connections available - disable various buttons
72+
btnConnect->setEnabled(FALSE);
73+
btnEdit->setEnabled(FALSE);
74+
btnDelete->setEnabled(FALSE);
75+
}
76+
}
77+
78+
void QgsWFSSourceSelect::addEntryToServerList()
79+
{
80+
QgsNewHttpConnection *nc = new QgsNewHttpConnection(this, "/Qgis/connections-wfs/");
81+
82+
if (nc->exec())
83+
{
84+
populateConnectionList();
85+
}
86+
}
87+
88+
void QgsWFSSourceSelect::modifyEntryOfServerList()
89+
{
90+
QgsNewHttpConnection nc(0, "/Qgis/connections-wfs/", cmbConnections->currentText());
91+
92+
if (nc.exec())
93+
{
94+
nc.saveConnection();
95+
}
96+
populateConnectionList();
97+
}
98+
99+
void QgsWFSSourceSelect::deleteEntryOfServerList()
100+
{
101+
QSettings settings;
102+
QString key = "/Qgis/connections-wfs/" + cmbConnections->currentText();
103+
QString msg =
104+
tr("Are you sure you want to remove the ") + cmbConnections->currentText() + tr(" connection and all associated settings?");
105+
int result = QMessageBox::information(this, tr("Confirm Delete"), msg, tr("Yes"), tr("No"));
106+
if (result == 0)
107+
{
108+
settings.remove(key);
109+
cmbConnections->removeItem(cmbConnections->currentItem());
110+
}
111+
}
112+
113+
void QgsWFSSourceSelect::connectToServer()
114+
{
115+
//find out the server URL
116+
QSettings settings;
117+
QString key = "/Qgis/connections-wfs/" + cmbConnections->currentText() + "/url";
118+
mUri = settings.value(key).toString();
119+
qWarning("url is: " + mUri);
120+
121+
//make a GetCapabilities request
122+
std::list<QString> typenames;
123+
std::list< std::list<QString> > crsList;
124+
if(QgsWFSProvider::getCapabilities(mUri, QgsWFSProvider::GET, typenames, crsList) != 0)
125+
{
126+
qWarning("error during GetCapabilities request");
127+
}
128+
129+
//insert the available CRS into mAvailableCRS
130+
mAvailableCRS.clear();
131+
std::list<QString>::const_iterator typeNameIter;
132+
std::list< std::list<QString> >::const_iterator crsIter;
133+
for(typeNameIter = typenames.begin(), crsIter = crsList.begin(); typeNameIter != typenames.end(); ++typeNameIter, ++crsIter)
134+
{
135+
std::list<QString> currentCRSList;
136+
for(std::list<QString>::const_iterator it = crsIter->begin(); it != crsIter->end(); ++it)
137+
{
138+
currentCRSList.push_back(*it);
139+
}
140+
mAvailableCRS.insert(std::make_pair(*typeNameIter, currentCRSList));
141+
}
142+
143+
//insert the typenames into the list view
144+
lstWidget->clear();
145+
for(std::list<QString>::const_iterator it = typenames.begin(); it != typenames.end(); ++it)
146+
{
147+
lstWidget->addItem(*it);
148+
}
149+
150+
if(typenames.size() > 0)
151+
{
152+
btnAdd->setEnabled(true);
153+
lstWidget->setCurrentRow(0);
154+
btnChangeSpatialRefSys->setEnabled(true);
155+
}
156+
else
157+
{
158+
btnAdd->setEnabled(false);
159+
}
160+
161+
162+
}
163+
164+
void QgsWFSSourceSelect::addLayer()
165+
{
166+
//get selected entry in lstWidget
167+
QListWidgetItem* cItem = lstWidget->currentItem();
168+
if(!cItem)
169+
{
170+
return;
171+
}
172+
QString typeName = cItem->text();
173+
qWarning(mUri + "SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=" + typeName);
174+
175+
//get CRS
176+
QString crsString;
177+
if(mProjectionSelector)
178+
{
179+
long epsgNr = mProjectionSelector->getCurrentEpsg();
180+
if(epsgNr != 0)
181+
{
182+
crsString = "&SRSNAME=EPSG:"+QString::number(epsgNr);
183+
}
184+
}
185+
//add a wfs layer to the map
186+
if(mIface)
187+
{
188+
qWarning(mUri + "SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=" + typeName + crsString);
189+
mIface->addVectorLayer(mUri + "SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=" + typeName + crsString, typeName, "WFS");
190+
}
191+
accept();
192+
}
193+
194+
void QgsWFSSourceSelect::changeCRS()
195+
{
196+
if(mProjectionSelector->exec())
197+
{
198+
199+
}
200+
}
201+
202+
void QgsWFSSourceSelect::changeCRSFilter()
203+
{
204+
//evaluate currently selected typename and set the CRS filter in mProjectionSelector
205+
QListWidgetItem* currentListItem = lstWidget->currentItem();
206+
if(currentListItem)
207+
{
208+
QString currentTypename = currentListItem->text();
209+
qWarning("the current typename is: " + currentTypename);
210+
211+
std::map<QString, std::list<QString> >::const_iterator crsIterator = mAvailableCRS.find(currentTypename);
212+
if(crsIterator != mAvailableCRS.end())
213+
{
214+
std::list<QString> crsList = crsIterator->second;
215+
QSet<QString> crsSet;
216+
for(std::list<QString>::const_iterator it = crsList.begin(); it != crsList.end(); ++it)
217+
{
218+
qWarning("inserting " + *it);
219+
crsSet.insert(*it);
220+
}
221+
if(mProjectionSelector)
222+
{
223+
mProjectionSelector->setOgcWmsCrsFilter(crsSet);
224+
}
225+
}
226+
}
227+
}

‎src/plugins/wfs/qgswfssourceselect.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/***************************************************************************
2+
qgswfssourceselect.h
3+
-------------------
4+
begin : August 25, 2006
5+
copyright : (C) 2006 by Marco Hugentobler
6+
email : marco dot hugentobler at karto dot baug dot ethz dot ch
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 QGSWFSSOURCESELECT_H
19+
#define QGSWFSSOURCESELECT_H
20+
21+
#include "ui_qgswfssourceselectbase.h"
22+
23+
class QgisIface;
24+
class QgsLayerProjectionSelector;
25+
26+
class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase
27+
{
28+
Q_OBJECT
29+
public:
30+
QgsWFSSourceSelect(QWidget* parent, QgisIface* iface);
31+
~QgsWFSSourceSelect();
32+
33+
private:
34+
QgsWFSSourceSelect(); //default constructor is forbidden
35+
QgisIface* mIface; //pointer to the QGIS interface object (needed to add WFS layers)
36+
QString mUri; //uri of the currently connected server
37+
QgsLayerProjectionSelector* mProjectionSelector;
38+
/**Stores the available CRS for a server connections.
39+
The first string is the typename, the corresponding list
40+
stores the CRS for the typename in the form 'EPSG:XXXX'*/
41+
std::map<QString, std::list<QString> > mAvailableCRS;
42+
void populateConnectionList();
43+
44+
private slots:
45+
void addEntryToServerList();
46+
void modifyEntryOfServerList();
47+
void deleteEntryOfServerList();
48+
void connectToServer();
49+
void addLayer();
50+
void changeCRS();
51+
void changeCRSFilter();
52+
};
53+
54+
#endif
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
<ui version="4.0" >
2+
<author></author>
3+
<comment></comment>
4+
<exportmacro></exportmacro>
5+
<class>QgsWFSSourceSelectBase</class>
6+
<widget class="QDialog" name="QgsWFSSourceSelectBase" >
7+
<property name="geometry" >
8+
<rect>
9+
<x>0</x>
10+
<y>0</y>
11+
<width>577</width>
12+
<height>444</height>
13+
</rect>
14+
</property>
15+
<property name="windowTitle" >
16+
<string>Dialog</string>
17+
</property>
18+
<layout class="QGridLayout" >
19+
<property name="margin" >
20+
<number>9</number>
21+
</property>
22+
<property name="spacing" >
23+
<number>6</number>
24+
</property>
25+
<item row="0" column="0" >
26+
<widget class="QGroupBox" name="GroupBox1" >
27+
<property name="title" >
28+
<string>Server Connections</string>
29+
</property>
30+
<layout class="QGridLayout" >
31+
<property name="margin" >
32+
<number>9</number>
33+
</property>
34+
<property name="spacing" >
35+
<number>6</number>
36+
</property>
37+
<item row="1" column="1" >
38+
<widget class="QPushButton" name="btnNew" >
39+
<property name="text" >
40+
<string>&amp;New</string>
41+
</property>
42+
</widget>
43+
</item>
44+
<item row="1" column="3" >
45+
<widget class="QPushButton" name="btnDelete" >
46+
<property name="enabled" >
47+
<bool>false</bool>
48+
</property>
49+
<property name="text" >
50+
<string>Delete</string>
51+
</property>
52+
</widget>
53+
</item>
54+
<item row="1" column="2" >
55+
<widget class="QPushButton" name="btnEdit" >
56+
<property name="enabled" >
57+
<bool>false</bool>
58+
</property>
59+
<property name="text" >
60+
<string>Edit</string>
61+
</property>
62+
</widget>
63+
</item>
64+
<item row="1" column="4" >
65+
<spacer>
66+
<property name="orientation" >
67+
<enum>Qt::Horizontal</enum>
68+
</property>
69+
<property name="sizeType" >
70+
<enum>QSizePolicy::Expanding</enum>
71+
</property>
72+
<property name="sizeHint" >
73+
<size>
74+
<width>171</width>
75+
<height>30</height>
76+
</size>
77+
</property>
78+
</spacer>
79+
</item>
80+
<item row="1" column="0" >
81+
<widget class="QPushButton" name="btnConnect" >
82+
<property name="enabled" >
83+
<bool>false</bool>
84+
</property>
85+
<property name="text" >
86+
<string>C&amp;onnect</string>
87+
</property>
88+
</widget>
89+
</item>
90+
<item row="0" column="0" colspan="5" >
91+
<widget class="QComboBox" name="cmbConnections" />
92+
</item>
93+
</layout>
94+
</widget>
95+
</item>
96+
<item row="1" column="0" >
97+
<widget class="QListWidget" name="lstWidget" />
98+
</item>
99+
<item row="3" column="0" >
100+
<layout class="QHBoxLayout" >
101+
<property name="margin" >
102+
<number>0</number>
103+
</property>
104+
<property name="spacing" >
105+
<number>6</number>
106+
</property>
107+
<item>
108+
<widget class="QPushButton" name="btnHelp" >
109+
<property name="enabled" >
110+
<bool>true</bool>
111+
</property>
112+
<property name="text" >
113+
<string>Help</string>
114+
</property>
115+
<property name="shortcut" >
116+
<string>F1</string>
117+
</property>
118+
<property name="autoDefault" >
119+
<bool>true</bool>
120+
</property>
121+
</widget>
122+
</item>
123+
<item>
124+
<spacer>
125+
<property name="orientation" >
126+
<enum>Qt::Horizontal</enum>
127+
</property>
128+
<property name="sizeType" >
129+
<enum>QSizePolicy::Expanding</enum>
130+
</property>
131+
<property name="sizeHint" >
132+
<size>
133+
<width>111</width>
134+
<height>31</height>
135+
</size>
136+
</property>
137+
</spacer>
138+
</item>
139+
<item>
140+
<widget class="QPushButton" name="btnAdd" >
141+
<property name="enabled" >
142+
<bool>false</bool>
143+
</property>
144+
<property name="text" >
145+
<string>&amp;Add</string>
146+
</property>
147+
<property name="shortcut" >
148+
<string>Alt+A</string>
149+
</property>
150+
<property name="autoDefault" >
151+
<bool>true</bool>
152+
</property>
153+
<property name="default" >
154+
<bool>true</bool>
155+
</property>
156+
</widget>
157+
</item>
158+
<item>
159+
<widget class="QPushButton" name="btnCancel" >
160+
<property name="text" >
161+
<string>C&amp;lose</string>
162+
</property>
163+
<property name="shortcut" >
164+
<string>Alt+L</string>
165+
</property>
166+
<property name="autoDefault" >
167+
<bool>true</bool>
168+
</property>
169+
</widget>
170+
</item>
171+
</layout>
172+
</item>
173+
<item row="2" column="0" >
174+
<widget class="QGroupBox" name="gbCRS" >
175+
<property name="title" >
176+
<string>Coordinate Reference System</string>
177+
</property>
178+
<layout class="QHBoxLayout" >
179+
<property name="margin" >
180+
<number>9</number>
181+
</property>
182+
<property name="spacing" >
183+
<number>6</number>
184+
</property>
185+
<item>
186+
<widget class="QLabel" name="labelCoordRefSys" >
187+
<property name="text" >
188+
<string/>
189+
</property>
190+
</widget>
191+
</item>
192+
<item>
193+
<spacer>
194+
<property name="orientation" >
195+
<enum>Qt::Horizontal</enum>
196+
</property>
197+
<property name="sizeType" >
198+
<enum>QSizePolicy::Expanding</enum>
199+
</property>
200+
<property name="sizeHint" >
201+
<size>
202+
<width>441</width>
203+
<height>23</height>
204+
</size>
205+
</property>
206+
</spacer>
207+
</item>
208+
<item>
209+
<widget class="QPushButton" name="btnChangeSpatialRefSys" >
210+
<property name="enabled" >
211+
<bool>false</bool>
212+
</property>
213+
<property name="text" >
214+
<string>Change ...</string>
215+
</property>
216+
</widget>
217+
</item>
218+
</layout>
219+
</widget>
220+
</item>
221+
</layout>
222+
</widget>
223+
<pixmapfunction></pixmapfunction>
224+
<resources/>
225+
<connections/>
226+
</ui>

0 commit comments

Comments
 (0)
Please sign in to comment.