mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
Enable minimum/maximum classification for wfs provider
git-svn-id: http://svn.osgeo.org/qgis/trunk@5876 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
749f822bd0
commit
00ed4f829d
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user