Navigation Menu

Skip to content

Commit

Permalink
port wfs provider to QgsSpatialIndex
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@9083 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Aug 20, 2008
1 parent 1c3927b commit abdda51
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 147 deletions.
1 change: 1 addition & 0 deletions src/providers/wfs/CMakeLists.txt
Expand Up @@ -22,6 +22,7 @@ QT4_WRAP_CPP(WFS_MOC_SRCS ${WFS_MOC_HDRS})

INCLUDE_DIRECTORIES (
../../core
../../core/spatialindex
${GEOS_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}/geos
${EXPAT_INCLUDE_DIR}
Expand Down
27 changes: 20 additions & 7 deletions src/providers/wfs/qgswfsdata.cpp
Expand Up @@ -17,14 +17,32 @@
#include "qgsspatialrefsys.h"
#include <QBuffer>
#include <QUrl>
#include <QList>
#include <QSet>

//just for a test
//#include <QProgressDialog>

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

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)
QgsWFSData::QgsWFSData(
const QString& uri, QgsRect* extent,
QgsSpatialRefSys* srs,
QList<QgsFeature*> &features,
const QString& geometryAttribute,
const QSet<QString>& thematicAttributes,
QGis::WKBTYPE* wkbType)
: QObject(),
mUri(uri),
mExtent(extent),
mSrs(srs),
mFeatures(features),
mGeometryAttribute(geometryAttribute),
mThematicAttributes(thematicAttributes),
mWkbType(wkbType),
mFinished(false),
mFeatureCount(0)
{
//qWarning("Name of the geometry attribute is:");
//qWarning(mGeometryAttribute.toLocal8Bit().data());
Expand All @@ -51,11 +69,6 @@ QgsWFSData::~QgsWFSData()

}

QgsWFSData::QgsWFSData()
{

}

int QgsWFSData::getWFSData()
{
XML_Parser p = XML_ParserCreateNS(NULL, NS_SEPARATOR);
Expand Down Expand Up @@ -237,7 +250,7 @@ void QgsWFSData::endElement(const XML_Char* el)
else if(elementName == GML_NAMESPACE + NS_SEPARATOR + "featureMember")
{
mCurrentFeature->setGeometryAndOwnership(mCurrentWKB, mCurrentWKBSize);
mFeatures->push_back(mCurrentFeature);
mFeatures << mCurrentFeature;
++mFeatureCount;
//qWarning("Removing featureMember from stack");
mParseModeStack.pop();
Expand Down
31 changes: 19 additions & 12 deletions src/providers/wfs/qgswfsdata.h
Expand Up @@ -34,7 +34,14 @@ class QgsWFSData: public QObject
{
Q_OBJECT
public:
QgsWFSData(const QString& uri, QgsRect* extent, QgsSpatialRefSys* srs, std::list<QgsFeature*>* features, const QString& geometryAttribute, const std::set<QString>& thematicAttributes, QGis::WKBTYPE* wkbType);
QgsWFSData(
const QString& uri,
QgsRect* extent,
QgsSpatialRefSys* srs,
QList<QgsFeature*> &features,
const QString& geometryAttribute,
const QSet<QString>& thematicAttributes,
QGis::WKBTYPE* wkbType);
~QgsWFSData();

/**Does the Http GET request to the wfs server
Expand Down Expand Up @@ -74,17 +81,17 @@ class QgsWFSData: public QObject
void endElement(const XML_Char* el);
void characters(const XML_Char* chars, int len);
static void start(void* data, const XML_Char* el, const XML_Char** attr)
{
static_cast<QgsWFSData*>(data)->startElement(el, attr);
}
{
static_cast<QgsWFSData*>(data)->startElement(el, attr);
}
static void end(void* data, const XML_Char* el)
{
static_cast<QgsWFSData*>(data)->endElement(el);
}
{
static_cast<QgsWFSData*>(data)->endElement(el);
}
static void chars(void* data, const XML_Char* chars, int len)
{
static_cast<QgsWFSData*>(data)->characters(chars, len);
}
{
static_cast<QgsWFSData*>(data)->characters(chars, len);
}

//helper routines
/**Reads attribute srsName="EPSG:..."
Expand Down Expand Up @@ -126,10 +133,10 @@ class QgsWFSData: public QObject
/**Source srs of the layer*/
QgsSpatialRefSys* mSrs;
/**The features of the layer*/
std::list<QgsFeature*>* mFeatures;
QList<QgsFeature*> &mFeatures;
/**Name of geometry attribute*/
QString mGeometryAttribute;
std::set<QString> mThematicAttributes;
const QSet<QString> &mThematicAttributes;
QGis::WKBTYPE* mWkbType;
/**True if the request is finished*/
bool mFinished;
Expand Down

0 comments on commit abdda51

Please sign in to comment.