Skip to content
Permalink
Browse files

Fix #8584 (WFS requests with FILTER fails against Geoserver)

  • Loading branch information
wonder-sk committed Feb 7, 2014
1 parent 8b8eb56 commit 10c15089d1735cec491ee0958b54b3fb0fad230d
Showing with 12 additions and 9 deletions.
  1. +2 −1 src/core/qgsogcutils.cpp
  2. +10 −8 tests/src/core/testqgsogcutils.cpp
@@ -15,6 +15,7 @@


static const QString GML_NAMESPACE = "http://www.opengis.net/gml";
static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc";

QgsGeometry* QgsOgcUtils::geometryFromGML( const QDomNode& geometryNode )
{
@@ -1879,7 +1880,7 @@ QDomElement QgsOgcUtils::expressionToOgcFilter( const QgsExpression& exp, QDomDo
if ( exprRootElem.isNull() )
return QDomElement();

QDomElement filterElem = doc.createElement( "ogc:Filter" );
QDomElement filterElem = doc.createElementNS( OGC_NAMESPACE, "ogc:Filter" );
filterElem.appendChild( exprRootElem );
return filterElem;
}
@@ -246,19 +246,21 @@ void TestQgsOgcUtils::testExpressionToOgcFilter_data()
QTest::addColumn<QString>( "xmlText" );

QTest::newRow( "=" ) << QString( "NAME = 'New York'" ) << QString(
"<ogc:Filter><ogc:PropertyIsEqualTo>"
"<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\">"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>NAME</ogc:PropertyName>"
"<ogc:Literal>New York</ogc:Literal>"
"</ogc:PropertyIsEqualTo></ogc:Filter>" );

QTest::newRow( ">" ) << QString( "COUNT > 3" ) << QString(
"<ogc:Filter><ogc:PropertyIsGreaterThan>"
"<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\">"
"<ogc:PropertyIsGreaterThan>"
"<ogc:PropertyName>COUNT</ogc:PropertyName>"
"<ogc:Literal>3</ogc:Literal>"
"</ogc:PropertyIsGreaterThan></ogc:Filter>" );

QTest::newRow( "and+or" ) << QString( "(FIELD1 = 10 OR FIELD1 = 20) AND STATUS = 'VALID'" ) << QString(
"<ogc:Filter>"
"<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\">"
"<ogc:And>"
"<ogc:Or>"
"<ogc:PropertyIsEqualTo>"
@@ -278,14 +280,14 @@ void TestQgsOgcUtils::testExpressionToOgcFilter_data()
"</ogc:Filter>" );

QTest::newRow( "is null" ) << QString( "X IS NULL" ) << QString(
"<ogc:Filter>"
"<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\">"
"<ogc:PropertyIsNull>"
"<ogc:PropertyName>X</ogc:PropertyName>"
"</ogc:PropertyIsNull>"
"</ogc:Filter>" );

QTest::newRow( "is not null" ) << QString( "X IS NOT NULL" ) << QString(
"<ogc:Filter>"
"<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\">"
"<ogc:Not>"
"<ogc:PropertyIsNull>"
"<ogc:PropertyName>X</ogc:PropertyName>"
@@ -294,7 +296,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilter_data()
"</ogc:Filter>" );

QTest::newRow( "in" ) << QString( "A IN (10,20,30)" ) << QString(
"<ogc:Filter>"
"<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\">"
"<ogc:Or>"
"<ogc:PropertyIsEqualTo>"
"<ogc:PropertyName>A</ogc:PropertyName>"
@@ -312,15 +314,15 @@ void TestQgsOgcUtils::testExpressionToOgcFilter_data()
"</ogc:Filter>" );

QTest::newRow( "intersects + wkt" ) << QString( "intersects($geometry, geomFromWKT('POINT (5 6)'))" ) << QString(
"<ogc:Filter>"
"<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\">"
"<ogc:Intersects>"
"<ogc:PropertyName>geometry</ogc:PropertyName>"
"<gml:Point><gml:coordinates cs=\",\" ts=\" \">5,6</gml:coordinates></gml:Point>"
"</ogc:Intersects>"
"</ogc:Filter>" );

QTest::newRow( "contains + gml" ) << QString( "contains($geometry, geomFromGML('<Point><coordinates cs=\",\" ts=\" \">5,6</coordinates></Point>'))" ) << QString(
"<ogc:Filter>"
"<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\">"
"<ogc:Contains>"
"<ogc:PropertyName>geometry</ogc:PropertyName>"
"<Point><coordinates cs=\",\" ts=\" \">5,6</coordinates></Point>"

0 comments on commit 10c1508

Please sign in to comment.
You can’t perform that action at this time.