Skip to content

Commit

Permalink
Improvements to WMS - users can now see what projections are availabl…
Browse files Browse the repository at this point in the history
…e 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@4937 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Mar 2, 2006
1 parent a303b57 commit 90f7f6b
Show file tree
Hide file tree
Showing 11 changed files with 641 additions and 87 deletions.
Binary file modified resources/qgis.db
Binary file not shown.
Binary file modified resources/srs.db
Binary file not shown.
16 changes: 15 additions & 1 deletion src/gui/qgslayerprojectionselector.cpp
Expand Up @@ -23,7 +23,8 @@
* \class QgsLayerProjectionSelector - Set user layerprojectionselector and preferences
* Constructor
*/
QgsLayerProjectionSelector::QgsLayerProjectionSelector(QWidget *parent, Qt::WFlags fl)
QgsLayerProjectionSelector::QgsLayerProjectionSelector(QWidget *parent,
Qt::WFlags fl)
: QDialog(parent, fl)
{
setupUi(this);
Expand All @@ -40,10 +41,12 @@ void QgsLayerProjectionSelector::setSelectedSRSName(QString theName)
{
projectionSelector->setSelectedSRSName(theName);
}

void QgsLayerProjectionSelector::setSelectedSRSID(long theID)
{
projectionSelector->setSelectedSRSID(theID);
}

QString QgsLayerProjectionSelector::getCurrentProj4String()
{
//@NOTE dont use getSelectedWKT as that just returns the name part!
Expand All @@ -55,3 +58,14 @@ long QgsLayerProjectionSelector::getCurrentSRSID()
//@NOTE dont use getSelectedWKT as that just returns the name part!
return projectionSelector->getCurrentSRSID();
}

long QgsLayerProjectionSelector::getCurrentEpsg()
{
return projectionSelector->getCurrentEpsg();
}

void QgsLayerProjectionSelector::setOgcWmsCrsFilter(QSet<QString> crsFilter)
{
projectionSelector->setOgcWmsCrsFilter(crsFilter);
}

28 changes: 27 additions & 1 deletion src/gui/qgslayerprojectionselector.h
Expand Up @@ -20,26 +20,52 @@
#define QGSLAYERPROJECTIONSELECTOR_H
#include "ui_qgslayerprojectionselectorbase.h"
#include "qgisgui.h"

#include <QSet>

/**
* \class QgsLayerProjectionSelector
* \brief Set Projection system for a layer
*/

class QgsLayerProjectionSelector : public QDialog, private Ui::QgsLayerProjectionSelectorBase
{
Q_OBJECT;
public:
/**
* Constructor
*/
QgsLayerProjectionSelector(QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags);
QgsLayerProjectionSelector(QWidget *parent = 0,
Qt::WFlags fl = QgisGui::ModalDialogFlags);

//! Destructor
~QgsLayerProjectionSelector();

public slots:
QString getCurrentProj4String();
long getCurrentSRSID();
long getCurrentEpsg();

void setSelectedSRSName(QString theName);
void setSelectedSRSID(long theID);

/**
* \brief filters this dialog by the given CRSs
*
* Sets this dialog to filter the available projections to those listed
* by the given Coordinate Reference Systems.
*
* \param crsFilter a list of OGC Coordinate Reference Systems to filter the
* list of projections by. This is useful in (e.g.) WMS situations
* where you just want to offer what the WMS server can support.
*
* \note This function only deals with EPSG labels only at this time.
*
* \warning This function's behaviour is undefined if it is called after the dialog is shown.
*/
void setOgcWmsCrsFilter(QSet<QString> crsFilter);


};

#endif // #ifndef QGSLAYERPROJECTIONSELECTOR_H
129 changes: 116 additions & 13 deletions src/gui/qgsserversourceselect.cpp
Expand Up @@ -18,12 +18,16 @@

#include "qgsserversourceselect.h"

#include "qgslayerprojectionselector.h"

#include "qgsnewhttpconnection.h"
#include "qgsnumericsortlistviewitem.h"
#include "qgsproviderregistry.h"
#include "../providers/wms/qgswmsprovider.h"
#include "qgscontexthelp.h"

#include "qgsproject.h"

#include <QMessageBox>
#include <QPicture>
#include <QSettings>
Expand All @@ -33,7 +37,9 @@

QgsServerSourceSelect::QgsServerSourceSelect(QgisApp * app, QWidget * parent, Qt::WFlags fl)
: QDialog(parent, fl),
qgisApp(app)
qgisApp(app),
wmsProvider(0),
m_Epsg(0)
{
setupUi(this);
connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
Expand Down Expand Up @@ -153,7 +159,7 @@ void QgsServerSourceSelect::populateLayerList(QgsWmsProvider* wmsProvider)
{

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

layerAndStyleCount++;
Expand Down Expand Up @@ -266,6 +272,36 @@ void QgsServerSourceSelect::populateImageEncodingGroup(QgsWmsProvider* wmsProvid
}


std::set<QString> QgsServerSourceSelect::crsForSelection()
{
std::set<QString> crsCandidates;;

QStringList::const_iterator i;
for (i = m_selectedLayers.constBegin(); i != m_selectedLayers.constEnd(); ++i)
{
/*
for ( int j = 0; j < ilayerProperty.boundingBox.size(); i++ )
{
#ifdef QGISDEBUG
std::cout << "QgsWmsProvider::parseLayer: testing bounding box CRS which is "
<< layerProperty.boundingBox[i].crs.toLocal8Bit().data() << "." << std::endl;
#endif
if ( layerProperty.boundingBox[i].crs == DEFAULT_LATLON_CRS )
{
extentForLayer[ layerProperty.name ] =
layerProperty.boundingBox[i].box;
}
}
if
cout << (*i).ascii() << endl;*/
}

}


void QgsServerSourceSelect::on_btnConnect_clicked()
{
// populate the table list
Expand Down Expand Up @@ -301,19 +337,26 @@ void QgsServerSourceSelect::on_btnConnect_clicked()
#ifdef QGISDEBUG
std::cout << "QgsServerSourceSelect::serverConnect: Connection info: '" << m_connInfo.toLocal8Bit().data() << "'." << std::endl;
#endif


// TODO: Create and bind to data provider

// load the server data provider plugin
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
QgsWmsProvider* wmsProvider =

wmsProvider =
(QgsWmsProvider*) pReg->getProvider( "wms", m_connInfo );

connect(wmsProvider, SIGNAL(setStatus(QString)), this, SLOT(showStatusMessage(QString)));
if (wmsProvider)
{
connect(wmsProvider, SIGNAL(setStatus(QString)), this, SLOT(showStatusMessage(QString)));

populateLayerList(wmsProvider);
populateLayerList(wmsProvider);
}
else
{
// TODO: Let user know we couldn't initialise the WMS provider
}

}

Expand All @@ -330,6 +373,43 @@ void QgsServerSourceSelect::on_btnAdd_clicked()
}


void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
{
if (!wmsProvider)
{
return;
}

QSet<QString> crsFilter = wmsProvider->supportedCrsForLayers(m_selectedLayers);

QgsLayerProjectionSelector * mySelector =
new QgsLayerProjectionSelector(this);

mySelector->setOgcWmsCrsFilter(crsFilter);

long myDefaultSRS = QgsProject::instance()->readNumEntry("SpatialRefSys", "/ProjectSRSID", GEOSRS_ID);

mySelector->setSelectedSRSID(myDefaultSRS);

if (mySelector->exec())
{
// TODO: assign EPSG back to the WMS provider
m_Epsg = mySelector->getCurrentEpsg();
}
else
{
// NOOP
}

labelSpatialRefSys->setText( mySelector->getCurrentProj4String() );

delete mySelector;

// update the display of this widget
this->update();
}


/**
* This function is used to:
* 1. Store the list of selected layers and visual styles as appropriate.
Expand All @@ -347,10 +427,9 @@ void QgsServerSourceSelect::on_lstLayers_selectionChanged()

// Iterate through the layers
Q3ListViewItemIterator it( lstLayers );
while ( it.current() )
while ( it.current() )
{
Q3ListViewItem *item = it.current();
++it;

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

}

++it;
}

// If we got some selected items, let the user play with projections
if (newSelectedLayers.count() > 0)
{
btnChangeSpatialRefSys->setEnabled(TRUE);
}
else
{
btnChangeSpatialRefSys->setEnabled(FALSE);
}

m_selectedLayers = newSelectedLayers;
Expand Down Expand Up @@ -434,6 +525,19 @@ QString QgsServerSourceSelect::selectedImageEncoding()

}

QString QgsServerSourceSelect::selectedCrs()
{
if (m_Epsg)
{
return QString("EPSG:%1")
.arg(m_Epsg);
}
else
{
return QString();
}
}

void QgsServerSourceSelect::showStatusMessage(QString const & theMessage)
{
labelStatus->setText(theMessage);
Expand All @@ -443,5 +547,4 @@ void QgsServerSourceSelect::showStatusMessage(QString const & theMessage)
}




// ENDS
15 changes: 15 additions & 0 deletions src/gui/qgsserversourceselect.h
Expand Up @@ -23,6 +23,7 @@

#include <vector>
#include <map>
#include <set>

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

//! String containing the selected WMS-format CRS
QString selectedCrs();


public slots:

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

//! Opens the Spatial Reference System dialog.
void on_btnChangeSpatialRefSys_clicked();

//! Opens help application
void on_btnHelp_clicked();

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

//! Returns the common CRSs for the selected layers.
std::set<QString> crsForSelection();

QString m_connName;
QString m_connInfo;
QStringList m_selectedLayers;
QStringList m_selectedStylesForSelectedLayers;
long m_Epsg;

std::map<QString, QString> m_selectedStyleIdForLayer;

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

//! The WMS provider that retreives information for this dialog
QgsWmsProvider * wmsProvider;

static const int context_id = 710979116;
};

Expand Down

0 comments on commit 90f7f6b

Please sign in to comment.