Skip to content
Permalink
Browse files

Updates for spatial query plugin from Luiz.

git-svn-id: http://svn.osgeo.org/qgis/trunk@15484 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Mar 14, 2011
1 parent 7054a22 commit a894e322133836ebcd9988daeac3dd53840f0999
@@ -15,7 +15,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id: qgsspatialquery.cpp 15141 2011-02-08 13:34:43Z jef $ */
/* $Id: qgsspatialquery.cpp 15302 2011-03-01 08:00:54Z timlinux $ */

#include <QMessageBox>

@@ -99,7 +99,7 @@ QMap<QString, int>* QgsSpatialQuery::getTypesOperations( QgsVectorLayer* lyrTarg

QMap<QString, int> * operations = new QMap<QString, int>;
operations->insert( QObject::tr( "Intersects" ), Intersects );
operations->insert( QObject::tr( "Disjoint" ), Disjoint );
operations->insert( QObject::tr( "Is disjoint" ), Disjoint );

short int dimTarget = 0, dimReference = 0;
dimTarget = dimensionGeometry( lyrTarget->geometryType() );
@@ -15,7 +15,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
/* $Id: qgsspatialquerydialog.cpp 15448 2011-03-12 10:17:05Z jef $ */

#include <QMessageBox>
#include <QDateTime>
@@ -44,8 +44,6 @@ QgsSpatialQueryDialog::QgsSpatialQueryDialog( QWidget* parent, QgisInterface* if
initGui();
connectAll();

mMsgLayersLessTwo = tr( "The spatial query requires at least two layers" );

} // QgsSpatialQueryDialog::QgsSpatialQueryDialog( QWidget* parent, QgisInterface* iface )

QgsSpatialQueryDialog::~QgsSpatialQueryDialog()
@@ -59,11 +57,39 @@ QgsSpatialQueryDialog::~QgsSpatialQueryDialog()

} // QgsSpatialQueryDialog::~QgsSpatialQueryDialog()

void QgsSpatialQueryDialog::messageLayersLessTwo()
bool QgsSpatialQueryDialog::hasPossibleQuery( QString &msg )
{
QString msgLayersLessTwo = tr( "The spatial query requires at least two layers" );
QMessageBox::warning( 0, tr( "Insufficient number of layers" ), msgLayersLessTwo, QMessageBox::Ok );
} // void QgsSpatialQueryDialog::messageLayersLessTwo()
// Count the number of vector layer
QMap <QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
QMapIterator <QString, QgsMapLayer*> item( layers );
QgsMapLayer * mapLayer = NULL;
QgsVectorLayer * lyr = NULL;
unsigned int totalVector = 0;
while ( item.hasNext() )
{
item.next();
mapLayer = item.value();
if ( mapLayer->type() != QgsMapLayer::VectorLayer )
{
continue;
}
lyr = qobject_cast<QgsVectorLayer *>( mapLayer );
if ( !lyr )
{
continue;
}
totalVector++;
}
// check is possible query
if( totalVector < 2 ) {
msg = tr( "The spatial query requires at least two vector layers" );
return false;
}
else {
return true;
}

} // bool QgsSpatialQueryDialog::hasPossibleQuery( QString &msg )

void QgsSpatialQueryDialog::initGui()
{
@@ -515,8 +541,8 @@ void QgsSpatialQueryDialog::populateCbTargetLayer()
{
cbTargetLayer->blockSignals( true );

QMap <QString, QgsMapLayer*> map = QgsMapLayerRegistry::instance()->mapLayers();
QMapIterator <QString, QgsMapLayer*> item( map );
QMap <QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
QMapIterator <QString, QgsMapLayer*> item( layers );
QgsMapLayer * mapLayer = NULL;
QgsVectorLayer * lyr = NULL;
QString layerId;
@@ -15,7 +15,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
/* $Id: qgsspatialquerydialog.h 15303 2011-03-01 08:10:18Z jef $ */

#ifndef SPATIALQUERYDIALOG_H
#define SPATIALQUERYDIALOG_H
@@ -44,8 +44,8 @@ class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogB
//! Destructor
~QgsSpatialQueryDialog();

//! Message about number layers less Two
static void messageLayersLessTwo();
//! Verify is possible execute the query
static bool hasPossibleQuery( QString &msg );

private slots:
//! Slots for signs of Dialog
@@ -157,9 +157,6 @@ class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogB
QString mSourceSelected;
bool mIsSelectedOperator;

// Message
QString mMsgLayersLessTwo;

void MsgDEBUG( QString sMSg );
};

@@ -16,7 +16,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id: qgsspatialqueryplugin.cpp 14897 2010-12-12 19:19:54Z wonder $ */
/* $Id: qgsspatialqueryplugin.cpp 15302 2011-03-01 08:00:54Z timlinux $ */


//
@@ -107,9 +107,10 @@ void QgsSpatialQueryPlugin::run()
{
if ( !mDialog )
{
if ( QgsMapLayerRegistry::instance()->mapLayers().size() < 2 )
QString msg;
if ( ! QgsSpatialQueryDialog::hasPossibleQuery( msg ) )
{
QgsSpatialQueryDialog::messageLayersLessTwo();
QMessageBox::warning( mIface->mainWindow(), tr( "Not possible execute the query" ), msg, QMessageBox::Ok );
return;
}
mDialog = new QgsSpatialQueryDialog( mIface->mainWindow(), mIface );

0 comments on commit a894e32

Please sign in to comment.
You can’t perform that action at this time.