Hi everyone, I have a simple question:

What is the standard way of getting the feature count of a MapLayer?

Calling layer.getFeatureSource().getCount() does not give the correct 
result, obviously, since this does not take the filters in the rules of 
the style into account (and  a layer also has a "definition query" which 
probably must be used as well).

What I have done so far, is to subclass DefaultMapLayer which adds a 
listener on the feature source. This listener will use the filters 
extracted from the style to evaluate if the features involved in a 
FeatureEvent.FEATURES_ADDED or FeatureEvent.FEATURES_REMOVED should be 
in this layer. If filter.evaluate(feature) returns true, an internal 
counter is incremented or decremented as appropriate.

It should also be mentioned that the FeatureSource in question is our 
own implementation, which fires a subclass of FeatureEvent which 
contains a list of the features involved in the event.

Regards,
Erik Loevlie

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to