Skip to content
Permalink
Browse files

[FEATURE][needs-docs] Add possbility to define one filter for several…

… layers
  • Loading branch information
troopa81 committed Feb 19, 2019
1 parent daa05e5 commit 21bfcfcca84e06578ebbe976b771a8a1adf5c1a1
@@ -1329,15 +1329,19 @@ namespace QgsWms
}
else if ( !f.isEmpty() )
{
// filter format: "LayerName:filterString;LayerName2:filterString2;..."
// filter format: "LayerName,LayerName2:filterString;LayerName3:filterString2;..."
// several filters can be defined for one layer
const QStringList splits = f.split( ':' );
if ( splits.size() == 2 )
{
QgsWmsParametersFilter filter;
filter.mFilter = splits[1];
filter.mType = QgsWmsParametersFilter::SQL;
filters.insert( splits[0], filter );
QStringList layers = splits[0].contains( ',' ) ? splits[0].split( ',' ) : QStringList() << splits[0];
for ( QString layer : layers )
{
QgsWmsParametersFilter filter;
filter.mFilter = splits[1];
filter.mType = QgsWmsParametersFilter::SQL;
filters.insert( layer, filter );
}
}
else
{
@@ -798,6 +798,25 @@ def test_wms_getmap_filter(self):
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Filter4")

# display multiple features filtered from multiple layers with same filter for some
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": "Country,Country_Diagrams,Hello",
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "1017529,-4226661,11271098,17063190",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857",
"FILTER": "Country,Country_Diagrams: \"name\" IN ( 'africa' , 'eurasia' );Hello: \"color\" IN ( 'magenta' , 'cerese' )"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Filter5")

def test_wms_getmap_filter_ogc(self):
filter = "<Filter><PropertyIsEqualTo><PropertyName>name</PropertyName>" + \
"<Literal>eurasia</Literal></PropertyIsEqualTo></Filter>"
Binary file not shown.
Binary file not shown.

0 comments on commit 21bfcfc

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