Skip to content

Commit 0ab834e

Browse files
committedJan 8, 2019
[BUGFIX] SLD : Support escapeChar attribute of PropertyIsLike
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.
1 parent 86ff500 commit 0ab834e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
 

‎src/core/qgsogcutils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,6 +1808,10 @@ QgsExpression::NodeBinaryOperator* QgsOgcUtils::nodeBinaryOperatorFromOgcFilter(
18081808
{
18091809
escape = element.attribute( "escape" );
18101810
}
1811+
else if ( element.hasAttribute( "escapeChar" ) )
1812+
{
1813+
escape = element.attribute( "escapeChar" );
1814+
}
18111815
// replace
18121816
QString oprValue = static_cast<const QgsExpression::NodeLiteral*>( opRight )->value().toString();
18131817
if ( !wildCard.isEmpty() && wildCard != "%" )

‎tests/src/core/testqgsogcutils.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,19 @@ void TestQgsOgcUtils::testExpressionFromOgcFilter_data()
330330
"<PropertyName>NAME</PropertyName><Literal>._QGIS.\\.</Literal></PropertyIsLike>"
331331
"</Filter>" )
332332
<< QString( "NAME LIKE '_\\\\_QGIS_.'" );
333-
// different single chars
333+
// different escape chars
334334
QTest::newRow( "like escape char" ) << QString(
335335
"<Filter>"
336336
"<PropertyIsLike wildCard=\"*\" singleChar=\".\" escape=\"!\">"
337337
"<PropertyName>NAME</PropertyName><Literal>_QGIS.!.!!%QGIS*!*</Literal></PropertyIsLike>"
338338
"</Filter>" )
339339
<< QString( "NAME LIKE '\\\\_QGIS_.!\\\\%QGIS%*'" );
340+
QTest::newRow( "like escape char" ) << QString(
341+
"<Filter>"
342+
"<PropertyIsLike wildCard=\"*\" singleChar=\".\" escapeChar=\"!\">"
343+
"<PropertyName>NAME</PropertyName><Literal>_QGIS.!.!!%QGIS*!*</Literal></PropertyIsLike>"
344+
"</Filter>" )
345+
<< QString( "NAME LIKE '\\\\_QGIS_.!\\\\%QGIS%*'" );
340346

341347
QTest::newRow( "is null" ) << QString(
342348
"<Filter>"

0 commit comments

Comments
 (0)
Please sign in to comment.