18 #include "qgis_core.h"
28 #include <QDomElement>
29 #include <QStringList>
81 } AxisOrientationLogic;
85 const QString &geometryAttribute,
87 AxisOrientationLogic axisOrientationLogic = Honour_EPSG_if_urn,
88 bool invertAxisOrientation =
false );
93 const QMap< QString, QPair<QString, QString> > &mapFieldNameToSrcLayerNameFieldName,
94 AxisOrientationLogic axisOrientationLogic = Honour_EPSG_if_urn,
95 bool invertAxisOrientation =
false );
107 bool processData(
const QByteArray &data,
bool atEnd, QString &errorMsg );
113 bool processData(
const QByteArray &data,
bool atEnd );
121 QVector<QgsGmlFeaturePtrGmlIdPair> getAndStealReadyFeatures();
176 void startElement(
const XML_Char *el,
const XML_Char **attr );
177 void endElement(
const XML_Char *el );
178 void characters(
const XML_Char *chars,
int len );
179 static void start(
void *data,
const XML_Char *el,
const XML_Char **attr )
183 static void end(
void *data,
const XML_Char *el )
187 static void chars(
void *data,
const XML_Char *chars,
int len )
193 void setAttribute(
const QString &name,
const QString &value );
203 int readEpsgFromAttribute(
int &epsgNr,
const XML_Char **attr );
211 QString readAttribute(
const QString &attributeName,
const XML_Char **attr )
const;
213 bool createBBoxFromCoordinateString(
QgsRectangle &bb,
const QString &coordString )
const;
221 int pointsFromCoordinateString( QList<QgsPointXY> &points,
const QString &coordString )
const;
230 int pointsFromPosListString( QList<QgsPointXY> &points,
const QString &coordString,
int dimension )
const;
232 int pointsFromString( QList<QgsPointXY> &points,
const QString &coordString )
const;
234 int getLineWKB(
QgsWkbPtr &wkbPtr,
const QList<QgsPointXY> &lineCoordinates )
const;
235 int getRingWKB(
QgsWkbPtr &wkbPtr,
const QList<QgsPointXY> &ringCoordinates )
const;
243 int createMultiLineFromFragments();
244 int createMultiPointFromFragments();
245 int createPolygonFromFragments();
246 int createMultiPolygonFromFragments();
248 int totalWKBFragmentSize()
const;
251 ParseMode modeStackTop() {
return mParseModeStack.isEmpty() ?
None : mParseModeStack.top(); }
254 ParseMode modeStackPop() {
return mParseModeStack.isEmpty() ?
None : mParseModeStack.pop(); }
260 QVector<QgsGmlFeaturePtrGmlIdPair> mFeatureList;
263 QList<LayerProperties> mLayerProperties;
264 QMap< QString, LayerProperties > mMapTypeNameToProperties;
268 QByteArray mTypeNameBA;
269 const char *mTypeNamePtr =
nullptr;
270 size_t mTypeNameUTF8Len;
277 QString mGeometryAttribute;
278 QByteArray mGeometryAttributeBA;
279 const char *mGeometryAttributePtr =
nullptr;
280 size_t mGeometryAttributeUTF8Len;
283 QMap<QString, QPair<int, QgsField> > mThematicAttributes;
286 QString mExceptionText;
287 bool mTruncatedResponse;
290 int mFeatureTupleDepth;
291 QString mCurrentTypename;
293 QStack<ParseMode> mParseModeStack;
297 QVector<QVariant> mCurrentAttributes;
298 QString mCurrentFeatureId;
303 bool mBoundedByNullFound;
311 QList< QList<QgsWkbPtr> > mCurrentWKBFragments;
312 QString mAttributeName;
315 QString mCoordinateSeparator;
317 QString mTupleSeparator;
319 QStack<int> mDimensionStack;
331 QString mGMLNameSpaceURI;
332 const char *mGMLNameSpaceURIPtr =
nullptr;
334 AxisOrientationLogic mAxisOrientationLogic;
336 bool mInvertAxisOrientationRequest;
338 bool mInvertAxisOrientation;
344 std::string mGeometryString;
346 bool mFoundUnhandledGeometryElement;
360 class CORE_EXPORT
QgsGml :
public QObject
366 const QString &geometryAttribute,
381 int getFeatures(
const QString &uri,
384 const QString &userName = QString(),
385 const QString &password = QString(),
386 const QString &authcfg = QString() )
SIP_PYNAME( getFeaturesUri );
395 QMap<QgsFeatureId, QgsFeature * >
featuresMap()
const {
return mFeatures; }
398 QMap<QgsFeatureId, QString >
idsMap()
const {
return mIdMap; }
417 void handleProgressEvent( qint64 progress, qint64 totalSteps );
427 void calculateExtentFromFeatures();
429 void fillMapsFromParser();
441 QMap<QgsFeatureId, QgsFeature * > mFeatures;
446 QMap<QgsFeatureId, QString > mIdMap;
This class represents a coordinate reference system (CRS).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Container of fields for a vector layer.
QString mGeometryAttribute
Geometry attribute name.
LayerProperties()=default
Constructor.
This class builds features from GML data in a streaming way.
QgsWkbTypes::Type wkbType() const
Returns the geometry type.
QPair< QgsFeature *, QString > QgsGmlFeaturePtrGmlIdPair
bool isException() const
Returns whether the document parser is a OGC exception.
int numberReturned() const
Returns WFS 2.0 "numberReturned" or WFS 1.1 "numberOfFeatures" attribute, or -1 if invalid/not found.
@ Ignore_EPSG
Ignore EPSG axis order.
@ Honour_EPSG
Honour EPSG axis order.
@ Honour_EPSG_if_urn
Honour EPSG axis order only if srsName is of the form urn:ogc:def:crs:EPSG:
QgsGmlStreamingParser & operator=(const QgsGmlStreamingParser &other)=delete
QgsGmlStreamingParser cannot be copied.
int numberMatched() const
Returns WFS 2.0 "numberMatched" attribute, or -1 if invalid/not found.
QgsGmlStreamingParser(const QgsGmlStreamingParser &other)=delete
QgsGmlStreamingParser cannot be copied.
bool isTruncatedResponse() const
Returns whether a "truncatedResponse" element is found.
QString exceptionText() const
Returns the exception text.
int getEPSGCode() const
Returns the EPSG code, or 0 if unknown.
const QgsRectangle & layerExtent() const
Returns layer bounding box.
QString srsName() const
Returns the value of the srsName attribute.
This class reads data from a WFS server or alternatively from a GML file.
QMap< QgsFeatureId, QgsFeature * > featuresMap() const
Gets parsed features for given type name.
void totalStepsUpdate(int totalSteps)
void dataReadProgress(int progress)
QMap< QgsFeatureId, QString > idsMap() const
Gets feature ids map.
void dataProgressAndSteps(int progress, int totalSteps)
Also emit signal with progress and totalSteps together (this is better for the status message)
A class to represent a 2D point.
A rectangle specified with double values.
Type
The WKB type describes the number of dimensions a geometry has.
const QgsCoordinateReferenceSystem & crs