|
QGIS API Documentation
master-3f58142
|
This class reads data from a WFS server or alternatively from a GML file. More...
#include <qgsgml.h>
Collaboration diagram for QgsGml:Signals | |
| void | dataProgressAndSteps (int progress, int totalSteps) |
| void | dataReadProgress (int progress) |
| void | totalStepsUpdate (int totalSteps) |
Public Member Functions | |
| QgsGml (const QString &typeName, const QString &geometryAttribute, const QgsFields &fields) | |
| ~QgsGml () | |
| QMap< QgsFeatureId, QgsFeature * > | featuresMap () const |
| Get parsed features for given type name. | |
| int | getFeatures (const QString &uri, QGis::WkbType *wkbType, QgsRectangle *extent=0) |
| Does the Http GET request to the wfs server. | |
| int | getFeatures (const QByteArray &data, QGis::WkbType *wkbType, QgsRectangle *extent=0) |
| Read from GML data. | |
| QMap< QgsFeatureId, QString > | idsMap () const |
| Get feature ids map. | |
Private Types | |
| enum | ParseMode { none, boundingBox, feature, 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 | |
| void | calculateExtentFromFeatures () |
| 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 QList< QgsPoint > &lineCoordinates) const |
| int | getPointWKB (unsigned char **wkb, int *size, const QgsPoint &) const |
| int | getRingWKB (unsigned char **wkb, int *size, const QList< QgsPoint > &ringCoordinates) const |
| ParseMode | modeStackPop () |
| Safely (if empty) pop from mode stack. | |
| ParseMode | modeStackTop () |
| Get safely (if empty) top from mode stack. | |
| int | pointsFromCoordinateString (QList< 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 |
| QgsRectangle | mCurrentExtent |
| QgsFeature * | mCurrentFeature |
| QString | mCurrentFeatureId |
| unsigned char * | mCurrentWKB |
| The total WKB for a feature. | |
| QList< QList< unsigned char * > > | mCurrentWKBFragments |
| WKB intermediate storage during parsing. | |
| QList< QList< 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, map of feature maps for each feature type. | |
| 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. | |
| QStack< ParseMode > | mParseModeStack |
| Keep track about the most important nested elements. | |
| QString | mStringCash |
| This contains the character data if an important element has been encountered. | |
| 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
enum QgsGml::ParseMode [private] |
| QgsGml::QgsGml | ( | const QString & | typeName, |
| const QString & | geometryAttribute, | ||
| const QgsFields & | fields | ||
| ) |
Definition at line 35 of file qgsgml.cpp.
References QgsApplication::endian(), mEndian, mThematicAttributes, mTypeName, and QgsFields::size().
| QgsGml::~QgsGml | ( | ) |
Definition at line 61 of file qgsgml.cpp.
| void QgsGml::calculateExtentFromFeatures | ( | ) | [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 830 of file qgsgml.cpp.
References QgsGeometry::boundingBox(), QgsFeature::geometry(), mExtent, mFeatures, and QgsRectangle::unionRect().
Referenced by getFeatures().
| void QgsGml::characters | ( | const XML_Char * | chars, |
| int | len | ||
| ) | [private] |
Definition at line 476 of file qgsgml.cpp.
References attribute, coordinate, mParseModeStack, and mStringCash.
| static void QgsGml::chars | ( | void * | data, |
| const XML_Char * | chars, | ||
| int | len | ||
| ) | [inline, static, private] |
Definition at line 110 of file qgsgml.h.
Referenced by getFeatures().
| int QgsGml::createBBoxFromCoordinateString | ( | QgsRectangle & | bb, |
| const QString & | coordString | ||
| ) | const [private] |
Creates a rectangle from a coordinate string.
Definition at line 536 of file qgsgml.cpp.
References pointsFromCoordinateString(), and QgsRectangle::set().
Referenced by endElement().
| int QgsGml::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 660 of file qgsgml.cpp.
References mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mEndian, mWkbType, totalWKBFragmentSize(), and QGis::WKBMultiLineString.
Referenced by endElement().
| int QgsGml::createMultiPointFromFragments | ( | ) | [private] |
Definition at line 694 of file qgsgml.cpp.
References mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mEndian, mWkbType, totalWKBFragmentSize(), and QGis::WKBMultiPoint.
Referenced by endElement().
| int QgsGml::createMultiPolygonFromFragments | ( | ) | [private] |
Definition at line 761 of file qgsgml.cpp.
References mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mEndian, mWkbType, totalWKBFragmentSize(), QGis::WKBMultiPolygon, and QGis::WKBPolygon.
Referenced by endElement().
| int QgsGml::createPolygonFromFragments | ( | ) | [private] |
Definition at line 729 of file qgsgml.cpp.
References mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mEndian, mWkbType, totalWKBFragmentSize(), and QGis::WKBPolygon.
Referenced by endElement().
| void QgsGml::dataProgressAndSteps | ( | int | progress, |
| int | totalSteps | ||
| ) | [signal] |
Referenced by handleProgressEvent().
| void QgsGml::dataReadProgress | ( | int | progress | ) | [signal] |
Referenced by getFeatures(), and handleProgressEvent().
| static void QgsGml::end | ( | void * | data, |
| const XML_Char * | el | ||
| ) | [inline, static, private] |
Definition at line 106 of file qgsgml.h.
Referenced by getFeatures().
| void QgsGml::endElement | ( | const XML_Char * | el | ) | [private] |
Definition at line 252 of file qgsgml.cpp.
References boundingBox, createBBoxFromCoordinateString(), createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), QgsGeometry::fromRect(), getLineWKB(), getPointWKB(), getRingWKB(), GML_NAMESPACE, QgsFeature::id(), QgsRectangle::isEmpty(), mAttributeName, mCurrentExtent, mCurrentFeature, mCurrentFeatureId, mCurrentWKB, mCurrentWKBFragments, mCurrentWKBFragmentSizes, mCurrentWKBSize, mFeatureCount, mFeatures, mGeometryAttribute, mIdMap, mParseModeStack, mStringCash, mThematicAttributes, mTypeName, multiLine, multiPoint, multiPolygon, mWkbType, NS_SEPARATOR, pointsFromCoordinateString(), QgsDebugMsg, QgsFeature::setAttribute(), QgsFeature::setGeometry(), QgsFeature::setGeometryAndOwnership(), QgsFeature::setValid(), QGis::WKBLineString, QGis::WKBMultiLineString, QGis::WKBMultiPoint, QGis::WKBMultiPolygon, QGis::WKBPoint, and QGis::WKBPolygon.
| QMap<QgsFeatureId, QgsFeature* > QgsGml::featuresMap | ( | ) | const [inline] |
| QWidget* QgsGml::findMainWindow | ( | ) | const [private] |
Returns pointer to main window or 0 if it does not exist.
| int QgsGml::getFeatures | ( | const QString & | uri, |
| QGis::WkbType * | wkbType, | ||
| QgsRectangle * | extent = 0 |
||
| ) |
Does the Http GET request to the wfs server.
| uri | GML URL |
| wkbType | wkbType to retrieve |
| extent | retrieved extents |
Definition at line 65 of file qgsgml.cpp.
References calculateExtentFromFeatures(), chars(), dataReadProgress(), end(), handleProgressEvent(), QgsNetworkAccessManager::instance(), QgsRectangle::isEmpty(), mExtent, mFinished, mTypeName, mUri, mWkbType, NS_SEPARATOR, setFinished(), QgsRectangle::setMinimal(), start(), totalStepsUpdate(), tr, and QGis::WKBNoGeometry.
| int QgsGml::getFeatures | ( | const QByteArray & | data, |
| QGis::WkbType * | wkbType, | ||
| QgsRectangle * | extent = 0 |
||
| ) |
Read from GML data.
Constructor uri param is ignored
Definition at line 132 of file qgsgml.cpp.
References chars(), end(), mExtent, mWkbType, NS_SEPARATOR, QgsDebugMsg, QgsRectangle::setMinimal(), and start().
| int QgsGml::getLineWKB | ( | unsigned char ** | wkb, |
| int * | size, | ||
| const QList< QgsPoint > & | lineCoordinates | ||
| ) | const [private] |
Definition at line 605 of file qgsgml.cpp.
References mEndian, and QGis::WKBLineString.
Referenced by endElement().
| int QgsGml::getPointWKB | ( | unsigned char ** | wkb, |
| int * | size, | ||
| const QgsPoint & | point | ||
| ) | const [private] |
Definition at line 585 of file qgsgml.cpp.
References mEndian, QGis::WKBPoint, QgsPoint::x(), and QgsPoint::y().
Referenced by endElement().
| int QgsGml::getRingWKB | ( | unsigned char ** | wkb, |
| int * | size, | ||
| const QList< QgsPoint > & | ringCoordinates | ||
| ) | const [private] |
Definition at line 636 of file qgsgml.cpp.
Referenced by endElement().
| void QgsGml::handleProgressEvent | ( | qint64 | progress, |
| qint64 | totalSteps | ||
| ) | [private, slot] |
Takes progress value and total steps and emit signals 'dataReadProgress' and 'totalStepUpdate'.
Definition at line 156 of file qgsgml.cpp.
References dataProgressAndSteps(), dataReadProgress(), and totalStepsUpdate().
Referenced by getFeatures().
| QMap<QgsFeatureId, QString > QgsGml::idsMap | ( | ) | const [inline] |
| ParseMode QgsGml::modeStackPop | ( | ) | [inline, private] |
| ParseMode QgsGml::modeStackTop | ( | ) | [inline, private] |
| int QgsGml::pointsFromCoordinateString | ( | QList< 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 554 of file qgsgml.cpp.
References mCoordinateSeparator, and mTupleSeparator.
Referenced by createBBoxFromCoordinateString(), and endElement().
| QString QgsGml::readAttribute | ( | const QString & | attributeName, |
| const XML_Char ** | attr | ||
| ) | const [private] |
Reads attribute as string.
| attributeName | |
| attr |
Definition at line 522 of file qgsgml.cpp.
Referenced by startElement().
| int QgsGml::readEpsgFromAttribute | ( | int & | epsgNr, |
| const XML_Char ** | attr | ||
| ) | const [private] |
Reads attribute srsName="EpsgCrsId:...".
| epsgNr | result |
| attr | attribute strings |
Definition at line 491 of file qgsgml.cpp.
Referenced by startElement().
| void QgsGml::setFinished | ( | ) | [private, slot] |
| static void QgsGml::start | ( | void * | data, |
| const XML_Char * | el, | ||
| const XML_Char ** | attr | ||
| ) | [inline, static, private] |
Definition at line 102 of file qgsgml.h.
Referenced by getFeatures().
| void QgsGml::startElement | ( | const XML_Char * | el, |
| const XML_Char ** | attr | ||
| ) | [private] |
XML handler methods.
Definition at line 167 of file qgsgml.cpp.
References attribute, boundingBox, coordinate, feature, 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 QgsGml::totalStepsUpdate | ( | int | totalSteps | ) | [signal] |
Referenced by getFeatures(), and handleProgressEvent().
| int QgsGml::totalWKBFragmentSize | ( | ) | const [private] |
Adds all the integers contained in mCurrentWKBFragmentSizes.
Definition at line 817 of file qgsgml.cpp.
References mCurrentWKBFragmentSizes.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), and createPolygonFromFragments().
QString QgsGml::mAttributeName [private] |
Definition at line 198 of file qgsgml.h.
Referenced by endElement(), and startElement().
QString QgsGml::mCoordinateSeparator [private] |
Coordinate separator for coordinate strings.
Usually ","
Definition at line 201 of file qgsgml.h.
Referenced by pointsFromCoordinateString(), and startElement().
QVector<QVariant> QgsGml::mCurrentAttributes [private] |
QgsRectangle QgsGml::mCurrentExtent [private] |
Definition at line 193 of file qgsgml.h.
Referenced by endElement().
QgsFeature* QgsGml::mCurrentFeature [private] |
Definition at line 185 of file qgsgml.h.
Referenced by endElement(), and startElement().
QString QgsGml::mCurrentFeatureId [private] |
Definition at line 187 of file qgsgml.h.
Referenced by endElement(), and startElement().
unsigned char* QgsGml::mCurrentWKB [private] |
The total WKB for a feature.
Definition at line 190 of file qgsgml.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), and endElement().
QList< QList<unsigned char*> > QgsGml::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 195 of file qgsgml.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), endElement(), and startElement().
QList< QList<int> > QgsGml::mCurrentWKBFragmentSizes [private] |
Similar to mCurrentWKB, but only the size.
Definition at line 197 of file qgsgml.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), endElement(), startElement(), and totalWKBFragmentSize().
int QgsGml::mCurrentWKBSize [private] |
The total WKB size for a feature.
Definition at line 192 of file qgsgml.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), and endElement().
QgsApplication::endian_t QgsGml::mEndian [private] |
Definition at line 199 of file qgsgml.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), getLineWKB(), getPointWKB(), and QgsGml().
QgsRectangle QgsGml::mExtent [private] |
Bounding box of the layer.
Definition at line 164 of file qgsgml.h.
Referenced by calculateExtentFromFeatures(), and getFeatures().
int QgsGml::mFeatureCount [private] |
Definition at line 188 of file qgsgml.h.
Referenced by endElement(), and startElement().
QMap<QgsFeatureId, QgsFeature* > QgsGml::mFeatures [private] |
The features of the layer, map of feature maps for each feature type.
Definition at line 167 of file qgsgml.h.
Referenced by calculateExtentFromFeatures(), and endElement().
bool QgsGml::mFinished [private] |
True if the request is finished.
Definition at line 180 of file qgsgml.h.
Referenced by getFeatures(), and setFinished().
QString QgsGml::mGeometryAttribute [private] |
Name of geometry attribute.
Definition at line 175 of file qgsgml.h.
Referenced by endElement(), and startElement().
QMap<QgsFeatureId, QString > QgsGml::mIdMap [private] |
Stores the relation between provider ids and WFS server ids.
Definition at line 172 of file qgsgml.h.
Referenced by endElement().
QStack<ParseMode> QgsGml::mParseModeStack [private] |
Keep track about the most important nested elements.
Definition at line 182 of file qgsgml.h.
Referenced by characters(), endElement(), and startElement().
QString QgsGml::mStringCash [private] |
This contains the character data if an important element has been encountered.
Definition at line 184 of file qgsgml.h.
Referenced by characters(), endElement(), and startElement().
QMap<QString, QPair<int, QgsField> > QgsGml::mThematicAttributes [private] |
Definition at line 177 of file qgsgml.h.
Referenced by endElement(), QgsGml(), and startElement().
QString QgsGml::mTupleSeparator [private] |
Tuple separator for coordinate strings.
Usually " "
Definition at line 203 of file qgsgml.h.
Referenced by pointsFromCoordinateString(), and startElement().
QString QgsGml::mTypeName [private] |
Definition at line 160 of file qgsgml.h.
Referenced by endElement(), getFeatures(), QgsGml(), and startElement().
QString QgsGml::mUri [private] |
Definition at line 161 of file qgsgml.h.
Referenced by getFeatures().
QGis::WkbType* QgsGml::mWkbType [private] |
Definition at line 178 of file qgsgml.h.
Referenced by createMultiLineFromFragments(), createMultiPointFromFragments(), createMultiPolygonFromFragments(), createPolygonFromFragments(), endElement(), and getFeatures().