Skip to content

Commit ce2b35d

Browse files
author
morb_au
committedMar 2, 2006
Improvements to WMS - users can now see what projections are available for their chosen layers. (However, the projection they select is not hooked up to anything yet.) Also, the projection selector now shows groupings in italics, for better visual distinction.
* QgsServerSourceSelect is now hooked up to QgsLayerProjectionSelector. * QgsLayerProjectionSelector and QgsProjectionSelector can now filter their results by a list of WMS-format CRSs (Coordinate Reference Systems). * QgsProjectionSelector now delays the calling of getProjList() and getUserProjList() until the filter has a chance to be set (using the new setOgcWmsCrsFilter). * The projection databases now have epsg added to the view so that it too can be searched upon. * Early works on the WMS Provider itself to accept new CRSs. Not hooked up to anything useful yet though. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4937 c8812cc2-4d05-0410-92ff-de0c093fc19c

11 files changed

+641
-87
lines changed
 

‎resources/qgis.db

0 Bytes
Binary file not shown.

‎resources/srs.db

0 Bytes
Binary file not shown.

‎src/gui/qgslayerprojectionselector.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
* \class QgsLayerProjectionSelector - Set user layerprojectionselector and preferences
2424
* Constructor
2525
*/
26-
QgsLayerProjectionSelector::QgsLayerProjectionSelector(QWidget *parent, Qt::WFlags fl)
26+
QgsLayerProjectionSelector::QgsLayerProjectionSelector(QWidget *parent,
27+
Qt::WFlags fl)
2728
: QDialog(parent, fl)
2829
{
2930
setupUi(this);
@@ -40,10 +41,12 @@ void QgsLayerProjectionSelector::setSelectedSRSName(QString theName)
4041
{
4142
projectionSelector->setSelectedSRSName(theName);
4243
}
44+
4345
void QgsLayerProjectionSelector::setSelectedSRSID(long theID)
4446
{
4547
projectionSelector->setSelectedSRSID(theID);
4648
}
49+
4750
QString QgsLayerProjectionSelector::getCurrentProj4String()
4851
{
4952
//@NOTE dont use getSelectedWKT as that just returns the name part!
@@ -55,3 +58,14 @@ long QgsLayerProjectionSelector::getCurrentSRSID()
5558
//@NOTE dont use getSelectedWKT as that just returns the name part!
5659
return projectionSelector->getCurrentSRSID();
5760
}
61+
62+
long QgsLayerProjectionSelector::getCurrentEpsg()
63+
{
64+
return projectionSelector->getCurrentEpsg();
65+
}
66+
67+
void QgsLayerProjectionSelector::setOgcWmsCrsFilter(QSet<QString> crsFilter)
68+
{
69+
projectionSelector->setOgcWmsCrsFilter(crsFilter);
70+
}
71+

‎src/gui/qgslayerprojectionselector.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,52 @@
2020
#define QGSLAYERPROJECTIONSELECTOR_H
2121
#include "ui_qgslayerprojectionselectorbase.h"
2222
#include "qgisgui.h"
23+
24+
#include <QSet>
25+
2326
/**
2427
* \class QgsLayerProjectionSelector
2528
* \brief Set Projection system for a layer
2629
*/
30+
2731
class QgsLayerProjectionSelector : public QDialog, private Ui::QgsLayerProjectionSelectorBase
2832
{
2933
Q_OBJECT;
3034
public:
3135
/**
3236
* Constructor
3337
*/
34-
QgsLayerProjectionSelector(QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags);
38+
QgsLayerProjectionSelector(QWidget *parent = 0,
39+
Qt::WFlags fl = QgisGui::ModalDialogFlags);
40+
3541
//! Destructor
3642
~QgsLayerProjectionSelector();
3743

3844
public slots:
3945
QString getCurrentProj4String();
4046
long getCurrentSRSID();
47+
long getCurrentEpsg();
48+
4149
void setSelectedSRSName(QString theName);
4250
void setSelectedSRSID(long theID);
51+
52+
/**
53+
* \brief filters this dialog by the given CRSs
54+
*
55+
* Sets this dialog to filter the available projections to those listed
56+
* by the given Coordinate Reference Systems.
57+
*
58+
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
59+
* list of projections by. This is useful in (e.g.) WMS situations
60+
* where you just want to offer what the WMS server can support.
61+
*
62+
* \note This function only deals with EPSG labels only at this time.
63+
*
64+
* \warning This function's behaviour is undefined if it is called after the dialog is shown.
65+
*/
66+
void setOgcWmsCrsFilter(QSet<QString> crsFilter);
67+
68+
4369
};
4470

4571
#endif // #ifndef QGSLAYERPROJECTIONSELECTOR_H

‎src/gui/qgsserversourceselect.cpp

Lines changed: 116 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818

1919
#include "qgsserversourceselect.h"
2020

21+
#include "qgslayerprojectionselector.h"
22+
2123
#include "qgsnewhttpconnection.h"
2224
#include "qgsnumericsortlistviewitem.h"
2325
#include "qgsproviderregistry.h"
2426
#include "../providers/wms/qgswmsprovider.h"
2527
#include "qgscontexthelp.h"
2628

29+
#include "qgsproject.h"
30+
2731
#include <QMessageBox>
2832
#include <QPicture>
2933
#include <QSettings>
@@ -33,7 +37,9 @@
3337

3438
QgsServerSourceSelect::QgsServerSourceSelect(QgisApp * app, QWidget * parent, Qt::WFlags fl)
3539
: QDialog(parent, fl),
36-
qgisApp(app)
40+
qgisApp(app),
41+
wmsProvider(0),
42+
m_Epsg(0)
3743
{
3844
setupUi(this);
3945
connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
@@ -153,7 +159,7 @@ void QgsServerSourceSelect::populateLayerList(QgsWmsProvider* wmsProvider)
153159
{
154160

155161
#ifdef QGISDEBUG
156-
std::cout << "QgsServerSourceSelect::populateLayerList: got layer name " << layer->name.toLocal8Bit().data() << " and title '" << layer->title.toLocal8Bit().data() << "'." << std::endl;
162+
// std::cout << "QgsServerSourceSelect::populateLayerList: got layer name " << layer->name.toLocal8Bit().data() << " and title '" << layer->title.toLocal8Bit().data() << "'." << std::endl;
157163
#endif
158164

159165
layerAndStyleCount++;
@@ -266,6 +272,36 @@ void QgsServerSourceSelect::populateImageEncodingGroup(QgsWmsProvider* wmsProvid
266272
}
267273

268274

275+
std::set<QString> QgsServerSourceSelect::crsForSelection()
276+
{
277+
std::set<QString> crsCandidates;;
278+
279+
QStringList::const_iterator i;
280+
for (i = m_selectedLayers.constBegin(); i != m_selectedLayers.constEnd(); ++i)
281+
{
282+
/*
283+
284+
for ( int j = 0; j < ilayerProperty.boundingBox.size(); i++ )
285+
{
286+
#ifdef QGISDEBUG
287+
std::cout << "QgsWmsProvider::parseLayer: testing bounding box CRS which is "
288+
<< layerProperty.boundingBox[i].crs.toLocal8Bit().data() << "." << std::endl;
289+
#endif
290+
if ( layerProperty.boundingBox[i].crs == DEFAULT_LATLON_CRS )
291+
{
292+
extentForLayer[ layerProperty.name ] =
293+
layerProperty.boundingBox[i].box;
294+
}
295+
}
296+
297+
298+
if
299+
cout << (*i).ascii() << endl;*/
300+
}
301+
302+
}
303+
304+
269305
void QgsServerSourceSelect::on_btnConnect_clicked()
270306
{
271307
// populate the table list
@@ -301,19 +337,26 @@ void QgsServerSourceSelect::on_btnConnect_clicked()
301337
#ifdef QGISDEBUG
302338
std::cout << "QgsServerSourceSelect::serverConnect: Connection info: '" << m_connInfo.toLocal8Bit().data() << "'." << std::endl;
303339
#endif
304-
305-
340+
341+
306342
// TODO: Create and bind to data provider
307-
343+
308344
// load the server data provider plugin
309345
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
310-
311-
QgsWmsProvider* wmsProvider =
346+
347+
wmsProvider =
312348
(QgsWmsProvider*) pReg->getProvider( "wms", m_connInfo );
313349

314-
connect(wmsProvider, SIGNAL(setStatus(QString)), this, SLOT(showStatusMessage(QString)));
350+
if (wmsProvider)
351+
{
352+
connect(wmsProvider, SIGNAL(setStatus(QString)), this, SLOT(showStatusMessage(QString)));
315353

316-
populateLayerList(wmsProvider);
354+
populateLayerList(wmsProvider);
355+
}
356+
else
357+
{
358+
// TODO: Let user know we couldn't initialise the WMS provider
359+
}
317360

318361
}
319362

@@ -330,6 +373,43 @@ void QgsServerSourceSelect::on_btnAdd_clicked()
330373
}
331374

332375

376+
void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
377+
{
378+
if (!wmsProvider)
379+
{
380+
return;
381+
}
382+
383+
QSet<QString> crsFilter = wmsProvider->supportedCrsForLayers(m_selectedLayers);
384+
385+
QgsLayerProjectionSelector * mySelector =
386+
new QgsLayerProjectionSelector(this);
387+
388+
mySelector->setOgcWmsCrsFilter(crsFilter);
389+
390+
long myDefaultSRS = QgsProject::instance()->readNumEntry("SpatialRefSys", "/ProjectSRSID", GEOSRS_ID);
391+
392+
mySelector->setSelectedSRSID(myDefaultSRS);
393+
394+
if (mySelector->exec())
395+
{
396+
// TODO: assign EPSG back to the WMS provider
397+
m_Epsg = mySelector->getCurrentEpsg();
398+
}
399+
else
400+
{
401+
// NOOP
402+
}
403+
404+
labelSpatialRefSys->setText( mySelector->getCurrentProj4String() );
405+
406+
delete mySelector;
407+
408+
// update the display of this widget
409+
this->update();
410+
}
411+
412+
333413
/**
334414
* This function is used to:
335415
* 1. Store the list of selected layers and visual styles as appropriate.
@@ -347,10 +427,9 @@ void QgsServerSourceSelect::on_lstLayers_selectionChanged()
347427

348428
// Iterate through the layers
349429
Q3ListViewItemIterator it( lstLayers );
350-
while ( it.current() )
430+
while ( it.current() )
351431
{
352432
Q3ListViewItem *item = it.current();
353-
++it;
354433

355434
// save the name of the layer (in case only one of its styles was
356435
// selected)
@@ -391,6 +470,18 @@ void QgsServerSourceSelect::on_lstLayers_selectionChanged()
391470
#endif
392471

393472
}
473+
474+
++it;
475+
}
476+
477+
// If we got some selected items, let the user play with projections
478+
if (newSelectedLayers.count() > 0)
479+
{
480+
btnChangeSpatialRefSys->setEnabled(TRUE);
481+
}
482+
else
483+
{
484+
btnChangeSpatialRefSys->setEnabled(FALSE);
394485
}
395486

396487
m_selectedLayers = newSelectedLayers;
@@ -434,6 +525,19 @@ QString QgsServerSourceSelect::selectedImageEncoding()
434525

435526
}
436527

528+
QString QgsServerSourceSelect::selectedCrs()
529+
{
530+
if (m_Epsg)
531+
{
532+
return QString("EPSG:%1")
533+
.arg(m_Epsg);
534+
}
535+
else
536+
{
537+
return QString();
538+
}
539+
}
540+
437541
void QgsServerSourceSelect::showStatusMessage(QString const & theMessage)
438542
{
439543
labelStatus->setText(theMessage);
@@ -443,5 +547,4 @@ void QgsServerSourceSelect::showStatusMessage(QString const & theMessage)
443547
}
444548

445549

446-
447-
550+
// ENDS

‎src/gui/qgsserversourceselect.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <vector>
2525
#include <map>
26+
#include <set>
2627

2728
class QgisApp;
2829
class QgsWmsProvider;
@@ -62,6 +63,10 @@ class QgsServerSourceSelect : public QDialog, private Ui::QgsServerSourceSelectB
6263
//! String containing the MIME type of the preferred image encoding
6364
QString selectedImageEncoding();
6465

66+
//! String containing the selected WMS-format CRS
67+
QString selectedCrs();
68+
69+
6570
public slots:
6671

6772
//! Opens the create connection dialog to build a new connection
@@ -79,6 +84,9 @@ public slots:
7984
//! Determines the layers the user selected and closes the dialog
8085
void on_btnAdd_clicked();
8186

87+
//! Opens the Spatial Reference System dialog.
88+
void on_btnChangeSpatialRefSys_clicked();
89+
8290
//! Opens help application
8391
void on_btnHelp_clicked();
8492

@@ -97,10 +105,14 @@ public slots:
97105
//! Populate the image encoding button group - private for now.
98106
void populateImageEncodingGroup(QgsWmsProvider* wmsProvider);
99107

108+
//! Returns the common CRSs for the selected layers.
109+
std::set<QString> crsForSelection();
110+
100111
QString m_connName;
101112
QString m_connInfo;
102113
QStringList m_selectedLayers;
103114
QStringList m_selectedStylesForSelectedLayers;
115+
long m_Epsg;
104116

105117
std::map<QString, QString> m_selectedStyleIdForLayer;
106118

@@ -113,6 +125,9 @@ public slots:
113125
//! The widget that controls the image format radio buttons
114126
QButtonGroup* m_imageFormatBtns;
115127

128+
//! The WMS provider that retreives information for this dialog
129+
QgsWmsProvider * wmsProvider;
130+
116131
static const int context_id = 710979116;
117132
};
118133

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,38 @@ std::vector<QgsWmsLayerProperty> QgsWmsProvider::supportedLayers()
183183
}
184184

185185

186+
QSet<QString> QgsWmsProvider::supportedCrsForLayers(QStringList const & layers)
187+
{
188+
QSet<QString> crsCandidates;
186189

190+
QStringList::const_iterator i;
191+
for (i = layers.constBegin(); i != layers.constEnd(); ++i)
192+
{
193+
std::vector<QString> crsVector = crsForLayer[*i];
194+
QSet<QString> crsSet;
195+
196+
// convert std::vector to std::set for set comparisons
197+
for (int j = 0; j < crsVector.size(); j++)
198+
{
199+
crsSet.insert( crsVector[j] );
200+
}
201+
202+
// first time through?
203+
if ( i == layers.constBegin() )
204+
{
205+
// do initial population of set
206+
crsCandidates = crsSet;
207+
}
208+
else
209+
{
210+
// do lowest common denominator (set intersection)
211+
crsCandidates.intersect(crsSet);
212+
}
213+
214+
}
215+
216+
return crsCandidates;
217+
}
187218

188219

189220
size_t QgsWmsProvider::layerCount() const
@@ -192,8 +223,6 @@ size_t QgsWmsProvider::layerCount() const
192223
} // QgsWmsProvider::layerCount()
193224

194225

195-
196-
197226
void QgsWmsProvider::addLayers(QStringList const & layers,
198227
QStringList const & styles)
199228
{
@@ -261,6 +290,16 @@ void QgsWmsProvider::setImageEncoding(QString const & mimeType)
261290
}
262291

263292

293+
void QgsWmsProvider::setImageCrs(QString const & crs)
294+
{
295+
#ifdef QGISDEBUG
296+
std::cout << "QgsWmsProvider::setImageCrs: Setting image CRS to " << crs.toLocal8Bit().data() << "." <<
297+
std::endl;
298+
#endif
299+
imageCrs = crs;
300+
}
301+
302+
264303
QImage* QgsWmsProvider::draw(QgsRect const & viewExtent, int pixelWidth, int pixelHeight)
265304
{
266305
#ifdef QGISDEBUG
@@ -1311,6 +1350,10 @@ void QgsWmsProvider::parseLayer(QDomElement const & e, QgsWmsLayerProperty& laye
13111350
// TODO: Save this somewhere
13121351

13131352

1353+
// Store the available Coordinate Reference Systems for the layer so that it
1354+
// can be combined with others later in supportedCrsForLayers()
1355+
crsForLayer[ layerProperty.name ] = layerProperty.crs;
1356+
13141357
// Store the WGS84 (CRS:84) extent so that it can be combined with others later
13151358
// in calculateExtent()
13161359

‎src/providers/wms/qgswmsprovider.h

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <map>
2525
#include <vector>
2626

27+
#include <QSet>
28+
2729
#include "qgsrasterdataprovider.h"
2830
#include "qgsrect.h"
2931

@@ -356,10 +358,18 @@ class QgsWmsProvider : public QgsRasterDataProvider
356358
virtual ~QgsWmsProvider();
357359

358360
// TODO: Document this better, make static
359-
/** \brief Returns a list of the supported layers of this WMS
361+
/** \brief Returns a list of the supported layers of the WMS server
360362
*/
361363
virtual std::vector<QgsWmsLayerProperty> supportedLayers();
362364

365+
// TODO: Document this better
366+
/** \brief Returns a list of the supported CRSs of the given layers
367+
* \note Since WMS can specify CRSs per layer, this may change depending
368+
on which layers are specified! The "lowest common denominator" between
369+
all specified layers is returned.
370+
*/
371+
virtual QSet<QString> supportedCrsForLayers(QStringList const & layers);
372+
363373
/**
364374
* Add the list of WMS layer names to be rendered by this server
365375
*/
@@ -380,17 +390,22 @@ class QgsWmsProvider : public QgsRasterDataProvider
380390
* (in order from bottom to top)
381391
* \note layers must have been previously added.
382392
*/
383-
void setLayerOrder(QStringList const & layers);
393+
void setLayerOrder(QStringList const & layers);
384394

385395
/**
386396
* Set the visibility of the given sublayer name
387397
*/
388-
void setSubLayerVisibility(QString const & name, bool vis);
398+
void setSubLayerVisibility(QString const & name, bool vis);
389399

390400
/**
391401
* Set the image encoding (as a MIME type) used in the transfer from the WMS server
392402
*/
393-
void setImageEncoding(QString const & mimeType);
403+
void setImageEncoding(QString const & mimeType);
404+
405+
/**
406+
* Set the image projection (in WMS CRS format) used in the transfer from the WMS server
407+
*/
408+
void setImageCrs(QString const & crs);
394409

395410
// TODO: Document this better.
396411
/** \brief Renders the layer as an image
@@ -654,7 +669,12 @@ public slots:
654669
* extents per layer (in WMS CRS:84 datum)
655670
*/
656671
std::map<QString, QgsRect> extentForLayer;
657-
672+
673+
/**
674+
* available CRSs per layer
675+
*/
676+
std::map<QString, std::vector<QString> > crsForLayer;
677+
658678
/**
659679
* Active sublayers managed by this provider in a draw function, in order from bottom to top
660680
* (some may not be visible in a draw function, cf. activeSubLayerVisibility)
@@ -673,6 +693,11 @@ public slots:
673693
*/
674694
QString imageMimeType;
675695

696+
/**
697+
* WMS CRS type of the image CRS used from the WMS server
698+
*/
699+
QString imageCrs;
700+
676701
/**
677702
* The previously retrieved image from the WMS server.
678703
* This can be reused if draw() is called consecutively

‎src/ui/qgsserversourceselectbase.ui

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<x>0</x>
1010
<y>0</y>
1111
<width>600</width>
12-
<height>400</height>
12+
<height>505</height>
1313
</rect>
1414
</property>
1515
<property name="windowTitle" >
@@ -240,6 +240,21 @@
240240
</layout>
241241
</widget>
242242
</item>
243+
<item row="5" column="0" colspan="4" >
244+
<widget class="QLabel" name="labelStatus" >
245+
<property name="sizePolicy" >
246+
<sizepolicy>
247+
<hsizetype>7</hsizetype>
248+
<vsizetype>5</vsizetype>
249+
<horstretch>0</horstretch>
250+
<verstretch>0</verstretch>
251+
</sizepolicy>
252+
</property>
253+
<property name="text" >
254+
<string>Ready</string>
255+
</property>
256+
</widget>
257+
</item>
243258
<item row="3" column="0" colspan="4" >
244259
<widget class="QGroupBox" name="btnGrpSrs" >
245260
<property name="title" >
@@ -252,10 +267,17 @@
252267
<property name="spacing" >
253268
<number>6</number>
254269
</property>
270+
<item>
271+
<widget class="QLabel" name="labelSpatialRefSys" >
272+
<property name="text" >
273+
<string>CRS is </string>
274+
</property>
275+
</widget>
276+
</item>
255277
<item>
256278
<widget class="QRadioButton" name="radioButtonEspg4326" >
257279
<property name="text" >
258-
<string>ESPG:4326</string>
280+
<string>EPSG:4326</string>
259281
</property>
260282
</widget>
261283
</item>
@@ -275,24 +297,19 @@
275297
</property>
276298
</spacer>
277299
</item>
300+
<item>
301+
<widget class="QPushButton" name="btnChangeSpatialRefSys" >
302+
<property name="enabled" >
303+
<bool>false</bool>
304+
</property>
305+
<property name="text" >
306+
<string>Change ...</string>
307+
</property>
308+
</widget>
309+
</item>
278310
</layout>
279311
</widget>
280312
</item>
281-
<item row="5" column="0" colspan="4" >
282-
<widget class="QLabel" name="labelStatus" >
283-
<property name="sizePolicy" >
284-
<sizepolicy>
285-
<hsizetype>7</hsizetype>
286-
<vsizetype>5</vsizetype>
287-
<horstretch>0</horstretch>
288-
<verstretch>0</verstretch>
289-
</sizepolicy>
290-
</property>
291-
<property name="text" >
292-
<string>Ready</string>
293-
</property>
294-
</widget>
295-
</item>
296313
</layout>
297314
</widget>
298315
<layoutdefault spacing="6" margin="11" />

‎src/widgets/projectionselector/qgsprojectionselector.cpp

Lines changed: 235 additions & 40 deletions
Large diffs are not rendered by default.

‎src/widgets/projectionselector/qgsprojectionselector.h

Lines changed: 124 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include "ui_qgsprojectionselectorbase.h"
1414

15+
#include <QSet>
16+
1517
class QResizeEvent;
1618

1719
/**
@@ -21,13 +23,36 @@ class QgsProjectionSelector: public QWidget, private Ui::QgsProjectionSelectorBa
2123
{
2224
Q_OBJECT
2325
public:
24-
QgsProjectionSelector( QWidget* parent , const char* name="", Qt::WFlags fl =0 );
26+
QgsProjectionSelector(QWidget* parent,
27+
const char * name = "",
28+
Qt::WFlags fl = 0);
29+
2530
~QgsProjectionSelector();
26-
//! Populate the proj tree view with user defined projection names...
27-
void getUserProjList();
28-
//! Populate the proj tree view with system projection names...
29-
void getProjList();
30-
void updateProjAndEllipsoidAcronyms(int theSrsid,QString theProj4String);
31+
32+
/**
33+
* \brief Populate the proj tree view with user defined projection names...
34+
*
35+
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
36+
* list of projections by. This is useful in (e.g.) WMS situations
37+
* where you just want to offer what the WMS server can support.
38+
*
39+
* \todo Should this be public?
40+
*/
41+
void applyUserProjList(QSet<QString> * crsFilter = 0);
42+
43+
/**
44+
* \brief Populate the proj tree view with system projection names...
45+
*
46+
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
47+
* list of projections by. This is useful in (e.g.) WMS situations
48+
* where you just want to offer what the WMS server can support.
49+
*
50+
* \todo Should this be public?
51+
*/
52+
void applyProjList(QSet<QString> * crsFilter = 0);
53+
54+
void updateProjAndEllipsoidAcronyms(int theSrsid, QString theProj4String);
55+
3156
/*!
3257
* \brief Make the string safe for use in SQL statements.
3358
* This involves escaping single quotes, double quotes, backslashes,
@@ -39,25 +64,95 @@ class QgsProjectionSelector: public QWidget, private Ui::QgsProjectionSelectorBa
3964
*/
4065
const QString stringSQLSafe(const QString theSQL);
4166

67+
//! Gets the current EPSG-style projection identifier
68+
long getCurrentEpsg();
69+
4270
public slots:
4371
void setSelectedSRSName(QString theSRSName);
72+
4473
QString getSelectedName();
74+
4575
void setSelectedSRSID(long theSRSID);
76+
4677
QString getCurrentProj4String();
47-
long getCurrentSRID(); //posgis style projection identifier
48-
long getCurrentSRSID();//qgis projection identfier
78+
79+
//! Gets the current PostGIS-style projection identifier
80+
long getCurrentSRID();
81+
82+
//! Gets the current QGIS projection identfier
83+
long getCurrentSRSID();
84+
85+
/**
86+
* \brief filters this widget by the given CRSs
87+
*
88+
* Sets this widget to filter the available projections to those listed
89+
* by the given Coordinate Reference Systems.
90+
*
91+
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
92+
* list of projections by. This is useful in (e.g.) WMS situations
93+
* where you just want to offer what the WMS server can support.
94+
*
95+
* \note This function only deals with EPSG labels only at this time.
96+
*
97+
* \warning This function's behaviour is undefined if it is called after the widget is shown.
98+
*/
99+
void setOgcWmsCrsFilter(QSet<QString> crsFilter);
100+
49101
void on_pbnFind_clicked();
50102

103+
protected:
104+
/** Used to ensure the projection list view is actually populated */
105+
void showEvent ( QShowEvent * theEvent );
106+
51107
private:
52108
/** Used to manage column sizes */
53109
void resizeEvent ( QResizeEvent * theEvent );
110+
111+
/**
112+
* \brief converts the CRS group to a SQL expression fragment
113+
*
114+
* Converts the given Coordinate Reference Systems to a format suitable
115+
* for use in SQL for querying against the QGIS SRS database.
116+
*
117+
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
118+
* list of projections by. This is useful in (e.g.) WMS situations
119+
* where you just want to offer what the WMS server can support.
120+
*
121+
* \note This function only deals with EPSG labels only at this time.
122+
*/
123+
QString ogcWmsCrsFilterAsSqlExpression(QSet<QString> * crsFilter);
124+
125+
/**
126+
* \brief does the legwork of applying the SRS Name Selection
127+
*
128+
* \warning This function does nothing unless getUserList() and getUserProjList()
129+
* Have already been called
130+
*/
131+
void applySRSNameSelection();
132+
133+
/**
134+
* \brief does the legwork of applying the SRS ID Selection
135+
*
136+
* \warning This function does nothing unless getUserList() and getUserProjList()
137+
* Have already been called
138+
*/
139+
void applySRSIDSelection();
140+
141+
/**
142+
* \brief gets an arbitrary sqlite3 attribute of type "long" from the selection
143+
*
144+
* \param attributeName The sqlite3 column name, typically "srid" or "epsg"
145+
*/
146+
long getCurrentLongAttribute(QString attributeName);
147+
54148
// List view nodes for the tree view of projections
55149
//! User defined projections node
56150
QTreeWidgetItem *mUserProjList;
57151
//! GEOGCS node
58152
QTreeWidgetItem *mGeoList;
59153
//! PROJCS node
60154
QTreeWidgetItem *mProjList;
155+
61156
//! Users custom coordinate system file
62157
QString mCustomCsFile;
63158
//! File name of the sqlite3 database
@@ -68,6 +163,27 @@ class QgsProjectionSelector: public QWidget, private Ui::QgsProjectionSelectorBa
68163
*/
69164
long getLargestSRSIDMatch(QString theSql);
70165

166+
//! Has the Projection List been populated?
167+
bool mProjListDone;
168+
169+
//! Has the User Projection List been populated?
170+
bool mUserProjListDone;
171+
172+
//! Is there a pending selection to be made by SRS Name?
173+
bool mSRSNameSelectionPending;
174+
175+
//! Is there a pending selection to be made by SRS ID?
176+
bool mSRSIDSelectionPending;
177+
178+
//! The SRS Name that wants to be selected on this widget
179+
QString mSRSNameSelection;
180+
181+
//! The SRS ID that wants to be selected on this widget
182+
long mSRSIDSelection;
183+
184+
//! The set of OGC WMS CRSs that want to be applied to this widget
185+
QSet<QString> mCrsFilter;
186+
71187
private slots:
72188
/**private handler for when user selects a cs
73189
*it will cause wktSelected and sridSelected events to be spawned

0 commit comments

Comments
 (0)
Please sign in to comment.