|
Quantum GIS API Documentation
master-7dce617
|
This class reads data from a WFS server or alternatively from a GML file. More...
#include <qgswfsdata.h>
Collaboration diagram for QgsWFSData:Signals | |
| void | dataProgressAndSteps (int progress, int totalSteps) |
| void | dataReadProgress (int progress) |
| void | totalStepsUpdate (int totalSteps) |
Public Member Functions | |
| QgsWFSData (const QString &uri, QgsRectangle *extent, QMap< QgsFeatureId, QgsFeature * > &features, QMap< QgsFeatureId, QString > &idMap, const QString &geometryAttribute, const QMap< QString, QPair< int, QgsField > > &thematicAttributes, QGis::WkbType *wkbType) | |
| Constructor. | |
| ~QgsWFSData () | |
| int | getWFSData () |
| Does the Http GET request to the wfs server. | |
Private Types | |
| enum | parseMode { boundingBox, featureMember, attribute, geometry, coordinate, point, line, polygon, multiPoint, multiLine, multiPolygon } |
Private Slots | |
| void | handleProgressEvent (qint64 progress, qint64 totalSteps) |
| Takes progress value and total steps and emit signals 'dataReadProgress' and 'totalStepUpdate'. | |
| void | setFinished () |
Private Member Functions | |
| QgsWFSData () | |
| void | calculateExtentFromFeatures () const |
| This function evaluates the layer bounding box from the features and sets it to mExtent. | |
| void | characters (const XML_Char *chars, int len) |
| int | createBBoxFromCoordinateString (QgsRectangle *bb, const QString &coordString) const |
| Creates a rectangle from a coordinate string. | |
| int | createMultiLineFromFragments () |
| Creates a multiline from the information in mCurrentWKBFragments and mCurrentWKBFragmentSizes. | |
| int | createMultiPointFromFragments () |
| int | createMultiPolygonFromFragments () |
| int | createPolygonFromFragments () |
| void | endElement (const XML_Char *el) |
| QWidget * | findMainWindow () const |
| Returns pointer to main window or 0 if it does not exist. | |
| int | getLineWKB (unsigned char **wkb, int *size, const std::list< QgsPoint > &lineCoordinates) const |
| int | getPointWKB (unsigned char **wkb, int *size, const QgsPoint &) const |
| int | getRingWKB (unsigned char **wkb, int *size, const std::list< QgsPoint > &ringCoordinates) const |
| int | pointsFromCoordinateString (std::list< QgsPoint > &points, const QString &coordString) const |
| Creates a set of points from a coordinate string. | |
| QString | readAttribute (const QString &attributeName, const XML_Char **attr) const |
| Reads attribute as string. | |
| int | readEpsgFromAttribute (int &epsgNr, const XML_Char **attr) const |
| Reads attribute srsName="EpsgCrsId:...". | |
| void | startElement (const XML_Char *el, const XML_Char **attr) |
| XML handler methods. | |
| int | totalWKBFragmentSize () const |
| Adds all the integers contained in mCurrentWKBFragmentSizes. | |
Static Private Member Functions | |
| static void | chars (void *data, const XML_Char *chars, int len) |
| static void | end (void *data, const XML_Char *el) |
| static void | start (void *data, const XML_Char *el, const XML_Char **attr) |
Private Attributes | |
| QString | mAttributeName |
| QString | mCoordinateSeparator |
| Coordinate separator for coordinate strings. | |
| QVector< QVariant > | mCurrentAttributes |
| QgsFeature * | mCurrentFeature |
| QString | mCurrentFeatureId |
| unsigned char * | mCurrentWKB |
| The total WKB for a feature. | |
| std::list< std::list< unsigned char * > > | mCurrentWKBFragments |
| WKB intermediate storage during parsing. | |
| std::list< std::list< int > > | mCurrentWKBFragmentSizes |
| Similar to mCurrentWKB, but only the size. | |
| int | mCurrentWKBSize |
| The total WKB size for a feature. | |
| QgsApplication::endian_t | mEndian |
| QgsRectangle * | mExtent |
| Bounding box of the layer. | |
| int | mFeatureCount |
| QMap< QgsFeatureId, QgsFeature * > & | mFeatures |
| The features of the layer. | |
| bool | mFinished |
| True if the request is finished. | |
| QString | mGeometryAttribute |
| Name of geometry attribute. | |
| QMap< QgsFeatureId, QString > & | mIdMap |
| Stores the relation between provider ids and WFS server ids. | |
| std::stack< parseMode > | mParseModeStack |
| Keep track about the most important nested elements. | |
| QString | mStringCash |
| This contains the character data if an important element has been encountered. | |
| const QMap< QString, QPair < int, QgsField > > & | mThematicAttributes |
| QString | mTupleSeparator |
| Tuple separator for coordinate strings. | |
| QString | mTypeName |
| QString | mUri |
| QGis::WkbType * | mWkbType |
This class reads data from a WFS server or alternatively from a GML file.
It uses the expat XML parser and an event based model to keep performance high. The parsing starts when the first data arrives, it does not wait until the request is finished
Definition at line 34 of file qgswfsdata.h.
enum QgsWFSData::parseMode [private] |
| boundingBox | |
| featureMember | |
| attribute | |
| geometry | |
| coordinate | |
| point | |
| line | |
| polygon | |
| multiPoint | |
| multiLine | |
| multiPolygon |
Definition at line 74 of file qgswfsdata.h.
| QgsWFSData::QgsWFSData | ( | const QString & | uri, |
| QgsRectangle * | extent, | ||
| QMap< QgsFeatureId, QgsFeature * > & | features, | ||
| QMap< QgsFeatureId, QString > & | idMap, | ||
| const QString & | geometryAttribute, | ||
| const QMap< QString, QPair< int, QgsField > > & | thematicAttributes, | ||
| QGis::WkbType * | wkbType | ||
| ) |
Constructor.
| uri | request uri |
| extent | the extent of the WFS layer |
| features | the features of the layer |
| idMap | |
| geometryAttribute | |
| thematicAttributes | |
| wkbType |
Definition at line 33 of file qgswfsdata.cpp.
References QgsApplication::endian(), mEndian, mTypeName, and QgsDebugMsg.
Definition at line 73 of file qgswfsdata.cpp.
| QgsWFSData::QgsWFSData | ( | ) | [private] |
| void QgsWFSData::calculateExtentFromFeatures | ( | ) | const [private] |
This function evaluates the layer bounding box from the features and sets it to mExtent.
Less efficient compared to reading the bbox from the provider, so it is only done if the wfs server does not provider extent information.
Definition at line 833 of file qgswfsdata.cpp.
References QgsGeometry::boundingBox(), QgsFeature::geometry(), mFeatures, and QgsRectangle::unionRect().
Referenced by getWFSData().
| void QgsWFSData::characters | ( | const XML_Char * | chars, |
| int | len | ||
| ) | [private] |
Definition at line 455 of file qgswfsdata.cpp.
References attribute, coordinate, mParseModeStack, and mStringCash.
| static void QgsWFSData::chars | ( | void * | data, |
| const XML_Char * | chars, | ||
| int | len | ||
| ) | [inline, static, private] |
Definition at line 103 of file qgswfsdata.h.
Referenced by getWFSData().
| int QgsWFSData::createBBoxFromCoordinateString | ( | QgsRectangle * | bb, |
| const QString & | coordString | ||
| ) | const [private] |
Creates a rectangle from a coordinate string.
Definition at line 516 of file qgswfsdata.cpp.
References pointsFromCoordinateString(), and QgsRectangle::set().
Referenced by endElement().
| int QgsWFSData::createMultiLineFromFragments | ( | ) | [private] |
Creates a multiline from the information in mCurrentWKBFragments and mCurrentWKBFragmentSizes.
Assign the result. The multiline is in mCurrentWKB and mCurrentWKBSize. The function deletes the memory in mCurrentWKBFragments. Returns 0 in case of success.
Definition at line 646 of file qgswfsdata.cpp.
References mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mEndian, mWkbType, totalWKBFragmentSize(), and QGis::WKBMultiLineString.
Referenced by endElement().
| int QgsWFSData::createMultiPointFromFragments | ( | ) | [private] |
Definition at line 680 of file qgswfsdata.cpp.
References mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mEndian, mWkbType, totalWKBFragmentSize(), and QGis::WKBMultiPoint.
Referenced by endElement().
| int QgsWFSData::createMultiPolygonFromFragments | ( | ) | [private] |
Definition at line 747 of file qgswfsdata.cpp.
References mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mEndian, mWkbType, totalWKBFragmentSize(), QGis::WKBMultiPolygon, and QGis::WKBPolygon.
Referenced by endElement().
| int QgsWFSData::createPolygonFromFragments | ( | ) | [private] |
Definition at line 715 of file qgswfsdata.cpp.
References mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mEndian, mWkbType, totalWKBFragmentSize(), and QGis::WKBPolygon.
Referenced by endElement().
| void QgsWFSData::dataProgressAndSteps | ( | int | progress, |
| int | totalSteps | ||
| ) | [signal] |
Referenced by handleProgressEvent().
| void QgsWFSData::dataReadProgress | ( | int | progress | ) | [signal] |
Referenced by getWFSData(), and handleProgressEvent().
| static void QgsWFSData::end | ( | void * | data, |
| const XML_Char * | el | ||
| ) | [inline, static, private] |
Definition at line 99 of file qgswfsdata.h.
Referenced by getWFSData().
| void QgsWFSData::endElement | ( | const XML_Char * | el | ) | [private] |
Definition at line 244 of file qgswfsdata.cpp.
References boundingBox, createBBoxFromCoordinateString(), createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), getLineWKB(), getPointWKB(), getRingWKB(), GML_NAMESPACE, QgsFeature::id(), mAttributeName, mCurrentFeature, mCurrentFeatureId, mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mExtent, mFeatureCount, mFeatures, mGeometryAttribute, mIdMap, mParseModeStack, mStringCash, mThematicAttributes, multiLine, multiPoint, multiPolygon, mWkbType, NS_SEPARATOR, pointsFromCoordinateString(), QgsDebugMsg, QgsFeature::setAttribute(), QgsFeature::setGeometryAndOwnership(), QGis::WKBLineString, QGis::WKBMultiLineString, QGis::WKBMultiPoint, QGis::WKBMultiPolygon, QGis::WKBPoint, and QGis::WKBPolygon.
| QWidget * QgsWFSData::findMainWindow | ( | ) | const [private] |
Returns pointer to main window or 0 if it does not exist.
Definition at line 816 of file qgswfsdata.cpp.
Referenced by getWFSData().
| int QgsWFSData::getLineWKB | ( | unsigned char ** | wkb, |
| int * | size, | ||
| const std::list< QgsPoint > & | lineCoordinates | ||
| ) | const [private] |
Definition at line 591 of file qgswfsdata.cpp.
References mEndian, and QGis::WKBLineString.
Referenced by endElement().
| int QgsWFSData::getPointWKB | ( | unsigned char ** | wkb, |
| int * | size, | ||
| const QgsPoint & | point | ||
| ) | const [private] |
Definition at line 571 of file qgswfsdata.cpp.
References mEndian, QGis::WKBPoint, QgsPoint::x(), and QgsPoint::y().
Referenced by endElement().
| int QgsWFSData::getRingWKB | ( | unsigned char ** | wkb, |
| int * | size, | ||
| const std::list< QgsPoint > & | ringCoordinates | ||
| ) | const [private] |
Definition at line 622 of file qgswfsdata.cpp.
Referenced by endElement().
| int QgsWFSData::getWFSData | ( | ) |
Does the Http GET request to the wfs server.
Definition at line 78 of file qgswfsdata.cpp.
References calculateExtentFromFeatures(), chars(), dataReadProgress(), end(), findMainWindow(), handleProgressEvent(), QgsNetworkAccessManager::instance(), QgsRectangle::isEmpty(), mExtent, mFinished, mTypeName, mUri, mWkbType, NS_SEPARATOR, QgsRectangle::set(), setFinished(), start(), totalStepsUpdate(), tr, and QGis::WKBNoGeometry.
| void QgsWFSData::handleProgressEvent | ( | qint64 | progress, |
| qint64 | totalSteps | ||
| ) | [private, slot] |
Takes progress value and total steps and emit signals 'dataReadProgress' and 'totalStepUpdate'.
Definition at line 148 of file qgswfsdata.cpp.
References dataProgressAndSteps(), dataReadProgress(), and totalStepsUpdate().
Referenced by getWFSData().
| int QgsWFSData::pointsFromCoordinateString | ( | std::list< QgsPoint > & | points, |
| const QString & | coordString | ||
| ) | const [private] |
Creates a set of points from a coordinate string.
| points | list that will contain the created points |
| coordString | the text containing the coordinates |
Definition at line 540 of file qgswfsdata.cpp.
References mCoordinateSeparator, and mTupleSeparator.
Referenced by createBBoxFromCoordinateString(), and endElement().
| QString QgsWFSData::readAttribute | ( | const QString & | attributeName, |
| const XML_Char ** | attr | ||
| ) | const [private] |
Reads attribute as string.
| attributeName | |
| attr |
Definition at line 502 of file qgswfsdata.cpp.
Referenced by startElement().
| int QgsWFSData::readEpsgFromAttribute | ( | int & | epsgNr, |
| const XML_Char ** | attr | ||
| ) | const [private] |
Reads attribute srsName="EpsgCrsId:...".
| epsgNr | result |
| attr | attribute strings |
Definition at line 471 of file qgswfsdata.cpp.
Referenced by startElement().
| void QgsWFSData::setFinished | ( | ) | [private, slot] |
| static void QgsWFSData::start | ( | void * | data, |
| const XML_Char * | el, | ||
| const XML_Char ** | attr | ||
| ) | [inline, static, private] |
Definition at line 95 of file qgswfsdata.h.
Referenced by getWFSData().
| void QgsWFSData::startElement | ( | const XML_Char * | el, |
| const XML_Char ** | attr | ||
| ) | [private] |
XML handler methods.
Definition at line 159 of file qgswfsdata.cpp.
References attribute, boundingBox, coordinate, featureMember, geometry, GML_NAMESPACE, mAttributeName, mCoordinateSeparator, mCurrentFeature, mCurrentFeatureId, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mFeatureCount, mGeometryAttribute, mParseModeStack, mStringCash, mThematicAttributes, mTupleSeparator, mTypeName, multiLine, multiPoint, multiPolygon, NS_SEPARATOR, QgsDebugMsg, readAttribute(), readEpsgFromAttribute(), and QgsFeature::setAttributes().
| void QgsWFSData::totalStepsUpdate | ( | int | totalSteps | ) | [signal] |
Referenced by getWFSData(), and handleProgressEvent().
| int QgsWFSData::totalWKBFragmentSize | ( | ) | const [private] |
Adds all the integers contained in mCurrentWKBFragmentSizes.
Definition at line 803 of file qgswfsdata.cpp.
References mCurrentWKBFragmentSizes.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), and createPolygonFromFragments().
QString QgsWFSData::mAttributeName [private] |
Definition at line 176 of file qgswfsdata.h.
Referenced by endElement(), and startElement().
QString QgsWFSData::mCoordinateSeparator [private] |
Coordinate separator for coordinate strings.
Usually ","
Definition at line 180 of file qgswfsdata.h.
Referenced by pointsFromCoordinateString(), and startElement().
QVector<QVariant> QgsWFSData::mCurrentAttributes [private] |
Definition at line 165 of file qgswfsdata.h.
QgsFeature* QgsWFSData::mCurrentFeature [private] |
Definition at line 164 of file qgswfsdata.h.
Referenced by endElement(), and startElement().
QString QgsWFSData::mCurrentFeatureId [private] |
Definition at line 166 of file qgswfsdata.h.
Referenced by endElement(), and startElement().
unsigned char* QgsWFSData::mCurrentWKB [private] |
The total WKB for a feature.
Definition at line 169 of file qgswfsdata.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), and endElement().
std::list< std::list<unsigned char*> > QgsWFSData::mCurrentWKBFragments [private] |
WKB intermediate storage during parsing.
For points and lines, no intermediate WKB is stored at all. For multipoins and multilines and polygons, only one nested list is used. For multipolygons, both nested lists are used
Definition at line 173 of file qgswfsdata.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), endElement(), and startElement().
std::list< std::list<int> > QgsWFSData::mCurrentWKBFragmentSizes [private] |
Similar to mCurrentWKB, but only the size.
Definition at line 175 of file qgswfsdata.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), endElement(), startElement(), and totalWKBFragmentSize().
int QgsWFSData::mCurrentWKBSize [private] |
The total WKB size for a feature.
Definition at line 171 of file qgswfsdata.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), and endElement().
QgsApplication::endian_t QgsWFSData::mEndian [private] |
Definition at line 178 of file qgswfsdata.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), getLineWKB(), getPointWKB(), and QgsWFSData().
QgsRectangle* QgsWFSData::mExtent [private] |
Bounding box of the layer.
Definition at line 149 of file qgswfsdata.h.
Referenced by endElement(), and getWFSData().
int QgsWFSData::mFeatureCount [private] |
Definition at line 167 of file qgswfsdata.h.
Referenced by endElement(), and startElement().
QMap<QgsFeatureId, QgsFeature* >& QgsWFSData::mFeatures [private] |
The features of the layer.
Definition at line 151 of file qgswfsdata.h.
Referenced by calculateExtentFromFeatures(), and endElement().
bool QgsWFSData::mFinished [private] |
True if the request is finished.
Definition at line 159 of file qgswfsdata.h.
Referenced by getWFSData(), and setFinished().
QString QgsWFSData::mGeometryAttribute [private] |
Name of geometry attribute.
Definition at line 155 of file qgswfsdata.h.
Referenced by endElement(), and startElement().
QMap<QgsFeatureId, QString >& QgsWFSData::mIdMap [private] |
Stores the relation between provider ids and WFS server ids.
Definition at line 153 of file qgswfsdata.h.
Referenced by endElement().
std::stack<parseMode> QgsWFSData::mParseModeStack [private] |
Keep track about the most important nested elements.
Definition at line 161 of file qgswfsdata.h.
Referenced by characters(), endElement(), and startElement().
QString QgsWFSData::mStringCash [private] |
This contains the character data if an important element has been encountered.
Definition at line 163 of file qgswfsdata.h.
Referenced by characters(), endElement(), and startElement().
const QMap<QString, QPair<int, QgsField> >& QgsWFSData::mThematicAttributes [private] |
Definition at line 156 of file qgswfsdata.h.
Referenced by endElement(), and startElement().
QString QgsWFSData::mTupleSeparator [private] |
Tuple separator for coordinate strings.
Usually " "
Definition at line 182 of file qgswfsdata.h.
Referenced by pointsFromCoordinateString(), and startElement().
QString QgsWFSData::mTypeName [private] |
Definition at line 177 of file qgswfsdata.h.
Referenced by getWFSData(), QgsWFSData(), and startElement().
QString QgsWFSData::mUri [private] |
Definition at line 146 of file qgswfsdata.h.
Referenced by getWFSData().
QGis::WkbType* QgsWFSData::mWkbType [private] |
Definition at line 157 of file qgswfsdata.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), endElement(), and getWFSData().