You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2013/11/24 05:51:23 UTC
svn commit: r1544911 - in
/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis:
referencing/cs/ test/suite/
Author: desruisseaux
Date: Sun Nov 24 04:51:23 2013
New Revision: 1544911
URL: http://svn.apache.org/r1544911
Log:
Added tests.
Added:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java (with props)
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java (with props)
Modified:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java?rev=1544911&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java [UTF-8] Sun Nov 24 04:51:23 2013
@@ -0,0 +1,430 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.cs;
+
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.RangeMeaning;
+import javax.measure.unit.NonSI;
+import javax.measure.unit.SI;
+import javax.measure.unit.Unit;
+
+import static java.util.Collections.singletonMap;
+
+
+/**
+ * Collection of axes for testing purpose.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.4
+ * @version 0.4
+ * @module
+ */
+@SuppressWarnings("serial")
+public final strictfp class CommonAxes {
+ /**
+ * Axis info for geodetic longitudes in a
+ * {@linkplain org.opengis.referencing.crs.GeographicCRS geographic CRS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#EAST East}
+ * and units are {@linkplain NonSI#DEGREE_ANGLE degrees}.
+ * The ISO 19111 name is "<cite>geodetic longitude</cite>" and the abbreviation is "λ" (lambda).
+ *
+ * <p>This axis is usually part of a {@link #GEODETIC_LONGITUDE}, {@link #GEODETIC_LATITUDE},
+ * {@link #ELLIPSOIDAL_HEIGHT} set.</p>
+ *
+ * @see #LONGITUDE
+ * @see #SPHERICAL_LONGITUDE
+ * @see #GEODETIC_LATITUDE
+ */
+ public static final DefaultCoordinateSystemAxis GEODETIC_LONGITUDE = create("Geodetic longitude", "λ",
+ AxisDirection.EAST, 180, NonSI.DEGREE_ANGLE);
+
+ /**
+ * Default axis info for geodetic latitudes in a
+ * {@linkplain org.opengis.referencing.crs.GeographicCRS geographic CRS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#NORTH North}
+ * and units are {@linkplain NonSI#DEGREE_ANGLE degrees}.
+ * The ISO 19111 name is "<cite>geodetic latitude</cite>" and the abbreviation is "φ" (phi).
+ *
+ * <p>This axis is usually part of a {@link #GEODETIC_LONGITUDE}, {@link #GEODETIC_LATITUDE},
+ * {@link #ELLIPSOIDAL_HEIGHT} set.</p>
+ *
+ * @see #LATITUDE
+ * @see #SPHERICAL_LATITUDE
+ * @see #GEODETIC_LONGITUDE
+ */
+ public static final DefaultCoordinateSystemAxis GEODETIC_LATITUDE = create("Geodetic latitude", "φ",
+ AxisDirection.NORTH, 90, NonSI.DEGREE_ANGLE);
+
+ /**
+ * Default axis info for longitudes.
+ * Increasing ordinates values go {@linkplain AxisDirection#EAST East}
+ * and units are {@linkplain NonSI#DEGREE_ANGLE degrees}.
+ * The abbreviation is "λ" (lambda).
+ *
+ * <p>This axis is usually part of a {@link #LONGITUDE}, {@link #LATITUDE}, {@link #ALTITUDE} set.</p>
+ *
+ * @see #GEODETIC_LONGITUDE
+ * @see #SPHERICAL_LONGITUDE
+ * @see #LATITUDE
+ */
+ public static final DefaultCoordinateSystemAxis LONGITUDE = create("Longitude", "λ",
+ AxisDirection.EAST, 180, NonSI.DEGREE_ANGLE);
+
+ /**
+ * Default axis info for latitudes.
+ * Increasing ordinates values go {@linkplain AxisDirection#NORTH North}
+ * and units are {@linkplain NonSI#DEGREE_ANGLE degrees}.
+ * The abbreviation is "φ" (phi).
+ *
+ * <p>This axis is usually part of a {@link #LONGITUDE}, {@link #LATITUDE}, {@link #ALTITUDE} set.</p>
+ *
+ * @see #GEODETIC_LATITUDE
+ * @see #SPHERICAL_LATITUDE
+ * @see #LONGITUDE
+ */
+ public static final DefaultCoordinateSystemAxis LATITUDE = create("Latitude", "φ",
+ AxisDirection.NORTH, 90, NonSI.DEGREE_ANGLE);
+
+ /**
+ * The default axis for height values above the ellipsoid in a
+ * {@linkplain org.opengis.referencing.crs.GeographicCRS geographic CRS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#UP up} and units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>ellipsoidal heigt</cite>" and the abbreviation is lower case "<var>h</var>".
+ *
+ * <p>This axis is usually part of a {@link #GEODETIC_LONGITUDE}, {@link #GEODETIC_LATITUDE},
+ * {@link #ELLIPSOIDAL_HEIGHT} set.</p>
+ *
+ * @see #ALTITUDE
+ * @see #GEOCENTRIC_RADIUS
+ * @see #GRAVITY_RELATED_HEIGHT
+ * @see #DEPTH
+ */
+ public static final DefaultCoordinateSystemAxis ELLIPSOIDAL_HEIGHT = create("Ellipsoidal height", "h",
+ AxisDirection.UP, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * The default axis for height values measured from gravity.
+ * Increasing ordinates values go {@linkplain AxisDirection#UP up} and units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>gravity-related height</cite>" and the abbreviation is upper case "<var>H</var>".
+ *
+ * @see #ALTITUDE
+ * @see #ELLIPSOIDAL_HEIGHT
+ * @see #GEOCENTRIC_RADIUS
+ * @see #DEPTH
+ */
+ public static final DefaultCoordinateSystemAxis GRAVITY_RELATED_HEIGHT = create("Gravity-related height", "H",
+ AxisDirection.UP, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * The default axis for altitude values.
+ * Increasing ordinates values go {@linkplain AxisDirection#UP up} and units are {@linkplain SI#METRE metres}.
+ * The abbreviation is lower case "<var>h</var>".
+ *
+ * <p>This axis is usually part of a {@link #LONGITUDE}, {@link #LATITUDE}, {@link #ALTITUDE} set.</p>
+ *
+ * @see #ELLIPSOIDAL_HEIGHT
+ * @see #GEOCENTRIC_RADIUS
+ * @see #GRAVITY_RELATED_HEIGHT
+ * @see #DEPTH
+ */
+ public static final DefaultCoordinateSystemAxis ALTITUDE = create("Altitude", "h",
+ AxisDirection.UP, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * The default axis for depth.
+ * Increasing ordinates values go {@linkplain AxisDirection#DOWN down} and units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>depth</cite>".
+ *
+ * @see #ALTITUDE
+ * @see #ELLIPSOIDAL_HEIGHT
+ * @see #GEOCENTRIC_RADIUS
+ * @see #GRAVITY_RELATED_HEIGHT
+ */
+ public static final DefaultCoordinateSystemAxis DEPTH = create("Depth", "d",
+ AxisDirection.DOWN, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for radius in a
+ * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
+ * {@linkplain org.opengis.referencing.cs.SphericalCS spherical CS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#UP up} and units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>geocentric radius</cite>" and the abbreviation is lower case "<var>r</var>".
+ *
+ * <p>This axis is usually part of a {@link #SPHERICAL_LONGITUDE}, {@link #SPHERICAL_LATITUDE},
+ * {@link #GEOCENTRIC_RADIUS} set.</p>
+ *
+ * @see #ALTITUDE
+ * @see #ELLIPSOIDAL_HEIGHT
+ * @see #GRAVITY_RELATED_HEIGHT
+ * @see #DEPTH
+ */
+ public static final DefaultCoordinateSystemAxis GEOCENTRIC_RADIUS = create("Geocentric radius", "r",
+ AxisDirection.UP, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for longitudes in a
+ * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
+ * {@linkplain org.opengis.referencing.crs.SphericalCS spherical CS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#EAST East}
+ * and units are {@linkplain NonSI#DEGREE_ANGLE degrees}.
+ * The ISO 19111 name is "<cite>spherical longitude</cite>" and the abbreviation is "Ω" (omega).
+ *
+ * <p>This axis is usually part of a {@link #SPHERICAL_LONGITUDE}, {@link #SPHERICAL_LATITUDE},
+ * {@link #GEOCENTRIC_RADIUS} set.</p>
+ *
+ * @see #LONGITUDE
+ * @see #GEODETIC_LONGITUDE
+ * @see #SPHERICAL_LATITUDE
+ */
+ public static final DefaultCoordinateSystemAxis SPHERICAL_LONGITUDE = create("Spherical longitude", "Ω",
+ AxisDirection.EAST, 180, NonSI.DEGREE_ANGLE);
+
+ /**
+ * Default axis info for latitudes in a
+ * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
+ * {@linkplain org.opengis.referencing.cs.SphericalCS spherical CS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#NORTH North}
+ * and units are {@linkplain NonSI#DEGREE_ANGLE degrees}.
+ * The ISO 19111 name is "<cite>spherical latitude</cite>" and the abbreviation is "Θ" (theta).
+ *
+ * <p>This axis is usually part of a {@link #SPHERICAL_LONGITUDE}, {@link #SPHERICAL_LATITUDE},
+ * {@link #GEOCENTRIC_RADIUS} set.</p>
+ *
+ * @see #LATITUDE
+ * @see #GEODETIC_LATITUDE
+ * @see #SPHERICAL_LONGITUDE
+ */
+ public static final DefaultCoordinateSystemAxis SPHERICAL_LATITUDE = create("Spherical latitude", "Θ",
+ AxisDirection.NORTH, 90, NonSI.DEGREE_ANGLE);
+
+ /**
+ * Default axis info for <var>x</var> values in a
+ * {@linkplain org.opengis.referencing.cs.CartesianCS Cartesian CS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#EAST East}
+ * and units are {@linkplain SI#METRE metres}.
+ * The abbreviation is lower case "<var>x</var>".
+ *
+ * <p>This axis is usually part of a {@link #X}, {@link #Y}, {@link #Z} set.</p>
+ *
+ * @see #EASTING
+ * @see #WESTING
+ * @see #GEOCENTRIC_X
+ * @see #DISPLAY_X
+ * @see #COLUMN
+ */
+ public static final DefaultCoordinateSystemAxis X = create("x", "x",
+ AxisDirection.EAST, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for <var>y</var> values in a
+ * {@linkplain org.opengis.referencing.cs.CartesianCS Cartesian CS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#NORTH North}
+ * and units are {@linkplain SI#METRE metres}.
+ * The abbreviation is lower case "<var>y</var>".
+ *
+ * <p>This axis is usually part of a {@link #X}, {@link #Y}, {@link #Z} set.</p>
+ *
+ * @see #NORTHING
+ * @see #SOUTHING
+ * @see #GEOCENTRIC_Y
+ * @see #DISPLAY_Y
+ * @see #ROW
+ */
+ public static final DefaultCoordinateSystemAxis Y = create("y", "y",
+ AxisDirection.NORTH, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for <var>z</var> values in a
+ * {@linkplain org.opengis.referencing.cs.CartesianCS Cartesian CS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#UP up}
+ * and units are {@linkplain SI#METRE metres}.
+ * The abbreviation is lower case "<var>z</var>".
+ *
+ * <p>This axis is usually part of a {@link #X}, {@link #Y}, {@link #Z} set.</p>
+ */
+ public static final DefaultCoordinateSystemAxis Z = create("z", "z",
+ AxisDirection.UP, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for <var>x</var> values in a
+ * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
+ * {@linkplain org.opengis.referencing.cs.CartesianCS Cartesian CS}.
+ * Increasing ordinates values goes typically toward prime meridian, but the actual axis direction
+ * is {@link AxisDirection#GEOCENTRIC_X GEOCENTRIC_X}. The units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>geocentric X</cite>" and the abbreviation is upper case "<var>X</var>".
+ *
+ * <p>In legacy OGC 01-009 specification (still in use for WKT format),
+ * the direction was {@link AxisDirection#OTHER OTHER}).</p>
+ *
+ * <p>This axis is usually part of a {@link #GEOCENTRIC_X}, {@link #GEOCENTRIC_Y}, {@link #GEOCENTRIC_Z} set.</p>
+ */
+ public static final DefaultCoordinateSystemAxis GEOCENTRIC_X = create("X", "X",
+ AxisDirection.GEOCENTRIC_X, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for <var>y</var> values in a
+ * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
+ * {@linkplain org.opengis.referencing.cs.CartesianCS Cartesian CS}.
+ * Increasing ordinates values goes typically toward East, but the actual axis direction is
+ * {@link AxisDirection#GEOCENTRIC_Y GEOCENTRIC_Y}. The units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>geocentric Y</cite>" and the abbreviation is upper case "<var>Y</var>".
+ *
+ * <p>In legacy OGC 01-009 specification (still in use for WKT format),
+ * the direction was {@link AxisDirection#EAST EAST}).</p>
+ *
+ * <p>This axis is usually part of a {@link #GEOCENTRIC_X}, {@link #GEOCENTRIC_Y}, {@link #GEOCENTRIC_Z} set.</p>
+ */
+ public static final DefaultCoordinateSystemAxis GEOCENTRIC_Y = create("Y", "Y",
+ AxisDirection.GEOCENTRIC_Y, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for <var>z</var> values in a
+ * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
+ * {@linkplain org.opengis.referencing.cs.CartesianCS Cartesian CS}.
+ * Increasing ordinates values goes typically toward North, but the actual axis direction is
+ * {@link AxisDirection#GEOCENTRIC_Z GEOCENTRIC_Z}. The units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>geocentric Z</cite>" and the abbreviation is upper case "<var>Z</var>".
+ *
+ * <p>In legacy OGC 01-009 specification (still in use for WKT format),
+ * the direction was {@link AxisDirection#NORTH NORTH}).</p>
+ *
+ * <p>This axis is usually part of a {@link #GEOCENTRIC_X}, {@link #GEOCENTRIC_Y}, {@link #GEOCENTRIC_Z} set.</p>
+ */
+ public static final DefaultCoordinateSystemAxis GEOCENTRIC_Z = create("Z", "Z",
+ AxisDirection.GEOCENTRIC_Z, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for Easting values in a
+ * {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#EAST East} and units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>easting</cite>" and the abbreviation is upper case "<var>E</var>".
+ *
+ * <p>This axis is usually part of a {@link #EASTING}, {@link #NORTHING} set.</p>
+ *
+ * @see #X
+ * @see #EASTING
+ * @see #WESTING
+ */
+ public static final DefaultCoordinateSystemAxis EASTING = create("Easting", "E",
+ AxisDirection.EAST, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for Westing values in a
+ * {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#WEST West} and units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>westing</cite>" and the abbreviation is upper case "<var>W</var>".
+ *
+ * @see #X
+ * @see #EASTING
+ * @see #WESTING
+ */
+ public static final DefaultCoordinateSystemAxis WESTING = create("Westing", "W",
+ AxisDirection.WEST, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for Northing values in a
+ * {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#NORTH North} and units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>northing</cite>" and the abbreviation is upper case "<var>N</var>".
+ *
+ * <p>This axis is usually part of a {@link #EASTING}, {@link #NORTHING} set.</p>
+ *
+ * @see #Y
+ * @see #NORTHING
+ * @see #SOUTHING
+ */
+ public static final DefaultCoordinateSystemAxis NORTHING = create("Northing", "N",
+ AxisDirection.NORTH, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * Default axis info for Southing values in a
+ * {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}.
+ * Increasing ordinates values go {@linkplain AxisDirection#SOUTH South} and units are {@linkplain SI#METRE metres}.
+ * The ISO 19111 name is "<cite>southing</cite>" and the abbreviation is upper case "<var>S</var>".
+ *
+ * @see #Y
+ * @see #NORTHING
+ * @see #SOUTHING
+ */
+ public static final DefaultCoordinateSystemAxis SOUTHING = create("Southing", "S",
+ AxisDirection.SOUTH, Double.POSITIVE_INFINITY, SI.METRE);
+
+ /**
+ * A default axis for time values in a {@linkplain org.opengis.referencing.cs.TimeCS time CS}.
+ * Increasing time go toward {@linkplain AxisDirection#FUTURE future} and units are {@linkplain NonSI#DAY days}.
+ * The abbreviation is lower case "<var>t</var>".
+ */
+ public static final DefaultCoordinateSystemAxis TIME = create("Time", "t",
+ AxisDirection.FUTURE, Double.POSITIVE_INFINITY, NonSI.DAY);
+
+ /**
+ * A default axis for column indices in a {@linkplain org.opengis.coverage.grid.GridCoverage grid coverage}.
+ * Increasing values go toward {@linkplain AxisDirection#COLUMN_POSITIVE positive column number}.
+ * The abbreviation is lower case "<var>i</var>".
+ */
+ public static final DefaultCoordinateSystemAxis COLUMN = create("Column", "i",
+ AxisDirection.COLUMN_POSITIVE, Double.POSITIVE_INFINITY, Unit.ONE);
+
+ /**
+ * A default axis for row indices in a {@linkplain org.opengis.coverage.grid.GridCoverage grid coverage}.
+ * Increasing values go toward {@linkplain AxisDirection#ROW_POSITIVE positive row number}.
+ * The abbreviation is lower case "<var>j</var>".
+ */
+ public static final DefaultCoordinateSystemAxis ROW = create("Row", "j",
+ AxisDirection.ROW_POSITIVE, Double.POSITIVE_INFINITY, Unit.ONE);
+
+ /**
+ * A default axis for <var>x</var> values in a display device. Increasing values go toward
+ * {@linkplain AxisDirection#DISPLAY_RIGHT display right}.
+ * The abbreviation is lower case "<var>x</var>".
+ */
+ public static final DefaultCoordinateSystemAxis DISPLAY_X = create("x", "x",
+ AxisDirection.DISPLAY_RIGHT, Double.POSITIVE_INFINITY, Unit.ONE);
+
+ /**
+ * A default axis for <var>y</var> values in a display device. Increasing values go toward
+ * {@linkplain AxisDirection#DISPLAY_DOWN display down}.
+ * The abbreviation is lower case "<var>y</var>".
+ */
+ public static final DefaultCoordinateSystemAxis DISPLAY_Y = create("y", "y",
+ AxisDirection.DISPLAY_DOWN, Double.POSITIVE_INFINITY, Unit.ONE);
+
+ /**
+ * Undefined or unknown axis. Axis direction is {@link AxisDirection#OTHER OTHER}
+ * and the unit is dimensionless. This constant is sometime used as a placeholder
+ * for axes that were not properly defined.
+ */
+ public static final DefaultCoordinateSystemAxis UNDEFINED = create("Undefined", "?",
+ AxisDirection.OTHER, Double.POSITIVE_INFINITY, Unit.ONE);
+
+ /**
+ * Creates a new axis of the given name, abbreviation, direction and unit.
+ */
+ private static DefaultCoordinateSystemAxis create(final String name, final String abbreviation,
+ final AxisDirection direction, final double maximum, final Unit<?> unit)
+ {
+ return new DefaultCoordinateSystemAxis(singletonMap(DefaultCoordinateSystemAxis.NAME_KEY, name),
+ abbreviation, direction, unit, name.endsWith("radius") ? 0 : -maximum, maximum,
+ name.endsWith("longitude") ? RangeMeaning.WRAPAROUND : RangeMeaning.EXACT);
+ }
+
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private CommonAxes() {
+ }
+}
Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java?rev=1544911&r1=1544910&r2=1544911&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java [UTF-8] Sun Nov 24 04:51:23 2013
@@ -17,11 +17,13 @@
package org.apache.sis.referencing.cs;
import org.opengis.referencing.cs.AxisDirection;
+import org.apache.sis.internal.referencing.AxisDirections;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
+import static java.lang.StrictMath.*;
import static org.junit.Assert.*;
import static org.apache.sis.referencing.cs.CoordinateSystems.*;
@@ -64,21 +66,92 @@ public final strictfp class CoordinateSy
}
/**
+ * Tests the {@link CoordinateSystems#getCompassAngle(AxisDirection, AxisDirection)} method.
+ */
+ @Test
+ public void testGetCompassAngle() {
+ final AxisDirection[] compass = new AxisDirection[] {
+ AxisDirection.NORTH,
+ AxisDirection.NORTH_NORTH_EAST,
+ AxisDirection.NORTH_EAST,
+ AxisDirection.EAST_NORTH_EAST,
+ AxisDirection.EAST,
+ AxisDirection.EAST_SOUTH_EAST,
+ AxisDirection.SOUTH_EAST,
+ AxisDirection.SOUTH_SOUTH_EAST,
+ AxisDirection.SOUTH,
+ AxisDirection.SOUTH_SOUTH_WEST,
+ AxisDirection.SOUTH_WEST,
+ AxisDirection.WEST_SOUTH_WEST,
+ AxisDirection.WEST,
+ AxisDirection.WEST_NORTH_WEST,
+ AxisDirection.NORTH_WEST,
+ AxisDirection.NORTH_NORTH_WEST
+ };
+ assertEquals(compass.length, COMPASS_DIRECTION_COUNT);
+ final int base = AxisDirection.NORTH.ordinal();
+ final int h = compass.length / 2;
+ for (int i=0; i<compass.length; i++) {
+ final AxisDirection direction = compass[i];
+ final AxisDirection opposite = AxisDirections.opposite(direction);
+ final String message = direction.name();
+ int io = i+h, in = i;
+ if (i >= h) io -= COMPASS_DIRECTION_COUNT;
+ if (i > h) in -= COMPASS_DIRECTION_COUNT;
+ assertEquals(message, base + i, direction.ordinal());
+ assertEquals(message, base + io, opposite.ordinal());
+ assertEquals(message, 0, getCompassAngle(direction, direction));
+ assertEquals(message, h, abs(getCompassAngle(direction, opposite)));
+ assertEquals(message, in, getCompassAngle(direction, AxisDirection.NORTH));
+ }
+ }
+
+ /**
* Tests {@link CoordinateSystems#angle(AxisDirection, AxisDirection)}.
*/
@Test
- @DependsOnMethod("testParseAxisDirection")
+ @DependsOnMethod("testGetCompassAngle")
public void testAngle() {
- assertEquals( +90, angle(AxisDirection.EAST, AxisDirection.NORTH), STRICT);
- assertEquals( -90, angle(AxisDirection.NORTH, AxisDirection.EAST), STRICT);
- assertEquals( +90, angle(AxisDirection.WEST, AxisDirection.SOUTH), STRICT);
- assertEquals( -90, angle(AxisDirection.SOUTH, AxisDirection.WEST), STRICT);
- assertEquals(-180, angle(AxisDirection.NORTH, AxisDirection.SOUTH), STRICT);
- assertEquals( 180, angle(AxisDirection.SOUTH, AxisDirection.NORTH), STRICT);
- assertEquals( 45, angle(AxisDirection.NORTH_EAST, AxisDirection.NORTH), STRICT);
- assertEquals(22.5, angle(AxisDirection.NORTH_NORTH_EAST, AxisDirection.NORTH), STRICT);
- assertEquals( 90, angle(parseAxisDirection("North along 90°E"), parseAxisDirection("North along 0°")), STRICT);
- assertEquals( 135, angle(parseAxisDirection("North along 90°E"), parseAxisDirection("North along 45°W")), STRICT);
- assertEquals(-135, angle(parseAxisDirection("North along 45°W"), parseAxisDirection("North along 90°E")), STRICT);
+ assertEquals( 0, angle(AxisDirection.EAST, AxisDirection.EAST), STRICT);
+ assertEquals( +90, angle(AxisDirection.EAST, AxisDirection.NORTH), STRICT);
+ assertEquals( -90, angle(AxisDirection.NORTH, AxisDirection.EAST), STRICT);
+ assertEquals( +90, angle(AxisDirection.WEST, AxisDirection.SOUTH), STRICT);
+ assertEquals( -90, angle(AxisDirection.SOUTH, AxisDirection.WEST), STRICT);
+ assertEquals( -180, angle(AxisDirection.NORTH, AxisDirection.SOUTH), STRICT);
+ assertEquals( 180, angle(AxisDirection.SOUTH, AxisDirection.NORTH), STRICT);
+ assertEquals( 45, angle(AxisDirection.NORTH_EAST, AxisDirection.NORTH), STRICT);
+ assertEquals( 22.5, angle(AxisDirection.NORTH_NORTH_EAST, AxisDirection.NORTH), STRICT);
+ assertEquals(-22.5, angle(AxisDirection.NORTH_NORTH_WEST, AxisDirection.NORTH), STRICT);
+ assertEquals( 45, angle(AxisDirection.SOUTH, AxisDirection.SOUTH_EAST), STRICT);
+ }
+
+ /**
+ * Tests {@link CoordinateSystems#angle(AxisDirection, AxisDirection)} using directions parsed from text.
+ */
+ @Test
+ @DependsOnMethod({"testParseAxisDirection", "testAngle"})
+ public void testAngleAlongMeridians() {
+ compareAngle( 90.0, "West", "South");
+ compareAngle(-90.0, "South", "West");
+ compareAngle( 45.0, "South", "South-East");
+ compareAngle(-22.5, "North-North-West", "North");
+ compareAngle(-22.5, "North_North_West", "North");
+ compareAngle(-22.5, "North North West", "North");
+ compareAngle( 90.0, "North along 90 deg East", "North along 0 deg");
+ compareAngle( 90.0, "South along 180 deg", "South along 90 deg West");
+ compareAngle( 90, "North along 90°E", "North along 0°");
+ compareAngle( 135, "North along 90°E", "North along 45°W");
+ compareAngle( -135, "North along 45°W", "North along 90°E");
+ }
+
+ /**
+ * Compare the angle between the specified directions.
+ */
+ private static void compareAngle(final double expected, final String source, final String target) {
+ final AxisDirection dir1 = parseAxisDirection(source);
+ final AxisDirection dir2 = parseAxisDirection(target);
+ assertNotNull(source, dir1);
+ assertNotNull(target, dir2);
+ assertEquals(expected, angle(dir1, dir2), STRICT);
}
}
Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java?rev=1544911&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java [UTF-8] Sun Nov 24 04:51:23 2013
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.cs;
+
+import org.opengis.test.Validators;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.referencing.cs.CommonAxes.*;
+
+
+/**
+ * Tests {@link DefaultCoordinateSystemAxis}.
+ *
+ * @author Martin Desruisseaux (IRD)
+ * @since 0.4 (derived from geotk-2.2)
+ * @version 0.4
+ * @module
+ */
+@DependsOn({
+ DirectionAlongMeridianTest.class,
+ org.apache.sis.referencing.AbstractIdentifiedObjectTest.class
+})
+public final strictfp class DefaultCoordinateSystemAxisTest extends TestCase {
+ /**
+ * Validates the {@link CommonAxes} constants.
+ */
+ @Test
+ public void validate() {
+ Validators.validate(GEODETIC_LONGITUDE);
+ Validators.validate(GEODETIC_LATITUDE);
+ Validators.validate(LONGITUDE);
+ Validators.validate(LATITUDE);
+ Validators.validate(ELLIPSOIDAL_HEIGHT);
+ Validators.validate(GRAVITY_RELATED_HEIGHT);
+ Validators.validate(ALTITUDE);
+ Validators.validate(DEPTH);
+ Validators.validate(GEOCENTRIC_RADIUS);
+ Validators.validate(SPHERICAL_LONGITUDE);
+ Validators.validate(SPHERICAL_LATITUDE);
+ Validators.validate(X);
+ Validators.validate(Y);
+ Validators.validate(Z);
+ Validators.validate(GEOCENTRIC_X);
+ Validators.validate(GEOCENTRIC_Y);
+ Validators.validate(GEOCENTRIC_Z);
+ Validators.validate(EASTING);
+ Validators.validate(WESTING);
+ Validators.validate(NORTHING);
+ Validators.validate(SOUTHING);
+ Validators.validate(TIME);
+ Validators.validate(COLUMN);
+ Validators.validate(ROW);
+ Validators.validate(DISPLAY_X);
+ Validators.validate(DISPLAY_Y);
+ }
+
+ /**
+ * Tests WKT formatting of predefined constants.
+ */
+ @Test
+ public void testWKT() {
+ assertWktEquals(X, "AXIS[“x”, EAST]");
+ assertWktEquals(Y, "AXIS[“y”, NORTH]");
+ assertWktEquals(Z, "AXIS[“z”, UP]");
+ assertWktEquals(LONGITUDE, "AXIS[“Longitude”, EAST]");
+ assertWktEquals(LATITUDE, "AXIS[“Latitude”, NORTH]");
+ assertWktEquals(ALTITUDE, "AXIS[“Altitude”, UP]");
+ assertWktEquals(TIME, "AXIS[“Time”, FUTURE]");
+ assertWktEquals(GEODETIC_LONGITUDE, "AXIS[“Geodetic longitude”, EAST]");
+ assertWktEquals(SPHERICAL_LONGITUDE, "AXIS[“Spherical longitude”, EAST]");
+ assertWktEquals(GEODETIC_LATITUDE, "AXIS[“Geodetic latitude”, NORTH]");
+ assertWktEquals(SPHERICAL_LATITUDE, "AXIS[“Spherical latitude”, NORTH]");
+ }
+
+ /**
+ * Tests the {@link DefaultCoordinateSystemAxis#nameMatches(String)} method.
+ */
+ @Test
+ public void testNameMatches() {
+ assertTrue (LONGITUDE.nameMatches(GEODETIC_LONGITUDE.getName().getCode()));
+ assertFalse(LONGITUDE.nameMatches(GEODETIC_LATITUDE .getName().getCode()));
+ assertFalse(LONGITUDE.nameMatches(ALTITUDE .getName().getCode()));
+ assertFalse(X .nameMatches(LONGITUDE .getName().getCode()));
+ assertFalse(X .nameMatches(EASTING .getName().getCode()));
+ assertFalse(X .nameMatches(NORTHING .getName().getCode()));
+ }
+
+ /**
+ * Tests the comparison of some axis, ignoring metadata.
+ */
+ @Test
+ @DependsOnMethod("testNameMatches")
+ public void testEqualsIgnoreMetadata() {
+ assertFalse("X", X .equals(GEOCENTRIC_X, ComparisonMode.IGNORE_METADATA));
+ assertFalse("Longitude", LONGITUDE.equals(GEODETIC_LONGITUDE, ComparisonMode.STRICT));
+ assertFalse("Longitude", LONGITUDE.equals(SPHERICAL_LONGITUDE, ComparisonMode.STRICT));
+ assertFalse("Longitude", LONGITUDE.equals(SPHERICAL_LONGITUDE, ComparisonMode.IGNORE_METADATA));
+ /*
+ * Tests aliases in the special "longitude" and "latitude" cases.
+ */
+ assertTrue ("Longitude", LONGITUDE.equals(GEODETIC_LONGITUDE, ComparisonMode.IGNORE_METADATA));
+ assertTrue ("Latitude", LATITUDE .equals(GEODETIC_LATITUDE, ComparisonMode.IGNORE_METADATA));
+ assertFalse("Lon/Lat", LATITUDE .equals(LONGITUDE, ComparisonMode.IGNORE_METADATA));
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialization() {
+ assertSerializedEquals(X);
+ assertSerializedEquals(GEOCENTRIC_X);
+ assertSerializedEquals(GEODETIC_LONGITUDE);
+ }
+}
Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1544911&r1=1544910&r2=1544911&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Sun Nov 24 04:51:23 2013
@@ -57,6 +57,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.datum.DefaultVerticalDatumTest.class,
org.apache.sis.referencing.datum.DefaultGeodeticDatumTest.class,
org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class,
+ org.apache.sis.referencing.cs.DefaultCoordinateSystemAxisTest.class,
org.apache.sis.referencing.cs.CoordinateSystemsTest.class,
org.apache.sis.referencing.StandardDefinitionsTest.class,
org.apache.sis.referencing.GeodeticObjectsTest.class,