QGIS API Documentation
2.4.0-Chugiak
|
#include <qgsgmlschema.h>
Public Member Functions | |
QgsGmlSchema () | |
~QgsGmlSchema () | |
bool | parseXSD (const QByteArray &xml) |
Get fields info from XSD. More... | |
bool | guessSchema (const QByteArray &data) |
Guess GML schema from data if XSD does not exist. More... | |
QStringList | typeNames () const |
Get list of dot separated paths to feature classes parsed from GML or XSD. More... | |
QList< QgsField > | fields (const QString &typeName) |
Get fields for type/class name parsed from GML or XSD. More... | |
QStringList | geometryAttributes (const QString &typeName) |
Get list of geometry attributes for type/class name. More... | |
QgsError | error () const |
Get error if parseXSD() or guessSchema() failed. More... | |
Private Types | |
enum | ParseMode { none, boundingBox, featureMembers, featureMember, feature, attribute, geometry } |
Private Member Functions | |
void | startElement (const XML_Char *el, const XML_Char **attr) |
XML handler methods. More... | |
void | endElement (const XML_Char *el) |
void | characters (const XML_Char *chars, int len) |
void | addAttribute (const QString &name, const QString &value) |
QString | readAttribute (const QString &attributeName, const XML_Char **attr) const |
Reads attribute as string. More... | |
QWidget * | findMainWindow () const |
Returns pointer to main window or 0 if it does not exist. More... | |
QList< QDomElement > | domElements (const QDomElement &element, const QString &path) |
Get dom elements by path. More... | |
QDomElement | domElement (const QDomElement &element, const QString &path) |
Get dom element by path. More... | |
QList< QDomElement > | domElements (QList< QDomElement > &elements, const QString &attr, const QString &attrVal) |
Filter list of elements by attribute value. More... | |
QDomElement | domElement (const QDomElement &element, const QString &path, const QString &attr, const QString &attrVal) |
Get dom element by path and attribute value. More... | |
QString | stripNS (const QString &name) |
Strip namespace from element name. More... | |
QString | xsdComplexTypeGmlBaseType (const QDomElement &element, const QString &name) |
Find GML base type for complex type of given name. More... | |
bool | xsdFeatureClass (const QDomElement &element, const QString &typeName, QgsGmlFeatureClass &featureClass) |
Get feature class information from complex type recursively. More... | |
ParseMode | modeStackTop () |
Get safely (if empty) top from mode stack. More... | |
ParseMode | modeStackPop () |
Safely (if empty) pop from mode stack. More... | |
Static Private Member Functions | |
static void | start (void *data, const XML_Char *el, const XML_Char **attr) |
static void | end (void *data, const XML_Char *el) |
static void | chars (void *data, const XML_Char *chars, int len) |
Private Attributes | |
QStack< ParseMode > | mParseModeStack |
Keep track about the most important nested elements. More... | |
QString | mStringCash |
This contains the character data if an important element has been encountered. More... | |
QgsFeature * | mCurrentFeature |
QString | mCurrentFeatureId |
int | mFeatureCount |
QString | mAttributeName |
QString | mCoordinateSeparator |
Coordinate separator for coordinate strings. More... | |
QString | mTupleSeparator |
Tuple separator for coordinate strings. More... | |
int | mLevel |
Depth level, root element is 0. More... | |
int | mSkipLevel |
Skip all levels under this. More... | |
QStringList | mParsePathStack |
Path to current level. More... | |
QString | mCurrentFeatureName |
QStringList | mGeometryTypes |
QMap< QString, QgsGmlFeatureClass > | mFeatureClassMap |
QgsError | mError |
Definition at line 75 of file qgsgmlschema.h.
|
private |
Enumerator | |
---|---|
none | |
boundingBox | |
featureMembers | |
featureMember | |
feature | |
attribute | |
geometry |
Definition at line 107 of file qgsgmlschema.h.
QgsGmlSchema::QgsGmlSchema | ( | ) |
Definition at line 60 of file qgsgmlschema.cpp.
References mGeometryTypes.
QgsGmlSchema::~QgsGmlSchema | ( | ) |
Definition at line 68 of file qgsgmlschema.cpp.
|
private |
Definition at line 522 of file qgsgmlschema.cpp.
References fields(), mCurrentFeatureName, mFeatureClassMap, QgsField::setType(), and QgsField::type().
Referenced by endElement(), and startElement().
|
private |
Definition at line 506 of file qgsgmlschema.cpp.
References attribute, mLevel, modeStackTop(), mSkipLevel, and mStringCash.
|
inlinestaticprivate |
Definition at line 130 of file qgsgmlschema.h.
Referenced by guessSchema().
|
private |
Get dom element by path.
Definition at line 307 of file qgsgmlschema.cpp.
References domElements().
Referenced by xsdComplexTypeGmlBaseType(), and xsdFeatureClass().
|
private |
Get dom element by path and attribute value.
Definition at line 325 of file qgsgmlschema.cpp.
References domElements().
|
private |
Get dom elements by path.
Definition at line 273 of file qgsgmlschema.cpp.
References stripNS().
Referenced by domElement(), parseXSD(), and xsdFeatureClass().
|
private |
Filter list of elements by attribute value.
Definition at line 312 of file qgsgmlschema.cpp.
|
inlinestaticprivate |
Definition at line 126 of file qgsgmlschema.h.
Referenced by guessSchema().
|
private |
Definition at line 456 of file qgsgmlschema.cpp.
References addAttribute(), attribute, featureMembers, geometryAttributes(), GML_NAMESPACE, mAttributeName, MathUtils::max(), mCurrentFeatureName, mFeatureClassMap, mLevel, modeStackPop(), modeStackTop(), mParsePathStack, mSkipLevel, mStringCash, NS_SEPARATOR, and QgsDebugMsgLevel.
|
inline |
Get error if parseXSD() or guessSchema() failed.
Definition at line 103 of file qgsgmlschema.h.
QList< QgsField > QgsGmlSchema::fields | ( | const QString & | typeName | ) |
Get fields for type/class name parsed from GML or XSD.
Definition at line 566 of file qgsgmlschema.cpp.
References mFeatureClassMap.
Referenced by addAttribute().
|
private |
Returns pointer to main window or 0 if it does not exist.
QStringList QgsGmlSchema::geometryAttributes | ( | const QString & | typeName | ) |
Get list of geometry attributes for type/class name.
Definition at line 572 of file qgsgmlschema.cpp.
References mFeatureClassMap.
Referenced by endElement(), and startElement().
bool QgsGmlSchema::guessSchema | ( | const QByteArray & | data | ) |
Guess GML schema from data if XSD does not exist.
Currently only recognizes UMN Mapserver GetFeatureInfo GML response. Supports only UTF-8, UTF-16, ISO-8859-1, US-ASCII XML encodings.
data | GML data |
Definition at line 331 of file qgsgmlschema.cpp.
References QgsError::append(), chars(), end(), MathUtils::max(), mError, mLevel, mSkipLevel, NS_SEPARATOR, QgsDebugMsg, start(), and tr.
|
inlineprivate |
Safely (if empty) pop from mode stack.
Definition at line 176 of file qgsgmlschema.h.
Referenced by endElement().
|
inlineprivate |
Get safely (if empty) top from mode stack.
Definition at line 173 of file qgsgmlschema.h.
Referenced by characters(), endElement(), and startElement().
bool QgsGmlSchema::parseXSD | ( | const QByteArray & | xml | ) |
Get fields info from XSD.
Definition at line 87 of file qgsgmlschema.cpp.
References domElements(), mFeatureClassMap, stripNS(), xsdComplexTypeGmlBaseType(), and xsdFeatureClass().
|
private |
Reads attribute as string.
Definition at line 73 of file qgsgmlschema.cpp.
Referenced by startElement().
|
inlinestaticprivate |
Definition at line 122 of file qgsgmlschema.h.
Referenced by guessSchema().
|
private |
XML handler methods.
Definition at line 354 of file qgsgmlschema.cpp.
References addAttribute(), attribute, feature, featureMember, featureMembers, geometryAttributes(), GML_NAMESPACE, mAttributeName, mCurrentFeatureName, mFeatureClassMap, mGeometryTypes, mLevel, modeStackTop(), mParseModeStack, mParsePathStack, mSkipLevel, mStringCash, NS_SEPARATOR, QgsDebugMsg, QgsDebugMsgLevel, and readAttribute().
|
private |
Strip namespace from element name.
Definition at line 268 of file qgsgmlschema.cpp.
Referenced by domElements(), parseXSD(), xsdComplexTypeGmlBaseType(), and xsdFeatureClass().
QStringList QgsGmlSchema::typeNames | ( | ) | const |
Get list of dot separated paths to feature classes parsed from GML or XSD.
Definition at line 561 of file qgsgmlschema.cpp.
References mFeatureClassMap.
|
private |
Find GML base type for complex type of given name.
element | input element |
name | complex type name |
Definition at line 245 of file qgsgmlschema.cpp.
References domElement(), and stripNS().
Referenced by parseXSD().
|
private |
Get feature class information from complex type recursively.
Definition at line 130 of file qgsgmlschema.cpp.
References domElement(), domElements(), QgsGmlFeatureClass::fields(), QgsGmlFeatureClass::geometryAttributes(), mGeometryTypes, QgsDebugMsg, and stripNS().
Referenced by parseXSD().
|
private |
Definition at line 186 of file qgsgmlschema.h.
Referenced by endElement(), and startElement().
|
private |
Coordinate separator for coordinate strings.
Usually ","
Definition at line 188 of file qgsgmlschema.h.
|
private |
Definition at line 183 of file qgsgmlschema.h.
|
private |
Definition at line 184 of file qgsgmlschema.h.
|
private |
Definition at line 203 of file qgsgmlschema.h.
Referenced by addAttribute(), endElement(), and startElement().
|
private |
Definition at line 212 of file qgsgmlschema.h.
Referenced by guessSchema().
|
private |
Definition at line 209 of file qgsgmlschema.h.
Referenced by addAttribute(), endElement(), fields(), geometryAttributes(), parseXSD(), startElement(), and typeNames().
|
private |
Definition at line 185 of file qgsgmlschema.h.
|
private |
Definition at line 206 of file qgsgmlschema.h.
Referenced by QgsGmlSchema(), startElement(), and xsdFeatureClass().
|
private |
Depth level, root element is 0.
Definition at line 195 of file qgsgmlschema.h.
Referenced by characters(), endElement(), guessSchema(), and startElement().
|
private |
Keep track about the most important nested elements.
Definition at line 180 of file qgsgmlschema.h.
Referenced by startElement().
|
private |
Path to current level.
Definition at line 201 of file qgsgmlschema.h.
Referenced by endElement(), and startElement().
|
private |
Skip all levels under this.
Definition at line 198 of file qgsgmlschema.h.
Referenced by characters(), endElement(), guessSchema(), and startElement().
|
private |
This contains the character data if an important element has been encountered.
Definition at line 182 of file qgsgmlschema.h.
Referenced by characters(), endElement(), and startElement().
|
private |