GeodeticCalculator changes for revisions 10795:10796

Changes in this commit seem to be the result of some "auto reformat" tool execution. The Java - GeoAPI - GeoTools import ordering is altered, imports used only in Javadoc are lost and the encoding of non-ASCII characters is broken. This commit has been reverted, except for the removal of really unused imports which are kept removed.

Command line:

svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r10795:10796 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/GeodeticCalculator.java
Revision 10795Revision 10796
// J2SE dependencies
import java.awt.Shape;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
import java.awt.geom.IllegalPathStateException;
import java.util.ArrayList;
import java.util.List;

// JTS dependencies
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.LinearRing;
import com.vividsolutions.jts.geom.MultiLineString;
import com.vividsolutions.jts.geom.GeometryFactory;

// OpenGIS dependencies
import org.opengis.referencing.datum.Ellipsoid;

// Geotools dependencies
import org.geotools.measure.Latitude;
import org.geotools.measure.Longitude;
import org.geotools.measure.CoordinateFormat;
import org.geotools.geometry.GeneralDirectPosition;
import org.geotools.resources.cts.Resources;
import org.geotools.resources.cts.ResourceKeys;
import org.geotools.resources.geometry.ShapeUtilities;


/**
 * Performs geodetic calculations on an ellipsoid. This class encapsulate a generic ellipsoid
 * and calculate the following properties:
// J2SE dependencies
import java.awt.Shape;
import java.awt.geom.GeneralPath;
import java.awt.geom.IllegalPathStateException;
import java.awt.geom.Line2D;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;

import org.geotools.geometry.GeneralDirectPosition;
import org.geotools.measure.CoordinateFormat;
import org.geotools.measure.Latitude;
import org.geotools.measure.Longitude;
import org.geotools.resources.cts.ResourceKeys;
import org.geotools.resources.cts.Resources;
import org.geotools.resources.geometry.ShapeUtilities;
import org.opengis.referencing.datum.Ellipsoid;

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.LinearRing;
import com.vividsolutions.jts.geom.MultiLineString;


/**
 * Performs geodetic calculations on an ellipsoid. This class encapsulate a generic ellipsoid
 * and calculate the following properties:
 * the {@linkplain #getDestinationPoint() destination point} are discarted.
 * They will need to be specified again.
 *
 * @param  longitude The longitude in degrees between -180 and +180°
 * @param  latitude  The latitude  in degrees between  -90 and  +90°
 * @throws IllegalArgumentException if the longitude or the latitude is out of bounds.
 */
public void setAnchorPoint(double longitude, double latitude) throws IllegalArgumentException {
 * the {@linkplain #getDestinationPoint() destination point} are discarted.
 * They will need to be specified again.
 *
 * @param  longitude The longitude in degrees between -180 and +180�
 * @param  latitude  The latitude  in degrees between  -90 and  +90�
 * @throws IllegalArgumentException if the longitude or the latitude is out of bounds.
 */
public void setAnchorPoint(double longitude, double latitude) throws IllegalArgumentException {
 * effect of this call. They will be recomputed the next time {@link #getAzimuth()} or
 * {@link #getOrthodromicDistance()} are invoked.
 *
 * @param  longitude The longitude in degrees between -180 and +180°
 * @param  latitude  The latgitude in degrees between  -90 and  +90°
 * @throws IllegalArgumentException if the longitude or the latitude is out of bounds.
 */
public void setDestinationPoint(double longitude, double latitude) throws IllegalArgumentException {
 * effect of this call. They will be recomputed the next time {@link #getAzimuth()} or
 * {@link #getOrthodromicDistance()} are invoked.
 *
 * @param  longitude The longitude in degrees between -180 and +180�
 * @param  latitude  The latgitude in degrees between  -90 and  +90�
 * @throws IllegalArgumentException if the longitude or the latitude is out of bounds.
 */
public void setDestinationPoint(double longitude, double latitude) throws IllegalArgumentException {
* The destination point will be updated as a side effect of this call. It will be
* recomputed the next time {@link #getDestinationPoint()} is invoked.
*
* @param  azimuth The azimuth in degrees from -180° to 180°.
* @param  distance The orthodromic distance in the same units as the
*         {@linkplain #getEllipsoid ellipsoid} axis.
* @throws IllegalArgumentException if the azimuth or the distance is out of bounds.
* The destination point will be updated as a side effect of this call. It will be
* recomputed the next time {@link #getDestinationPoint()} is invoked.
*
* @param  azimuth The azimuth in degrees from -180� to 180�.
* @param  distance The orthodromic distance in the same units as the
*         {@linkplain #getEllipsoid ellipsoid} axis.
* @throws IllegalArgumentException if the azimuth or the distance is out of bounds.
 * has been invoked after. In this later case, the azimuth will be computed from the
 * {@linkplain #getAnchorPoint anchor point} to the destination point.
 *
 * @return The azimuth, in degrees from -180° to +180°.
 * @throws IllegalStateException if the destination point has not been set.
 */
public double getAzimuth() throws IllegalStateException {
 * has been invoked after. In this later case, the azimuth will be computed from the
 * {@linkplain #getAnchorPoint anchor point} to the destination point.
 *
 * @return The azimuth, in degrees from -180� to +180�.
 * @throws IllegalStateException if the destination point has not been set.
 */
public double getAzimuth() throws IllegalStateException {
 *         {@linkplain #getAnchorPoint anchor point} to the
 *         {@linkplain #getDestinationPoint destination point}.
 *
 * @todo We should check for cases where the path cross the 90°N, 90°S, 90°E or 90°W boundaries.
 */
public Shape getGeodeticCurve(final int numberOfPoints) {
    checkNumberOfPoints(numberOfPoints);
 *         {@linkplain #getAnchorPoint anchor point} to the
 *         {@linkplain #getDestinationPoint destination point}.
 *
 * @todo We should check for cases where the path cross the 90�N, 90�S, 90�E or 90�W boundaries.
 */
public Shape getGeodeticCurve(final int numberOfPoints) {
    checkNumberOfPoints(numberOfPoints);
** THE FOLLOWING IS CHECKED FOR COMPILER ERROR, BUT EXCLUDED FROM THE .class FILE.  **
** THIS CODE IS WRONG: LOXODROMIC CURVES ARE STRAIGHT LINES IN MERCATOR PROJECTION, **
** NOT IT PLAIN (longitude,latitude) SPACE. FURTHERMORE, THE "OUT OF BOUNDS" CHECK  **
** IS UNFINISHED: WHEN THE PATH CROSS THE 180° LONGITUDE, A +360° ADDITION NEED TO  **
** BE PERFORMED ON ONE OF THE SOURCE OR TARGET POINT  BEFORE TO COMPUTE THE LINEAR  **
** INTERPOLATION (OTHERWISE, THE SLOPE VALUE IS WRONG). FORMULAS FOR COMPUTING MID- **
** POINT ON A LOXODROMIC CURVE ARE AVAILABLE THERE:                                 **
** THE FOLLOWING IS CHECKED FOR COMPILER ERROR, BUT EXCLUDED FROM THE .class FILE.  **
** THIS CODE IS WRONG: LOXODROMIC CURVES ARE STRAIGHT LINES IN MERCATOR PROJECTION, **
** NOT IT PLAIN (longitude,latitude) SPACE. FURTHERMORE, THE "OUT OF BOUNDS" CHECK  **
** IS UNFINISHED: WHEN THE PATH CROSS THE 180� LONGITUDE, A +360� ADDITION NEED TO  **
** BE PERFORMED ON ONE OF THE SOURCE OR TARGET POINT  BEFORE TO COMPUTE THE LINEAR  **
** INTERPOLATION (OTHERWISE, THE SLOPE VALUE IS WRONG). FORMULAS FOR COMPUTING MID- **
** POINT ON A LOXODROMIC CURVE ARE AVAILABLE THERE:                                 **
if (Boolean.FALSE.equals(yDirect)) {
    /*
     * Crossing North or South pole is more complicated than what we do for now: If we
     * follow the 0° longitude toward North, then we have to follow the 180° longitude
     * from North to South pole and follow the 0° longitude again toward North up to
     * the destination point.
     */
    throw new UnsupportedOperationException("Crossing pole is not yet implemented");
if (Boolean.FALSE.equals(yDirect)) {
    /*
     * Crossing North or South pole is more complicated than what we do for now: If we
     * follow the 0� longitude toward North, then we have to follow the 180� longitude
     * from North to South pole and follow the 0� longitude again toward North up to
     * the destination point.
     */
    throw new UnsupportedOperationException("Crossing pole is not yet implemented");
}
/*
 * The azimuth is heading in the opposite direction of the path from P1 to P2. Computes
 * the intersection points at the 90°N / 90°S boundaries, or the 180°E / 180°W boundaries.
 * (xout,yout) is the point where the path goes out (initialized to the corner where the
 * azimuth is heading); (xin,yin) is the point where the path come back in the opposite
 * hemisphere.
}
/*
 * The azimuth is heading in the opposite direction of the path from P1 to P2. Computes
 * the intersection points at the 90�N / 90�S boundaries, or the 180�E / 180�W boundaries.
 * (xout,yout) is the point where the path goes out (initialized to the corner where the
 * azimuth is heading); (xin,yin) is the point where the path come back in the opposite
 * hemisphere.
 * The path is diagonal (neither horizontal or vertical). The following loop
 * is executed exactly twice:  the first pass computes the "out" point,  and
 * the second pass computes the "in" point.  Each pass computes actually two
 * points: the intersection point against the 180°W or 180°E boundary, and
 * the intersection point against the 90°N or 90°S boundary. Usually one of
 * those points will be out of range and the other one is selected.
 */
boolean in = false;
do {
    final double meridX, meridY; // The point where the path cross the +/-180° meridian.
    final double zonalX, zonalY; // The point where the path cross the +/- 90° parallel.
    meridX = in ? xin : xout;    meridY = dy/dx * (meridX-x1) + y1;
    zonalY = in ? yin : yout;    zonalX = dx/dy * (zonalY-y1) + x1;
    if (Math.abs(meridY) < Math.abs(zonalX)*0.5) {
 * The path is diagonal (neither horizontal or vertical). The following loop
 * is executed exactly twice:  the first pass computes the "out" point,  and
 * the second pass computes the "in" point.  Each pass computes actually two
 * points: the intersection point against the 180�W or 180�E boundary, and
 * the intersection point against the 90�N or 90�S boundary. Usually one of
 * those points will be out of range and the other one is selected.
 */
boolean in = false;
do {
    final double meridX, meridY; // The point where the path cross the +/-180� meridian.
    final double zonalX, zonalY; // The point where the path cross the +/- 90� parallel.
    meridX = in ? xin : xout;    meridY = dy/dx * (meridX-x1) + y1;
    zonalY = in ? yin : yout;    zonalX = dx/dy * (zonalY-y1) + x1;
    if (Math.abs(meridY) < Math.abs(zonalX)*0.5) {