[OpenLayers-Users] Changing map file FILTER parameter via URL - WFS layer with OVF connection

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Fri Feb 16 13:57:41 EST 2007


Hi,

yes after the mylayer initialization if you use mergeNewParams.

Please note, if you already know the user at initialization, you can 
pass the parameter "filter" already in the constructor of your layer, 
just like you pass in typename right now.

The filter encoding I gave was just an example, for the right name of 
the PropertyName check the DescribeFeatureType response of your 
Mapserver WFS, something like:

http://localhost/cgi-bin/mapserv?map=/var/www/thesilence/webroot/mapserver/config/data_points.map&typename=points&service=WFS&version=1.0.0&request=DescribeFeatureType

I would advise you to first get things running by putting a direct URL 
in the browser, and then code the stuff in OpenLayers javascript, so try 
something like:

http://localhost/cgi-bin/mapserv?map=/var/www/thesilence/webroot/mapserver/config/data_points.map&typename=points&service=WFS&version=1.0.0&request=GetFeature&filter=<test 
your filter here>

Hope this helps.

Best regards,
Bart

Pedrazzi Gelsomini schreef:
> Thank you very much for your help.
> I should ask you more information beacause i can't understand what i 
> have to do.
>
> >  var filter = 
> '<Filter><PropertyIsEqualTo><PropertyName>user_id</PropertyName><Literal>3</Literal>< 
>
> >  /PropertyIsEqualTo></Filter>';
>
> >  mylayer.mergeNewParams({"filter":filter});
>
> Putting these instruction above i have the following error
>
> "this.map has no properties"
> ( Grid.js - line 171 - var viewSize = this.map.getSize();
>
> Do i have to insert these instructions after mylayer initialization, 
> that is in the  function init() that creates my map?
> Is it correct put in the <PropertyName> the name of a field that I get 
> from the SELECT query of the OVF  file?
>
> Is it enough to add this code lines or I have to do something other in 
> order to make working the Filter Encoding?
> Sorry for the trivial questions but i am quite new in this subject.
>
> Thanks a lot for your time!
>
>
>
> 2007/2/16, Bart van den Eijnden (OSGIS) <bartvde at osgis.nl 
> <mailto:bartvde at osgis.nl>>:
>
>     Hi,
>
>     you need to use the FILTER parameter from the OGC WFS spec to do
>     this, check
>     this for more info:
>
>     http://mapserver.gis.umn.edu/docs/howto/filterencoding/
>     <http://mapserver.gis.umn.edu/docs/howto/filterencoding/>
>
>     then you need to call mergeNewParams on your OpenLayers layer:
>
>     var filter =
>     '<Filter><PropertyIsEqualTo><PropertyName>USER</PropertyName>
>     <Literal>Peter</Literal></PropertyIsEqualTo></Filter>';
>
>     mylayer.mergeNewParams({"filter":filter});
>
>     Best regards,
>     Bart
>
>     --
>     Bart van den Eijnden
>     OSGIS, Open Source GIS
>     http://www.osgis.nl
>
>
>     --------- Oorspronkelijk bericht --------
>     Van: Pedrazzi Gelsomini <pedrazzi.gelsomini at gmail.com
>     <mailto:pedrazzi.gelsomini at gmail.com>>
>     Naar: users at openlayers.org <mailto:users at openlayers.org> <
>     users at openlayers.org <mailto:users at openlayers.org>>
>     Onderwerp: [OpenLayers-Users] Changing map file FILTER parameter
>     via URL -
>     WFS layer with OVF connection
>     Datum: 16/02/07 13:02
>
>     > Hi everyone,I m using openlayers for my application and I have a
>     WFS layer
>     filled by my mysql database using mapserver.My layer
>     inizialitazion is:
>     > var user_wfs = new OpenLayers.Layer.WFS( &quot;User Points&quot;,
>     >
>     >
>     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
>
>     &nbsp;&nbsp;&nbsp;
>     &quot;http://localhost/cgi-bin/mapserv?map=/var/www/thesilence/webroot/mapserver/config/data_points.map&amp;
>     > &quot;,
>     >
>     > &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {typename:
>     &quot;points&quot;}, { featureClass: OpenLayers.Feature.WFS});
>     >
>     > In my file.map i have the following layer:LAYER&nbsp;&nbsp;&nbsp;
>     CONNECTION &quot;my_points.ovf&quot;&nbsp;&nbsp;&nbsp; CONNECTIONTYPE
>     OGR&nbsp;&nbsp;&nbsp; DATA &quot;points&quot;&nbsp;&nbsp;&nbsp;
>     METADATA
>     &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>     &quot;wms_srs&quot;&nbsp;&nbsp;&nbsp;
>     &quot;EPSG:4326&quot;
>     > &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>     &quot;wms_title&quot;&nbsp;&nbsp;&nbsp;
>     &quot;points&quot;&nbsp;&nbsp;&nbsp;
>     &nbsp;&nbsp;&nbsp; &quot;wfs_srs&quot;&nbsp;&nbsp;&nbsp;
>     &quot;EPSG:4326&quot;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>     &quot;wfs_title&quot;&nbsp;&nbsp;&nbsp;
>     &quot;points&quot;&nbsp;&nbsp;&nbsp;
>     &nbsp;&nbsp;&nbsp; &quot;gml_featureid&quot;&nbsp;&nbsp;&nbsp;
>     &quot;fid&quot;
>     > &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>     &quot;gml_include_items&quot;&nbsp;
>     &quot;all&quot;&nbsp;&nbsp;&nbsp; END&nbsp;&nbsp;&nbsp; NAME
>     &quot;points&quot;&nbsp;&nbsp;&nbsp; SIZEUNITS
>     PIXELS&nbsp;&nbsp;&nbsp;
>     STATUS ON&nbsp;&nbsp;&nbsp; DUMP TRUE&nbsp;&nbsp;&nbsp;
>     PROJECTION&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>     &quot;init=epsg:4326&quot;&nbsp;&nbsp;&nbsp; END
>     > &nbsp;&nbsp;&nbsp; TOLERANCE 20&nbsp;&nbsp;&nbsp; TOLERANCEUNITS
>     PIXELS&nbsp;&nbsp;&nbsp; TYPE POINT&nbsp;&nbsp;&nbsp; UNITS
>     METERS&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FILTERITEM
>     &quot;user_id&quot;&nbsp;&nbsp;&nbsp; #FILTER &quot;&quot;where
>     my_points.ovf is:&lt;OGRVRTDataSource&gt;
>     > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;OGRVRTLayer
>     name=&quot;points&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
>     &lt;SrcDataSource&gt;ODBC:myuser/mypsw at mydns&lt;/SrcDataSource&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
>     &lt;SrcSQL&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SELECT
>     data_points.id AS
>     fid, latitude, longitude, des_walks.com_user_id AS user_id
>     > &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FROM data_points JOIN
>     des_walks&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE des_walks.id =
>     data_points.des_walk_id&nbsp;&nbsp;&nbsp;
>     &lt;/SrcSQL&gt;&nbsp;&nbsp;&nbsp;
>     &lt;GeometryType&gt;wkbPoint&lt;/GeometryType&gt;&nbsp;&nbsp;&nbsp;
>     &lt;LayerSRS&gt;WGS84&lt;/LayerSRS&gt;
>     > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;GeometryField
>     encoding=&quot;PointFromColumns&quot; x=&quot;longitude&quot;
>     y=&quot;latitude&quot;/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
>     &lt;/OGRVRTLayer&gt;&lt;/OGRVRTDataSource&gt;but I need to change
>     the value
>     of the FILTER parameter in the map file via URL.
>     >
>     > The connection with database works and allows me to put my
>     points on my
>     map.I would like to filter these data by &quot;user_id&quot; and
>     show only
>     the data linked to a specific user, but i have to pass this
>     parameter via
>     url because it is not always the same.
>     >
>     > Now i m passing just the typename in the openlayers function,
>     but i dont
>     know how to change the FILTER parameter in my map
>     file.&nbsp;&nbsp;&nbsp;
>     FILTERITEM &quot;user_id&quot;
>     > &nbsp;&nbsp;&nbsp; #FILTER &quot;&quot;Any suggestion?Thank you
>     very much!
>     >
>     >
>     >
>     >
>     >
>     > _______________________________________________
>     > Users mailing list
>     > Users at openlayers.org <mailto:Users at openlayers.org>
>     > http://openlayers.org/mailman/listinfo/users
>     >
>
>
>
>
>
>
> -- 
> Ilaria Gelsomini
> Francesca Pedrazzi 


-- 
Bart van den Eijnden
OSGIS, Open Source GIS
bartvde at osgis.nl
http://www.osgis.nl




More information about the Users mailing list