/* * Geotools 2 - OpenSource mapping toolkit * (C) 2003, Geotools Project Managment Committee (PMC) * (C) 2001, Institut de Recherche pour le Développement * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * This package contains documentation from OpenGIS specifications. * OpenGIS consortium's work is fully acknowledged here. */ package org.geotools.cs; // OpenGIS dependencies import java.rmi.RemoteException; import java.rmi.ServerException; import javax.media.jai.ParameterList; import javax.media.jai.ParameterListDescriptorImpl; import javax.media.jai.ParameterListImpl; import org.geotools.ct.MathTransformFactory; import org.geotools.resources.RemoteProxy; import org.geotools.resources.XArray; import org.geotools.resources.i18n.ErrorKeys; import org.geotools.resources.i18n.Errors; import org.geotools.units.Unit; import org.opengis.cs.CS_AngularUnit; import org.opengis.cs.CS_AxisInfo; import org.opengis.cs.CS_AxisOrientationEnum; import org.opengis.cs.CS_CompoundCoordinateSystem; import org.opengis.cs.CS_CoordinateSystem; import org.opengis.cs.CS_CoordinateSystemAuthorityFactory; import org.opengis.cs.CS_CoordinateSystemFactory; import org.opengis.cs.CS_Datum; import org.opengis.cs.CS_DatumType; import org.opengis.cs.CS_Ellipsoid; import org.opengis.cs.CS_FittedCoordinateSystem; import org.opengis.cs.CS_GeocentricCoordinateSystem; import org.opengis.cs.CS_GeographicCoordinateSystem; import org.opengis.cs.CS_HorizontalCoordinateSystem; import org.opengis.cs.CS_HorizontalDatum; import org.opengis.cs.CS_Info; import org.opengis.cs.CS_LinearUnit; import org.opengis.cs.CS_LocalCoordinateSystem; import org.opengis.cs.CS_LocalDatum; import org.opengis.cs.CS_PrimeMeridian; import org.opengis.cs.CS_ProjectedCoordinateSystem; import org.opengis.cs.CS_Projection; import org.opengis.cs.CS_ProjectionParameter; import org.opengis.cs.CS_Unit; import org.opengis.cs.CS_VerticalCoordinateSystem; import org.opengis.cs.CS_VerticalDatum; import org.opengis.cs.CS_WGS84ConversionInfo; import org.opengis.referencing.FactoryException; /** * Provide methods for interoperability with OpenGIS CS package. * All methods accept null argument. All OpenGIS objects are suitable for RMI use. * * A default instance of the Adapters classes is provided in the * {@link org.geotools.ct.Adapters#getDefault() org.geotools.ct} package. * * @source $URL$ * @version $Id$ * @author Martin Desruisseaux * * @see org.geotools.ct.Adapters#getDefault() * * @deprecated The legacy OpenGIS CS package is deprecated. * There is no replacement at this time for RMI objects. */ public class Adapters extends org.geotools.pt.Adapters { /** * The factory to use for creating {@link CoordinateSystem} objects. */ protected final CoordinateSystemFactory csFactory; /** * The factory to use for creating {@link MathTransform} objects. * This is used by {@link #wrap(CS_FittedCoordinateSystem)}. * * @task REVISIT: Commented out for now in order to avoid premature class loading. */ // protected final MathTransformFactory mtFactory; /** * Construct an adapter with default factories. */ protected Adapters() { csFactory = CoordinateSystemFactory.getDefault(); // mtFactory = MathTransformFactory.getDefault(); } /** * Construct an adapter with the specified factories. * * @param csFactory The factory to use for creating {@link CoordinateSystem} objects. * @param mtFactory The factory to use for creating {@link MathTransform} objects. * This is used by {@link #wrap(CS_FittedCoordinateSystem)}. */ // protected Adapters(final CoordinateSystemFactory csFactory, // final MathTransformFactory mtFactory) // { // this.csFactory = csFactory; // this.mtFactory = mtFactory; // } /** * Returns an OpenGIS interface for a coordinate system authority factory. * @throws RemoteException if the object can't be exported. */ public CS_CoordinateSystemAuthorityFactory export(final CoordinateSystemAuthorityFactory factory) throws RemoteException { return (factory!=null) ? (CS_CoordinateSystemAuthorityFactory)factory.toOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a coordinate system factory. * @throws RemoteException if the object can't be exported. */ public CS_CoordinateSystemFactory export(final CoordinateSystemFactory factory) throws RemoteException { return (factory!=null) ? (CS_CoordinateSystemFactory)factory.toOpenGIS(this) : null; } /** * Returns an OpenGIS interface for an info. If the argument is an * Info subclass, the returned object will implement * the corresponding interface. For example, a call with an argument * of type {@link GeographicCoordinateSystem} will return an object * implementing the {@link CS_GeographicCoordinateSystem} interface. * * @throws RemoteException if the object can't be exported. */ public CS_Info export(final Info info) throws RemoteException { return (info!=null) ? (CS_Info)info.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a coordinate system. If the argument * is a CoordinateSystem subclass, the returned object will * implement the corresponding interface. * * @throws RemoteException if the object can't be exported. */ public CS_CoordinateSystem export(final CoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_CoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a fitted coordinate system. * @throws RemoteException if the object can't be exported. */ public CS_FittedCoordinateSystem export(final FittedCoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_FittedCoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a compound coordinate system. * @throws RemoteException if the object can't be exported. */ public CS_CompoundCoordinateSystem export(final CompoundCoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_CompoundCoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a local coordinate system. * @throws RemoteException if the object can't be exported. */ public CS_LocalCoordinateSystem export(final LocalCoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_LocalCoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a geocentric coordinate system. * @throws RemoteException if the object can't be exported. */ public CS_GeocentricCoordinateSystem export(final GeocentricCoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_GeocentricCoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a vertical coordinate system. * @throws RemoteException if the object can't be exported. */ public CS_VerticalCoordinateSystem export(final VerticalCoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_VerticalCoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a horizontal coordinate system. * @throws RemoteException if the object can't be exported. */ public CS_HorizontalCoordinateSystem export(final HorizontalCoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_HorizontalCoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a geographic coordinate system. * @throws RemoteException if the object can't be exported. */ public CS_GeographicCoordinateSystem export(final GeographicCoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_GeographicCoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a projected coordinate system. * @throws RemoteException if the object can't be exported. */ public CS_ProjectedCoordinateSystem export(final ProjectedCoordinateSystem cs) throws RemoteException { return (cs!=null) ? (CS_ProjectedCoordinateSystem)cs.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a projection. * @throws RemoteException if the object can't be exported. */ public CS_Projection export(final Projection projection) throws RemoteException { return (projection!=null) ? (CS_Projection)projection.cachedOpenGIS(this) : null; } /** * Constructs an array of OpenGIS structures from a parameters list. * This method is named exportProjectionParameters in * order to avoid conflict with {@link org.geotools.ct.Adapters#export(ParameterList)}. */ final CS_ProjectionParameter[] exportProjectionParameters(final ParameterList parameters) { if (parameters == null) { return null; } final String[] names = parameters.getParameterListDescriptor().getParamNames(); final CS_ProjectionParameter[] param = new CS_ProjectionParameter[names!=null ? names.length : 0]; int count=0; for (int i=0; i