Skip to content

Commit add929a

Browse files
author
jef
committed
port wfs provider to QgsSpatialIndex
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9083 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 34db97d commit add929a

File tree

5 files changed

+137
-147
lines changed

5 files changed

+137
-147
lines changed

src/providers/wfs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ QT4_WRAP_CPP(WFS_MOC_SRCS ${WFS_MOC_HDRS})
2222

2323
INCLUDE_DIRECTORIES (
2424
../../core
25+
../../core/spatialindex
2526
${GEOS_INCLUDE_DIR}
2627
${GEOS_INCLUDE_DIR}/geos
2728
${EXPAT_INCLUDE_DIR}

src/providers/wfs/qgswfsdata.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,32 @@
1717
#include "qgsspatialrefsys.h"
1818
#include <QBuffer>
1919
#include <QUrl>
20+
#include <QList>
21+
#include <QSet>
2022

2123
//just for a test
2224
//#include <QProgressDialog>
2325

2426
const char NS_SEPARATOR = '?';
2527
const QString GML_NAMESPACE = "http://www.opengis.net/gml";
2628

27-
QgsWFSData::QgsWFSData(const QString& uri, QgsRect* extent, QgsSpatialRefSys* srs, std::list<QgsFeature*>* features, const QString& geometryAttribute, const std::set<QString>& thematicAttributes, QGis::WKBTYPE* wkbType): QObject(), mUri(uri), mExtent(extent), mSrs(srs), mFeatures(features), mGeometryAttribute(geometryAttribute), mThematicAttributes(thematicAttributes), mWkbType(wkbType), mFinished(false), mFeatureCount(0)
29+
QgsWFSData::QgsWFSData(
30+
const QString& uri, QgsRect* extent,
31+
QgsSpatialRefSys* srs,
32+
QList<QgsFeature*> &features,
33+
const QString& geometryAttribute,
34+
const QSet<QString>& thematicAttributes,
35+
QGis::WKBTYPE* wkbType)
36+
: QObject(),
37+
mUri(uri),
38+
mExtent(extent),
39+
mSrs(srs),
40+
mFeatures(features),
41+
mGeometryAttribute(geometryAttribute),
42+
mThematicAttributes(thematicAttributes),
43+
mWkbType(wkbType),
44+
mFinished(false),
45+
mFeatureCount(0)
2846
{
2947
//qWarning("Name of the geometry attribute is:");
3048
//qWarning(mGeometryAttribute.toLocal8Bit().data());
@@ -51,11 +69,6 @@ QgsWFSData::~QgsWFSData()
5169

5270
}
5371

54-
QgsWFSData::QgsWFSData()
55-
{
56-
57-
}
58-
5972
int QgsWFSData::getWFSData()
6073
{
6174
XML_Parser p = XML_ParserCreateNS(NULL, NS_SEPARATOR);
@@ -237,7 +250,7 @@ void QgsWFSData::endElement(const XML_Char* el)
237250
else if(elementName == GML_NAMESPACE + NS_SEPARATOR + "featureMember")
238251
{
239252
mCurrentFeature->setGeometryAndOwnership(mCurrentWKB, mCurrentWKBSize);
240-
mFeatures->push_back(mCurrentFeature);
253+
mFeatures << mCurrentFeature;
241254
++mFeatureCount;
242255
//qWarning("Removing featureMember from stack");
243256
mParseModeStack.pop();

src/providers/wfs/qgswfsdata.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ class QgsWFSData: public QObject
3434
{
3535
Q_OBJECT
3636
public:
37-
QgsWFSData(const QString& uri, QgsRect* extent, QgsSpatialRefSys* srs, std::list<QgsFeature*>* features, const QString& geometryAttribute, const std::set<QString>& thematicAttributes, QGis::WKBTYPE* wkbType);
37+
QgsWFSData(
38+
const QString& uri,
39+
QgsRect* extent,
40+
QgsSpatialRefSys* srs,
41+
QList<QgsFeature*> &features,
42+
const QString& geometryAttribute,
43+
const QSet<QString>& thematicAttributes,
44+
QGis::WKBTYPE* wkbType);
3845
~QgsWFSData();
3946

4047
/**Does the Http GET request to the wfs server
@@ -74,17 +81,17 @@ class QgsWFSData: public QObject
7481
void endElement(const XML_Char* el);
7582
void characters(const XML_Char* chars, int len);
7683
static void start(void* data, const XML_Char* el, const XML_Char** attr)
77-
{
78-
static_cast<QgsWFSData*>(data)->startElement(el, attr);
79-
}
84+
{
85+
static_cast<QgsWFSData*>(data)->startElement(el, attr);
86+
}
8087
static void end(void* data, const XML_Char* el)
81-
{
82-
static_cast<QgsWFSData*>(data)->endElement(el);
83-
}
88+
{
89+
static_cast<QgsWFSData*>(data)->endElement(el);
90+
}
8491
static void chars(void* data, const XML_Char* chars, int len)
85-
{
86-
static_cast<QgsWFSData*>(data)->characters(chars, len);
87-
}
92+
{
93+
static_cast<QgsWFSData*>(data)->characters(chars, len);
94+
}
8895

8996
//helper routines
9097
/**Reads attribute srsName="EPSG:..."
@@ -126,10 +133,10 @@ class QgsWFSData: public QObject
126133
/**Source srs of the layer*/
127134
QgsSpatialRefSys* mSrs;
128135
/**The features of the layer*/
129-
std::list<QgsFeature*>* mFeatures;
136+
QList<QgsFeature*> &mFeatures;
130137
/**Name of geometry attribute*/
131138
QString mGeometryAttribute;
132-
std::set<QString> mThematicAttributes;
139+
const QSet<QString> &mThematicAttributes;
133140
QGis::WKBTYPE* mWkbType;
134141
/**True if the request is finished*/
135142
bool mFinished;

0 commit comments

Comments
 (0)