package usda.weru.gis;

import java.util.List;
import javax.measure.Quantity;
import javax.measure.quantity.Length;
import org.geotools.data.DataStore;
import org.opengis.feature.Feature;
import org.opengis.geometry.DirectPosition;

/**
 * GISLookup is a service to transform gis data from multiple sources into usable
 * java objects.  Register a GISImplementation with ServiceLoader.
 * @param <T> the type of object being stored
 * @author Joseph A. Levin <joelevin@weru.ksu.edu>
 */
public interface GISLookup<T> {

    /**
     * Called when a datastore is registered.  Allows the lookup to test if it
     * can use the data.  Should test quickly by looking at schema.
     * @param id
     * @param data
     */
    public void register(String id, DataStore data);

    /**
     *
     * @param c
     * @return
     */
    public boolean supports(Class<?> c);

    /**
     * Lookup up and returns all the data objects for this lookup.  This may be
     * a high cost function because it is unlikely an implementation can filter
     * any thing.
     * @return
     */
    public List<T> lookup();

    /**
     * Lookup features containing the latlong.
     * @param latlong
     * @return
     */
    public List<T> lookup(DirectPosition latlong);

    /**
     * Lookup features containing the latlong within the given radius.
     * @param latlong
     * @param radius
     * @return
     */
    public List<T> lookup(DirectPosition latlong, Quantity<Length> radius);

    /**
     * Lookup the gis features that would create the given object.  The object
     * does not be one that was returned by a lookup, but it must be equal to one
     * that could.
     * @param object
     * @return
     * @throws IllegalStateException
     */
    public List<Feature> lookup(T object) throws IllegalStateException;

}
