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.ArrayList;
042: import java.util.List;
043:
044: import javax.vecmath.Point3d;
045:
046: import org.deegree.framework.log.ILogger;
047: import org.deegree.framework.log.LoggerFactory;
048: import org.deegree.model.crs.CRSTransformationException;
049: import org.deegree.model.crs.CoordinateSystem;
050: import org.deegree.model.crs.GeoTransformer;
051:
052: /**
053: * <code>SimpleData</code> takes a list of points which will be transformed.
054: *
055: * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
056: *
057: * @author last edited by: $Author:$
058: *
059: * @version $Revision:$, $Date:$
060: *
061: */
062: public class SimpleData extends TransformableData<Point3d> {
063: private static ILogger LOG = LoggerFactory
064: .getLogger(SimpleData.class);
065:
066: /**
067: * The coordinate separator, default to ','
068: */
069: private final String cs;
070:
071: /**
072: * The tuple separator, default to ' '
073: */
074: private final String ts;
075:
076: private List<Point3d> sourcePoints;
077:
078: /**
079: * Creates a simple data instance.
080: *
081: * @param sourceCRS
082: * in which the data is referenced.
083: * @param targetCRS
084: * to which the data should be transformed.
085: * @param transformableData
086: * @param cs the coordinate separator
087: * @param ts the tuple separator
088: * @throws IllegalArgumentException
089: * if either one of the crs's are <code>null</code>.
090: */
091: public SimpleData(CoordinateSystem sourceCRS,
092: CoordinateSystem targetCRS,
093: List<Point3d> transformableData, String cs, String ts)
094: throws IllegalArgumentException {
095: super (sourceCRS, targetCRS);
096: if (transformableData == null) {
097: transformableData = new ArrayList<Point3d>();
098: }
099: this .sourcePoints = transformableData;
100: if (cs == null || "".equals(cs)) {
101: cs = ",";
102: }
103: this .cs = cs;
104:
105: if (ts == null || "".equals(ts)) {
106: ts = " ";
107: }
108: this .ts = ts;
109: }
110:
111: /*
112: * (non-Javadoc)
113: *
114: * @see org.deegree.ogcwebservices.wcts.operation.TransformableData#doTransform(org.deegree.model.crs.CoordinateSystem,
115: * org.deegree.model.crs.CoordinateSystem, boolean)
116: */
117: @Override
118: public void doTransform(boolean enableLogging) {
119: GeoTransformer transformer = getGeotransformer();
120: try {
121: sourcePoints = transformer.transform(getSourceCRS(),
122: sourcePoints);
123: } catch (IllegalArgumentException e) {
124: LOG.logError(e.getMessage(), e);
125: } catch (CRSTransformationException e) {
126: LOG.logError(e.getMessage(), e);
127: }
128: }
129:
130: /*
131: * (non-Javadoc)
132: *
133: * @see org.deegree.ogcwebservices.wcts.operation.TransformableData#getResult()
134: */
135: @Override
136: public List<Point3d> getTransformedData() {
137: return sourcePoints;
138: }
139:
140: /**
141: * @return the value for the ts attribute, defaults to a single space character.
142: */
143: public final String getTupleSeparator() {
144: return ts;
145: }
146:
147: /**
148: * @return the value for the cs attribute, defaults to a single comma character.
149: */
150: public final String getCoordinateSeparator() {
151: return cs;
152: }
153:
154: }
|