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/05 05:29:22 UTC
svn commit: r1555456 [1/2] - in /sis/trunk: ./
application/sis-console/src/site/resources/css/
application/sis-webapp/src/site/resources/css/
application/src/site/resources/css/
core/sis-build-helper/src/site/resources/css/ core/sis-feature/src/site/ c...
Author: desruisseaux
Date: Sun Jan 5 04:29:20 2014
New Revision: 1555456
URL: http://svn.apache.org/r1555456
Log:
Merge from the JDK6 branch.
Added:
sis/trunk/core/sis-build-helper/src/site/resources/css/site.css
- copied unchanged from r1555455, sis/branches/JDK6/core/sis-build-helper/src/site/resources/css/site.css
sis/trunk/core/sis-feature/src/site/
- copied from r1555455, sis/branches/JDK6/core/sis-feature/src/site/
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SC_VerticalCRS.java
- copied unchanged from r1555455, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SC_VerticalCRS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/
- copied from r1555455, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/
sis/trunk/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.AdapterReplacement
- copied unchanged from r1555455, sis/branches/JDK6/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.AdapterReplacement
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameterTest.java
- copied unchanged from r1555455, sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameterTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/
- copied from r1555455, sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/integration/
sis/trunk/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/CartesianCS.xml
- copied unchanged from r1555455, sis/branches/JDK6/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/CartesianCS.xml
sis/trunk/core/sis-referencing/src/test/resources/org/apache/sis/test/
- copied from r1555455, sis/branches/JDK6/core/sis-referencing/src/test/resources/org/apache/sis/test/
sis/trunk/core/src/site/resources/css/site.css
- copied unchanged from r1555455, sis/branches/JDK6/core/src/site/resources/css/site.css
sis/trunk/profiles/sis-french-profile/src/site/
- copied from r1555455, sis/branches/JDK6/profiles/sis-french-profile/src/site/
sis/trunk/profiles/src/
- copied from r1555455, sis/branches/JDK6/profiles/src/
sis/trunk/src/main/link-target/
- copied from r1555455, sis/branches/JDK6/src/main/link-target/
sis/trunk/storage/sis-shapefile/src/site/
- copied from r1555455, sis/branches/JDK6/storage/sis-shapefile/src/site/
sis/trunk/storage/sis-storage/src/site/resources/css/site.css
- copied unchanged from r1555455, sis/branches/JDK6/storage/sis-storage/src/site/resources/css/site.css
Modified:
sis/trunk/ (props changed)
sis/trunk/application/sis-console/src/site/resources/css/site.css
sis/trunk/application/sis-webapp/src/site/resources/css/site.css
sis/trunk/application/src/site/resources/css/site.css
sis/trunk/core/sis-metadata/src/site/resources/css/site.css
sis/trunk/core/sis-metadata/src/site/site.xml
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEngineeringDatum.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultImageDatum.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
sis/trunk/core/sis-referencing/src/main/resources/META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration
sis/trunk/core/sis-referencing/src/site/resources/css/site.css
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectVerifier.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/CommonAxes.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCartesianCSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCSTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/trunk/core/sis-referencing/src/test/resources/org/apache/sis/referencing/cs/EllipsoidalCS.xml
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
sis/trunk/core/sis-utility/src/site/resources/css/site.css
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/NumericsTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/math/DecimalFunctionsTest.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
sis/trunk/src/site/site.xml
sis/trunk/storage/sis-netcdf/src/site/resources/css/site.css
sis/trunk/storage/src/site/resources/css/site.css
Propchange: sis/trunk/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1554740-1555453
Merged /sis/branches/JDK6:r1554743-1555455
Modified: sis/trunk/application/sis-console/src/site/resources/css/site.css
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/site/resources/css/site.css?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/site/resources/css/site.css (original)
+++ sis/trunk/application/sis-console/src/site/resources/css/site.css Sun Jan 5 04:29:20 2014
@@ -1 +1 @@
-link ../../../../../../core/sis-build-helper/src/site/resources/css/site.css
\ No newline at end of file
+link ../../../../../../src/main/link-target/site-module.css
\ No newline at end of file
Modified: sis/trunk/application/sis-webapp/src/site/resources/css/site.css
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-webapp/src/site/resources/css/site.css?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/application/sis-webapp/src/site/resources/css/site.css (original)
+++ sis/trunk/application/sis-webapp/src/site/resources/css/site.css Sun Jan 5 04:29:20 2014
@@ -1 +1 @@
-link ../../../../../../core/sis-build-helper/src/site/resources/css/site.css
\ No newline at end of file
+link ../../../../../../src/main/link-target/site-module.css
\ No newline at end of file
Modified: sis/trunk/application/src/site/resources/css/site.css
URL: http://svn.apache.org/viewvc/sis/trunk/application/src/site/resources/css/site.css?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/application/src/site/resources/css/site.css (original)
+++ sis/trunk/application/src/site/resources/css/site.css Sun Jan 5 04:29:20 2014
@@ -1 +1 @@
-link ../../../../../core/src/site/resources/css/site.css
\ No newline at end of file
+link ../../../../../src/main/link-target/site-module-group.css
\ No newline at end of file
Modified: sis/trunk/core/sis-metadata/src/site/resources/css/site.css
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/site/resources/css/site.css?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/site/resources/css/site.css (original)
+++ sis/trunk/core/sis-metadata/src/site/resources/css/site.css Sun Jan 5 04:29:20 2014
@@ -1 +1 @@
-link ../../../../../sis-build-helper/src/site/resources/css/site.css
\ No newline at end of file
+link ../../../../../../src/main/link-target/site-module.css
\ No newline at end of file
Modified: sis/trunk/core/sis-metadata/src/site/site.xml
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/site/site.xml?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/site/site.xml (original)
+++ sis/trunk/core/sis-metadata/src/site/site.xml Sun Jan 5 04:29:20 2014
@@ -30,7 +30,7 @@
<body>
<menu name="Quick links">
<item name="Apache SIS home" href="http://sis.apache.org"/>
- <item name="Package Javadoc" href="../apidocs/org/apache/sis/metadata/iso/package-summary.html"/>
+ <item name="Package Javadoc" href="../apidocs/org/apache/sis/metadata/package-summary.html"/>
<item name="FAQ" href="http://sis.apache.org/faq.html#metadata"/>
</menu>
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NilReferencingObject.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -20,8 +20,9 @@ import java.util.Set;
import java.util.Collection;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
-import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.ReferenceSystem;
import org.opengis.referencing.ReferenceIdentifier;
+import org.opengis.metadata.extent.Extent;
import org.apache.sis.xml.NilReason;
import org.apache.sis.xml.NilObject;
import org.apache.sis.io.wkt.UnformattableObjectException;
@@ -38,7 +39,7 @@ import org.apache.sis.io.wkt.Unformattab
* @version 0.4
* @module
*/
-public final class NilReferencingObject implements NilObject, IdentifiedObject {
+public final class NilReferencingObject implements NilObject, ReferenceSystem {
/**
* The unique instance.
*/
@@ -67,6 +68,8 @@ public final class NilReferencingObject
@Override public Collection<GenericName> getAlias() {return null;}
@Override public Set<ReferenceIdentifier> getIdentifiers() {return null;}
@Override public InternationalString getRemarks() {return null;}
+ @Override public InternationalString getScope() {return null;}
+ @Override public Extent getDomainOfValidity() {return null;}
/**
* Throws the exception in all cases.
@@ -78,11 +81,4 @@ public final class NilReferencingObject
public String toWKT() throws UnformattableObjectException {
throw new UnformattableObjectException();
}
-
- /**
- * Returns the unique instance on deserialization.
- */
- private Object readResolve() {
- return INSTANCE;
- }
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -16,6 +16,8 @@
*/
package org.apache.sis.internal.referencing;
+import java.util.Collection;
+import javax.measure.unit.Unit;
import org.opengis.parameter.*;
import org.opengis.referencing.*;
import org.opengis.referencing.cs.*;
@@ -23,6 +25,7 @@ import org.opengis.referencing.crs.*;
import org.opengis.referencing.datum.*;
import org.opengis.referencing.operation.*;
import org.apache.sis.referencing.operation.matrix.MatrixSIS;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.Static;
@@ -82,6 +85,24 @@ public final class ReferencingUtilities
}
/**
+ * Returns the URN type for the given class, or {@code null} if unknown.
+ * See {@link org.apache.sis.internal.util.DefinitionURI} javadoc for a list of URN types.
+ *
+ * @param type The class for which to get the URN type.
+ * @return The URN type, or {@code null} if unknown.
+ *
+ * @see org.apache.sis.internal.util.DefinitionURI
+ */
+ public static String toURNType(final Class<?> type) {
+ for (int i=0; i<TYPES.length; i++) {
+ if (TYPES[i].isAssignableFrom(type)) {
+ return URN_TYPES[i];
+ }
+ }
+ return null;
+ }
+
+ /**
* Retrieves the value at the specified row and column of the given matrix, wrapped in a {@code Number}.
* The {@code Number} type depends on the matrix accuracy.
*
@@ -99,20 +120,84 @@ public final class ReferencingUtilities
}
/**
- * Returns the URN type for the given class, or {@code null} if unknown.
- * See {@link org.apache.sis.internal.util.DefinitionURI} javadoc for a list of URN types.
+ * Returns the unit used for all axes in the given coordinate system.
+ * If not all axes use the same unit, then this method returns {@code null}.
+ * This convenience method is often used for Well Know Text (WKT) version 1 formatting.
*
- * @param type The class for which to get the URN type.
- * @return The URN type, or {@code null} if unknown.
+ * @param cs The coordinate system for which to get the unit, or {@code null}.
+ * @return The unit for all axis in the given coordinate system, or {@code null}.
+ */
+ public static Unit<?> getUnit(final CoordinateSystem cs) {
+ Unit<?> unit = null;
+ if (cs != null) {
+ for (int i=cs.getDimension(); --i>=0;) {
+ final Unit<?> candidate = cs.getAxis(i).getUnit();
+ if (candidate != null) {
+ if (unit == null) {
+ unit = candidate;
+ } else if (!unit.equals(candidate)) {
+ return null;
+ }
+ }
+ }
+ }
+ return unit;
+ }
+
+ /**
+ * Copies all {@link SingleCRS} components from the given source to the given collection.
+ * For each {@link CompoundCRS} element found in the iteration, this method replaces the
+ * {@code CompoundCRS} by its {@linkplain CompoundCRS#getComponents() components}, which
+ * may themselves have other {@code CompoundCRS}. Those replacements are performed recursively
+ * until we obtain a flat view of CRS components.
*
- * @see org.apache.sis.internal.util.DefinitionURI
+ * @param source The collection of single or compound CRS.
+ * @param addTo Where to add the single CRS in order to obtain a flat view of {@code source}.
+ * @return {@code true} if this method found only single CRS in {@code source}, in which case {@code addTo}
+ * got the same content (assuming that {@code addTo} was empty prior this method call).
+ * @throws ClassCastException if a CRS is neither a {@link SingleCRS} or a {@link CompoundCRS}.
+ *
+ * @see org.apache.sis.referencing.CRS#getSingleComponents(CoordinateReferenceSystem)
*/
- public static String toURNType(final Class<?> type) {
- for (int i=0; i<TYPES.length; i++) {
- if (TYPES[i].isAssignableFrom(type)) {
- return URN_TYPES[i];
+ public static boolean getSingleComponents(final Iterable<? extends CoordinateReferenceSystem> source,
+ final Collection<? super SingleCRS> addTo) throws ClassCastException
+ {
+ boolean sameContent = true;
+ for (final CoordinateReferenceSystem candidate : source) {
+ if (candidate instanceof CompoundCRS) {
+ getSingleComponents(((CompoundCRS) candidate).getComponents(), addTo);
+ sameContent = false;
+ } else {
+ // Intentional CassCastException here if the candidate is not a SingleCRS.
+ addTo.add((SingleCRS) candidate);
}
}
- return null;
+ return sameContent;
+ }
+
+ /**
+ * Ensures that the given argument value is {@code false}. This method is invoked by private setter methods,
+ * which are themselves invoked by JAXB at unmarshalling time. Invoking this method from those setter methods
+ * serves two purposes:
+ *
+ * <ul>
+ * <li>Make sure that a singleton property is not defined twice in the XML document.</li>
+ * <li>Protect ourselves against changes in immutable objects outside unmarshalling. It should
+ * not be necessary since the setter methods shall not be public, but we are paranoiac.</li>
+ * <li>Be a central point where we can trace all setter methods, in case we want to improve
+ * warning or error messages in future SIS versions.</li>
+ * </ul>
+ *
+ * @param name The property name, used only in case of error message to format.
+ * @param isDefined Whether the property in the caller object is current defined.
+ * @return {@code true} if the caller can set the property.
+ * @throws IllegalStateException If {@code isDefined} is {@code true}.
+ */
+ public static boolean canSetProperty(final String name, final boolean isDefined) throws IllegalStateException {
+ if (isDefined) {
+ // Future SIS version could log a warning instead if a unmarshalling is in progress.
+ throw new IllegalStateException(Errors.format(Errors.Keys.ElementAlreadyPresent_1, name));
+ }
+ return true;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -18,10 +18,8 @@ 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.Iterator;
import java.util.Locale;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlID;
@@ -46,6 +44,7 @@ import org.apache.sis.xml.Namespaces;
import org.apache.sis.util.Deprecable;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.LenientComparable;
+import org.apache.sis.util.Classes;
import org.apache.sis.util.iso.Types;
import org.apache.sis.util.resources.Errors;
@@ -55,6 +54,7 @@ import static org.apache.sis.internal.ut
import static org.apache.sis.internal.util.CollectionsExt.nonEmpty;
import static org.apache.sis.internal.util.CollectionsExt.immutableSet;
import static org.apache.sis.internal.util.Utilities.appendUnicodeIdentifier;
+import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -117,7 +117,7 @@ import org.apache.sis.internal.jdk7.Obje
"remarks"
})
@XmlSeeAlso({
- AbstractReferenceSystem.class,
+ org.apache.sis.referencing.crs.AbstractCRS.class,
org.apache.sis.referencing.datum.AbstractDatum.class,
org.apache.sis.referencing.datum.DefaultEllipsoid.class,
org.apache.sis.referencing.datum.DefaultPrimeMeridian.class,
@@ -159,7 +159,7 @@ public class AbstractIdentifiedObject ex
* Alternatively an identifier by which this object can be referenced.
*
* <p><b>Consider this field as final!</b>
- * This field is modified only at unmarshalling time by {@link #setIdentifier(ReferenceIdentifier)}</p>
+ * This field is modified only at unmarshalling time by {@link #setIdentifier(Code)}</p>
*
* @see #getIdentifiers()
* @see #getIdentifier()
@@ -355,6 +355,29 @@ public class AbstractIdentifiedObject ex
}
/**
+ * Returns the GeoAPI interface implemented by this class.
+ * This information is part of the data compared by {@link #equals(Object, ComparisonMode)}.
+ *
+ * <p>The default implementation returns {@code IdentifiedObject.class}.
+ * Subclasses implementing a more specific GeoAPI interface shall override this method.</p>
+ *
+ * {@section Invariants}
+ * The following invariants must hold for all {@code AbstractIdentifiedObject} instances:
+ * <ul>
+ * <li><code>getInterface().{@linkplain Class#isInstance(Object) isInstance}(this)</code>
+ * shall return {@code true}.</li>
+ * <li>If {@code A.getClass() == B.getClass()} is {@code true}, then
+ * {@code A.getInterface() == B.getInterface()} shall be {@code true}.
+ * Note that the converse does not need to hold.</li>
+ * </ul>
+ *
+ * @return The GeoAPI interface implemented by this class.
+ */
+ public Class<? extends IdentifiedObject> getInterface() {
+ return IdentifiedObject.class;
+ }
+
+ /**
* The {@code gml:id}, which is mandatory. The current implementation searches for the first identifier,
* regardless its authority. If no identifier is found, then the name is used.
* If no name is found (which should not occur for valid objects), then this method returns {@code null}.
@@ -425,7 +448,7 @@ public class AbstractIdentifiedObject ex
private void setIdentifier(final Code identifier) {
if (identifier != null) {
final ReferenceIdentifier id = identifier.getIdentifier();
- if (id != null) {
+ if (id != null && canSetProperty("identifier", identifiers != null)) {
identifiers = Collections.singleton(id);
}
}
@@ -600,13 +623,17 @@ public class AbstractIdentifiedObject ex
* The strictness level is controlled by the second argument:
*
* <ul>
- * <li>If {@code mode} is {@link ComparisonMode#STRICT STRICT}, then all available properties
- * are compared including {@linkplain #getName() name}, {@linkplain #getRemarks() remarks},
- * {@linkplain #getIdentifiers() identifiers code}, <i>etc.</i></li>
+ * <li>If {@code mode} is {@link ComparisonMode#STRICT STRICT}, then this method verifies if the two
+ * objects are of the same {@linkplain #getClass() class} and compares all public properties,
+ * including SIS-specific (non standard) properties.</li>
+ * <li>If {@code mode} is {@link ComparisonMode#BY_CONTRACT BY_CONTRACT}, then this method verifies if the two
+ * objects implement the same {@linkplain #getInterface() GeoAPI interface} and compares all properties
+ * defined by that interface ({@linkplain #getName() name}, {@linkplain #getRemarks() remarks},
+ * {@linkplain #getIdentifiers() identifiers}, <i>etc</i>).</li>
* <li>If {@code mode} is {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA},
* then this method compares only the properties needed for computing transformations.
* In other words, {@code sourceCRS.equals(targetCRS, IGNORE_METADATA)} returns {@code true}
- * if the transformation from {@code sourceCRS} to {@code targetCRS} is likely to be the
+ * if the transformation from {@code sourceCRS} to {@code targetCRS} would be the
* identity transform, no matter what {@link #getName()} said.</li>
* </ul>
*
@@ -622,9 +649,7 @@ public class AbstractIdentifiedObject ex
* See {@link #isHeuristicMatchForName(String)} for more information.
*
* @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
+ * @param mode The strictness level of the comparison.
* @return {@code true} if both objects are equal.
*
* @see #computeHashCode()
@@ -661,7 +686,7 @@ public class AbstractIdentifiedObject ex
Objects.equals(remarks, that.remarks);
}
case BY_CONTRACT: {
- if (!(object instanceof IdentifiedObject)) {
+ if (!implementsSameInterface(object)) {
return false;
}
final IdentifiedObject that = (IdentifiedObject) object;
@@ -673,7 +698,7 @@ public class AbstractIdentifiedObject ex
case IGNORE_METADATA:
case APPROXIMATIVE:
case DEBUG: {
- return (object instanceof IdentifiedObject);
+ return implementsSameInterface(object);
}
default: {
throw new IllegalArgumentException(Errors.format(Errors.Keys.UnknownEnumValue_1, mode));
@@ -682,6 +707,26 @@ public class AbstractIdentifiedObject ex
}
/**
+ * Returns {@code true} if the given object implements the same GeoAPI interface than this object.
+ */
+ private boolean implementsSameInterface(final Object object) {
+ final Class<? extends IdentifiedObject> type = getInterface();
+ if (object instanceof AbstractIdentifiedObject) {
+ return ((AbstractIdentifiedObject) object).getInterface() == type;
+ }
+ /*
+ * Fallback for non-SIS implementations.
+ */
+ if (type.isInstance(object)) {
+ final Class<? extends IdentifiedObject>[] t = Classes.getLeafInterfaces(object.getClass(), type);
+ if (t.length == 1 && t[0] == type) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Compares the specified object with this object for equality.
* This method is implemented as below (omitting assertions):
*
@@ -733,7 +778,8 @@ public class AbstractIdentifiedObject ex
* Invoked by {@link #hashCode()} for computing the hash code when first needed.
* This method is invoked at most once in normal execution, or an arbitrary amount of times if Java
* assertions are enabled. The hash code value shall never change during the whole lifetime of this
- * object.
+ * object in a JVM. The hash code value does not need to be the same in two different executions of
+ * the JVM.
*
* {@section Overriding}
* Subclasses can override this method for using more properties in hash code calculation.
@@ -750,6 +796,6 @@ public class AbstractIdentifiedObject ex
* @return The hash code value. This value may change in any future Apache SIS version.
*/
protected long computeHashCode() {
- return Objects.hash(name, nonNull(alias), nonNull(identifiers), remarks) ^ serialVersionUID;
+ return Objects.hash(name, nonNull(alias), nonNull(identifiers), remarks) ^ getInterface().hashCode();
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -18,6 +18,7 @@ package org.apache.sis.referencing;
import java.util.Map;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
import org.opengis.referencing.ReferenceSystem;
@@ -60,6 +61,7 @@ import org.apache.sis.internal.jdk7.Obje
* @version 0.4
* @module
*/
+@XmlTransient
public class AbstractReferenceSystem extends AbstractIdentifiedObject implements ReferenceSystem {
/**
* Serial number for inter-operability with different versions.
@@ -93,21 +95,6 @@ public class AbstractReferenceSystem ext
}
/**
- * Constructs a new reference system with the same values than the specified one.
- * This copy constructor provides a way to convert an arbitrary implementation into a SIS one
- * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
- *
- * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
- *
- * @param object The reference system to copy.
- */
- public AbstractReferenceSystem(final ReferenceSystem object) {
- super(object);
- domainOfValidity = object.getDomainOfValidity();
- scope = object.getScope();
- }
-
- /**
* Constructs a reference system from the given properties.
* The properties given in argument follow the same rules than for the
* {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
@@ -163,6 +150,33 @@ public class AbstractReferenceSystem ext
}
/**
+ * Constructs a new reference system with the same values than the specified one.
+ * This copy constructor provides a way to convert an arbitrary implementation into a SIS one
+ * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
+ *
+ * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
+ *
+ * @param object The reference system to copy.
+ */
+ protected AbstractReferenceSystem(final ReferenceSystem object) {
+ super(object);
+ domainOfValidity = object.getDomainOfValidity();
+ scope = object.getScope();
+ }
+
+ /**
+ * Returns the GeoAPI interface implemented by this class.
+ * The default implementation returns {@code ReferenceSystem.class}.
+ * Subclasses implementing a more specific GeoAPI interface shall override this method.
+ *
+ * @return The GeoAPI interface implemented by this class.
+ */
+ @Override
+ public Class<? extends ReferenceSystem> getInterface() {
+ return ReferenceSystem.class;
+ }
+
+ /**
* Returns the region or timeframe in which this reference system is valid,
* or {@code null} if unspecified.
*
@@ -201,7 +215,7 @@ public class AbstractReferenceSystem ext
*/
@Override
public boolean equals(final Object object, final ComparisonMode mode) {
- if (!(object instanceof ReferenceSystem && super.equals(object, mode))) {
+ if (!super.equals(object, mode)) {
return false;
}
switch (mode) {
@@ -223,7 +237,7 @@ public class AbstractReferenceSystem ext
}
/**
- * Invoked by {@link #hashCode()} for computing the hash code when first needed.
+ * Invoked by {@code hashCode()} for computing the hash code when first needed.
* See {@link org.apache.sis.referencing.AbstractIdentifiedObject#computeHashCode()}
* for more information.
*
@@ -231,10 +245,6 @@ public class AbstractReferenceSystem ext
*/
@Override
protected long computeHashCode() {
- /*
- * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
- * differentiate this ReferenceSystem implementation from implementations of other GeoAPI interfaces.
- */
- return serialVersionUID ^ (super.computeHashCode() + Objects.hash(domainOfValidity, scope));
+ return super.computeHashCode() + Objects.hash(domainOfValidity, scope);
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -16,9 +16,16 @@
*/
package org.apache.sis.referencing;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
import org.opengis.util.FactoryException;
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.referencing.ReferencingUtilities;
+import org.apache.sis.referencing.crs.DefaultCompoundCRS;
import org.apache.sis.util.Static;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -29,7 +36,7 @@ import static org.apache.sis.util.Argume
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.4
* @module
*/
public final class CRS extends Static {
@@ -56,4 +63,66 @@ public final class CRS extends Static {
ensureNonNull("code", code);
return null;
}
+
+ /**
+ * Returns the ordered list of single coordinate reference systems for the specified CRS.
+ * This method performs the following choices:
+ *
+ * <ul>
+ * <li>If the given CRS is null, returns an empty list.</li>
+ * <li>If the given CRS is an instance of {@link SingleCRS}, returns that instance in a singleton list.</li>
+ * <li>If the given CRS is an instance of {@link CompoundCRS}, returns a flattened list of its
+ * {@linkplain DefaultCompoundCRS#getComponents() components}. Some components may themselves be
+ * other {@code CompoundCRS} instances, in which case those compound CRS are also expanded in their
+ * list of {@code SingleCRS} components.</li>
+ * <li>Otherwise throws a {@code ClassCastException}.</li>
+ * </ul>
+ *
+ * {@example Apache SIS allows 4-dimensional (<var>x</var>,<var>y</var>,<var>z</var>,<var>t</var>)
+ * coordinate reference system to be built in two different ways as shown below:
+ *
+ * <p><table class="compact">
+ * <tr><th>Hierarchical structure</th><th>Flat list</th></tr>
+ * <tr><td><blockquote>
+ * <code>CompoundCRS</code> — (<var>x</var>, <var>y</var>, <var>z</var>, <var>t</var>)<br>
+ * <code> ├─CompoundCRS</code> — (<var>x</var>, <var>y</var>, <var>z</var>)<br>
+ * <code> │ ├─ProjectedCRS</code> — (<var>x</var>, <var>y</var>)<br>
+ * <code> │ └─VerticalCRS</code> — (<var>z</var>)<br>
+ * <code> └─TemporalCRS</code> — (<var>t</var>)
+ * </blockquote></td><td><blockquote>
+ * <code>CompoundCRS</code> — (<var>x</var>, <var>y</var>, <var>z</var>, <var>t</var>)<br>
+ * <code> ├─ProjectedCRS</code> — (<var>x</var>, <var>y</var>)<br>
+ * <code> ├─VerticalCRS</code> — (<var>z</var>)<br>
+ * <code> └─TemporalCRS</code> — (<var>t</var>)
+ * </blockquote>
+ * </td></tr></table></p>
+ *
+ * This method guaranteed that the returned list is a flat one as shown on the right side.
+ * Note that such flat lists are the only one allowed by ISO/OGC standards for compound CRS.
+ * The hierarchical structure is an Apache SIS flexibility.}
+ *
+ * @param crs The coordinate reference system, or {@code null}.
+ * @return The single coordinate reference systems, or an empty list if the given CRS is {@code null}.
+ * @throws ClassCastException if a CRS is neither a {@link SingleCRS} or a {@link CompoundCRS}.
+ *
+ * @see DefaultCompoundCRS#getSingleComponents()
+ */
+ public static List<SingleCRS> getSingleComponents(final CoordinateReferenceSystem crs) {
+ final List<SingleCRS> singles;
+ if (crs == null) {
+ singles = Collections.emptyList();
+ } else if (crs instanceof CompoundCRS) {
+ if (crs instanceof DefaultCompoundCRS) {
+ singles = ((DefaultCompoundCRS) crs).getSingleComponents();
+ } else {
+ final List<CoordinateReferenceSystem> elements = ((CompoundCRS) crs).getComponents();
+ singles = new ArrayList<SingleCRS>(elements.size());
+ ReferencingUtilities.getSingleComponents(elements, singles);
+ }
+ } else {
+ // Intentional CassCastException here if the crs is not a SingleCRS.
+ singles = Collections.singletonList((SingleCRS) crs);
+ }
+ return singles;
+ }
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -23,6 +23,7 @@ import javax.measure.unit.Unit;
import javax.measure.unit.NonSI;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
@@ -68,8 +69,18 @@ import static org.apache.sis.util.Utilit
* @see org.apache.sis.referencing.crs.AbstractCRS
*/
@XmlType(name = "AbstractCoordinateSystemType")
+@XmlRootElement(name = "AbstractCoordinateSystem")
@XmlSeeAlso({
- DefaultEllipsoidalCS.class
+ DefaultAffineCS.class,
+ DefaultCartesianCS.class, // Not an AffineCS subclass in GML schema.
+ DefaultSphericalCS.class,
+ DefaultEllipsoidalCS.class,
+ DefaultCylindricalCS.class,
+ DefaultPolarCS.class,
+ DefaultLinearCS.class,
+ DefaultVerticalCS.class,
+ DefaultTimeCS.class,
+ DefaultUserDefinedCS.class
})
public class AbstractCS extends AbstractIdentifiedObject implements CoordinateSystem {
/**
@@ -94,9 +105,9 @@ public class AbstractCS extends Abstract
private final CoordinateSystemAxis[] axes;
/**
- * 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.
+ * Constructs a new object in which every attributes are set to a null or empty 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.
*/
AbstractCS() {
super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
@@ -228,6 +239,18 @@ public class AbstractCS extends Abstract
}
/**
+ * Returns the GeoAPI interface implemented by this class.
+ * The default implementation returns {@code CoordinateSystem.class}.
+ * Subclasses implementing a more specific GeoAPI interface shall override this method.
+ *
+ * @return The coordinate system interface implemented by this class.
+ */
+ @Override
+ public Class<? extends CoordinateSystem> getInterface() {
+ return CoordinateSystem.class;
+ }
+
+ /**
* Returns the number of dimensions of this coordinate system.
* This is the number of axes given at construction time.
*
@@ -261,6 +284,9 @@ public class AbstractCS extends Abstract
*/
@Override
public boolean equals(final Object object, final ComparisonMode mode) {
+ if (object == this) {
+ return true; // Slight optimization.
+ }
if (!super.equals(object, mode)) {
return false;
}
@@ -270,9 +296,6 @@ public class AbstractCS extends Abstract
return Arrays.equals(axes, ((AbstractCS) object).axes);
}
default: {
- if (!(object instanceof CoordinateSystem)) {
- return false;
- }
final CoordinateSystem that = (CoordinateSystem) object;
final int dimension = getDimension();
if (dimension != that.getDimension()) {
@@ -289,7 +312,7 @@ public class AbstractCS extends Abstract
}
/**
- * Invoked by {@link #hashCode()} for computing the hash code when first needed.
+ * Invoked by {@code hashCode()} for computing the hash code when first needed.
* See {@link org.apache.sis.referencing.AbstractIdentifiedObject#computeHashCode()}
* for more information.
*
@@ -297,11 +320,7 @@ public class AbstractCS extends Abstract
*/
@Override
protected long computeHashCode() {
- /*
- * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
- * differentiate this CoordinateSystem implementation from implementations of other GeoAPI interfaces.
- */
- return serialVersionUID ^ (super.computeHashCode() + Arrays.hashCode(axes));
+ return super.computeHashCode() + Arrays.hashCode(axes);
}
/**
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultAffineCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -18,13 +18,14 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import javax.measure.unit.Unit;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.AffineCS;
import org.opengis.referencing.cs.CartesianCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
import org.apache.sis.measure.Units;
-import org.apache.sis.util.ComparisonMode;
/**
@@ -52,6 +53,8 @@ import org.apache.sis.util.ComparisonMod
* @version 0.4
* @module
*/
+@XmlType(name = "AffineCSType")
+@XmlRootElement(name = "AffineCS")
public class DefaultAffineCS extends AbstractCS implements AffineCS {
/**
* Serial number for inter-operability with different versions.
@@ -195,19 +198,14 @@ public class DefaultAffineCS extends Abs
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The default implementation returns {@code AffineCS.class}.
+ * Subclasses implementing a more specific GeoAPI interface shall override this method.
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * @return The affine coordinate system interface implemented by this class.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof AffineCS) && super.equals(object, mode);
+ public Class<? extends AffineCS> getInterface() {
+ return AffineCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCartesianCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -17,12 +17,13 @@
package org.apache.sis.referencing.cs;
import java.util.Map;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.CartesianCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.Formulas;
import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.ComparisonMode;
/**
@@ -57,6 +58,8 @@ import org.apache.sis.util.ComparisonMod
* @version 0.4
* @module
*/
+@XmlType(name = "CartesianCSType")
+@XmlRootElement(name = "CartesianCS")
public class DefaultCartesianCS extends DefaultAffineCS implements CartesianCS {
/**
* Serial number for inter-operability with different versions.
@@ -201,19 +204,17 @@ public class DefaultCartesianCS extends
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code CartesianCS.class}.
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>CartesianCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
+ *
+ * @return {@code CartesianCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof CartesianCS) && super.equals(object, mode);
+ public Class<? extends CartesianCS> getInterface() {
+ return CartesianCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -186,9 +186,6 @@ public class DefaultCompoundCS extends A
*/
@Override
public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
if (!(object instanceof DefaultCompoundCS && super.equals(object, mode))) {
return false;
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -44,8 +44,12 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.io.wkt.Formatter;
+import static java.lang.Double.doubleToLongBits;
+import static java.lang.Double.NEGATIVE_INFINITY;
+import static java.lang.Double.POSITIVE_INFINITY;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
import static org.apache.sis.util.CharSequences.trimWhitespaces;
+import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -156,7 +160,9 @@ public class DefaultCoordinateSystemAxis
/**
* Minimal and maximal value for this axis, or negative/positive infinity if none.
*
- * Consider this field as final. It is not final only for XML unmarshalling.
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setMinimum(Double)}
+ * or {@link #setMaximum(Double)}</p>
*/
private double minimumValue, maximumValue;
@@ -177,8 +183,8 @@ public class DefaultCoordinateSystemAxis
direction = null;
unit = null;
rangeMeaning = null;
- minimumValue = Double.NEGATIVE_INFINITY;
- maximumValue = Double.POSITIVE_INFINITY;
+ minimumValue = NEGATIVE_INFINITY;
+ maximumValue = POSITIVE_INFINITY;
}
/**
@@ -244,7 +250,7 @@ public class DefaultCoordinateSystemAxis
if (!(minimumValue < maximumValue)) { // Use '!' for catching NaN
throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalRange_2, minimumValue, maximumValue));
}
- if ((minimumValue != Double.NEGATIVE_INFINITY) || (maximumValue != Double.POSITIVE_INFINITY)) {
+ if ((minimumValue != NEGATIVE_INFINITY) || (maximumValue != POSITIVE_INFINITY)) {
ensureNonNull("rangeMeaning", rangeMeaning);
} else {
rangeMeaning = null;
@@ -276,8 +282,8 @@ public class DefaultCoordinateSystemAxis
ensureNonNull("abbreviation", abbreviation);
ensureNonNull("direction", direction);
ensureNonNull("unit", unit);
- double min = Double.NEGATIVE_INFINITY;
- double max = Double.POSITIVE_INFINITY;
+ double min = NEGATIVE_INFINITY;
+ double max = POSITIVE_INFINITY;
RangeMeaning r = null;
if (Units.isAngular(unit)) {
final UnitConverter fromDegrees = NonSI.DEGREE_ANGLE.getConverterTo(unit.asType(Angle.class));
@@ -339,6 +345,21 @@ public class DefaultCoordinateSystemAxis
}
/**
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code CoordinateSystemAxis.class}.
+ *
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>CoordinateSystemAxis</code> sub-interface. Overriding possibility is left mostly
+ * for implementors who wish to extend GeoAPI with their own set of interfaces.}
+ *
+ * @return {@code CoordinateSystemAxis.class} or a user-defined sub-interface.
+ */
+ @Override
+ public Class<? extends CoordinateSystemAxis> getInterface() {
+ return CoordinateSystemAxis.class;
+ }
+
+ /**
* Returns the direction of this coordinate system axis.
* This direction is often approximate and intended to provide a human interpretable meaning to the axis.
* A {@linkplain AbstractCS coordinate system} can not contain two axes having the same direction or
@@ -396,14 +417,14 @@ public class DefaultCoordinateSystemAxis
*/
@XmlElement(name = "minimumValue")
private Double getMinimum() {
- return (minimumValue != Double.NEGATIVE_INFINITY) ? minimumValue : null;
+ return (minimumValue != NEGATIVE_INFINITY) ? minimumValue : null;
}
/**
* Invoked by JAXB at unmarshalling time for setting the minimum value.
*/
private void setMinimum(final Double value) {
- if (value != null) {
+ if (value != null && canSetProperty("minimumValue", minimumValue != NEGATIVE_INFINITY)) {
final double min = value.doubleValue();
if (min < maximumValue) {
minimumValue = min;
@@ -430,14 +451,14 @@ public class DefaultCoordinateSystemAxis
*/
@XmlElement(name = "maximumValue")
private Double getMaximum() {
- return (maximumValue != Double.POSITIVE_INFINITY) ? maximumValue : null;
+ return (maximumValue != POSITIVE_INFINITY) ? maximumValue : null;
}
/**
* Invoked by JAXB at unmarshalling time for setting the maximum value.
*/
private void setMaximum(final Double value) {
- if (value != null) {
+ if (value != null && canSetProperty("maximumValue", maximumValue != POSITIVE_INFINITY)) {
final double max = value.doubleValue();
if (max > minimumValue) {
maximumValue = max;
@@ -551,7 +572,7 @@ public class DefaultCoordinateSystemAxis
if (object == this) {
return true; // Slight optimization.
}
- if (!(object instanceof CoordinateSystemAxis && super.equals(object, mode))) {
+ if (!super.equals(object, mode)) {
return false;
}
final DefaultCoordinateSystemAxis that = castOrCopy((CoordinateSystemAxis) object);
@@ -576,8 +597,8 @@ public class DefaultCoordinateSystemAxis
if (compareMetadata) {
if (!Objects.equals(this.abbreviation, that.abbreviation) ||
!Objects.equals(this.rangeMeaning, that.rangeMeaning) ||
- Double.doubleToLongBits(minimumValue) != Double.doubleToLongBits(that.minimumValue) ||
- Double.doubleToLongBits(maximumValue) != Double.doubleToLongBits(that.maximumValue))
+ doubleToLongBits(minimumValue) != doubleToLongBits(that.minimumValue) ||
+ doubleToLongBits(maximumValue) != doubleToLongBits(that.maximumValue))
{
return false;
}
@@ -628,7 +649,7 @@ public class DefaultCoordinateSystemAxis
}
/**
- * Invoked by {@link #hashCode()} for computing the hash code when first needed.
+ * Invoked by {@code hashCode()} for computing the hash code when first needed.
* See {@link org.apache.sis.referencing.AbstractIdentifiedObject#computeHashCode()}
* for more information.
*
@@ -636,12 +657,8 @@ public class DefaultCoordinateSystemAxis
*/
@Override
protected long computeHashCode() {
- /*
- * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
- * differentiate this CoordinateSystemAxis implementation from implementations of other GeoAPI interfaces.
- */
- return serialVersionUID ^ (super.computeHashCode() + Objects.hashCode(unit) + Objects.hashCode(direction)
- + Double.doubleToLongBits(minimumValue) + 31*Double.doubleToLongBits(maximumValue));
+ return super.computeHashCode() + Objects.hashCode(unit) + Objects.hashCode(direction)
+ + doubleToLongBits(minimumValue) + 31*doubleToLongBits(maximumValue);
}
/**
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCylindricalCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -18,11 +18,12 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import javax.measure.unit.Unit;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.CylindricalCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
import org.apache.sis.measure.Units;
@@ -51,6 +52,8 @@ import org.apache.sis.measure.Units;
*
* @see DefaultPolarCS
*/
+@XmlType(name = "CylindricalCSType")
+@XmlRootElement(name = "CylindricalCS")
public class DefaultCylindricalCS extends AbstractCS implements CylindricalCS {
/**
* Serial number for inter-operability with different versions.
@@ -162,19 +165,17 @@ public class DefaultCylindricalCS extend
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code CylindricalCS.class}.
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>CylindricalCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
+ *
+ * @return {@code CylindricalCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof CylindricalCS) && super.equals(object, mode);
+ public Class<? extends CylindricalCS> getInterface() {
+ return CylindricalCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultEllipsoidalCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -24,7 +24,6 @@ import org.opengis.referencing.cs.Ellips
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
import org.apache.sis.measure.Units;
@@ -186,19 +185,17 @@ public class DefaultEllipsoidalCS extend
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code EllipsoidalCS.class}.
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>EllipsoidalCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
+ *
+ * @return {@code EllipsoidalCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof EllipsoidalCS) && super.equals(object, mode);
+ public Class<? extends EllipsoidalCS> getInterface() {
+ return EllipsoidalCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultLinearCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -18,12 +18,13 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import javax.measure.unit.Unit;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.LinearCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
import org.apache.sis.measure.Units;
-import org.apache.sis.util.ComparisonMode;
/**
@@ -50,6 +51,8 @@ import org.apache.sis.util.ComparisonMod
* @version 0.4
* @module
*/
+@XmlType(name = "LinearCSType")
+@XmlRootElement(name = "LinearCS")
public class DefaultLinearCS extends AbstractCS implements LinearCS {
/**
* Serial number for inter-operability with different versions.
@@ -155,19 +158,17 @@ public class DefaultLinearCS extends Abs
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code LinearCS.class}.
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>LinearCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
+ *
+ * @return {@code LinearCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof LinearCS) && super.equals(object, mode);
+ public Class<? extends LinearCS> getInterface() {
+ return LinearCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultPolarCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -18,12 +18,13 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import javax.measure.unit.Unit;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.PolarCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
import org.apache.sis.measure.Units;
-import org.apache.sis.util.ComparisonMode;
/**
@@ -49,6 +50,8 @@ import org.apache.sis.util.ComparisonMod
* @version 0.4
* @module
*/
+@XmlType(name = "PolarCSType")
+@XmlRootElement(name = "PolarCS")
public class DefaultPolarCS extends AbstractCS implements PolarCS {
/**
* Serial number for inter-operability with different versions.
@@ -158,19 +161,17 @@ public class DefaultPolarCS extends Abst
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code PolarCS.class}.
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>PolarCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
+ *
+ * @return {@code PolarCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof PolarCS) && super.equals(object, mode);
+ public Class<? extends PolarCS> getInterface() {
+ return PolarCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultSphericalCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -18,11 +18,12 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import javax.measure.unit.Unit;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.SphericalCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
import org.apache.sis.measure.Units;
@@ -53,6 +54,8 @@ import org.apache.sis.measure.Units;
* @version 0.4
* @module
*/
+@XmlType(name = "SphericalCSType")
+@XmlRootElement(name = "SphericalCS")
public class DefaultSphericalCS extends AbstractCS implements SphericalCS {
/**
* Serial number for inter-operability with different versions.
@@ -162,19 +165,17 @@ public class DefaultSphericalCS extends
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code SphericalCS.class}.
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>SphericalCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
+ *
+ * @return {@code SphericalCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof SphericalCS) && super.equals(object, mode);
+ public Class<? extends SphericalCS> getInterface() {
+ return SphericalCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultTimeCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -19,11 +19,12 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.TimeCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
import org.apache.sis.measure.Units;
@@ -48,7 +49,12 @@ import org.apache.sis.measure.Units;
* @since 0.4 (derived from geotk-2.0)
* @version 0.4
* @module
+ *
+ * @see org.apache.sis.referencing.crs.DefaultTemporalCRS
+ * @see org.apache.sis.referencing.datum.DefaultTemporalDatum
*/
+@XmlType(name = "TimeCSType")
+@XmlRootElement(name = "TimeCS")
public class DefaultTimeCS extends AbstractCS implements TimeCS {
/**
* Serial number for inter-operability with different versions.
@@ -152,19 +158,17 @@ public class DefaultTimeCS extends Abstr
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code TimeCS.class}.
+ *
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>TimeCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * @return {@code TimeCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof TimeCS) && super.equals(object, mode);
+ public Class<? extends TimeCS> getInterface() {
+ return TimeCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultUserDefinedCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -17,9 +17,10 @@
package org.apache.sis.referencing.cs;
import java.util.Map;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.UserDefinedCS;
import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.apache.sis.util.ComparisonMode;
/**
@@ -36,6 +37,8 @@ import org.apache.sis.util.ComparisonMod
* @version 0.4
* @module
*/
+@XmlType(name = "UserDefinedCSType")
+@XmlRootElement(name = "UserDefinedCS")
public class DefaultUserDefinedCS extends AbstractCS implements UserDefinedCS {
/**
* Serial number for inter-operability with different versions.
@@ -144,19 +147,17 @@ public class DefaultUserDefinedCS extend
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code UserDefinedCS.class}.
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>UserDefinedCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
+ *
+ * @return {@code UserDefinedCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof UserDefinedCS) && super.equals(object, mode);
+ public Class<? extends UserDefinedCS> getInterface() {
+ return UserDefinedCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultVerticalCS.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -18,11 +18,12 @@ package org.apache.sis.referencing.cs;
import java.util.Map;
import javax.measure.unit.Unit;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.referencing.cs.VerticalCS;
import org.opengis.referencing.cs.AxisDirection;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.util.ComparisonMode;
/**
@@ -60,7 +61,12 @@ import org.apache.sis.util.ComparisonMod
* @since 0.4 (derived from geotk-2.0)
* @version 0.4
* @module
+ *
+ * @see org.apache.sis.referencing.crs.DefaultVerticalCRS
+ * @see org.apache.sis.referencing.datum.DefaultVerticalDatum
*/
+@XmlType(name = "VerticalCSType")
+@XmlRootElement(name = "VerticalCS")
public class DefaultVerticalCS extends AbstractCS implements VerticalCS {
/**
* Serial number for inter-operability with different versions.
@@ -164,19 +170,17 @@ public class DefaultVerticalCS extends A
}
/**
- * Compares this coordinate system with the specified object for equality.
+ * Returns the GeoAPI interface implemented by this class.
+ * The SIS implementation returns {@code VerticalCS.class}.
+ *
+ * {@note Subclasses usually do not need to override this method since GeoAPI does not define
+ * <code>VerticalCS</code> sub-interface. Overriding possibility is left mostly for
+ * implementors who wish to extend GeoAPI with their own set of interfaces.}
*
- * @param object The object to compare to {@code this}.
- * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
- * {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
- * relevant to coordinate transformations.
- * @return {@code true} if both objects are equal.
+ * @return {@code VerticalCS.class} or a user-defined sub-interface.
*/
@Override
- public boolean equals(final Object object, final ComparisonMode mode) {
- if (object == this) {
- return true; // Slight optimization.
- }
- return (object instanceof VerticalCS) && super.equals(object, mode);
+ public Class<? extends VerticalCS> getInterface() {
+ return VerticalCS.class;
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/package-info.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -38,7 +38,7 @@
@XmlJavaTypeAdapter(CS_AxisDirection.class),
@XmlJavaTypeAdapter(CS_CoordinateSystemAxis.class),
@XmlJavaTypeAdapter(CS_RangeMeaning.class),
- @XmlJavaTypeAdapter(UnitAdapter.AsURN.class)
+ @XmlJavaTypeAdapter(UnitAdapter.ForCS.class)
})
package org.apache.sis.referencing.cs;
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1555456&r1=1555455&r2=1555456&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] Sun Jan 5 04:29:20 2014
@@ -19,8 +19,9 @@ package org.apache.sis.referencing.datum
import java.util.Date;
import java.util.Map;
import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
import org.opengis.metadata.extent.Extent;
@@ -36,6 +37,7 @@ import org.apache.sis.internal.metadata.
import static org.apache.sis.util.Utilities.deepEquals;
import static org.apache.sis.util.collection.Containers.property;
+import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
// Related to JDK7
import org.apache.sis.internal.jdk7.Objects;
@@ -67,6 +69,7 @@ import org.apache.sis.internal.jdk7.Obje
* @see org.apache.sis.referencing.crs.AbstractCRS
*/
@XmlType(name = "AbstractDatumType")
+@XmlRootElement(name = "AbstractDatum")
@XmlSeeAlso({
DefaultGeodeticDatum.class,
DefaultVerticalDatum.class,
@@ -97,7 +100,8 @@ public class AbstractDatum extends Abstr
* (e.g. 1997 for IRTF97) or merely a year (e.g. 1983 for NAD83). If the time is
* not defined, then the value is {@link Long#MIN_VALUE}.
*
- * <p>Consider this field as final. It is non-final only for the need of XML unmarshalling.</p>
+ * <p><b>Consider this field as final!</b>
+ * This field is modified only at unmarshalling time by {@link #setRealizationEpoch(Date)}</p>
*/
private long realizationEpoch;
@@ -242,6 +246,18 @@ public class AbstractDatum extends Abstr
}
/**
+ * Returns the GeoAPI interface implemented by this class.
+ * The default implementation returns {@code Datum.class}.
+ * Subclasses implementing a more specific GeoAPI interface shall override this method.
+ *
+ * @return The datum interface implemented by this class.
+ */
+ @Override
+ public Class<? extends Datum> getInterface() {
+ return Datum.class;
+ }
+
+ /**
* Returns a description of the point(s) used to anchor the datum to the Earth.
* Also known as the "origin", especially for Engineering and Image Datums.
*
@@ -286,7 +302,9 @@ public class AbstractDatum extends Abstr
* Invoked by JAXB only at unmarshalling time.
*/
private void setRealizationEpoch(final Date value) {
- realizationEpoch = MetadataUtilities.toMilliseconds(value);
+ if (value != null && canSetProperty("realizationEpoch", realizationEpoch != Long.MIN_VALUE)) {
+ realizationEpoch = value.getTime();
+ }
}
/**
@@ -371,7 +389,7 @@ public class AbstractDatum extends Abstr
*/
@Override
public boolean equals(final Object object, final ComparisonMode mode) {
- if (!(object instanceof Datum && super.equals(object, mode))) {
+ if (!super.equals(object, mode)) {
return false;
}
switch (mode) {
@@ -404,7 +422,7 @@ public class AbstractDatum extends Abstr
}
/**
- * Invoked by {@link #hashCode()} for computing the hash code when first needed.
+ * Invoked by {@code hashCode()} for computing the hash code when first needed.
* See {@link org.apache.sis.referencing.AbstractIdentifiedObject#computeHashCode()}
* for more information.
*
@@ -412,12 +430,7 @@ public class AbstractDatum extends Abstr
*/
@Override
protected long computeHashCode() {
- /*
- * The "serialVersionUID ^ …" is an arbitrary change applied to the hash code value in order to
- * differentiate this Datum implementation from implementations of other GeoAPI interfaces.
- */
- return serialVersionUID ^ (super.computeHashCode() +
- Objects.hash(anchorPoint, realizationEpoch, domainOfValidity, scope));
+ return super.computeHashCode() + Objects.hash(anchorPoint, realizationEpoch, domainOfValidity, scope);
}
/**