mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
spatial query plugin: fix warnings, reindent, include in debian package
git-svn-id: http://svn.osgeo.org/qgis/trunk@13360 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
e0ec67b2fe
commit
3d2b177143
3
debian/changelog
vendored
3
debian/changelog
vendored
@ -5,8 +5,9 @@ qgis (1.5.0) UNRELEASED; urgency=low
|
|||||||
* require CMake >2.6 and Qt 4.4 for sid
|
* require CMake >2.6 and Qt 4.4 for sid
|
||||||
* remove circular dependencies
|
* remove circular dependencies
|
||||||
* integrate new GRASS raster provider
|
* integrate new GRASS raster provider
|
||||||
|
* add spatialquery plugin
|
||||||
|
|
||||||
-- Jürgen E. Fischer <jef@norbit.de> Thu, 04 Feb 2010 23:20:29 +0100
|
-- Jürgen E. Fischer <jef@norbit.de> Sat, 24 Apr 2010 10:57:21 +0200
|
||||||
|
|
||||||
qgis (1.4.0) UNRELEASED; urgency=low
|
qgis (1.4.0) UNRELEASED; urgency=low
|
||||||
|
|
||||||
|
1
debian/qgis.install
vendored
1
debian/qgis.install
vendored
@ -26,6 +26,7 @@ usr/lib/qgis/libevis.so
|
|||||||
usr/lib/qgis/libosmprovider.so
|
usr/lib/qgis/libosmprovider.so
|
||||||
usr/lib/qgis/librasterterrainplugin.so
|
usr/lib/qgis/librasterterrainplugin.so
|
||||||
usr/lib/qgis/liblabelingplugin.so
|
usr/lib/qgis/liblabelingplugin.so
|
||||||
|
usr/lib/qgis/libspatialqueryplugin.so
|
||||||
usr/share/pixmaps/qgis-icon.xpm
|
usr/share/pixmaps/qgis-icon.xpm
|
||||||
usr/share/pixmaps/qgis-mime-icon.png
|
usr/share/pixmaps/qgis-mime-icon.png
|
||||||
usr/share/pixmaps/qgis-mime-icon.png usr/share/icons/crystalsvg/128x128/mimetypes
|
usr/share/pixmaps/qgis-mime-icon.png usr/share/icons/crystalsvg/128x128/mimetypes
|
||||||
|
2
debian/rules
vendored
2
debian/rules
vendored
@ -10,7 +10,7 @@ DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
|||||||
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||||
|
|
||||||
DISTRIBUTION := $(shell dpkg-parsechangelog --format rfc822 | sed -ne "s/^Distribution: //p")
|
DISTRIBUTION := $(shell dpkg-parsechangelog --format rfc822 | sed -ne "s/^Distribution: //p")
|
||||||
ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"lenny hardy intrepid jaunty karmic"))
|
ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"lenny hardy intrepid jaunty karmic lucid"))
|
||||||
DISTRIBUTION := sid
|
DISTRIBUTION := sid
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -14,11 +14,6 @@ SET (SPATIALQUERY_SRCS
|
|||||||
SET (SPATIALQUERY_MOC_HDRS
|
SET (SPATIALQUERY_MOC_HDRS
|
||||||
qgsspatialqueryplugin.h
|
qgsspatialqueryplugin.h
|
||||||
qgsspatialquerydialog.h
|
qgsspatialquerydialog.h
|
||||||
qgsspatialquery.h
|
|
||||||
qgsreaderfeatures.h
|
|
||||||
qgsrubberselectid.h
|
|
||||||
qgsgeometrycoordinatetransform.h
|
|
||||||
qgsmngprogressbar.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( SPATIALQUERY_UIS qgsspatialquerydialogbase.ui)
|
SET( SPATIALQUERY_UIS qgsspatialquerydialogbase.ui)
|
||||||
|
@ -23,33 +23,33 @@
|
|||||||
|
|
||||||
QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
|
QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
|
||||||
{
|
{
|
||||||
delete mCoordTransform;
|
delete mCoordTransform;
|
||||||
|
|
||||||
} // QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
|
} // QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
|
||||||
|
|
||||||
void QgsGeometryCoordinateTransform::setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
void QgsGeometryCoordinateTransform::setCoordinateTransform( QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
|
||||||
{
|
{
|
||||||
// Transform Forward: Target to Reference
|
// Transform Forward: Target to Reference
|
||||||
// * Use srs() to use old versions QGis - will be deprecited in 2.0 (after use crs())
|
// * Use srs() to use old versions QGis - will be deprecited in 2.0 (after use crs())
|
||||||
QgsCoordinateReferenceSystem srsTarget = lyrTarget->srs();
|
QgsCoordinateReferenceSystem srsTarget = lyrTarget->srs();
|
||||||
QgsCoordinateReferenceSystem srsReference = lyrReference->srs();
|
QgsCoordinateReferenceSystem srsReference = lyrReference->srs();
|
||||||
|
|
||||||
mCoordTransform = new QgsCoordinateTransform(srsTarget, srsReference);
|
mCoordTransform = new QgsCoordinateTransform( srsTarget, srsReference );
|
||||||
|
|
||||||
mFuncTransform = ( srsTarget != srsReference)
|
mFuncTransform = ( srsTarget != srsReference )
|
||||||
? &QgsGeometryCoordinateTransform::setGeomTransform
|
? &QgsGeometryCoordinateTransform::setGeomTransform
|
||||||
: &QgsGeometryCoordinateTransform::setNoneGeomTransform;
|
: &QgsGeometryCoordinateTransform::setNoneGeomTransform;
|
||||||
|
|
||||||
} // void QgsGeometryCoordinateTransform::setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
} // void QgsGeometryCoordinateTransform::setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
||||||
|
|
||||||
void QgsGeometryCoordinateTransform::transform(QgsGeometry *geom)
|
void QgsGeometryCoordinateTransform::transform( QgsGeometry *geom )
|
||||||
{
|
{
|
||||||
(this->*mFuncTransform)(geom);
|
( this->*mFuncTransform )( geom );
|
||||||
|
|
||||||
} // void QgsGeometryCoordinateTransform::transformCoordenate()
|
} // void QgsGeometryCoordinateTransform::transformCoordenate()
|
||||||
|
|
||||||
void QgsGeometryCoordinateTransform::setGeomTransform(QgsGeometry *geom)
|
void QgsGeometryCoordinateTransform::setGeomTransform( QgsGeometry *geom )
|
||||||
{
|
{
|
||||||
geom->transform(*mCoordTransform);
|
geom->transform( *mCoordTransform );
|
||||||
|
|
||||||
} // void QgsGeometryCoordinateTransform::setGeomTransform(QgsGeometry *geom)
|
} // void QgsGeometryCoordinateTransform::setGeomTransform(QgsGeometry *geom)
|
||||||
|
@ -29,44 +29,44 @@
|
|||||||
*/
|
*/
|
||||||
class QgsGeometryCoordinateTransform
|
class QgsGeometryCoordinateTransform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* \brief Constructor for a Geometry Coordinate Transform.
|
* \brief Constructor for a Geometry Coordinate Transform.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
QgsGeometryCoordinateTransform () {};
|
QgsGeometryCoordinateTransform() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Destructor
|
* \brief Destructor
|
||||||
*/
|
*/
|
||||||
~QgsGeometryCoordinateTransform ();
|
~QgsGeometryCoordinateTransform();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets the coordinate reference system the target and reference layer
|
* \brief Sets the coordinate reference system the target and reference layer
|
||||||
* \param lyrTarget target layer.
|
* \param lyrTarget target layer.
|
||||||
* \param lyrReference reference layer.
|
* \param lyrReference reference layer.
|
||||||
*/
|
*/
|
||||||
void setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference);
|
void setCoordinateTransform( QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Transform the coordinates reference system of the geometry, if target have the different system of reference
|
* \brief Transform the coordinates reference system of the geometry, if target have the different system of reference
|
||||||
* \param geom Geometry
|
* \param geom Geometry
|
||||||
*/
|
*/
|
||||||
void transform(QgsGeometry *geom);
|
void transform( QgsGeometry *geom );
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* \brief Transform the coordinates reference system of the geometry (use by transform)
|
* \brief Transform the coordinates reference system of the geometry (use by transform)
|
||||||
* \param geom Geometry
|
* \param geom Geometry
|
||||||
*/
|
*/
|
||||||
void setGeomTransform(QgsGeometry *geom);
|
void setGeomTransform( QgsGeometry *geom );
|
||||||
/**
|
/**
|
||||||
* \brief None transform the coordinates reference system of the geometry (use by transform)
|
* \brief None transform the coordinates reference system of the geometry (use by transform)
|
||||||
* \param geom Geometry
|
* \param geom Geometry
|
||||||
*/
|
*/
|
||||||
void setNoneGeomTransform(QgsGeometry *geom) {};
|
void setNoneGeomTransform( QgsGeometry *geom ) {};
|
||||||
|
|
||||||
QgsCoordinateTransform * mCoordTransform;
|
QgsCoordinateTransform * mCoordTransform;
|
||||||
void (QgsGeometryCoordinateTransform::* mFuncTransform)(QgsGeometry *);
|
void ( QgsGeometryCoordinateTransform::* mFuncTransform )( QgsGeometry * );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GEOMETRYCOORDINATETRANSFORM_H
|
#endif // GEOMETRYCOORDINATETRANSFORM_H
|
||||||
|
@ -19,32 +19,32 @@
|
|||||||
|
|
||||||
#include "qgsmngprogressbar.h"
|
#include "qgsmngprogressbar.h"
|
||||||
|
|
||||||
MngProgressBar::MngProgressBar(QProgressBar *pb)
|
MngProgressBar::MngProgressBar( QProgressBar *pb )
|
||||||
{
|
{
|
||||||
mPb = pb;
|
mPb = pb;
|
||||||
mPb->reset();
|
mPb->reset();
|
||||||
} // MngProgressBar::MngProgressBar(QProgressBar *pb)
|
} // MngProgressBar::MngProgressBar(QProgressBar *pb)
|
||||||
|
|
||||||
void MngProgressBar::init(int minimum, int maximum)
|
void MngProgressBar::init( int minimum, int maximum )
|
||||||
{
|
{
|
||||||
mPb->reset();
|
mPb->reset();
|
||||||
mPb->setRange(minimum, maximum);
|
mPb->setRange( minimum, maximum );
|
||||||
|
|
||||||
} // void MngProgressBar::init(int minimum, int maximum)
|
} // void MngProgressBar::init(int minimum, int maximum)
|
||||||
|
|
||||||
void MngProgressBar::setFormat(QString format)
|
void MngProgressBar::setFormat( QString format )
|
||||||
{
|
{
|
||||||
// special caracters:
|
// special caracters:
|
||||||
// %p - is replaced by the percentage completed.
|
// %p - is replaced by the percentage completed.
|
||||||
// %v - is replaced by the current value.
|
// %v - is replaced by the current value.
|
||||||
// %m - is replaced by the total number of steps.
|
// %m - is replaced by the total number of steps.
|
||||||
mPb->setFormat(format);
|
mPb->setFormat( format );
|
||||||
|
|
||||||
} // void MngProgressBar::setFormat(QString format)
|
} // void MngProgressBar::setFormat(QString format)
|
||||||
|
|
||||||
void MngProgressBar::step(int step)
|
void MngProgressBar::step( int step )
|
||||||
{
|
{
|
||||||
mPb->setValue(step);
|
mPb->setValue( step );
|
||||||
mPb->repaint();
|
mPb->repaint();
|
||||||
|
|
||||||
} // void MngProgressBar::step()
|
} // void MngProgressBar::step()
|
||||||
|
@ -27,12 +27,12 @@
|
|||||||
*/
|
*/
|
||||||
class MngProgressBar
|
class MngProgressBar
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* \brief Constructor for a MngProgressBar.
|
* \brief Constructor for a MngProgressBar.
|
||||||
* \param pb Pointer to the MngProgressBar object.
|
* \param pb Pointer to the MngProgressBar object.
|
||||||
*/
|
*/
|
||||||
MngProgressBar(QProgressBar *pb);
|
MngProgressBar( QProgressBar *pb );
|
||||||
/**
|
/**
|
||||||
* \brief Destructor
|
* \brief Destructor
|
||||||
*/
|
*/
|
||||||
@ -43,21 +43,21 @@ public:
|
|||||||
* \param minimum minimun value.
|
* \param minimum minimun value.
|
||||||
* \param maximum maximum value.
|
* \param maximum maximum value.
|
||||||
*/
|
*/
|
||||||
void init(int minimum, int maximum);
|
void init( int minimum, int maximum );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets the format the current text.
|
* \brief Sets the format the current text.
|
||||||
* \param format This property holds the string used to generate the current text.
|
* \param format This property holds the string used to generate the current text.
|
||||||
*/
|
*/
|
||||||
void setFormat(QString format);
|
void setFormat( QString format );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets current value progress bar's
|
* \brief Sets current value progress bar's
|
||||||
* \param step current value
|
* \param step current value
|
||||||
*/
|
*/
|
||||||
void step(int step );
|
void step( int step );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QProgressBar * mPb;
|
QProgressBar * mPb;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -21,67 +21,67 @@
|
|||||||
|
|
||||||
#include "qgsreaderfeatures.h"
|
#include "qgsreaderfeatures.h"
|
||||||
|
|
||||||
QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
|
QgsReaderFeatures::QgsReaderFeatures( QgsVectorLayer *layer, bool useSelection )
|
||||||
{
|
{
|
||||||
mLayer = layer;
|
mLayer = layer;
|
||||||
|
|
||||||
initReader(useSelection);
|
initReader( useSelection );
|
||||||
|
|
||||||
} // QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
|
} // QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
|
||||||
|
|
||||||
QgsReaderFeatures::~QgsReaderFeatures()
|
QgsReaderFeatures::~QgsReaderFeatures()
|
||||||
{
|
{
|
||||||
if ( mListSelectedFeature.count() > 0 )
|
if ( mListSelectedFeature.count() > 0 )
|
||||||
{
|
{
|
||||||
mListSelectedFeature.clear();
|
mListSelectedFeature.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // QgsReaderFeatures::~QgsReaderFeatures()
|
} // QgsReaderFeatures::~QgsReaderFeatures()
|
||||||
|
|
||||||
bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
|
bool QgsReaderFeatures::nextFeature( QgsFeature & feature )
|
||||||
{
|
{
|
||||||
return (this->*mFuncNextFeature)(feature);
|
return ( this->*mFuncNextFeature )( feature );
|
||||||
|
|
||||||
} // bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
|
} // bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
|
||||||
|
|
||||||
void QgsReaderFeatures::initReader(bool useSelection)
|
void QgsReaderFeatures::initReader( bool useSelection )
|
||||||
{
|
{
|
||||||
if ( useSelection )
|
if ( useSelection )
|
||||||
{
|
{
|
||||||
mListSelectedFeature = mLayer->selectedFeatures();
|
mListSelectedFeature = mLayer->selectedFeatures();
|
||||||
mIterSelectedFeature = mListSelectedFeature.begin();
|
mIterSelectedFeature = mListSelectedFeature.begin();
|
||||||
mFuncNextFeature = &QgsReaderFeatures::nextFeatureSelected;
|
mFuncNextFeature = &QgsReaderFeatures::nextFeatureSelected;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QgsAttributeList attListGeom;
|
QgsAttributeList attListGeom;
|
||||||
int idGeom = 0;
|
int idGeom = 0;
|
||||||
attListGeom.append(idGeom);
|
attListGeom.append( idGeom );
|
||||||
mLayer->select(attListGeom, mLayer->extent(), true, false);
|
mLayer->select( attListGeom, mLayer->extent(), true, false );
|
||||||
mFuncNextFeature = &QgsReaderFeatures::nextFeatureTotal;
|
mFuncNextFeature = &QgsReaderFeatures::nextFeatureTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // void QgsReaderFeatures::initReader()
|
} // void QgsReaderFeatures::initReader()
|
||||||
|
|
||||||
bool QgsReaderFeatures::nextFeatureTotal ( QgsFeature & feature )
|
bool QgsReaderFeatures::nextFeatureTotal( QgsFeature & feature )
|
||||||
{
|
{
|
||||||
return mLayer->dataProvider()->nextFeature(feature);
|
return mLayer->dataProvider()->nextFeature( feature );
|
||||||
|
|
||||||
} // bool QgsReaderFeatures::nextFeatureTotal ( QgsFeature & feature )
|
} // bool QgsReaderFeatures::nextFeatureTotal ( QgsFeature & feature )
|
||||||
|
|
||||||
bool QgsReaderFeatures::nextFeatureSelected ( QgsFeature & feature )
|
bool QgsReaderFeatures::nextFeatureSelected( QgsFeature & feature )
|
||||||
{
|
{
|
||||||
bool bReturn = true;
|
bool bReturn = true;
|
||||||
if ( mIterSelectedFeature == mListSelectedFeature.end() )
|
if ( mIterSelectedFeature == mListSelectedFeature.end() )
|
||||||
{
|
{
|
||||||
bReturn = false;
|
bReturn = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
feature = *mIterSelectedFeature;
|
feature = *mIterSelectedFeature;
|
||||||
mIterSelectedFeature++;
|
mIterSelectedFeature++;
|
||||||
}
|
}
|
||||||
return bReturn;
|
return bReturn;
|
||||||
|
|
||||||
} // bool QgsReaderFeatures::nextFeatureSelected( QgsFeature &feature )
|
} // bool QgsReaderFeatures::nextFeatureSelected( QgsFeature &feature )
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
*/
|
*/
|
||||||
class QgsReaderFeatures
|
class QgsReaderFeatures
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* \brief Constructor for a Reader Features.
|
* \brief Constructor for a Reader Features.
|
||||||
* \param layer Pointer to the layer.
|
* \param layer Pointer to the layer.
|
||||||
* \param useSelection Use or not use the features selected
|
* \param useSelection Use or not use the features selected
|
||||||
*/
|
*/
|
||||||
QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection);
|
QgsReaderFeatures( QgsVectorLayer *layer, bool useSelection );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Destructor
|
* \brief Destructor
|
||||||
@ -46,33 +46,33 @@ public:
|
|||||||
* \param feature reference to next Feature.
|
* \param feature reference to next Feature.
|
||||||
* \returns True if has next feature.
|
* \returns True if has next feature.
|
||||||
*/
|
*/
|
||||||
bool nextFeature(QgsFeature & feature);
|
bool nextFeature( QgsFeature & feature );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* \brief init Reader
|
* \brief init Reader
|
||||||
* \param useSelection Use or not use the features selected
|
* \param useSelection Use or not use the features selected
|
||||||
*/
|
*/
|
||||||
void initReader(bool useSelection);
|
void initReader( bool useSelection );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Next feature, not using the features selected
|
* \brief Next feature, not using the features selected
|
||||||
* \param feature reference to next Feature.
|
* \param feature reference to next Feature.
|
||||||
* \returns True if has next feature.
|
* \returns True if has next feature.
|
||||||
*/
|
*/
|
||||||
bool nextFeatureTotal(QgsFeature & feature);
|
bool nextFeatureTotal( QgsFeature & feature );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Next feature, using the features selected
|
* \brief Next feature, using the features selected
|
||||||
* \param feature reference to next Feature.
|
* \param feature reference to next Feature.
|
||||||
* \returns True if has next feature.
|
* \returns True if has next feature.
|
||||||
*/
|
*/
|
||||||
bool nextFeatureSelected(QgsFeature & feature);
|
bool nextFeatureSelected( QgsFeature & feature );
|
||||||
|
|
||||||
QgsVectorLayer * mLayer;
|
QgsVectorLayer * mLayer;
|
||||||
QgsFeatureList mListSelectedFeature;
|
QgsFeatureList mListSelectedFeature;
|
||||||
QList<QgsFeature>::iterator mIterSelectedFeature;
|
QList<QgsFeature>::iterator mIterSelectedFeature;
|
||||||
bool (QgsReaderFeatures::* mFuncNextFeature) ( QgsFeature &);
|
bool ( QgsReaderFeatures::* mFuncNextFeature )( QgsFeature & );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // READERFEATURES_H
|
#endif // READERFEATURES_H
|
||||||
|
@ -22,62 +22,62 @@
|
|||||||
|
|
||||||
#include "qgsfeature.h"
|
#include "qgsfeature.h"
|
||||||
|
|
||||||
QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas)
|
QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas )
|
||||||
{
|
{
|
||||||
mIsPolygon = true;
|
mIsPolygon = true;
|
||||||
mMapCanvas = mapCanvas;
|
mMapCanvas = mapCanvas;
|
||||||
mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
|
mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
|
||||||
|
|
||||||
} // QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas, bool isPolygon = true )
|
} // QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas, bool isPolygon = true )
|
||||||
|
|
||||||
QgsRubberSelectId::~QgsRubberSelectId()
|
QgsRubberSelectId::~QgsRubberSelectId()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
delete mRubberBand;
|
delete mRubberBand;
|
||||||
|
|
||||||
} // QgsRubberSelectId::~QgsRubberSelectId()
|
} // QgsRubberSelectId::~QgsRubberSelectId()
|
||||||
|
|
||||||
void QgsRubberSelectId::isGeometryNotPolygon(bool isPolygon = false)
|
void QgsRubberSelectId::isGeometryNotPolygon( bool isPolygon = false )
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
delete mRubberBand;
|
delete mRubberBand;
|
||||||
mIsPolygon = isPolygon;
|
mIsPolygon = isPolygon;
|
||||||
mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
|
mRubberBand = new QgsRubberBand( mMapCanvas, mIsPolygon );
|
||||||
|
|
||||||
} // void QgsRubberSelectId::isGeometryNotPolygon(bool isPolygon)
|
} // void QgsRubberSelectId::isGeometryNotPolygon(bool isPolygon)
|
||||||
|
|
||||||
void QgsRubberSelectId::reset()
|
void QgsRubberSelectId::reset()
|
||||||
{
|
{
|
||||||
mRubberBand->reset( mIsPolygon );
|
mRubberBand->reset( mIsPolygon );
|
||||||
|
|
||||||
} // void QgsRubberSelectId::reset()
|
} // void QgsRubberSelectId::reset()
|
||||||
|
|
||||||
void QgsRubberSelectId::setColor(int colorRed, int colorGreen, int colorBlue, int width, float alfa = 0)
|
void QgsRubberSelectId::setColor( int colorRed, int colorGreen, int colorBlue, int width, float alfa = 0 )
|
||||||
{
|
{
|
||||||
QColor color = QColor( colorRed, colorGreen, colorBlue );
|
QColor color = QColor( colorRed, colorGreen, colorBlue );
|
||||||
color.setAlpha( alfa );
|
color.setAlpha( alfa );
|
||||||
mRubberBand->setColor( color );
|
mRubberBand->setColor( color );
|
||||||
mRubberBand->setWidth( width );
|
mRubberBand->setWidth( width );
|
||||||
|
|
||||||
} // void QgsRubberSelectId::setColor(int colorRed, int colorGreen, int colorBlue, float alfa, width)
|
} // void QgsRubberSelectId::setColor(int colorRed, int colorGreen, int colorBlue, float alfa, width)
|
||||||
|
|
||||||
void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int fid )
|
void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int fid )
|
||||||
{
|
{
|
||||||
QgsFeature feat;
|
QgsFeature feat;
|
||||||
if ( !mLayer->featureAtId( fid, feat, true, false ) )
|
if ( !mLayer->featureAtId( fid, feat, true, false ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( !feat.geometry() )
|
if ( !feat.geometry() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mRubberBand->setToGeometry( feat.geometry(), mLayer );
|
mRubberBand->setToGeometry( feat.geometry(), mLayer );
|
||||||
|
|
||||||
} // void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int Id )
|
} // void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int Id )
|
||||||
|
|
||||||
void QgsRubberSelectId::show()
|
void QgsRubberSelectId::show()
|
||||||
{
|
{
|
||||||
mRubberBand->show();
|
mRubberBand->show();
|
||||||
} // QgsRubberSelectId::show()
|
} // QgsRubberSelectId::show()
|
||||||
|
@ -30,12 +30,12 @@
|
|||||||
*/
|
*/
|
||||||
class QgsRubberSelectId
|
class QgsRubberSelectId
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor for a class RubberSelectedId.
|
* Constructor for a class RubberSelectedId.
|
||||||
* @param mapCanvas Pointer to the iface.mapCanvas().
|
* @param mapCanvas Pointer to the iface.mapCanvas().
|
||||||
*/
|
*/
|
||||||
QgsRubberSelectId( QgsMapCanvas* mapCanvas);
|
QgsRubberSelectId( QgsMapCanvas* mapCanvas );
|
||||||
/**
|
/**
|
||||||
* \brief Destructor
|
* \brief Destructor
|
||||||
*/
|
*/
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
* \brief Set if is geometry polygon for rubber band
|
* \brief Set if is geometry polygon for rubber band
|
||||||
* \param isPolygon boolean for type geometry is polygon
|
* \param isPolygon boolean for type geometry is polygon
|
||||||
*/
|
*/
|
||||||
void isGeometryNotPolygon(bool isPolygon);
|
void isGeometryNotPolygon( bool isPolygon );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Reset rubber band
|
* \brief Reset rubber band
|
||||||
@ -72,7 +72,7 @@ public:
|
|||||||
* \brief Show rubber band
|
* \brief Show rubber band
|
||||||
*/
|
*/
|
||||||
void show();
|
void show();
|
||||||
private:
|
private:
|
||||||
//! RubberBand
|
//! RubberBand
|
||||||
QgsRubberBand* mRubberBand;
|
QgsRubberBand* mRubberBand;
|
||||||
bool mIsPolygon;
|
bool mIsPolygon;
|
||||||
|
@ -25,163 +25,166 @@
|
|||||||
#include "qgsgeometrycoordinatetransform.h"
|
#include "qgsgeometrycoordinatetransform.h"
|
||||||
#include "qgsspatialquery.h"
|
#include "qgsspatialquery.h"
|
||||||
|
|
||||||
QgsSpatialQuery::QgsSpatialQuery(MngProgressBar *pb)
|
QgsSpatialQuery::QgsSpatialQuery( MngProgressBar *pb )
|
||||||
{
|
{
|
||||||
mPb = pb;
|
mPb = pb;
|
||||||
mUseTargetSelection = mUseReferenceSelection = false;
|
mUseTargetSelection = mUseReferenceSelection = false;
|
||||||
|
|
||||||
} // QgsSpatialQuery::QgsSpatialQuery(MngProgressBar *pb)
|
} // QgsSpatialQuery::QgsSpatialQuery(MngProgressBar *pb)
|
||||||
|
|
||||||
QgsSpatialQuery::~QgsSpatialQuery()
|
QgsSpatialQuery::~QgsSpatialQuery()
|
||||||
{
|
{
|
||||||
delete mReaderFeaturesTarget;
|
delete mReaderFeaturesTarget;
|
||||||
|
|
||||||
} // QgsSpatialQuery::~QgsSpatialQuery()
|
} // QgsSpatialQuery::~QgsSpatialQuery()
|
||||||
|
|
||||||
void QgsSpatialQuery::setSelectedFeaturesTarget(bool useSelected)
|
void QgsSpatialQuery::setSelectedFeaturesTarget( bool useSelected )
|
||||||
{
|
{
|
||||||
mUseTargetSelection = useSelected;
|
mUseTargetSelection = useSelected;
|
||||||
|
|
||||||
} // void QgsSpatialQuery::setSelectedFeaturesTarget(bool useSelected)
|
} // void QgsSpatialQuery::setSelectedFeaturesTarget(bool useSelected)
|
||||||
|
|
||||||
void QgsSpatialQuery::setSelectedFeaturesReference(bool useSelected)
|
void QgsSpatialQuery::setSelectedFeaturesReference( bool useSelected )
|
||||||
{
|
{
|
||||||
mUseReferenceSelection = useSelected;
|
mUseReferenceSelection = useSelected;
|
||||||
|
|
||||||
} // void QgsSpatialQuery::setSelectedFeaturesReference(bool useSelected)
|
} // void QgsSpatialQuery::setSelectedFeaturesReference(bool useSelected)
|
||||||
|
|
||||||
void QgsSpatialQuery::runQuery( QSet<int> & qsetIndexResult, int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
|
void QgsSpatialQuery::runQuery( QSet<int> & qsetIndexResult, int relation, QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
|
||||||
{
|
{
|
||||||
setQuery(lyrTarget, lyrReference);
|
setQuery( lyrTarget, lyrReference );
|
||||||
|
|
||||||
// Create Spatial index for Reference - Set mIndexReference
|
// Create Spatial index for Reference - Set mIndexReference
|
||||||
mPb->setFormat("Processing 1/2 - %p%");
|
mPb->setFormat( "Processing 1/2 - %p%" );
|
||||||
int totalStep = mUseReferenceSelection
|
int totalStep = mUseReferenceSelection
|
||||||
? mLayerReference->selectedFeatureCount()
|
? mLayerReference->selectedFeatureCount()
|
||||||
: (int) (mLayerReference->featureCount());
|
: ( int )( mLayerReference->featureCount() );
|
||||||
mPb->init(1, totalStep);
|
mPb->init( 1, totalStep );
|
||||||
setSpatialIndexReference(); // Need set mLayerReference before
|
setSpatialIndexReference(); // Need set mLayerReference before
|
||||||
|
|
||||||
// Make Query
|
// Make Query
|
||||||
mPb->setFormat("Processing 2/2 - %p%");
|
mPb->setFormat( "Processing 2/2 - %p%" );
|
||||||
totalStep = mUseTargetSelection
|
totalStep = mUseTargetSelection
|
||||||
? mLayerTarget->selectedFeatureCount()
|
? mLayerTarget->selectedFeatureCount()
|
||||||
: (int) (mLayerTarget->featureCount());
|
: ( int )( mLayerTarget->featureCount() );
|
||||||
mPb->init(1, totalStep);
|
mPb->init( 1, totalStep );
|
||||||
|
|
||||||
execQuery(qsetIndexResult, relation);
|
execQuery( qsetIndexResult, relation );
|
||||||
|
|
||||||
} // QSet<int> QgsSpatialQuery::runQuery( int relation)
|
} // QSet<int> QgsSpatialQuery::runQuery( int relation)
|
||||||
|
|
||||||
QMap<QString, int>* QgsSpatialQuery::getTypesOperations(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
QMap<QString, int>* QgsSpatialQuery::getTypesOperations( QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference )
|
||||||
{
|
{
|
||||||
/* Relations from OGC document (obtain in February 2010)
|
/* Relations from OGC document (obtain in February 2010)
|
||||||
06-103r3_Candidate_Implementation_Specification_for_Geographic_Information_-_Simple_feature_access_-_Part_1_Common_Architecture_v1.2.0.pdf
|
06-103r3_Candidate_Implementation_Specification_for_Geographic_Information_-_Simple_feature_access_-_Part_1_Common_Architecture_v1.2.0.pdf
|
||||||
|
|
||||||
(P)oint, (L)ine and (A)rea
|
(P)oint, (L)ine and (A)rea
|
||||||
Target Geometry(P,L,A) / Reference Geometry (P,L,A)
|
Target Geometry(P,L,A) / Reference Geometry (P,L,A)
|
||||||
dim -> Dimension of geometry
|
dim -> Dimension of geometry
|
||||||
Relations:
|
Relations:
|
||||||
1) Intersects and Disjoint: All
|
1) Intersects and Disjoint: All
|
||||||
2) Touches: P/L P/A L/L L/A A/A
|
2) Touches: P/L P/A L/L L/A A/A
|
||||||
dimReference > dimTarget OR dimReference = dimTarget if dimReference > 0
|
dimReference > dimTarget OR dimReference = dimTarget if dimReference > 0
|
||||||
3) Crosses: P/L P/A L/L L/A
|
3) Crosses: P/L P/A L/L L/A
|
||||||
dimReference > dimTarget OR dimReference = dimTarget if dimReference = 1
|
dimReference > dimTarget OR dimReference = dimTarget if dimReference = 1
|
||||||
4) Within: P/L P/A L/A A/A
|
4) Within: P/L P/A L/A A/A
|
||||||
dimReference > dimTarget OR dimReference = dimTarget if dimReference = 2
|
dimReference > dimTarget OR dimReference = dimTarget if dimReference = 2
|
||||||
5) Equals: P/P L/L A/A
|
5) Equals: P/P L/L A/A
|
||||||
dimReference = dimTarget
|
dimReference = dimTarget
|
||||||
6) Overlaps: P/P L/L A/A
|
6) Overlaps: P/P L/L A/A
|
||||||
dimReference = dimTarget
|
dimReference = dimTarget
|
||||||
7) Contains: L/P A/P A/L A/A
|
7) Contains: L/P A/P A/L A/A
|
||||||
dimReference < dimTarget OR dimReference = dimTarget if dimReference = 2
|
dimReference < dimTarget OR dimReference = dimTarget if dimReference = 2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QMap<QString, int> * operations = new QMap<QString, int>;
|
QMap<QString, int> * operations = new QMap<QString, int>;
|
||||||
operations->insert(QObject::tr("Intersects"), Intersects);
|
operations->insert( QObject::tr( "Intersects" ), Intersects );
|
||||||
operations->insert(QObject::tr("Disjoint"), Disjoint);
|
operations->insert( QObject::tr( "Disjoint" ), Disjoint );
|
||||||
|
|
||||||
short int dimTarget=0, dimReference=0;
|
short int dimTarget = 0, dimReference = 0;
|
||||||
dimTarget = dimensionGeometry(lyrTarget->geometryType());
|
dimTarget = dimensionGeometry( lyrTarget->geometryType() );
|
||||||
dimReference = dimensionGeometry(lyrReference->geometryType());
|
dimReference = dimensionGeometry( lyrReference->geometryType() );
|
||||||
|
|
||||||
if (dimReference > dimTarget)
|
if ( dimReference > dimTarget )
|
||||||
|
{
|
||||||
|
operations->insert( QObject::tr( "Touches" ), Touches );
|
||||||
|
operations->insert( QObject::tr( "Crosses" ), Crosses );
|
||||||
|
operations->insert( QObject::tr( "Within" ), Within );
|
||||||
|
}
|
||||||
|
else if ( dimReference < dimTarget )
|
||||||
|
{
|
||||||
|
operations->insert( QObject::tr( "Contains" ), Contains );
|
||||||
|
}
|
||||||
|
else // dimReference == dimTarget
|
||||||
|
{
|
||||||
|
operations->insert( QObject::tr( "Equals" ), Equals );
|
||||||
|
operations->insert( QObject::tr( "Overlaps" ), Overlaps );
|
||||||
|
switch ( dimReference )
|
||||||
{
|
{
|
||||||
operations->insert(QObject::tr("Touches"), Touches);
|
case 0:
|
||||||
operations->insert(QObject::tr("Crosses"), Crosses);
|
break;
|
||||||
operations->insert(QObject::tr("Within"), Within);
|
case 1:
|
||||||
|
operations->insert( QObject::tr( "Touches" ), Touches );
|
||||||
|
operations->insert( QObject::tr( "Crosses" ), Crosses );
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
operations->insert( QObject::tr( "Touches" ), Touches );
|
||||||
|
operations->insert( QObject::tr( "Within" ), Within );
|
||||||
|
operations->insert( QObject::tr( "Contains" ), Contains );
|
||||||
}
|
}
|
||||||
else if (dimReference < dimTarget)
|
}
|
||||||
{
|
return operations;
|
||||||
operations->insert(QObject::tr("Contains"), Contains);
|
|
||||||
}
|
|
||||||
else // dimReference == dimTarget
|
|
||||||
{
|
|
||||||
operations->insert(QObject::tr("Equals"), Equals);
|
|
||||||
operations->insert(QObject::tr("Overlaps"), Overlaps);
|
|
||||||
switch (dimReference)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
operations->insert(QObject::tr("Touches"), Touches);
|
|
||||||
operations->insert(QObject::tr("Crosses"), Crosses);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
operations->insert(QObject::tr("Touches"), Touches);
|
|
||||||
operations->insert(QObject::tr("Within"), Within);
|
|
||||||
operations->insert(QObject::tr("Contains"), Contains);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return operations;
|
|
||||||
|
|
||||||
} // QMap<QString, int>* QgsSpatialQuery::getTypesOperators(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
} // QMap<QString, int>* QgsSpatialQuery::getTypesOperators(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
||||||
|
|
||||||
short int QgsSpatialQuery::dimensionGeometry(QGis::GeometryType geomType)
|
short int QgsSpatialQuery::dimensionGeometry( QGis::GeometryType geomType )
|
||||||
{
|
{
|
||||||
int dimGeom = 0;
|
int dimGeom = 0;
|
||||||
switch (geomType)
|
switch ( geomType )
|
||||||
{
|
{
|
||||||
case QGis::Point:
|
case QGis::Point:
|
||||||
dimGeom = 0;
|
dimGeom = 0;
|
||||||
break;
|
break;
|
||||||
case QGis::Line:
|
case QGis::Line:
|
||||||
dimGeom = 1;
|
dimGeom = 1;
|
||||||
break;
|
break;
|
||||||
case QGis::Polygon:
|
case QGis::Polygon:
|
||||||
dimGeom = 2;
|
dimGeom = 2;
|
||||||
}
|
default:
|
||||||
return dimGeom;
|
Q_ASSERT( 0 );
|
||||||
|
dimGeom = 0;
|
||||||
|
}
|
||||||
|
return dimGeom;
|
||||||
|
|
||||||
} // int QgsSpatialQuery::dimensionGeometry(QGis::GeometryType geomType)
|
} // int QgsSpatialQuery::dimensionGeometry(QGis::GeometryType geomType)
|
||||||
|
|
||||||
void QgsSpatialQuery::setQuery (QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference)
|
void QgsSpatialQuery::setQuery( QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference )
|
||||||
{
|
{
|
||||||
mLayerTarget = layerTarget;
|
mLayerTarget = layerTarget;
|
||||||
mReaderFeaturesTarget = new QgsReaderFeatures(mLayerTarget, mUseTargetSelection);
|
mReaderFeaturesTarget = new QgsReaderFeatures( mLayerTarget, mUseTargetSelection );
|
||||||
mLayerReference = layerReference;
|
mLayerReference = layerReference;
|
||||||
|
|
||||||
} // void QgsSpatialQuery::setQuery (QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference)
|
} // void QgsSpatialQuery::setQuery (QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference)
|
||||||
|
|
||||||
bool QgsSpatialQuery::hasValidGeometry(QgsFeature &feature)
|
bool QgsSpatialQuery::hasValidGeometry( QgsFeature &feature )
|
||||||
{
|
{
|
||||||
if ( ! feature.isValid() )
|
if ( ! feature.isValid() )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsGeometry *geom = feature.geometry();
|
QgsGeometry *geom = feature.geometry();
|
||||||
|
|
||||||
if ( NULL == geom )
|
if ( NULL == geom )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GEOSGeometry *geomGeos = geom->asGeos();
|
GEOSGeometry *geomGeos = geom->asGeos();
|
||||||
|
|
||||||
if ( GEOSisEmpty(geomGeos) || 1 != GEOSisValid(geomGeos))
|
if ( GEOSisEmpty( geomGeos ) || 1 != GEOSisValid( geomGeos ) )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -190,153 +193,153 @@ bool QgsSpatialQuery::hasValidGeometry(QgsFeature &feature)
|
|||||||
|
|
||||||
void QgsSpatialQuery::setSpatialIndexReference()
|
void QgsSpatialQuery::setSpatialIndexReference()
|
||||||
{
|
{
|
||||||
QgsReaderFeatures * readerFeaturesReference = new QgsReaderFeatures(mLayerReference, mUseReferenceSelection);
|
QgsReaderFeatures * readerFeaturesReference = new QgsReaderFeatures( mLayerReference, mUseReferenceSelection );
|
||||||
QgsFeature feature;
|
QgsFeature feature;
|
||||||
int step = 1;
|
int step = 1;
|
||||||
while ( true )
|
while ( true )
|
||||||
|
{
|
||||||
|
if ( ! readerFeaturesReference->nextFeature( feature ) )
|
||||||
{
|
{
|
||||||
if ( ! readerFeaturesReference->nextFeature(feature) )
|
break;
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
mPb->step(step++);
|
|
||||||
|
|
||||||
if ( ! hasValidGeometry(feature) )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
mIndexReference.insertFeature(feature);
|
|
||||||
}
|
}
|
||||||
delete readerFeaturesReference;
|
mPb->step( step++ );
|
||||||
|
|
||||||
|
if ( ! hasValidGeometry( feature ) )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
mIndexReference.insertFeature( feature );
|
||||||
|
}
|
||||||
|
delete readerFeaturesReference;
|
||||||
|
|
||||||
} // void QgsSpatialQuery::setSpatialIndexReference()
|
} // void QgsSpatialQuery::setSpatialIndexReference()
|
||||||
|
|
||||||
void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
|
void QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation )
|
||||||
{
|
{
|
||||||
// Set function GEOS
|
// Set function GEOS
|
||||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry*);
|
char( *operation )( const GEOSGeometry *, const GEOSGeometry* );
|
||||||
switch (relation)
|
switch ( relation )
|
||||||
{
|
{
|
||||||
case Disjoint:
|
case Disjoint:
|
||||||
operation = &GEOSDisjoint;
|
operation = &GEOSDisjoint;
|
||||||
break;
|
break;
|
||||||
case Equals:
|
case Equals:
|
||||||
operation = &GEOSEquals;
|
operation = &GEOSEquals;
|
||||||
break;
|
break;
|
||||||
case Touches:
|
case Touches:
|
||||||
operation = &GEOSTouches;
|
operation = &GEOSTouches;
|
||||||
break;
|
break;
|
||||||
case Overlaps:
|
case Overlaps:
|
||||||
operation = &GEOSOverlaps;
|
operation = &GEOSOverlaps;
|
||||||
break;
|
break;
|
||||||
case Within:
|
case Within:
|
||||||
operation = &GEOSWithin;
|
operation = &GEOSWithin;
|
||||||
break;
|
break;
|
||||||
case Contains:
|
case Contains:
|
||||||
operation = &GEOSContains;
|
operation = &GEOSContains;
|
||||||
break;
|
break;
|
||||||
case Crosses:
|
case Crosses:
|
||||||
operation = &GEOSCrosses;
|
operation = &GEOSCrosses;
|
||||||
break;
|
break;
|
||||||
case Intersects:
|
case Intersects:
|
||||||
operation = &GEOSIntersects;
|
operation = &GEOSIntersects;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform referencer Target = Reference
|
// Transform referencer Target = Reference
|
||||||
QgsGeometryCoordinateTransform *coordinateTransform = new QgsGeometryCoordinateTransform();
|
QgsGeometryCoordinateTransform *coordinateTransform = new QgsGeometryCoordinateTransform();
|
||||||
coordinateTransform->setCoordinateTransform(mLayerTarget, mLayerReference);
|
coordinateTransform->setCoordinateTransform( mLayerTarget, mLayerReference );
|
||||||
|
|
||||||
// Set function for populate result
|
// Set function for populate result
|
||||||
void (QgsSpatialQuery::* funcPopulateIndexResult)
|
void ( QgsSpatialQuery::* funcPopulateIndexResult )
|
||||||
(QSet<int> &, int, QgsGeometry *,
|
( QSet<int> &, int, QgsGeometry *,
|
||||||
char(*)(const GEOSGeometry *, const GEOSGeometry *) );
|
char( * )( const GEOSGeometry *, const GEOSGeometry * ) );
|
||||||
funcPopulateIndexResult = ( relation == Disjoint )
|
funcPopulateIndexResult = ( relation == Disjoint )
|
||||||
? &QgsSpatialQuery::populateIndexResultDisjoint
|
? &QgsSpatialQuery::populateIndexResultDisjoint
|
||||||
: &QgsSpatialQuery::populateIndexResult;
|
: &QgsSpatialQuery::populateIndexResult;
|
||||||
|
|
||||||
QgsFeature featureTarget;
|
QgsFeature featureTarget;
|
||||||
QgsGeometry * geomTarget;
|
QgsGeometry * geomTarget;
|
||||||
int step = 1;
|
int step = 1;
|
||||||
while( true )
|
while ( true )
|
||||||
|
{
|
||||||
|
if ( ! mReaderFeaturesTarget->nextFeature( featureTarget ) ) break;
|
||||||
|
|
||||||
|
mPb->step( step++ );
|
||||||
|
|
||||||
|
if ( ! hasValidGeometry( featureTarget ) )
|
||||||
{
|
{
|
||||||
if ( ! mReaderFeaturesTarget->nextFeature(featureTarget) ) break;
|
continue;
|
||||||
|
|
||||||
mPb->step(step++);
|
|
||||||
|
|
||||||
if ( ! hasValidGeometry(featureTarget) )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
geomTarget = featureTarget.geometry();
|
|
||||||
coordinateTransform->transform(geomTarget);
|
|
||||||
|
|
||||||
(this->*funcPopulateIndexResult)
|
|
||||||
(qsetIndexResult, featureTarget.id(), geomTarget, operation);
|
|
||||||
}
|
}
|
||||||
delete coordinateTransform;
|
|
||||||
|
geomTarget = featureTarget.geometry();
|
||||||
|
coordinateTransform->transform( geomTarget );
|
||||||
|
|
||||||
|
( this->*funcPopulateIndexResult )
|
||||||
|
( qsetIndexResult, featureTarget.id(), geomTarget, operation );
|
||||||
|
}
|
||||||
|
delete coordinateTransform;
|
||||||
|
|
||||||
} // QSet<int> QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
|
} // QSet<int> QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
|
||||||
|
|
||||||
void QgsSpatialQuery::populateIndexResult(
|
void QgsSpatialQuery::populateIndexResult(
|
||||||
QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
||||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry *) )
|
char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) )
|
||||||
{
|
{
|
||||||
QList<int> listIdReference;
|
QList<int> listIdReference;
|
||||||
listIdReference = mIndexReference.intersects(geomTarget->boundingBox());
|
listIdReference = mIndexReference.intersects( geomTarget->boundingBox() );
|
||||||
if ( listIdReference.count() == 0 )
|
if ( listIdReference.count() == 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GEOSGeometry * geosTarget = geomTarget->asGeos();
|
||||||
|
QgsFeature featureReference;
|
||||||
|
QgsGeometry * geomReference;
|
||||||
|
QList<int>::iterator iterIdReference = listIdReference.begin();
|
||||||
|
for ( ; iterIdReference != listIdReference.end(); iterIdReference++ )
|
||||||
|
{
|
||||||
|
mLayerReference->featureAtId( *iterIdReference, featureReference );
|
||||||
|
geomReference = featureReference.geometry();
|
||||||
|
if (( *operation )( geosTarget, geomReference->asGeos() ) == 1 )
|
||||||
{
|
{
|
||||||
return;
|
qsetIndexResult.insert( idTarget );
|
||||||
}
|
break;
|
||||||
GEOSGeometry * geosTarget = geomTarget->asGeos();
|
|
||||||
QgsFeature featureReference;
|
|
||||||
QgsGeometry * geomReference;
|
|
||||||
QList<int>::iterator iterIdReference = listIdReference.begin();
|
|
||||||
for( ; iterIdReference != listIdReference.end(); iterIdReference++ )
|
|
||||||
{
|
|
||||||
mLayerReference->featureAtId(*iterIdReference, featureReference);
|
|
||||||
geomReference = featureReference.geometry();
|
|
||||||
if( (*operation)(geosTarget, geomReference->asGeos()) == 1 )
|
|
||||||
{
|
|
||||||
qsetIndexResult.insert(idTarget);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // void QgsSpatialQuery::populateIndexResult(...
|
} // void QgsSpatialQuery::populateIndexResult(...
|
||||||
|
|
||||||
void QgsSpatialQuery::populateIndexResultDisjoint(
|
void QgsSpatialQuery::populateIndexResultDisjoint(
|
||||||
QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
QSet<int> &qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
||||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry *) )
|
char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) )
|
||||||
{
|
{
|
||||||
QList<int> listIdReference;
|
QList<int> listIdReference;
|
||||||
listIdReference = mIndexReference.intersects(geomTarget->boundingBox());
|
listIdReference = mIndexReference.intersects( geomTarget->boundingBox() );
|
||||||
if ( listIdReference.count() == 0 )
|
if ( listIdReference.count() == 0 )
|
||||||
|
{
|
||||||
|
qsetIndexResult.insert( idTarget );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GEOSGeometry * geosTarget = geomTarget->asGeos();
|
||||||
|
QgsFeature featureReference;
|
||||||
|
QgsGeometry * geomReference;
|
||||||
|
QList<int>::iterator iterIdReference = listIdReference.begin();
|
||||||
|
bool addIndex = true;
|
||||||
|
for ( ; iterIdReference != listIdReference.end(); iterIdReference++ )
|
||||||
|
{
|
||||||
|
mLayerReference->featureAtId( *iterIdReference, featureReference );
|
||||||
|
geomReference = featureReference.geometry();
|
||||||
|
if (( *operation )( geosTarget, geomReference->asGeos() ) == 0 )
|
||||||
{
|
{
|
||||||
qsetIndexResult.insert(idTarget);
|
addIndex = false;
|
||||||
return;
|
break;
|
||||||
}
|
|
||||||
GEOSGeometry * geosTarget = geomTarget->asGeos();
|
|
||||||
QgsFeature featureReference;
|
|
||||||
QgsGeometry * geomReference;
|
|
||||||
QList<int>::iterator iterIdReference = listIdReference.begin();
|
|
||||||
bool addIndex = true;
|
|
||||||
for( ; iterIdReference != listIdReference.end(); iterIdReference++ )
|
|
||||||
{
|
|
||||||
mLayerReference->featureAtId(*iterIdReference, featureReference);
|
|
||||||
geomReference = featureReference.geometry();
|
|
||||||
if( (*operation)(geosTarget, geomReference->asGeos()) == 0 )
|
|
||||||
{
|
|
||||||
addIndex = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( addIndex )
|
|
||||||
{
|
|
||||||
qsetIndexResult.insert(idTarget);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ( addIndex )
|
||||||
|
{
|
||||||
|
qsetIndexResult.insert( idTarget );
|
||||||
|
}
|
||||||
|
|
||||||
} // void QgsSpatialQuery::populateIndexResultDisjoint( ...
|
} // void QgsSpatialQuery::populateIndexResultDisjoint( ...
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@
|
|||||||
*/
|
*/
|
||||||
enum Topologic_Relation
|
enum Topologic_Relation
|
||||||
{
|
{
|
||||||
Intersects,
|
Intersects,
|
||||||
Disjoint,
|
Disjoint,
|
||||||
Touches,
|
Touches,
|
||||||
Crosses,
|
Crosses,
|
||||||
Within,
|
Within,
|
||||||
Equals,
|
Equals,
|
||||||
Overlaps,
|
Overlaps,
|
||||||
Contains
|
Contains
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -53,12 +53,12 @@ enum Topologic_Relation
|
|||||||
*/
|
*/
|
||||||
class QgsSpatialQuery
|
class QgsSpatialQuery
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* \brief Constructor for a Spatial query.
|
* \brief Constructor for a Spatial query.
|
||||||
* \param pb Pointer to the MngProgressBar object.
|
* \param pb Pointer to the MngProgressBar object.
|
||||||
*/
|
*/
|
||||||
QgsSpatialQuery(MngProgressBar *pb);
|
QgsSpatialQuery( MngProgressBar *pb );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Destructor
|
* \brief Destructor
|
||||||
@ -69,13 +69,13 @@ public:
|
|||||||
* \brief Sets if using selected features in Target layer
|
* \brief Sets if using selected features in Target layer
|
||||||
* \param useSelected TRUE if use selected.
|
* \param useSelected TRUE if use selected.
|
||||||
*/
|
*/
|
||||||
void setSelectedFeaturesTarget(bool useSelected);
|
void setSelectedFeaturesTarget( bool useSelected );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets if using selected features in Reference layer
|
* \brief Sets if using selected features in Reference layer
|
||||||
* \param useSelected TRUE if use selected.
|
* \param useSelected TRUE if use selected.
|
||||||
*/
|
*/
|
||||||
void setSelectedFeaturesReference(bool useSelected);
|
void setSelectedFeaturesReference( bool useSelected );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Execute the query
|
* \brief Execute the query
|
||||||
@ -99,9 +99,9 @@ public:
|
|||||||
* \param geomType Geometry Type
|
* \param geomType Geometry Type
|
||||||
* \returns short int Topologic Dimension
|
* \returns short int Topologic Dimension
|
||||||
*/
|
*/
|
||||||
static short int dimensionGeometry(QGis::GeometryType geomType);
|
static short int dimensionGeometry( QGis::GeometryType geomType );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets the target layer and reference layer
|
* \brief Sets the target layer and reference layer
|
||||||
@ -114,7 +114,7 @@ private:
|
|||||||
* \brief Verify has valid Geometry in feature
|
* \brief Verify has valid Geometry in feature
|
||||||
* \param QgsFeature Feature
|
* \param QgsFeature Feature
|
||||||
*/
|
*/
|
||||||
bool hasValidGeometry(QgsFeature &feature);
|
bool hasValidGeometry( QgsFeature &feature );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Build the Spatial Index
|
* \brief Build the Spatial Index
|
||||||
@ -126,7 +126,7 @@ private:
|
|||||||
* \param qsetIndexResult Reference to QSet contains the result query
|
* \param qsetIndexResult Reference to QSet contains the result query
|
||||||
* \param relation Enum Topologic Relation
|
* \param relation Enum Topologic Relation
|
||||||
*/
|
*/
|
||||||
void execQuery(QSet<int> & qsetIndexResult, int relation);
|
void execQuery( QSet<int> & qsetIndexResult, int relation );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Populate index Result
|
* \brief Populate index Result
|
||||||
@ -136,8 +136,8 @@ private:
|
|||||||
* \param operation Pointer to function of GEOS operation
|
* \param operation Pointer to function of GEOS operation
|
||||||
*/
|
*/
|
||||||
void populateIndexResult(
|
void populateIndexResult(
|
||||||
QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
||||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry *) );
|
char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) );
|
||||||
/**
|
/**
|
||||||
* \brief Populate index Result Disjoint
|
* \brief Populate index Result Disjoint
|
||||||
* \param qsetIndexResult Reference to QSet contains the result query
|
* \param qsetIndexResult Reference to QSet contains the result query
|
||||||
@ -146,8 +146,8 @@ private:
|
|||||||
* \param operation Pointer to function of GEOS operation
|
* \param operation Pointer to function of GEOS operation
|
||||||
*/
|
*/
|
||||||
void populateIndexResultDisjoint(
|
void populateIndexResultDisjoint(
|
||||||
QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
QSet<int> & qsetIndexResult, int idTarget, QgsGeometry * geomTarget,
|
||||||
char(*operation)(const GEOSGeometry *, const GEOSGeometry *) );
|
char( *operation )( const GEOSGeometry *, const GEOSGeometry * ) );
|
||||||
|
|
||||||
MngProgressBar *mPb;
|
MngProgressBar *mPb;
|
||||||
bool mUseReferenceSelection;
|
bool mUseReferenceSelection;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,13 +34,13 @@
|
|||||||
class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogBase
|
class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor for a dialog. The QgisInterface pointer is passed by
|
* Constructor for a dialog. The QgisInterface pointer is passed by
|
||||||
* QGIS when it attempts to instantiate the plugin.
|
* QGIS when it attempts to instantiate the plugin.
|
||||||
* @param iface Pointer to the QgisInterface object.
|
* @param iface Pointer to the QgisInterface object.
|
||||||
*/
|
*/
|
||||||
QgsSpatialQueryDialog(QWidget *parent = 0, QgisInterface* iface = 0);
|
QgsSpatialQueryDialog( QWidget *parent = 0, QgisInterface* iface = 0 );
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~QgsSpatialQueryDialog();
|
~QgsSpatialQueryDialog();
|
||||||
|
|
||||||
@ -50,24 +50,24 @@ public:
|
|||||||
//! Unload plugins by QGIS - Disconnect signal from QGIS
|
//! Unload plugins by QGIS - Disconnect signal from QGIS
|
||||||
void disconnectQGis();
|
void disconnectQGis();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Slots for signs of Dialog
|
//! Slots for signs of Dialog
|
||||||
void on_buttonBox_accepted();
|
void on_buttonBox_accepted();
|
||||||
void on_buttonBox_rejected();
|
void on_buttonBox_rejected();
|
||||||
void on_targetLayerComboBox_currentIndexChanged( int index );
|
void on_targetLayerComboBox_currentIndexChanged( int index );
|
||||||
void on_referenceLayerComboBox_currentIndexChanged( int index );
|
void on_referenceLayerComboBox_currentIndexChanged( int index );
|
||||||
void on_selectedFeatureListWidget_currentTextChanged ( const QString& currentText );
|
void on_selectedFeatureListWidget_currentTextChanged( const QString& currentText );
|
||||||
void on_showLogProcessingCheckBox_clicked(bool checked);
|
void on_showLogProcessingCheckBox_clicked( bool checked );
|
||||||
|
|
||||||
//! Slots for signs of QGIS
|
//! Slots for signs of QGIS
|
||||||
void signal_qgis_layerWasAdded ( QgsMapLayer* mapLayer );
|
void signal_qgis_layerWasAdded( QgsMapLayer* mapLayer );
|
||||||
void signal_qgis_layerWillBeRemoved ( QString idLayer );
|
void signal_qgis_layerWillBeRemoved( QString idLayer );
|
||||||
|
|
||||||
//! Slots for signs of Layers (Target or Reference)
|
//! Slots for signs of Layers (Target or Reference)
|
||||||
void signal_layerTarget_selectionFeaturesChanged();
|
void signal_layerTarget_selectionFeaturesChanged();
|
||||||
void signal_layerReference_selectionFeaturesChanged();
|
void signal_layerReference_selectionFeaturesChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Initialize the Gui
|
//! Initialize the Gui
|
||||||
void initGui();
|
void initGui();
|
||||||
//! Set Color mRubberSelectId
|
//! Set Color mRubberSelectId
|
||||||
@ -79,11 +79,11 @@ private slots:
|
|||||||
//! Run Query
|
//! Run Query
|
||||||
void runQuery();
|
void runQuery();
|
||||||
//! Show Log Processing
|
//! Show Log Processing
|
||||||
void showLogProcessing(bool hasShow);
|
void showLogProcessing( bool hasShow );
|
||||||
//! Show result of query
|
//! Show result of query
|
||||||
void showResultQuery(QDateTime *datetimeStart, QDateTime *datetimeEnd);
|
void showResultQuery( QDateTime *datetimeStart, QDateTime *datetimeEnd );
|
||||||
//! Get Description Layer to show result
|
//! Get Description Layer to show result
|
||||||
QString getDescriptionLayerShow(bool isTarget);
|
QString getDescriptionLayerShow( bool isTarget );
|
||||||
//! Connect all slots
|
//! Connect all slots
|
||||||
void connectAll();
|
void connectAll();
|
||||||
//! Disconnect all slots
|
//! Disconnect all slots
|
||||||
@ -91,15 +91,15 @@ private slots:
|
|||||||
//! reject - override
|
//! reject - override
|
||||||
void reject();
|
void reject();
|
||||||
//! Get Vector layer from combobox
|
//! Get Vector layer from combobox
|
||||||
QgsVectorLayer * getLayerFromCombobox(bool isTarget, int index);
|
QgsVectorLayer * getLayerFromCombobox( bool isTarget, int index );
|
||||||
//! Get Icon for vector layer
|
//! Get Icon for vector layer
|
||||||
QIcon getIconTypeGeometry(QGis::GeometryType geomType);
|
QIcon getIconTypeGeometry( QGis::GeometryType geomType );
|
||||||
//! Add layer in combobox (text, data and tooltips)
|
//! Add layer in combobox (text, data and tooltips)
|
||||||
void addLayerCombobox(bool isTarget, QgsVectorLayer* vectorLayer);
|
void addLayerCombobox( bool isTarget, QgsVectorLayer* vectorLayer );
|
||||||
//! Find Layer in combobox
|
//! Find Layer in combobox
|
||||||
int getIndexLayerCombobox(bool isTarget, QgsVectorLayer* vectorLayer);
|
int getIndexLayerCombobox( bool isTarget, QgsVectorLayer* vectorLayer );
|
||||||
//! Remove layer in combobox and setting GUI
|
//! Remove layer in combobox and setting GUI
|
||||||
void removeLayer(bool isTarget, QgsVectorLayer* lyrRemove);
|
void removeLayer( bool isTarget, QgsVectorLayer* lyrRemove );
|
||||||
//! Populates targetLayerComboBox with all layers
|
//! Populates targetLayerComboBox with all layers
|
||||||
void populateTargetLayerComboBox();
|
void populateTargetLayerComboBox();
|
||||||
//! Populates referenceLayerComboBox with all layers except the current target layer
|
//! Populates referenceLayerComboBox with all layers except the current target layer
|
||||||
@ -125,7 +125,7 @@ private slots:
|
|||||||
// Menssage
|
// Menssage
|
||||||
QString mMsgLayersLessTwo;
|
QString mMsgLayersLessTwo;
|
||||||
|
|
||||||
void MsgDEBUG(QString sMSg);
|
void MsgDEBUG( QString sMSg );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SPATIALQUERYDIALOG_H
|
#endif // SPATIALQUERYDIALOG_H
|
||||||
|
@ -57,83 +57,84 @@ static const QgisPlugin::PLUGINTYPE type_ = QgisPlugin::UI;
|
|||||||
* @param qgis Pointer to the QGIS main window
|
* @param qgis Pointer to the QGIS main window
|
||||||
* @parma mIface Pointer to the QGIS interface object
|
* @parma mIface Pointer to the QGIS interface object
|
||||||
*/
|
*/
|
||||||
QgsSpatialQueryPlugin::QgsSpatialQueryPlugin(QgisInterface* iface)
|
QgsSpatialQueryPlugin::QgsSpatialQueryPlugin( QgisInterface* iface )
|
||||||
:QgisPlugin( name_, description_, version_, type_ ),
|
: QgisPlugin( name_, description_, version_, type_ ),
|
||||||
mIface(iface)
|
mIface( iface )
|
||||||
{
|
{
|
||||||
mDialog = NULL;
|
mDialog = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsSpatialQueryPlugin::~QgsSpatialQueryPlugin()
|
QgsSpatialQueryPlugin::~QgsSpatialQueryPlugin()
|
||||||
{
|
{
|
||||||
mIface = NULL;
|
mIface = NULL;
|
||||||
delete mSpatialQueryAction;
|
delete mSpatialQueryAction;
|
||||||
delete mDialog;
|
delete mDialog;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Initialize the GUI interface for the plugin
|
* Initialize the GUI interface for the plugin
|
||||||
*/
|
*/
|
||||||
void QgsSpatialQueryPlugin::initGui()
|
void QgsSpatialQueryPlugin::initGui()
|
||||||
{
|
{
|
||||||
// Create the action for tool
|
// Create the action for tool
|
||||||
mSpatialQueryAction = new QAction( QIcon(), tr("&Spatial Query"), this);
|
mSpatialQueryAction = new QAction( QIcon(), tr( "&Spatial Query" ), this );
|
||||||
|
|
||||||
// Connect the action to the spatialQuery slot
|
// Connect the action to the spatialQuery slot
|
||||||
connect(mSpatialQueryAction, SIGNAL(activated()), this, SLOT(run()));
|
connect( mSpatialQueryAction, SIGNAL( activated() ), this, SLOT( run() ) );
|
||||||
|
|
||||||
setCurrentTheme( "" );
|
setCurrentTheme( "" );
|
||||||
// this is called when the icon theme is changed
|
// this is called when the icon theme is changed
|
||||||
connect( mIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );
|
connect( mIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );
|
||||||
|
|
||||||
// Add the icon to the toolbar and to the plugin menu
|
// Add the icon to the toolbar and to the plugin menu
|
||||||
mIface->addToolBarIcon(mSpatialQueryAction);
|
mIface->addToolBarIcon( mSpatialQueryAction );
|
||||||
mIface->addPluginToMenu(tr("&Spatial Query"), mSpatialQueryAction);
|
mIface->addPluginToMenu( tr( "&Spatial Query" ), mSpatialQueryAction );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Unload the plugin by cleaning up the GUI
|
//Unload the plugin by cleaning up the GUI
|
||||||
void QgsSpatialQueryPlugin::unload()
|
void QgsSpatialQueryPlugin::unload()
|
||||||
{
|
{
|
||||||
// remove the GUI
|
// remove the GUI
|
||||||
mIface->removeToolBarIcon(mSpatialQueryAction);
|
mIface->removeToolBarIcon( mSpatialQueryAction );
|
||||||
mIface->removePluginMenu(tr("&Spatial Query"), mSpatialQueryAction);
|
mIface->removePluginMenu( tr( "&Spatial Query" ), mSpatialQueryAction );
|
||||||
|
|
||||||
delete mSpatialQueryAction;
|
delete mSpatialQueryAction;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsSpatialQueryPlugin::run()
|
void QgsSpatialQueryPlugin::run()
|
||||||
{
|
{
|
||||||
if (!mDialog){
|
if ( !mDialog )
|
||||||
if(QgsMapLayerRegistry::instance()->mapLayers().size() < 2)
|
{
|
||||||
{
|
if ( QgsMapLayerRegistry::instance()->mapLayers().size() < 2 )
|
||||||
QgsSpatialQueryDialog::messageLayersLessTwo();
|
{
|
||||||
return;
|
QgsSpatialQueryDialog::messageLayersLessTwo();
|
||||||
}
|
return;
|
||||||
mDialog = new QgsSpatialQueryDialog(mIface->mainWindow(), mIface);
|
}
|
||||||
mDialog->setModal(false);
|
mDialog = new QgsSpatialQueryDialog( mIface->mainWindow(), mIface );
|
||||||
mDialog->show();
|
mDialog->setModal( false );
|
||||||
|
mDialog->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !mDialog->isVisible() )
|
||||||
|
{
|
||||||
|
delete mDialog;
|
||||||
|
mDialog = NULL;
|
||||||
|
run();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !mDialog->isVisible() )
|
mDialog->activateWindow();
|
||||||
{
|
|
||||||
delete mDialog;
|
|
||||||
mDialog = NULL;
|
|
||||||
run();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mDialog->activateWindow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Set icons to the current theme
|
//! Set icons to the current theme
|
||||||
void QgsSpatialQueryPlugin::setCurrentTheme( QString )
|
void QgsSpatialQueryPlugin::setCurrentTheme( QString )
|
||||||
{
|
{
|
||||||
mSpatialQueryAction->setIcon(getThemeIcon("/spatialquery.png"));
|
mSpatialQueryAction->setIcon( getThemeIcon( "/spatialquery.png" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon QgsSpatialQueryPlugin::getThemeIcon( const QString &theName )
|
QIcon QgsSpatialQueryPlugin::getThemeIcon( const QString &theName )
|
||||||
@ -142,19 +143,19 @@ QIcon QgsSpatialQueryPlugin::getThemeIcon( const QString &theName )
|
|||||||
{
|
{
|
||||||
return QIcon( QgsApplication::activeThemePath() + "/plugins" + theName );
|
return QIcon( QgsApplication::activeThemePath() + "/plugins" + theName );
|
||||||
}
|
}
|
||||||
else if (QFile::exists(QgsApplication::defaultThemePath() + "/plugins" + theName ))
|
else if ( QFile::exists( QgsApplication::defaultThemePath() + "/plugins" + theName ) )
|
||||||
{
|
{
|
||||||
return QIcon( QgsApplication::defaultThemePath() + "/plugins" + theName );
|
return QIcon( QgsApplication::defaultThemePath() + "/plugins" + theName );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QIcon(":/icons" + theName);
|
return QIcon( ":/icons" + theName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsSpatialQueryPlugin::MsgDEBUG(QString sMSg)
|
void QgsSpatialQueryPlugin::MsgDEBUG( QString sMSg )
|
||||||
{
|
{
|
||||||
QMessageBox::warning(0, tr("DEBUG"), sMSg, QMessageBox::Ok);
|
QMessageBox::warning( 0, tr( "DEBUG" ), sMSg, QMessageBox::Ok );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -164,9 +165,9 @@ void QgsSpatialQueryPlugin::MsgDEBUG(QString sMSg)
|
|||||||
* of the plugin class
|
* of the plugin class
|
||||||
*/
|
*/
|
||||||
// Class factory to return a new instance of the plugin class
|
// Class factory to return a new instance of the plugin class
|
||||||
QGISEXTERN QgisPlugin* classFactory(QgisInterface* iface)
|
QGISEXTERN QgisPlugin* classFactory( QgisInterface* iface )
|
||||||
{
|
{
|
||||||
return new QgsSpatialQueryPlugin(iface);
|
return new QgsSpatialQueryPlugin( iface );
|
||||||
}
|
}
|
||||||
// Return the name of the plugin
|
// Return the name of the plugin
|
||||||
|
|
||||||
@ -194,7 +195,7 @@ QGISEXTERN QString version()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete ourself
|
// Delete ourself
|
||||||
QGISEXTERN void unload(QgisPlugin* theSpatialQueryPluginPointer)
|
QGISEXTERN void unload( QgisPlugin* theSpatialQueryPluginPointer )
|
||||||
{
|
{
|
||||||
delete theSpatialQueryPluginPointer;
|
delete theSpatialQueryPluginPointer;
|
||||||
}
|
}
|
||||||
|
@ -45,17 +45,17 @@ class QAction;
|
|||||||
class QgsSpatialQueryPlugin: public QObject, public QgisPlugin
|
class QgsSpatialQueryPlugin: public QObject, public QgisPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* \brief Constructor for a plugin. The QgisInterface pointer is passed by
|
* \brief Constructor for a plugin. The QgisInterface pointer is passed by
|
||||||
* QGIS when it attempts to instantiate the plugin.
|
* QGIS when it attempts to instantiate the plugin.
|
||||||
* \param iface Pointer to the QgisInterface object.
|
* \param iface Pointer to the QgisInterface object.
|
||||||
*/
|
*/
|
||||||
QgsSpatialQueryPlugin(QgisInterface* iface);
|
QgsSpatialQueryPlugin( QgisInterface* iface );
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~QgsSpatialQueryPlugin();
|
~QgsSpatialQueryPlugin();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! init the gui
|
//! init the gui
|
||||||
void initGui();
|
void initGui();
|
||||||
//! unload the plugin
|
//! unload the plugin
|
||||||
@ -66,7 +66,7 @@ class QgsSpatialQueryPlugin: public QObject, public QgisPlugin
|
|||||||
void setCurrentTheme( QString theThemeName );
|
void setCurrentTheme( QString theThemeName );
|
||||||
QIcon getThemeIcon( const QString &theThemeName );
|
QIcon getThemeIcon( const QString &theThemeName );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QgsSpatialQueryDialog *mDialog;
|
QgsSpatialQueryDialog *mDialog;
|
||||||
//! Pointer to the QgisInterface object
|
//! Pointer to the QgisInterface object
|
||||||
@ -75,7 +75,7 @@ class QgsSpatialQueryPlugin: public QObject, public QgisPlugin
|
|||||||
QAction* mSpatialQueryAction;
|
QAction* mSpatialQueryAction;
|
||||||
|
|
||||||
|
|
||||||
void MsgDEBUG(QString sMSg);
|
void MsgDEBUG( QString sMSg );
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user