Class FeatureGroupFilter

java.lang.Object
noaa.coastwatch.render.feature.FeatureGroupFilter
All Implemented Interfaces:
Cloneable

public class FeatureGroupFilter extends Object implements Cloneable
A FeatureGroupFilter filters a set of Feature objects using a grouping concept. Features are grouped by an attribute value they have in common -- in the case of point features that represent measurements made over time, this could by the ID of the platform making the measurement. The group is then filtered by only selecting the single feature in the group whose attribute value is closest to a specified value. For example, suppose that we have features with "id" and "time" attributes as follows:
  • id=BUOY1, time=1985-10-26T01:20:00
  • id=BUOY1, time=1985-10-26T01:21:00
  • id=BUOY1, time=1985-10-26T01:22:00
  • id=BUOY2, time=1985-10-26T01:20:00
  • id=BUOY2, time=1985-10-26T01:21:00
  • id=BUOY2, time=1985-10-26T01:22:00
If the grouping attribute is "id", and the filtering attribute is "time" with a value of 1985-10-26T01:21:10, then the results of the filter would contain only two features:
  • id=BUOY1, time=1985-10-26T01:21:00
  • id=BUOY2, time=1985-10-26T01:21:00
The group filter would detect two groups: all features with "id" values of "BUOY1" and all features with "BUOY2". Then it would select the feature from each group with "time" attribute closest to 1985-10-26T01:21:10.
Since:
3.3.2
Author:
Peter Hollemans
  • Field Details

    • nameMap

      protected Map<String,Integer> nameMap
      The map to use to translate name to index for attributes.
  • Constructor Details

    • FeatureGroupFilter

      public FeatureGroupFilter(String groupAttName, Map<String,Integer> nameMap, String filterAttName, Object targetAttValue)
      Creates a new group filter with the specified properties.
      Parameters:
      groupAttName - the name of the attribute to use for creating groups of features.
      nameMap - the name to index mapping.
      filterAttName - the name of the attribute to use for filtering.
      targetAttValue - the target attribute value to filter for.
  • Method Details

    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • filter

      public List<Feature> filter(List<Feature> features)
      Filters a collection of features using the algorithm in this filter for matching.
      Parameters:
      features - the features to filter.
      Returns:
      the list of the matching features.
    • setGroupAttribute

      public void setGroupAttribute(String groupAttName)
      Sets the grouping attribute. During filtering, features will be grouped according to the value of their grouping attribute (according to Object.equals()) and then filtered by target value.
      Parameters:
      groupAttName - the name of the grouping attribute to use while filtering.
    • getGroupAttribute

      public String getGroupAttribute()
      Gets the grouping attribute name.
      Returns:
      grouping attribute name.
      See Also:
    • setFilterAttribute

      public void setFilterAttribute(String filterAttName)
      Sets the filtering attribute. The filtering attribute is used to search for the feature in each group with closest attribute value to a target value.
      Parameters:
      filterAttName - the name of the filtering attribute to use.
    • getFilterAttribute

      public String getFilterAttribute()
      Gets the filter attribute name.
      Returns:
      filter attribute name.
      See Also:
    • setTargetValue

      public void setTargetValue(Object targetAttValue)
      Sets the target attribute value The target value is used to filter each feature group. Only the feature from each group with the closest value to the target value is retained.
      Parameters:
      targetAttValue - the target value to use for measuring distance.
    • getTargetValue

      public Object getTargetValue()
      Gets the target value.
      Returns:
      target value object.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • main

      public static void main(String[] argv) throws Exception
      Tests this class.
      Parameters:
      argv - the array of command line parameters.
      Throws:
      Exception