Class EarthLocationSet<T>

java.lang.Object
noaa.coastwatch.util.EarthLocationSet<T>

public class EarthLocationSet<T> extends Object
An EarthLocationSet holds a number of earth locations and allows for fast retrieval of the nearest location in the set to a given point and an associated data object. The implementation uses bins and assumes that locations are contiguous or highly clustered and that bins that contain locations are adjacent to some other bin in the set.
Since:
3.5.0
Author:
Peter Hollemans
  • Constructor Details

    • EarthLocationSet

      public EarthLocationSet(int binsPerDegree)
      Creates a new empty location set.
      Parameters:
      binsPerDegree - the number of bins to use per degree of latitude, minimum 1.
  • Method Details

    • getContext

      public Object getContext()
      Gets a search context object to use with repeated calls to the nearest(noaa.coastwatch.util.EarthLocation) method.
      Returns:
      the new search context object.
    • getBinCount

      public int getBinCount()
      Gets the count of actively used bins. These are bins that have locations as a result of insertions.
      Returns:
      the count of active bins.
    • clear

      public void clear()
      Clears the set so that it contains no locations.
    • insert

      public void insert(EarthLocation loc, T data)
      Inserts a new location and its data into the location set.
      Parameters:
      loc - the location to insert.
      data - the data to insert with the location.
    • nearest

      public EarthLocationSet<T>.Entry nearest(EarthLocation loc)
      Gets the nearest location entry to the specified location.
      Parameters:
      loc - the location to search for.
      Returns:
      the nearest entry found or null for none.
    • nearest

      public EarthLocationSet<T>.Entry nearest(EarthLocation loc, Object context)
      Gets the nearest location entry to the specified location using a context obtained from getContext().
      Parameters:
      loc - the location to search for.
      context - the context to use for searching, or null for none.
      Returns:
      the nearest entry found or null for none.
    • main

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