[OpenLayers-Trac] Re: [OpenLayers] #2818: add OpenLayers.Filter.Callback

OpenLayers trac-20090302 at openlayers.org
Mon Sep 13 10:29:53 EDT 2010


#2818: add OpenLayers.Filter.Callback
----------------------+-----------------------------------------------------
 Reporter:  alexdean  |       Owner:              
     Type:  feature   |      Status:  new         
 Priority:  minor     |   Milestone:  2.11 Release
Component:  Filter    |     Version:  2.10 RC1    
 Keywords:            |       State:  Review      
----------------------+-----------------------------------------------------
Changes (by alexdean):

  * state:  Awaiting User Feedback => Review


Comment:

 Interesting.  I didn't consider overloading `evaluate` in that way.

 This would allow assertions based on a feature's attributes, but still
 would not allow assertions based on non-attribute data, like geometry
 type.  OpenLayers.Rule will only supply the full feature to `evaluate`
 when using OpenLayers.Filter.FeatureId.

 The sample code you sent would have to be re-written like:
 {{{
 new OpenLayers.Filter({
   evaluate: function(feature) {
     return( feature.density >= 100 || feature.population >= 200000 )
   }
 });
 }}}

 Granted, that's a minor change for this specific example.  But if I wanted
 to only apply my styling to points, I would still be unable to do that due
 to how OpenLayers.Rule is written.

 source:trunk/openlayers/lib/OpenLayers/Rule.js at 10706#L173

 I'm unable to write things like
 {{{
 new OpenLayers.Filter({
   evaluate: function(feature) {
     return( feature.geometry.CLASS_NAME == 'OpenLayers.Geometry.Point' )
   }
 });
 }}}

 Would you consider a patch to change all Filter subclasses to expect the
 full feature as an argument, so they'd all be treated like
 `OpenLayers.Filter.FeatureId`?  I believe that would not be very complex
 to do, would remove the special case code for
 `OpenLayers.Filter.FeatureId`, and would allow filters based on non-
 attribute data in the way you suggest above.

-- 
Ticket URL: <http://trac.openlayers.org/ticket/2818#comment:2>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list