001 /*
002 * GeoAPI - Java interfaces for OGC/ISO standards
003 * http://www.geoapi.org
004 *
005 * Copyright (C) 2004-2012 Open Geospatial Consortium, Inc.
006 * All Rights Reserved. http://www.opengeospatial.org/ogc/legal
007 *
008 * Permission to use, copy, and modify this software and its documentation, with
009 * or without modification, for any purpose and without fee or royalty is hereby
010 * granted, provided that you include the following on ALL copies of the software
011 * and documentation or portions thereof, including modifications, that you make:
012 *
013 * 1. The full text of this NOTICE in a location viewable to users of the
014 * redistributed or derivative work.
015 * 2. Notice of any changes or modifications to the OGC files, including the
016 * date changes were made.
017 *
018 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
019 * NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
020 * TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
021 * THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
022 * PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
023 *
024 * COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
025 * CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
026 *
027 * The name and trademarks of copyright holders may NOT be used in advertising or
028 * publicity pertaining to the software without specific, written prior permission.
029 * Title to copyright in this software and any associated documentation will at all
030 * times remain with copyright holders.
031 */
032 package org.opengis.referencing.operation;
033
034 import org.opengis.geometry.DirectPosition; // For javadoc
035
036
037 /**
038 * Common superclass for a number of transformation-related exceptions.
039 * {@code TransformException} are thrown by {@link MathTransform}
040 * when a coordinate transformation can't be {@linkplain MathTransform#inverse inverted}
041 * ({@link NoninvertibleTransformException}), when the
042 * {@linkplain MathTransform#derivative derivative} can't be computed or when a coordinate
043 * can't be {@linkplain MathTransform#transform(DirectPosition, DirectPosition) transformed}.
044 * It is also thrown when {@link CoordinateOperationFactory} fails to find a path between two
045 * {@linkplain org.opengis.referencing.crs.CoordinateReferenceSystem coordinate reference systems}.
046 *
047 * @departure extension
048 * This exception is not part of the OGC specification.
049 *
050 * @author Martin Desruisseaux (IRD)
051 * @version 3.0
052 * @since 1.0
053 */
054 public class TransformException extends Exception {
055 /**
056 * Serial number for inter-operability with different versions.
057 */
058 private static final long serialVersionUID = -8923944544398567533L;
059
060 /**
061 * The last transform that either transformed successfully all coordinates, or filled the
062 * untransformable coordinates with {@linkplain Double#NaN NaN} values. This information
063 * is useful in the context of concatenated transforms. May be {@code null} if unknown.
064 *
065 * @see #getLastCompletedTransform()
066 * @see #setLastCompletedTransform(MathTransform)
067 *
068 * @since 2.2
069 */
070 private MathTransform lastCompletedTransform;
071
072 /**
073 * Constructs an exception with no detail message.
074 */
075 public TransformException() {
076 }
077
078 /**
079 * Constructs an exception with the specified detail message.
080 *
081 * @param message The detail message. The detail message is saved
082 * for later retrieval by the {@link #getMessage()} method.
083 */
084 public TransformException(String message) {
085 super(message);
086 }
087
088 /**
089 * Constructs an exception with the specified detail message and cause.
090 *
091 * @param message The detail message. The detail message is saved
092 * for later retrieval by the {@link #getMessage()} method.
093 * @param cause The cause for this exception. The cause is saved
094 * for later retrieval by the {@link #getCause()} method.
095 */
096 public TransformException(String message, Throwable cause) {
097 super(message, cause);
098 }
099
100 /**
101 * Returns the last transform that either transformed successfully all coordinates, or filled
102 * the untransformable coordinates with {@linkplain Double#NaN NaN} values. This information
103 * is useful in the context of concatenated transforms. May be {@code null} if unknown.
104 *
105 * @return The last reliable transform.
106 *
107 * @since 2.2
108 */
109 public MathTransform getLastCompletedTransform() {
110 return lastCompletedTransform;
111 }
112
113 /**
114 * Sets the last transform that either transformed successfully all coordinates, or
115 * filled the untransformable coordinates with {@linkplain Double#NaN NaN} values.
116 *
117 * @param transform The last reliable transform.
118 *
119 * @since 2.2
120 */
121 public void setLastCompletedTransform(final MathTransform transform) {
122 lastCompletedTransform = transform;
123 }
124 }