*/
@Override
public Measure distance(final double[] coord1, final double[] coord2)
throws UnsupportedOperationException, MismatchedDimensionException
{
final DefaultEllipsoidalCS cs;
final DefaultEllipsoid e;
if (!(coordinateSystem instanceof DefaultEllipsoidalCS)) {
throw new UnsupportedImplementationException(coordinateSystem.getClass());
}
final Ellipsoid ellipsoid = ((GeodeticDatum) datum).getEllipsoid();
if (!(ellipsoid instanceof DefaultEllipsoid)) {
throw new UnsupportedImplementationException(ellipsoid.getClass());
}
cs = (DefaultEllipsoidalCS) coordinateSystem;
e = (DefaultEllipsoid) ellipsoid;
if (coord1.length!=2 || coord2.length!=2 || cs.getDimension()!=2) {
/*
* Not yet implemented (an exception will be thrown later).
* We should probably revisit the way we compute distances.
*/
return super.distance(coord1, coord2);
}
return new Measure(e.orthodromicDistance(cs.getLongitude(coord1),
cs.getLatitude (coord1),
cs.getLongitude(coord2),
cs.getLatitude (coord2)), e.getAxisUnit());
}