It is perfectly legal to use a CoordTransform object directly to tranform positions without having to attach it to a CoordinateSystem. In this case, one would use one of the following CoordTransform methods:
When you use the transforming methods directly, you may need to be
prepared to catch two possible CoordTransformExceptions:
PositionBeyondDomainException and
[4]
TransformUndefinedException. One of these exceptions may be
thrown if there is no logical or mathematical tranform for the input
position. For example, the LinToSphLinCoordTransform class is
used to project a flat surface onto a sphere using one of a variety of
projection scheme (e.g. mercatur, sinusoidal, etc.). With certain
projections, not all positions in the ``map'' plane correspond to
positions on a globe; these positions would throw a
[4]
PositionBeyondDomainException.
There are a few thing that you should note when using the transforming methods directly. First, in the interest of speed and efficiency, the transforming method has the option of overwriting the values within the input array. They also have the option of creating and returning a new array to hold the tranformed position. Therefore, after calling either forward() or reverse(), always assume that the input position has been corrupted and that the output position has the value you want. A good way to implement this tip would be with the following code:
double pos = { 1.0, 234.25, 18.5 };
pos = conversion.forward(pos);
The second thing to keep in mind is that the number of input axes need not equal the number of output axes (here would be a case where the transform would have to create a new array to hold the output position). Unless you know at programming time what the effect of the transform is, you should check the length of the output array before accessing the output position values.