18 #include "qgis_core.h" 28 #include <QDomElement> 29 #include <QStringList> 83 const QString &geometryAttribute,
85 AxisOrientationLogic axisOrientationLogic = Honour_EPSG_if_urn,
86 bool invertAxisOrientation =
false );
91 const QMap< QString, QPair<QString, QString> > &mapFieldNameToSrcLayerNameFieldName,
92 AxisOrientationLogic axisOrientationLogic = Honour_EPSG_if_urn,
93 bool invertAxisOrientation =
false );
104 bool processData(
const QByteArray &data,
bool atEnd, QString &errorMsg );
109 bool processData(
const QByteArray &data,
bool atEnd );
116 QVector<QgsGmlFeaturePtrGmlIdPair> getAndStealReadyFeatures();
171 void startElement(
const XML_Char *el,
const XML_Char **attr );
172 void endElement(
const XML_Char *el );
173 void characters(
const XML_Char *chars,
int len );
174 static void start(
void *data,
const XML_Char *el,
const XML_Char **attr )
178 static void end(
void *data,
const XML_Char *el )
182 static void chars(
void *data,
const XML_Char *chars,
int len )
188 void setAttribute(
const QString &name,
const QString &value );
198 int readEpsgFromAttribute(
int &epsgNr,
const XML_Char **attr );
206 QString readAttribute(
const QString &attributeName,
const XML_Char **attr )
const;
208 bool createBBoxFromCoordinateString(
QgsRectangle &bb,
const QString &coordString )
const;
216 int pointsFromCoordinateString( QList<QgsPointXY> &points,
const QString &coordString )
const;
225 int pointsFromPosListString( QList<QgsPointXY> &points,
const QString &coordString,
int dimension )
const;
227 int pointsFromString( QList<QgsPointXY> &points,
const QString &coordString )
const;
229 int getLineWKB(
QgsWkbPtr &wkbPtr,
const QList<QgsPointXY> &lineCoordinates )
const;
230 int getRingWKB(
QgsWkbPtr &wkbPtr,
const QList<QgsPointXY> &ringCoordinates )
const;
238 int createMultiLineFromFragments();
239 int createMultiPointFromFragments();
240 int createPolygonFromFragments();
241 int createMultiPolygonFromFragments();
243 int totalWKBFragmentSize()
const;
246 ParseMode modeStackTop() {
return mParseModeStack.isEmpty() ? None : mParseModeStack.top(); }
249 ParseMode modeStackPop() {
return mParseModeStack.isEmpty() ? None : mParseModeStack.pop(); }
255 QVector<QgsGmlFeaturePtrGmlIdPair> mFeatureList;
258 QList<LayerProperties> mLayerProperties;
259 QMap< QString, LayerProperties > mMapTypeNameToProperties;
263 QByteArray mTypeNameBA;
264 const char *mTypeNamePtr =
nullptr;
265 size_t mTypeNameUTF8Len;
272 QString mGeometryAttribute;
273 QByteArray mGeometryAttributeBA;
274 const char *mGeometryAttributePtr =
nullptr;
275 size_t mGeometryAttributeUTF8Len;
278 QMap<QString, QPair<int, QgsField> > mThematicAttributes;
281 QString mExceptionText;
282 bool mTruncatedResponse;
285 int mFeatureTupleDepth;
286 QString mCurrentTypename;
287 QStack<ParseMode> mParseModeStack;
292 QVector<QVariant> mCurrentAttributes;
293 QString mCurrentFeatureId;
298 bool mBoundedByNullFound;
305 QList< QList<QgsWkbPtr> > mCurrentWKBFragments;
306 QString mAttributeName;
309 QString mCoordinateSeparator;
311 QString mTupleSeparator;
313 QStack<int> mDimensionStack;
325 QString mGMLNameSpaceURI;
326 const char *mGMLNameSpaceURIPtr =
nullptr;
328 AxisOrientationLogic mAxisOrientationLogic;
330 bool mInvertAxisOrientationRequest;
332 bool mInvertAxisOrientation;
338 std::string mGeometryString;
340 bool mFoundUnhandledGeometryElement;
351 class CORE_EXPORT
QgsGml :
public QObject
356 const QString &typeName,
357 const QString &geometryAttribute,
372 int getFeatures(
const QString &uri,
375 const QString &userName = QString(),
376 const QString &password = QString(),
377 const QString &authcfg = QString() )
SIP_PYNAME( getFeaturesUri );
386 QMap<QgsFeatureId, QgsFeature * >
featuresMap()
const {
return mFeatures; }
389 QMap<QgsFeatureId, QString >
idsMap()
const {
return mIdMap; }
397 void dataReadProgress(
int progress );
398 void totalStepsUpdate(
int totalSteps );
400 void dataProgressAndSteps(
int progress,
int totalSteps );
407 void handleProgressEvent( qint64 progress, qint64 totalSteps );
417 void calculateExtentFromFeatures();
419 void fillMapsFromParser();
431 QMap<QgsFeatureId, QgsFeature * > mFeatures;
436 QMap<QgsFeatureId, QString > mIdMap;
int getEPSGCode() const
Return the EPSG code, or 0 if unknown.
A rectangle specified with double values.
AxisOrientationLogic
Axis orientation logic.
int numberReturned() const
Return WFS 2.0 "numberReturned" or WFS 1.1 "numberOfFeatures" attribute, or -1 if invalid/not found...
QString srsName() const
Return the value of the srsName attribute.
A class to represent a 2D point.
int numberMatched() const
Return WFS 2.0 "numberMatched" attribute, or -1 if invalid/not found.
Container of fields for a vector layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QMap< QgsFeatureId, QgsFeature *> featuresMap() const
Get parsed features for given type name.
bool isException() const
Return whether the document parser is a OGC exception.
Type
The WKB type describes the number of dimensions a geometry has.
This class reads data from a WFS server or alternatively from a GML file.
QString exceptionText() const
Return the exception text.
QMap< QgsFeatureId, QString > idsMap() const
Get feature ids map.
Honour EPSG axis order only if srsName is of the form urn:ogc:def:crs:EPSG: *.
QString mGeometryAttribute
Geometry attribute name.
const QgsRectangle & layerExtent() const
Return layer bounding box.
QPair< QgsFeature *, QString > QgsGmlFeaturePtrGmlIdPair
bool isTruncatedResponse() const
Return whether a "truncatedResponse" element is found.
This class represents a coordinate reference system (CRS).
QgsWkbTypes::Type wkbType() const
Return the geometry type.
This class builds features from GML data in a streaming way.