Skip to content

Commit

Permalink
Moved expression to OGC filter code to QgsOgcUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Mar 14, 2013
1 parent 16ec226 commit b513674
Show file tree
Hide file tree
Showing 8 changed files with 476 additions and 435 deletions.
45 changes: 22 additions & 23 deletions python/core/qgsexpression.sip
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class QgsExpression
//! Returns parser error
QString parserErrorString() const;

//! Returns root node of the expression. Root node is null is parsing has failed
const QgsExpression::Node* rootNode() const;

//! Get the expression ready for evaluation - find out column indexes.
bool prepare( const QgsFields &fields );

Expand Down Expand Up @@ -118,9 +121,6 @@ class QgsExpression
// static const char* BinaryOperatorText[];
// static const char* UnaryOperatorText[];

// static const char* BinaryOgcOperatorText[];
// static const char* UnaryOgcOperatorText[];

class Function
{
public:
Expand Down Expand Up @@ -167,10 +167,22 @@ class QgsExpression

//////

enum NodeType
{
ntUnaryOperator,
ntBinaryOperator,
ntInOperator,
ntFunction,
ntLiteral,
ntColumnRef,
ntCondition
};

class Node
{
public:
virtual ~Node();
virtual QgsExpression::NodeType nodeType() const = 0;
// abstract virtual eval function
// errors are reported to the parent
virtual QVariant eval( QgsExpression* parent, QgsFeature* f ) = 0;
Expand All @@ -181,8 +193,6 @@ class QgsExpression

virtual QString dump() const = 0;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const = 0;
virtual bool needsGeometry() const = 0;

Expand All @@ -200,7 +210,6 @@ class QgsExpression
QList<QgsExpression::Node*> list();

virtual QString dump() const;
virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
};

class Interval
Expand Down Expand Up @@ -231,12 +240,11 @@ class QgsExpression
QgsExpression::UnaryOperator op() const;
QgsExpression::Node* operand() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v ) const;
Expand All @@ -252,12 +260,11 @@ class QgsExpression
QgsExpression::Node* opLeft() const;
QgsExpression::Node* opRight() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v ) const;
Expand All @@ -273,12 +280,11 @@ class QgsExpression
bool isNotIn() const;
QgsExpression::NodeList* list() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v ) const;
Expand All @@ -294,12 +300,11 @@ class QgsExpression
int fnIndex() const;
QgsExpression::NodeList* args() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v ) const;
Expand All @@ -312,12 +317,11 @@ class QgsExpression

QVariant value() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v ) const;
Expand All @@ -330,12 +334,11 @@ class QgsExpression

QString name() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v ) const;
Expand All @@ -359,12 +362,11 @@ class QgsExpression
NodeCondition( QgsExpression::WhenThenList* conditions, QgsExpression::Node* elseExp = NULL );
~NodeCondition();

virtual QgsExpression::NodeType nodeType() const;
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v ) const;
Expand All @@ -390,9 +392,6 @@ class QgsExpression
/** entry function for the visitor pattern */
void acceptVisitor( QgsExpression::Visitor& v ) const;

// convert from/to OGC Filter
void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

protected:
void initGeomCalculator();
};
2 changes: 1 addition & 1 deletion python/core/qgsogcutils.sip
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public:
/** Creates OGC filter XML element. Supports minimum standard filter according to the OGC filter specs (=,!=,<,>,<=,>=,AND,OR,NOT)
@return valid <Filter> QDomElement on success, otherwise null QDomElement
*/
static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc );
static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage /Out/ );

};

Loading

0 comments on commit b513674

Please sign in to comment.