QGIS API Documentation
qgsogcutils.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsogcutils.h
3  ---------------------
4  begin : March 2013
5  copyright : (C) 2013 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSOGCUTILS_H
16 #define QGSOGCUTILS_H
17 
18 class QColor;
19 class QDomNode;
20 class QDomElement;
21 class QDomDocument;
22 class QString;
23 
24 #include <list>
25 #include <QVector>
26 
27 class QgsExpression;
28 class QgsGeometry;
29 class QgsPoint;
30 class QgsRectangle;
31 
32 #include "qgsgeometry.h"
33 #include "qgsexpression.h"
34 
42 class CORE_EXPORT QgsOgcUtils
43 {
44  public:
45 
49  typedef enum
50  {
54  } GMLVersion;
55 
61  static QgsGeometry* geometryFromGML( const QString& xmlString );
62 
65  static QgsGeometry* geometryFromGML( const QDomNode& geometryNode );
66 
68  static QgsRectangle rectangleFromGMLBox( const QDomNode& boxNode );
69 
71  static QgsRectangle rectangleFromGMLEnvelope( const QDomNode& envelopeNode );
72 
77  static QDomElement geometryToGML( const QgsGeometry* geometry, QDomDocument& doc,
78  GMLVersion gmlVersion,
79  const QString& srsName,
80  bool invertAxisOrientation,
81  const QString& gmlIdBase,
82  int precision = 17 );
83 
87  static QDomElement geometryToGML( const QgsGeometry* geometry, QDomDocument& doc, const QString& format, int precision = 17 );
88 
92  static QDomElement geometryToGML( const QgsGeometry* geometry, QDomDocument& doc, int precision = 17 );
93 
97  static QDomElement rectangleToGMLBox( QgsRectangle* box, QDomDocument& doc, int precision = 17 );
98 
103  static QDomElement rectangleToGMLBox( QgsRectangle* box, QDomDocument& doc,
104  const QString& srsName,
105  bool invertAxisOrientation,
106  int precision = 17 );
107 
111  static QDomElement rectangleToGMLEnvelope( QgsRectangle* env, QDomDocument& doc, int precision = 17 );
112 
117  static QDomElement rectangleToGMLEnvelope( QgsRectangle* env, QDomDocument& doc,
118  const QString& srsName,
119  bool invertAxisOrientation,
120  int precision = 17 );
121 
122 
124  static QColor colorFromOgcFill( const QDomElement& fillElement );
125 
127  static QgsExpression* expressionFromOgcFilter( const QDomElement& element );
128 
134  static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage = nullptr );
135 
139  typedef enum
140  {
143  FILTER_FES_2_0
144  } FilterVersion;
145 
152  static QDomElement expressionToOgcFilter( const QgsExpression& exp,
153  QDomDocument& doc,
154  GMLVersion gmlVersion,
155  FilterVersion filterVersion,
156  const QString& geometryName,
157  const QString& srsName,
158  bool honourAxisOrientation,
159  bool invertAxisOrientation,
160  QString* errorMessage = nullptr );
161 
162  private:
163 
165  static QgsGeometry* geometryFromGMLPoint( const QDomElement& geometryElement );
167  static QgsGeometry* geometryFromGMLLineString( const QDomElement& geometryElement );
169  static QgsGeometry* geometryFromGMLPolygon( const QDomElement& geometryElement );
171  static QgsGeometry* geometryFromGMLMultiPoint( const QDomElement& geometryElement );
173  static QgsGeometry* geometryFromGMLMultiLineString( const QDomElement& geometryElement );
175  static QgsGeometry* geometryFromGMLMultiPolygon( const QDomElement& geometryElement );
180  static bool readGMLCoordinates( QgsPolyline &coords, const QDomElement &elem );
187  static bool readGMLPositions( QgsPolyline &coords, const QDomElement &elem );
188 
189 
194  static QDomElement createGMLCoordinates( const QgsPolyline &points, QDomDocument& doc );
195 
200  static QDomElement createGMLPositions( const QgsPolyline &points, QDomDocument& doc );
201 
203  static QgsExpression::Node* nodeFromOgcFilter( QDomElement &element, QString &errorMessage );
205  static QgsExpression::NodeBinaryOperator* nodeBinaryOperatorFromOgcFilter( QDomElement &element, QString &errorMessage );
207  static QgsExpression::NodeFunction* nodeSpatialOperatorFromOgcFilter( QDomElement& element, QString& errorMessage );
209  static QgsExpression::NodeUnaryOperator* nodeNotFromOgcFilter( QDomElement &element, QString &errorMessage );
211  static QgsExpression::NodeFunction* nodeFunctionFromOgcFilter( QDomElement &element, QString &errorMessage );
213  static QgsExpression::Node* nodeLiteralFromOgcFilter( QDomElement &element, QString &errorMessage );
215  static QgsExpression::NodeColumnRef* nodeColumnRefFromOgcFilter( QDomElement &element, QString &errorMessage );
217  static QgsExpression::Node* nodeIsBetweenFromOgcFilter( QDomElement& element, QString& errorMessage );
219  static QgsExpression::NodeBinaryOperator* nodePropertyIsNullFromOgcFilter( QDomElement& element, QString& errorMessage );
220 };
221 
226 {
227  public:
230  QgsOgcUtils::GMLVersion gmlVersion,
231  QgsOgcUtils::FilterVersion filterVersion,
232  const QString& geometryName,
233  const QString& srsName,
234  bool honourAxisOrientation,
235  bool invertAxisOrientation );
236 
238  QDomElement expressionNodeToOgcFilter( const QgsExpression::Node* node );
239 
241  bool GMLNamespaceUsed() const { return mGMLUsed; }
242 
244  const QString& errorMessage() const { return mErrorMessage; }
245 
246  private:
247  QDomDocument& mDoc;
248  bool mGMLUsed;
249  QgsOgcUtils::GMLVersion mGMLVersion;
250  QgsOgcUtils::FilterVersion mFilterVersion;
251  const QString& mGeometryName;
252  const QString& mSrsName;
253  bool mInvertAxisOrientation;
254  QString mErrorMessage;
255  QString mFilterPrefix;
256  QString mPropertyName;
257  int mGeomId;
258 
259  QDomElement expressionUnaryOperatorToOgcFilter( const QgsExpression::NodeUnaryOperator* node );
260  QDomElement expressionBinaryOperatorToOgcFilter( const QgsExpression::NodeBinaryOperator* node );
261  QDomElement expressionLiteralToOgcFilter( const QgsExpression::NodeLiteral* node );
262  QDomElement expressionColumnRefToOgcFilter( const QgsExpression::NodeColumnRef* node );
263  QDomElement expressionInOperatorToOgcFilter( const QgsExpression::NodeInOperator* node );
264  QDomElement expressionFunctionToOgcFilter( const QgsExpression::NodeFunction* node );
265 };
266 
267 #endif // QGSOGCUTILS_H
Class for parsing and evaluation of expressions (formerly called "search strings").
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Internal use by QgsOgcUtils.
Definition: qgsogcutils.h:225
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
const QString & errorMessage() const
Return the error message.
Definition: qgsogcutils.h:244
A class to represent a point.
Definition: qgspoint.h:117
FilterVersion
OGC filter version.
Definition: qgsogcutils.h:139
GMLVersion
GML version.
Definition: qgsogcutils.h:49
The QgsOgcUtils class provides various utility functions for conversion between OGC (Open Geospatial ...
Definition: qgsogcutils.h:42
bool GMLNamespaceUsed() const
Return whether the gml: namespace is used.
Definition: qgsogcutils.h:241