Skip to content

Commit

Permalink
[BUGFIX] SLD : Support escapeChar attribute of PropertyIsLike
Browse files Browse the repository at this point in the history
In OGC FilterEncoding standard, the PropertyIsLike element has an escapeChar attribute in place of escape attribute.

In the QgsOgcUtils class, the attribute escape or escapeChar is added to PropertyIsLike element, but it only checks escape attribute when it decodes it.

The commit fixed it and adds test.
  • Loading branch information
rldhont committed Jan 8, 2019
1 parent 86ff500 commit 0ab834e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/qgsogcutils.cpp
Expand Up @@ -1808,6 +1808,10 @@ QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodeBinaryOperatorFromOgcFilter(
{
escape = element.attribute( "escape" );
}
else if ( element.hasAttribute( "escapeChar" ) )
{
escape = element.attribute( "escapeChar" );
}
// replace
QString oprValue = static_cast<const QgsExpression::NodeLiteral*>( opRight )->value().toString();
if ( !wildCard.isEmpty() && wildCard != "%" )
Expand Down
8 changes: 7 additions & 1 deletion tests/src/core/testqgsogcutils.cpp
Expand Up @@ -330,13 +330,19 @@ void TestQgsOgcUtils::testExpressionFromOgcFilter_data()
"<PropertyName>NAME</PropertyName><Literal>._QGIS.\\.</Literal></PropertyIsLike>"
"</Filter>" )
<< QString( "NAME LIKE '_\\\\_QGIS_.'" );
// different single chars
// different escape chars
QTest::newRow( "like escape char" ) << QString(
"<Filter>"
"<PropertyIsLike wildCard=\"*\" singleChar=\".\" escape=\"!\">"
"<PropertyName>NAME</PropertyName><Literal>_QGIS.!.!!%QGIS*!*</Literal></PropertyIsLike>"
"</Filter>" )
<< QString( "NAME LIKE '\\\\_QGIS_.!\\\\%QGIS%*'" );
QTest::newRow( "like escape char" ) << QString(
"<Filter>"
"<PropertyIsLike wildCard=\"*\" singleChar=\".\" escapeChar=\"!\">"
"<PropertyName>NAME</PropertyName><Literal>_QGIS.!.!!%QGIS*!*</Literal></PropertyIsLike>"
"</Filter>" )
<< QString( "NAME LIKE '\\\\_QGIS_.!\\\\%QGIS%*'" );

QTest::newRow( "is null" ) << QString(
"<Filter>"
Expand Down

0 comments on commit 0ab834e

Please sign in to comment.