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/15 23:01:48 UTC
svn commit: r1558583 [1/3] - in /sis/branches/JDK6: ./
core/sis-referencing/src/main/java/org/apache/sis/geometry/
core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/
core/sis-referencing/src/main/java/org/apache/sis/referencing/ co...
Author: desruisseaux
Date: Wed Jan 15 22:01:46 2014
New Revision: 1558583
URL: http://svn.apache.org/r1558583
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SubTypes.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SubTypes.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AxesConvention.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/Normalizer.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/SubTypes.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/SubTypes.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/AbstractCSTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCompoundCSTest.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCompoundCSTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/NormalizerTest.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/ElevationAngle.java
- copied unchanged from r1558579, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/ElevationAngle.java
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/CoordinateSystems.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java
sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/SubTypes.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralDirectPositionTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/geometry/SubEnvelopeTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/AxisDirectionsTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectsTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CoordinateSystemsTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DirectionAlongMeridianTest.java
sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Latitude.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/Longitude.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1556839-1558579
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -1020,14 +1020,14 @@ public abstract class AbstractEnvelope i
@Override
public int hashCode() {
final int dimension = getDimension();
- long code = 1;
+ int code = 1;
boolean p = true;
do {
for (int i=0; i<dimension; i++) {
- code = code*31 + doubleToLongBits(p ? getLower(i) : getUpper(i));
+ code = code*31 + Numerics.hashCode(doubleToLongBits(p ? getLower(i) : getUpper(i)));
}
} while ((p = !p) == false);
- return Numerics.hashCode(code) + Objects.hashCode(getCoordinateReferenceSystem());
+ return code + Objects.hashCode(getCoordinateReferenceSystem());
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -30,11 +30,10 @@ import org.opengis.geometry.MismatchedRe
import org.opengis.metadata.extent.GeographicBoundingBox;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.FactoryException;
+import org.apache.sis.referencing.GeodeticObjects;
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.resources.Errors;
-import org.apache.sis.referencing.CRS;
import static org.apache.sis.util.ArgumentChecks.*;
import static org.apache.sis.math.MathFunctions.isNegative;
@@ -195,12 +194,7 @@ class ArrayEnvelope extends AbstractEnve
ArraysExt.swap(ordinates, 1, (ordinates.length >>> 1) + 1);
}
}
- try {
- crs = CRS.forCode("CRS:84");
- } catch (FactoryException e) {
- // Should never happen since we asked for a CRS which should always be present.
- throw new AssertionError(e);
- }
+ crs = GeodeticObjects.WGS84.normalizedGeographic();
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -25,10 +25,9 @@ import org.opengis.metadata.extent.Geogr
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.util.FactoryException;
+import org.apache.sis.referencing.GeodeticObjects;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.Emptiable;
-import org.apache.sis.referencing.CRS;
import static java.lang.Double.NaN;
import static java.lang.Double.isNaN;
@@ -209,12 +208,7 @@ public class Envelope2D extends Rectangl
box.getSouthBoundLatitude(),
box.getEastBoundLongitude(),
box.getNorthBoundLatitude());
- try {
- crs = CRS.forCode("CRS:84");
- } catch (FactoryException e) {
- // Should never happen since we asked for a CRS which should always be present.
- throw new AssertionError(e);
- }
+ crs = GeodeticObjects.WGS84.normalizedGeographic();
if (Boolean.FALSE.equals(box.getInclusion())) {
x += width;
width = -width;
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/AxisDirections.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -35,10 +35,22 @@ import static org.apache.sis.util.CharSe
*/
public final class AxisDirections extends Static {
/**
- * Do not allow instantiation of this class.
+ * Number of directions like "North", "North-North-East", "North-East", etc.
+ * The first of those directions is {@link AxisDirection#NORTH}.
*/
- private AxisDirections() {
- }
+ public static final int COMPASS_COUNT = 16;
+
+ /**
+ * Number of geocentric directions.
+ * The first of those directions is {@link AxisDirection#GEOCENTRIC_X}.
+ */
+ public static final int GEOCENTRIC_COUNT = 3;
+
+ /**
+ * Number of directions like "Display right", "Display down", etc.
+ * The first of those directions is {@link AxisDirection#DISPLAY_RIGHT}.
+ */
+ public static final int DISPLAY_COUNT = 4;
/**
* For each direction, the opposite direction.
@@ -71,6 +83,12 @@ public final class AxisDirections extend
}
/**
+ * Do not allow instantiation of this class.
+ */
+ private AxisDirections() {
+ }
+
+ /**
* Returns the "absolute" direction of the given direction.
* This "absolute" operation is similar to the {@code Math.abs(int)} method in that "negative" directions like
* ({@code SOUTH}, {@code WEST}, {@code DOWN}, {@code PAST}) are changed for their "positive" counterparts
@@ -151,6 +169,45 @@ public final class AxisDirections extend
}
/**
+ * Returns {@code true} if the specified direction is a compass direction.
+ * Compass directions are {@code NORTH}, {@code EAST}, {@code NORTH_EAST}, etc.
+ *
+ * @param dir The direction to test, or {@code null}.
+ * @return {@code true} if the given direction is a compass direction.
+ *
+ * @see #angleForCompass(AxisDirection, AxisDirection)
+ */
+ public static boolean isCompass(final AxisDirection dir) {
+ if (dir == null) return false;
+ final int n = dir.ordinal() - NORTH.ordinal();
+ return n >= 0 && n < COMPASS_COUNT;
+ }
+
+ /**
+ * Returns {@code true} if the specified direction is an inter-cardinal direction.
+ * Inter-cardinal directions are {@code NORTH_EAST}, {@code SOUTH_SOUTH_EAST}, etc.
+ *
+ * @param dir The direction to test, or {@code null}.
+ * @return {@code true} if the given direction is an inter-cardinal direction.
+ */
+ public static boolean isIntercardinal(final AxisDirection dir) {
+ if (dir == null) return false;
+ final int n = dir.ordinal() - NORTH.ordinal();
+ return n >= 0 && n < COMPASS_COUNT && (n & 3) != 0;
+ }
+
+ /**
+ * Returns {@code true} if the given direction is {@code UP} or {@code DOWN}.
+ *
+ * @param dir The direction to test, or {@code null}.
+ * @return {@code true} if the direction is vertical, or {@code false} otherwise.
+ */
+ public static boolean isVertical(final AxisDirection dir) {
+ if (dir == null) return false;
+ return ((dir.ordinal() - UP.ordinal()) & ~1) == 0;
+ }
+
+ /**
* 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
* set of directions which are known to be non-spatial. We conservatively accept unknown axis directions because
@@ -185,6 +242,89 @@ public final class AxisDirections extend
}
/**
+ * Angle between geocentric directions only.
+ *
+ * @param source The start direction.
+ * @param target The final direction.
+ * @return The angle as a multiple of 90°, or {@link Integer#MIN_VALUE} if none.
+ */
+ public static int angleForGeocentric(final AxisDirection source, final AxisDirection target) {
+ final int base = GEOCENTRIC_X.ordinal();
+ final int src = source.ordinal() - base;
+ if (src >= 0 && src < GEOCENTRIC_COUNT) {
+ final int tgt = target.ordinal() - base;
+ if (tgt >= 0 && tgt < GEOCENTRIC_COUNT) {
+ int n = (tgt - src);
+ n -= GEOCENTRIC_COUNT * (n/2); // If -2 add 3. If +2 subtract 3. Otherwise do nothing.
+ return n;
+ }
+ }
+ return Integer.MIN_VALUE;
+ }
+
+ /**
+ * Angle between compass directions only (not for angle between direction along meridians).
+ *
+ * @param source The start direction.
+ * @param target The final direction.
+ * @return The arithmetic angle as a multiple of 360/{@link #COMPASS_COUNT}, or {@link Integer#MIN_VALUE} if none.
+ *
+ * @see #isCompass(AxisDirection)
+ */
+ public static int angleForCompass(final AxisDirection source, final AxisDirection target) {
+ final int base = NORTH.ordinal();
+ final int src = source.ordinal() - base;
+ if (src >= 0 && src < COMPASS_COUNT) {
+ final int tgt = target.ordinal() - base;
+ if (tgt >= 0 && tgt < COMPASS_COUNT) {
+ int n = src - tgt;
+ if (n < -COMPASS_COUNT/2) {
+ n += COMPASS_COUNT;
+ } else if (n > COMPASS_COUNT/2) {
+ n -= COMPASS_COUNT;
+ }
+ return n;
+ }
+ }
+ return Integer.MIN_VALUE;
+ }
+
+ /**
+ * Angle between display directions only.
+ *
+ * @param source The start direction.
+ * @param target The final direction.
+ * @return The arithmetic angle as a multiple of 360/{@link #DISPLAY_RIGHT}, or {@link Integer#MIN_VALUE} if none.
+ */
+ public static int angleForDisplay(final AxisDirection source, final AxisDirection target) {
+ final int base = DISPLAY_RIGHT.ordinal();
+ int src = source.ordinal() - base;
+ if (src >= 0 && src < DISPLAY_COUNT) {
+ int tgt = target.ordinal() - base;
+ if (tgt >= 0 && tgt < DISPLAY_COUNT) {
+ /*
+ * Display directions are RIGHT, LEFT, UP, DOWN. We need to reorder them as UP, RIGHT, DOWN, LEFT.
+ */
+ src = DISPLAY_ORDER[src];
+ tgt = DISPLAY_ORDER[tgt];
+ int n = src - tgt;
+ if (n < -DISPLAY_COUNT/2) {
+ n += DISPLAY_COUNT;
+ } else if (n > DISPLAY_COUNT/2) {
+ n -= DISPLAY_COUNT;
+ }
+ return n;
+ }
+ }
+ return Integer.MIN_VALUE;
+ }
+
+ /**
+ * Maps RIGHT, LEFT, UP, DOWN display order to UP, RIGHT, DOWN, LEFT.
+ */
+ private static final byte[] DISPLAY_ORDER = {1, 3, 0, 2};
+
+ /**
* Finds the dimension of an axis having the given direction or its opposite.
* If more than one axis has the given direction, only the first occurrence is returned.
* If both the given direction and its opposite exist, then the dimension for the given
@@ -213,7 +353,7 @@ public final class AxisDirections extend
}
/**
- * Searches for a axis direction having the given name in the specified list of directions.
+ * Searches for an axis direction having the given name in the specified list of directions.
* This method compares the given name with the name of each {@code AxisDirection} in a lenient way:
*
* <ul>
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -18,7 +18,6 @@ package org.apache.sis.referencing;
import java.util.Map;
import java.util.Set;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.AbstractCollection;
@@ -42,6 +41,7 @@ import org.opengis.referencing.Reference
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.jaxb.referencing.Code;
import org.apache.sis.internal.util.Numerics;
+import org.apache.sis.internal.util.UnmodifiableArrayList;
import org.apache.sis.io.wkt.FormattableObject;
import org.apache.sis.xml.Namespaces;
import org.apache.sis.util.Deprecable;
@@ -490,66 +490,76 @@ public class AbstractIdentifiedObject ex
* Invoked by JAXB at unmarshalling time for each identifier. The first identifier will be taken
* as the name and all other identifiers (if any) as aliases.
*
- * <p>Some JAXB implementations never invoke {@link AbstractIdentifiedObject#setNames(Collection)}.
+ * <p>Some (but not all) JAXB implementations never invoke setter method for collections.
* Instead they invoke {@link AbstractIdentifiedObject#getNames()} and add directly the identifiers
* in the returned collection. Consequently this method must writes directly in the enclosing object.
* See <a href="https://java.net/jira/browse/JAXB-488">JAXB-488</a> for more information.</p>
*/
@Override
public boolean add(final ReferenceIdentifier id) {
- if (name == null) {
- name = id;
- return true;
- }
- if (alias == null) {
- alias = new ArrayList<GenericName>(4);
- }
+ addName(id);
+ return true;
+ }
+ }
+
+ /**
+ * Implementation of {@link Names#add(ReferenceIdentifier)}, defined in the enclosing class
+ * for access to private fields without compiler-generated bridge methods.
+ */
+ final void addName(final ReferenceIdentifier id) {
+ if (name == null) {
+ name = id;
+ } else {
/*
* Our Code and RS_Identifier implementations should always create NamedIdentifier instance,
- * so the 'instanceof' check should not be necessary. But do a paranoiac check anyway.
+ * so the 'instanceof' check should not be necessary. But we do a paranoiac check anyway.
*/
- return alias.add(id instanceof GenericName ? (GenericName) id : new NamedIdentifier(id));
+ final GenericName n = id instanceof GenericName ? (GenericName) id : new NamedIdentifier(id);
+ if (alias == null) {
+ alias = Collections.singleton(n);
+ } else {
+ /*
+ * This implementation is inefficient since each addition copies the array, but we rarely
+ * have more than two aliases. This implementation is okay for a small number of aliases
+ * and ensures that the enclosing AbstractIdentifiedObject is unmodifiable except by this
+ * add(…) method.
+ *
+ * Note about alternative approaches
+ * ---------------------------------
+ * An alternative approach could be to use an ArrayList and replace it by an unmodifiable
+ * list only after unmarshalling (using an afterUnmarshal(Unmarshaller, Object) method),
+ * but we want to avoid Unmarshaller dependency (for reducing classes loading for users
+ * who are not interrested in XML) and it may actually be less efficient for the vast
+ * majority of cases where there is less than 3 aliases.
+ */
+ final int size = alias.size();
+ final GenericName[] names = alias.toArray(new GenericName[size + 1]);
+ names[size] = n;
+ alias = UnmodifiableArrayList.wrap(names);
+ }
}
}
/**
* Returns the {@link #name} and all aliases which are also instance of {@lik ReferenceIdentifier}.
* The later happen often in SIS implementation since many aliases are instance of {@link NamedIdentifier}.
- */
- @XmlElement(name = "name", required = true)
- final Collection<ReferenceIdentifier> getNames() {
- return new Names();
- }
-
- /**
- * Sets the first element as the {@link #name} and all remaining elements as {@link #alias}.
- * This method is invoked by some implementations of JAXB (not all of them) at unmarshalling time.
- * It should not be invoked anymore after the object has been made available to the user.
*
- * <p>Some JAXB implementations never invoke this setter method. Instead they invoke {@link #getNames()}
- * and add directly the identifiers in the returned collection. Whether JAXB will perform a final call to
+ * <p>The returned collection is <cite>live</cite>: adding elements in that collection will modify this
+ * {@code AbstractIdentifiedObject} instance. This is needed for unmarshalling with JAXB and should not
+ * be used in other context.</p>
+ *
+ * {@section Why there is no <code>setNames(…)</code> method}
+ * Some JAXB implementations never invoke setter method for collections. Instead they invoke the getter and
+ * add directly the identifiers in the returned collection. Whether JAXB will perform or not a final call to
* {@code setNames(…)} is JAXB-implementation dependent (JDK7 does but JDK6 and JDK8 early access do not).
- * Consequently we can not rely on this method to be invoked. It is better if this method is invoked, but
- * we will not lost data if it is not.</p>
+ * It seems a more portable approach (at least for JAXB reference implementations) to design our class
+ * without setter method, in order to have the same behavior on all supported JDK versions.
*
* @see <a href="https://java.net/jira/browse/JAXB-488">JAXB-488</a>
*/
- private void setNames(final Collection<ReferenceIdentifier> names) {
- /*
- * If the collection is an instance of Names, then assume that the collection is the instance obtained
- * by getNames(), in which case this IdentifiedObject already contains the content of that collection.
- * This behavior is necessary for working around the JAXB-488 issue.
- */
- if (!(names instanceof Names)) {
- getNames().addAll(names);
- }
- /*
- * Froze aliases in an unmodifiable set. In JAXB implementations that do not invoke the setter method,
- * the aliases list is left modifiable. This is a hole in our object immutability.
- */
- if (alias != null) {
- alias = immutableSet(true, alias.toArray(new GenericName[alias.size()]));
- }
+ @XmlElement(name = "name", required = true)
+ final Collection<ReferenceIdentifier> getNames() {
+ return new Names();
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -20,12 +20,16 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import org.opengis.util.FactoryException;
+import org.opengis.util.NoSuchIdentifierException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.SingleCRS;
import org.opengis.referencing.crs.CompoundCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.internal.util.DefinitionURI;
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.referencing.crs.DefaultCompoundCRS;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Static;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -48,8 +52,22 @@ public final class CRS extends Static {
/**
* Returns a Coordinate Reference System from the given authority code.
+ * There is many thousands of CRS identified by EPSG codes or by other authorities.
+ * The following table lists a very small subset of some of those codes:
*
- * @todo This method is not yet implemented. It will be provided after the EPSG-backed
+ * <blockquote><table class="sis">
+ * <tr><th>Name or alias</th> <th>Code</th></tr>
+ * <tr><td>ED50</td> <td>EPSG:4230</td></tr>
+ * <tr><td>ETRS89</td> <td>EPSG:4258</td></tr>
+ * <tr><td>NAD27</td> <td>EPSG:4267</td></tr>
+ * <tr><td>NAD83</td> <td>EPSG:4269</td></tr>
+ * <tr><td>GRS 1980 Authalic Sphere</td> <td>EPSG:4047</td></tr>
+ * <tr><td>WGS 72</td> <td>EPSG:4322</td></tr>
+ * <tr><td>WGS 84</td> <td>EPSG:4326</td></tr>
+ * <tr><td>WGS 84 with (<var>longitude</var>, <var>latitude</var>) axis order</td> <td>CRS:84</td></tr>
+ * </table></blockquote>
+ *
+ * @todo This method is only partially implemented. It will be fully supported after the EPSG-backed
* authority factory has been ported to Apache SIS.
*
* @param code The authority code.
@@ -61,7 +79,52 @@ public final class CRS extends Static {
throws NoSuchAuthorityCodeException, FactoryException
{
ensureNonNull("code", code);
- return null;
+ final String authority;
+ final String value;
+ final DefinitionURI uri = DefinitionURI.parse(code);
+ if (uri != null) {
+ final String type = uri.type;
+ if (type != null && !type.equalsIgnoreCase("crs")) {
+ throw new NoSuchIdentifierException(Errors.format(Errors.Keys.UnknownType_1, type), type);
+ }
+ authority = uri.authority;
+ value = uri.code;
+ } else {
+ final int s = code.indexOf(DefinitionURI.SEPARATOR);
+ authority = CharSequences.trimWhitespaces(code.substring(0, Math.max(0, s)));
+ value = CharSequences.trimWhitespaces(code.substring(s + 1));
+ }
+ if (authority == null || authority.isEmpty()) {
+ throw new NoSuchIdentifierException(Errors.format(Errors.Keys.MissingAuthority_1, code), code);
+ }
+ /*
+ * Code below this point is a temporary implementation to
+ * be removed after we ported the EPSG authority factory.
+ */
+ NumberFormatException cause = null;
+ try {
+ if (authority.equalsIgnoreCase("CRS")) {
+ switch (Integer.parseInt(value)) {
+ case 84: return GeodeticObjects.WGS84.normalizedGeographic();
+ }
+ } else if (authority.equalsIgnoreCase("EPSG")) {
+ final int n = Integer.parseInt(value);
+ for (final GeodeticObjects candidate : GeodeticObjects.values()) {
+ if (candidate.geographic == n) {
+ return candidate.geographic();
+ }
+ }
+ } else {
+ throw new NoSuchIdentifierException(Errors.format(Errors.Keys.UnknownAuthority_1, authority), authority);
+ }
+ } catch (NumberFormatException e) {
+ cause = e;
+ }
+ final NoSuchAuthorityCodeException e = new NoSuchAuthorityCodeException(
+ Errors.format(Errors.Keys.NoSuchAuthorityCode_3, authority, CoordinateReferenceSystem.class, value),
+ authority, value, code);
+ e.initCause(cause);
+ throw e;
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/GeodeticObjects.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -38,8 +38,10 @@ import org.opengis.referencing.datum.Ver
import org.opengis.referencing.datum.TemporalDatum;
import org.opengis.referencing.datum.DatumAuthorityFactory;
import org.opengis.referencing.crs.CRSAuthorityFactory;
+import org.apache.sis.referencing.crs.DefaultGeographicCRS;
import org.apache.sis.referencing.datum.DefaultVerticalDatum;
import org.apache.sis.referencing.datum.DefaultTemporalDatum;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.util.resources.Vocabulary;
import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
@@ -60,7 +62,7 @@ import static org.opengis.referencing.Id
* (<var>longitude</var>, <var>latitude</var>) axis order on the {@link #WGS84} geodetic datum:</p>
*
* {@preformat java
- * GeographicCRS crs = GeodeticObjects.WGS84.geographic();
+ * GeographicCRS crs = GeodeticObjects.WGS84.normalizedGeographic();
* }
*
* For each enumeration value, the name of the CRS, datum and ellipsoid objects may or may not be the same.
@@ -223,10 +225,10 @@ public enum GeodeticObjects {
/**
* The EPSG code of the geographic CRS.
*/
- final short crs;
+ final short geographic;
/**
- * The EPSG code of the datum. The value is often {@link #crs} + 2000,
+ * The EPSG code of the datum. The value is often {@link #geographic} + 2000,
* but it doesn't have to be always the case.
*/
final short datum;
@@ -244,16 +246,23 @@ public enum GeodeticObjects {
private transient volatile IdentifiedObject cached;
/**
+ * The normalized geographic CRS, created when first needed.
+ *
+ * @see #normalizedGeographic()
+ */
+ private transient volatile GeographicCRS normalized;
+
+ /**
* Creates a new constant for the given EPSG or SIS codes.
*
- * @param crs The EPSG code for the geographic CRS.
- * @param datum The EPSG code for the datum.
- * @param ellipsoid The EPSG code for the ellipsoid.
- */
- private GeodeticObjects(final short crs, final short datum, final short ellipsoid) {
- this.crs = crs;
- this.datum = datum;
- this.ellipsoid = ellipsoid;
+ * @param geographic The EPSG code for the geographic CRS.
+ * @param datum The EPSG code for the datum.
+ * @param ellipsoid The EPSG code for the ellipsoid.
+ */
+ private GeodeticObjects(final short geographic, final short datum, final short ellipsoid) {
+ this.geographic = geographic;
+ this.datum = datum;
+ this.ellipsoid = ellipsoid;
}
/**
@@ -272,10 +281,47 @@ public enum GeodeticObjects {
}
/**
- * Returns the two-dimensional geographic CRS associated to this geodetic object.
- * The coordinate system axes will be in (<var>latitude</var>, <var>longitude</var>) order
- * oriented toward {@linkplain AxisDirection#NORTH North} and {@linkplain AxisDirection#EAST East}
- * respectively, with units in degrees.
+ * Returns a two-dimensional geographic CRS with axes in the non-standard but computationally convenient
+ * (<var>longitude</var>, <var>latitude</var>) order. The coordinate system axes will be oriented toward
+ * {@linkplain AxisDirection#EAST East} and {@linkplain AxisDirection#NORTH North} respectively, with units
+ * in degrees. The following table summarizes the coordinate reference systems known to this class,
+ * together with an enumeration value that can be used for fetching that CRS:
+ *
+ * <blockquote><table class="sis">
+ * <tr><th>Name or alias</th> <th>Enum</th> <th>Code</th></tr>
+ * <tr><td>ED50</td> <td>{@link #ED50}</td> <td></td></tr>
+ * <tr><td>ETRS89</td> <td>{@link #ETRS89}</td> <td></td></tr>
+ * <tr><td>NAD27</td> <td>{@link #NAD27}</td> <td></td></tr>
+ * <tr><td>NAD83</td> <td>{@link #NAD83}</td> <td></td></tr>
+ * <tr><td>GRS 1980 Authalic Sphere</td> <td>{@link #SPHERE}</td> <td></td></tr>
+ * <tr><td>WGS 72</td> <td>{@link #WGS72}</td> <td></td></tr>
+ * <tr><td>WGS 84</td> <td>{@link #WGS84}</td> <td>CRS:84</td></tr>
+ * </table></blockquote>
+ *
+ * @return The geographic CRS with non-standard (<var>longitude</var>, <var>latitude</var>) axis order.
+ *
+ * @see DefaultGeographicCRS#forConvention(AxesConvention)
+ * @see AxesConvention#NORMALIZED
+ */
+ public GeographicCRS normalizedGeographic() {
+ GeographicCRS object = normalized;
+ if (object == null) {
+ DefaultGeographicCRS crs = DefaultGeographicCRS.castOrCopy(geographic());
+ crs = crs.forConvention(AxesConvention.RIGHT_HANDED); // Equivalent to NORMALIZED in our cases, but faster.
+ synchronized (this) {
+ object = normalized;
+ if (object == null) {
+ normalized = object = crs;
+ }
+ }
+ }
+ return object;
+ }
+
+ /**
+ * Returns the two-dimensional geographic CRS with axes in the standard (<var>latitude</var>, <var>longitude</var>)
+ * order. The coordinate system axes will be oriented toward {@linkplain AxisDirection#NORTH North} and
+ * {@linkplain AxisDirection#EAST East} respectively, with units in degrees.
* The following table summarizes the coordinate reference systems known to this class,
* together with an enumeration value that can be used for fetching that CRS:
*
@@ -290,7 +336,7 @@ public enum GeodeticObjects {
* <tr><td>WGS 84</td> <td>{@link #WGS84}</td> <td>4326</td></tr>
* </table></blockquote>
*
- * @return The geographic CRS associated to this constant.
+ * @return The geographic CRS with standard (<var>latitude</var>, <var>longitude</var>) axis order.
*
* @see org.apache.sis.referencing.crs.DefaultGeographicCRS
* @see CRSAuthorityFactory#createGeographicCRS(String)
@@ -303,7 +349,7 @@ public enum GeodeticObjects {
if (object == null) {
final CRSAuthorityFactory factory = StandardObjects.crsFactory();
if (factory != null) try {
- cached = object = factory.createGeographicCRS(String.valueOf(crs));
+ cached = object = factory.createGeographicCRS(String.valueOf(geographic));
return object;
} catch (FactoryException e) {
StandardObjects.failure(this, "geographic", e);
@@ -319,7 +365,8 @@ public enum GeodeticObjects {
} else {
cs = WGS84.geographic().getCoordinateSystem();
}
- object = StandardDefinitions.createGeographicCRS(crs, datum(), cs);
+ object = StandardDefinitions.createGeographicCRS(geographic, datum(), cs);
+ cached = object;
}
}
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -28,6 +28,7 @@ import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.referencing.operation.CoordinateOperation;
import org.apache.sis.util.Static;
import org.apache.sis.util.CharSequences;
@@ -61,16 +62,37 @@ public final class IdentifiedObjects ext
/**
* Returns the information provided in the specified identified object as a map of properties.
- * The returned map contains keys declared in the {@link IdentifiedObject} interface, for example
- * {@link IdentifiedObject#NAME_KEY}. The values are obtained by calls to the methods associated
- * to each key, for example {@link IdentifiedObject#getName()} for the {@code NAME_KEY}.
+ * The returned map contains the following entries for each key not contained in the {@code excludes} list
+ * and for which the corresponding method returns a non-null and non-empty value.
+ *
+ * <table class="sis">
+ * <tr><th>Key</th> <th>Value</th></tr>
+ * <tr><td>{@value org.opengis.referencing.IdentifiedObject#NAME_KEY}</td>
+ * <td>{@link IdentifiedObject#getName()}</td></tr>
+ * <tr><td>{@value org.opengis.referencing.IdentifiedObject#ALIAS_KEY}</td>
+ * <td>{@link IdentifiedObject#getAlias()}</td></tr>
+ * <tr><td>{@value org.opengis.referencing.IdentifiedObject#IDENTIFIERS_KEY}</td>
+ * <td>{@link IdentifiedObject#getIdentifiers()}</td></tr>
+ * <tr><td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
+ * <td>{@link IdentifiedObject#getRemarks()}</td></tr>
+ * <tr><td>{@value org.opengis.referencing.operation.CoordinateOperation#SCOPE_KEY}</td>
+ * <td>{@link CoordinateOperation#getScope()} (also in datum and reference systems)</td></tr>
+ * <tr><td>{@value org.opengis.referencing.operation.CoordinateOperation#DOMAIN_OF_VALIDITY_KEY}</td>
+ * <td>{@link CoordinateOperation#getDomainOfValidity()} (also in datum and reference systems)</td></tr>
+ * <tr><td>{@value org.opengis.referencing.operation.CoordinateOperation#OPERATION_VERSION_KEY}</td>
+ * <td>{@link CoordinateOperation#getOperationVersion()}</td></tr>
+ * <tr><td>{@value org.opengis.referencing.operation.CoordinateOperation#COORDINATE_OPERATION_ACCURACY_KEY}</td>
+ * <td>{@link CoordinateOperation#getCoordinateOperationAccuracy()}</td></tr>
+ * </table>
*
* @param object The identified object to view as a properties map.
+ * @param excludes The keys of properties to exclude from the map.
* @return An view of the identified object as an immutable map.
*/
- public static Map<String,?> getProperties(final IdentifiedObject object) {
+ public static Map<String,?> getProperties(final IdentifiedObject object, final String... excludes) {
ensureNonNull("object", object);
- return new Properties(object);
+ ensureNonNull("excludes", excludes);
+ return new Properties(object, excludes);
}
/**
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/Properties.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -55,7 +55,7 @@ final class Properties extends AbstractM
/**
* The keys to search for. The index of each element in this array must matches the index searched
- * by {@link #get(IdentifiedObject, int)}. In other words, this array performs the reverse mapping
+ * by {@link #getAt(IdentifiedObject, int)}. In other words, this array performs the reverse mapping
* of {@link #INDICES}.
*/
private static final String[] KEYS = {
@@ -70,7 +70,7 @@ final class Properties extends AbstractM
};
/**
- * The mapping from key names to the index expected by the {@link #get(IdentifiedObject, int)} method.
+ * The mapping from key names to the index expected by the {@link #getAt(IdentifiedObject, int)} method.
* This map shall not be modified after construction (for multi-thread safety without synchronization).
*/
private static final Map<String,Integer> INDICES = new HashMap<String,Integer>(16);
@@ -83,102 +83,116 @@ final class Properties extends AbstractM
}
/**
+ * The object where all properties come from.
+ */
+ final IdentifiedObject object;
+
+ /**
+ * The bitmask of properties to exclude.
+ */
+ final int excludeMask;
+
+ /**
+ * Creates new properties from the specified identified object.
+ */
+ Properties(final IdentifiedObject object, final String[] excludes) {
+ this.object = object;
+ int excludeMask = 0;
+ for (final String exclude : excludes) {
+ final Integer i = INDICES.get(exclude);
+ if (i != null) {
+ excludeMask |= (1 << i);
+ }
+ }
+ this.excludeMask = excludeMask;
+ }
+
+ /**
* Returns the value to which this map maps the specified index.
* Returns null if the map contains no mapping for the given index.
*
- * @param object The object from which to get the property value.
- * @param key The property index, as one of the values in the {@link #INDICES} map.
+ * @param key The property index, as one of the values in the {@link #INDICES} map.
*/
- private static Object get(final IdentifiedObject object, final int key) {
- switch (key) {
- case 0: {
- return object.getName();
- }
- case 1: {
- final Collection<ReferenceIdentifier> c = object.getIdentifiers();
- if (c != null) {
- final int size = c.size();
- if (size != 0) {
- return c.toArray(new ReferenceIdentifier[size]);
+ final Object getAt(final int key) {
+ if ((excludeMask & (1 << key)) == 0) {
+ switch (key) {
+ case 0: {
+ return object.getName();
+ }
+ case 1: {
+ final Collection<ReferenceIdentifier> c = object.getIdentifiers();
+ if (c != null) {
+ final int size = c.size();
+ if (size != 0) {
+ return c.toArray(new ReferenceIdentifier[size]);
+ }
}
+ break;
}
- break;
- }
- case 2: {
- final Collection<GenericName> c = object.getAlias();
- if (c != null) {
- final int size = c.size();
- if (size != 0) {
- return c.toArray(new GenericName[size]);
+ case 2: {
+ final Collection<GenericName> c = object.getAlias();
+ if (c != null) {
+ final int size = c.size();
+ if (size != 0) {
+ return c.toArray(new GenericName[size]);
+ }
}
+ break;
}
- break;
- }
- case 3: {
- return object.getRemarks();
- }
- case 4: {
- if (object instanceof ReferenceSystem) {
- return ((ReferenceSystem) object).getScope();
- } else if (object instanceof Datum) {
- return ((Datum) object).getScope();
- } else if (object instanceof CoordinateOperation) {
- return ((CoordinateOperation) object).getScope();
+ case 3: {
+ return object.getRemarks();
}
- break;
- }
- case 5: {
- if (object instanceof ReferenceSystem) {
- return ((ReferenceSystem) object).getDomainOfValidity();
- } else if (object instanceof Datum) {
- return ((Datum) object).getDomainOfValidity();
- } else if (object instanceof CoordinateOperation) {
- return ((CoordinateOperation) object).getDomainOfValidity();
+ case 4: {
+ if (object instanceof ReferenceSystem) {
+ return ((ReferenceSystem) object).getScope();
+ } else if (object instanceof Datum) {
+ return ((Datum) object).getScope();
+ } else if (object instanceof CoordinateOperation) {
+ return ((CoordinateOperation) object).getScope();
+ }
+ break;
}
- break;
- }
- case 6: {
- if (object instanceof CoordinateOperation) {
- return ((CoordinateOperation) object).getOperationVersion();
+ case 5: {
+ if (object instanceof ReferenceSystem) {
+ return ((ReferenceSystem) object).getDomainOfValidity();
+ } else if (object instanceof Datum) {
+ return ((Datum) object).getDomainOfValidity();
+ } else if (object instanceof CoordinateOperation) {
+ return ((CoordinateOperation) object).getDomainOfValidity();
+ }
+ break;
}
- break;
- }
- case 7: {
- if (object instanceof CoordinateOperation) {
- final Collection<PositionalAccuracy> c = ((CoordinateOperation) object).getCoordinateOperationAccuracy();
- if (c != null) {
- final int size = c.size();
- if (size != 0) {
- return c.toArray(new PositionalAccuracy[size]);
+ case 6: {
+ if (object instanceof CoordinateOperation) {
+ return ((CoordinateOperation) object).getOperationVersion();
+ }
+ break;
+ }
+ case 7: {
+ if (object instanceof CoordinateOperation) {
+ final Collection<PositionalAccuracy> c = ((CoordinateOperation) object).getCoordinateOperationAccuracy();
+ if (c != null) {
+ final int size = c.size();
+ if (size != 0) {
+ return c.toArray(new PositionalAccuracy[size]);
+ }
}
}
+ break;
}
- break;
+ default: throw new AssertionError(key);
}
- default: throw new AssertionError(key);
}
return null;
}
/**
- * The object where all properties come from.
- */
- final IdentifiedObject object;
-
- /**
- * Creates new properties from the specified identified object.
- */
- Properties(final IdentifiedObject object) {
- this.object = object;
- }
-
- /**
* Returns {@code false} if this map contains at least one element, or {@code true} otherwise.
*/
@Override
public boolean isEmpty() {
for (int i=0; i<KEYS.length; i++) {
- if (get(object, i) != null) {
+ if (getAt(i) != null) {
return false;
}
}
@@ -192,7 +206,7 @@ final class Properties extends AbstractM
public int size() {
int n = 0;
for (int i=0; i<KEYS.length; i++) {
- if (get(object, i) != null) {
+ if (getAt(i) != null) {
n++;
}
}
@@ -214,7 +228,7 @@ final class Properties extends AbstractM
@Override
public Object get(final Object key) {
final Integer i = INDICES.get(key);
- return (i != null) ? get(object, i) : null;
+ return (i != null) ? getAt(i) : null;
}
/**
@@ -248,19 +262,14 @@ final class Properties extends AbstractM
/** Iterates over the {@link #KEYS}, returning only the entry having a non-null value. */
@Override
public Iterator<Entry<String, Object>> iterator() {
- return new Iter(object);
+ return new Iter();
}
}
/**
* The iterator returned by {@link EntrySet#iterator()}.
*/
- private static final class Iter implements Iterator<Entry<String,Object>> {
- /**
- * A copy of the {@link Properties#object} reference.
- */
- private final IdentifiedObject object;
-
+ private final class Iter implements Iterator<Entry<String,Object>> {
/**
* Index of the next element to return.
*/
@@ -272,10 +281,9 @@ final class Properties extends AbstractM
private Object value;
/**
- * Creates a new iterator wrapping the given object.
+ * Creates a new iterator.
*/
- Iter(final IdentifiedObject object) {
- this.object = object;
+ Iter() {
}
/**
@@ -287,7 +295,7 @@ final class Properties extends AbstractM
if (nextIndex == KEYS.length) {
return false;
}
- value = get(object, nextIndex++);
+ value = getAt(nextIndex++);
}
return true;
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -17,6 +17,7 @@
package org.apache.sis.referencing.crs;
import java.util.Map;
+import java.util.EnumMap;
import javax.measure.unit.Unit;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlRootElement;
@@ -29,6 +30,8 @@ import org.opengis.referencing.crs.Singl
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.cs.AbstractCS;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.io.wkt.Formatter;
@@ -91,13 +94,21 @@ public class AbstractCRS extends Abstrac
* The coordinate system.
*
* <p><b>Consider this field as final!</b>
- * This field is modified only at unmarshalling time by {@link #setCoordinateSystem(CoordinateSystem)}</p>
+ * This field is modified only at unmarshalling time by {@link #setCoordinateSystem(String, CoordinateSystem)}</p>
*
* @see #getCoordinateSystem()
*/
private CoordinateSystem coordinateSystem;
/**
+ * Other coordinate systems derived from this coordinate systems for other axes conventions.
+ * Created only when first needed.
+ *
+ * @see #forConvention(AxesConvention)
+ */
+ private transient Map<AxesConvention,AbstractCRS> derived;
+
+ /**
* Constructs a new object in which every attributes are set to a null value.
* <strong>This is not a valid object.</strong> This constructor is strictly
* reserved to JAXB, which will assign values to the fields using reflexion.
@@ -167,6 +178,8 @@ public class AbstractCRS extends Abstrac
* <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
*
* @param crs The coordinate reference system to copy.
+ *
+ * @see #castOrCopy(CoordinateReferenceSystem)
*/
protected AbstractCRS(final CoordinateReferenceSystem crs) {
super(crs);
@@ -174,6 +187,40 @@ public class AbstractCRS extends Abstrac
}
/**
+ * Returns a SIS coordinate reference system implementation with the values of the given arbitrary implementation.
+ * This method performs the first applicable actions in the following choices:
+ *
+ * <ul>
+ * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
+ * <li>Otherwise if the given object is is an instance of
+ * {@link org.opengis.referencing.crs.GeodeticCRS} (including the
+ * {@link org.opengis.referencing.crs.GeographicCRS} and
+ * {@link org.opengis.referencing.crs.GeocentricCRS} subtypes),
+ * {@link org.opengis.referencing.crs.VerticalCRS},
+ * {@link org.opengis.referencing.crs.TemporalCRS},
+ * {@link org.opengis.referencing.crs.EngineeringCRS},
+ * {@link org.opengis.referencing.crs.ImageCRS} or
+ * {@link org.opengis.referencing.cs.CompoundCRS},
+ * then this method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.
+ * Note that if the given object implements more than one of the above-cited interfaces,
+ * then the {@code castOrCopy(…)} method to be used is unspecified.</li>
+ * <li>Otherwise if the given object is already an instance of
+ * {@code AbstractCRS}, then it is returned unchanged.</li>
+ * <li>Otherwise a new {@code AbstractCRS} instance is created using the
+ * {@linkplain #AbstractCRS(CoordinateReferenceSystem) copy constructor}
+ * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other
+ * properties contained in the given object are not recursively copied.</li>
+ * </ul>
+ *
+ * @param object The object to get as a SIS implementation, or {@code null} if none.
+ * @return A SIS implementation containing the values of the given object (may be the
+ * given object itself), or {@code null} if the argument was null.
+ */
+ public static AbstractCRS castOrCopy(final CoordinateReferenceSystem object) {
+ return SubTypes.castOrCopy(object);
+ }
+
+ /**
* Returns the GeoAPI interface implemented by this class.
* The default implementation returns {@code CoordinateReferenceSystem.class}.
* Subclasses implementing a more specific GeoAPI interface shall override this method.
@@ -243,8 +290,60 @@ public class AbstractCRS extends Abstrac
}
/**
+ * Returns the map of cached CRS for axes conventions.
+ * This method shall be invoked in a synchronized block.
+ */
+ final Map<AxesConvention,AbstractCRS> derived() {
+ assert Thread.holdsLock(this);
+ if (derived == null) {
+ derived = new EnumMap<AxesConvention,AbstractCRS>(AxesConvention.class);
+ }
+ return derived;
+ }
+
+ /**
+ * Returns a coordinate reference system equivalent to this one but with axes rearranged according the given
+ * convention. If this CRS is already compatible with the given convention, then this method returns {@code this}.
+ *
+ * @param convention The axes convention for which a coordinate reference system is desired.
+ * @return A coordinate reference system compatible with the given convention (may be {@code this}).
+ *
+ * @see AbstractCS#forConvention(AxesConvention)
+ */
+ public synchronized AbstractCRS forConvention(final AxesConvention convention) {
+ ensureNonNull("convention", convention);
+ final Map<AxesConvention,AbstractCRS> derived = derived();
+ AbstractCRS crs = derived.get(convention);
+ if (crs == null) {
+ final AbstractCS cs = AbstractCS.castOrCopy(coordinateSystem);
+ final AbstractCS candidate = cs.forConvention(convention);
+ if (candidate == cs) {
+ crs = this;
+ } else {
+ crs = createSameType(IdentifiedObjects.getProperties(this, IDENTIFIERS_KEY), candidate);
+ for (final AbstractCRS existing : derived.values()) {
+ if (crs.equals(existing)) {
+ crs = existing;
+ break;
+ }
+ }
+ }
+ derived.put(convention, crs);
+ }
+ return crs;
+ }
+
+ /**
+ * Returns a coordinate reference system of the same type than this CRS but with different axes.
+ * This method shall be overridden by all {@code AbstractCRS} subclasses in this package.
+ */
+ AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ return new AbstractCRS(properties, cs);
+ }
+
+ /**
* Returns the unit used for all axis, or {@code null} if not all axis uses the same unit.
- * This method is often used for formatting according Well Know Text (WKT) version 1.
+ * This method is often used for formatting according Well Known Text (WKT) version 1.
*/
final Unit<?> getUnit() {
return ReferencingUtilities.getUnit(coordinateSystem);
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -28,8 +28,10 @@ import org.opengis.referencing.crs.Singl
import org.opengis.referencing.crs.CompoundCRS;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.cs.CoordinateSystem;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.cs.DefaultCompoundCS;
import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.internal.referencing.ReferencingUtilities;
import org.apache.sis.internal.util.UnmodifiableArrayList;
import org.apache.sis.util.collection.CheckedContainer;
@@ -306,6 +308,40 @@ public class DefaultCompoundCRS extends
}
/**
+ * {@inheritDoc}
+ *
+ * @return {@inheritDoc}
+ */
+ @Override
+ public synchronized DefaultCompoundCRS forConvention(final AxesConvention convention) {
+ ensureNonNull("convention", convention);
+ final Map<AxesConvention,AbstractCRS> derived = derived();
+ DefaultCompoundCRS crs = (DefaultCompoundCRS) derived.get(convention);
+ if (crs == null) {
+ crs = this;
+ boolean changed = false;
+ final CoordinateReferenceSystem[] components = new CoordinateReferenceSystem[singles.size()];
+ for (int i=0; i<components.length; i++) {
+ CoordinateReferenceSystem component = singles.get(i);
+ AbstractCRS m = castOrCopy(component);
+ if (m != (m = m.forConvention(convention))) {
+ component = m;
+ changed = true;
+ }
+ components[i] = component;
+ }
+ if (changed) {
+ if (convention == AxesConvention.NORMALIZED) {
+ Arrays.sort(components, SubTypes.BY_TYPE); // This array typically has less than 4 elements.
+ }
+ crs = new DefaultCompoundCRS(IdentifiedObjects.getProperties(this, IDENTIFIERS_KEY), components);
+ }
+ derived.put(convention, crs);
+ }
+ return crs;
+ }
+
+ /**
* Compares this coordinate reference system with the specified object for equality.
*
* @param object The object to compare to {@code this}.
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -30,6 +30,7 @@ import org.opengis.referencing.cs.PolarC
import org.opengis.referencing.cs.SphericalCS;
import org.opengis.referencing.cs.UserDefinedCS;
import org.opengis.referencing.datum.EngineeringDatum;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.io.wkt.Formatter;
@@ -233,6 +234,24 @@ public class DefaultEngineeringCRS exten
private void setUserDefinedCS(final UserDefinedCS cs) {super.setCoordinateSystem("userDefinedCS", cs);}
/**
+ * {@inheritDoc}
+ *
+ * @return {@inheritDoc}
+ */
+ @Override
+ public DefaultEngineeringCRS forConvention(final AxesConvention convention) {
+ return (DefaultEngineeringCRS) super.forConvention(convention);
+ }
+
+ /**
+ * Returns a coordinate reference system of the same type than this CRS but with different axes.
+ */
+ @Override
+ final AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ return new DefaultEngineeringCRS(properties, datum, cs);
+ }
+
+ /**
* Formats the inner part of a <cite>Well Known Text</cite> (WKT)</a> element.
*
* @param formatter The formatter to use.
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -18,13 +18,14 @@ package org.apache.sis.referencing.crs;
import java.util.Map;
import javax.xml.bind.annotation.XmlTransient;
+import javax.measure.unit.Unit;
import org.opengis.referencing.cs.CartesianCS;
import org.opengis.referencing.cs.SphericalCS;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.crs.GeocentricCRS;
import org.opengis.referencing.datum.GeodeticDatum;
-import javax.measure.unit.Unit;
import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.AbstractReferenceSystem;
@@ -64,6 +65,17 @@ public class DefaultGeocentricCRS extend
}
/**
+ * For {@link #createSameType(Map, CoordinateSystem)} usage only.
+ * This constructor does not verify the coordinate system type.
+ */
+ private DefaultGeocentricCRS(final Map<String,?> properties,
+ final GeodeticDatum datum,
+ final CoordinateSystem cs)
+ {
+ super(properties, datum, cs);
+ }
+
+ /**
* Creates a coordinate reference system from the given properties, datum and coordinate system.
* The properties given in argument follow the same rules than for the
* {@linkplain AbstractReferenceSystem#AbstractReferenceSystem(Map) super-class constructor}.
@@ -180,6 +192,24 @@ public class DefaultGeocentricCRS extend
}
/**
+ * {@inheritDoc}
+ *
+ * @return {@inheritDoc}
+ */
+ @Override
+ public DefaultGeocentricCRS forConvention(final AxesConvention convention) {
+ return (DefaultGeocentricCRS) super.forConvention(convention);
+ }
+
+ /**
+ * Returns a coordinate reference system of the same type than this CRS but with different axes.
+ */
+ @Override
+ final AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ return new DefaultGeocentricCRS(properties, super.getDatum(), cs);
+ }
+
+ /**
* Formats the inner part of a <cite>Well Known Text</cite> (WKT)</a> element.
*
* @param formatter The formatter to use.
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -144,4 +144,13 @@ class DefaultGeodeticCRS extends Abstrac
private void setCartesianCS (final CartesianCS cs) {super.setCoordinateSystem("cartesianCS", cs);}
private void setSphericalCS (final SphericalCS cs) {super.setCoordinateSystem("sphericalCS", cs);}
private void setEllipsoidalCS(final EllipsoidalCS cs) {super.setCoordinateSystem("ellipsoidalCS", cs);}
+
+ /**
+ * Returns a coordinate reference system of the same type than this CRS but with different axes.
+ * This method shall be overridden by all {@code DefaultGeodeticCRS} subclasses in this package.
+ */
+ @Override
+ AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ return new DefaultGeodeticCRS(properties, datum, cs);
+ }
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -27,6 +27,7 @@ import org.opengis.referencing.cs.Coordi
import org.opengis.referencing.cs.EllipsoidalCS;
import org.opengis.referencing.datum.GeodeticDatum;
import org.opengis.referencing.crs.GeographicCRS;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.internal.referencing.AxisDirections;
import org.apache.sis.io.wkt.Formatter;
@@ -131,7 +132,7 @@ public class DefaultGeographicCRS extend
*
* @param crs The coordinate reference system to copy.
*
- * @see #castOrCopy(GeocentricCRS)
+ * @see #castOrCopy(GeographicCRS)
*/
protected DefaultGeographicCRS(final GeographicCRS crs) {
super(crs);
@@ -178,6 +179,24 @@ public class DefaultGeographicCRS extend
}
/**
+ * {@inheritDoc}
+ *
+ * @return {@inheritDoc}
+ */
+ @Override
+ public DefaultGeographicCRS forConvention(final AxesConvention convention) {
+ return (DefaultGeographicCRS) super.forConvention(convention);
+ }
+
+ /**
+ * Returns a coordinate reference system of the same type than this CRS but with different axes.
+ */
+ @Override
+ final AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ return new DefaultGeographicCRS(properties, super.getDatum(), (EllipsoidalCS) cs);
+ }
+
+ /**
* Returns the angular unit of the specified coordinate system.
* The preference will be given to the longitude axis, if found.
*/
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -20,10 +20,12 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.AffineCS;
import org.opengis.referencing.crs.ImageCRS;
import org.opengis.referencing.cs.CartesianCS;
import org.opengis.referencing.datum.ImageDatum;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.AbstractReferenceSystem;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -230,4 +232,22 @@ public class DefaultImageCRS extends Abs
private void setCartesianCS(final CartesianCS cs) {
super.setCoordinateSystem("cartesianCS", cs);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return {@inheritDoc}
+ */
+ @Override
+ public DefaultImageCRS forConvention(final AxesConvention convention) {
+ return (DefaultImageCRS) super.forConvention(convention);
+ }
+
+ /**
+ * Returns a coordinate reference system of the same type than this CRS but with different axes.
+ */
+ @Override
+ final AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ return new DefaultImageCRS(properties, datum, (AffineCS) cs);
+ }
}
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -23,9 +23,11 @@ import javax.xml.bind.annotation.XmlElem
import javax.xml.bind.annotation.XmlRootElement;
import javax.measure.quantity.Duration;
import javax.measure.converter.UnitConverter;
+import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.TimeCS;
import org.opengis.referencing.crs.TemporalCRS;
import org.opengis.referencing.datum.TemporalDatum;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.measure.Units;
@@ -237,6 +239,24 @@ public class DefaultTemporalCRS extends
}
/**
+ * {@inheritDoc}
+ *
+ * @return {@inheritDoc}
+ */
+ @Override
+ public DefaultTemporalCRS forConvention(final AxesConvention convention) {
+ return (DefaultTemporalCRS) super.forConvention(convention);
+ }
+
+ /**
+ * Returns a coordinate reference system of the same type than this CRS but with different axes.
+ */
+ @Override
+ final AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ return new DefaultTemporalCRS(properties, datum, (TimeCS) cs);
+ }
+
+ /**
* Convert the given value into a {@link Date} object.
* If the given value is {@link Double#NaN NaN} or infinite, then this method returns {@code null}.
*
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -20,9 +20,11 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.VerticalCS;
import org.opengis.referencing.crs.VerticalCRS;
import org.opengis.referencing.datum.VerticalDatum;
+import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.AbstractReferenceSystem;
import org.apache.sis.io.wkt.Formatter;
@@ -209,6 +211,24 @@ public class DefaultVerticalCRS extends
}
/**
+ * {@inheritDoc}
+ *
+ * @return {@inheritDoc}
+ */
+ @Override
+ public DefaultVerticalCRS forConvention(final AxesConvention convention) {
+ return (DefaultVerticalCRS) super.forConvention(convention);
+ }
+
+ /**
+ * Returns a coordinate reference system of the same type than this CRS but with different axes.
+ */
+ @Override
+ final AbstractCRS createSameType(final Map<String,?> properties, final CoordinateSystem cs) {
+ return new DefaultVerticalCRS(properties, datum, (VerticalCS) cs);
+ }
+
+ /**
* Formats the inner part of a <cite>Well Known Text</cite> (WKT)</a> element.
*
* @param formatter The formatter to use.
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java?rev=1558583&r1=1558582&r2=1558583&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java [UTF-8] Wed Jan 15 22:01:46 2014
@@ -52,6 +52,7 @@
* Some SIS implementations provide additional methods that are not part of OGC/ISO specifications:
*
* <ul>
+ * <li>{@link org.apache.sis.referencing.crs.AbstractCRS#forConvention AbstractCRS.forConvention(AxesConvention)}</li>
* <li>{@link org.apache.sis.referencing.crs.DefaultTemporalCRS#toDate(double)}</li>
* <li>{@link org.apache.sis.referencing.crs.DefaultTemporalCRS#toValue DefaultTemporalCRS.toValue(Date)}</li>
* </ul>