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 2014/01/18 00:54:34 UTC
svn commit: r1559289 [1/2] - in /sis/branches/JDK7/core/sis-referencing/src:
main/java/org/apache/sis/referencing/cs/
test/java/org/apache/sis/referencing/
test/java/org/apache/sis/referencing/crs/
test/java/org/apache/sis/referencing/cs/ test/java/org...
Author: desruisseaux
Date: Fri Jan 17 23:54:34 2014
New Revision: 1559289
URL: http://svn.apache.org/r1559289
Log:
Added more tests.
Added:
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java (with props)
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java (with props)
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCSTest.java (with props)
Modified:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -36,11 +36,13 @@ import org.opengis.referencing.cs.Coordi
import org.apache.sis.internal.referencing.AxisDirections;
import org.apache.sis.referencing.AbstractIdentifiedObject;
import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.NamedIdentifier;
import org.apache.sis.measure.Longitude;
import org.apache.sis.measure.Latitude;
import org.apache.sis.measure.Units;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.io.wkt.Formatter;
@@ -94,6 +96,16 @@ public class DefaultCoordinateSystemAxis
private static final long serialVersionUID = -7883614853277827689L;
/**
+ * The identifier for axis of unknown name. We have to use this identifier when the axis direction changed,
+ * because such change often implies a name change too (e.g. "Westing" → "Easting"), and we can not always
+ * guess what the new name should be.
+ *
+ * <p>This constant is used as a sentinel value for skipping axis name comparisons when the axis name is
+ * unknown.</p>
+ */
+ static final NamedIdentifier UNNAMED = new NamedIdentifier(null, Vocabulary.format(Vocabulary.Keys.Unnamed));
+
+ /**
* Some names to be treated as equivalent. This is needed because axis names are the primary way to
* distinguish between {@link CoordinateSystemAxis} instances. Those names are strictly defined by
* ISO 19111 as "Geodetic latitude" and "Geodetic longitude" among others, but the legacy WKT
@@ -576,33 +588,23 @@ public class DefaultCoordinateSystemAxis
return false;
}
final DefaultCoordinateSystemAxis that = castOrCopy((CoordinateSystemAxis) object);
- return equals(that, mode.ordinal() < ComparisonMode.IGNORE_METADATA.ordinal(), true);
- }
-
- /**
- * Compares the specified object with this axis for equality, with optional comparison of units.
- * Units shall always be compared (they are not just metadata), except in the particular case of
- * {@link CoordinateSystems#axisColinearWith}, which is used as a first step toward units conversions
- * through {@link CoordinateSystems#swapAndScaleAxes}.
- */
- final boolean equals(final DefaultCoordinateSystemAxis that,
- final boolean compareMetadata, final boolean compareUnit)
- {
+ if (!Objects.equals(direction, that.direction) || !Objects.equals(unit, that.unit)) {
+ return false;
+ }
/*
* It is important to NOT compare the minimum and maximum values when we are in
* "ignore metadata" mode, because we want CRS with a [-180 … +180]° longitude
* range to be considered equivalent, from a coordinate transformation point of
* view, to a CRS with a [0 … 360]° longitude range.
*/
- if (compareMetadata) {
- if (!Objects.equals(this.abbreviation, that.abbreviation) ||
- !Objects.equals(this.rangeMeaning, that.rangeMeaning) ||
- doubleToLongBits(minimumValue) != doubleToLongBits(that.minimumValue) ||
- doubleToLongBits(maximumValue) != doubleToLongBits(that.maximumValue))
- {
- return false;
- }
- } else {
+ if (mode.ordinal() < ComparisonMode.IGNORE_METADATA.ordinal()) {
+ return Objects.equals(abbreviation, that.abbreviation) &&
+ Objects.equals(rangeMeaning, that.rangeMeaning) &&
+ doubleToLongBits(minimumValue) == doubleToLongBits(that.minimumValue) &&
+ doubleToLongBits(maximumValue) == doubleToLongBits(that.maximumValue);
+ }
+ ReferenceIdentifier name = that.getName();
+ if (name != UNNAMED) {
/*
* Checking the abbreviation is not sufficient. For example the polar angle and the
* spherical latitude have the same abbreviation (θ). Legacy names like "Longitude"
@@ -613,39 +615,33 @@ public class DefaultCoordinateSystemAxis
* the axis name instead. These names are constrained by ISO 19111 specification
* (see class javadoc), so they should be reliable enough.
*
- * Note: there is no need to execute this block if 'compareMetadata' is true,
+ * Note: there is no need to execute this block if metadata are not ignored,
* because in this case a stricter check has already been performed by
* the 'equals' method in the superclass.
*/
- final String thatName = that.getName().getCode();
- if (!isHeuristicMatchForName(thatName)) {
- /*
- * The above test checked for special cases ("Lat" / "Lon" aliases, etc.).
- * The next line may repeat the same check, so we may have a partial waste
- * of CPU. But we do it anyway for checking the 'that' aliases, and also
- * because the user may have overridden 'that.isHeuristicMatchForName(…)'.
- */
- final String thisName = getName().getCode();
- if (!IdentifiedObjects.isHeuristicMatchForName(that, thisName)) {
+ final String thatCode = name.getCode();
+ if (!isHeuristicMatchForName(thatCode)) {
+ name = getName();
+ if (name != UNNAMED) {
/*
- * For the needs of CoordinateSystems.axisColinearWith(...), we must stop here.
- * In addition it may be safer to not test 'isHeuristicMatchForNameXY' when we
- * do not have the extra-safety of units comparison, because "x" and "y" names
- * are too generic.
+ * The above test checked for special cases ("Lat" / "Lon" aliases, etc.).
+ * The next line may repeat the same check, so we may have a partial waste
+ * of CPU. But we do it anyway for checking the 'that' aliases, and also
+ * because the user may have overridden 'that.isHeuristicMatchForName(…)'.
*/
- if (!compareUnit) {
- return false;
- }
- // Last chance: check for the special case of "x" and "y" axis names.
- if (!isHeuristicMatchForNameXY(thatName, thisName) &&
- !isHeuristicMatchForNameXY(thisName, thatName))
- {
- return false;
+ final String thisCode = name.getCode();
+ if (!IdentifiedObjects.isHeuristicMatchForName(that, thisCode)) {
+ // Check for the special case of "x" and "y" axis names.
+ if (!isHeuristicMatchForNameXY(thatCode, thisCode) &&
+ !isHeuristicMatchForNameXY(thisCode, thatCode))
+ {
+ return false;
+ }
}
}
}
}
- return Objects.equals(direction, that.direction) && (!compareUnit || Objects.equals(unit, that.unit));
+ return true;
}
/**
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -28,7 +28,6 @@ import org.opengis.referencing.cs.AxisDi
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.CharSequences;
import org.apache.sis.measure.Units;
@@ -182,7 +181,7 @@ final class Normalizer implements Compar
if (newAbbr.equals(abbreviation)) {
properties = IdentifiedObjects.getProperties(axis, EXCLUDES);
} else {
- properties = singletonMap(NAME_KEY, Vocabulary.format(Vocabulary.Keys.Unnamed));
+ properties = singletonMap(NAME_KEY, DefaultCoordinateSystemAxis.UNNAMED);
}
/*
* Converts the axis range and build the new axis.
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -16,14 +16,20 @@
*/
package org.apache.sis.referencing;
+import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.opengis.referencing.cs.EllipsoidalCS;
import org.opengis.referencing.datum.Ellipsoid;
+import org.opengis.referencing.datum.PrimeMeridian;
import org.opengis.referencing.datum.GeodeticDatum;
import org.apache.sis.test.mock.GeodeticDatumMock;
+import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.opengis.test.Validators;
+import org.apache.sis.referencing.crs.HardCodedCRS;
import org.apache.sis.referencing.cs.HardCodedAxes;
+import org.apache.sis.referencing.datum.HardCodedDatum;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -38,8 +44,7 @@ import static org.junit.Assert.*;
* @module
*/
@DependsOn({
- org.apache.sis.referencing.datum.DefaultEllipsoidTest.class,
- org.apache.sis.referencing.cs.DefaultCoordinateSystemAxisTest.class
+ org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class
})
public final strictfp class StandardDefinitionsTest extends TestCase {
/**
@@ -48,67 +53,105 @@ public final strictfp class StandardDefi
private static final double STRICT = 0;
/**
- * Compares the values created by {@link StandardDefinitions#createEllipsoid(short)} against
- * the {@link GeodeticObjects} constants. Actually this is more a {@code GeodeticDatumMock}
- * test than a {@code StandardDefinitions} one - in case of test failure, both classes could
- * be at fault.
+ * Compares the values created by {@code StandardDefinitions} against hard-coded constants.
+ * This method tests the following methods:
+ *
+ * <ul>
+ * <li>{@link StandardDefinitions#createEllipsoid(short)}</li>
+ * <li>{@link StandardDefinitions#createGeodeticDatum(short, Ellipsoid, PrimeMeridian)}</li>
+ * <li>{@link StandardDefinitions#createGeographicCRS(short, GeodeticDatum, EllipsoidalCS)}</li>
+ * </ul>
+ *
+ * The geodetic objects are compared against the {@link HardCodedCRS}, {@link HardCodedDatum} and
+ * {@link GeodeticDatumMock} constants. Actually this is more a test of the above-cited constants
+ * than a {@code StandardDefinitions} one - in case of test failure, any of those classes could be
+ * at fault.
*/
@Test
- public void testCreateEllipsoid() {
- final GeodeticDatum[] mocks = new GeodeticDatum[] {
- GeodeticDatumMock.WGS84,
- GeodeticDatumMock.WGS72,
- GeodeticDatumMock.NAD83,
- GeodeticDatumMock.NAD27,
- GeodeticDatumMock.SPHERE
- };
- final GeodeticObjects[] enums = new GeodeticObjects[] {
- GeodeticObjects.WGS84,
- GeodeticObjects.WGS72,
- GeodeticObjects.NAD83,
- GeodeticObjects.NAD27,
- GeodeticObjects.SPHERE
- };
- assertEquals(mocks.length, enums.length);
- for (int i=0; i<mocks.length; i++) {
- final Ellipsoid mock = mocks[i].getEllipsoid();
- final Ellipsoid def = StandardDefinitions.createEllipsoid(enums[i].ellipsoid);
- Validators.validate(def);
- assertEquals("semiMajorAxis", mock.getSemiMajorAxis(), def.getSemiMajorAxis(), STRICT);
- assertEquals("semiMinorAxis", mock.getSemiMinorAxis(), def.getSemiMinorAxis(), STRICT);
- assertEquals("inverseFlattening", mock.getInverseFlattening(), def.getInverseFlattening(), mock.isIvfDefinitive() ? STRICT : 1E-11);
- assertEquals("isIvfDefinitive", mock.isIvfDefinitive(), def.isIvfDefinitive());
- assertEquals("isSphere", mock.isSphere(), def.isSphere());
+ @DependsOnMethod("testCreateAxis")
+ public void testCreateGographicCRS() {
+ final PrimeMeridian pm = StandardDefinitions.primeMeridian();
+ final EllipsoidalCS cs = (EllipsoidalCS) StandardDefinitions.createCoordinateSystem((short) 6422);
+ for (final GeodeticObjects e : GeodeticObjects.values()) {
+ final Ellipsoid ellipsoid = StandardDefinitions.createEllipsoid(e.ellipsoid);
+ switch (e) {
+ case WGS84: compare(GeodeticDatumMock.WGS84 .getEllipsoid(), ellipsoid); break;
+ case WGS72: compare(GeodeticDatumMock.WGS72 .getEllipsoid(), ellipsoid); break;
+ case NAD83: compare(GeodeticDatumMock.NAD83 .getEllipsoid(), ellipsoid); break;
+ case NAD27: compare(GeodeticDatumMock.NAD27 .getEllipsoid(), ellipsoid); break;
+ case SPHERE: compare(GeodeticDatumMock.SPHERE.getEllipsoid(), ellipsoid); break;
+ }
+ final GeodeticDatum datum = StandardDefinitions.createGeodeticDatum(e.datum, ellipsoid, pm);
+ switch (e) {
+ case WGS84: compare(HardCodedDatum.WGS84, datum); break;
+ case WGS72: compare(HardCodedDatum.WGS72, datum); break;
+ case SPHERE: compare(HardCodedDatum.SPHERE, datum); break;
+ }
+ final GeographicCRS crs = StandardDefinitions.createGeographicCRS(e.geographic, datum, cs);
+ Validators.validate(crs);
+ switch (e) {
+ case WGS84: compare(HardCodedCRS.WGS84, crs); break;
+ }
+ Validators.validate(crs);
}
}
/**
+ * Compares only the properties which are known to be defined in {@link StandardDefinitions}.
+ */
+ private static void compare(final GeographicCRS expected, final GeographicCRS actual) {
+ assertEquals("name", expected.getName().getCode(), actual.getName().getCode());
+ }
+
+ /**
+ * Compares only the properties which are known to be defined in {@link StandardDefinitions}.
+ */
+ private static void compare(final GeodeticDatum expected, final GeodeticDatum actual) {
+ assertEquals("name", expected.getName().getCode(), actual.getName().getCode());
+ }
+
+ /**
+ * Compares only the properties which are known to be defined in {@link StandardDefinitions}.
+ */
+ private static void compare(final Ellipsoid expected, final Ellipsoid actual) {
+ assertEquals("semiMajorAxis", expected.getSemiMajorAxis(), actual.getSemiMajorAxis(), STRICT);
+ assertEquals("semiMinorAxis", expected.getSemiMinorAxis(), actual.getSemiMinorAxis(), STRICT);
+ assertEquals("inverseFlattening", expected.getInverseFlattening(), actual.getInverseFlattening(), expected.isIvfDefinitive() ? STRICT : 1E-11);
+ assertEquals("isIvfDefinitive", expected.isIvfDefinitive(), actual.isIvfDefinitive());
+ assertEquals("isSphere", expected.isSphere(), actual.isSphere());
+ }
+
+ /**
* Compares the values created by {@link StandardDefinitions#createAxis(short)} against the {@link HardCodedAxes}
* constants. Actually this is more a {@code HardCodedAxes} test than a {@code StandardDefinitions} one - in case
* of test failure, both classes could be at fault.
*/
@Test
public void testCreateAxis() {
- final short[] codes = {
- 106, 107, 110, 114, 113
- };
- final CoordinateSystemAxis[] axes = {
- HardCodedAxes.GEODETIC_LATITUDE,
- HardCodedAxes.GEODETIC_LONGITUDE,
- HardCodedAxes.ELLIPSOIDAL_HEIGHT,
- HardCodedAxes.GRAVITY_RELATED_HEIGHT,
- HardCodedAxes.DEPTH
- };
- for (int i=0; i<codes.length; i++) {
- final CoordinateSystemAxis axis = StandardDefinitions.createAxis(codes[i]);
- final CoordinateSystemAxis expected = axes[i];
- assertEquals("name", expected.getName().getCode(), axis.getName().getCode());
- assertEquals("abbreviation", expected.getAbbreviation(), axis.getAbbreviation());
- assertEquals("unit", expected.getUnit(), axis.getUnit());
- assertEquals("direction", expected.getDirection(), axis.getDirection());
- assertEquals("minimumValue", expected.getMinimumValue(), axis.getMinimumValue(), STRICT);
- assertEquals("maximumValue", expected.getMaximumValue(), axis.getMaximumValue(), STRICT);
- assertEquals("rangeMeaning", expected.getRangeMeaning(), axis.getRangeMeaning());
+ for (final short code : new short[] {106, 107, 110, 114, 113}) {
+ final CoordinateSystemAxis actual = StandardDefinitions.createAxis(code);
+ Validators.validate(actual);
+ switch (code) {
+ case 106: compare(HardCodedAxes.GEODETIC_LATITUDE, actual); break;
+ case 107: compare(HardCodedAxes.GEODETIC_LONGITUDE, actual); break;
+ case 110: compare(HardCodedAxes.ELLIPSOIDAL_HEIGHT, actual); break;
+ case 114: compare(HardCodedAxes.GRAVITY_RELATED_HEIGHT, actual); break;
+ case 113: compare(HardCodedAxes.DEPTH, actual); break;
+ default: throw new AssertionError(code);
+ }
}
}
+
+ /**
+ * Compares only the properties which are known to be defined in {@link StandardDefinitions}.
+ */
+ private static void compare(final CoordinateSystemAxis expected, final CoordinateSystemAxis actual) {
+ assertEquals("name", expected.getName().getCode(), actual.getName().getCode());
+ assertEquals("abbreviation", expected.getAbbreviation(), actual.getAbbreviation());
+ assertEquals("unit", expected.getUnit(), actual.getUnit());
+ assertEquals("direction", expected.getDirection(), actual.getDirection());
+ assertEquals("minimumValue", expected.getMinimumValue(), actual.getMinimumValue(), STRICT);
+ assertEquals("maximumValue", expected.getMaximumValue(), actual.getMaximumValue(), STRICT);
+ assertEquals("rangeMeaning", expected.getRangeMeaning(), actual.getRangeMeaning());
+ }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -46,10 +46,10 @@ public final strictfp class AbstractCRST
final AbstractCRS toTest, expected, actual;
toTest = new AbstractCRS(singletonMap(NAME_KEY, "My CRS"),
new AbstractCS (singletonMap(NAME_KEY, "My strange CS"),
- HardCodedAxes.TIME, HardCodedAxes.ALTITUDE, HardCodedAxes.LATITUDE, HardCodedAxes.LONGITUDE));
+ HardCodedAxes.TIME, HardCodedAxes.ALTITUDE, HardCodedAxes.GEODETIC_LATITUDE, HardCodedAxes.GEODETIC_LONGITUDE));
expected = new AbstractCRS(singletonMap(NAME_KEY, "My CRS"),
new AbstractCS (singletonMap(NAME_KEY, "Coordinate system: East (deg), North (deg), Up (m), Future (d)."),
- HardCodedAxes.LONGITUDE, HardCodedAxes.LATITUDE, HardCodedAxes.ALTITUDE, HardCodedAxes.TIME));
+ HardCodedAxes.GEODETIC_LONGITUDE, HardCodedAxes.GEODETIC_LATITUDE, HardCodedAxes.ALTITUDE, HardCodedAxes.TIME));
actual = toTest.forConvention(AxesConvention.RIGHT_HANDED);
assertEquals("forConvention(RIGHT_HANDED)", expected, actual);
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -16,6 +16,12 @@
*/
package org.apache.sis.referencing.crs;
+import org.opengis.test.Validators;
+import org.opengis.referencing.cs.CoordinateSystem;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.referencing.cs.DefaultCompoundCS;
+import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.referencing.cs.HardCodedAxes;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -33,32 +39,104 @@ import static org.apache.sis.test.Assert
* @version 0.4
* @module
*/
-@DependsOn({SubTypesTest.class, AbstractCRSTest.class})
+@DependsOn({
+ SubTypesTest.class,
+ DefaultGeographicCRSTest.class
+})
public final strictfp class DefaultCompoundCRSTest extends TestCase {
/**
+ * The vertical CRS arbitrarily chosen in this class for the tests.
+ */
+ private static final DefaultVerticalCRS HEIGHT = HardCodedCRS.GRAVITY_RELATED_HEIGHT;
+
+ /**
+ * The temporal CRS arbitrarily chosen in this class for the tests.
+ */
+ private static final DefaultTemporalCRS TIME = HardCodedCRS.TIME;
+
+ /**
+ * Tolerance threshold for strict floating point comparisons.
+ */
+ private static final double STRICT = 0;
+
+ /**
* Tests construction and serialization of a {@link DefaultCompoundCRS}.
*/
@Test
public void testConstructionAndSerialization() {
- final DefaultCompoundCRS crs3 = new DefaultCompoundCRS(singletonMap(NAME_KEY, "3D"),
- HardCodedCRS.WGS84, HardCodedCRS.ELLIPSOIDAL_HEIGHT); // Not legal, but we just want to test.
- final DefaultCompoundCRS crs4 = new DefaultCompoundCRS(singletonMap(NAME_KEY, "4D"),
- crs3, HardCodedCRS.TIME);
-
- verify(crs3, crs4);
- verify(crs3, assertSerializedEquals(crs4));
+ final DefaultGeographicCRS crs2 = HardCodedCRS.WGS84;
+ final DefaultCompoundCRS crs3 = new DefaultCompoundCRS(singletonMap(NAME_KEY, "3D"), crs2, HEIGHT);
+ final DefaultCompoundCRS crs4 = new DefaultCompoundCRS(singletonMap(NAME_KEY, "4D"), crs3, TIME);
+ Validators.validate(crs4);
+ /*
+ * Verifies the coordinate system axes.
+ */
+ final CoordinateSystem cs = crs4.getCoordinateSystem();
+ assertInstanceOf("coordinateSystem", DefaultCompoundCS.class, cs);
+ assertEquals("dimension", 4, cs.getDimension());
+ assertSame(HardCodedAxes.GEODETIC_LONGITUDE, cs.getAxis(0));
+ assertSame(HardCodedAxes.GEODETIC_LATITUDE, cs.getAxis(1));
+ assertSame(HardCodedAxes.GRAVITY_RELATED_HEIGHT, cs.getAxis(2));
+ assertSame(HardCodedAxes.TIME, cs.getAxis(3));
+ /*
+ * Verifies the list of components, including after serialization
+ * since readObject(ObjectInputStream) is expected to recreate it.
+ */
+ verifyComponents(crs2, crs3, crs4);
+ verifyComponents(crs2, crs3, assertSerializedEquals(crs4));
}
/**
* Verifies the components of the CRS created by {@link #testConstructionAndSerialization()}.
+ *
+ * @param crs2 The expected two-dimensional component (for the 2 first axes).
+ * @param crs3 The expected three-dimensional component.
+ * @param crs4 The four-dimensional compound CRS to test.
*/
- private static void verify(final DefaultCompoundCRS crs3, final DefaultCompoundCRS crs4) {
- assertArrayEquals("getComponents()", new AbstractCRS[] {
- crs3, HardCodedCRS.TIME
- }, crs4.getComponents().toArray());
-
- assertArrayEquals("getSingleComponents()", new AbstractCRS[] {
- HardCodedCRS.WGS84, HardCodedCRS.ELLIPSOIDAL_HEIGHT, HardCodedCRS.TIME
- }, crs4.getSingleComponents().toArray());
+ private static void verifyComponents(final DefaultGeographicCRS crs2,
+ final DefaultCompoundCRS crs3,
+ final DefaultCompoundCRS crs4)
+ {
+ assertArrayEquals(new AbstractCRS[] {crs3, TIME}, crs4.getComponents().toArray());
+ assertArrayEquals(new AbstractCRS[] {crs2, HEIGHT, TIME}, crs4.getSingleComponents().toArray());
+ }
+
+ /**
+ * Tests {@link DefaultCompoundCRS#forConvention(AxesConvention)} with {@link AxesConvention#RIGHT_HANDED}.
+ */
+ @Test
+ public void testNormalization() {
+ final DefaultGeographicCRS crs2 = HardCodedCRS.WGS84_φλ;
+ final DefaultGeographicCRS rh2 = crs2.forConvention(AxesConvention.RIGHT_HANDED);
+ final DefaultCompoundCRS crs3 = new DefaultCompoundCRS(singletonMap(NAME_KEY, "3D"), crs2, HEIGHT);
+ final DefaultCompoundCRS crs4 = new DefaultCompoundCRS(singletonMap(NAME_KEY, "4D"), crs3, TIME);
+ final DefaultCompoundCRS rh4 = crs4.forConvention(AxesConvention.RIGHT_HANDED);
+ assertNotSame(crs4, rh4);
+ Validators.validate(rh4);
+ verifyComponents(crs2, crs3, crs4);
+ verifyComponents(rh2, new DefaultCompoundCRS(singletonMap(NAME_KEY, "3D"), rh2, HEIGHT), rh4);
+ }
+
+ /**
+ * Tests {@link DefaultCompoundCRS#forConvention(AxesConvention)} with {@link AxesConvention#POSITIVE_RANGE}.
+ */
+ @Test
+ public void testShiftLongitudeRange() {
+ final DefaultGeographicCRS crs3 = HardCodedCRS.WGS84_3D;
+ final DefaultCompoundCRS crs4 = new DefaultCompoundCRS(singletonMap(NAME_KEY, "4D"), crs3, TIME);
+ CoordinateSystemAxis axis = crs4.getCoordinateSystem().getAxis(0);
+ assertEquals("longitude.minimumValue", -180.0, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", +180.0, axis.getMaximumValue(), STRICT);
+
+ assertSame("Expected a no-op.", crs4, crs4.forConvention(AxesConvention.RIGHT_HANDED));
+ final DefaultCompoundCRS shifted = crs4.forConvention(AxesConvention.POSITIVE_RANGE);
+ assertNotSame("Expected a new CRS.", crs4, shifted);
+ Validators.validate(shifted);
+
+ axis = shifted.getCoordinateSystem().getAxis(0);
+ assertEquals("longitude.minimumValue", 0.0, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", 360.0, axis.getMaximumValue(), STRICT);
+ assertSame("Expected a no-op.", shifted, shifted.forConvention(AxesConvention.POSITIVE_RANGE));
+ assertSame("Expected cached instance.", shifted, crs4 .forConvention(AxesConvention.POSITIVE_RANGE));
}
}
Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java?rev=1559289&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -0,0 +1,67 @@
+/*
+ * 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.crs;
+
+import org.opengis.test.Validators;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
+import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.Assert.*;
+
+
+/**
+ * Tests {@link DefaultGeographicCRS}
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.4 (derived from geotk-3.20)
+ * @version 0.4
+ * @module
+ */
+@DependsOn({
+ DefaultGeodeticCRSTest.class
+})
+public final strictfp class DefaultGeographicCRSTest extends TestCase {
+ /**
+ * Tolerance threshold for strict floating point comparisons.
+ */
+ private static final double STRICT = 0;
+
+ /**
+ * Tests the {@link DefaultGeographicCRS#forConvention(AxesConvention)} method.
+ */
+ @Test
+ public void testShiftLongitudeRange() {
+ final DefaultGeographicCRS crs = HardCodedCRS.WGS84_3D;
+ CoordinateSystemAxis axis = crs.getCoordinateSystem().getAxis(0);
+ assertEquals("longitude.minimumValue", -180.0, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", +180.0, axis.getMaximumValue(), STRICT);
+
+ assertSame("Expected a no-op.", crs, crs.forConvention(AxesConvention.RIGHT_HANDED));
+ final DefaultGeographicCRS shifted = crs.forConvention(AxesConvention.POSITIVE_RANGE);
+ assertNotSame("Expected a new CRS.", crs, shifted);
+ Validators.validate(shifted);
+
+ axis = shifted.getCoordinateSystem().getAxis(0);
+ assertEquals("longitude.minimumValue", 0.0, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", 360.0, axis.getMaximumValue(), STRICT);
+ assertSame("Expected a no-op.", shifted, shifted.forConvention(AxesConvention.POSITIVE_RANGE));
+ assertSame("Expected cached instance.", shifted, crs .forConvention(AxesConvention.POSITIVE_RANGE));
+ }
+}
Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -39,6 +39,17 @@ import static org.apache.sis.referencing
public final strictfp class HardCodedCRS {
/**
* A two-dimensional geographic coordinate reference system using the WGS84 datum.
+ * This CRS uses (<var>latitude</var>, <var>longitude</var>) ordinates with latitude values
+ * increasing towards the North and longitude values increasing towards the East.
+ * The angular units are decimal degrees and the prime meridian is Greenwich.
+ *
+ * <p>This CRS is equivalent to {@code EPSG:4326}.</p>
+ */
+ public static final DefaultGeographicCRS WGS84_φλ = new DefaultGeographicCRS(
+ properties("WGS 84 (φ,λ)"), HardCodedDatum.WGS84, HardCodedCS.GEODETIC_φλ);
+
+ /**
+ * A two-dimensional geographic coordinate reference system using the WGS84 datum.
* This CRS uses (<var>longitude</var>, <var>latitude</var>) ordinates with longitude values
* increasing towards the East and latitude values increasing towards the North.
* The angular units are decimal degrees and the prime meridian is Greenwich.
Added: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java?rev=1559289&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java (added)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -0,0 +1,94 @@
+/*
+ * 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.crs;
+
+import org.opengis.test.ValidatorContainer;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOn;
+import org.junit.Test;
+
+import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.referencing.crs.HardCodedCRS.*;
+
+
+/**
+ * Validates the {@link HardCodedCRS} definitions.
+ *
+ * @author Martin Desruisseaux (IRD, Geomatys)
+ * @since 0.4 (derived from geotk-2.2)
+ * @version 0.4
+ * @module
+ */
+@DependsOn({
+ org.apache.sis.referencing.cs.HardCodedCSTest.class,
+ DefaultGeographicCRSTest.class
+})
+public final strictfp class HardCodedCRSTest extends TestCase {
+ /**
+ * Validates constants.
+ *
+ * <p>Note: ISO specification does not allow ellipsoidal height, so we have to relax
+ * the check for the {@code DefaultVerticalCRS.ELLIPSOIDAL_HEIGHT} constant.</p>
+ */
+ @Test
+ public void validate() {
+ final ValidatorContainer validators = new ValidatorContainer();
+ validators.validate(WGS84);
+ validators.validate(WGS84_3D); validators.crs.enforceStandardNames = false;
+ validators.validate(ELLIPSOIDAL_HEIGHT); validators.crs.enforceStandardNames = true;
+ validators.validate(GRAVITY_RELATED_HEIGHT);
+ validators.validate(TIME);
+ validators.validate(SPHERICAL);
+ validators.validate(GEOCENTRIC);
+ validators.validate(CARTESIAN_2D);
+ validators.validate(CARTESIAN_3D);
+ }
+
+ /**
+ * Tests dimension of constants.
+ */
+ @Test
+ public void testDimensions() {
+ assertEquals("WGS84 2D", 2, WGS84 .getCoordinateSystem().getDimension());
+ assertEquals("WGS84 3D", 3, WGS84_3D.getCoordinateSystem().getDimension());
+ }
+
+ /**
+ * Tests WKT formatting.
+ */
+ @Test
+ public void testWKT() {
+ assertWktEquals(WGS84,
+ "GEOGCS[“WGS 84”,\n" +
+ " DATUM[“World Geodetic System 1984”,\n" +
+ " SPHEROID[“WGS84”, 6378137.0, 298.257223563],\n" +
+ " AUTHORITY[“EPSG”, “6326”]],\n" +
+ " PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”, “8901”]],\n" +
+ " UNIT[“degree”, 0.017453292519943295],\n" +
+ " AXIS[“Geodetic longitude”, EAST],\n" +
+ " AXIS[“Geodetic latitude”, NORTH]]");
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialization() {
+ assertSerializedEquals(WGS84);
+ assertSerializedEquals(WGS84_3D);
+ }
+}
Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -71,9 +71,9 @@ public final strictfp class AbstractCSTe
@Test
public void testForRightHandedConvention() {
final AbstractCS cs = new AbstractCS(singletonMap(NAME_KEY, "Test"),
- HardCodedAxes.LATITUDE, HardCodedAxes.TIME, HardCodedAxes.ALTITUDE, HardCodedAxes.LONGITUDE);
+ HardCodedAxes.GEODETIC_LATITUDE, HardCodedAxes.TIME, HardCodedAxes.ALTITUDE, HardCodedAxes.GEODETIC_LONGITUDE);
verifyAxesConvention(AxesConvention.RIGHT_HANDED, cs,
- HardCodedAxes.LONGITUDE, HardCodedAxes.LATITUDE, HardCodedAxes.ALTITUDE, HardCodedAxes.TIME);
+ HardCodedAxes.GEODETIC_LONGITUDE, HardCodedAxes.GEODETIC_LATITUDE, HardCodedAxes.ALTITUDE, HardCodedAxes.TIME);
assertSame("Right-handed CS shall be same as normalized.",
cs.forConvention(AxesConvention.RIGHT_HANDED),
cs.forConvention(AxesConvention.NORMALIZED));
@@ -112,8 +112,10 @@ public final strictfp class AbstractCSTe
*/
@Test
public void testForPositiveRangeConvention() {
- final AbstractCS cs = new AbstractCS(singletonMap(NAME_KEY, "Test"), HardCodedAxes.LONGITUDE, HardCodedAxes.LATITUDE);
- verifyAxesConvention(AxesConvention.POSITIVE_RANGE, cs, HardCodedAxes.SHIFTED_LONGITUDE, HardCodedAxes.LATITUDE);
+ final AbstractCS cs = new AbstractCS(singletonMap(NAME_KEY, "Test"),
+ HardCodedAxes.GEODETIC_LONGITUDE, HardCodedAxes.GEODETIC_LATITUDE);
+ verifyAxesConvention(AxesConvention.POSITIVE_RANGE, cs,
+ HardCodedAxes.SHIFTED_LONGITUDE, HardCodedAxes.GEODETIC_LATITUDE);
}
/**
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -18,27 +18,34 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import javax.xml.bind.JAXBException;
+import javax.measure.unit.SI;
import org.opengis.test.Validators;
+import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.referencing.GeodeticObjectVerifier;
import org.apache.sis.test.XMLTestCase;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
import org.junit.Test;
import static org.apache.sis.test.Assert.*;
import static java.util.Collections.singletonMap;
+import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
import static org.apache.sis.test.TestUtilities.getSingleton;
/**
* Tests the {@link DefaultCartesianCS} class.
*
- * @author Martin Desruisseaux (IRD)
+ * @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-2.2)
* @version 0.4
* @module
*/
-@DependsOn(AbstractCSTest.class)
+@DependsOn({
+ DirectionAlongMeridianTest.class,
+ AbstractCSTest.class
+})
public final strictfp class DefaultCartesianCSTest extends XMLTestCase {
/**
* An XML file in this package containing a Cartesian coordinate system definition.
@@ -86,8 +93,8 @@ public final strictfp class DefaultCarte
*/
try {
final DefaultCartesianCS cs = new DefaultCartesianCS(properties,
- HardCodedAxes.LONGITUDE,
- HardCodedAxes.LATITUDE);
+ HardCodedAxes.GEODETIC_LONGITUDE,
+ HardCodedAxes.GEODETIC_LATITUDE);
fail("Angular units should not be accepted for " + cs);
} catch (IllegalArgumentException e) {
assertFalse(e.getMessage().isEmpty());
@@ -114,6 +121,82 @@ public final strictfp class DefaultCarte
}
/**
+ * Creates an axis for the specified direction.
+ *
+ * @param direction The name of an {@link AxisDirection} value.
+ */
+ private static DefaultCoordinateSystemAxis createAxis(final String direction) {
+ final AxisDirection c = CoordinateSystems.parseAxisDirection(direction);
+ if (c.equals(AxisDirection.NORTH)) return HardCodedAxes.NORTHING;
+ if (c.equals(AxisDirection.EAST)) return HardCodedAxes.EASTING;
+ if (c.equals(AxisDirection.SOUTH)) return HardCodedAxes.SOUTHING;
+ if (c.equals(AxisDirection.WEST)) return HardCodedAxes.WESTING;
+ return new DefaultCoordinateSystemAxis(singletonMap(NAME_KEY, c.name()), "?", c, SI.METRE);
+ }
+
+ /**
+ * Creates a coordinate system with the specified axis directions.
+ *
+ * @param x The name of an {@link AxisDirection} value for the x axis.
+ * @param y The name of an {@link AxisDirection} value for the y axis.
+ */
+ private static DefaultCartesianCS createCS(final String x, final String y) {
+ final DefaultCoordinateSystemAxis xAxis = createAxis(x);
+ final DefaultCoordinateSystemAxis yAxis = createAxis(y);
+ final String name = xAxis.getName().getCode() + ", " + yAxis.getName().getCode();
+ return new DefaultCartesianCS(singletonMap(NAME_KEY, name), xAxis, yAxis);
+ }
+
+ /**
+ * Creates a Cartesian CS using the provided test axis, invoke {@link AbstractCS#standard}
+ * with it and compare with the expected axis.
+ *
+ * @param expectedX The name of the expected {@link AxisDirection} of x axis after normalization.
+ * @param expectedY The name of the expected {@link AxisDirection} of y axis after normalization.
+ * @param toTestX The name of the {@link AxisDirection} value for the x axis of the CS to normalize.
+ * @param toTestY The name of the {@link AxisDirection} value for the y axis of the CS to normalize.
+ */
+ private static void assertNormalizationEquals(
+ final String expectedX, final String expectedY,
+ final String toTestX, final String toTestY)
+ {
+ DefaultCartesianCS cs = createCS(toTestX, toTestY);
+ cs = cs.forConvention(AxesConvention.NORMALIZED);
+ assertEqualsIgnoreMetadata(createCS(expectedX, expectedY), cs);
+ }
+
+ /**
+ * Asserts that the coordinate system made of the given axes is normalized.
+ * This method also ensures that swapping the axes and normalizing give back the original CS.
+ */
+ private static void assertNormalized(final String x, final String y) {
+ assertNormalizationEquals(x, y, x, y); // Expect no-op.
+ assertNormalizationEquals(x, y, y, x); // Expect normalization.
+ }
+
+ /**
+ * Tests {@link DefaultCartesianCS#forConvention(AxesConvention)} with {@link AxesConvention#NORMALIZED}.
+ */
+ @Test
+ @DependsOnMethod("testConstructor")
+ public void testNormalization() {
+ // ----------- Axis to test ------ Expected axis --
+ assertNormalizationEquals("East", "North", "East", "North");
+ assertNormalizationEquals("East", "North", "North", "East");
+ assertNormalizationEquals("East", "North", "South", "East");
+ assertNormalizationEquals("East", "North", "South", "West");
+
+ assertNormalized("East", "North");
+ assertNormalized("South-East", "North-East");
+ assertNormalized("North along 90 deg East", "North along 0 deg");
+ assertNormalized("North along 90 deg East", "North along 0 deg");
+ assertNormalized("North along 75 deg West", "North along 165 deg West");
+ assertNormalized("South along 90 deg West", "South along 0 deg");
+ assertNormalized("South along 180 deg", "South along 90 deg West");
+ assertNormalized("North along 130 deg West", "North along 140 deg East");
+ }
+
+ /**
* Tests (un)marshalling of a Cartesian coordinate system.
*
* @throws JAXBException If an error occurred during unmarshalling.
Modified: 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=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -16,6 +16,9 @@
*/
package org.apache.sis.referencing.cs;
+import javax.measure.unit.NonSI;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.RangeMeaning;
import org.opengis.test.Validators;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.test.DependsOnMethod;
@@ -25,6 +28,7 @@ import org.junit.Test;
import static org.apache.sis.referencing.Assert.*;
import static org.apache.sis.referencing.cs.HardCodedAxes.*;
+import static org.apache.sis.referencing.IdentifiedObjects.getProperties;
/**
@@ -47,8 +51,8 @@ public final strictfp class DefaultCoord
public void validate() {
Validators.validate(GEODETIC_LONGITUDE);
Validators.validate(GEODETIC_LATITUDE);
- Validators.validate(LONGITUDE);
- Validators.validate(LATITUDE);
+ Validators.validate(LONGITUDE_gon);
+ Validators.validate(LATITUDE_gon);
Validators.validate(ELLIPSOIDAL_HEIGHT);
Validators.validate(GRAVITY_RELATED_HEIGHT);
Validators.validate(ALTITUDE);
@@ -81,8 +85,8 @@ public final strictfp class DefaultCoord
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(LONGITUDE_gon, "AXIS[“Longitude”, EAST]");
+ assertWktEquals(LATITUDE_gon, "AXIS[“Latitude”, NORTH]");
assertWktEquals(ALTITUDE, "AXIS[“Altitude”, UP]");
assertWktEquals(TIME, "AXIS[“Time”, FUTURE]");
assertWktEquals(GEODETIC_LONGITUDE, "AXIS[“Geodetic longitude”, EAST]");
@@ -96,12 +100,13 @@ public final strictfp class DefaultCoord
*/
@Test
public void testIsHeuristicMatchForName() {
- assertTrue (LONGITUDE.isHeuristicMatchForName(GEODETIC_LONGITUDE.getName().getCode()));
- assertFalse(LONGITUDE.isHeuristicMatchForName(GEODETIC_LATITUDE .getName().getCode()));
- assertFalse(LONGITUDE.isHeuristicMatchForName(ALTITUDE .getName().getCode()));
- assertFalse(X .isHeuristicMatchForName(LONGITUDE .getName().getCode()));
- assertFalse(X .isHeuristicMatchForName(EASTING .getName().getCode()));
- assertFalse(X .isHeuristicMatchForName(NORTHING .getName().getCode()));
+ assertTrue (LONGITUDE_gon.isHeuristicMatchForName(GEODETIC_LONGITUDE.getName().getCode()));
+ assertFalse(LONGITUDE_gon.isHeuristicMatchForName(GEODETIC_LATITUDE .getName().getCode()));
+ assertFalse(LONGITUDE_gon.isHeuristicMatchForName(ALTITUDE .getName().getCode()));
+ assertTrue (LATITUDE_gon .isHeuristicMatchForName(GEODETIC_LATITUDE .getName().getCode()));
+ assertFalse(X .isHeuristicMatchForName(LONGITUDE_gon .getName().getCode()));
+ assertFalse(X .isHeuristicMatchForName(EASTING .getName().getCode()));
+ assertFalse(X .isHeuristicMatchForName(NORTHING .getName().getCode()));
}
/**
@@ -110,6 +115,15 @@ public final strictfp class DefaultCoord
@Test
@DependsOnMethod("testIsHeuristicMatchForName")
public void testEqualsIgnoreMetadata() {
+ /*
+ * Defines, only for the purpose of this test, axis constants identical to
+ * (GEODETIC_LONGITUDE, GEODETIC_LATITUDE) except for the name.
+ */
+ final DefaultCoordinateSystemAxis LONGITUDE = new DefaultCoordinateSystemAxis(getProperties(LONGITUDE_gon),
+ "λ", AxisDirection.EAST, NonSI.DEGREE_ANGLE, -180, 180, RangeMeaning.WRAPAROUND);
+ final DefaultCoordinateSystemAxis LATITUDE = new DefaultCoordinateSystemAxis(getProperties(LATITUDE_gon),
+ "φ", AxisDirection.NORTH, NonSI.DEGREE_ANGLE, -90, 90, RangeMeaning.EXACT);
+
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));
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -17,10 +17,12 @@
package org.apache.sis.referencing.cs;
import javax.xml.bind.JAXBException;
+import javax.measure.unit.NonSI;
import org.opengis.test.Validators;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.test.XMLTestCase;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.referencing.GeodeticObjectVerifier;
import org.junit.Test;
@@ -31,7 +33,7 @@ import static org.apache.sis.test.TestUt
/**
* Tests the {@link DefaultEllipsoidalCS} class.
*
- * @author Martin Desruisseaux (IRD)
+ * @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.4 (derived from geotk-2.2)
* @version 0.4
* @module
@@ -39,11 +41,82 @@ import static org.apache.sis.test.TestUt
@DependsOn(AbstractCSTest.class)
public final strictfp class DefaultEllipsoidalCSTest extends XMLTestCase {
/**
+ * Tolerance threshold for strict floating point comparisons.
+ */
+ private static final double STRICT = 0;
+
+ /**
* An XML file in this package containing an ellipsoidal coordinate system definition.
*/
private static final String XML_FILE = "EllipsoidalCS.xml";
/**
+ * Tests the {@link DefaultEllipsoidalCS#forConvention(AxesConvention)} method.
+ */
+ @Test
+ public void testShiftLongitudeRange() {
+ final DefaultEllipsoidalCS cs = HardCodedCS.GEODETIC_3D;
+ CoordinateSystemAxis axis = cs.getAxis(0);
+ assertEquals("longitude.minimumValue", -180, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", +180, axis.getMaximumValue(), STRICT);
+
+ assertSame("Expected a no-op.", cs, cs.forConvention(AxesConvention.NORMALIZED));
+ final DefaultEllipsoidalCS shifted = cs.forConvention(AxesConvention.POSITIVE_RANGE);
+ assertNotSame("Expected a new CS.", cs, shifted);
+ Validators.validate(shifted);
+
+ axis = shifted.getAxis(0);
+ assertEquals("longitude.minimumValue", 0, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", 360, axis.getMaximumValue(), STRICT);
+ assertSame("Expected a no-op.", shifted, shifted.forConvention(AxesConvention.POSITIVE_RANGE));
+ assertSame("Expected cached instance.", shifted, cs .forConvention(AxesConvention.POSITIVE_RANGE));
+ }
+
+ /**
+ * Tests the {@link DefaultEllipsoidalCS#forConvention(AxesConvention)} method with gradians units.
+ */
+ @Test
+ @DependsOnMethod("testShiftLongitudeRange")
+ public void testShiftLongitudeRangeGradians() {
+ final DefaultEllipsoidalCS cs = HardCodedCS.ELLIPSOIDAL_gon;
+ CoordinateSystemAxis axis = cs.getAxis(0);
+ assertEquals("longitude.minimumValue", -200, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", +200, axis.getMaximumValue(), STRICT);
+
+ assertSame("Expected a no-op.", cs, cs.forConvention(AxesConvention.RIGHT_HANDED));
+ final DefaultEllipsoidalCS shifted = cs.forConvention(AxesConvention.POSITIVE_RANGE);
+ assertNotSame("Expected a new CS.", cs, shifted);
+ Validators.validate(shifted);
+
+ axis = shifted.getAxis(0);
+ assertEquals("longitude.minimumValue", 0, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", 400, axis.getMaximumValue(), STRICT);
+ assertSame("Expected a no-op.", shifted, shifted.forConvention(AxesConvention.POSITIVE_RANGE));
+ assertSame("Expected cached instance.", shifted, cs .forConvention(AxesConvention.POSITIVE_RANGE));
+ }
+
+ /**
+ * Tests the {@link DefaultEllipsoidalCS#forConvention(AxesConvention)} involving unit conversions.
+ */
+ @Test
+ public void testUnitConversion() {
+ final DefaultEllipsoidalCS cs = HardCodedCS.ELLIPSOIDAL_gon;
+ CoordinateSystemAxis axis = cs.getAxis(0);
+ assertEquals("unit", NonSI.GRADE, axis.getUnit());
+ assertEquals("longitude.minimumValue", -200, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", +200, axis.getMaximumValue(), STRICT);
+
+ final DefaultEllipsoidalCS converted = cs.forConvention(AxesConvention.NORMALIZED);
+ assertNotSame("Expected a new CS.", cs, converted);
+ Validators.validate(converted);
+
+ axis = converted.getAxis(0);
+ assertEquals("unit", NonSI.DEGREE_ANGLE, axis.getUnit());
+ assertEquals("longitude.minimumValue", -180, axis.getMinimumValue(), STRICT);
+ assertEquals("longitude.maximumValue", +180, axis.getMaximumValue(), STRICT);
+ }
+
+ /**
* Tests (un)marshalling of an ellipsoidal coordinate system.
*
* @throws JAXBException If an error occurred during unmarshalling.
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedAxes.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -35,8 +35,7 @@ import static java.util.Collections.sing
*/
public final strictfp class HardCodedAxes {
/**
- * Axis info for geodetic longitudes in a
- * {@linkplain org.opengis.referencing.crs.GeographicCRS geographic CRS}.
+ * Axis for geodetic longitudes in a {@linkplain org.apache.sis.referencing.crs.DefaultGeographicCRS 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).
@@ -52,8 +51,7 @@ public final strictfp class HardCodedAxe
AxisDirection.EAST, NonSI.DEGREE_ANGLE, -180, 180, RangeMeaning.WRAPAROUND);
/**
- * Default axis info for geodetic latitudes in a
- * {@linkplain org.opengis.referencing.crs.GeographicCRS geographic CRS}.
+ * Axis for geodetic latitudes in a {@linkplain org.apache.sis.referencing.crs.DefaultGeographicCRS 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).
@@ -69,46 +67,42 @@ public final strictfp class HardCodedAxe
AxisDirection.NORTH, NonSI.DEGREE_ANGLE, -90, 90, RangeMeaning.EXACT);
/**
- * Identical to {@link #LONGITUDE} except for the range of longitude values.
+ * Identical to {@link #GEODETIC_LONGITUDE} except for the range of longitude values.
*/
- public static final DefaultCoordinateSystemAxis SHIFTED_LONGITUDE = create("Longitude", "λ",
+ public static final DefaultCoordinateSystemAxis SHIFTED_LONGITUDE = create("Geodetic longitude", "λ",
AxisDirection.EAST, NonSI.DEGREE_ANGLE, 0, 360, RangeMeaning.WRAPAROUND);
/**
- * 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>
+ * Axis for longitudes in gradian units.
+ * The axis name is {@code "Longitude"} (the {@code "Geodetic" } prefix is omitted for testing purpose).
+ * Increasing ordinates values go {@linkplain AxisDirection#EAST East} and units are {@link NonSI#GRADE}.
+ * The abbreviation is "λ" (lambda). The unit symbol is "gon".
*
* @see #GEODETIC_LONGITUDE
* @see #SPHERICAL_LONGITUDE
* @see #LATITUDE
*/
- public static final DefaultCoordinateSystemAxis LONGITUDE = create("Longitude", "λ",
- AxisDirection.EAST, NonSI.DEGREE_ANGLE, -180, 180, RangeMeaning.WRAPAROUND);
+ public static final DefaultCoordinateSystemAxis LONGITUDE_gon = create("Longitude", "λ",
+ AxisDirection.EAST, NonSI.GRADE, -200, 200, RangeMeaning.WRAPAROUND);
/**
- * 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>
+ * Axis for latitudes in gradian units.
+ * The axis name is {@code "Latitude"} (the {@code "Geodetic" } prefix is omitted for testing purpose).
+ * Increasing ordinates values go {@linkplain AxisDirection#NORTH North} and units are {@link NonSI#GRADE}.
+ * The abbreviation is "φ" (phi). The unit symbol is "gon".
*
* @see #GEODETIC_LATITUDE
* @see #SPHERICAL_LATITUDE
* @see #LONGITUDE
*/
- public static final DefaultCoordinateSystemAxis LATITUDE = create("Latitude", "φ",
- AxisDirection.NORTH, NonSI.DEGREE_ANGLE, -90, 90, RangeMeaning.EXACT);
+ public static final DefaultCoordinateSystemAxis LATITUDE_gon = create("Latitude", "φ",
+ AxisDirection.NORTH, NonSI.GRADE, -100, 100, RangeMeaning.EXACT);
/**
- * The default axis for height values above the ellipsoid in a
- * {@linkplain org.opengis.referencing.crs.GeographicCRS geographic CRS}.
+ * Axis for height values above the ellipsoid in a
+ * {@linkplain org.apache.sis.referencing.crs.DefaultGeographicCRS 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>".
+ * The ISO 19111 name is "<cite>ellipsoidal height</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>
@@ -122,7 +116,7 @@ public final strictfp class HardCodedAxe
AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * The default axis for height values measured from gravity.
+ * 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>".
*
@@ -141,7 +135,7 @@ public final strictfp class HardCodedAxe
AxisDirection.UP, SI.CENTIMETRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * The default axis for altitude values.
+ * 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>".
*
@@ -156,7 +150,7 @@ public final strictfp class HardCodedAxe
AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * The default axis for depth.
+ * 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>".
*
@@ -169,9 +163,8 @@ public final strictfp class HardCodedAxe
AxisDirection.DOWN, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * Default axis info for radius in a
- * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
- * {@linkplain org.opengis.referencing.cs.SphericalCS spherical CS}.
+ * Axis for radius in a {@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS geocentric CRS}
+ * using {@linkplain org.apache.sis.referencing.cs.DefaultSphericalCS 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>".
*
@@ -187,9 +180,8 @@ public final strictfp class HardCodedAxe
AxisDirection.UP, SI.METRE, 0, Double.POSITIVE_INFINITY, RangeMeaning.EXACT);
/**
- * Default axis info for longitudes in a
- * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
- * {@linkplain org.opengis.referencing.crs.SphericalCS spherical CS}.
+ * Axis for longitudes in a {@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS geocentric CRS}
+ * using {@linkplain org.apache.sis.referencing.cs.DefaultSphericalCS 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).
@@ -205,9 +197,8 @@ public final strictfp class HardCodedAxe
AxisDirection.EAST, NonSI.DEGREE_ANGLE, -180, 180, RangeMeaning.WRAPAROUND);
/**
- * Default axis info for latitudes in a
- * {@linkplain org.opengis.referencing.crs.GeocentricCRS geocentric CRS} using
- * {@linkplain org.opengis.referencing.cs.SphericalCS spherical CS}.
+ * Axis for latitudes in a {@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS geocentric CRS}
+ * using {@linkplain org.apache.sis.referencing.cs.DefaultSphericalCS 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).
@@ -223,10 +214,8 @@ public final strictfp class HardCodedAxe
AxisDirection.NORTH, NonSI.DEGREE_ANGLE, -90, 90, RangeMeaning.EXACT);
/**
- * 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}.
+ * Axis for <var>x</var> values in a {@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS 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>
@@ -241,10 +230,8 @@ public final strictfp class HardCodedAxe
AxisDirection.EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * 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}.
+ * Axis for <var>y</var> values in a {@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS 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>
@@ -259,10 +246,8 @@ public final strictfp class HardCodedAxe
AxisDirection.NORTH, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * 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}.
+ * Axis for <var>z</var> values in a {@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS 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>
@@ -271,56 +256,52 @@ public final strictfp class HardCodedAxe
AxisDirection.UP, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * 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}.
+ * Axis for <var>x</var> values in a {@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS geocentric CRS}
+ * using {@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS 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>".
+ * 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",
+ public static final DefaultCoordinateSystemAxis GEOCENTRIC_X = create("Geocentric X", "X",
AxisDirection.GEOCENTRIC_X, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * 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}.
+ * Axis for <var>y</var> values in a {@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS geocentric CRS}
+ * using {@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS 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>".
+ * 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",
+ public static final DefaultCoordinateSystemAxis GEOCENTRIC_Y = create("Geocentric Y", "Y",
AxisDirection.GEOCENTRIC_Y, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * 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}.
+ * Axis for <var>z</var> values in a {@linkplain org.apache.sis.referencing.crs.DefaultGeocentricCRS geocentric CRS}
+ * using {@linkplain org.apache.sis.referencing.cs.DefaultCartesianCS 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>".
+ * 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",
+ public static final DefaultCoordinateSystemAxis GEOCENTRIC_Z = create("Geocentric Z", "Z",
AxisDirection.GEOCENTRIC_Z, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * Default axis info for Easting values in a
- * {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}.
+ * Axis for Easting values in a {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS 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>".
*
@@ -334,8 +315,7 @@ public final strictfp class HardCodedAxe
AxisDirection.EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * Default axis info for Westing values in a
- * {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}.
+ * Axis for Westing values in a {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS 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>".
*
@@ -347,8 +327,7 @@ public final strictfp class HardCodedAxe
AxisDirection.WEST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * Default axis info for Northing values in a
- * {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}.
+ * Axis for Northing values in a {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS 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>".
*
@@ -362,8 +341,7 @@ public final strictfp class HardCodedAxe
AxisDirection.NORTH, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * Default axis info for Southing values in a
- * {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}.
+ * Axis for Southing values in a {@linkplain org.apache.sis.referencing.crs.DefaultProjectedCRS 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>".
*
@@ -387,7 +365,7 @@ public final strictfp class HardCodedAxe
AxisDirection.SOUTH_EAST, SI.METRE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * A default axis for time values in a {@linkplain org.opengis.referencing.cs.TimeCS time CS}.
+ * Axis for time values in a {@linkplain org.apache.sis.referencing.cs.DefaultTimeCS 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>".
*/
@@ -395,7 +373,7 @@ public final strictfp class HardCodedAxe
AxisDirection.FUTURE, NonSI.DAY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * A default axis for column indices in a {@linkplain org.opengis.coverage.grid.GridCoverage grid coverage}.
+ * 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>".
*/
@@ -403,7 +381,7 @@ public final strictfp class HardCodedAxe
AxisDirection.COLUMN_POSITIVE, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * A default axis for row indices in a {@linkplain org.opengis.coverage.grid.GridCoverage grid coverage}.
+ * 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>".
*/
@@ -411,16 +389,16 @@ public final strictfp class HardCodedAxe
AxisDirection.ROW_POSITIVE, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * A default axis for <var>x</var> values in a display device. Increasing values go toward
- * {@linkplain AxisDirection#DISPLAY_RIGHT display right}.
+ * 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, Unit.ONE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, null);
/**
- * A default axis for <var>y</var> values in a display device. Increasing values go toward
- * {@linkplain AxisDirection#DISPLAY_DOWN display down}.
+ * 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",
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java?rev=1559289&r1=1559288&r2=1559289&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java [UTF-8] Fri Jan 17 23:54:34 2014
@@ -37,6 +37,17 @@ import static org.apache.sis.referencing
public final strictfp class HardCodedCS {
/**
* A two-dimensional ellipsoidal CS with
+ * <var>{@linkplain HardCodedAxes#GEODETIC_LATITUDE geodetic latitude}</var>,
+ * <var>{@linkplain HardCodedAxes#GEODETIC_LONGITUDE geodetic longitude}</var>
+ * axes in decimal degrees.
+ */
+ public static final DefaultEllipsoidalCS GEODETIC_φλ = new DefaultEllipsoidalCS(
+ singletonMap(NAME_KEY, "Geodetic 2D (φ,λ)"),
+ HardCodedAxes.GEODETIC_LATITUDE,
+ HardCodedAxes.GEODETIC_LONGITUDE);
+
+ /**
+ * A two-dimensional ellipsoidal CS with
* <var>{@linkplain HardCodedAxes#GEODETIC_LONGITUDE geodetic longitude}</var>,
* <var>{@linkplain HardCodedAxes#GEODETIC_LATITUDE geodetic latitude}</var>
* axes in decimal degrees.
@@ -60,6 +71,17 @@ public final strictfp class HardCodedCS
HardCodedAxes.ELLIPSOIDAL_HEIGHT);
/**
+ * A two-dimensional ellipsoidal CS with
+ * <var>{@linkplain HardCodedAxes#LONGITUDE_gon longitude}</var>,
+ * <var>{@linkplain HardCodedAxes#LATITUDE_gon latitude}</var>
+ * axes (without "Geodetic" prefix) in gradians.
+ */
+ public static final DefaultEllipsoidalCS ELLIPSOIDAL_gon = new DefaultEllipsoidalCS(
+ singletonMap(NAME_KEY, "Ellipsoidal (gon)"),
+ HardCodedAxes.LONGITUDE_gon,
+ HardCodedAxes.LATITUDE_gon);
+
+ /**
* A three-dimensional spherical CS with
* <var>{@linkplain HardCodedAxes#SPHERICAL_LONGITUDE longitude}</var>,
* <var>{@linkplain HardCodedAxes#SPHERICAL_LATITUDE latitude}</var>,