QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
QgsGmlSchema Class Reference

#include <qgsgmlschema.h>

Collaboration diagram for QgsGmlSchema:
Collaboration graph
[legend]

Public Member Functions

 QgsGmlSchema ()
 ~QgsGmlSchema ()
bool parseXSD (const QByteArray &xml)
 Get fields info from XSD.
bool guessSchema (const QByteArray &data)
 Guess GML schema from data if XSD does not exist.
QStringList typeNames () const
 Get list of dot separated paths to feature classes parsed from GML or XSD.
QList< QgsFieldfields (const QString &typeName)
 Get fields for type/class name parsed from GML or XSD.
QStringList geometryAttributes (const QString &typeName)
 Get list of geometry attributes for type/class name.
QgsError error () const
 Get error if parseXSD() or guessSchema() failed.

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.
void endElement (const XML_Char *el)
void characters (const XML_Char *chars, int len)
QString readAttribute (const QString &attributeName, const XML_Char **attr) const
 Reads attribute as string.
QWidget * findMainWindow () const
 Returns pointer to main window or 0 if it does not exist.
QList< QDomElement > domElements (const QDomElement &element, const QString &path)
 Get dom elements by path.
QDomElement domElement (const QDomElement &element, const QString &path)
 Get dom element by path.
QList< QDomElement > domElements (QList< QDomElement > &elements, const QString &attr, const QString &attrVal)
 Filter list of elements by attribute value.
QDomElement domElement (const QDomElement &element, const QString &path, const QString &attr, const QString &attrVal)
 Get dom element by path and attribute value.
QString stripNS (const QString &name)
 Strip namespace from element name.
QString xsdComplexTypeGmlBaseType (const QDomElement &element, const QString &name)
 Find GML base type for complex type of given name.
bool xsdFeatureClass (const QDomElement &element, const QString &typeName, QgsGmlFeatureClass &featureClass)
 Get feature class information from complex type recursively.
ParseMode modeStackTop ()
 Get safely (if empty) top from mode stack.
ParseMode modeStackPop ()
 Safely (if empty) pop from mode stack.

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< ParseModemParseModeStack
 Keep track about the most important nested elements.
QString mStringCash
 This contains the character data if an important element has been encountered.
QgsFeaturemCurrentFeature
QString mCurrentFeatureId
int mFeatureCount
QString mAttributeName
QString mCoordinateSeparator
 Coordinate separator for coordinate strings.
QString mTupleSeparator
 Tuple separator for coordinate strings.
int mLevel
 Depth level, root element is 0.
int mSkipLevel
 Skip all levels under this.
QStringList mParsePathStack
 Path to current level.
QString mCurrentFeatureName
QStringList mGeometryTypes
QMap< QString, QgsGmlFeatureClassmFeatureClassMap
QgsError mError

Detailed Description

Definition at line 75 of file qgsgmlschema.h.

Member Enumeration Documentation

Enumerator:
none 
boundingBox 
featureMembers 
featureMember 
feature 
attribute 
geometry 

Definition at line 107 of file qgsgmlschema.h.

Constructor & Destructor Documentation

QgsGmlSchema::QgsGmlSchema ( )

Definition at line 60 of file qgsgmlschema.cpp.

References mGeometryTypes.

QgsGmlSchema::~QgsGmlSchema ( )

Definition at line 68 of file qgsgmlschema.cpp.

Member Function Documentation

void QgsGmlSchema::characters ( const XML_Char *  chars,
int  len 
)
private

Definition at line 518 of file qgsgmlschema.cpp.

References attribute, mLevel, modeStackTop(), mSkipLevel, and mStringCash.

static void QgsGmlSchema::chars ( void *  data,
const XML_Char *  chars,
int  len 
)
inlinestaticprivate

Definition at line 130 of file qgsgmlschema.h.

Referenced by guessSchema().

QDomElement QgsGmlSchema::domElement ( const QDomElement &  element,
const QString &  path 
)
private

Get dom element by path.

Definition at line 307 of file qgsgmlschema.cpp.

References domElements().

Referenced by xsdComplexTypeGmlBaseType(), and xsdFeatureClass().

QDomElement QgsGmlSchema::domElement ( const QDomElement &  element,
const QString &  path,
const QString &  attr,
const QString &  attrVal 
)
private

Get dom element by path and attribute value.

Definition at line 325 of file qgsgmlschema.cpp.

References domElements().

QList< QDomElement > QgsGmlSchema::domElements ( const QDomElement &  element,
const QString &  path 
)
private

Get dom elements by path.

Definition at line 273 of file qgsgmlschema.cpp.

References stripNS().

Referenced by domElement(), parseXSD(), and xsdFeatureClass().

QList< QDomElement > QgsGmlSchema::domElements ( QList< QDomElement > &  elements,
const QString &  attr,
const QString &  attrVal 
)
private

Filter list of elements by attribute value.

Definition at line 312 of file qgsgmlschema.cpp.

static void QgsGmlSchema::end ( void *  data,
const XML_Char *  el 
)
inlinestaticprivate

Definition at line 126 of file qgsgmlschema.h.

Referenced by guessSchema().

void QgsGmlSchema::endElement ( const XML_Char *  el)
private
QgsError QgsGmlSchema::error ( ) const
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 539 of file qgsgmlschema.cpp.

References mFeatureClassMap.

Referenced by endElement().

QWidget* QgsGmlSchema::findMainWindow ( ) const
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 545 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.

Parameters
dataGML data
Returns
true in case of success

Definition at line 331 of file qgsgmlschema.cpp.

References QgsError::append(), chars(), end(), MathUtils::max(), mError, mLevel, mSkipLevel, NS_SEPARATOR, QgsDebugMsg, start(), and tr.

ParseMode QgsGmlSchema::modeStackPop ( )
inlineprivate

Safely (if empty) pop from mode stack.

Definition at line 174 of file qgsgmlschema.h.

Referenced by endElement().

ParseMode QgsGmlSchema::modeStackTop ( )
inlineprivate

Get safely (if empty) top from mode stack.

Definition at line 171 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().

QString QgsGmlSchema::readAttribute ( const QString &  attributeName,
const XML_Char **  attr 
) const
private

Reads attribute as string.

Returns
attribute value or an empty string if no such attribute

Definition at line 73 of file qgsgmlschema.cpp.

static void QgsGmlSchema::start ( void *  data,
const XML_Char *  el,
const XML_Char **  attr 
)
inlinestaticprivate

Definition at line 122 of file qgsgmlschema.h.

Referenced by guessSchema().

void QgsGmlSchema::startElement ( const XML_Char *  el,
const XML_Char **  attr 
)
private
QString QgsGmlSchema::stripNS ( const QString &  name)
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 534 of file qgsgmlschema.cpp.

References mFeatureClassMap.

QString QgsGmlSchema::xsdComplexTypeGmlBaseType ( const QDomElement &  element,
const QString &  name 
)
private

Find GML base type for complex type of given name.

Parameters
elementinput element
namecomplex type name
Returns
name of GML base type without NS, e.g. AbstractFeatureType or empty string if not passed on GML type

Definition at line 245 of file qgsgmlschema.cpp.

References domElement(), and stripNS().

Referenced by parseXSD().

bool QgsGmlSchema::xsdFeatureClass ( const QDomElement &  element,
const QString &  typeName,
QgsGmlFeatureClass featureClass 
)
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().

Member Data Documentation

QString QgsGmlSchema::mAttributeName
private

Definition at line 184 of file qgsgmlschema.h.

Referenced by endElement(), and startElement().

QString QgsGmlSchema::mCoordinateSeparator
private

Coordinate separator for coordinate strings.

Usually ","

Definition at line 186 of file qgsgmlschema.h.

QgsFeature* QgsGmlSchema::mCurrentFeature
private

Definition at line 181 of file qgsgmlschema.h.

QString QgsGmlSchema::mCurrentFeatureId
private

Definition at line 182 of file qgsgmlschema.h.

QString QgsGmlSchema::mCurrentFeatureName
private

Definition at line 201 of file qgsgmlschema.h.

Referenced by endElement(), and startElement().

QgsError QgsGmlSchema::mError
private

Definition at line 210 of file qgsgmlschema.h.

Referenced by guessSchema().

QMap<QString, QgsGmlFeatureClass> QgsGmlSchema::mFeatureClassMap
private
int QgsGmlSchema::mFeatureCount
private

Definition at line 183 of file qgsgmlschema.h.

QStringList QgsGmlSchema::mGeometryTypes
private

Definition at line 204 of file qgsgmlschema.h.

Referenced by QgsGmlSchema(), startElement(), and xsdFeatureClass().

int QgsGmlSchema::mLevel
private

Depth level, root element is 0.

Definition at line 193 of file qgsgmlschema.h.

Referenced by characters(), endElement(), guessSchema(), and startElement().

QStack<ParseMode> QgsGmlSchema::mParseModeStack
private

Keep track about the most important nested elements.

Definition at line 178 of file qgsgmlschema.h.

Referenced by startElement().

QStringList QgsGmlSchema::mParsePathStack
private

Path to current level.

Definition at line 199 of file qgsgmlschema.h.

Referenced by endElement(), and startElement().

int QgsGmlSchema::mSkipLevel
private

Skip all levels under this.

Definition at line 196 of file qgsgmlschema.h.

Referenced by characters(), endElement(), guessSchema(), and startElement().

QString QgsGmlSchema::mStringCash
private

This contains the character data if an important element has been encountered.

Definition at line 180 of file qgsgmlschema.h.

Referenced by characters(), endElement(), and startElement().

QString QgsGmlSchema::mTupleSeparator
private

Tuple separator for coordinate strings.

Usually " "

Definition at line 188 of file qgsgmlschema.h.


The documentation for this class was generated from the following files: