[fdo-internals] Bug in FdoFilter::ToString()
Romica Dascalescu
Romica.Dascalescu at autodesk.com
Mon Jul 12 10:00:47 EDT 2010
Hello Igor,
First case is indeed a bug in the parser/ToString function since "NOT (a AND B)" is not equal with "NOT a AND B"
For the second case NOT has a higher operator precedence than AND and that's why "NOT a AND b == (NOT a) AND b"
See more about operator precedence, even is for C/C++, it applies in this case also.
http://www.difranco.net/cop2220/op-prec.htm
http://www.cppreference.com/wiki/operator_precedence
Thanks,
Romy.
________________________________
From: fdo-internals-bounces at lists.osgeo.org [fdo-internals-bounces at lists.osgeo.org] On Behalf Of Igor Jarm [igor at sl-king.com]
Sent: Friday, July 09, 2010 5:53 AM
To: fdo-internals at lists.osgeo.org
Subject: [fdo-internals] Bug in FdoFilter::ToString()
Hello,
FdoFilter::ToString() returns wrong string representation of "complex" filter NOT(a AND b).
The following is a description of a bug:
1. filter = NOT ( a AND b)
2. filter.ToString -> NOT a AND b == (NOT a) AND b //WRONG
3. FfdoFilter::Parse("NOT a AND b") -> NOT a AND b
A sample code to reproduce two different filters when they should be identical:
FdoPtr<FdoFilter> flt1 = FdoFilter::Parse(L"Geometry INTERSECTS GeomFromText('POLYGON ((461848 100030, 462399 100892, 463039 100544, 462697 99882, 462545 99926, 462652 100525, 462539 100612, 462075 99911, 461848 100030))')");//a
FdoPtr<FdoFilter> flt2 = FdoFilter::Parse(L"POVRSINA < 200");//b
FdoPtr<FdoFilter> fltand = FdoFilter::Combine(flt1, FdoBinaryLogicalOperations_And, flt2);
FdoPtr<FdoFilter> fltnot = FdoUnaryLogicalOperator::Create(fltand, FdoUnaryLogicalOperations_Not);
FdoPtr<FdoFilter> fltnot2 = FdoFilter::Parse(fltnot->ToString());
//fltnot != fltnot2
Surely this is not correct or is it ?
Regards,
Igor Jarm
More information about the fdo-internals
mailing list