Skip to content

Commit 349b1ec

Browse files
author
timlinux
committedApr 23, 2010
[FEATURE] Applied patch #2634 from Luiz Motta which provide a new c++ plugin for carrying out spatial selections
git-svn-id: http://svn.osgeo.org/qgis/trunk@13356 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9bc24cb commit 349b1ec

22 files changed

+2887
-0
lines changed
 

‎src/plugins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ SUBDIRS (copyright_label
1313
evis
1414
labeling
1515
point_displacement_renderer
16+
spatialquery
1617
)
1718

1819
IF (POSTGRES_FOUND)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
########################################################
2+
# Files
3+
4+
SET (SPATIALQUERY_SRCS
5+
qgsspatialqueryplugin.cpp
6+
qgsspatialquerydialog.cpp
7+
qgsspatialquery.cpp
8+
qgsreaderfeatures.cpp
9+
qgsrubberselectid.cpp
10+
qgsgeometrycoordinatetransform.cpp
11+
qgsmngprogressbar.cpp
12+
)
13+
14+
SET (SPATIALQUERY_MOC_HDRS
15+
qgsspatialqueryplugin.h
16+
qgsspatialquerydialog.h
17+
qgsspatialquery.h
18+
qgsreaderfeatures.h
19+
qgsrubberselectid.h
20+
qgsgeometrycoordinatetransform.h
21+
qgsmngprogressbar.h
22+
)
23+
24+
SET( SPATIALQUERY_UIS qgsspatialquerydialogbase.ui)
25+
26+
SET (SPATIALQUERY_RCCS qgsspatialquerydialogbase.qrc)
27+
28+
########################################################
29+
# Build
30+
31+
QT4_WRAP_UI (SPATIALQUERY_UIS_H ${SPATIALQUERY_UIS})
32+
33+
QT4_WRAP_CPP (SPATIALQUERY_MOC_SRCS ${SPATIALQUERY_MOC_HDRS})
34+
35+
QT4_ADD_RESOURCES (SPATIALQUERY_RCC_SRCS ${SPATIALQUERY_RCCS})
36+
37+
ADD_LIBRARY (spatialqueryplugin MODULE ${SPATIALQUERY_SRCS} ${SPATIALQUERY_MOC_SRCS} ${SPATIALQUERY_RCC_SRCS} ${SPATIALQUERY_UIS_H})
38+
39+
INCLUDE_DIRECTORIES(
40+
${CMAKE_CURRENT_BINARY_DIR}
41+
${CMAKE_CURRENT_BINARY_DIR}/../../ui/
42+
../../core
43+
../../core/spatialindex
44+
../../core/raster
45+
../../core/renderer
46+
../../core/symbology
47+
../../gui
48+
..
49+
)
50+
51+
TARGET_LINK_LIBRARIES(spatialqueryplugin
52+
qgis_core
53+
qgis_gui
54+
)
55+
56+
57+
########################################################
58+
# Install
59+
60+
INSTALL(TARGETS spatialqueryplugin
61+
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
62+
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

‎src/plugins/spatialquery/README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Spatial Query Plugin for Quantum GIS
2+
3+
Luiz Motta and Diego Moreira 2009
4+
5+
Plugin for make spatial query with two layers
6+
where features of target layer are selected by topological operations
7+
with reference layer
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/***************************************************************************
2+
qgsgeometrycoordinatetransform.cpp
3+
-------------------
4+
begin : Dec 29, 2009
5+
copyright : (C) 2009 by Diego Moreira And Luiz Motta
6+
email : moreira.geo at gmail.com And motta.luiz at gmail.com
7+
8+
***************************************************************************/
9+
10+
/***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************/
18+
/* $Id: $ */
19+
20+
#include "qgsgeometrycoordinatetransform.h"
21+
22+
#include "qgscoordinatereferencesystem.h"
23+
24+
QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
25+
{
26+
delete mCoordTransform;
27+
28+
} // QgsGeometryCoordinateTransform::~QgsGeometryCoordinateTransform()
29+
30+
void QgsGeometryCoordinateTransform::setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
31+
{
32+
// Transform Forward: Target to Reference
33+
// * Use srs() to use old versions QGis - will be deprecited in 2.0 (after use crs())
34+
QgsCoordinateReferenceSystem srsTarget = lyrTarget->srs();
35+
QgsCoordinateReferenceSystem srsReference = lyrReference->srs();
36+
37+
mCoordTransform = new QgsCoordinateTransform(srsTarget, srsReference);
38+
39+
mFuncTransform = ( srsTarget != srsReference)
40+
? &QgsGeometryCoordinateTransform::setGeomTransform
41+
: &QgsGeometryCoordinateTransform::setNoneGeomTransform;
42+
43+
} // void QgsGeometryCoordinateTransform::setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference)
44+
45+
void QgsGeometryCoordinateTransform::transform(QgsGeometry *geom)
46+
{
47+
(this->*mFuncTransform)(geom);
48+
49+
} // void QgsGeometryCoordinateTransform::transformCoordenate()
50+
51+
void QgsGeometryCoordinateTransform::setGeomTransform(QgsGeometry *geom)
52+
{
53+
geom->transform(*mCoordTransform);
54+
55+
} // void QgsGeometryCoordinateTransform::setGeomTransform(QgsGeometry *geom)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/***************************************************************************
2+
qgsgeometrycoordinatetransform.h
3+
-------------------
4+
begin : Dec 29, 2009
5+
copyright : (C) 2009 by Diego Moreira And Luiz Motta
6+
email : moreira.geo at gmail.com And motta.luiz at gmail.com
7+
8+
***************************************************************************/
9+
10+
/***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************/
18+
/* $Id: $ */
19+
#ifndef GEOMETRYCOORDINATETRANSFORM_H
20+
#define GEOMETRYCOORDINATETRANSFORM_H
21+
22+
#include "qgsgeometry.h"
23+
#include "qgsvectorlayer.h"
24+
#include "qgscoordinatetransform.h"
25+
26+
/**
27+
* \class QgsGeometryCoordinateTransform
28+
* \brief Transform the coordinate reference system of the geometry
29+
*/
30+
class QgsGeometryCoordinateTransform
31+
{
32+
public:
33+
/**
34+
* \brief Constructor for a Geometry Coordinate Transform.
35+
*
36+
*/
37+
QgsGeometryCoordinateTransform () {};
38+
39+
/**
40+
* \brief Destructor
41+
*/
42+
~QgsGeometryCoordinateTransform ();
43+
44+
/**
45+
* \brief Sets the coordinate reference system the target and reference layer
46+
* \param lyrTarget target layer.
47+
* \param lyrReference reference layer.
48+
*/
49+
void setCoordinateTransform(QgsVectorLayer* lyrTarget, QgsVectorLayer* lyrReference);
50+
51+
/**
52+
* \brief Transform the coordinates reference system of the geometry, if target have the different system of reference
53+
* \param geom Geometry
54+
*/
55+
void transform(QgsGeometry *geom);
56+
private:
57+
/**
58+
* \brief Transform the coordinates reference system of the geometry (use by transform)
59+
* \param geom Geometry
60+
*/
61+
void setGeomTransform(QgsGeometry *geom);
62+
/**
63+
* \brief None transform the coordinates reference system of the geometry (use by transform)
64+
* \param geom Geometry
65+
*/
66+
void setNoneGeomTransform(QgsGeometry *geom) {};
67+
68+
QgsCoordinateTransform * mCoordTransform;
69+
void (QgsGeometryCoordinateTransform::* mFuncTransform)(QgsGeometry *);
70+
};
71+
72+
#endif // GEOMETRYCOORDINATETRANSFORM_H
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/***************************************************************************
2+
qgsmngprogressbar.cpp
3+
-------------------
4+
begin : Dec 29, 2009
5+
copyright : (C) 2009 by Diego Moreira And Luiz Motta
6+
email : moreira.geo at gmail.com And motta.luiz at gmail.com
7+
8+
***************************************************************************/
9+
10+
/***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************/
18+
/* $Id: $ */
19+
20+
#include "qgsmngprogressbar.h"
21+
22+
MngProgressBar::MngProgressBar(QProgressBar *pb)
23+
{
24+
mPb = pb;
25+
mPb->reset();
26+
} // MngProgressBar::MngProgressBar(QProgressBar *pb)
27+
28+
void MngProgressBar::init(int minimum, int maximum)
29+
{
30+
mPb->reset();
31+
mPb->setRange(minimum, maximum);
32+
33+
} // void MngProgressBar::init(int minimum, int maximum)
34+
35+
void MngProgressBar::setFormat(QString format)
36+
{
37+
// special caracters:
38+
// %p - is replaced by the percentage completed.
39+
// %v - is replaced by the current value.
40+
// %m - is replaced by the total number of steps.
41+
mPb->setFormat(format);
42+
43+
} // void MngProgressBar::setFormat(QString format)
44+
45+
void MngProgressBar::step(int step)
46+
{
47+
mPb->setValue(step);
48+
mPb->repaint();
49+
50+
} // void MngProgressBar::step()
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/***************************************************************************
2+
qgsmngprogressbar.h
3+
-------------------
4+
begin : Dec 29, 2009
5+
copyright : (C) 2009 by Diego Moreira And Luiz Motta
6+
email : moreira.geo at gmail.com And motta.luiz at gmail.com
7+
8+
***************************************************************************/
9+
10+
/***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************/
18+
/* $Id: $ */
19+
#ifndef QGSMNGPROGRESSBAR_H
20+
#define QGSMNGPROGRESSBAR_H
21+
22+
#include "qprogressbar.h"
23+
24+
/**
25+
* \class MngProgressBar
26+
* \brief This Class manager the progress bar
27+
*/
28+
class MngProgressBar
29+
{
30+
public:
31+
/**
32+
* \brief Constructor for a MngProgressBar.
33+
* \param pb Pointer to the MngProgressBar object.
34+
*/
35+
MngProgressBar(QProgressBar *pb);
36+
/**
37+
* \brief Destructor
38+
*/
39+
~MngProgressBar() { mPb->reset(); };
40+
41+
/**
42+
* \brief Sets the progress bar's minimum and maximum values to minimum and maximum respectively
43+
* \param minimum minimun value.
44+
* \param maximum maximum value.
45+
*/
46+
void init(int minimum, int maximum);
47+
48+
/**
49+
* \brief Sets the format the current text.
50+
* \param format This property holds the string used to generate the current text.
51+
*/
52+
void setFormat(QString format);
53+
54+
/**
55+
* \brief Sets current value progress bar's
56+
* \param step current value
57+
*/
58+
void step(int step );
59+
60+
private:
61+
QProgressBar * mPb;
62+
63+
};
64+
65+
#endif // QGSMNGPROGRESSBAR_H

0 commit comments

Comments
 (0)
Please sign in to comment.