Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
WFS AND Filters with BBOX are broken #5352
The following WFS filter containing a BBOX and a property filter:
Logs the following:
Note that the AND keyword is stuck to the intersects keyword. MapServer then seems to apply the spatial filter using the "rect" rather than the filter itself, and returns the correct results without error. The problem however is that this filter string is converted to native database strings when using other data sources, e.g for the MSSQL driver it throws the following error:
Tested using the following command:
Using Mapserver 7.0.2.
Sample MAP file:
Sample data at https://github.com/geographika/mapserver-tutorial-data/tree/master/data/vector/naturalearth (ne_110m_populated_places.shp)
Seems like the issue could be at: https://github.com/mapserver/mapserver/blob/66309eebb7ba0dc70469efeb40f865a8e88fafbd/mapogcfiltercommon.c#L382
The sprintf space created before adding the second filter clause is never used.
There is no space for the intersects function in the same file:
However many of the "psRightNode" expressions already have spaces built into them, resulting in 2 spaces, which whilst not a breaking issue makes the Filter look incorrect at a first glance.
@rouault - thanks!
The lexer didn't throw an error without the space, but the spatial filter seemed to be applied using the rect part of the statement. I'll check again in the debugger.
I'll open a separate ticket for the MSSQL driver. The msMSSQL2008LayerTranslateFilter now crashes when it hits the comma after [shape]. I presume the
From what I saw, the intersects() was correctly parsed as a MS_TOKEN_COMPARISON_INTERSECTS token, and it was not a rect statement. In the test I added, the filter was something like ( condition OR ( another_condition AND BBOX) ), and in that case, the BBOX cannot be applied as a rect since it's not a "top" BBOX.
@szekerest - many thanks for the driver fixes! The filter now translates perfectly in a MSSQL WHERE clause. My WFS layers are 50% quicker now the filtering is done in the database rather than in MapServer.
@rouault - I went through the debugger again, and read up on how the lexer works, and the lack of a space may have been a false issue. It certainly looked like it was an error in the logs, so the clean-up will definitely help someone in the future. Thanks.