Quantum GIS API Documentation  master-7dce617
QgsWFSData Class Reference

This class reads data from a WFS server or alternatively from a GML file. More...

#include <qgswfsdata.h>

+ Collaboration diagram for QgsWFSData:

List of all members.

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
QgsFeaturemCurrentFeature
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
QgsRectanglemExtent
 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< parseModemParseModeStack
 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::WkbTypemWkbType

Detailed Description

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.


Member Enumeration Documentation

enum QgsWFSData::parseMode [private]
Enumerator:
boundingBox 
featureMember 
attribute 
geometry 
coordinate 
point 
line 
polygon 
multiPoint 
multiLine 
multiPolygon 

Definition at line 74 of file qgswfsdata.h.


Constructor & Destructor Documentation

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.

Parameters:
urirequest uri
extentthe extent of the WFS layer
featuresthe 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]

Member Function Documentation

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.

Returns:
0 in case of success

Definition at line 516 of file qgswfsdata.cpp.

References pointsFromCoordinateString(), and QgsRectangle::set().

Referenced by endElement().

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().

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().

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().

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.

Parameters:
pointslist that will contain the created points
coordStringthe text containing the coordinates
Returns:
0 in case of success

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.

Parameters:
attributeName
attr
Returns:
attribute value or an empty string if no such attribute

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:...".

Parameters:
epsgNrresult
attrattribute strings
Returns:
0 in case of success

Definition at line 471 of file qgswfsdata.cpp.

Referenced by startElement().

void QgsWFSData::setFinished ( ) [private, slot]

Definition at line 143 of file qgswfsdata.cpp.

References mFinished.

Referenced by getWFSData().

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::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().


Member Data Documentation

QString QgsWFSData::mAttributeName [private]

Definition at line 176 of file qgswfsdata.h.

Referenced by endElement(), and startElement().

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.

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().

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().

Bounding box of the layer.

Definition at line 149 of file qgswfsdata.h.

Referenced by endElement(), and getWFSData().

Definition at line 167 of file qgswfsdata.h.

Referenced by endElement(), and startElement().

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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines