/* * 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.ct; // 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.resources.XArray; import org.opengis.ct.CT_CoordinateTransformation; import org.opengis.ct.CT_CoordinateTransformationFactory; import org.opengis.ct.CT_DomainFlags; import org.opengis.ct.CT_MathTransform; import org.opengis.ct.CT_MathTransformFactory; import org.opengis.ct.CT_Parameter; import org.opengis.ct.CT_TransformType; import org.opengis.referencing.FactoryException; /** * Provide methods for interoperability with OpenGIS CT package. * All methods accept null argument. All OpenGIS objects are suitable for RMI use. * * @source $URL$ * @version $Id$ * @author Martin Desruisseaux * * @deprecated The legacy OpenGIS CT package is deprecated. * There is no replacement at this time for RMI objects. */ public class Adapters extends org.geotools.cs.Adapters { /** * Default adapters. Will be constructed * only when first requested. */ private static Adapters DEFAULT; /** * Construct an adapter with default factories. */ protected Adapters() { super(); } /** * 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. */ // protected Adapters(final CoordinateSystemFactory csFactory, // final MathTransformFactory mtFactory) // { // super(csFactory, mtFactory); // } /** * Gets the default adapters. */ public static synchronized Adapters getDefault() { if (DEFAULT == null) { DEFAULT = new Adapters(); } return DEFAULT; } /** * Returns an OpenGIS interface for a math transform. * @throws RemoteException if the object can't be exported. */ public CT_MathTransform export(final MathTransform transform) throws RemoteException { if (transform == null) { return null; } if (transform instanceof AbstractMathTransform) { final AbstractMathTransform atr = (AbstractMathTransform) transform; return (CT_MathTransform) atr.cachedOpenGIS(this); } throw new UnsupportedOperationException(); } /** * Returns an OpenGIS interface for a math transform. * @throws RemoteException if the object can't be exported. */ public CT_CoordinateTransformation export(final CoordinateTransformation transform) throws RemoteException { return (transform!=null) ? (CT_CoordinateTransformation)transform.cachedOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a math transform factory. * @throws RemoteException if the object can't be exported. */ public CT_MathTransformFactory export(final MathTransformFactory factory) throws RemoteException { return (factory!=null) ? (CT_MathTransformFactory)factory.toOpenGIS(this) : null; } /** * Returns an OpenGIS interface for a coordinate transformation factory. * @throws RemoteException if the object can't be exported. */ public CT_CoordinateTransformationFactory export(final CoordinateTransformationFactory factory) throws RemoteException { return (factory!=null) ? (CT_CoordinateTransformationFactory)factory.toOpenGIS(this) : null; } /** * Construct an array of OpenGIS structure from a parameter list. */ public CT_Parameter[] export(final ParameterList parameters) { if (parameters==null) { return null; } final String[] names = parameters.getParameterListDescriptor().getParamNames(); final CT_Parameter[] param = new CT_Parameter[names!=null ? names.length : 0]; int count=0; for (int i=0; i