[OpenLayers-Trac] [OpenLayers] #3394: parseFeatures does not handle filters

OpenLayers trac-20090302 at openlayers.org
Thu Jun 30 10:36:39 EDT 2011


#3394: parseFeatures does not handle filters
------------------------------------+---------------------------------------
 Reporter:  edoliscom               |       Owner:              
     Type:  bug                     |      Status:  new         
 Priority:  minor                   |   Milestone:  2.12 Release
Component:  general                 |     Version:  2.10        
 Keywords:  format filter protocol  |       State:              
------------------------------------+---------------------------------------
 Hi there,[[BR]]

 first ticket so please forgive me if I didn't get the basics yet.
 My problem: I'm trying to import geoJSON data applying a Format.filter to
 process the JSON data as they are converted in Features.
 To perform this I am creating a vector layer, specifying as protocol with
 a format parameter set to a Protocol.HTTP object and passing along as a
 Format a OpenLayers.Format.GeoJSON object with a filter property set to a
 function.[[BR]]

 Now, the function is not being used while parsing the JSON data - and
 looking at the implementation of Protocol.HTTP I can see what
 follows:[[BR]]

 OpenLayers.Protocol.HTTP[[BR]]
 ''the function:''

 {{{
  handleResponse:function(resp, '''options''') {
 ....
                     resp.features = '''this.parseFeatures(request);'''
 ....}
 }}}
 ''calls:''

 {{{
 parseFeatures: function(request) {
         var doc = request.responseXML;
         if (!doc || !doc.documentElement) {
             doc = request.responseText;
         }
         if (!doc || doc.length <= 0) {
             return null;
         }
         return this.format.read(doc);
     },
 }}}
 in this call, the filter object from the '''options''' parameter
 (containing the filter from the Format object) is not provided to the
 format.read function
 .On the other end, the called function read could accept such parameter,
 since its signature is:
 OpenLayers.Format.GeoJSON

 {{{
 '''read: function(json, type, filter)'''
 }}}

 The overall result is that it's not possible to apply Format.filters when
 importing data from HTTP protocol at Layer creation.
 This problem seem to affect all the protocols: is this a bug or by design?
 If it is not a bug, what is the legit way to apply a filter creating a
 vector layer from data retrieved through a Protocol?
 Thanks

-- 
Ticket URL: <http://trac.openlayers.org/ticket/3394>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list