[FEATURE] Drop spatial query plugin
* Tagged as feature to remember to include in release notes The functionality of this plugin is duplicated in the processing Extract by Location and Select by Location algorithms.
1
debian/qgis.install
vendored
@ -2,7 +2,6 @@ usr/lib/qgis/plugins/libgeorefplugin.so
|
||||
usr/lib/qgis/plugins/libgpsimporterplugin.so
|
||||
usr/lib/qgis/plugins/libcoordinatecaptureplugin.so
|
||||
usr/lib/qgis/plugins/libevis.so
|
||||
usr/lib/qgis/plugins/libspatialqueryplugin.so
|
||||
usr/lib/qgis/plugins/libofflineeditingplugin.so
|
||||
usr/lib/qgis/plugins/libtopolplugin.so
|
||||
usr/lib/qgis/plugins/libgeometrycheckerplugin.so
|
||||
|
@ -381,7 +381,6 @@ tar -C %OSGEO4W_ROOT% -cjf %ARCH%/release/qgis/%PACKAGENAME%/%PACKAGENAME%-%VERS
|
||||
"apps/%PACKAGENAME%/plugins/georefplugin.dll" ^
|
||||
"apps/%PACKAGENAME%/plugins/gpsimporterplugin.dll" ^
|
||||
"apps/%PACKAGENAME%/plugins/offlineeditingplugin.dll" ^
|
||||
"apps/%PACKAGENAME%/plugins/spatialqueryplugin.dll" ^
|
||||
"apps/%PACKAGENAME%/plugins/topolplugin.dll" ^
|
||||
"apps/%PACKAGENAME%/plugins/geometrycheckerplugin.dll" ^
|
||||
"apps/%PACKAGENAME%/qtplugins/sqldrivers/qsqlspatialite.dll" ^
|
||||
|
@ -15,7 +15,6 @@ WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "globeplugin" "false
|
||||
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "gpsimporterplugin" "true"
|
||||
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "grassplugin" "true"
|
||||
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "offlineeditingplugin" "true"
|
||||
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "spatialqueryplugin" "true"
|
||||
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "topolplugin" "true"
|
||||
|
||||
############################### reg2nsis end #################################
|
||||
|
@ -8,7 +8,6 @@ SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDI
|
||||
|
||||
ADD_SUBDIRECTORY(coordinate_capture)
|
||||
ADD_SUBDIRECTORY(evis)
|
||||
ADD_SUBDIRECTORY(spatialquery)
|
||||
ADD_SUBDIRECTORY(gps_importer)
|
||||
ADD_SUBDIRECTORY(topology)
|
||||
ADD_SUBDIRECTORY(offline_editing)
|
||||
|
@ -1,64 +0,0 @@
|
||||
########################################################
|
||||
# Files
|
||||
|
||||
SET (SPATIALQUERY_SRCS
|
||||
qgsspatialqueryplugin.cpp
|
||||
qgsspatialquerydialog.cpp
|
||||
qgsspatialquery.cpp
|
||||
qgsreaderfeatures.cpp
|
||||
qgsrubberselectid.cpp
|
||||
qgsgeometrycoordinatetransform.cpp
|
||||
qgsmngprogressbar.cpp
|
||||
)
|
||||
|
||||
SET (SPATIALQUERY_MOC_HDRS
|
||||
qgsspatialqueryplugin.h
|
||||
qgsspatialquerydialog.h
|
||||
)
|
||||
|
||||
SET( SPATIALQUERY_UIS qgsspatialquerydialogbase.ui)
|
||||
|
||||
SET (SPATIALQUERY_RCCS qgsspatialquerydialogbase.qrc)
|
||||
|
||||
########################################################
|
||||
# Build
|
||||
|
||||
QT5_WRAP_UI (SPATIALQUERY_UIS_H ${SPATIALQUERY_UIS})
|
||||
|
||||
QT5_WRAP_CPP (SPATIALQUERY_MOC_SRCS ${SPATIALQUERY_MOC_HDRS})
|
||||
|
||||
QT5_ADD_RESOURCES (SPATIALQUERY_RCC_SRCS ${SPATIALQUERY_RCCS})
|
||||
|
||||
ADD_LIBRARY (spatialqueryplugin MODULE ${SPATIALQUERY_SRCS} ${SPATIALQUERY_MOC_SRCS} ${SPATIALQUERY_RCC_SRCS} ${SPATIALQUERY_UIS_H})
|
||||
|
||||
INCLUDE_DIRECTORIES(SYSTEM
|
||||
${GEOS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_SOURCE_DIR}/src/core
|
||||
${CMAKE_SOURCE_DIR}/src/core/geometry
|
||||
${CMAKE_SOURCE_DIR}/src/core/expression
|
||||
${CMAKE_SOURCE_DIR}/src/core/metadata
|
||||
${CMAKE_SOURCE_DIR}/src/core/raster
|
||||
${CMAKE_SOURCE_DIR}/src/gui
|
||||
${CMAKE_SOURCE_DIR}/src/plugins
|
||||
|
||||
${CMAKE_BINARY_DIR}/src/core
|
||||
${CMAKE_BINARY_DIR}/src/gui
|
||||
${CMAKE_BINARY_DIR}/src/ui
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(spatialqueryplugin
|
||||
qgis_core
|
||||
qgis_gui
|
||||
)
|
||||
|
||||
|
||||
########################################################
|
||||
# Install
|
||||
|
||||
INSTALL(TARGETS spatialqueryplugin
|
||||
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
|
||||
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
|
@ -1,7 +0,0 @@
|
||||
Spatial Query Plugin for QGIS
|
||||
|
||||
Luiz Motta and Diego Moreira 2009
|
||||
|
||||
Plugin for make spatial query with two layers
|
||||
where features of target layer are selected by topological operations
|
||||
with reference layer
|
Before Width: | Height: | Size: 1021 B |
@ -1,57 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsgeometrycoordinatetransform.cpp
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsgeometrycoordinatetransform.h"
|
||||
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
|
||||
QgsGeometryCoordinateTransform::QgsGeometryCoordinateTransform()
|
||||
: mFuncTransform( nullptr )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
|
||||
{
|
||||
} // QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
|
||||
|
||||
void QgsGeometryCoordinateTransform::setCoordinateTransform( QgsVectorLayer *lyrTarget, QgsVectorLayer *lyrReference )
|
||||
{
|
||||
// Transform Forward: Target to Reference
|
||||
QgsCoordinateReferenceSystem srsTarget = lyrTarget->crs();
|
||||
QgsCoordinateReferenceSystem srsReference = lyrReference->crs();
|
||||
|
||||
mCoordTransform = QgsCoordinateTransform( srsTarget, srsReference );
|
||||
|
||||
mFuncTransform = ( srsTarget != srsReference )
|
||||
? &QgsGeometryCoordinateTransform::setGeomTransform
|
||||
: &QgsGeometryCoordinateTransform::setNoneGeomTransform;
|
||||
|
||||
} // void QgsGeometryCoordinateTransform::setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
|
||||
|
||||
void QgsGeometryCoordinateTransform::transform( QgsGeometry *geom )
|
||||
{
|
||||
( this->*mFuncTransform )( geom );
|
||||
|
||||
} // void QgsGeometryCoordinateTransform::transformCoordenate()
|
||||
|
||||
void QgsGeometryCoordinateTransform::setGeomTransform( QgsGeometry *geom )
|
||||
{
|
||||
geom->transform( mCoordTransform );
|
||||
|
||||
} // void QgsGeometryCoordinateTransform::setGeomTransform(QgsGeometry *geom)
|
@ -1,75 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsgeometrycoordinatetransform.h
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef GEOMETRYCOORDINATETRANSFORM_H
|
||||
#define GEOMETRYCOORDINATETRANSFORM_H
|
||||
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
|
||||
/**
|
||||
* \class QgsGeometryCoordinateTransform
|
||||
* \brief Transform the coordinate reference system of the geometry
|
||||
*/
|
||||
class QgsGeometryCoordinateTransform
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Constructor for a Geometry Coordinate Transform.
|
||||
*
|
||||
*/
|
||||
QgsGeometryCoordinateTransform();
|
||||
|
||||
~QgsGeometryCoordinateTransform();
|
||||
|
||||
/**
|
||||
* \brief Sets the coordinate reference system the target and reference layer
|
||||
* \param lyrTarget target layer.
|
||||
* \param lyrReference reference layer.
|
||||
*/
|
||||
void setCoordinateTransform( QgsVectorLayer *lyrTarget, QgsVectorLayer *lyrReference );
|
||||
|
||||
/**
|
||||
* \brief Transform the coordinates reference system of the geometry, if target have the different system of reference
|
||||
* \param geom Geometry
|
||||
*/
|
||||
void transform( QgsGeometry *geom );
|
||||
private:
|
||||
|
||||
/**
|
||||
* \brief Transform the coordinates reference system of the geometry (use by transform)
|
||||
* \param geom Geometry
|
||||
*/
|
||||
void setGeomTransform( QgsGeometry *geom );
|
||||
|
||||
/**
|
||||
* \brief None transform the coordinates reference system of the geometry (use by transform)
|
||||
* \param geom Geometry
|
||||
*/
|
||||
void setNoneGeomTransform( QgsGeometry *geom )
|
||||
{ Q_UNUSED( geom ); }
|
||||
|
||||
QgsCoordinateTransform mCoordTransform;
|
||||
void ( QgsGeometryCoordinateTransform::* mFuncTransform )( QgsGeometry * );
|
||||
|
||||
QgsGeometryCoordinateTransform( const QgsGeometryCoordinateTransform &rh );
|
||||
QgsGeometryCoordinateTransform &operator=( const QgsGeometryCoordinateTransform &rh );
|
||||
};
|
||||
|
||||
#endif // GEOMETRYCOORDINATETRANSFORM_H
|
@ -1,49 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsmngprogressbar.cpp
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsmngprogressbar.h"
|
||||
|
||||
MngProgressBar::MngProgressBar( QProgressBar *pb )
|
||||
{
|
||||
mPb = pb;
|
||||
mPb->reset();
|
||||
} // MngProgressBar::MngProgressBar(QProgressBar *pb)
|
||||
|
||||
void MngProgressBar::init( int minimum, int maximum )
|
||||
{
|
||||
mPb->reset();
|
||||
mPb->setRange( minimum, maximum );
|
||||
|
||||
} // void MngProgressBar::init(int minimum, int maximum)
|
||||
|
||||
void MngProgressBar::setFormat( const QString &format )
|
||||
{
|
||||
// special characters:
|
||||
// %p - is replaced by the percentage completed.
|
||||
// %v - is replaced by the current value.
|
||||
// %m - is replaced by the total number of steps.
|
||||
mPb->setFormat( format );
|
||||
|
||||
} // void MngProgressBar::setFormat(QString format)
|
||||
|
||||
void MngProgressBar::step( int step )
|
||||
{
|
||||
mPb->setValue( step );
|
||||
mPb->repaint();
|
||||
|
||||
} // void MngProgressBar::step()
|
@ -1,63 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsmngprogressbar.h
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSMNGPROGRESSBAR_H
|
||||
#define QGSMNGPROGRESSBAR_H
|
||||
|
||||
#include "qprogressbar.h"
|
||||
|
||||
/**
|
||||
* \class MngProgressBar
|
||||
* \brief This Class manager the progress bar
|
||||
*/
|
||||
class MngProgressBar
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Constructor for a MngProgressBar.
|
||||
* \param pb Pointer to the MngProgressBar object.
|
||||
*/
|
||||
explicit MngProgressBar( QProgressBar *pb );
|
||||
|
||||
~MngProgressBar() { mPb->reset(); }
|
||||
|
||||
/**
|
||||
* \brief Sets the progress bar's minimum and maximum values to minimum and maximum respectively
|
||||
* \param minimum minimum value.
|
||||
* \param maximum maximum value.
|
||||
*/
|
||||
void init( int minimum, int maximum );
|
||||
|
||||
/**
|
||||
* \brief Sets the format the current text.
|
||||
* \param format This property holds the string used to generate the current text.
|
||||
*/
|
||||
void setFormat( const QString &format );
|
||||
|
||||
/**
|
||||
* \brief Sets current value progress bar's
|
||||
* \param step current value
|
||||
*/
|
||||
void step( int step );
|
||||
|
||||
private:
|
||||
QProgressBar *mPb = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSMNGPROGRESSBAR_H
|
@ -1,46 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsreaderfeatures.cpp
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsvectordataprovider.h"
|
||||
|
||||
#include "qgsreaderfeatures.h"
|
||||
|
||||
QgsReaderFeatures::QgsReaderFeatures( QgsVectorLayer *layer, bool useSelection )
|
||||
{
|
||||
mLayer = layer;
|
||||
|
||||
initReader( useSelection );
|
||||
|
||||
} // QgsReaderFeatures::QgsReaderFeatures(QgsVectorLayer *layer, bool useSelection)
|
||||
|
||||
bool QgsReaderFeatures::nextFeature( QgsFeature &feature )
|
||||
{
|
||||
return mFit.nextFeature( feature );
|
||||
} // bool QgsReaderFeatures::nextFeature(QgsFeature & feature)
|
||||
|
||||
void QgsReaderFeatures::initReader( bool useSelection )
|
||||
{
|
||||
if ( useSelection )
|
||||
{
|
||||
mFit = mLayer->getSelectedFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFit = mLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
|
||||
}
|
||||
} // void QgsReaderFeatures::initReader()
|
@ -1,59 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsreaderfeatures.h
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef READERFEATURES_H
|
||||
#define READERFEATURES_H
|
||||
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsfeature.h"
|
||||
#include "qgsfeatureiterator.h"
|
||||
|
||||
/**
|
||||
* \class QgsReaderFeatures
|
||||
* \brief Reader Features
|
||||
*/
|
||||
class QgsReaderFeatures
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Constructor for a Reader Features.
|
||||
* \param layer Pointer to the layer.
|
||||
* \param useSelection Use or not use the features selected
|
||||
*/
|
||||
QgsReaderFeatures( QgsVectorLayer *layer, bool useSelection );
|
||||
|
||||
/**
|
||||
* \brief Next feature
|
||||
* \param feature reference to next Feature.
|
||||
* \returns True if has next feature.
|
||||
*/
|
||||
bool nextFeature( QgsFeature &feature );
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* \brief init Reader
|
||||
* \param useSelection Use or not use the features selected
|
||||
*/
|
||||
void initReader( bool useSelection );
|
||||
|
||||
QgsVectorLayer *mLayer = nullptr;
|
||||
QgsFeatureIterator mFit;
|
||||
};
|
||||
|
||||
#endif // READERFEATURES_H
|
@ -1,88 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsrubberselectid.cpp
|
||||
A plugin that makes spatial queries on vector layers
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsrubberselectid.h"
|
||||
#include "qgsfeatureiterator.h"
|
||||
#include "qgsfeature.h"
|
||||
|
||||
QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas *mapCanvas )
|
||||
{
|
||||
mGeometryType = QgsWkbTypes::LineGeometry;
|
||||
mMapCanvas = mapCanvas;
|
||||
mRubberBand = new QgsRubberBand( mMapCanvas, mGeometryType );
|
||||
mColorRGB[0] = 255;
|
||||
mColorRGB[1] = 0;
|
||||
mColorRGB[2] = 0;
|
||||
mWidth = 2;
|
||||
setStyle();
|
||||
} // QgsRubberSelectId::QgsRubberSelectId( QgsMapCanvas* mapCanvas, bool isPolygon = true )
|
||||
|
||||
QgsRubberSelectId::~QgsRubberSelectId()
|
||||
{
|
||||
reset();
|
||||
delete mRubberBand;
|
||||
|
||||
} // QgsRubberSelectId::~QgsRubberSelectId()
|
||||
|
||||
void QgsRubberSelectId::reset()
|
||||
{
|
||||
mRubberBand->reset( mGeometryType );
|
||||
} // void QgsRubberSelectId::reset()
|
||||
|
||||
void QgsRubberSelectId::setStyle( int colorRed, int colorGreen, int colorBlue, int width )
|
||||
{
|
||||
mColorRGB[0] = colorRed;
|
||||
mColorRGB[1] = colorGreen;
|
||||
mColorRGB[2] = colorBlue;
|
||||
mWidth = width;
|
||||
setStyle();
|
||||
} // void QgsRubberSelectId::setColor(int colorRed, int colorGreen, int colorBlue, float alfa, width)
|
||||
|
||||
void QgsRubberSelectId::addFeature( QgsVectorLayer *lyr, QgsFeatureId fid )
|
||||
{
|
||||
if ( mGeometryType != lyr->geometryType() )
|
||||
{
|
||||
reset();
|
||||
mGeometryType = lyr->geometryType();
|
||||
mRubberBand->reset( lyr->geometryType() );
|
||||
setStyle();
|
||||
}
|
||||
QgsFeature feat;
|
||||
if ( !lyr->getFeatures( QgsFeatureRequest().setFilterFid( fid ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( feat ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( !feat.hasGeometry() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
mRubberBand->setToGeometry( feat.geometry(), lyr );
|
||||
} // void QgsRubberSelectId::addFeature( QgsVectorLayer* mLayer, int Id )
|
||||
|
||||
void QgsRubberSelectId::show()
|
||||
{
|
||||
mRubberBand->show();
|
||||
} // QgsRubberSelectId::show()
|
||||
|
||||
void QgsRubberSelectId::setStyle()
|
||||
{
|
||||
QColor color = QColor( mColorRGB[0], mColorRGB[1], mColorRGB[2], 65 );
|
||||
mRubberBand->setColor( color );
|
||||
mRubberBand->setWidth( mWidth );
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsrubberselectid.h
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.comm
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSRUBBERSELECTID_H
|
||||
#define QGSRUBBERSELECTID_H
|
||||
|
||||
#include "qgsrubberband.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
|
||||
/**
|
||||
* \class QgsRubberSelectId
|
||||
* \brief This Class management the RubberBand for selected ID from query result
|
||||
*/
|
||||
class QgsRubberSelectId
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for a class RubberSelectedId.
|
||||
* \param mapCanvas Pointer to the iface.mapCanvas().
|
||||
*/
|
||||
explicit QgsRubberSelectId( QgsMapCanvas *mapCanvas );
|
||||
|
||||
~QgsRubberSelectId();
|
||||
|
||||
/**
|
||||
* \brief Reset rubber band
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* \brief Set color for rubber band
|
||||
* \param colorRed integer for value red (0 - 255)
|
||||
* \param colorGreen integer for value green (0 - 255)
|
||||
* \param colorBlue integer for value blue (0 - 255)
|
||||
*/
|
||||
void setStyle( int colorRed, int colorGreen, int colorBlue, int width );
|
||||
|
||||
/**
|
||||
* \brief Create rubber band from geometry by feature
|
||||
* \param mLayer pointer to QgsVectorLayer
|
||||
* \param fid integer for ID for feature
|
||||
*/
|
||||
void addFeature( QgsVectorLayer *lyr, QgsFeatureId fid );
|
||||
|
||||
/**
|
||||
* \brief Show rubber band
|
||||
*/
|
||||
void show();
|
||||
private:
|
||||
//! Set Style
|
||||
void setStyle();
|
||||
|
||||
//! RubberBand
|
||||
QgsRubberBand *mRubberBand = nullptr;
|
||||
int mColorRGB[3];
|
||||
int mWidth;
|
||||
QgsWkbTypes::GeometryType mGeometryType;
|
||||
QgsMapCanvas *mMapCanvas = nullptr;
|
||||
|
||||
Q_DISABLE_COPY( QgsRubberSelectId )
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,341 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsspatialquery.cpp
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsfeature.h"
|
||||
#include "qgsgeometrycoordinatetransform.h"
|
||||
#include "qgsgeometryengine.h"
|
||||
#include "qgsspatialquery.h"
|
||||
|
||||
QgsSpatialQuery::QgsSpatialQuery( MngProgressBar *pb )
|
||||
: mPb( pb )
|
||||
, mReaderFeaturesTarget( nullptr )
|
||||
, mLayerTarget( nullptr )
|
||||
, mLayerReference( nullptr )
|
||||
{
|
||||
mUseTargetSelection = mUseReferenceSelection = false;
|
||||
} // QgsSpatialQuery::QgsSpatialQuery(MngProgressBar *pb)
|
||||
|
||||
QgsSpatialQuery::~QgsSpatialQuery()
|
||||
{
|
||||
delete mReaderFeaturesTarget;
|
||||
|
||||
} // QgsSpatialQuery::~QgsSpatialQuery()
|
||||
|
||||
void QgsSpatialQuery::setSelectedFeaturesTarget( bool useSelected )
|
||||
{
|
||||
mUseTargetSelection = useSelected;
|
||||
|
||||
} // void QgsSpatialQuery::setSelectedFeaturesTarget(bool useSelected)
|
||||
|
||||
void QgsSpatialQuery::setSelectedFeaturesReference( bool useSelected )
|
||||
{
|
||||
mUseReferenceSelection = useSelected;
|
||||
|
||||
} // void QgsSpatialQuery::setSelectedFeaturesReference(bool useSelected)
|
||||
|
||||
void QgsSpatialQuery::runQuery( QgsFeatureIds &qsetIndexResult,
|
||||
QgsFeatureIds &qsetIndexInvalidTarget,
|
||||
QgsFeatureIds &qsetIndexInvalidReference,
|
||||
int relation, QgsVectorLayer *lyrTarget, QgsVectorLayer *lyrReference )
|
||||
{
|
||||
setQuery( lyrTarget, lyrReference );
|
||||
|
||||
// Create Spatial index for Reference - Set mIndexReference
|
||||
mPb->setFormat( QObject::tr( "Processing 1/2 - %p%" ) );
|
||||
int totalStep = mUseReferenceSelection
|
||||
? mLayerReference->selectedFeatureCount()
|
||||
: ( int )( mLayerReference->featureCount() );
|
||||
mPb->init( 1, totalStep );
|
||||
setSpatialIndexReference( qsetIndexInvalidReference ); // Need set mLayerReference before
|
||||
|
||||
// Make Query
|
||||
mPb->setFormat( QObject::tr( "Processing 2/2 - %p%" ) );
|
||||
totalStep = mUseTargetSelection
|
||||
? mLayerTarget->selectedFeatureCount()
|
||||
: ( int )( mLayerTarget->featureCount() );
|
||||
mPb->init( 1, totalStep );
|
||||
|
||||
execQuery( qsetIndexResult, qsetIndexInvalidTarget, relation );
|
||||
|
||||
} // QSet<int> QgsSpatialQuery::runQuery( int relation)
|
||||
|
||||
QMap<QString, int> *QgsSpatialQuery::getTypesOperations( QgsVectorLayer *lyrTarget, QgsVectorLayer *lyrReference )
|
||||
{
|
||||
/* 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
|
||||
|
||||
(P)oint, (L)ine and (A)rea
|
||||
Target Geometry(P,L,A) / Reference Geometry (P,L,A)
|
||||
dim -> Dimension of geometry
|
||||
Relations:
|
||||
1) Intersects and Disjoint: All
|
||||
2) Touches: P/L P/A L/L L/A A/A
|
||||
dimReference > dimTarget OR dimReference = dimTarget if dimReference > 0
|
||||
3) Crosses: P/L P/A L/L L/A
|
||||
dimReference > dimTarget OR dimReference = dimTarget if dimReference = 1
|
||||
4) Within: P/L P/A L/A A/A
|
||||
dimReference > dimTarget OR dimReference = dimTarget if dimReference = 2
|
||||
5) Equals: P/P L/L A/A
|
||||
dimReference = dimTarget
|
||||
6) Overlaps: P/P L/L A/A
|
||||
dimReference = dimTarget
|
||||
7) Contains: L/P A/P A/L A/A
|
||||
dimReference < dimTarget OR dimReference = dimTarget if dimReference = 2
|
||||
*/
|
||||
|
||||
QMap<QString, int> *operations = new QMap<QString, int>;
|
||||
operations->insert( QObject::tr( "Intersects" ), Intersects );
|
||||
operations->insert( QObject::tr( "Is disjoint" ), Disjoint );
|
||||
|
||||
short int dimTarget = 0, dimReference = 0;
|
||||
dimTarget = dimensionGeometry( lyrTarget->geometryType() );
|
||||
dimReference = dimensionGeometry( lyrReference->geometryType() );
|
||||
|
||||
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 )
|
||||
{
|
||||
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)
|
||||
|
||||
short int QgsSpatialQuery::dimensionGeometry( QgsWkbTypes::GeometryType geomType )
|
||||
{
|
||||
int dimGeom = 0;
|
||||
switch ( geomType )
|
||||
{
|
||||
case QgsWkbTypes::PointGeometry:
|
||||
dimGeom = 0;
|
||||
break;
|
||||
case QgsWkbTypes::LineGeometry:
|
||||
dimGeom = 1;
|
||||
break;
|
||||
case QgsWkbTypes::PolygonGeometry:
|
||||
dimGeom = 2;
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT( 0 );
|
||||
break;
|
||||
}
|
||||
return dimGeom;
|
||||
|
||||
} // int QgsSpatialQuery::dimensionGeometry(QgsWkbTypes::GeometryType geomType)
|
||||
|
||||
void QgsSpatialQuery::setQuery( QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference )
|
||||
{
|
||||
mLayerTarget = layerTarget;
|
||||
mReaderFeaturesTarget = new QgsReaderFeatures( mLayerTarget, mUseTargetSelection );
|
||||
mLayerReference = layerReference;
|
||||
|
||||
} // void QgsSpatialQuery::setQuery (QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference)
|
||||
|
||||
bool QgsSpatialQuery::hasValidGeometry( QgsFeature &feature )
|
||||
{
|
||||
if ( !feature.isValid() )
|
||||
return false;
|
||||
|
||||
QgsGeometry geom = feature.geometry();
|
||||
|
||||
if ( geom.isNull() || geom.isEmpty() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
} // bool QgsSpatialQuery::hasValidGeometry(QgsFeature &feature)
|
||||
|
||||
void QgsSpatialQuery::setSpatialIndexReference( QgsFeatureIds &qsetIndexInvalidReference )
|
||||
{
|
||||
QgsReaderFeatures *readerFeaturesReference = new QgsReaderFeatures( mLayerReference, mUseReferenceSelection );
|
||||
QgsFeature feature;
|
||||
int step = 1;
|
||||
while ( readerFeaturesReference->nextFeature( feature ) )
|
||||
{
|
||||
mPb->step( step++ );
|
||||
|
||||
if ( !hasValidGeometry( feature ) )
|
||||
{
|
||||
qsetIndexInvalidReference.insert( feature.id() );
|
||||
continue;
|
||||
}
|
||||
|
||||
mIndexReference.insertFeature( feature );
|
||||
}
|
||||
delete readerFeaturesReference;
|
||||
|
||||
} // void QgsSpatialQuery::setSpatialIndexReference()
|
||||
|
||||
void QgsSpatialQuery::execQuery( QgsFeatureIds &qsetIndexResult, QgsFeatureIds &qsetIndexInvalidTarget, int relation )
|
||||
{
|
||||
bool ( QgsGeometryEngine::* operation )( const QgsAbstractGeometry *, QString * ) const;
|
||||
switch ( relation )
|
||||
{
|
||||
case Disjoint:
|
||||
operation = &QgsGeometryEngine::disjoint;
|
||||
break;
|
||||
case Equals:
|
||||
operation = &QgsGeometryEngine::isEqual;
|
||||
break;
|
||||
case Touches:
|
||||
operation = &QgsGeometryEngine::touches;
|
||||
break;
|
||||
case Overlaps:
|
||||
operation = &QgsGeometryEngine::overlaps;
|
||||
break;
|
||||
case Within:
|
||||
operation = &QgsGeometryEngine::within;
|
||||
break;
|
||||
case Contains:
|
||||
operation = &QgsGeometryEngine::contains;
|
||||
break;
|
||||
case Crosses:
|
||||
operation = &QgsGeometryEngine::crosses;
|
||||
break;
|
||||
case Intersects:
|
||||
operation = &QgsGeometryEngine::intersects;
|
||||
break;
|
||||
default:
|
||||
qWarning( "undefined operation" );
|
||||
return;
|
||||
}
|
||||
|
||||
// Transform referencer Target = Reference
|
||||
QgsGeometryCoordinateTransform *coordinateTransform = new QgsGeometryCoordinateTransform();
|
||||
coordinateTransform->setCoordinateTransform( mLayerTarget, mLayerReference );
|
||||
|
||||
// Set function for populate result
|
||||
void ( QgsSpatialQuery::* funcPopulateIndexResult )( QgsFeatureIds &, QgsFeatureId, const QgsGeometry &, bool ( QgsGeometryEngine::* )( const QgsAbstractGeometry *, QString * ) const );
|
||||
funcPopulateIndexResult = ( relation == Disjoint )
|
||||
? &QgsSpatialQuery::populateIndexResultDisjoint
|
||||
: &QgsSpatialQuery::populateIndexResult;
|
||||
|
||||
QgsFeature featureTarget;
|
||||
int step = 1;
|
||||
while ( mReaderFeaturesTarget->nextFeature( featureTarget ) )
|
||||
{
|
||||
mPb->step( step++ );
|
||||
|
||||
if ( !hasValidGeometry( featureTarget ) )
|
||||
{
|
||||
qsetIndexInvalidTarget.insert( featureTarget.id() );
|
||||
continue;
|
||||
}
|
||||
|
||||
QgsGeometry geomTarget = featureTarget.geometry();
|
||||
coordinateTransform->transform( &geomTarget );
|
||||
|
||||
( this->*funcPopulateIndexResult )( qsetIndexResult, featureTarget.id(), geomTarget, operation );
|
||||
}
|
||||
delete coordinateTransform;
|
||||
|
||||
} // QSet<int> QgsSpatialQuery::execQuery( QSet<int> & qsetIndexResult, int relation)
|
||||
|
||||
void QgsSpatialQuery::populateIndexResult(
|
||||
QgsFeatureIds &qsetIndexResult, QgsFeatureId idTarget, const QgsGeometry &geomTarget,
|
||||
bool ( QgsGeometryEngine::* op )( const QgsAbstractGeometry *, QString * ) const )
|
||||
{
|
||||
QgsFeatureIds listIdReference = mIndexReference.intersects( geomTarget.boundingBox() ).toSet();
|
||||
if ( listIdReference.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//prepare geometry
|
||||
QgsGeometryEngine *geomEngine = geomTarget.createGeometryEngine( geomTarget.geometry() );
|
||||
geomEngine->prepareGeometry();
|
||||
|
||||
QgsFeature featureReference;
|
||||
QgsGeometry geomReference;
|
||||
QgsFeatureIterator listIt = mLayerReference->getFeatures( QgsFeatureRequest().setFilterFids( listIdReference ) );
|
||||
|
||||
while ( listIt.nextFeature( featureReference ) )
|
||||
{
|
||||
geomReference = featureReference.geometry();
|
||||
|
||||
if ( ( geomEngine->*op )( geomReference.geometry(), 0 ) )
|
||||
{
|
||||
qsetIndexResult.insert( idTarget );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete geomEngine;
|
||||
} // void QgsSpatialQuery::populateIndexResult(...
|
||||
|
||||
void QgsSpatialQuery::populateIndexResultDisjoint(
|
||||
QgsFeatureIds &qsetIndexResult, QgsFeatureId idTarget, const QgsGeometry &geomTarget,
|
||||
bool ( QgsGeometryEngine::* op )( const QgsAbstractGeometry *, QString * ) const )
|
||||
{
|
||||
QgsFeatureIds listIdReference = mIndexReference.intersects( geomTarget.boundingBox() ).toSet();
|
||||
if ( listIdReference.isEmpty() )
|
||||
{
|
||||
qsetIndexResult.insert( idTarget );
|
||||
return;
|
||||
}
|
||||
|
||||
//prepare geometry
|
||||
QgsGeometryEngine *geomEngine = geomTarget.createGeometryEngine( geomTarget.geometry() );
|
||||
geomEngine->prepareGeometry();
|
||||
|
||||
QgsFeature featureReference;
|
||||
QgsGeometry geomReference;
|
||||
QgsFeatureIterator listIt = mLayerReference->getFeatures( QgsFeatureRequest().setFilterFids( listIdReference ) );
|
||||
|
||||
bool addIndex = true;
|
||||
while ( listIt.nextFeature( featureReference ) )
|
||||
{
|
||||
geomReference = featureReference.geometry();
|
||||
if ( ( geomEngine->*op )( geomReference.geometry(), 0 ) )
|
||||
{
|
||||
addIndex = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( addIndex )
|
||||
{
|
||||
qsetIndexResult.insert( idTarget );
|
||||
}
|
||||
delete geomEngine;
|
||||
} // void QgsSpatialQuery::populateIndexResultDisjoint( ...
|
||||
|
@ -1,165 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsspatialquery.h
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef SPATIALQUERY_H
|
||||
#define SPATIALQUERY_H
|
||||
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsspatialindex.h"
|
||||
|
||||
#include "qgsmngprogressbar.h"
|
||||
#include "qgsreaderfeatures.h"
|
||||
|
||||
class QgsGeometryEngine;
|
||||
|
||||
/**
|
||||
* \brief Enum with the topologic relations
|
||||
* \enum Topologic Relations
|
||||
*
|
||||
*/
|
||||
enum Topologic_Relation
|
||||
{
|
||||
Intersects,
|
||||
Disjoint,
|
||||
Touches,
|
||||
Crosses,
|
||||
Within,
|
||||
Equals,
|
||||
Overlaps,
|
||||
Contains
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \class QgsSpatialQuery
|
||||
* \brief Spatial Query core
|
||||
*
|
||||
*/
|
||||
class QgsSpatialQuery
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Constructor for a Spatial query.
|
||||
* \param pb Pointer to the MngProgressBar object.
|
||||
*/
|
||||
explicit QgsSpatialQuery( MngProgressBar *pb );
|
||||
|
||||
~QgsSpatialQuery();
|
||||
|
||||
QgsSpatialQuery( const QgsSpatialQuery &rh ) = delete;
|
||||
QgsSpatialQuery &operator=( const QgsSpatialQuery &rh ) = delete;
|
||||
|
||||
/**
|
||||
* \brief Sets if using selected features in Target layer
|
||||
* \param useSelected true if use selected.
|
||||
*/
|
||||
void setSelectedFeaturesTarget( bool useSelected );
|
||||
|
||||
/**
|
||||
* \brief Sets if using selected features in Reference layer
|
||||
* \param useSelected true if use selected.
|
||||
*/
|
||||
void setSelectedFeaturesReference( bool useSelected );
|
||||
|
||||
/**
|
||||
* \brief Execute the query
|
||||
* \param qsetIndexResult Reference to QSet contains the result query
|
||||
* \param relation Enum Topologic Relation
|
||||
* \param lyrTarget Pointer to Target Layer
|
||||
* \param lyrReference Pointer to Reference Layer
|
||||
*/
|
||||
void runQuery( QgsFeatureIds &qsetIndexResult,
|
||||
QgsFeatureIds &qsetIndexInvalidTarget,
|
||||
QgsFeatureIds &qsetIndexInvalidReference,
|
||||
int relation, QgsVectorLayer *lyrTarget, QgsVectorLayer *lyrReference );
|
||||
|
||||
/**
|
||||
* \brief Gets the possible topologic relations
|
||||
* \param lyrTarget Pointer to Target Layer
|
||||
* \param lyrReference Pointer to Reference Layer
|
||||
* \returns QMap<QString, int> Nome inteligível and Topologic Relation
|
||||
*/
|
||||
static QMap<QString, int> *getTypesOperations( QgsVectorLayer *lyrTarget, QgsVectorLayer *lyrReference );
|
||||
|
||||
/**
|
||||
* \brief Gets the topologic dimension
|
||||
* \param geomType Geometry Type
|
||||
* \returns short int Topologic Dimension
|
||||
*/
|
||||
static short int dimensionGeometry( QgsWkbTypes::GeometryType geomType );
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* \brief Sets the target layer and reference layer
|
||||
* \param layerTarget Target Layer
|
||||
* \param layerReference Reference Layer
|
||||
*/
|
||||
void setQuery( QgsVectorLayer *layerTarget, QgsVectorLayer *layerReference );
|
||||
|
||||
/**
|
||||
* \brief Verify has valid Geometry in feature
|
||||
* \param QgsFeature Feature
|
||||
*/
|
||||
bool hasValidGeometry( QgsFeature &feature );
|
||||
|
||||
/**
|
||||
* \brief Build the Spatial Index
|
||||
*/
|
||||
void setSpatialIndexReference( QgsFeatureIds &qsetIndexInvalidReference );
|
||||
|
||||
/**
|
||||
* \brief Execute query
|
||||
* \param qsetIndexResult Reference to QSet contains the result query
|
||||
* \param relation Enum Topologic Relation
|
||||
*/
|
||||
void execQuery( QgsFeatureIds &qsetIndexResult, QgsFeatureIds &qsetIndexInvalidTarget, int relation );
|
||||
|
||||
/**
|
||||
* \brief Populate index Result
|
||||
* \param qsetIndexResult Reference to QSet contains the result query
|
||||
* \param idTarget Id of the feature Target
|
||||
* \param geomTarget Geometry the feature Target
|
||||
* \param operation Pointer to function of GEOS operation
|
||||
*/
|
||||
void populateIndexResult( QgsFeatureIds &qsetIndexResult, QgsFeatureId idTarget, const QgsGeometry &geomTarget,
|
||||
bool ( QgsGeometryEngine::*operation )( const QgsAbstractGeometry *, QString * ) const );
|
||||
|
||||
/**
|
||||
* \brief Populate index Result Disjoint
|
||||
* \param qsetIndexResult Reference to QSet contains the result query
|
||||
* \param idTarget Id of the feature Target
|
||||
* \param geomTarget Geometry the feature Target
|
||||
* \param operation Pointer to function of GEOS operation
|
||||
*/
|
||||
void populateIndexResultDisjoint( QgsFeatureIds &qsetIndexResult, QgsFeatureId idTarget, const QgsGeometry &geomTarget,
|
||||
bool ( QgsGeometryEngine::*operation )( const QgsAbstractGeometry *, QString * ) const );
|
||||
|
||||
MngProgressBar *mPb = nullptr;
|
||||
bool mUseReferenceSelection;
|
||||
bool mUseTargetSelection;
|
||||
|
||||
QgsReaderFeatures *mReaderFeaturesTarget = nullptr;
|
||||
QgsVectorLayer *mLayerTarget = nullptr;
|
||||
QgsVectorLayer *mLayerReference = nullptr;
|
||||
QgsSpatialIndex mIndexReference;
|
||||
|
||||
};
|
||||
|
||||
#endif // SPATIALQUERY_H
|
||||
|
@ -1,165 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsspatialquerydialog.h
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SPATIALQUERYDIALOG_H
|
||||
#define SPATIALQUERYDIALOG_H
|
||||
|
||||
#include "qgsrubberselectid.h"
|
||||
|
||||
#include "ui_qgsspatialquerydialogbase.h"
|
||||
#include "qgisinterface.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgshelp.h"
|
||||
|
||||
/**
|
||||
* \class QgsSpatialQueryDialog
|
||||
* \brief Spatial Query dialog
|
||||
*
|
||||
*/
|
||||
class QgsSpatialQueryDialog : public QDialog, private Ui::QgsSpatialQueryDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for a dialog. The QgisInterface pointer is passed by
|
||||
* QGIS when it attempts to instantiate the plugin.
|
||||
* \param iface Pointer to the QgisInterface object.
|
||||
*/
|
||||
QgsSpatialQueryDialog( QWidget *parent = nullptr, QgisInterface *iface = nullptr );
|
||||
|
||||
~QgsSpatialQueryDialog();
|
||||
|
||||
//! Verify is possible execute the query
|
||||
static bool hasPossibleQuery( QString &msg );
|
||||
|
||||
private slots:
|
||||
//! Slots for signs of Dialog
|
||||
void on_bbMain_clicked( QAbstractButton *button );
|
||||
void on_pbCreateLayerItems_clicked();
|
||||
void on_pbCreateLayerSelected_clicked();
|
||||
void on_cbTargetLayer_currentIndexChanged( int index );
|
||||
void on_cbReferenceLayer_currentIndexChanged( int index );
|
||||
void on_cbTypeItems_currentIndexChanged( int index );
|
||||
void on_cbResultFor_currentIndexChanged();
|
||||
void on_cbOperation_currentIndexChanged();
|
||||
void on_lwFeatures_currentItemChanged( QListWidgetItem *item );
|
||||
void on_ckbUsingSelectedTarget_toggled();
|
||||
void on_ckbLogProcessing_clicked( bool checked );
|
||||
void on_ckbZoomItem_clicked( bool checked );
|
||||
void showHelp();
|
||||
|
||||
//! Slots for signs of QGIS
|
||||
void signal_qgis_layerWasAdded( QgsMapLayer *mapLayer );
|
||||
void signal_qgis_layerWillBeRemoved( const QString &idLayer );
|
||||
|
||||
//! Slots for signs of Layers (Target or Reference)
|
||||
void signal_layerTarget_selectionFeaturesChanged();
|
||||
void signal_layerReference_selectionFeaturesChanged();
|
||||
|
||||
private:
|
||||
//! Enum Type of items
|
||||
enum TypeItems { ItemsResult, ItemsInvalidTarget, ItemsInvalidReference };
|
||||
//! Enum Type Result for
|
||||
enum TypeResultFor { SelectedNew, SelectedAdd, SelectedRemove };
|
||||
//! Enum Type of verify subset
|
||||
enum TypeVerifyCreateSubset { VerifyOk, VerifyTry, VerifyImpossible };
|
||||
|
||||
//! Initialize the Gui
|
||||
void initGui();
|
||||
//! Apply Button
|
||||
void apply();
|
||||
//! Visible result
|
||||
void visibleResult( bool show );
|
||||
//! Set Layer (Target or Reference)
|
||||
void setLayer( bool isTarget, int index );
|
||||
//! Evaluate status of selected features from layer (Target or Reference)
|
||||
void evaluateCheckBoxLayer( bool isTarget );
|
||||
//! Run Query
|
||||
void runQuery();
|
||||
//! Show result of query
|
||||
void showResultQuery( QDateTime *datetimeStart, QDateTime *datetimeEnd );
|
||||
//! Get string subset with selected FID
|
||||
QString getSubsetFIDs( const QgsFeatureIds *fids, const QString &fieldFID );
|
||||
//! Verify can create layer subset
|
||||
TypeVerifyCreateSubset verifyCreateSubset( QString &msg, QString &fieldFID );
|
||||
//! Add layer target with subset
|
||||
bool addLayerSubset( const QString &name, const QString &subset );
|
||||
//! Get Description Layer to show result
|
||||
QString getDescriptionLayerShow( bool isTarget );
|
||||
//! Get Description Layer to show result
|
||||
QString getDescriptionInvalidFeaturesShow( bool isTarget );
|
||||
//! Connect all slots
|
||||
void connectAll();
|
||||
//! Disconnect all slots
|
||||
void disconnectAll();
|
||||
//! reject - override
|
||||
void reject() override;
|
||||
//! Get Vector layer from combobox
|
||||
QgsVectorLayer *getLayerFromCombobox( bool isTarget, int index );
|
||||
//! Get Icon for vector layer
|
||||
QIcon getIconTypeGeometry( QgsWkbTypes::GeometryType geomType );
|
||||
//! Add layer in combobox (text, data and tooltips)
|
||||
void addCbLayer( bool isTarget, QgsVectorLayer *lyr );
|
||||
//! Find Layer in combobox
|
||||
int getCbIndexLayer( bool isTarget, QgsVectorLayer *lyr );
|
||||
//! Remove layer in combobox and setting GUI
|
||||
void removeLayer( bool isTarget, QgsVectorLayer *lyr );
|
||||
//! Populate cbResultFor
|
||||
void populateCbResulFor();
|
||||
//! Populate cbTypeItems
|
||||
void populateTypeItems();
|
||||
//! Populates cbTargetLayer with all layers
|
||||
void populateCbTargetLayer();
|
||||
//! Populates cbReferenceLayer with all layers except the current target layer
|
||||
void populateCbReferenceLayer();
|
||||
//! Populates operationComboBox with the topological operations
|
||||
void populateCbOperation();
|
||||
//! Set selected GUI (lbStatusSelected and pbCreateLayerSelected)
|
||||
void setSelectedGui();
|
||||
//! Make action when change item in List feature
|
||||
void changeLwFeature( QgsVectorLayer *lyr, QgsFeatureId fid );
|
||||
//! Zoom mapcanvas to current feature in listbox target
|
||||
void zoomFeature( QgsVectorLayer *lyr, QgsFeatureId fid );
|
||||
//! Show rubber from feature
|
||||
void showRubberFeature( QgsVectorLayer *lyr, QgsFeatureId id );
|
||||
|
||||
//! Pointer to Interface QGIS
|
||||
QgisInterface *mIface = nullptr;
|
||||
//! Target Layer, the query will be performed on it
|
||||
QgsVectorLayer *mLayerTarget = nullptr;
|
||||
//! Reference Layer, the query will be based on it
|
||||
QgsVectorLayer *mLayerReference = nullptr;
|
||||
//! Stores ID's from spatial query
|
||||
QgsFeatureIds mFeatureResult;
|
||||
//! Stores ID's invalid of target layer
|
||||
QgsFeatureIds mFeatureInvalidTarget;
|
||||
//! Stores ID's invalid of reference layer
|
||||
QgsFeatureIds mFeatureInvalidReference;
|
||||
//! Map for Id name of vector layers (use in signal_qgis_layerWillBeRemoved)
|
||||
QMap<QString, QgsVectorLayer *> mMapIdVectorLayers;
|
||||
//! Rubber band for features result
|
||||
QgsRubberSelectId *mRubberSelectId = nullptr;
|
||||
//! Text for source selected
|
||||
QString mSourceSelected;
|
||||
bool mIsSelectedOperator;
|
||||
|
||||
void MsgDEBUG( QString sMSg );
|
||||
};
|
||||
|
||||
#endif // SPATIALQUERYDIALOG_H
|
@ -1,7 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/icons">
|
||||
<file>spatialquery.png</file>
|
||||
<file>selectcreatelayer.png</file>
|
||||
<file>itemscreatelayer.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,432 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QgsSpatialQueryDialogBase</class>
|
||||
<widget class="QDialog" name="QgsSpatialQueryDialogBase">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>407</width>
|
||||
<height>510</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Spatial Query</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedKingdom"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="lyOperatorResult">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="lytOperator">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbTarget">
|
||||
<property name="toolTip">
|
||||
<string>Layer on which the topological operation will select geometries</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Select source features from</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbTargetLayer">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select the target layer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckbUsingSelectedTarget">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">When checked the operation will only consider selected geometries of the target layer</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Selected feature(s) only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>ckbUsingSelectedTarget</zorder>
|
||||
<zorder>cbTargetLayer</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbOperation">
|
||||
<property name="text">
|
||||
<string>Where the feature</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbOperation">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select the topological operation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbReference">
|
||||
<property name="toolTip">
|
||||
<string>Layer whose geometries will be used as reference by the topological operation</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Reference features of </string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbReferenceLayer">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select the reference layer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckbUsingSelectedReference">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">When checked the operation will be only consider selected geometries of the reference layer</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Selected feature(s) only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbResultFor">
|
||||
<property name="text">
|
||||
<string>And use the result to</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbResultFor"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spResult">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>146</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbSelected">
|
||||
<property name="title">
|
||||
<string>Selected features</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbStatusSelected">
|
||||
<property name="toolTip">
|
||||
<string>Number of selected features in map</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbCreateLayerSelected">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>44</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>44</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create layer with selected</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qgsspatialquerydialogbase.qrc">
|
||||
<normaloff>:/icons/selectcreatelayer.png</normaloff>:/icons/selectcreatelayer.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="leSpace">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="lyResult">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbResultQuery">
|
||||
<property name="title">
|
||||
<string>Result feature ID's</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbTypeItems">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="lwFeatures">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select one FID to identify geometry of feature</string>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Fixed</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="lytItems">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbStatusItems">
|
||||
<property name="toolTip">
|
||||
<string>Number of selected features in map</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">items</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbCreateLayerItems">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>35</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>35</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Create layer with list of items</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qgsspatialquerydialogbase.qrc">
|
||||
<normaloff>:/icons/itemscreatelayer.png</normaloff>:/icons/itemscreatelayer.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckbZoomItem">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom to item</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="lyLogMessage">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckbLogProcessing">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Check to show log processing of query</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Log messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="teStatus">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="pgbStatus">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="textVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bbMain">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Run query or close the window</string>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Help</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>cbTargetLayer</tabstop>
|
||||
<tabstop>ckbUsingSelectedTarget</tabstop>
|
||||
<tabstop>cbOperation</tabstop>
|
||||
<tabstop>cbReferenceLayer</tabstop>
|
||||
<tabstop>ckbUsingSelectedReference</tabstop>
|
||||
<tabstop>cbResultFor</tabstop>
|
||||
<tabstop>pbCreateLayerSelected</tabstop>
|
||||
<tabstop>cbTypeItems</tabstop>
|
||||
<tabstop>lwFeatures</tabstop>
|
||||
<tabstop>pbCreateLayerItems</tabstop>
|
||||
<tabstop>ckbZoomItem</tabstop>
|
||||
<tabstop>ckbLogProcessing</tabstop>
|
||||
<tabstop>teStatus</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="qgsspatialquerydialogbase.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,214 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsspatialqueryplugin.cpp
|
||||
A plugin that makes spatial queries on vector layers
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.com
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
//
|
||||
// Required qgis includes
|
||||
//
|
||||
#include "qgisinterface.h"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsmessagebar.h"
|
||||
|
||||
//
|
||||
// Required plugin includes
|
||||
//
|
||||
#include "qgsspatialqueryplugin.h"
|
||||
#include "qgsspatialquerydialog.h"
|
||||
|
||||
//
|
||||
// Required Qt includes
|
||||
//
|
||||
#include <QAction>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
static const QString name_ = QObject::tr( "Spatial Query Plugin" );
|
||||
static const QString description_ = QObject::tr( "A plugin that makes spatial queries on vector layers" );
|
||||
static const QString category_ = QObject::tr( "Vector" );
|
||||
static const QString version_ = QObject::tr( "Version 0.1" );
|
||||
static const QgisPlugin::PluginType type_ = QgisPlugin::UI;
|
||||
static const QString icon_ = QStringLiteral( ":/icons/spatialquery.png" );
|
||||
|
||||
/**
|
||||
* Constructor for the plugin. The plugin is passed a pointer to the main app
|
||||
* and an interface object that provides access to exposed functions in QGIS.
|
||||
* @param qgis Pointer to the QGIS main window
|
||||
* @parma mIface Pointer to the QGIS interface object
|
||||
*/
|
||||
QgsSpatialQueryPlugin::QgsSpatialQueryPlugin( QgisInterface *iface )
|
||||
: QgisPlugin( name_, description_, category_, version_, type_ )
|
||||
, mDialog( nullptr )
|
||||
, mIface( iface )
|
||||
, mSpatialQueryAction( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
QgsSpatialQueryPlugin::~QgsSpatialQueryPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the GUI interface for the plugin
|
||||
*/
|
||||
void QgsSpatialQueryPlugin::initGui()
|
||||
{
|
||||
delete mSpatialQueryAction;
|
||||
|
||||
// Create the action for tool
|
||||
mSpatialQueryAction = new QAction( QIcon(), tr( "&Spatial Query" ), this );
|
||||
mSpatialQueryAction->setObjectName( QStringLiteral( "mSpatialQueryAction" ) );
|
||||
|
||||
// Connect the action to the spatialQuery slot
|
||||
connect( mSpatialQueryAction, &QAction::triggered, this, &QgsSpatialQueryPlugin::run );
|
||||
|
||||
setCurrentTheme( QLatin1String( "" ) );
|
||||
// this is called when the icon theme is changed
|
||||
connect( mIface, &QgisInterface::currentThemeChanged, this, &QgsSpatialQueryPlugin::setCurrentTheme );
|
||||
|
||||
// Add the icon to the toolbar and to the plugin menu
|
||||
mIface->addVectorToolBarIcon( mSpatialQueryAction );
|
||||
mIface->addPluginToVectorMenu( tr( "&Spatial Query" ), mSpatialQueryAction );
|
||||
|
||||
}
|
||||
|
||||
//Unload the plugin by cleaning up the GUI
|
||||
void QgsSpatialQueryPlugin::unload()
|
||||
{
|
||||
// remove the GUI
|
||||
mIface->removeVectorToolBarIcon( mSpatialQueryAction );
|
||||
mIface->removePluginVectorMenu( tr( "&Spatial Query" ), mSpatialQueryAction );
|
||||
|
||||
delete mSpatialQueryAction;
|
||||
mSpatialQueryAction = nullptr;
|
||||
delete mDialog;
|
||||
mDialog = nullptr;
|
||||
}
|
||||
|
||||
void QgsSpatialQueryPlugin::run()
|
||||
{
|
||||
if ( !mDialog )
|
||||
{
|
||||
QString msg;
|
||||
if ( ! QgsSpatialQueryDialog::hasPossibleQuery( msg ) )
|
||||
{
|
||||
mIface->messageBar()->pushMessage( tr( "Query not executed" ), msg, QgsMessageBar::INFO, mIface->messageTimeout() );
|
||||
return;
|
||||
}
|
||||
mDialog = new QgsSpatialQueryDialog( mIface->mainWindow(), mIface );
|
||||
mDialog->setModal( false );
|
||||
mDialog->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !mDialog->isVisible() )
|
||||
{
|
||||
delete mDialog;
|
||||
mDialog = nullptr;
|
||||
run();
|
||||
}
|
||||
else
|
||||
{
|
||||
mDialog->activateWindow();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! Set icons to the current theme
|
||||
void QgsSpatialQueryPlugin::setCurrentTheme( const QString & )
|
||||
{
|
||||
if ( mSpatialQueryAction )
|
||||
mSpatialQueryAction->setIcon( getThemeIcon( QStringLiteral( "/spatialquery.png" ) ) );
|
||||
}
|
||||
|
||||
QIcon QgsSpatialQueryPlugin::getThemeIcon( const QString &name )
|
||||
{
|
||||
if ( QFile::exists( QgsApplication::activeThemePath() + "/plugins" + name ) )
|
||||
{
|
||||
return QIcon( QgsApplication::activeThemePath() + "/plugins" + name );
|
||||
}
|
||||
else if ( QFile::exists( QgsApplication::defaultThemePath() + "/plugins" + name ) )
|
||||
{
|
||||
return QIcon( QgsApplication::defaultThemePath() + "/plugins" + name );
|
||||
}
|
||||
else
|
||||
{
|
||||
return QIcon( ":/icons" + name );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsSpatialQueryPlugin::MsgDEBUG( const QString &sMSg )
|
||||
{
|
||||
QMessageBox::warning( nullptr, tr( "DEBUG" ), sMSg, QMessageBox::Ok );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Required extern functions needed for every plugin
|
||||
* These functions can be called prior to creating an instance
|
||||
* of the plugin class
|
||||
*/
|
||||
// Class factory to return a new instance of the plugin class
|
||||
QGISEXTERN QgisPlugin *classFactory( QgisInterface *iface )
|
||||
{
|
||||
return new QgsSpatialQueryPlugin( iface );
|
||||
}
|
||||
// Return the name of the plugin
|
||||
|
||||
QGISEXTERN QString name()
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
// Return the description
|
||||
QGISEXTERN QString description()
|
||||
{
|
||||
return description_;
|
||||
}
|
||||
|
||||
|
||||
// Return the category
|
||||
QGISEXTERN QString category()
|
||||
{
|
||||
return category_;
|
||||
}
|
||||
|
||||
// Return the type (either UI or MapLayer plugin)
|
||||
QGISEXTERN int type()
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
// Return the version
|
||||
QGISEXTERN QString version()
|
||||
{
|
||||
return version_;
|
||||
}
|
||||
|
||||
QGISEXTERN QString icon()
|
||||
{
|
||||
return icon_;
|
||||
}
|
||||
|
||||
// Delete ourself
|
||||
QGISEXTERN void unload( QgisPlugin *spatialQueryPluginPointer )
|
||||
{
|
||||
delete spatialQueryPluginPointer;
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsspatialqueryplugin.h
|
||||
A plugin that makes spatial queries on vector layers
|
||||
-------------------
|
||||
begin : Dec 29, 2009
|
||||
copyright : (C) 2009 by Diego Moreira And Luiz Motta
|
||||
email : moreira.geo at gmail.com And motta.luiz at gmail.comm
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SPATIALQUERYPLUGIN_H
|
||||
#define SPATIALQUERYPLUGIN_H
|
||||
|
||||
//
|
||||
//QGIS Includes
|
||||
//
|
||||
#include "qgisplugin.h"
|
||||
|
||||
class QgisInterface;
|
||||
class QgsSpatialQueryDialog;
|
||||
|
||||
//
|
||||
//QT Includes
|
||||
//
|
||||
#include <QIcon>
|
||||
#include <QObject>
|
||||
class QAction;
|
||||
|
||||
|
||||
/**
|
||||
* \class QgsSpatialQueryPlugin
|
||||
* \brief Spatial Query plugin for QGIS
|
||||
*
|
||||
*/
|
||||
class QgsSpatialQueryPlugin: public QObject, public QgisPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Constructor for a plugin. The QgisInterface pointer is passed by
|
||||
* QGIS when it attempts to instantiate the plugin.
|
||||
* \param iface Pointer to the QgisInterface object.
|
||||
*/
|
||||
explicit QgsSpatialQueryPlugin( QgisInterface *iface );
|
||||
|
||||
~QgsSpatialQueryPlugin();
|
||||
|
||||
public slots:
|
||||
//! init the gui
|
||||
void initGui() override;
|
||||
//! unload the plugin
|
||||
void unload() override;
|
||||
//! Show the dialog box
|
||||
void run();
|
||||
//! update the plugins theme when the app tells us its theme is changed
|
||||
void setCurrentTheme( const QString &themeName );
|
||||
QIcon getThemeIcon( const QString &themeName );
|
||||
|
||||
private:
|
||||
|
||||
QgsSpatialQueryDialog *mDialog = nullptr;
|
||||
//! Pointer to the QgisInterface object
|
||||
QgisInterface *mIface = nullptr;
|
||||
//! Pointer to the QAction used in the menu and on the toolbar
|
||||
QAction *mSpatialQueryAction = nullptr;
|
||||
|
||||
|
||||
void MsgDEBUG( const QString &sMSg );
|
||||
|
||||
};
|
||||
#endif
|
||||
|
Before Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 583 B |
Before Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 585 B |
Before Width: | Height: | Size: 563 B |
Before Width: | Height: | Size: 1.4 KiB |