/*
* Geotools 2 - OpenSource mapping toolkit
* (C) 2003, Geotools Project Managment Committee (PMC)
* (C) 2001, Institut de Recherche pour le Développement
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* This package contains documentation from OpenGIS specifications.
* OpenGIS consortium's work is fully acknowledged here.
*/
package org.geotools.cs;
// OpenGIS dependencies
import java.rmi.RemoteException;
import java.util.Arrays;
import org.geotools.resources.i18n.ErrorKeys;
import org.geotools.resources.i18n.Errors;
import org.geotools.units.Unit;
import org.opengis.cs.CS_GeocentricCoordinateSystem;
import org.opengis.cs.CS_HorizontalDatum;
import org.opengis.cs.CS_LinearUnit;
import org.opengis.cs.CS_PrimeMeridian;
/**
* A 3D coordinate system, with its origin at the center of the Earth.
* The X axis points towards the prime meridian.
* The Y axis points East or West.
* The Z axis points North or South. By default, the
* Z axis will point North, and the Y axis
* will point East (e.g. a right handed system), but you should
* check the axes for non-default values.
*
* @source $URL$
* @version $Id$
* @author OpenGIS (www.opengis.org)
* @author Martin Desruisseaux
*
* @see org.opengis.cs.CS_GeocentricCoordinateSystem
*
* @deprecated Replaced by {@link org.geotools.referencing.crs.DefaultGeocentricCRS}.
*/
public class GeocentricCoordinateSystem extends CoordinateSystem {
/**
* Serial number for interoperability with different versions.
*/
private static final long serialVersionUID = -6577810243397267703L;
/**
* The set of default axis orientations.
* The X axis points towards the prime meridian.
* The Y axis points East.
* The Z axis points North.
*/
static final AxisInfo[] DEFAULT_AXIS = new AxisInfo[] {
new AxisInfo("x", AxisOrientation.OTHER),
new AxisInfo("y", AxisOrientation.EAST ),
new AxisInfo("z", AxisOrientation.NORTH)
};
/**
* The default geocentric coordinate system. Prime meridian is Greenwich,
* horizontal datum is WGS84 and linear units are metres.
* The X axis points towards the prime meridian.
* The Y axis points East.
* The Z axis points North.
*/
public static final GeocentricCoordinateSystem DEFAULT = (GeocentricCoordinateSystem) pool.canonicalize(
new GeocentricCoordinateSystem("WGS84", Unit.METRE, HorizontalDatum.WGS84,
PrimeMeridian.GREENWICH, DEFAULT_AXIS));
/**
* The linear unit.
*/
private final Unit unit;
/**
* The horizontal datum.
*/
private final HorizontalDatum datum;
/**
* The prime meridian.
*/
private final PrimeMeridian meridian;
/**
* The axis infos.
*/
private final AxisInfo[] axis;
/**
* Constructs a geocentric coordinate system with default
* axis. Units are metres and prime meridian is greenwich.
*
* @param name The coordinate system name.
* @param datum The horizontal datum.
*/
public GeocentricCoordinateSystem(final CharSequence name, final HorizontalDatum datum) {
this(name, Unit.METRE, datum, PrimeMeridian.GREENWICH);
}
/**
* Constructs a geocentric coordinate system with default axis.
* The X axis points towards the prime meridian.
* The Y axis points East.
* The Z axis points North.
*
* @param name The coordinate system name.
* @param unit The linear unit.
* @param datum The horizontal datum.
* @param meridian The prime meridian.
*/
public GeocentricCoordinateSystem(final CharSequence name,
final Unit unit,
final HorizontalDatum datum,
final PrimeMeridian meridian)
{
this(name, unit, datum, meridian, DEFAULT_AXIS);
}
/**
* Constructs a geocentric coordinate system.
*
* @param name The coordinate system name.
* @param unit The linear unit.
* @param datum The horizontal datum.
* @param meridian The prime meridian.
* @param axis The axis info. This is usually an array of length 3.
*/
public GeocentricCoordinateSystem(final CharSequence name,
final Unit unit,
final HorizontalDatum datum,
final PrimeMeridian meridian,
final AxisInfo[] axis)
{
super(name);
this.unit = unit;
this.datum = datum;
this.meridian = meridian;
ensureNonNull("axis", axis);
ensureNonNull("unit", unit);
ensureNonNull("datum", datum);
ensureNonNull("meridian", meridian);
ensureLinearUnit(unit);
this.axis = clone(axis);
}
/**
* Clones the specified axis array.
*/
private static AxisInfo[] clone(final AxisInfo[] axis) {
return Arrays.equals(axis, DEFAULT_AXIS) ? DEFAULT_AXIS : (AxisInfo[]) axis.clone();
}
/**
* Returns the dimension of this coordinate system, which is usually 3.
*
* @see org.opengis.cs.CS_GeocentricCoordinateSystem#getDimension()
*/
public int getDimension() {
return axis.length;
}
/**
* Overrides {@link CoordinateSystem#getLegacyDatum()}.
*
* @task REVISIT: in a future version (when J2SE 1.5 will be available), we may
* make this method public, change its return type to {@link HorizontalDatum}
* and deprecate the {@link #getHorizontalDatum} method.
*/
final Datum getLegacyDatum() {
return getHorizontalDatum();
}
/**
* Returns the horizontal datum.
* The horizontal datum is used to determine where the center of the Earth
* is considered to be. All coordinate points will be measured from the
* center of the Earth, and not the surface.
*
* @see org.opengis.cs.CS_GeocentricCoordinateSystem#getHorizontalDatum()
*
* @deprecated Replaced by {@link org.geotools.referencing.crs.DefaultGeocentricCRS#getDatum}.
*/
public HorizontalDatum getHorizontalDatum() {
return datum;
}
/**
* Gets units for dimension within coordinate system.
* For a GeocentricCoordinateSystem
, the
* units are the same for all axes.
*
* @param dimension Zero based index of axis.
*
* @see org.opengis.cs.CS_GeocentricCoordinateSystem#getUnits(int)
*
* @deprecated Replaced by {@link org.geotools.referencing.cs.DefaultCoordinateSystemAxis#getUnit}.
*/
public Unit getUnits(final int dimension) {
if (dimension>=0 && dimensionthis.
* @param compareNames true
to comparare the {@linkplain #getName name},
* {@linkplain #getAlias alias}, {@linkplain #getAuthorityCode authority
* code}, etc. as well, or false
to compare only properties
* relevant to transformations.
* @return true
if both objects are equal.
*/
public boolean equals(final Info object, final boolean compareNames) {
if (object == this) {
return true;
}
if (super.equals(object, compareNames)) {
final GeocentricCoordinateSystem that = (GeocentricCoordinateSystem) object;
return equals(this.unit, that.unit ) &&
equals(this.datum, that.datum, compareNames) &&
equals(this.meridian, that.meridian, compareNames);
}
return false;
}
/**
* Returns a hash value for this coordinate system. {@linkplain #getName Name},
* {@linkplain #getAlias alias}, {@linkplain #getAuthorityCode authority code}
* and the like are not taken in account. In other words, two coordinate systems
* will return the same hash value if they are equal in the sense of
* {@link #equals equals}(Info, false)
.
*
* @return The hash code value. This value doesn't need to be the same
* in past or future versions of this class.
*/
public int hashCode() {
return (int)serialVersionUID +
37*(datum .hashCode() +
37*(unit .hashCode() +
37*(meridian.hashCode())));
}
/**
* Fills the part inside "[...]".
* Used for formatting Well Known Text (WKT).
*/
String addString(final StringBuffer buffer, final Unit context) {
buffer.append(", ");
buffer.append(datum);
buffer.append(", ");
buffer.append(meridian);
buffer.append(", ");
addUnit(buffer, unit);
for (int i=0; i