wfs attribute filtering

Huub Fleuren hfl at HOME.NL
Tue Aug 23 12:33:58 PDT 2005


I found that i can now (gml_include_items all on de WFS serverlayer) use 
FILTERITEM and FILTER using the literal spelling of the column in the 
temporary GML file


  CONNECTIONTYPE WFS
  CONNECTION 
"http://localhost/cgi-bin/mapserv/bin/mapserv.exe?map=mapserv/bin/chameleon.map&"
  FILTERITEM "myns:PARK_"
  FILTER "%PARK_%"
  METADATA
    "wfs_typename"          "park"
    "wfs_version"           "1.0.0"
    "wfs_request_method"    "GET"
    "wfs_connectiontimeout" "60"
    "wfs_maxfeatures"       "50"
  END

i also found that there actually *i*s a policy on variable substitution 
: it works on DATA CONNECTION and FILTER
maybe it should be elaborated for wfs_filtering strings

mapserv.c line 285

      if(map->layers[j].data && (strstr(map->layers[j].data, tmpstr) != 
NULL)) map->layers[j].data = gsub(map->layers[j].data, tmpstr, 
msObj->request->ParamValues[i]);
      if(map->layers[j].connection && (strstr(map->layers[j].connection, 
tmpstr) != NULL)) map->layers[j].connection = 
gsub(map->layers[j].connection, tmpstr, msObj->request->ParamValues[i]);
      if(map->layers[j].filter.string && 
(strstr(map->layers[j].filter.string, tmpstr) != NULL)) 
map->layers[j].filter.string = gsub(map->layers[j].filter.string, 
tmpstr, msObj->request->ParamValues[i]);


Regards, Huub

Huub Fleuren wrote:

> I see. Thanks .
>
> I might experiment with
>
> gml_include_items "all"
>
> to retrieve all data with a proxy that i use for the CONNECTION if 
> that's not too mapserverspecific, and filter it in there with XSL, but 
> that would be quite a workaround
>
> variable substitution would be good though!
>
> let's see...
> mapserv.c ln. 274 in *loadMap
>
>  /* check for any %variable% substitutions here, also do any map_ 
> changes, we do this here so WMS/WFS  */
>  /* services can take advantage of these "vendor specific" extensions */
>  for(i=0;i<msObj->request->NumParams;i++) {
>    if(strncasecmp(msObj->request->ParamNames[i],"map_",4) == 0) { /* 
> check to see if there are any additions to the mapfile */
>      if(msLoadMapString(map, msObj->request->ParamNames[i], 
> msObj->request->ParamValues[i]) == -1) writeError();
>    }
>
> Seems to me that it should work.
> Maybe file a bug.
>
>
>
> Huub
>
>
> Bart van den Eijnden wrote:
>
>> Huub,
>>
>> 1: add gml_include_items "all" to your LAYER's METADATA section
>> 2: I don't expect this to work with variable subsitution
>> 3: You can set the wfs_filter METADATA with Mapscript, I don't think 
>> you can do this with normal CGI
>>
>> Best regards,
>> Bart
>>
>> Bart van den Eijnden
>> Syncera IT Solutions
>> Postbus 270
>> 2600 AG  DELFT
>>
>> tel.nr.: 015-7512436
>> email: BEN at Syncera-ITSolutions.nl
>>
>>  
>>
>>>>> Huub Fleuren <hfl at HOME.NL> 08/23/05 1:55 pm >>>
>>>>>       
>>>>
>> Hi List
>>
>> I'm happily getting images from a wfs_filtered WFS client layer from 
>> my map-WFS-server and i was accumulating the following questions.
>>
>> 1. Why are there no attributes in the response to
>>
>> http://localhost/cgi-bin/mapserv/bin/mapserv.exe?map=mapserv/bin/chameleon.map&version=1.0.0&service=wfs&request=getfeature&typename=park 
>> http://localhost/cgi-bin/mapserv/bin/mapserv.exe?map=mapserv/bin/chameleon.map&version=1.0.0&service=wfs&request=getfeature&typename=park&Filter=<Filter><PropertyIsEqualTo><PropertyName>PARK_</PropertyName><Literal>10</Literal></PropertyIsEqualTo></Filter> 
>>
>>
>> 2. I'm trying variable substitution in the to <ogc:filter/> but the 
>> expression % + variable + % is  interpreted litterally
>>
>> http://localhost/cgi-bin/mapserv/bin/mapserv.exe?map=mapserv/bin/wfs_park.map&PARK_=10&service=wms&request=getmap&version=1.1.1&layers=wfs_park&styles=&srs=EPSG:42304&bbox=-2600000,-700000,3500000,3840000&width=610&height=450&format=png&transparent=true&exceptions=text/xml&bgcolor=0xffffff 
>>
>> 3. How can I  filter dynamically?
>>
>> Regards, Huub
>> ===
>>
>> WFS Server layerdefinition
>> LAYER
>>  NAME park
>>  DUMP TRUE
>>  METADATA
>>    DESCRIPTION   "Park"
>>  END
>>  TYPE POLYGON
>>  STATUS ON
>>  DATA park
>>  CLASS
>>    NAME "Parks"
>>    COLOR 200 255 0
>>    OUTLINECOLOR 120 120 120
>>  END
>>  TOLERANCE 5
>> END # Layer
>>
>>
>> WFS Client layerdefinition
>>
>> LAYER
>>  NAME wfs_park
>>  TYPE POLYGON
>>  STATUS ON
>>  CONNECTIONTYPE WFS
>>  CONNECTION 
>> "http://localhost/cgi-bin/mapserv/bin/mapserv.exe?map=mapserv/bin/chameleon.map" 
>>
>>  #adding a Filterkeyword works, but also not applicable to variable 
>> substitution
>>  
>> #&Filter=<Filter><PropertyIsEqualTo><PropertyName>PARK_</PropertyName><Literal>%PARK_%</Literal></PropertyIsEqualTo></Filter>" 
>>
>>  METADATA
>>    "wfs_typename"          "park"
>>    "wfs_version"           "1.0.0"
>>    "wfs_request_method"    "GET"
>>    "wfs_connectiontimeout" "60"
>>    "wfs_maxfeatures"       "50"
>>    "wfs_filter"   
>> "<PropertyIsEqualTo><PropertyName>PARK_</PropertyName><Literal>%PARK_%</Literal></PropertyIsEqualTo>" 
>>
>> #  "wfs_filter"   
>> "<PropertyIsEqualTo><PropertyName>PARK_</PropertyName><Literal>10</Literal></PropertyIsEqualTo>" 
>>
>>
>>  END
>>  PROJECTION
>>    "init=epsg:42304"
>>  END
>>    CLASS
>>        STYLE
>>        COLOR 0 255 0
>>        END
>>    END
>> END
>>
>>
>>
>>  
>>
>
>



More information about the MapServer-users mailing list