001: //$HeadURL: $
002: /*---------------- FILE HEADER ------------------------------------------
003: This file is part of deegree.
004: Copyright (C) 2001-2008 by:
005: Department of Geography, University of Bonn
006: http://www.giub.uni-bonn.de/deegree/
007: lat/lon GmbH
008: http://www.lat-lon.de
009:
010: This library is free software; you can redistribute it and/or
011: modify it under the terms of the GNU Lesser General Public
012: License as published by the Free Software Foundation; either
013: version 2.1 of the License, or (at your option) any later version.
014: This library is distributed in the hope that it will be useful,
015: but WITHOUT ANY WARRANTY; without even the implied warranty of
016: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: Lesser General Public License for more details.
018: You should have received a copy of the GNU Lesser General Public
019: License along with this library; if not, write to the Free Software
020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021: Contact:
022:
023: Andreas Poth
024: lat/lon GmbH
025: Aennchenstr. 19
026: 53177 Bonn
027: Germany
028: E-Mail: poth@lat-lon.de
029:
030: Prof. Dr. Klaus Greve
031: Department of Geography
032: University of Bonn
033: Meckenheimer Allee 166
034: 53115 Bonn
035: Germany
036: E-Mail: greve@giub.uni-bonn.de
037: ---------------------------------------------------------------------------*/
038:
039: package org.deegree.ogcwebservices.wcts.data;
040:
041: import java.util.List;
042:
043: import javax.vecmath.Point3d;
044:
045: import org.deegree.i18n.Messages;
046: import org.deegree.model.crs.CoordinateSystem;
047: import org.deegree.model.crs.GeoTransformer;
048: import org.deegree.model.spatialschema.Geometry;
049: import org.deegree.ogcwebservices.OGCWebServiceException;
050:
051: /**
052: * <code>TransformableData</code> defines the interface for different kinds of Data, which can be transformed.
053: *
054: * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
055: *
056: * @author last edited by: $Author:$
057: *
058: * @version $Revision:$, $Date:$
059: * @param <T>
060: * the type of data.
061: *
062: */
063: public abstract class TransformableData<T> {
064:
065: private final CoordinateSystem targetCRS;
066:
067: private final CoordinateSystem sourceCRS;
068:
069: /**
070: * The parent of all transformable data.
071: *
072: * @param sourceCRS
073: * in which the data is referenced.
074: * @param targetCRS
075: * to which the data should be transformed.
076: * @throws IllegalArgumentException
077: * if either one of the crs's are <code>null</code>.
078: */
079: public TransformableData(CoordinateSystem sourceCRS,
080: CoordinateSystem targetCRS) throws IllegalArgumentException {
081: if (sourceCRS == null) {
082: throw new IllegalArgumentException(Messages.getMessage(
083: "WCTS_MISSING_ARGUMENT", "sourceCRS"));
084: }
085: if (targetCRS == null) {
086: throw new IllegalArgumentException(Messages.getMessage(
087: "WCTS_MISSING_ARGUMENT", "targetCRS"));
088:
089: }
090: this .sourceCRS = sourceCRS;
091: this .targetCRS = targetCRS;
092: }
093:
094: /**
095: * This function should implement the transforming of the underlying data.
096: *
097: * @param enableLogging
098: * if true the implementing class should log all transformations.
099: * @throws OGCWebServiceException if an exception occurs while transforming.
100: */
101: public abstract void doTransform(boolean enableLogging)
102: throws OGCWebServiceException;
103:
104: /**
105: * @return the targetCRS.
106: */
107: public final CoordinateSystem getTargetCRS() {
108: return targetCRS;
109: }
110:
111: /**
112: * @return the sourceCRS.
113: */
114: public final CoordinateSystem getSourceCRS() {
115: return sourceCRS;
116: }
117:
118: /**
119: * @return a new GeoTransformer instance initialized with the targetCRS.
120: */
121: public final GeoTransformer getGeotransformer() {
122: return new GeoTransformer(targetCRS);
123: }
124:
125: /**
126: * @return the transformed data as a list of the overriding class implementation, for example {@link Geometry}
127: * (GeometyData), or {@link Point3d} (SimpleData).
128: */
129: public abstract List<T> getTransformedData();
130:
131: }
|