This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 918e07bcbc Avoid usage of the deprecated `AxisDirection.OTHER` code
list value.
918e07bcbc is described below
commit 918e07bcbc1c2787cfffb8a124151932599e199d
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Fri Apr 19 11:31:58 2024 +0200
Avoid usage of the deprecated `AxisDirection.OTHER` code list value.
---
.../apache/sis/coverage/grid/GridExtentCRS.java | 6 ++---
.../apache/sis/io/wkt/GeodeticObjectParser.java | 5 ++--
.../org/apache/sis/referencing/cs/AbstractCS.java | 4 +--
.../main/org/apache/sis/referencing/cs/Codes.java | 24 +++++++++--------
.../org/apache/sis/referencing/cs/Normalizer.java | 9 ++++---
.../sis/referencing/factory/sql/TableInfo.java | 1 -
.../apache/sis/referencing/internal/Legacy.java | 16 +++++++++---
.../referencing/operation/DefaultConversion.java | 3 ++-
.../sis/referencing/operation/matrix/Matrices.java | 2 +-
.../sis/referencing/privy/AxisDirections.java | 24 ++++++++++++++---
.../org/apache/sis/io/wkt/TransliteratorTest.java | 12 ++++-----
.../apache/sis/referencing/cs/HardCodedAxes.java | 4 +--
.../apache/sis/referencing/cs/NormalizerTest.java | 5 ++--
.../sis/referencing/privy/AxisDirectionsTest.java | 30 ++++++++++++++--------
.../org/apache/sis/storage/netcdf/base/Axis.java | 2 +-
.../sis/util/collection/CodeListSetTest.java | 26 +++++++++----------
geoapi/snapshot | 2 +-
17 files changed, 108 insertions(+), 67 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java
index cacfa9b7fa..95020e45e4 100644
---
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java
+++
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridExtentCRS.java
@@ -299,7 +299,7 @@ final class GridExtentCRS {
abbreviation = "t"; direction = AxisDirection.FUTURE;
hasTime = true;
} else {
abbreviation = abbreviation(target);
- direction = AxisDirection.OTHER;
+ direction = AxisDirection.UNSPECIFIED;
hasOther = true;
}
/*
@@ -311,7 +311,7 @@ final class GridExtentCRS {
final CoordinateSystemAxis previous = axes[k];
if (previous != null) {
if
(direction.equals(AxisDirections.absolute(previous.getDirection()))) {
- direction = AxisDirection.OTHER;
+ direction = AxisDirection.UNSPECIFIED;
hasOther = true;
}
if (abbreviation.equals(previous.getAbbreviation())) {
@@ -334,7 +334,7 @@ final class GridExtentCRS {
if (axes[j] == null) {
final String name =
Vocabulary.forLocale(locale).getString(Vocabulary.Keys.Dimension_1, j);
final String abbreviation = abbreviation(j);
- axes[j] = axis(csFactory, name, abbreviation,
AxisDirection.OTHER);
+ axes[j] = axis(csFactory, name, abbreviation,
AxisDirection.UNSPECIFIED);
}
}
/*
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
index f0678cf713..2ab59defc8 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/io/wkt/GeodeticObjectParser.java
@@ -867,7 +867,7 @@ class GeodeticObjectParser extends MathTransformParser
implements Comparator<Coo
if (defaultUnit == null) {
throw
parent.missingComponent(WKTKeywords.ParametricUnit);
}
- direction = AxisDirection.OTHER;
+ direction = AxisDirection.UNSPECIFIED;
nz = "Parametric";
z = "p";
break;
@@ -2213,7 +2213,6 @@ class GeodeticObjectParser extends MathTransformParser
implements Comparator<Coo
* @return the {@code "FITTED_CS"} element as a {@link CompoundCRS} object.
* @throws ParseException if the {@code "COMPD_CS"} element cannot be
parsed.
*/
- @SuppressWarnings("deprecation")
private DerivedCRS parseFittedCS(final int mode, final Element parent)
throws ParseException {
final Element element = parent.pullElement(mode,
WKTKeywords.Fitted_CS);
if (element == null) {
@@ -2243,7 +2242,7 @@ class GeodeticObjectParser extends MathTransformParser
implements Comparator<Coo
buffer.append(number);
axes[i] = csFactory.createCoordinateSystemAxis(
singletonMap(CoordinateSystemAxis.NAME_KEY,
buffer.toString()),
- number, AxisDirection.OTHER, Units.UNITY);
+ number, AxisDirection.UNSPECIFIED, Units.UNITY);
}
final Map<String,Object> properties =
parseMetadataAndClose(element, name, baseCRS);
final Map<String,Object> axisName =
singletonMap(CoordinateSystem.NAME_KEY, AxisDirections.appendTo(new
StringBuilder("CS"), axes));
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
index a7a8ca7b3b..f69e8f1555 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/AbstractCS.java
@@ -228,11 +228,11 @@ public class AbstractCS extends AbstractIdentifiedObject
implements CoordinateSy
* more than one time axis. Such case happen in meteorological
models.
*/
final AxisDirection dir = AxisDirections.absolute(direction);
- if (!dir.equals(AxisDirection.OTHER)) {
+ if (dir != AxisDirection.UNSPECIFIED &&
!AxisDirections.isLegacyOther(dir)) {
for (int j=i; --j>=0;) {
final AxisDirection other = axes[j].getDirection();
final AxisDirection abs = AxisDirections.absolute(other);
- if (dir.equals(abs) && !abs.equals(AxisDirection.FUTURE)) {
+ if (dir == abs && abs != AxisDirection.FUTURE) {
throw new
IllegalArgumentException(Resources.forProperties(properties).getString(
Resources.Keys.ColinearAxisDirections_2,
direction, other));
}
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Codes.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Codes.java
index 9cfd4e8c53..c85db0b272 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Codes.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Codes.java
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import java.util.HashMap;
+import java.util.OptionalInt;
import javax.measure.Unit;
import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.measure.Units;
@@ -66,21 +67,21 @@ final class Codes {
/**
* Packs the given axis directions in a single integer.
*
- * @return the packed directions, or 0 if the given directions cannot be
packed.
+ * @return the packed directions, or empty if the given directions cannot
be packed.
*/
- private static int pack(final AxisDirection[] directions) {
+ private static OptionalInt pack(final AxisDirection[] directions) {
int packed = 0;
int i = directions.length;
if (i <= Integer.BYTES) {
while (--i >= 0) {
final int ordinal = directions[i].ordinal();
- if (ordinal <= 0 || ordinal > Byte.MAX_VALUE) {
- return 0;
+ if (ordinal < 0 || ordinal > Byte.MAX_VALUE) {
+ return OptionalInt.empty();
}
packed = (packed << Byte.SIZE) | ordinal;
}
}
- return packed;
+ return OptionalInt.of(packed);
}
/**
@@ -92,9 +93,9 @@ final class Codes {
static short lookup(final Unit<?> unit, final AxisDirection[] directions) {
final Integer uc = Units.getEpsgCode(unit, true);
if (uc != null) {
- final int p = pack(directions);
- if (p != 0) {
- Codes m = new Codes(p, uc.shortValue(), (short) 0);
+ final OptionalInt p = pack(directions);
+ if (p.isPresent()) {
+ Codes m = new Codes(p.getAsInt(), uc.shortValue(), (short) 0);
m = EPSG.get(m);
if (m != null) {
return m.epsg;
@@ -133,7 +134,7 @@ final class Codes {
static {
final AxisDirection[] directions = new AxisDirection[]
{AxisDirection.EAST, AxisDirection.NORTH};
final int addVertical = AxisDirection.UP.ordinal() << (2 * Byte.SIZE);
- int packed = pack(directions);
+ OptionalInt packed = pack(directions);
short unit = EPSG_METRE;
loop: for (int i=0; ; i++) {
final short epsg;
@@ -168,7 +169,8 @@ loop: for (int i=0; ; i++) {
epsg = 6501; break;
// Cartesian [S,W] in metres
default: break loop;
}
- Codes m = new Codes(packed, unit, epsg);
+ final int p = packed.getAsInt();
+ Codes m = new Codes(p, unit, epsg);
if (EPSG.put(m, m) != null) {
throw new AssertionError(m.epsg);
}
@@ -177,7 +179,7 @@ loop: for (int i=0; ; i++) {
* (this is encoded in CodesTest.VERTICAL_UNIT constant).
*/
if (to3D != 0) {
- m = new Codes(packed | addVertical, unit, to3D);
+ m = new Codes(p | addVertical, unit, to3D);
if (EPSG.put(m, m) != null) {
throw new AssertionError(m.epsg);
}
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
index cb93b937f7..0f64309fdd 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/cs/Normalizer.java
@@ -97,7 +97,7 @@ final class Normalizer implements Comparable<Normalizer> {
/**
* Number of bits by which to shift the {@link AxisDirection#ordinal()}
value in order to make room for
- * inserting intermediate values between them. A shift of 2 make room for
{@literal 1 << 2} intermediate
+ * inserting intermediate values between them. A shift of 3 makes room for
{@literal 1 << 3} intermediate
* values. Those intermediate values are declared in the {@link #ORDER}
map.
*
* @see #order(AxisDirection)
@@ -109,7 +109,7 @@ final class Normalizer implements Comparable<Normalizer> {
*
* @see #order(AxisDirection)
*/
- private static final Map<AxisDirection,Integer> ORDER = new HashMap<>();
+ private static final Map<AxisDirection,Integer> ORDER = new HashMap<>(12);
static {
// Get ordinal of last compass direction defined by GeoAPI. We will
continue on the horizontal plane.
int code = (AxisDirection.NORTH.ordinal() +
(AxisDirections.COMPASS_COUNT - 1)) << SHIFT;
@@ -156,10 +156,13 @@ final class Normalizer implements Comparable<Normalizer> {
/**
* Returns the order of the given axis direction.
+ * The returned value may be negative.
*/
private static int order(final AxisDirection dir) {
final Integer p = ORDER.get(dir);
- return (p != null) ? p : (dir.ordinal() << SHIFT);
+ if (p != null) return p;
+ if (AxisDirections.isLegacyOther(dir)) return -1;
+ return dir.ordinal() << SHIFT;
}
/**
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java
index 61f0df5aab..7ac34d28a2 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/TableInfo.java
@@ -142,7 +142,6 @@ final class TableInfo {
new Class<?>[] { Conversion.class, Transformation.class},
new String[] {"conversion", "transformation"},
"SHOW_OPERATION"),
- // Note: Projection is handled in a special way.
new TableInfo(OperationMethod.class,
"[Coordinate_Operation Method]",
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
index 79324f86ba..9707a27c18 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/internal/Legacy.java
@@ -65,6 +65,14 @@ public final class Legacy {
*/
public static final String DERIVED_TYPE_KEY = "derivedType";
+ /**
+ * The "other" direction used in WKT 1 definition of geocentric CRS.
+ * It was used for meaning "toward prime meridian".
+ *
+ * @see
org.apache.sis.referencing.privy.AxisDirections#isLegacyOther(AxisDirection)
+ */
+ public static final AxisDirection OTHER = AxisDirection.valueOf("OTHER");
+
/**
* A three-dimensional Cartesian CS with the legacy set of geocentric axes.
* OGC 01-009 defines the default geocentric axes as:
@@ -77,8 +85,8 @@ public final class Legacy {
* the ISO 19111's ones (ISO names are "Geocentric X", "Geocentric Y" and
"Geocentric Z"). This constant uses
* the invalid names and directions for WKT 1 parsing/formatting purposes.
*/
- private static final CartesianCS LEGACY = new
DefaultCartesianCS(Map.of(NAME_KEY, "Legacy geocentric"),
- new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "X"), "X",
AxisDirection.OTHER, Units.METRE),
+ private static final CartesianCS GEOCENTRIC = new
DefaultCartesianCS(Map.of(NAME_KEY, "Legacy geocentric"),
+ new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "X"), "X",
OTHER, Units.METRE),
new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "Y"), "Y",
AxisDirection.EAST, Units.METRE),
new DefaultCoordinateSystemAxis(Map.of(NAME_KEY, "Z"), "Z",
AxisDirection.NORTH, Units.METRE));
@@ -109,7 +117,7 @@ public final class Legacy {
* or {@code cs} if the CS axes should be used as-is.
*/
public static CartesianCS forGeocentricCRS(final CartesianCS cs, final
boolean toLegacy) {
- final CartesianCS check = toLegacy ? standard(null) : LEGACY;
+ final CartesianCS check = toLegacy ? standard(null) : GEOCENTRIC;
final int dimension = check.getDimension();
if (cs.getDimension() != dimension) {
return cs;
@@ -120,7 +128,7 @@ public final class Legacy {
}
}
final Unit<?> unit = ReferencingUtilities.getUnit(cs);
- return toLegacy ? replaceUnit(LEGACY, unit) : standard(unit);
+ return toLegacy ? replaceUnit(GEOCENTRIC, unit) : standard(unit);
}
/**
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
index 90cf08b7bd..58fa818fc6 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java
@@ -326,8 +326,9 @@ public class DefaultConversion extends
AbstractSingleOperation implements Conver
public static DefaultConversion castOrCopy(final Conversion object) {
if (object == null || object instanceof DefaultConversion) {
return (DefaultConversion) object;
+ } else {
+ return new DefaultConversion(object);
}
- return new DefaultConversion(object);
}
/**
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
index 294001201b..ef9bf28036 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/matrix/Matrices.java
@@ -451,7 +451,7 @@ public final class Matrices extends Static {
if (Arrays.equals(srcAxes, dstAxes)) {
/*
* createTransform(…) may fail if the arrays contain two axes with
the same direction, for example
- * AxisDirection.OTHER. This check prevents that failure for the
common case of an identity transform.
+ * AxisDirection.UNSPECIFIED. This check prevents that failure for
the case of identity transform.
* The returned matrix must use extended precision for reason
documented in `createTransform(…)`.
*/
final int n = srcAxes.length + 1;
diff --git
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
index 9a42c857f1..aa443b4110 100644
---
a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
+++
b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/AxisDirections.java
@@ -72,9 +72,9 @@ public final class AxisDirections extends Static {
* For each direction, the opposite direction.
* This map shall be immutable after construction.
*/
- private static final Map<AxisDirection,AxisDirection> OPPOSITES = new
HashMap<>(20);
+ private static final Map<AxisDirection,AxisDirection> OPPOSITES = new
HashMap<>(24);
static {
- put(OTHER, OTHER);
+ put(UNSPECIFIED, UNSPECIFIED);
put(NORTH, SOUTH);
put(NORTH_NORTH_EAST, SOUTH_SOUTH_WEST);
put(NORTH_EAST, SOUTH_WEST);
@@ -109,7 +109,7 @@ public final class AxisDirections extends Static {
ROW_POSITIVE, "j",
DISPLAY_RIGHT, "x",
DISPLAY_UP, "y",
- OTHER, "z", // Arbitrary abbreviation, may change
in any future SIS version.
+ UNSPECIFIED, "m", // Arbitrary abbreviation, may change
in any future SIS version.
AWAY_FROM, "r",
COUNTER_CLOCKWISE, "θ");
@@ -256,6 +256,21 @@ public final class AxisDirections extends Static {
return dir == GEOCENTRIC_X || dir == GEOCENTRIC_Y || dir ==
GEOCENTRIC_Z;
}
+ /**
+ * Returns {@code true} if the given direction is the legacy "other" code
list value.
+ * The "other" direction was used in Well Known Text (WKT) 1 but is no
longer declared
+ * in recent standards.
+ *
+ * @param dir the direction to test, or {@code null}.
+ * @return {@code true} if the given direction is the legacy "other"
direction.
+ *
+ * @see org.apache.sis.referencing.internal.Legacy#OTHER
+ */
+ public static boolean isLegacyOther(final AxisDirection dir) {
+ // Compare "other" as string for avoiding class loading.
+ return (dir != null) && "OTHER".equalsIgnoreCase(dir.name());
+ }
+
/**
* Returns {@code true} if the given direction is a spatial axis direction
(including vertical and geocentric axes).
* The current implementation conservatively returns {@code true} for
every non-null directions except a hard-coded
@@ -713,6 +728,9 @@ next: for (int i=0; i <= limit; i++) {
if (abbreviation != null) {
return abbreviation;
}
+ if (isLegacyOther(direction)) {
+ return "m"; // Arbitrary abbreviation, may change
in any future SIS version.
+ }
}
final String id = direction.identifier(); // UML identifier, or null
if none.
return camelCaseToAcronym(id != null ? id :
direction.name()).toString().intern();
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/TransliteratorTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/TransliteratorTest.java
index 31c0786c52..3ba62d844f 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/TransliteratorTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/io/wkt/TransliteratorTest.java
@@ -98,12 +98,12 @@ public final class TransliteratorTest extends TestCase {
@Test
public void testToUnicodeAbbreviation() {
final Transliterator t = Transliterator.DEFAULT;
- assertEquals("φ", t.toUnicodeAbbreviation("ellipsoidal",
AxisDirection.NORTH, "P"), "P");
- assertEquals("φ", t.toUnicodeAbbreviation("ellipsoidal",
AxisDirection.NORTH, "B"), "B");
- assertEquals("λ", t.toUnicodeAbbreviation("ellipsoidal",
AxisDirection.EAST, "L"), "L");
- assertEquals("θ", t.toUnicodeAbbreviation("polar",
AxisDirection.OTHER, "U"), "U");
- assertEquals("Ω", t.toUnicodeAbbreviation("spherical",
AxisDirection.NORTH, "U"), "U");
- assertEquals("θ", t.toUnicodeAbbreviation("spherical",
AxisDirection.EAST, "V"), "V");
+ assertEquals("φ", t.toUnicodeAbbreviation("ellipsoidal",
AxisDirection.NORTH, "P"), "P");
+ assertEquals("φ", t.toUnicodeAbbreviation("ellipsoidal",
AxisDirection.NORTH, "B"), "B");
+ assertEquals("λ", t.toUnicodeAbbreviation("ellipsoidal",
AxisDirection.EAST, "L"), "L");
+ assertEquals("θ", t.toUnicodeAbbreviation("polar",
AxisDirection.CLOCKWISE, "U"), "U");
+ assertEquals("Ω", t.toUnicodeAbbreviation("spherical",
AxisDirection.NORTH, "U"), "U");
+ assertEquals("θ", t.toUnicodeAbbreviation("spherical",
AxisDirection.EAST, "V"), "V");
}
/**
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/HardCodedAxes.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/HardCodedAxes.java
index fe5edb9942..b7b43a955b 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/HardCodedAxes.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/HardCodedAxes.java
@@ -468,8 +468,8 @@ public final class HardCodedAxes {
* and the unit is dimensionless. This constant is sometimes used as a
placeholder
* for axes that were not properly defined.
*/
- public static final DefaultCoordinateSystemAxis UNDEFINED =
create("Undefined", "z",
- AxisDirection.OTHER, Units.UNITY, Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY, null);
+ public static final DefaultCoordinateSystemAxis UNDEFINED =
create("Undefined", "m",
+ AxisDirection.UNSPECIFIED, Units.UNITY, Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY, null);
/**
* Creates a new axis of the given name, abbreviation, direction and unit.
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
index 3a6b0585e8..28ff4bb908 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/cs/NormalizerTest.java
@@ -24,6 +24,7 @@ import org.opengis.referencing.cs.CoordinateSystemAxis;
import static org.opengis.referencing.cs.CoordinateSystem.NAME_KEY;
import org.apache.sis.referencing.ImmutableIdentifier;
import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.internal.Legacy;
import org.apache.sis.util.resources.Vocabulary;
import org.apache.sis.measure.Units;
@@ -115,12 +116,12 @@ public final class NormalizerTest extends TestCase {
@Test
public void testSortWKT1() {
assertOrdered(new AxisDirection[] {
- AxisDirection.OTHER,
+ Legacy.OTHER,
AxisDirection.EAST,
AxisDirection.NORTH
}, new AxisDirection[] {
AxisDirection.NORTH,
- AxisDirection.OTHER,
+ Legacy.OTHER,
AxisDirection.EAST
});
}
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/AxisDirectionsTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/AxisDirectionsTest.java
index 4a347861f2..db2480f1af 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/AxisDirectionsTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/AxisDirectionsTest.java
@@ -23,6 +23,7 @@ import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import static org.opengis.referencing.cs.AxisDirection.*;
+import org.apache.sis.referencing.internal.Legacy;
import org.apache.sis.measure.Units;
// Test dependencies
@@ -102,15 +103,15 @@ public final class AxisDirectionsTest extends TestCase {
*/
@Test
public void testIsOpposite() {
- assertFalse(AxisDirections.isOpposite(NORTH ));
- assertTrue (AxisDirections.isOpposite(SOUTH ));
- assertFalse(AxisDirections.isOpposite(EAST ));
- assertTrue (AxisDirections.isOpposite(WEST ));
- assertFalse(AxisDirections.isOpposite(UP ));
- assertTrue (AxisDirections.isOpposite(DOWN ));
+ assertFalse(AxisDirections.isOpposite(NORTH));
+ assertTrue (AxisDirections.isOpposite(SOUTH));
+ assertFalse(AxisDirections.isOpposite(EAST));
+ assertTrue (AxisDirections.isOpposite(WEST));
+ assertFalse(AxisDirections.isOpposite(UP));
+ assertTrue (AxisDirections.isOpposite(DOWN));
assertFalse(AxisDirections.isOpposite(FUTURE));
- assertTrue (AxisDirections.isOpposite(PAST ));
- assertFalse(AxisDirections.isOpposite(OTHER ));
+ assertTrue (AxisDirections.isOpposite(PAST));
+ assertFalse(AxisDirections.isOpposite(UNSPECIFIED));
}
/**
@@ -136,7 +137,7 @@ public final class AxisDirectionsTest extends TestCase {
assertFalse(AxisDirections.isCardinal(NORTH_NORTH_WEST));
assertFalse(AxisDirections.isCardinal(UP));
assertFalse(AxisDirections.isCardinal(FUTURE));
- assertFalse(AxisDirections.isCardinal(OTHER));
+ assertFalse(AxisDirections.isCardinal(UNSPECIFIED));
}
/**
@@ -162,7 +163,7 @@ public final class AxisDirectionsTest extends TestCase {
assertTrue (AxisDirections.isIntercardinal(NORTH_NORTH_WEST));
assertFalse(AxisDirections.isIntercardinal(UP));
assertFalse(AxisDirections.isIntercardinal(FUTURE));
- assertFalse(AxisDirections.isIntercardinal(OTHER));
+ assertFalse(AxisDirections.isIntercardinal(UNSPECIFIED));
}
/**
@@ -199,6 +200,15 @@ public final class AxisDirectionsTest extends TestCase {
assertFalse(AxisDirections.isGeocentric(FUTURE));
}
+ /**
+ * Tests {@link AxisDirections#isLegacyOther(AxisDirection)}.
+ */
+ @Test
+ public void testIsLegacyOther() {
+ assertFalse(AxisDirections.isLegacyOther(NORTH));
+ assertTrue (AxisDirections.isLegacyOther(Legacy.OTHER));
+ }
+
/**
* Tests {@link AxisDirections#isSpatialOrUserDefined(AxisDirection,
boolean)} and
* {@link AxisDirections#isGrid(AxisDirection)}.
diff --git
a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Axis.java
b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Axis.java
index c0ccbf3514..8bff2968de 100644
---
a/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Axis.java
+++
b/endorsed/src/org.apache.sis.storage.netcdf/main/org/apache/sis/storage/netcdf/base/Axis.java
@@ -630,7 +630,7 @@ public final class Axis extends NamedElement {
} else switch (order) {
case 0: dir = AxisDirection.COLUMN_POSITIVE; break;
case 1: dir = AxisDirection.ROW_POSITIVE; break;
- default: dir = AxisDirection.OTHER; break;
+ default: dir = AxisDirection.UNSPECIFIED; break;
}
}
final String abbr;
diff --git
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/CodeListSetTest.java
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/CodeListSetTest.java
index 6f449ee356..e6ecb333bf 100644
---
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/CodeListSetTest.java
+++
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/collection/CodeListSetTest.java
@@ -46,7 +46,7 @@ public final class CodeListSetTest extends TestCase {
/**
* Creates a new set filled with up to 4 axis directions.
- * The directions are (NORTH, EAST, UP, FUTURE) in that order.
+ * The directions are (NORTH_NORTH_EAST, EAST, UP, FUTURE) in that order.
*
* @param n Number of code list to add.
*/
@@ -59,7 +59,7 @@ public final class CodeListSetTest extends TestCase {
case 4: assertTrue(c.add(FUTURE)); // Fallthrough
everywhere.
case 3: assertTrue(c.add(UP));
case 2: assertTrue(c.add(EAST));
- case 1: assertTrue(c.add(NORTH));
+ case 1: assertTrue(c.add(NORTH_NORTH_EAST));
case 0: break;
}
assertEquals(n, c.size());
@@ -68,12 +68,12 @@ public final class CodeListSetTest extends TestCase {
/**
* Creates a code list of another kind. The returned set contains a code
list having
- * the same ordinal value as {@link AxisDirection#NORTH}, so we can detect
if the
- * {@code SortedSet} confuses the code list types.
+ * the same ordinal value as {@link AxisDirection#NORTH_NORTH_EAST}, so we
can detect
+ * if the {@code SortedSet} confuses the code list types.
*/
private CodeListSet<OnLineFunction> createOtherKind() {
// For the validity of the tests, ordinal value must be the same.
- assertEquals(NORTH.ordinal(), OnLineFunction.INFORMATION.ordinal());
+ assertEquals(NORTH_NORTH_EAST.ordinal(),
OnLineFunction.INFORMATION.ordinal());
final CodeListSet<OnLineFunction> c = new
CodeListSet<>(OnLineFunction.class);
assertTrue(c.add(OnLineFunction.INFORMATION));
return c;
@@ -86,7 +86,7 @@ public final class CodeListSetTest extends TestCase {
@Test
public void testToArray() {
final CodeListSet<AxisDirection> c = create(4);
- assertArrayEquals(new Object[] {NORTH, EAST, UP, FUTURE}, c.toArray());
+ assertArrayEquals(new Object[] {NORTH_NORTH_EAST, EAST, UP, FUTURE},
c.toArray());
}
/**
@@ -106,7 +106,7 @@ public final class CodeListSetTest extends TestCase {
@Test
public void testContains() {
final CodeListSet<AxisDirection> c = create(4);
- assertTrue (c.contains(NORTH));
+ assertTrue (c.contains(NORTH_NORTH_EAST));
assertFalse(c.contains(SOUTH));
assertTrue (c.contains(FUTURE));
assertFalse(c.contains(PAST));
@@ -128,9 +128,9 @@ public final class CodeListSetTest extends TestCase {
assertFalse(c.remove(null), "Should be null-safe.");
assertFalse(c.remove(OnLineFunction.INFORMATION), "Code list of other
kind should not be included.");
- assertTrue (c.remove (NORTH));
+ assertTrue (c.remove (NORTH_NORTH_EAST));
assertFalse(c.remove (SOUTH));
- assertFalse(c.contains(NORTH));
+ assertFalse(c.contains(NORTH_NORTH_EAST));
assertEquals(3, c.size());
assertTrue (c.remove (FUTURE));
@@ -151,7 +151,7 @@ public final class CodeListSetTest extends TestCase {
final CodeListSet<AxisDirection> c = create(4);
final CodeListSet<AxisDirection> o = create(4);
assertTrue (c.containsAll(o));
- assertTrue (o.remove(NORTH));
+ assertTrue (o.remove(NORTH_NORTH_EAST));
assertTrue (o.remove(FUTURE));
assertTrue (c.containsAll(o));
assertTrue (o.add(NORTH_EAST));
@@ -185,7 +185,7 @@ public final class CodeListSetTest extends TestCase {
assertTrue(o.add(NORTH_EAST)); // Extra value shall be ignored.
assertTrue(c.retainAll(o));
- assertArrayEquals(new Object[] {NORTH, EAST}, c.toArray());
+ assertArrayEquals(new Object[] {NORTH_NORTH_EAST, EAST}, c.toArray());
assertFalse(c.retainAll(o)); // Invoking a second time should
not make any difference.
assertEquals(2, c.size());
assertTrue(c.retainAll(createOtherKind()));
@@ -202,7 +202,7 @@ public final class CodeListSetTest extends TestCase {
assertTrue(c.add(NORTH_EAST));
assertTrue(c.addAll(o));
- assertArrayEquals(new Object[] {NORTH, NORTH_EAST, EAST, UP},
c.toArray());
+ assertArrayEquals(new Object[] {NORTH_NORTH_EAST, NORTH_EAST, EAST,
UP}, c.toArray());
assertFalse(c.addAll(o)); // Invoking a second time should not
make any difference.
}
@@ -213,7 +213,7 @@ public final class CodeListSetTest extends TestCase {
public void testFill() {
final CodeListSet<AxisDirection> c = new
CodeListSet<>(AxisDirection.class, true);
assertTrue(c.size() >= 32, "Expect at least 32 elements as of GeoAPI
3.0.");
- assertTrue(c.toString().startsWith("[AxisDirection.OTHER,
AxisDirection.NORTH, "));
+ assertTrue(c.toString().startsWith("[AxisDirection.NORTH,
AxisDirection.NORTH_NORTH_EAST, "));
/*
* Testing the full array would be too long and may change in future
GeoAPI version
* anyway. Actually the main interest of this test is to ensure that
the toString()
diff --git a/geoapi/snapshot b/geoapi/snapshot
index 1dd682e1b3..792044359e 160000
--- a/geoapi/snapshot
+++ b/geoapi/snapshot
@@ -1 +1 @@
-Subproject commit 1dd682e1b3950d7024b17f6639673b896f701441
+Subproject commit 792044359e4e5e2140678ba89bd126f0ca6b57ce