Package noaa.coastwatch.util
Class EarthLocationSet<T>
java.lang.Object
noaa.coastwatch.util.EarthLocationSet<T>
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn entry in the set holds the data for an earth location and it's associated data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the set so that it contains no locations.intGets the count of actively used bins.Gets a search context object to use with repeated calls to thenearest(noaa.coastwatch.util.EarthLocation)method.voidinsert(EarthLocation loc, T data) Inserts a new location and its data into the location set.static voidTests this class.nearest(EarthLocation loc) Gets the nearest location entry to the specified location.nearest(EarthLocation loc, Object context) Gets the nearest location entry to the specified location using a context obtained fromgetContext().
-
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
Gets a search context object to use with repeated calls to thenearest(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
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
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
Gets the nearest location entry to the specified location using a context obtained fromgetContext().- 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
Tests this class.- Parameters:
argv- the array of command line parameters.- Throws:
Exception- if an error occurred.
-