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.crs.exceptions;
040:
041: import java.util.HashMap;
042: import java.util.List;
043: import java.util.Map;
044:
045: import javax.vecmath.Point3d;
046:
047: import org.deegree.crs.coordinatesystems.CoordinateSystem;
048:
049: /**
050: * The <code>TransformationException</code> class can be thrown if a transformation exception occurs. For example in
051: * the process of creating a transformation step.
052: *
053: * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
054: *
055: * @author last edited by: $Author:$
056: *
057: * @version $Revision:$, $Date:$
058: *
059: */
060:
061: public class TransformationException extends Exception {
062:
063: /**
064: *
065: */
066: private static final long serialVersionUID = 1475176551325426832L;
067:
068: private Map<Integer, String> transformErrors = new HashMap<Integer, String>();
069:
070: private List<Point3d> transformedPoints = null;
071:
072: /**
073: * Initializes the error message map with the given size.
074: *
075: * @param numberOfCoordinates
076: * in the list of coordinates which will be transformed.
077: */
078: public TransformationException(int numberOfCoordinates) {
079: if (numberOfCoordinates < 0) {
080: numberOfCoordinates = 0;
081: }
082: transformErrors = new HashMap<Integer, String>(
083: numberOfCoordinates);
084: }
085:
086: /**
087: * @param message
088: */
089: public TransformationException(String message) {
090: super (message);
091: }
092:
093: /**
094: * @param cause
095: */
096: public TransformationException(Throwable cause) {
097: super (cause);
098: }
099:
100: /**
101: * @param message
102: * @param cause
103: */
104: public TransformationException(String message, Throwable cause) {
105: super (message, cause);
106: }
107:
108: /**
109: * @param sourceCS
110: * from which crs
111: * @param targetCS
112: * to which crs
113: * @param cause
114: * for the exception.
115: */
116: public TransformationException(CoordinateSystem sourceCS,
117: CoordinateSystem targetCS, String cause) {
118: super (new StringBuilder("Can't transform from: ").append(
119: sourceCS.getIdentifier()).append(" into ").append(
120: targetCS.getIdentifier()).append(" because: ").append(
121: cause).toString());
122: }
123:
124: /**
125: * @return the transformErrors may be empty but will never be <code>null</code>.
126: */
127: public final Map<Integer, String> getTransformErrors() {
128: return transformErrors;
129: }
130:
131: /**
132: * @param coordinateNumber
133: * the position of the coordinate-tuple/triple which were responsible for the transformationexception.
134: * @param errorMessage
135: * the error message for given coordinate pair (in the array of coordinates).
136: */
137: public final void setTransformError(int coordinateNumber,
138: String errorMessage) {
139: String value = "";
140: Integer key = new Integer(coordinateNumber);
141: if (transformErrors.containsKey(key)
142: && transformErrors.get(key) != null) {
143: value = transformErrors.get(key) + ";";
144: }
145: value += errorMessage;
146: transformErrors.put(key, value);
147: }
148:
149: /**
150: * @return the transformedPoints, which are the points that were (successfully or unsuccessfully) transformed or <code>null</code> if no
151: * points were set.
152: */
153: public final List<Point3d> getTransformedPoints() {
154: return transformedPoints;
155: }
156:
157: /**
158: * @param transformedPoints which were (successfully or unsuccessfully) transformed until the exception(s) occurred.
159: */
160: public final void setTransformedPoints(
161: List<Point3d> transformedPoints) {
162: this.transformedPoints = transformedPoints;
163: }
164:
165: }
|