Skip to content
Permalink
Browse files
Enable minimum/maximum classification for wfs provider
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5876 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Sep 27, 2006
1 parent cd587d1 commit f2dda7f3c5b42d0a66a4cb7ad47017585e6e7907
Showing with 56 additions and 2 deletions.
  1. +50 −2 src/providers/wfs/qgswfsprovider.cpp
  2. +6 −0 src/providers/wfs/qgswfsprovider.h
@@ -22,6 +22,7 @@
#include "qgslogger.h"
#include <QDomDocument>
#include <QDomNodeList>
#include <cfloat>

#ifdef WIN32
#define QGISEXTERN extern "C" __declspec( dllexport )
@@ -151,12 +152,59 @@ void QgsWFSProvider::reset()

QString QgsWFSProvider::minValue(int position)
{
return "0";
if(mMinMaxCash.size() == 0)
{
fillMinMaxCash();
}
return mMinMaxCash[position].first;
}

QString QgsWFSProvider::maxValue(int position)
{
return "0";
if(mMinMaxCash.size() == 0)
{
fillMinMaxCash();
}
return mMinMaxCash[position].second;
}

void QgsWFSProvider::fillMinMaxCash()
{
QgsFeature* theFeature = 0;
int fieldCount = fields().size();
int i;
double currentValue;

std::vector<std::pair<double, double> > tempMinMax;
tempMinMax.resize(fieldCount);
for(i = 0; i < fieldCount; ++i)
{
tempMinMax[i] = std::make_pair(DBL_MAX, -DBL_MAX);
}

reset();
while(theFeature = getNextFeature(true))
{
for(i = 0; i < fieldCount; ++i)
{
currentValue = (theFeature->attributeMap())[i].fieldValue().toDouble();
if(currentValue < tempMinMax[i].first)
{
tempMinMax[i].first = currentValue;
}
if(currentValue > tempMinMax[i].second)
{
tempMinMax[i].second = currentValue;
}
}
}

mMinMaxCash.clear();
mMinMaxCash.resize(fieldCount);
for(i = 0; i < fieldCount; ++i)
{
mMinMaxCash[i] = std::make_pair(QString::number(tempMinMax[i].first), QString::number(tempMinMax[i].second));
}
}

std::vector<QgsFeature>& QgsWFSProvider::identify(QgsRect *rect) /*legacy*/
@@ -97,6 +97,9 @@ class QgsWFSProvider: public QgsVectorDataProvider
mutable QGis::WKBTYPE mWKBType;
/**Source SRS*/
QgsSpatialRefSys* mSourceSRS;
/**Stores the minimum/maximum values for each attribute
The position in the vector is equal to the position of an attribute in the layers attribute vector*/
std::vector< std::pair<QString, QString> > mMinMaxCash;

/**Collects information about the field types. Is called internally from QgsWFSProvider::getFeature*/
int describeFeatureType(const QString& uri, std::vector<QgsField>& fields);
@@ -141,6 +144,9 @@ class QgsWFSProvider: public QgsVectorDataProvider

/**Tries to create a QgsSpatialRefSys object and assign it to mSourceSRS. Returns 0 in case of success*/
int setSRSFromGML(const QDomElement& wfsCollectionElement);

/***/
void fillMinMaxCash();
};

#endif

0 comments on commit f2dda7f

Please sign in to comment.