18 #include "qgis_core.h"
28 #include <QDomElement>
29 #include <QStringList>
82 } AxisOrientationLogic;
86 const QString &geometryAttribute,
88 AxisOrientationLogic axisOrientationLogic = Honour_EPSG_if_urn,
89 bool invertAxisOrientation =
false );
94 const QMap< QString, QPair<QString, QString> > &mapFieldNameToSrcLayerNameFieldName,
95 AxisOrientationLogic axisOrientationLogic = Honour_EPSG_if_urn,
96 bool invertAxisOrientation =
false );
108 bool processData(
const QByteArray &data,
bool atEnd, QString &errorMsg );
114 bool processData(
const QByteArray &data,
bool atEnd );
122 QVector<QgsGmlFeaturePtrGmlIdPair> getAndStealReadyFeatures();
177 void startElement(
const XML_Char *el,
const XML_Char **attr );
178 void endElement(
const XML_Char *el );
179 void characters(
const XML_Char *chars,
int len );
180 static void start(
void *data,
const XML_Char *el,
const XML_Char **attr )
184 static void end(
void *data,
const XML_Char *el )
188 static void chars(
void *data,
const XML_Char *chars,
int len )
194 void setAttribute(
const QString &name,
const QString &value );
204 int readEpsgFromAttribute(
int &epsgNr,
const XML_Char **attr );
212 QString readAttribute(
const QString &attributeName,
const XML_Char **attr )
const;
214 bool createBBoxFromCoordinateString(
QgsRectangle &bb,
const QString &coordString )
const;
222 int pointsFromCoordinateString( QList<QgsPointXY> &points,
const QString &coordString )
const;
231 int pointsFromPosListString( QList<QgsPointXY> &points,
const QString &coordString,
int dimension )
const;
233 int pointsFromString( QList<QgsPointXY> &points,
const QString &coordString )
const;
235 int getLineWKB(
QgsWkbPtr &wkbPtr,
const QList<QgsPointXY> &lineCoordinates )
const;
236 int getRingWKB(
QgsWkbPtr &wkbPtr,
const QList<QgsPointXY> &ringCoordinates )
const;
244 int createMultiLineFromFragments();
245 int createMultiPointFromFragments();
246 int createPolygonFromFragments();
247 int createMultiPolygonFromFragments();
249 int totalWKBFragmentSize()
const;
252 ParseMode modeStackTop() {
return mParseModeStack.isEmpty() ?
None : mParseModeStack.top(); }
255 ParseMode modeStackPop() {
return mParseModeStack.isEmpty() ?
None : mParseModeStack.pop(); }
258 void createParser(
const QByteArray &encoding = QByteArray() );
261 XML_Parser mParser =
nullptr;
264 QVector<QgsGmlFeaturePtrGmlIdPair> mFeatureList;
267 QList<LayerProperties> mLayerProperties;
268 QMap< QString, LayerProperties > mMapTypeNameToProperties;
272 QByteArray mTypeNameBA;
273 const char *mTypeNamePtr =
nullptr;
274 size_t mTypeNameUTF8Len;
281 QString mGeometryAttribute;
282 QByteArray mGeometryAttributeBA;
283 const char *mGeometryAttributePtr =
nullptr;
284 size_t mGeometryAttributeUTF8Len;
287 QMap<QString, QPair<int, QgsField> > mThematicAttributes;
290 QString mExceptionText;
291 bool mTruncatedResponse;
294 int mFeatureTupleDepth;
295 QString mCurrentTypename;
297 QStack<ParseMode> mParseModeStack;
301 QVector<QVariant> mCurrentAttributes;
302 QString mCurrentFeatureId;
307 bool mBoundedByNullFound;
315 QList< QList<QgsWkbPtr> > mCurrentWKBFragments;
316 QString mAttributeName;
319 QString mCoordinateSeparator;
321 QString mTupleSeparator;
323 QStack<int> mDimensionStack;
335 QString mGMLNameSpaceURI;
336 const char *mGMLNameSpaceURIPtr =
nullptr;
338 AxisOrientationLogic mAxisOrientationLogic;
340 bool mInvertAxisOrientationRequest;
342 bool mInvertAxisOrientation;
348 std::string mGeometryString;
350 bool mFoundUnhandledGeometryElement;
352 QTextCodec *mCodec =
nullptr;
366 class CORE_EXPORT
QgsGml :
public QObject
372 const QString &geometryAttribute,
386 int getFeatures(
const QString &uri,
389 const QString &userName = QString(),
390 const QString &password = QString(),
391 const QString &authcfg = QString() )
SIP_PYNAME( getFeaturesUri );
399 QMap<QgsFeatureId, QgsFeature * >
featuresMap()
const {
return mFeatures; }
402 QMap<QgsFeatureId, QString >
idsMap()
const {
return mIdMap; }
421 void handleProgressEvent( qint64 progress, qint64 totalSteps );
431 void calculateExtentFromFeatures();
433 void fillMapsFromParser();
445 QMap<QgsFeatureId, QgsFeature * > mFeatures;
450 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