/*
 * GeometryConverter.java
 *
 * Created on September 30, 2004, 4:10 PM
 */

package org.geotools.data;

import com.vividsolutions.jts.geom.Geometry;

/**
 * Geometry converter interface for different geospatial/geodetic databases.
 * 
 * Convert JTS Geometries to and from specific database spatial types.
 * @author kjn
 * @author Ken Tanaka, Ken.Tanaka@noaa.gov
 */
public interface GeometryConverter {
    /**
     * For reading a JTS geometry from a result set.
     * @param gdbGeometry Geospatial Database object to convert to JTS geometry
     * @throws ConversionException If the database can't provide details of the gdbGeometry 
     * needed for conversion
     * @return a JTS geometry equivalent to the provided gdbGeometry
     */
    public Geometry convertToGeometry(Object gdbGeometry) throws ConversionException;

    /**
     * For writing to a GDB result set from a JTS geometry.
     * @param geom JTS geometry to convert to a geospatial database object.
     * @throws ConversionException If the database functions encounter errors making the conversion.
     * @return a geospatial database object for insertion into a spatial DB table.
     */
    public Object convertFromGeometry(Geometry geom) throws ConversionException;

    /**
     * Get the name of the GDB geometry type.
     * 
     * Some expected results might be "MDSYS.SDO_GEOMETRY" for Oracle Spatial, or
     * "GeoObject" for Informix Geodetic, or "ST_Geometry" for Informix Spatial.
     * @return the name of the GDB geometry type.
     */
    public String getDataTypeName();
    
    /**
     * Checks to determine whether objects of the specified class can be
     * converted to a JTS Geometry by this Converter.
     */
    public boolean isCapable(Class cls);
    
    /**
     * Checks to see if the JTS geometry is a 2D/3D object suitable for the GDB
     * @param geom The geometry to test. It must not contain Linear Referencing System (LRS)
     * values.
     * @return True if the JTS geometry is compatible with the DB column. False otherwise.
     */
    public boolean isCapable(Geometry geom);
    
}

